aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/media/Makefile4
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-rk3x.txt42
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt41
-rw-r--r--Documentation/kbuild/makefiles.txt2
-rw-r--r--Documentation/kernel-parameters.txt14
-rw-r--r--Documentation/thermal/nouveau_thermal7
-rw-r--r--MAINTAINERS13
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig20
-rw-r--r--arch/arm/boot/dts/armada-375-db.dts2
-rw-r--r--arch/arm/boot/dts/armada-385-db.dts2
-rw-r--r--arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts2
-rw-r--r--arch/arm/configs/multi_v7_defconfig1
-rw-r--r--arch/arm/configs/omap2plus_defconfig1
-rw-r--r--arch/arm/include/asm/ftrace.h2
-rw-r--r--arch/arm/mach-bcm/Kconfig7
-rw-r--r--arch/arm/mach-berlin/Kconfig6
-rw-r--r--arch/arm/mach-cns3xxx/Kconfig7
-rw-r--r--arch/arm/mach-davinci/Kconfig1
-rw-r--r--arch/arm/mach-exynos/Kconfig7
-rw-r--r--arch/arm/mach-exynos/common.h1
-rw-r--r--arch/arm/mach-exynos/exynos.c31
-rw-r--r--arch/arm/mach-exynos/platsmp.c26
-rw-r--r--arch/arm/mach-highbank/Kconfig1
-rw-r--r--arch/arm/mach-imx/Kconfig10
-rw-r--r--arch/arm/mach-integrator/Kconfig2
-rw-r--r--arch/arm/mach-integrator/impd1.c12
-rw-r--r--arch/arm/mach-keystone/Kconfig1
-rw-r--r--arch/arm/mach-moxart/Kconfig2
-rw-r--r--arch/arm/mach-mvebu/Kconfig7
-rw-r--r--arch/arm/mach-nomadik/Kconfig4
-rw-r--r--arch/arm/mach-omap2/Kconfig7
-rw-r--r--arch/arm/mach-omap2/common.h7
-rw-r--r--arch/arm/mach-prima2/Kconfig6
-rw-r--r--arch/arm/mach-qcom/Kconfig6
-rw-r--r--arch/arm/mach-s3c24xx/Kconfig2
-rw-r--r--arch/arm/mach-s3c64xx/Kconfig4
-rw-r--r--arch/arm/mach-s5p64x0/Kconfig6
-rw-r--r--arch/arm/mach-s5pc100/Kconfig3
-rw-r--r--arch/arm/mach-s5pv210/Kconfig3
-rw-r--r--arch/arm/mach-shmobile/Kconfig6
-rw-r--r--arch/arm/mach-spear/Kconfig1
-rw-r--r--arch/arm/mach-sti/Kconfig2
-rw-r--r--arch/arm/mach-tegra/Kconfig8
-rw-r--r--arch/arm/mach-u300/Kconfig6
-rw-r--r--arch/arm/mach-ux500/Kconfig7
-rw-r--r--arch/arm/mach-vexpress/Kconfig8
-rw-r--r--arch/arm/mach-vt8500/Kconfig1
-rw-r--r--arch/arm/mach-zynq/Kconfig1
-rw-r--r--arch/arm/plat-samsung/Kconfig28
-rw-r--r--arch/arm64/Kconfig3
-rw-r--r--arch/arm64/boot/dts/apm-mustang.dts4
-rw-r--r--arch/arm64/boot/dts/apm-storm.dtsi36
-rw-r--r--arch/arm64/configs/defconfig15
-rw-r--r--arch/arm64/crypto/ghash-ce-core.S92
-rw-r--r--arch/arm64/crypto/ghash-ce-glue.c5
-rw-r--r--arch/arm64/include/asm/Kbuild1
-rw-r--r--arch/arm64/include/asm/dma-mapping.h2
-rw-r--r--arch/arm64/include/asm/pgtable.h2
-rw-r--r--arch/arm64/include/uapi/asm/posix_types.h10
-rw-r--r--arch/arm64/include/uapi/asm/sigcontext.h2
-rw-r--r--arch/arm64/kernel/entry-ftrace.S2
-rw-r--r--arch/arm64/kernel/entry.S1
-rw-r--r--arch/arm64/kernel/ptrace.c32
-rw-r--r--arch/arm64/mm/init.c10
-rw-r--r--arch/ia64/hp/common/sba_iommu.c64
-rw-r--r--arch/s390/configs/default_defconfig5
-rw-r--r--arch/s390/configs/gcov_defconfig5
-rw-r--r--arch/s390/configs/performance_defconfig5
-rw-r--r--arch/s390/configs/zfcpdump_defconfig3
-rw-r--r--arch/s390/defconfig8
-rw-r--r--arch/s390/include/asm/mmu_context.h33
-rw-r--r--arch/s390/include/asm/switch_to.h4
-rw-r--r--arch/s390/include/uapi/asm/ucontext.h8
-rw-r--r--arch/s390/kernel/compat_linux.h4
-rw-r--r--arch/sparc/crypto/aes_glue.c6
-rw-r--r--arch/sparc/include/asm/atomic_32.h8
-rw-r--r--arch/sparc/include/asm/atomic_64.h18
-rw-r--r--arch/sparc/include/asm/auxio.h7
-rw-r--r--arch/sparc/include/asm/auxio_32.h6
-rw-r--r--arch/sparc/include/asm/auxio_64.h6
-rw-r--r--arch/sparc/include/asm/bitext.h6
-rw-r--r--arch/sparc/include/asm/bitops_32.h6
-rw-r--r--arch/sparc/include/asm/bitops_64.h24
-rw-r--r--arch/sparc/include/asm/btext.h2
-rw-r--r--arch/sparc/include/asm/bug.h4
-rw-r--r--arch/sparc/include/asm/cacheflush_32.h8
-rw-r--r--arch/sparc/include/asm/cacheflush_64.h24
-rw-r--r--arch/sparc/include/asm/checksum_32.h4
-rw-r--r--arch/sparc/include/asm/checksum_64.h32
-rw-r--r--arch/sparc/include/asm/cmpxchg_32.h6
-rw-r--r--arch/sparc/include/asm/cmpxchg_64.h4
-rw-r--r--arch/sparc/include/asm/cpudata.h10
-rw-r--r--arch/sparc/include/asm/cpudata_64.h5
-rw-r--r--arch/sparc/include/asm/delay_32.h4
-rw-r--r--arch/sparc/include/asm/delay_64.h4
-rw-r--r--arch/sparc/include/asm/device.h2
-rw-r--r--arch/sparc/include/asm/dma-mapping.h2
-rw-r--r--arch/sparc/include/asm/ebus_dma.h16
-rw-r--r--arch/sparc/include/asm/floppy_32.h14
-rw-r--r--arch/sparc/include/asm/floppy_64.h2
-rw-r--r--arch/sparc/include/asm/ftrace.h6
-rw-r--r--arch/sparc/include/asm/highmem.h10
-rw-r--r--arch/sparc/include/asm/hvtramp.h2
-rw-r--r--arch/sparc/include/asm/hypervisor.h325
-rw-r--r--arch/sparc/include/asm/idprom.h2
-rw-r--r--arch/sparc/include/asm/io-unit.h2
-rw-r--r--arch/sparc/include/asm/io_32.h299
-rw-r--r--arch/sparc/include/asm/io_64.h21
-rw-r--r--arch/sparc/include/asm/iommu_32.h10
-rw-r--r--arch/sparc/include/asm/iommu_64.h6
-rw-r--r--arch/sparc/include/asm/irq_32.h3
-rw-r--r--arch/sparc/include/asm/irq_64.h44
-rw-r--r--arch/sparc/include/asm/irqflags_32.h6
-rw-r--r--arch/sparc/include/asm/kdebug_64.h2
-rw-r--r--arch/sparc/include/asm/kgdb.h5
-rw-r--r--arch/sparc/include/asm/kprobes.h8
-rw-r--r--arch/sparc/include/asm/ldc.h66
-rw-r--r--arch/sparc/include/asm/leon.h54
-rw-r--r--arch/sparc/include/asm/leon_pci.h4
-rw-r--r--arch/sparc/include/asm/mc146818rtc.h5
-rw-r--r--arch/sparc/include/asm/mdesc.h32
-rw-r--r--arch/sparc/include/asm/mmu_64.h6
-rw-r--r--arch/sparc/include/asm/mmu_context_64.h24
-rw-r--r--arch/sparc/include/asm/nmi.h10
-rw-r--r--arch/sparc/include/asm/oplib_32.h68
-rw-r--r--arch/sparc/include/asm/oplib_64.h112
-rw-r--r--arch/sparc/include/asm/page.h3
-rw-r--r--arch/sparc/include/asm/page_64.h8
-rw-r--r--arch/sparc/include/asm/pci_64.h14
-rw-r--r--arch/sparc/include/asm/pcic.h8
-rw-r--r--arch/sparc/include/asm/pcr.h6
-rw-r--r--arch/sparc/include/asm/pgalloc_32.h2
-rw-r--r--arch/sparc/include/asm/pgalloc_64.h16
-rw-r--r--arch/sparc/include/asm/pgtable_32.h11
-rw-r--r--arch/sparc/include/asm/pgtable_64.h58
-rw-r--r--arch/sparc/include/asm/processor_32.h5
-rw-r--r--arch/sparc/include/asm/processor_64.h6
-rw-r--r--arch/sparc/include/asm/prom.h24
-rw-r--r--arch/sparc/include/asm/ptrace.h2
-rw-r--r--arch/sparc/include/asm/setup.h39
-rw-r--r--arch/sparc/include/asm/sfp-machine_32.h28
-rw-r--r--arch/sparc/include/asm/smp_32.h6
-rw-r--r--arch/sparc/include/asm/smp_64.h24
-rw-r--r--arch/sparc/include/asm/spitfire.h2
-rw-r--r--arch/sparc/include/asm/stacktrace.h2
-rw-r--r--arch/sparc/include/asm/starfire.h8
-rw-r--r--arch/sparc/include/asm/string_32.h12
-rw-r--r--arch/sparc/include/asm/string_64.h12
-rw-r--r--arch/sparc/include/asm/switch_to_32.h6
-rw-r--r--arch/sparc/include/asm/switch_to_64.h4
-rw-r--r--arch/sparc/include/asm/syscalls.h8
-rw-r--r--arch/sparc/include/asm/timer_32.h6
-rw-r--r--arch/sparc/include/asm/timer_64.h6
-rw-r--r--arch/sparc/include/asm/tlb_64.h8
-rw-r--r--arch/sparc/include/asm/tlbflush_64.h22
-rw-r--r--arch/sparc/include/asm/topology_64.h2
-rw-r--r--arch/sparc/include/asm/trap_block.h6
-rw-r--r--arch/sparc/include/asm/uaccess.h2
-rw-r--r--arch/sparc/include/asm/uaccess_32.h14
-rw-r--r--arch/sparc/include/asm/uaccess_64.h50
-rw-r--r--arch/sparc/include/asm/vio.h36
-rw-r--r--arch/sparc/include/asm/visasm.h3
-rw-r--r--arch/sparc/include/asm/xor_64.h28
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/audit.c8
-rw-r--r--arch/sparc/kernel/auxio_32.c9
-rw-r--r--arch/sparc/kernel/btext.c2
-rw-r--r--arch/sparc/kernel/compat_audit.c1
-rw-r--r--arch/sparc/kernel/cpu.c1
-rw-r--r--arch/sparc/kernel/cpumap.h4
-rw-r--r--arch/sparc/kernel/devices.c12
-rw-r--r--arch/sparc/kernel/entry.h259
-rw-r--r--arch/sparc/kernel/iommu.c3
-rw-r--r--arch/sparc/kernel/iommu_common.h14
-rw-r--r--arch/sparc/kernel/ioport.c6
-rw-r--r--arch/sparc/kernel/irq.h11
-rw-r--r--arch/sparc/kernel/irq_32.c1
-rw-r--r--arch/sparc/kernel/kernel.h124
-rw-r--r--arch/sparc/kernel/kgdb_64.c2
-rw-r--r--arch/sparc/kernel/kprobes.c5
-rw-r--r--arch/sparc/kernel/leon_kernel.c10
-rw-r--r--arch/sparc/kernel/leon_pci.c79
-rw-r--r--arch/sparc/kernel/leon_pci_grpci1.c16
-rw-r--r--arch/sparc/kernel/leon_pci_grpci2.c22
-rw-r--r--arch/sparc/kernel/leon_pmc.c8
-rw-r--r--arch/sparc/kernel/leon_smp.c13
-rw-r--r--arch/sparc/kernel/of_device_common.c4
-rw-r--r--arch/sparc/kernel/pci.c1
-rw-r--r--arch/sparc/kernel/pci_impl.h30
-rw-r--r--arch/sparc/kernel/pci_sun4v.h156
-rw-r--r--arch/sparc/kernel/pcic.c116
-rw-r--r--arch/sparc/kernel/perf_event.c23
-rw-r--r--arch/sparc/kernel/process_32.c12
-rw-r--r--arch/sparc/kernel/process_64.c2
-rw-r--r--arch/sparc/kernel/prom.h2
-rw-r--r--arch/sparc/kernel/prom_64.c5
-rw-r--r--arch/sparc/kernel/psycho_common.h22
-rw-r--r--arch/sparc/kernel/ptrace_32.c2
-rw-r--r--arch/sparc/kernel/setup_32.c4
-rw-r--r--arch/sparc/kernel/signal32.c56
-rw-r--r--arch/sparc/kernel/signal_32.c11
-rw-r--r--arch/sparc/kernel/signal_64.c6
-rw-r--r--arch/sparc/kernel/smp_32.c13
-rw-r--r--arch/sparc/kernel/smp_64.c16
-rw-r--r--arch/sparc/kernel/sun4d_irq.c17
-rw-r--r--arch/sparc/kernel/sys_sparc32.c2
-rw-r--r--arch/sparc/kernel/sys_sparc_32.c10
-rw-r--r--arch/sparc/kernel/sys_sparc_64.c1
-rw-r--r--arch/sparc/kernel/systbls.h124
-rw-r--r--arch/sparc/kernel/tadpole.c126
-rw-r--r--arch/sparc/kernel/time_32.c8
-rw-r--r--arch/sparc/kernel/traps_32.c4
-rw-r--r--arch/sparc/kernel/traps_64.c11
-rw-r--r--arch/sparc/kernel/unaligned_32.c4
-rw-r--r--arch/sparc/kernel/unaligned_64.c2
-rw-r--r--arch/sparc/kernel/windows.c3
-rw-r--r--arch/sparc/lib/Makefile2
-rw-r--r--arch/sparc/math-emu/sfp-util_32.h20
-rw-r--r--arch/sparc/math-emu/sfp-util_64.h12
-rw-r--r--arch/sparc/mm/fault_32.c9
-rw-r--r--arch/sparc/mm/fault_64.c4
-rw-r--r--arch/sparc/mm/init_32.c7
-rw-r--r--arch/sparc/mm/init_64.c9
-rw-r--r--arch/sparc/mm/init_64.h4
-rw-r--r--arch/sparc/mm/io-unit.c21
-rw-r--r--arch/sparc/mm/iommu.c25
-rw-r--r--arch/sparc/mm/leon_mm.c4
-rw-r--r--arch/sparc/mm/mm_32.h24
-rw-r--r--arch/sparc/mm/srmmu.c13
-rw-r--r--arch/sparc/mm/srmmu.h4
-rw-r--r--arch/sparc/mm/tsb.c1
-rw-r--r--arch/sparc/prom/misc_64.c5
-rw-r--r--arch/unicore32/Kconfig6
-rw-r--r--arch/unicore32/include/asm/io.h27
-rw-r--r--arch/unicore32/include/asm/pgtable.h10
-rw-r--r--arch/unicore32/include/asm/ptrace.h1
-rw-r--r--arch/unicore32/kernel/clock.c8
-rw-r--r--arch/unicore32/kernel/ksyms.c41
-rw-r--r--arch/unicore32/kernel/ksyms.h2
-rw-r--r--arch/unicore32/kernel/module.c11
-rw-r--r--arch/unicore32/kernel/process.c1
-rw-r--r--arch/unicore32/kernel/setup.c4
-rw-r--r--arch/unicore32/mm/alignment.c1
-rw-r--r--arch/unicore32/mm/proc-syms.c2
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/boot/compressed/aslr.c9
-rw-r--r--arch/x86/kernel/traps.c7
-rw-r--r--arch/x86/xen/enlighten.c5
-rw-r--r--arch/x86/xen/setup.c60
-rw-r--r--arch/x86/xen/xen-ops.h1
-rw-r--r--block/blk-core.c3
-rw-r--r--block/blk-flush.c38
-rw-r--r--block/blk-mq-tag.c59
-rw-r--r--block/blk-mq-tag.h2
-rw-r--r--block/blk-mq.c11
-rw-r--r--block/blk.h1
-rw-r--r--block/elevator.c20
-rw-r--r--drivers/acpi/acpi_lpss.c15
-rw-r--r--drivers/acpi/battery.c39
-rw-r--r--drivers/acpi/osl.c3
-rw-r--r--drivers/acpi/tables.c3
-rw-r--r--drivers/block/null_blk.c7
-rw-r--r--drivers/bus/Kconfig2
-rw-r--r--drivers/char/random.c17
-rw-r--r--drivers/cpufreq/Kconfig2
-rw-r--r--drivers/cpufreq/cpufreq.c10
-rw-r--r--drivers/cpufreq/intel_pstate.c5
-rw-r--r--drivers/cpuidle/cpuidle-armada-370-xp.c4
-rw-r--r--drivers/gpu/drm/drm_modeset_lock.c1
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c47
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c9
-rw-r--r--drivers/gpu/drm/i915/i915_gpu_error.c3
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c18
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c5
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c23
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h2
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c4
-rw-r--r--drivers/gpu/drm/i915/intel_uncore.c3
-rw-r--r--drivers/gpu/drm/nouveau/Makefile1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/nvc0.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/base.c6
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/dport.c7
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/gpc.fuc2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hub.fuc18
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubgm107.fuc5.h460
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnv108.fuc5.h460
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvc0.fuc.h188
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvd7.fuc.h188
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnve0.fuc.h170
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvf0.fuc.h170
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/macros.fuc6
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/fuc/os.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv50.c9
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c41
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/i2c.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c8
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c76
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/i2c/gf117.c39
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/ibus/nve0.c19
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/host.fuc2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nv108.fuc.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nva3.fuc.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvc0.fuc.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvd0.fuc.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c7
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c118
-rw-r--r--drivers/gpu/drm/radeon/evergreen_reg.h2
-rw-r--r--drivers/gpu/drm/radeon/r500_reg.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c35
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c22
-rw-r--r--drivers/i2c/busses/Kconfig23
-rw-r--r--drivers/i2c/busses/Makefile2
-rw-r--r--drivers/i2c/busses/i2c-rk3x.c763
-rw-r--r--drivers/i2c/busses/i2c-sun6i-p2wi.c345
-rw-r--r--drivers/iio/adc/at91_adc.c16
-rw-r--r--drivers/iio/adc/men_z188_adc.c4
-rw-r--r--drivers/iio/adc/twl4030-madc.c1
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c3
-rw-r--r--drivers/iio/magnetometer/ak8975.c9
-rw-r--r--drivers/iio/pressure/mpl3115.c6
-rw-r--r--drivers/misc/vexpress-syscfg.c12
-rw-r--r--drivers/misc/vmw_balloon.c3
-rw-r--r--drivers/of/base.c7
-rw-r--r--drivers/of/platform.c4
-rw-r--r--drivers/regulator/as3722-regulator.c2
-rw-r--r--drivers/regulator/ltc3589.c2
-rw-r--r--drivers/regulator/palmas-regulator.c2
-rw-r--r--drivers/remoteproc/Kconfig2
-rw-r--r--drivers/rtc/rtc-puv3.c4
-rw-r--r--drivers/s390/block/dcssblk.c2
-rw-r--r--drivers/s390/char/Makefile1
-rw-r--r--drivers/s390/char/sclp_vt220.c2
-rw-r--r--drivers/s390/char/vmlogrdr.c2
-rw-r--r--drivers/s390/char/vmwatchdog.c338
-rw-r--r--drivers/s390/cio/airq.c13
-rw-r--r--drivers/s390/cio/ccwgroup.c28
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--drivers/s390/cio/device.c71
-rw-r--r--drivers/s390/cio/qdio_debug.c79
-rw-r--r--drivers/s390/cio/qdio_debug.h2
-rw-r--r--drivers/s390/cio/qdio_main.c16
-rw-r--r--drivers/s390/crypto/ap_bus.c4
-rw-r--r--drivers/s390/crypto/zcrypt_api.c2
-rw-r--r--drivers/scsi/mvsas/mv_94xx.c10
-rw-r--r--drivers/scsi/mvsas/mv_94xx.h58
-rw-r--r--drivers/spi/spi-pxa2xx-dma.c2
-rw-r--r--drivers/staging/android/timed_output.c1
-rw-r--r--drivers/staging/comedi/Kconfig1
-rw-r--r--drivers/staging/iio/Kconfig9
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c12
-rw-r--r--drivers/staging/iio/light/tsl2x7x_core.c8
-rw-r--r--drivers/staging/imx-drm/parallel-display.c7
-rw-r--r--drivers/tty/n_tty.c19
-rw-r--r--drivers/tty/serial/8250/8250_core.c2
-rw-r--r--drivers/tty/serial/8250/8250_early.c5
-rw-r--r--drivers/tty/serial/altera_uart.c6
-rw-r--r--drivers/tty/serial/amba-pl010.c2
-rw-r--r--drivers/tty/serial/amba-pl011.c2
-rw-r--r--drivers/tty/serial/atmel_serial.c2
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c2
-rw-r--r--drivers/tty/serial/bfin_uart.c2
-rw-r--r--drivers/tty/serial/dz.c2
-rw-r--r--drivers/tty/serial/earlycon.c2
-rw-r--r--drivers/tty/serial/efm32-uart.c2
-rw-r--r--drivers/tty/serial/fsl_lpuart.c2
-rw-r--r--drivers/tty/serial/ip22zilog.c2
-rw-r--r--drivers/tty/serial/m32r_sio.c2
-rw-r--r--drivers/tty/serial/max310x.c2
-rw-r--r--drivers/tty/serial/mcf.c6
-rw-r--r--drivers/tty/serial/mfd.c2
-rw-r--r--drivers/tty/serial/mpsc.c2
-rw-r--r--drivers/tty/serial/msm_serial.c2
-rw-r--r--drivers/tty/serial/mxs-auart.c2
-rw-r--r--drivers/tty/serial/netx-serial.c2
-rw-r--r--drivers/tty/serial/pmac_zilog.c2
-rw-r--r--drivers/tty/serial/pnx8xxx_uart.c2
-rw-r--r--drivers/tty/serial/pxa.c2
-rw-r--r--drivers/tty/serial/samsung.c2
-rw-r--r--drivers/tty/serial/sb1250-duart.c2
-rw-r--r--drivers/tty/serial/sccnxp.c2
-rw-r--r--drivers/tty/serial/serial_ks8695.c2
-rw-r--r--drivers/tty/serial/serial_txx9.c2
-rw-r--r--drivers/tty/serial/sirfsoc_uart.c2
-rw-r--r--drivers/tty/serial/st-asc.c2
-rw-r--r--drivers/tty/serial/sunsab.c2
-rw-r--r--drivers/tty/serial/sunsu.c2
-rw-r--r--drivers/tty/serial/sunzilog.c2
-rw-r--r--drivers/tty/serial/ucc_uart.c2
-rw-r--r--drivers/tty/serial/vr41xx_siu.c2
-rw-r--r--drivers/tty/serial/zs.c2
-rw-r--r--drivers/tty/vt/vt.c24
-rw-r--r--drivers/uio/uio.c2
-rw-r--r--drivers/usb/core/hub.c33
-rw-r--r--drivers/usb/core/hub.h2
-rw-r--r--drivers/usb/core/port.c89
-rw-r--r--drivers/usb/host/pci-quirks.c19
-rw-r--r--drivers/usb/host/xhci-hub.c2
-rw-r--r--drivers/usb/misc/usbtest.c16
-rw-r--r--drivers/video/console/dummycon.c1
-rw-r--r--drivers/video/console/vgacon.c1
-rw-r--r--drivers/video/fbdev/offb.c11
-rw-r--r--drivers/w1/masters/mxc_w1.c2
-rw-r--r--drivers/watchdog/Kconfig7
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/diag288_wdt.c316
-rw-r--r--drivers/xen/grant-table.c3
-rw-r--r--fs/btrfs/ctree.h13
-rw-r--r--fs/btrfs/extent-tree.c143
-rw-r--r--fs/btrfs/extent_io.h1
-rw-r--r--fs/btrfs/extent_map.c2
-rw-r--r--fs/btrfs/extent_map.h1
-rw-r--r--fs/btrfs/free-space-cache.c192
-rw-r--r--fs/btrfs/inode.c41
-rw-r--r--fs/btrfs/locking.c80
-rw-r--r--fs/btrfs/scrub.c19
-rw-r--r--fs/btrfs/volumes.c36
-rw-r--r--fs/btrfs/volumes.h3
-rw-r--r--fs/eventpoll.c4
-rw-r--r--fs/locks.c2
-rw-r--r--fs/nfsd/nfs4state.c78
-rw-r--r--fs/nfsd/nfs4xdr.c1
-rw-r--r--include/acpi/processor.h10
-rw-r--r--include/drm/i915_powerwell.h4
-rw-r--r--include/linux/blk-mq.h2
-rw-r--r--include/linux/blkdev.h2
-rw-r--r--include/linux/elevator.h1
-rw-r--r--include/linux/fs.h6
-rw-r--r--include/linux/profile.h1
-rw-r--r--include/linux/regulator/consumer.h5
-rw-r--r--include/linux/suspend.h2
-rw-r--r--include/sound/core.h2
-rw-r--r--include/uapi/linux/perf_event.h1
-rw-r--r--kernel/context_tracking.c3
-rw-r--r--kernel/events/core.c37
-rw-r--r--kernel/locking/rtmutex-debug.h5
-rw-r--r--kernel/locking/rtmutex.c243
-rw-r--r--kernel/locking/rtmutex.h5
-rw-r--r--kernel/power/hibernate.c37
-rw-r--r--kernel/power/main.c6
-rw-r--r--kernel/power/user.c3
-rw-r--r--kernel/sysctl.c4
-rw-r--r--scripts/package/builddeb14
-rw-r--r--scripts/package/buildtar3
-rw-r--r--sound/core/control.c78
-rw-r--r--sound/core/init.c1
-rw-r--r--sound/pci/hda/hda_i915.c12
-rw-r--r--sound/pci/hda/hda_i915.h4
-rw-r--r--sound/pci/hda/hda_intel.c7
-rw-r--r--sound/soc/codecs/Kconfig12
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/sigmadsp-i2c.c35
-rw-r--r--sound/soc/codecs/sigmadsp-regmap.c36
-rw-r--r--sound/soc/codecs/sigmadsp.c65
-rw-r--r--sound/soc/codecs/sigmadsp.h20
-rw-r--r--sound/soc/fsl/fsl_dma.c4
-rw-r--r--sound/soc/fsl/fsl_spdif.c6
-rw-r--r--sound/soc/pxa/Kconfig11
-rw-r--r--sound/soc/sh/rcar/core.c2
-rw-r--r--sound/soc/soc-dapm.c29
-rw-r--r--tools/lib/traceevent/event-parse.c113
-rw-r--r--tools/lib/traceevent/event-parse.h25
-rw-r--r--tools/lib/traceevent/event-plugin.c203
-rw-r--r--tools/lib/traceevent/plugin_function.c43
-rw-r--r--tools/perf/Documentation/perf-report.txt23
-rw-r--r--tools/perf/Documentation/perf-timechart.txt41
-rw-r--r--tools/perf/Makefile.perf6
-rw-r--r--tools/perf/builtin-inject.c2
-rw-r--r--tools/perf/builtin-probe.c23
-rw-r--r--tools/perf/config/Makefile6
-rw-r--r--tools/perf/perf.c1
-rw-r--r--tools/perf/tests/builtin-test.c42
-rw-r--r--tools/perf/tests/dso-data.c214
-rw-r--r--tools/perf/tests/dwarf-unwind.c2
-rw-r--r--tools/perf/tests/make7
-rw-r--r--tools/perf/tests/tests.h2
-rw-r--r--tools/perf/util/dso.c279
-rw-r--r--tools/perf/util/dso.h50
-rw-r--r--tools/perf/util/event.c57
-rw-r--r--tools/perf/util/event.h7
-rw-r--r--tools/perf/util/evsel.c5
-rw-r--r--tools/perf/util/hist.c9
-rw-r--r--tools/perf/util/hist.h1
-rw-r--r--tools/perf/util/machine.c4
-rw-r--r--tools/perf/util/map.c4
-rw-r--r--tools/perf/util/map.h4
-rw-r--r--tools/perf/util/perf_regs.c10
-rw-r--r--tools/perf/util/perf_regs.h4
-rw-r--r--tools/perf/util/probe-event.c13
-rw-r--r--tools/perf/util/probe-finder.c11
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c1
-rw-r--r--tools/perf/util/scripting-engines/trace-event-python.c2
-rw-r--r--tools/perf/util/sort.c107
-rw-r--r--tools/perf/util/sort.h2
-rw-r--r--tools/perf/util/unwind-libunwind.c2
-rw-r--r--tools/perf/util/util.c1
-rw-r--r--tools/perf/util/util.h1
499 files changed, 7684 insertions, 4293 deletions
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index 1d27f0a1abd1..639e74857968 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -202,8 +202,8 @@ $(MEDIA_OBJ_DIR)/%: $(MEDIA_SRC_DIR)/%.b64
202 202
203$(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES) 203$(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES)
204 @$($(quiet)gen_xml) 204 @$($(quiet)gen_xml)
205 @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/) 205 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/v4l/*xml $(MEDIA_OBJ_DIR)/)
206 @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/) 206 @(ln -sf `cd $(MEDIA_SRC_DIR) && /bin/pwd`/dvb/*xml $(MEDIA_OBJ_DIR)/)
207 207
208$(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/uapi/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)
diff --git a/Documentation/devicetree/bindings/i2c/i2c-rk3x.txt b/Documentation/devicetree/bindings/i2c/i2c-rk3x.txt
new file mode 100644
index 000000000000..dde6c22ce91a
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-rk3x.txt
@@ -0,0 +1,42 @@
1* Rockchip RK3xxx I2C controller
2
3This driver interfaces with the native I2C controller present in Rockchip
4RK3xxx SoCs.
5
6Required properties :
7
8 - reg : Offset and length of the register set for the device
9 - compatible : should be "rockchip,rk3066-i2c", "rockchip,rk3188-i2c" or
10 "rockchip,rk3288-i2c".
11 - interrupts : interrupt number
12 - clocks : parent clock
13
14Required on RK3066, RK3188 :
15
16 - rockchip,grf : the phandle of the syscon node for the general register
17 file (GRF)
18 - on those SoCs an alias with the correct I2C bus ID (bit offset in the GRF)
19 is also required.
20
21Optional properties :
22
23 - clock-frequency : SCL frequency to use (in Hz). If omitted, 100kHz is used.
24
25Example:
26
27aliases {
28 i2c0 = &i2c0;
29}
30
31i2c0: i2c@2002d000 {
32 compatible = "rockchip,rk3188-i2c";
33 reg = <0x2002d000 0x1000>;
34 interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
35 #address-cells = <1>;
36 #size-cells = <0>;
37
38 rockchip,grf = <&grf>;
39
40 clock-names = "i2c";
41 clocks = <&cru PCLK_I2C0>;
42};
diff --git a/Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt b/Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt
new file mode 100644
index 000000000000..6b765485af7d
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-sunxi-p2wi.txt
@@ -0,0 +1,41 @@
1
2* Allwinner P2WI (Push/Pull 2 Wire Interface) controller
3
4Required properties :
5
6 - reg : Offset and length of the register set for the device.
7 - compatible : Should one of the following:
8 - "allwinner,sun6i-a31-p2wi"
9 - interrupts : The interrupt line connected to the P2WI peripheral.
10 - clocks : The gate clk connected to the P2WI peripheral.
11 - resets : The reset line connected to the P2WI peripheral.
12
13Optional properties :
14
15 - clock-frequency : Desired P2WI bus clock frequency in Hz. If not set the
16default frequency is 100kHz
17
18A P2WI may contain one child node encoding a P2WI slave device.
19
20Slave device properties:
21 Required properties:
22 - reg : the I2C slave address used during the initialization
23 process to switch from I2C to P2WI mode
24
25Example:
26
27 p2wi@01f03400 {
28 compatible = "allwinner,sun6i-a31-p2wi";
29 reg = <0x01f03400 0x400>;
30 interrupts = <0 39 4>;
31 clocks = <&apb0_gates 3>;
32 clock-frequency = <6000000>;
33 resets = <&apb0_rst 3>;
34
35 axp221: pmic@68 {
36 compatible = "x-powers,axp221";
37 reg = <0x68>;
38
39 /* ... */
40 };
41 };
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index d567a7cc552b..c600e2f44a62 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1171,7 +1171,7 @@ When kbuild executes, the following steps are followed (roughly):
1171 obvious reason. 1171 obvious reason.
1172 1172
1173 dtc 1173 dtc
1174 Create flattend device tree blob object suitable for linking 1174 Create flattened device tree blob object suitable for linking
1175 into vmlinux. Device tree blobs linked into vmlinux are placed 1175 into vmlinux. Device tree blobs linked into vmlinux are placed
1176 in an init section in the image. Platform code *must* copy the 1176 in an init section in the image. Platform code *must* copy the
1177 blob to non-init memory prior to calling unflatten_device_tree(). 1177 blob to non-init memory prior to calling unflatten_device_tree().
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 6eaa9cdb7094..884904975d0b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1474,6 +1474,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1474 js= [HW,JOY] Analog joystick 1474 js= [HW,JOY] Analog joystick
1475 See Documentation/input/joystick.txt. 1475 See Documentation/input/joystick.txt.
1476 1476
1477 kaslr/nokaslr [X86]
1478 Enable/disable kernel and module base offset ASLR
1479 (Address Space Layout Randomization) if built into
1480 the kernel. When CONFIG_HIBERNATION is selected,
1481 kASLR is disabled by default. When kASLR is enabled,
1482 hibernation will be disabled.
1483
1477 keepinitrd [HW,ARM] 1484 keepinitrd [HW,ARM]
1478 1485
1479 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter 1486 kernelcore=nn[KMG] [KNL,X86,IA-64,PPC] This parameter
@@ -2110,10 +2117,6 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2110 noapic [SMP,APIC] Tells the kernel to not make use of any 2117 noapic [SMP,APIC] Tells the kernel to not make use of any
2111 IOAPICs that may be present in the system. 2118 IOAPICs that may be present in the system.
2112 2119
2113 nokaslr [X86]
2114 Disable kernel and module base offset ASLR (Address
2115 Space Layout Randomization) if built into the kernel.
2116
2117 noautogroup Disable scheduler automatic task group creation. 2120 noautogroup Disable scheduler automatic task group creation.
2118 2121
2119 nobats [PPC] Do not use BATs for mapping kernel lowmem 2122 nobats [PPC] Do not use BATs for mapping kernel lowmem
@@ -2184,6 +2187,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2184 in certain environments such as networked servers or 2187 in certain environments such as networked servers or
2185 real-time systems. 2188 real-time systems.
2186 2189
2190 nohibernate [HIBERNATION] Disable hibernation and resume.
2191
2187 nohz= [KNL] Boottime enable/disable dynamic ticks 2192 nohz= [KNL] Boottime enable/disable dynamic ticks
2188 Valid arguments: on, off 2193 Valid arguments: on, off
2189 Default: on 2194 Default: on
@@ -2980,6 +2985,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2980 noresume Don't check if there's a hibernation image 2985 noresume Don't check if there's a hibernation image
2981 present during boot. 2986 present during boot.
2982 nocompress Don't compress/decompress hibernation images. 2987 nocompress Don't compress/decompress hibernation images.
2988 no Disable hibernation and resume.
2983 2989
2984 retain_initrd [RAM] Keep initrd memory after extraction 2990 retain_initrd [RAM] Keep initrd memory after extraction
2985 2991
diff --git a/Documentation/thermal/nouveau_thermal b/Documentation/thermal/nouveau_thermal
index efceb7828f54..60bc29357ac3 100644
--- a/Documentation/thermal/nouveau_thermal
+++ b/Documentation/thermal/nouveau_thermal
@@ -4,7 +4,7 @@ Kernel driver nouveau
4Supported chips: 4Supported chips:
5* NV43+ 5* NV43+
6 6
7Authors: Martin Peres (mupuf) <martin.peres@labri.fr> 7Authors: Martin Peres (mupuf) <martin.peres@free.fr>
8 8
9Description 9Description
10--------- 10---------
@@ -68,8 +68,9 @@ Your fan can be driven in different modes:
68 68
69NOTE: Be sure to use the manual mode if you want to drive the fan speed manually 69NOTE: Be sure to use the manual mode if you want to drive the fan speed manually
70 70
71NOTE2: Not all fan management modes may be supported on all chipsets. We are 71NOTE2: When operating in manual mode outside the vbios-defined
72working on it. 72[PWM_min, PWM_max] range, the reported fan speed (RPM) may not be accurate
73depending on your hardware.
73 74
74Bug reports 75Bug reports
75--------- 76---------
diff --git a/MAINTAINERS b/MAINTAINERS
index 7c291d13182c..1a3564dddcb7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6960,7 +6960,7 @@ PKUNITY SOC DRIVERS
6960M: Guan Xuetao <gxt@mprc.pku.edu.cn> 6960M: Guan Xuetao <gxt@mprc.pku.edu.cn>
6961W: http://mprc.pku.edu.cn/~guanxuetao/linux 6961W: http://mprc.pku.edu.cn/~guanxuetao/linux
6962S: Maintained 6962S: Maintained
6963T: git git://git.kernel.org/pub/scm/linux/kernel/git/epip/linux-2.6-unicore32.git 6963T: git git://github.com/gxt/linux.git
6964F: drivers/input/serio/i8042-unicore32io.h 6964F: drivers/input/serio/i8042-unicore32io.h
6965F: drivers/i2c/busses/i2c-puv3.c 6965F: drivers/i2c/busses/i2c-puv3.c
6966F: drivers/video/fb-puv3.c 6966F: drivers/video/fb-puv3.c
@@ -7948,6 +7948,7 @@ F: drivers/mmc/host/sdhci-spear.c
7948 7948
7949SECURITY SUBSYSTEM 7949SECURITY SUBSYSTEM
7950M: James Morris <james.l.morris@oracle.com> 7950M: James Morris <james.l.morris@oracle.com>
7951M: Serge E. Hallyn <serge@hallyn.com>
7951L: linux-security-module@vger.kernel.org (suggested Cc:) 7952L: linux-security-module@vger.kernel.org (suggested Cc:)
7952T: git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git 7953T: git git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git
7953W: http://kernsec.org/ 7954W: http://kernsec.org/
@@ -9268,7 +9269,7 @@ UNICORE32 ARCHITECTURE:
9268M: Guan Xuetao <gxt@mprc.pku.edu.cn> 9269M: Guan Xuetao <gxt@mprc.pku.edu.cn>
9269W: http://mprc.pku.edu.cn/~guanxuetao/linux 9270W: http://mprc.pku.edu.cn/~guanxuetao/linux
9270S: Maintained 9271S: Maintained
9271T: git git://git.kernel.org/pub/scm/linux/kernel/git/epip/linux-2.6-unicore32.git 9272T: git git://github.com/gxt/linux.git
9272F: arch/unicore32/ 9273F: arch/unicore32/
9273 9274
9274UNIFDEF 9275UNIFDEF
@@ -9735,6 +9736,14 @@ L: virtualization@lists.linux-foundation.org
9735S: Supported 9736S: Supported
9736F: arch/x86/kernel/cpu/vmware.c 9737F: arch/x86/kernel/cpu/vmware.c
9737 9738
9739VMWARE BALLOON DRIVER
9740M: Xavier Deguillard <xdeguillard@vmware.com>
9741M: Philip Moltmann <moltmann@vmware.com>
9742M: "VMware, Inc." <pv-drivers@vmware.com>
9743L: linux-kernel@vger.kernel.org
9744S: Maintained
9745F: drivers/misc/vmw_balloon.c
9746
9738VMWARE VMXNET3 ETHERNET DRIVER 9747VMWARE VMXNET3 ETHERNET DRIVER
9739M: Shreyas Bhatewara <sbhatewara@vmware.com> 9748M: Shreyas Bhatewara <sbhatewara@vmware.com>
9740M: "VMware, Inc." <pv-drivers@vmware.com> 9749M: "VMware, Inc." <pv-drivers@vmware.com>
diff --git a/Makefile b/Makefile
index 97b286128c1e..b11e2d504a00 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 16 2PATCHLEVEL = 16
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 87b63fde06d7..245058b3b0ef 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -175,13 +175,6 @@ config ARCH_HAS_ILOG2_U32
175config ARCH_HAS_ILOG2_U64 175config ARCH_HAS_ILOG2_U64
176 bool 176 bool
177 177
178config ARCH_HAS_CPUFREQ
179 bool
180 help
181 Internal node to signify that the ARCH has CPUFREQ support
182 and that the relevant menu configurations are displayed for
183 it.
184
185config ARCH_HAS_BANDGAP 178config ARCH_HAS_BANDGAP
186 bool 179 bool
187 180
@@ -318,7 +311,6 @@ config ARCH_MULTIPLATFORM
318 311
319config ARCH_INTEGRATOR 312config ARCH_INTEGRATOR
320 bool "ARM Ltd. Integrator family" 313 bool "ARM Ltd. Integrator family"
321 select ARCH_HAS_CPUFREQ
322 select ARM_AMBA 314 select ARM_AMBA
323 select ARM_PATCH_PHYS_VIRT 315 select ARM_PATCH_PHYS_VIRT
324 select AUTO_ZRELADDR 316 select AUTO_ZRELADDR
@@ -538,7 +530,6 @@ config ARCH_DOVE
538 530
539config ARCH_KIRKWOOD 531config ARCH_KIRKWOOD
540 bool "Marvell Kirkwood" 532 bool "Marvell Kirkwood"
541 select ARCH_HAS_CPUFREQ
542 select ARCH_REQUIRE_GPIOLIB 533 select ARCH_REQUIRE_GPIOLIB
543 select CPU_FEROCEON 534 select CPU_FEROCEON
544 select GENERIC_CLOCKEVENTS 535 select GENERIC_CLOCKEVENTS
@@ -637,7 +628,6 @@ config ARCH_LPC32XX
637config ARCH_PXA 628config ARCH_PXA
638 bool "PXA2xx/PXA3xx-based" 629 bool "PXA2xx/PXA3xx-based"
639 depends on MMU 630 depends on MMU
640 select ARCH_HAS_CPUFREQ
641 select ARCH_MTD_XIP 631 select ARCH_MTD_XIP
642 select ARCH_REQUIRE_GPIOLIB 632 select ARCH_REQUIRE_GPIOLIB
643 select ARM_CPU_SUSPEND if PM 633 select ARM_CPU_SUSPEND if PM
@@ -707,7 +697,6 @@ config ARCH_RPC
707 697
708config ARCH_SA1100 698config ARCH_SA1100
709 bool "SA1100-based" 699 bool "SA1100-based"
710 select ARCH_HAS_CPUFREQ
711 select ARCH_MTD_XIP 700 select ARCH_MTD_XIP
712 select ARCH_REQUIRE_GPIOLIB 701 select ARCH_REQUIRE_GPIOLIB
713 select ARCH_SPARSEMEM_ENABLE 702 select ARCH_SPARSEMEM_ENABLE
@@ -725,7 +714,6 @@ config ARCH_SA1100
725 714
726config ARCH_S3C24XX 715config ARCH_S3C24XX
727 bool "Samsung S3C24XX SoCs" 716 bool "Samsung S3C24XX SoCs"
728 select ARCH_HAS_CPUFREQ
729 select ARCH_REQUIRE_GPIOLIB 717 select ARCH_REQUIRE_GPIOLIB
730 select ATAGS 718 select ATAGS
731 select CLKDEV_LOOKUP 719 select CLKDEV_LOOKUP
@@ -746,7 +734,6 @@ config ARCH_S3C24XX
746 734
747config ARCH_S3C64XX 735config ARCH_S3C64XX
748 bool "Samsung S3C64XX" 736 bool "Samsung S3C64XX"
749 select ARCH_HAS_CPUFREQ
750 select ARCH_REQUIRE_GPIOLIB 737 select ARCH_REQUIRE_GPIOLIB
751 select ARM_AMBA 738 select ARM_AMBA
752 select ARM_VIC 739 select ARM_VIC
@@ -809,7 +796,6 @@ config ARCH_S5PC100
809 796
810config ARCH_S5PV210 797config ARCH_S5PV210
811 bool "Samsung S5PV210/S5PC110" 798 bool "Samsung S5PV210/S5PC110"
812 select ARCH_HAS_CPUFREQ
813 select ARCH_HAS_HOLES_MEMORYMODEL 799 select ARCH_HAS_HOLES_MEMORYMODEL
814 select ARCH_SPARSEMEM_ENABLE 800 select ARCH_SPARSEMEM_ENABLE
815 select ATAGS 801 select ATAGS
@@ -845,7 +831,6 @@ config ARCH_DAVINCI
845config ARCH_OMAP1 831config ARCH_OMAP1
846 bool "TI OMAP1" 832 bool "TI OMAP1"
847 depends on MMU 833 depends on MMU
848 select ARCH_HAS_CPUFREQ
849 select ARCH_HAS_HOLES_MEMORYMODEL 834 select ARCH_HAS_HOLES_MEMORYMODEL
850 select ARCH_OMAP 835 select ARCH_OMAP
851 select ARCH_REQUIRE_GPIOLIB 836 select ARCH_REQUIRE_GPIOLIB
@@ -1009,8 +994,6 @@ source "arch/arm/mach-rockchip/Kconfig"
1009 994
1010source "arch/arm/mach-sa1100/Kconfig" 995source "arch/arm/mach-sa1100/Kconfig"
1011 996
1012source "arch/arm/plat-samsung/Kconfig"
1013
1014source "arch/arm/mach-socfpga/Kconfig" 997source "arch/arm/mach-socfpga/Kconfig"
1015 998
1016source "arch/arm/mach-spear/Kconfig" 999source "arch/arm/mach-spear/Kconfig"
@@ -1028,6 +1011,7 @@ source "arch/arm/mach-s5pc100/Kconfig"
1028source "arch/arm/mach-s5pv210/Kconfig" 1011source "arch/arm/mach-s5pv210/Kconfig"
1029 1012
1030source "arch/arm/mach-exynos/Kconfig" 1013source "arch/arm/mach-exynos/Kconfig"
1014source "arch/arm/plat-samsung/Kconfig"
1031 1015
1032source "arch/arm/mach-shmobile/Kconfig" 1016source "arch/arm/mach-shmobile/Kconfig"
1033 1017
@@ -2109,9 +2093,7 @@ endmenu
2109 2093
2110menu "CPU Power Management" 2094menu "CPU Power Management"
2111 2095
2112if ARCH_HAS_CPUFREQ
2113source "drivers/cpufreq/Kconfig" 2096source "drivers/cpufreq/Kconfig"
2114endif
2115 2097
2116source "drivers/cpuidle/Kconfig" 2098source "drivers/cpuidle/Kconfig"
2117 2099
diff --git a/arch/arm/boot/dts/armada-375-db.dts b/arch/arm/boot/dts/armada-375-db.dts
index 772fec2d26ce..1e2919d43d78 100644
--- a/arch/arm/boot/dts/armada-375-db.dts
+++ b/arch/arm/boot/dts/armada-375-db.dts
@@ -91,6 +91,8 @@
91 marvell,nand-keep-config; 91 marvell,nand-keep-config;
92 marvell,nand-enable-arbiter; 92 marvell,nand-enable-arbiter;
93 nand-on-flash-bbt; 93 nand-on-flash-bbt;
94 nand-ecc-strength = <4>;
95 nand-ecc-step-size = <512>;
94 96
95 partition@0 { 97 partition@0 {
96 label = "U-Boot"; 98 label = "U-Boot";
diff --git a/arch/arm/boot/dts/armada-385-db.dts b/arch/arm/boot/dts/armada-385-db.dts
index ff9637dd8d0f..5bae4731828b 100644
--- a/arch/arm/boot/dts/armada-385-db.dts
+++ b/arch/arm/boot/dts/armada-385-db.dts
@@ -98,6 +98,8 @@
98 marvell,nand-keep-config; 98 marvell,nand-keep-config;
99 marvell,nand-enable-arbiter; 99 marvell,nand-enable-arbiter;
100 nand-on-flash-bbt; 100 nand-on-flash-bbt;
101 nand-ecc-strength = <4>;
102 nand-ecc-step-size = <512>;
101 103
102 partition@0 { 104 partition@0 {
103 label = "U-Boot"; 105 label = "U-Boot";
diff --git a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
index e5c6a0492ca0..4e5a59ee1501 100644
--- a/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
+++ b/arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
@@ -25,7 +25,7 @@
25 25
26 memory { 26 memory {
27 device_type = "memory"; 27 device_type = "memory";
28 reg = <0 0x00000000 0 0xC0000000>; /* 3 GB */ 28 reg = <0 0x00000000 0 0x40000000>; /* 1 GB soldered on */
29 }; 29 };
30 30
31 soc { 31 soc {
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index e2d62048e198..17d9462b9fb9 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -300,6 +300,7 @@ CONFIG_MMC=y
300CONFIG_MMC_BLOCK_MINORS=16 300CONFIG_MMC_BLOCK_MINORS=16
301CONFIG_MMC_ARMMMCI=y 301CONFIG_MMC_ARMMMCI=y
302CONFIG_MMC_SDHCI=y 302CONFIG_MMC_SDHCI=y
303CONFIG_MMC_SDHCI_PLTFM=y
303CONFIG_MMC_SDHCI_OF_ARASAN=y 304CONFIG_MMC_SDHCI_OF_ARASAN=y
304CONFIG_MMC_SDHCI_ESDHC_IMX=y 305CONFIG_MMC_SDHCI_ESDHC_IMX=y
305CONFIG_MMC_SDHCI_DOVE=y 306CONFIG_MMC_SDHCI_DOVE=y
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 59066cf0271a..536a137863cb 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -32,6 +32,7 @@ CONFIG_SOC_OMAP5=y
32CONFIG_SOC_AM33XX=y 32CONFIG_SOC_AM33XX=y
33CONFIG_SOC_AM43XX=y 33CONFIG_SOC_AM43XX=y
34CONFIG_SOC_DRA7XX=y 34CONFIG_SOC_DRA7XX=y
35CONFIG_CACHE_L2X0=y
35CONFIG_ARM_THUMBEE=y 36CONFIG_ARM_THUMBEE=y
36CONFIG_ARM_ERRATA_411920=y 37CONFIG_ARM_ERRATA_411920=y
37CONFIG_SMP=y 38CONFIG_SMP=y
diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
index eb577f4f5f70..39eb16b0066f 100644
--- a/arch/arm/include/asm/ftrace.h
+++ b/arch/arm/include/asm/ftrace.h
@@ -52,7 +52,7 @@ extern inline void *return_address(unsigned int level)
52 52
53#endif 53#endif
54 54
55#define ftrace_return_addr(n) return_address(n) 55#define ftrace_return_address(n) return_address(n)
56 56
57#endif /* ifndef __ASSEMBLY__ */ 57#endif /* ifndef __ASSEMBLY__ */
58 58
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index 9bc6db1c1348..41c839167e87 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -1,10 +1,9 @@
1config ARCH_BCM 1menuconfig ARCH_BCM
2 bool "Broadcom SoC Support" if ARCH_MULTI_V6_V7 2 bool "Broadcom SoC Support" if ARCH_MULTI_V6_V7
3 help 3 help
4 This enables support for Broadcom ARM based SoC chips 4 This enables support for Broadcom ARM based SoC chips
5 5
6menu "Broadcom SoC Selection" 6if ARCH_BCM
7 depends on ARCH_BCM
8 7
9config ARCH_BCM_MOBILE 8config ARCH_BCM_MOBILE
10 bool "Broadcom Mobile SoC Support" if ARCH_MULTI_V7 9 bool "Broadcom Mobile SoC Support" if ARCH_MULTI_V7
@@ -88,4 +87,4 @@ config ARCH_BCM_5301X
88 different SoC or with the older BCM47XX and BCM53XX based 87 different SoC or with the older BCM47XX and BCM53XX based
89 network SoC using a MIPS CPU, they are supported by arch/mips/bcm47xx 88 network SoC using a MIPS CPU, they are supported by arch/mips/bcm47xx
90 89
91endmenu 90endif
diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
index 101e0f356730..2631cfc5ab0d 100644
--- a/arch/arm/mach-berlin/Kconfig
+++ b/arch/arm/mach-berlin/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_BERLIN 1menuconfig ARCH_BERLIN
2 bool "Marvell Berlin SoCs" if ARCH_MULTI_V7 2 bool "Marvell Berlin SoCs" if ARCH_MULTI_V7
3 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
4 select ARM_GIC 4 select ARM_GIC
@@ -9,8 +9,6 @@ config ARCH_BERLIN
9 9
10if ARCH_BERLIN 10if ARCH_BERLIN
11 11
12menu "Marvell Berlin SoC variants"
13
14config MACH_BERLIN_BG2 12config MACH_BERLIN_BG2
15 bool "Marvell Armada 1500 (BG2)" 13 bool "Marvell Armada 1500 (BG2)"
16 select CACHE_L2X0 14 select CACHE_L2X0
@@ -30,6 +28,4 @@ config MACH_BERLIN_BG2Q
30 select HAVE_ARM_TWD if SMP 28 select HAVE_ARM_TWD if SMP
31 select PINCTRL_BERLIN_BG2Q 29 select PINCTRL_BERLIN_BG2Q
32 30
33endmenu
34
35endif 31endif
diff --git a/arch/arm/mach-cns3xxx/Kconfig b/arch/arm/mach-cns3xxx/Kconfig
index 66838f42037f..3c22a1990ecd 100644
--- a/arch/arm/mach-cns3xxx/Kconfig
+++ b/arch/arm/mach-cns3xxx/Kconfig
@@ -1,12 +1,11 @@
1config ARCH_CNS3XXX 1menuconfig ARCH_CNS3XXX
2 bool "Cavium Networks CNS3XXX family" if ARCH_MULTI_V6 2 bool "Cavium Networks CNS3XXX family" if ARCH_MULTI_V6
3 select ARM_GIC 3 select ARM_GIC
4 select PCI_DOMAINS if PCI 4 select PCI_DOMAINS if PCI
5 help 5 help
6 Support for Cavium Networks CNS3XXX platform. 6 Support for Cavium Networks CNS3XXX platform.
7 7
8menu "CNS3XXX platform type" 8if ARCH_CNS3XXX
9 depends on ARCH_CNS3XXX
10 9
11config MACH_CNS3420VB 10config MACH_CNS3420VB
12 bool "Support for CNS3420 Validation Board" 11 bool "Support for CNS3420 Validation Board"
@@ -17,4 +16,4 @@ config MACH_CNS3420VB
17 This is a platform with an on-board ARM11 MPCore and has support 16 This is a platform with an on-board ARM11 MPCore and has support
18 for USB, USB-OTG, MMC/SD/SDIO, SATA, PCI-E, etc. 17 for USB, USB-OTG, MMC/SD/SDIO, SATA, PCI-E, etc.
19 18
20endmenu 19endif
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig
index db18ef866593..584e8d4e2892 100644
--- a/arch/arm/mach-davinci/Kconfig
+++ b/arch/arm/mach-davinci/Kconfig
@@ -39,7 +39,6 @@ config ARCH_DAVINCI_DA830
39config ARCH_DAVINCI_DA850 39config ARCH_DAVINCI_DA850
40 bool "DA850/OMAP-L138/AM18x based system" 40 bool "DA850/OMAP-L138/AM18x based system"
41 select ARCH_DAVINCI_DA8XX 41 select ARCH_DAVINCI_DA8XX
42 select ARCH_HAS_CPUFREQ
43 select CP_INTC 42 select CP_INTC
44 43
45config ARCH_DAVINCI_DA8XX 44config ARCH_DAVINCI_DA8XX
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index d58995c9a95a..8f9b66c4ac78 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -7,10 +7,9 @@
7 7
8# Configuration options for the EXYNOS4 8# Configuration options for the EXYNOS4
9 9
10config ARCH_EXYNOS 10menuconfig ARCH_EXYNOS
11 bool "Samsung EXYNOS" if ARCH_MULTI_V7 11 bool "Samsung EXYNOS" if ARCH_MULTI_V7
12 select ARCH_HAS_BANDGAP 12 select ARCH_HAS_BANDGAP
13 select ARCH_HAS_CPUFREQ
14 select ARCH_HAS_HOLES_MEMORYMODEL 13 select ARCH_HAS_HOLES_MEMORYMODEL
15 select ARCH_REQUIRE_GPIOLIB 14 select ARCH_REQUIRE_GPIOLIB
16 select ARM_AMBA 15 select ARM_AMBA
@@ -30,8 +29,6 @@ config ARCH_EXYNOS
30 29
31if ARCH_EXYNOS 30if ARCH_EXYNOS
32 31
33menu "SAMSUNG EXYNOS SoCs Support"
34
35config ARCH_EXYNOS3 32config ARCH_EXYNOS3
36 bool "SAMSUNG EXYNOS3" 33 bool "SAMSUNG EXYNOS3"
37 select ARM_CPU_SUSPEND if PM 34 select ARM_CPU_SUSPEND if PM
@@ -118,8 +115,6 @@ config SOC_EXYNOS5800
118 default y 115 default y
119 depends on SOC_EXYNOS5420 116 depends on SOC_EXYNOS5420
120 117
121endmenu
122
123config EXYNOS5420_MCPM 118config EXYNOS5420_MCPM
124 bool "Exynos5420 Multi-Cluster PM support" 119 bool "Exynos5420 Multi-Cluster PM support"
125 depends on MCPM && SOC_EXYNOS5420 120 depends on MCPM && SOC_EXYNOS5420
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 16617bdb37a9..1ee91763fa7c 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -118,6 +118,7 @@ extern void __iomem *sysram_ns_base_addr;
118extern void __iomem *sysram_base_addr; 118extern void __iomem *sysram_base_addr;
119void exynos_init_io(void); 119void exynos_init_io(void);
120void exynos_restart(enum reboot_mode mode, const char *cmd); 120void exynos_restart(enum reboot_mode mode, const char *cmd);
121void exynos_sysram_init(void);
121void exynos_cpuidle_init(void); 122void exynos_cpuidle_init(void);
122void exynos_cpufreq_init(void); 123void exynos_cpufreq_init(void);
123void exynos_init_late(void); 124void exynos_init_late(void);
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 90aab4d75d08..f38cf7c110cc 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -184,6 +184,28 @@ void __init exynos_cpufreq_init(void)
184 platform_device_register_simple("exynos-cpufreq", -1, NULL, 0); 184 platform_device_register_simple("exynos-cpufreq", -1, NULL, 0);
185} 185}
186 186
187void __iomem *sysram_base_addr;
188void __iomem *sysram_ns_base_addr;
189
190void __init exynos_sysram_init(void)
191{
192 struct device_node *node;
193
194 for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram") {
195 if (!of_device_is_available(node))
196 continue;
197 sysram_base_addr = of_iomap(node, 0);
198 break;
199 }
200
201 for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram-ns") {
202 if (!of_device_is_available(node))
203 continue;
204 sysram_ns_base_addr = of_iomap(node, 0);
205 break;
206 }
207}
208
187void __init exynos_init_late(void) 209void __init exynos_init_late(void)
188{ 210{
189 if (of_machine_is_compatible("samsung,exynos5440")) 211 if (of_machine_is_compatible("samsung,exynos5440"))
@@ -198,7 +220,7 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
198 int depth, void *data) 220 int depth, void *data)
199{ 221{
200 struct map_desc iodesc; 222 struct map_desc iodesc;
201 __be32 *reg; 223 const __be32 *reg;
202 int len; 224 int len;
203 225
204 if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") && 226 if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
@@ -271,6 +293,13 @@ static void __init exynos_dt_machine_init(void)
271 } 293 }
272 } 294 }
273 295
296 /*
297 * This is called from smp_prepare_cpus if we've built for SMP, but
298 * we still need to set it up for PM and firmware ops if not.
299 */
300 if (!IS_ENABLED(SMP))
301 exynos_sysram_init();
302
274 exynos_cpuidle_init(); 303 exynos_cpuidle_init();
275 exynos_cpufreq_init(); 304 exynos_cpufreq_init();
276 305
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index ec02422e8499..1c8d31e39520 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -32,28 +32,6 @@
32 32
33extern void exynos4_secondary_startup(void); 33extern void exynos4_secondary_startup(void);
34 34
35void __iomem *sysram_base_addr;
36void __iomem *sysram_ns_base_addr;
37
38static void __init exynos_smp_prepare_sysram(void)
39{
40 struct device_node *node;
41
42 for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram") {
43 if (!of_device_is_available(node))
44 continue;
45 sysram_base_addr = of_iomap(node, 0);
46 break;
47 }
48
49 for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram-ns") {
50 if (!of_device_is_available(node))
51 continue;
52 sysram_ns_base_addr = of_iomap(node, 0);
53 break;
54 }
55}
56
57static inline void __iomem *cpu_boot_reg_base(void) 35static inline void __iomem *cpu_boot_reg_base(void)
58{ 36{
59 if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1) 37 if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
@@ -234,11 +212,11 @@ static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
234{ 212{
235 int i; 213 int i;
236 214
215 exynos_sysram_init();
216
237 if (read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9) 217 if (read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9)
238 scu_enable(scu_base_addr()); 218 scu_enable(scu_base_addr());
239 219
240 exynos_smp_prepare_sysram();
241
242 /* 220 /*
243 * Write the address of secondary startup into the 221 * Write the address of secondary startup into the
244 * system-wide flags register. The boot monitor waits 222 * system-wide flags register. The boot monitor waits
diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig
index 830b76e70250..a5960e2ac090 100644
--- a/arch/arm/mach-highbank/Kconfig
+++ b/arch/arm/mach-highbank/Kconfig
@@ -1,7 +1,6 @@
1config ARCH_HIGHBANK 1config ARCH_HIGHBANK
2 bool "Calxeda ECX-1000/2000 (Highbank/Midway)" if ARCH_MULTI_V7 2 bool "Calxeda ECX-1000/2000 (Highbank/Midway)" if ARCH_MULTI_V7
3 select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE 3 select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
4 select ARCH_HAS_CPUFREQ
5 select ARCH_HAS_HOLES_MEMORYMODEL 4 select ARCH_HAS_HOLES_MEMORYMODEL
6 select ARCH_HAS_OPP 5 select ARCH_HAS_OPP
7 select ARCH_SUPPORTS_BIG_ENDIAN 6 select ARCH_SUPPORTS_BIG_ENDIAN
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 8d42eab76d53..28fa2fa49e5d 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -1,6 +1,5 @@
1config ARCH_MXC 1menuconfig ARCH_MXC
2 bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7 2 bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7
3 select ARCH_HAS_CPUFREQ
4 select ARCH_HAS_OPP 3 select ARCH_HAS_OPP
5 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
6 select ARM_CPU_SUSPEND if PM 5 select ARM_CPU_SUSPEND if PM
@@ -13,8 +12,7 @@ config ARCH_MXC
13 help 12 help
14 Support for Freescale MXC/iMX-based family of processors 13 Support for Freescale MXC/iMX-based family of processors
15 14
16menu "Freescale i.MX support" 15if ARCH_MXC
17 depends on ARCH_MXC
18 16
19config MXC_TZIC 17config MXC_TZIC
20 bool 18 bool
@@ -99,7 +97,6 @@ config SOC_IMX25
99 97
100config SOC_IMX27 98config SOC_IMX27
101 bool 99 bool
102 select ARCH_HAS_CPUFREQ
103 select ARCH_HAS_OPP 100 select ARCH_HAS_OPP
104 select CPU_ARM926T 101 select CPU_ARM926T
105 select IMX_HAVE_IOMUX_V1 102 select IMX_HAVE_IOMUX_V1
@@ -124,7 +121,6 @@ config SOC_IMX35
124 121
125config SOC_IMX5 122config SOC_IMX5
126 bool 123 bool
127 select ARCH_HAS_CPUFREQ
128 select ARCH_HAS_OPP 124 select ARCH_HAS_OPP
129 select ARCH_MXC_IOMUX_V3 125 select ARCH_MXC_IOMUX_V3
130 select MXC_TZIC 126 select MXC_TZIC
@@ -786,4 +782,4 @@ endif
786 782
787source "arch/arm/mach-imx/devices/Kconfig" 783source "arch/arm/mach-imx/devices/Kconfig"
788 784
789endmenu 785endif
diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
index ba43321001d8..64f8e2564a37 100644
--- a/arch/arm/mach-integrator/Kconfig
+++ b/arch/arm/mach-integrator/Kconfig
@@ -28,7 +28,7 @@ config ARCH_CINTEGRATOR
28 bool 28 bool
29 29
30config INTEGRATOR_IMPD1 30config INTEGRATOR_IMPD1
31 tristate "Include support for Integrator/IM-PD1" 31 bool "Include support for Integrator/IM-PD1"
32 depends on ARCH_INTEGRATOR_AP 32 depends on ARCH_INTEGRATOR_AP
33 select ARCH_REQUIRE_GPIOLIB 33 select ARCH_REQUIRE_GPIOLIB
34 select ARM_VIC 34 select ARM_VIC
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 0e870ea818c4..3ce880729cff 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -308,7 +308,12 @@ static struct impd1_device impd1_devs[] = {
308 */ 308 */
309#define IMPD1_VALID_IRQS 0x00000bffU 309#define IMPD1_VALID_IRQS 0x00000bffU
310 310
311static int __init impd1_probe(struct lm_device *dev) 311/*
312 * As this module is bool, it is OK to have this as __init_refok() - no
313 * probe calls will be done after the initial system bootup, as devices
314 * are discovered as part of the machine startup.
315 */
316static int __init_refok impd1_probe(struct lm_device *dev)
312{ 317{
313 struct impd1_module *impd1; 318 struct impd1_module *impd1;
314 int irq_base; 319 int irq_base;
@@ -397,6 +402,11 @@ static void impd1_remove(struct lm_device *dev)
397static struct lm_driver impd1_driver = { 402static struct lm_driver impd1_driver = {
398 .drv = { 403 .drv = {
399 .name = "impd1", 404 .name = "impd1",
405 /*
406 * As we're dropping the probe() function, suppress driver
407 * binding from sysfs.
408 */
409 .suppress_bind_attrs = true,
400 }, 410 },
401 .probe = impd1_probe, 411 .probe = impd1_probe,
402 .remove = impd1_remove, 412 .remove = impd1_remove,
diff --git a/arch/arm/mach-keystone/Kconfig b/arch/arm/mach-keystone/Kconfig
index f50bc936cb84..98a156afaa94 100644
--- a/arch/arm/mach-keystone/Kconfig
+++ b/arch/arm/mach-keystone/Kconfig
@@ -1,6 +1,7 @@
1config ARCH_KEYSTONE 1config ARCH_KEYSTONE
2 bool "Texas Instruments Keystone Devices" 2 bool "Texas Instruments Keystone Devices"
3 depends on ARCH_MULTI_V7 3 depends on ARCH_MULTI_V7
4 depends on ARM_PATCH_PHYS_VIRT
4 select ARM_GIC 5 select ARM_GIC
5 select HAVE_ARM_ARCH_TIMER 6 select HAVE_ARM_ARCH_TIMER
6 select CLKSRC_MMIO 7 select CLKSRC_MMIO
diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 82a4ba8578a2..f49328c39bef 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_MOXART 1menuconfig ARCH_MOXART
2 bool "MOXA ART SoC" if ARCH_MULTI_V4 2 bool "MOXA ART SoC" if ARCH_MULTI_V4
3 select CPU_FA526 3 select CPU_FA526
4 select ARM_DMA_MEM_BUFFERABLE 4 select ARM_DMA_MEM_BUFFERABLE
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 6090b9eb00c8..4a7c250c9a30 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_MVEBU 1menuconfig ARCH_MVEBU
2 bool "Marvell Engineering Business Unit (MVEBU) SoCs" if (ARCH_MULTI_V7 || ARCH_MULTI_V5) 2 bool "Marvell Engineering Business Unit (MVEBU) SoCs" if (ARCH_MULTI_V7 || ARCH_MULTI_V5)
3 select ARCH_SUPPORTS_BIG_ENDIAN 3 select ARCH_SUPPORTS_BIG_ENDIAN
4 select CLKSRC_MMIO 4 select CLKSRC_MMIO
@@ -13,8 +13,6 @@ config ARCH_MVEBU
13 13
14if ARCH_MVEBU 14if ARCH_MVEBU
15 15
16menu "Marvell EBU SoC variants"
17
18config MACH_MVEBU_V7 16config MACH_MVEBU_V7
19 bool 17 bool
20 select ARMADA_370_XP_TIMER 18 select ARMADA_370_XP_TIMER
@@ -84,7 +82,6 @@ config MACH_DOVE
84 82
85config MACH_KIRKWOOD 83config MACH_KIRKWOOD
86 bool "Marvell Kirkwood boards" if ARCH_MULTI_V5 84 bool "Marvell Kirkwood boards" if ARCH_MULTI_V5
87 select ARCH_HAS_CPUFREQ
88 select ARCH_REQUIRE_GPIOLIB 85 select ARCH_REQUIRE_GPIOLIB
89 select CPU_FEROCEON 86 select CPU_FEROCEON
90 select KIRKWOOD_CLK 87 select KIRKWOOD_CLK
@@ -97,6 +94,4 @@ config MACH_KIRKWOOD
97 Say 'Y' here if you want your kernel to support boards based 94 Say 'Y' here if you want your kernel to support boards based
98 on the Marvell Kirkwood device tree. 95 on the Marvell Kirkwood device tree.
99 96
100endmenu
101
102endif 97endif
diff --git a/arch/arm/mach-nomadik/Kconfig b/arch/arm/mach-nomadik/Kconfig
index 486d301f43fd..3c61096c8627 100644
--- a/arch/arm/mach-nomadik/Kconfig
+++ b/arch/arm/mach-nomadik/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_NOMADIK 1menuconfig ARCH_NOMADIK
2 bool "ST-Ericsson Nomadik" 2 bool "ST-Ericsson Nomadik"
3 depends on ARCH_MULTI_V5 3 depends on ARCH_MULTI_V5
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
@@ -15,7 +15,6 @@ config ARCH_NOMADIK
15 Support for the Nomadik platform by ST-Ericsson 15 Support for the Nomadik platform by ST-Ericsson
16 16
17if ARCH_NOMADIK 17if ARCH_NOMADIK
18menu "Nomadik boards"
19 18
20config MACH_NOMADIK_8815NHK 19config MACH_NOMADIK_8815NHK
21 bool "ST 8815 Nomadik Hardware Kit (evaluation board)" 20 bool "ST 8815 Nomadik Hardware Kit (evaluation board)"
@@ -24,7 +23,6 @@ config MACH_NOMADIK_8815NHK
24 select I2C_ALGOBIT 23 select I2C_ALGOBIT
25 select I2C_NOMADIK 24 select I2C_NOMADIK
26 25
27endmenu
28endif 26endif
29 27
30config NOMADIK_8815 28config NOMADIK_8815
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 0ba482638ebf..062505345c95 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -1,3 +1,6 @@
1menu "TI OMAP/AM/DM/DRA Family"
2 depends on ARCH_MULTI_V6 || ARCH_MULTI_V7
3
1config ARCH_OMAP 4config ARCH_OMAP
2 bool 5 bool
3 6
@@ -28,7 +31,6 @@ config ARCH_OMAP4
28 select ARM_CPU_SUSPEND if PM 31 select ARM_CPU_SUSPEND if PM
29 select ARM_ERRATA_720789 32 select ARM_ERRATA_720789
30 select ARM_GIC 33 select ARM_GIC
31 select CACHE_L2X0
32 select HAVE_ARM_SCU if SMP 34 select HAVE_ARM_SCU if SMP
33 select HAVE_ARM_TWD if SMP 35 select HAVE_ARM_TWD if SMP
34 select OMAP_INTERCONNECT 36 select OMAP_INTERCONNECT
@@ -80,7 +82,6 @@ config SOC_DRA7XX
80config ARCH_OMAP2PLUS 82config ARCH_OMAP2PLUS
81 bool 83 bool
82 select ARCH_HAS_BANDGAP 84 select ARCH_HAS_BANDGAP
83 select ARCH_HAS_CPUFREQ
84 select ARCH_HAS_HOLES_MEMORYMODEL 85 select ARCH_HAS_HOLES_MEMORYMODEL
85 select ARCH_OMAP 86 select ARCH_OMAP
86 select ARCH_REQUIRE_GPIOLIB 87 select ARCH_REQUIRE_GPIOLIB
@@ -343,3 +344,5 @@ config OMAP4_ERRATA_I688
343endmenu 344endmenu
344 345
345endif 346endif
347
348endmenu
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index ff029737c8f0..a373d508799a 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -91,7 +91,14 @@ extern void omap3_sync32k_timer_init(void);
91extern void omap3_secure_sync32k_timer_init(void); 91extern void omap3_secure_sync32k_timer_init(void);
92extern void omap3_gptimer_timer_init(void); 92extern void omap3_gptimer_timer_init(void);
93extern void omap4_local_timer_init(void); 93extern void omap4_local_timer_init(void);
94#ifdef CONFIG_CACHE_L2X0
94int omap_l2_cache_init(void); 95int omap_l2_cache_init(void);
96#else
97static inline int omap_l2_cache_init(void)
98{
99 return 0;
100}
101#endif
95extern void omap5_realtime_timer_init(void); 102extern void omap5_realtime_timer_init(void);
96 103
97void omap2420_init_early(void); 104void omap2420_init_early(void);
diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig
index e4e505f52ba0..042f693ef423 100644
--- a/arch/arm/mach-prima2/Kconfig
+++ b/arch/arm/mach-prima2/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_SIRF 1menuconfig ARCH_SIRF
2 bool "CSR SiRF" if ARCH_MULTI_V7 2 bool "CSR SiRF" if ARCH_MULTI_V7
3 select ARCH_HAS_RESET_CONTROLLER 3 select ARCH_HAS_RESET_CONTROLLER
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
@@ -11,7 +11,7 @@ config ARCH_SIRF
11 11
12if ARCH_SIRF 12if ARCH_SIRF
13 13
14menu "CSR SiRF atlas6/primaII/Marco/Polo Specific Features" 14comment "CSR SiRF atlas6/primaII/Marco/Polo Specific Features"
15 15
16config ARCH_ATLAS6 16config ARCH_ATLAS6
17 bool "CSR SiRFSoC ATLAS6 ARM Cortex A9 Platform" 17 bool "CSR SiRFSoC ATLAS6 ARM Cortex A9 Platform"
@@ -37,8 +37,6 @@ config ARCH_MARCO
37 help 37 help
38 Support for CSR SiRFSoC ARM Cortex A9 Platform 38 Support for CSR SiRFSoC ARM Cortex A9 Platform
39 39
40endmenu
41
42config SIRF_IRQ 40config SIRF_IRQ
43 bool 41 bool
44 42
diff --git a/arch/arm/mach-qcom/Kconfig b/arch/arm/mach-qcom/Kconfig
index fd2b99dceb89..ee5697ba05bc 100644
--- a/arch/arm/mach-qcom/Kconfig
+++ b/arch/arm/mach-qcom/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_QCOM 1menuconfig ARCH_QCOM
2 bool "Qualcomm Support" if ARCH_MULTI_V7 2 bool "Qualcomm Support" if ARCH_MULTI_V7
3 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
4 select ARM_GIC 4 select ARM_GIC
@@ -11,8 +11,6 @@ config ARCH_QCOM
11 11
12if ARCH_QCOM 12if ARCH_QCOM
13 13
14menu "Qualcomm SoC Selection"
15
16config ARCH_MSM8X60 14config ARCH_MSM8X60
17 bool "Enable support for MSM8X60" 15 bool "Enable support for MSM8X60"
18 select CLKSRC_QCOM 16 select CLKSRC_QCOM
@@ -25,8 +23,6 @@ config ARCH_MSM8974
25 bool "Enable support for MSM8974" 23 bool "Enable support for MSM8974"
26 select HAVE_ARM_ARCH_TIMER 24 select HAVE_ARM_ARCH_TIMER
27 25
28endmenu
29
30config QCOM_SCM 26config QCOM_SCM
31 bool 27 bool
32 28
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
index 04284de7aca5..ad5316ae524e 100644
--- a/arch/arm/mach-s3c24xx/Kconfig
+++ b/arch/arm/mach-s3c24xx/Kconfig
@@ -117,7 +117,7 @@ config S3C24XX_SETUP_TS
117 Compile in platform device definition for Samsung TouchScreen. 117 Compile in platform device definition for Samsung TouchScreen.
118 118
119config S3C24XX_DMA 119config S3C24XX_DMA
120 bool "S3C2410 DMA support" 120 bool "S3C2410 DMA support (deprecated)"
121 select S3C_DMA 121 select S3C_DMA
122 help 122 help
123 S3C2410 DMA support. This is needed for drivers like sound which 123 S3C2410 DMA support. This is needed for drivers like sound which
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index 3136d86b0d6e..26ca2427e53d 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -18,9 +18,9 @@ config CPU_S3C6410
18 Enable S3C6410 CPU support 18 Enable S3C6410 CPU support
19 19
20config S3C64XX_PL080 20config S3C64XX_PL080
21 bool "S3C64XX DMA using generic PL08x driver" 21 def_bool DMADEVICES
22 select ARM_AMBA
22 select AMBA_PL08X 23 select AMBA_PL08X
23 select SAMSUNG_DMADEV
24 24
25config S3C64XX_SETUP_SDHCI 25config S3C64XX_SETUP_SDHCI
26 bool 26 bool
diff --git a/arch/arm/mach-s5p64x0/Kconfig b/arch/arm/mach-s5p64x0/Kconfig
index bb2111b3751e..26003e23796d 100644
--- a/arch/arm/mach-s5p64x0/Kconfig
+++ b/arch/arm/mach-s5p64x0/Kconfig
@@ -9,16 +9,18 @@ if ARCH_S5P64X0
9 9
10config CPU_S5P6440 10config CPU_S5P6440
11 bool 11 bool
12 select ARM_AMBA
13 select PL330_DMA if DMADEVICES
12 select S5P_SLEEP if PM 14 select S5P_SLEEP if PM
13 select SAMSUNG_DMADEV
14 select SAMSUNG_WAKEMASK if PM 15 select SAMSUNG_WAKEMASK if PM
15 help 16 help
16 Enable S5P6440 CPU support 17 Enable S5P6440 CPU support
17 18
18config CPU_S5P6450 19config CPU_S5P6450
19 bool 20 bool
21 select ARM_AMBA
22 select PL330_DMA if DMADEVICES
20 select S5P_SLEEP if PM 23 select S5P_SLEEP if PM
21 select SAMSUNG_DMADEV
22 select SAMSUNG_WAKEMASK if PM 24 select SAMSUNG_WAKEMASK if PM
23 help 25 help
24 Enable S5P6450 CPU support 26 Enable S5P6450 CPU support
diff --git a/arch/arm/mach-s5pc100/Kconfig b/arch/arm/mach-s5pc100/Kconfig
index 15170be97a74..c5e3a969b063 100644
--- a/arch/arm/mach-s5pc100/Kconfig
+++ b/arch/arm/mach-s5pc100/Kconfig
@@ -9,8 +9,9 @@ if ARCH_S5PC100
9 9
10config CPU_S5PC100 10config CPU_S5PC100
11 bool 11 bool
12 select ARM_AMBA
13 select PL330_DMA if DMADEVICES
12 select S5P_EXT_INT 14 select S5P_EXT_INT
13 select SAMSUNG_DMADEV
14 help 15 help
15 Enable S5PC100 CPU support 16 Enable S5PC100 CPU support
16 17
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index 8c3abe521757..f60f2862856d 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -11,10 +11,11 @@ if ARCH_S5PV210
11 11
12config CPU_S5PV210 12config CPU_S5PV210
13 bool 13 bool
14 select ARM_AMBA
15 select PL330_DMA if DMADEVICES
14 select S5P_EXT_INT 16 select S5P_EXT_INT
15 select S5P_PM if PM 17 select S5P_PM if PM
16 select S5P_SLEEP if PM 18 select S5P_SLEEP if PM
17 select SAMSUNG_DMADEV
18 help 19 help
19 Enable S5PV210 CPU support 20 Enable S5PV210 CPU support
20 21
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index dbd954e61aa7..798073057e51 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -1,7 +1,7 @@
1config ARCH_SHMOBILE 1config ARCH_SHMOBILE
2 bool 2 bool
3 3
4config ARCH_SHMOBILE_MULTI 4menuconfig ARCH_SHMOBILE_MULTI
5 bool "Renesas ARM SoCs" if ARCH_MULTI_V7 5 bool "Renesas ARM SoCs" if ARCH_MULTI_V7
6 depends on MMU 6 depends on MMU
7 select ARCH_SHMOBILE 7 select ARCH_SHMOBILE
@@ -15,7 +15,7 @@ config ARCH_SHMOBILE_MULTI
15 15
16if ARCH_SHMOBILE_MULTI 16if ARCH_SHMOBILE_MULTI
17 17
18comment "Renesas ARM SoCs System Type" 18#comment "Renesas ARM SoCs System Type"
19 19
20config ARCH_EMEV2 20config ARCH_EMEV2
21 bool "Emma Mobile EV2" 21 bool "Emma Mobile EV2"
@@ -85,7 +85,6 @@ config ARCH_R8A73A4
85 select CPU_V7 85 select CPU_V7
86 select SH_CLK_CPG 86 select SH_CLK_CPG
87 select RENESAS_IRQC 87 select RENESAS_IRQC
88 select ARCH_HAS_CPUFREQ
89 select ARCH_HAS_OPP 88 select ARCH_HAS_OPP
90 select SYS_SUPPORTS_SH_CMT 89 select SYS_SUPPORTS_SH_CMT
91 select SYS_SUPPORTS_SH_TMU 90 select SYS_SUPPORTS_SH_TMU
@@ -264,7 +263,6 @@ config MACH_KOELSCH
264config MACH_KZM9G 263config MACH_KZM9G
265 bool "KZM-A9-GT board" 264 bool "KZM-A9-GT board"
266 depends on ARCH_SH73A0 265 depends on ARCH_SH73A0
267 select ARCH_HAS_CPUFREQ
268 select ARCH_HAS_OPP 266 select ARCH_HAS_OPP
269 select ARCH_REQUIRE_GPIOLIB 267 select ARCH_REQUIRE_GPIOLIB
270 select REGULATOR_FIXED_VOLTAGE if REGULATOR 268 select REGULATOR_FIXED_VOLTAGE if REGULATOR
diff --git a/arch/arm/mach-spear/Kconfig b/arch/arm/mach-spear/Kconfig
index 0786249b2832..90df2022276a 100644
--- a/arch/arm/mach-spear/Kconfig
+++ b/arch/arm/mach-spear/Kconfig
@@ -14,7 +14,6 @@ if PLAT_SPEAR
14config ARCH_SPEAR13XX 14config ARCH_SPEAR13XX
15 bool "ST SPEAr13xx" 15 bool "ST SPEAr13xx"
16 depends on ARCH_MULTI_V7 || PLAT_SPEAR_SINGLE 16 depends on ARCH_MULTI_V7 || PLAT_SPEAR_SINGLE
17 select ARCH_HAS_CPUFREQ
18 select ARM_GIC 17 select ARM_GIC
19 select GPIO_SPEAR_SPICS 18 select GPIO_SPEAR_SPICS
20 select HAVE_ARM_SCU if SMP 19 select HAVE_ARM_SCU if SMP
diff --git a/arch/arm/mach-sti/Kconfig b/arch/arm/mach-sti/Kconfig
index abf9ee9bbc3f..7e33e9d2c42e 100644
--- a/arch/arm/mach-sti/Kconfig
+++ b/arch/arm/mach-sti/Kconfig
@@ -1,5 +1,5 @@
1menuconfig ARCH_STI 1menuconfig ARCH_STI
2 bool "STMicroelectronics Consumer Electronics SOCs with Device Trees" if ARCH_MULTI_V7 2 bool "STMicroelectronics Consumer Electronics SOCs" if ARCH_MULTI_V7
3 select ARM_GIC 3 select ARM_GIC
4 select ARM_GLOBAL_TIMER 4 select ARM_GLOBAL_TIMER
5 select PINCTRL 5 select PINCTRL
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index e16999e5b735..095399618ca5 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -1,6 +1,5 @@
1config ARCH_TEGRA 1menuconfig ARCH_TEGRA
2 bool "NVIDIA Tegra" if ARCH_MULTI_V7 2 bool "NVIDIA Tegra" if ARCH_MULTI_V7
3 select ARCH_HAS_CPUFREQ
4 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
5 select ARCH_SUPPORTS_TRUSTED_FOUNDATIONS 4 select ARCH_SUPPORTS_TRUSTED_FOUNDATIONS
6 select ARM_GIC 5 select ARM_GIC
@@ -16,8 +15,7 @@ config ARCH_TEGRA
16 help 15 help
17 This enables support for NVIDIA Tegra based systems. 16 This enables support for NVIDIA Tegra based systems.
18 17
19menu "NVIDIA Tegra options" 18if ARCH_TEGRA
20 depends on ARCH_TEGRA
21 19
22config ARCH_TEGRA_2x_SOC 20config ARCH_TEGRA_2x_SOC
23 bool "Enable support for Tegra20 family" 21 bool "Enable support for Tegra20 family"
@@ -69,4 +67,4 @@ config TEGRA_AHB
69 which controls AHB bus master arbitration and some 67 which controls AHB bus master arbitration and some
70 performance parameters(priority, prefech size). 68 performance parameters(priority, prefech size).
71 69
72endmenu 70endif
diff --git a/arch/arm/mach-u300/Kconfig b/arch/arm/mach-u300/Kconfig
index e3a96d7302e9..bc51a71394af 100644
--- a/arch/arm/mach-u300/Kconfig
+++ b/arch/arm/mach-u300/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_U300 1menuconfig ARCH_U300
2 bool "ST-Ericsson U300 Series" if ARCH_MULTI_V5 2 bool "ST-Ericsson U300 Series" if ARCH_MULTI_V5
3 depends on MMU 3 depends on MMU
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
@@ -16,8 +16,6 @@ config ARCH_U300
16 16
17if ARCH_U300 17if ARCH_U300
18 18
19menu "ST-Ericsson AB U300/U335 Platform"
20
21config MACH_U300 19config MACH_U300
22 depends on ARCH_U300 20 depends on ARCH_U300
23 bool "U300" 21 bool "U300"
@@ -43,6 +41,4 @@ config MACH_U300_SPIDUMMY
43 you don't need it. Selecting this will activate the 41 you don't need it. Selecting this will activate the
44 SPI framework and ARM PL022 support. 42 SPI framework and ARM PL022 support.
45 43
46endmenu
47
48endif 44endif
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index b41a42da1505..5be7c4583a93 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -1,9 +1,8 @@
1config ARCH_U8500 1menuconfig ARCH_U8500
2 bool "ST-Ericsson U8500 Series" if ARCH_MULTI_V7 2 bool "ST-Ericsson U8500 Series" if ARCH_MULTI_V7
3 depends on MMU 3 depends on MMU
4 select AB8500_CORE 4 select AB8500_CORE
5 select ABX500_CORE 5 select ABX500_CORE
6 select ARCH_HAS_CPUFREQ
7 select ARCH_REQUIRE_GPIOLIB 6 select ARCH_REQUIRE_GPIOLIB
8 select ARM_AMBA 7 select ARM_AMBA
9 select ARM_ERRATA_754322 8 select ARM_ERRATA_754322
@@ -34,8 +33,6 @@ config UX500_SOC_DB8500
34 select REGULATOR 33 select REGULATOR
35 select REGULATOR_DB8500_PRCMU 34 select REGULATOR_DB8500_PRCMU
36 35
37menu "Ux500 target platform (boards)"
38
39config MACH_MOP500 36config MACH_MOP500
40 bool "U8500 Development platform, MOP500 versions" 37 bool "U8500 Development platform, MOP500 versions"
41 select I2C 38 select I2C
@@ -68,8 +65,6 @@ config UX500_AUTO_PLATFORM
68 a working kernel. If everything else is disabled, this 65 a working kernel. If everything else is disabled, this
69 automatically enables MACH_MOP500. 66 automatically enables MACH_MOP500.
70 67
71endmenu
72
73config UX500_DEBUG_UART 68config UX500_DEBUG_UART
74 int "Ux500 UART to use for low-level debug" 69 int "Ux500 UART to use for low-level debug"
75 default 2 70 default 2
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 90249cfc37b3..99c1f151c403 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -1,4 +1,4 @@
1config ARCH_VEXPRESS 1menuconfig ARCH_VEXPRESS
2 bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7 2 bool "ARM Ltd. Versatile Express family" if ARCH_MULTI_V7
3 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
4 select ARCH_SUPPORTS_BIG_ENDIAN 4 select ARCH_SUPPORTS_BIG_ENDIAN
@@ -37,8 +37,7 @@ config ARCH_VEXPRESS
37 platforms. The traditional (ATAGs) boot method is not usable on 37 platforms. The traditional (ATAGs) boot method is not usable on
38 these boards with this option. 38 these boards with this option.
39 39
40menu "Versatile Express platform type" 40if ARCH_VEXPRESS
41 depends on ARCH_VEXPRESS
42 41
43config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA 42config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
44 bool "Enable A5 and A9 only errata work-arounds" 43 bool "Enable A5 and A9 only errata work-arounds"
@@ -65,7 +64,6 @@ config ARCH_VEXPRESS_DCSCB
65 64
66config ARCH_VEXPRESS_SPC 65config ARCH_VEXPRESS_SPC
67 bool "Versatile Express Serial Power Controller (SPC)" 66 bool "Versatile Express Serial Power Controller (SPC)"
68 select ARCH_HAS_CPUFREQ
69 select ARCH_HAS_OPP 67 select ARCH_HAS_OPP
70 select PM_OPP 68 select PM_OPP
71 help 69 help
@@ -83,4 +81,4 @@ config ARCH_VEXPRESS_TC2_PM
83 Support for CPU and cluster power management on Versatile Express 81 Support for CPU and cluster power management on Versatile Express
84 with a TC2 (A15x2 A7x3) big.LITTLE core tile. 82 with a TC2 (A15x2 A7x3) big.LITTLE core tile.
85 83
86endmenu 84endif
diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 08f56a41cb55..aaaa24fe4d71 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -1,6 +1,5 @@
1config ARCH_VT8500 1config ARCH_VT8500
2 bool 2 bool
3 select ARCH_HAS_CPUFREQ
4 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
5 select CLKDEV_LOOKUP 4 select CLKDEV_LOOKUP
6 select VT8500_TIMER 5 select VT8500_TIMER
diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig
index 573e0db1d0f0..0c164f81e72d 100644
--- a/arch/arm/mach-zynq/Kconfig
+++ b/arch/arm/mach-zynq/Kconfig
@@ -1,6 +1,5 @@
1config ARCH_ZYNQ 1config ARCH_ZYNQ
2 bool "Xilinx Zynq ARM Cortex A9 Platform" if ARCH_MULTI_V7 2 bool "Xilinx Zynq ARM Cortex A9 Platform" if ARCH_MULTI_V7
3 select ARCH_HAS_CPUFREQ
4 select ARCH_HAS_OPP 3 select ARCH_HAS_OPP
5 select ARCH_SUPPORTS_BIG_ENDIAN 4 select ARCH_SUPPORTS_BIG_ENDIAN
6 select ARM_AMBA 5 select ARM_AMBA
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 243dfcb2ca0e..301b892d97d9 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -35,27 +35,15 @@ config SAMSUNG_PM
35 Base platform power management code for samsung code 35 Base platform power management code for samsung code
36 36
37if PLAT_SAMSUNG 37if PLAT_SAMSUNG
38menu "Samsung Common options"
38 39
39# boot configurations 40# boot configurations
40 41
41comment "Boot options" 42comment "Boot options"
42 43
43config S3C_BOOT_ERROR_RESET
44 bool "S3C Reboot on decompression error"
45 help
46 Say y here to use the watchdog to reset the system if the
47 kernel decompressor detects an error during decompression.
48
49config S3C_BOOT_UART_FORCE_FIFO
50 bool "Force UART FIFO on during boot process"
51 default y
52 help
53 Say Y here to force the UART FIFOs on during the kernel
54 uncompressor
55
56
57config S3C_LOWLEVEL_UART_PORT 44config S3C_LOWLEVEL_UART_PORT
58 int "S3C UART to use for low-level messages" 45 int "S3C UART to use for low-level messages"
46 depends on ARCH_S3C64XX
59 default 0 47 default 0
60 help 48 help
61 Choice of which UART port to use for the low-level messages, 49 Choice of which UART port to use for the low-level messages,
@@ -407,17 +395,16 @@ config SAMSUNG_PM_GPIO
407 Include legacy GPIO power management code for platforms not using 395 Include legacy GPIO power management code for platforms not using
408 pinctrl-samsung driver. 396 pinctrl-samsung driver.
409 397
410endif
411
412config SAMSUNG_DMADEV 398config SAMSUNG_DMADEV
413 bool 399 bool "Use legacy Samsung DMA abstraction"
414 select ARM_AMBA 400 depends on CPU_S5PV210 || CPU_S5PC100 || ARCH_S5P64X0 || ARCH_S3C64XX
415 select DMADEVICES 401 select DMADEVICES
416 select PL330_DMA if (ARCH_EXYNOS5 || ARCH_EXYNOS4 || CPU_S5PV210 || CPU_S5PC100 || \ 402 default y
417 CPU_S5P6450 || CPU_S5P6440)
418 help 403 help
419 Use DMA device engine for PL330 DMAC. 404 Use DMA device engine for PL330 DMAC.
420 405
406endif
407
421config S5P_DEV_MFC 408config S5P_DEV_MFC
422 bool 409 bool
423 help 410 help
@@ -503,4 +490,5 @@ config DEBUG_S3C_UART
503 default "2" if DEBUG_S3C_UART2 490 default "2" if DEBUG_S3C_UART2
504 default "3" if DEBUG_S3C_UART3 491 default "3" if DEBUG_S3C_UART3
505 492
493endmenu
506endif 494endif
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7295419165e1..a474de346be6 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,8 +1,9 @@
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_USE_CMPXCHG_LOCKREF 4 select ARCH_HAS_OPP
5 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 5 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
6 select ARCH_USE_CMPXCHG_LOCKREF
6 select ARCH_WANT_OPTIONAL_GPIOLIB 7 select ARCH_WANT_OPTIONAL_GPIOLIB
7 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION 8 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
8 select ARCH_WANT_FRAME_POINTERS 9 select ARCH_WANT_FRAME_POINTERS
diff --git a/arch/arm64/boot/dts/apm-mustang.dts b/arch/arm64/boot/dts/apm-mustang.dts
index 1247ca1200b1..6541962f5d70 100644
--- a/arch/arm64/boot/dts/apm-mustang.dts
+++ b/arch/arm64/boot/dts/apm-mustang.dts
@@ -24,3 +24,7 @@
24 reg = < 0x1 0x00000000 0x0 0x80000000 >; /* Updated by bootloader */ 24 reg = < 0x1 0x00000000 0x0 0x80000000 >; /* Updated by bootloader */
25 }; 25 };
26}; 26};
27
28&serial0 {
29 status = "ok";
30};
diff --git a/arch/arm64/boot/dts/apm-storm.dtsi b/arch/arm64/boot/dts/apm-storm.dtsi
index c5f0a47a1375..40aa96ce13c4 100644
--- a/arch/arm64/boot/dts/apm-storm.dtsi
+++ b/arch/arm64/boot/dts/apm-storm.dtsi
@@ -273,8 +273,9 @@
273 }; 273 };
274 274
275 serial0: serial@1c020000 { 275 serial0: serial@1c020000 {
276 status = "disabled";
276 device_type = "serial"; 277 device_type = "serial";
277 compatible = "ns16550"; 278 compatible = "ns16550a";
278 reg = <0 0x1c020000 0x0 0x1000>; 279 reg = <0 0x1c020000 0x0 0x1000>;
279 reg-shift = <2>; 280 reg-shift = <2>;
280 clock-frequency = <10000000>; /* Updated by bootloader */ 281 clock-frequency = <10000000>; /* Updated by bootloader */
@@ -282,6 +283,39 @@
282 interrupts = <0x0 0x4c 0x4>; 283 interrupts = <0x0 0x4c 0x4>;
283 }; 284 };
284 285
286 serial1: serial@1c021000 {
287 status = "disabled";
288 device_type = "serial";
289 compatible = "ns16550a";
290 reg = <0 0x1c021000 0x0 0x1000>;
291 reg-shift = <2>;
292 clock-frequency = <10000000>; /* Updated by bootloader */
293 interrupt-parent = <&gic>;
294 interrupts = <0x0 0x4d 0x4>;
295 };
296
297 serial2: serial@1c022000 {
298 status = "disabled";
299 device_type = "serial";
300 compatible = "ns16550a";
301 reg = <0 0x1c022000 0x0 0x1000>;
302 reg-shift = <2>;
303 clock-frequency = <10000000>; /* Updated by bootloader */
304 interrupt-parent = <&gic>;
305 interrupts = <0x0 0x4e 0x4>;
306 };
307
308 serial3: serial@1c023000 {
309 status = "disabled";
310 device_type = "serial";
311 compatible = "ns16550a";
312 reg = <0 0x1c023000 0x0 0x1000>;
313 reg-shift = <2>;
314 clock-frequency = <10000000>; /* Updated by bootloader */
315 interrupt-parent = <&gic>;
316 interrupts = <0x0 0x4f 0x4>;
317 };
318
285 phy1: phy@1f21a000 { 319 phy1: phy@1f21a000 {
286 compatible = "apm,xgene-phy"; 320 compatible = "apm,xgene-phy";
287 reg = <0x0 0x1f21a000 0x0 0x100>; 321 reg = <0x0 0x1f21a000 0x0 0x100>;
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 157e1d8d9a47..3421f316f5dc 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -6,9 +6,18 @@ CONFIG_NO_HZ_IDLE=y
6CONFIG_HIGH_RES_TIMERS=y 6CONFIG_HIGH_RES_TIMERS=y
7CONFIG_BSD_PROCESS_ACCT=y 7CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_BSD_PROCESS_ACCT_V3=y 8CONFIG_BSD_PROCESS_ACCT_V3=y
9CONFIG_TASKSTATS=y
10CONFIG_TASK_DELAY_ACCT=y
11CONFIG_TASK_XACCT=y
12CONFIG_TASK_IO_ACCOUNTING=y
9CONFIG_IKCONFIG=y 13CONFIG_IKCONFIG=y
10CONFIG_IKCONFIG_PROC=y 14CONFIG_IKCONFIG_PROC=y
11CONFIG_LOG_BUF_SHIFT=14 15CONFIG_LOG_BUF_SHIFT=14
16CONFIG_RESOURCE_COUNTERS=y
17CONFIG_MEMCG=y
18CONFIG_MEMCG_SWAP=y
19CONFIG_MEMCG_KMEM=y
20CONFIG_CGROUP_HUGETLB=y
12# CONFIG_UTS_NS is not set 21# CONFIG_UTS_NS is not set
13# CONFIG_IPC_NS is not set 22# CONFIG_IPC_NS is not set
14# CONFIG_PID_NS is not set 23# CONFIG_PID_NS is not set
@@ -27,6 +36,7 @@ CONFIG_ARCH_VEXPRESS=y
27CONFIG_ARCH_XGENE=y 36CONFIG_ARCH_XGENE=y
28CONFIG_SMP=y 37CONFIG_SMP=y
29CONFIG_PREEMPT=y 38CONFIG_PREEMPT=y
39CONFIG_KSM=y
30CONFIG_TRANSPARENT_HUGEPAGE=y 40CONFIG_TRANSPARENT_HUGEPAGE=y
31CONFIG_CMA=y 41CONFIG_CMA=y
32CONFIG_CMDLINE="console=ttyAMA0" 42CONFIG_CMDLINE="console=ttyAMA0"
@@ -45,6 +55,7 @@ CONFIG_IP_PNP_BOOTP=y
45CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 55CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
46CONFIG_DEVTMPFS=y 56CONFIG_DEVTMPFS=y
47CONFIG_DMA_CMA=y 57CONFIG_DMA_CMA=y
58CONFIG_BLK_DEV_LOOP=y
48CONFIG_VIRTIO_BLK=y 59CONFIG_VIRTIO_BLK=y
49# CONFIG_SCSI_PROC_FS is not set 60# CONFIG_SCSI_PROC_FS is not set
50CONFIG_BLK_DEV_SD=y 61CONFIG_BLK_DEV_SD=y
@@ -53,6 +64,7 @@ CONFIG_ATA=y
53CONFIG_PATA_PLATFORM=y 64CONFIG_PATA_PLATFORM=y
54CONFIG_PATA_OF_PLATFORM=y 65CONFIG_PATA_OF_PLATFORM=y
55CONFIG_NETDEVICES=y 66CONFIG_NETDEVICES=y
67CONFIG_TUN=y
56CONFIG_SMC91X=y 68CONFIG_SMC91X=y
57CONFIG_SMSC911X=y 69CONFIG_SMSC911X=y
58# CONFIG_WLAN is not set 70# CONFIG_WLAN is not set
@@ -85,6 +97,8 @@ CONFIG_EXT3_FS=y
85# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 97# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
86# CONFIG_EXT3_FS_XATTR is not set 98# CONFIG_EXT3_FS_XATTR is not set
87CONFIG_EXT4_FS=y 99CONFIG_EXT4_FS=y
100CONFIG_FANOTIFY=y
101CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
88CONFIG_FUSE_FS=y 102CONFIG_FUSE_FS=y
89CONFIG_CUSE=y 103CONFIG_CUSE=y
90CONFIG_VFAT_FS=y 104CONFIG_VFAT_FS=y
@@ -104,6 +118,7 @@ CONFIG_DEBUG_KERNEL=y
104CONFIG_LOCKUP_DETECTOR=y 118CONFIG_LOCKUP_DETECTOR=y
105# CONFIG_SCHED_DEBUG is not set 119# CONFIG_SCHED_DEBUG is not set
106# CONFIG_FTRACE is not set 120# CONFIG_FTRACE is not set
121CONFIG_SECURITY=y
107CONFIG_CRYPTO_ANSI_CPRNG=y 122CONFIG_CRYPTO_ANSI_CPRNG=y
108CONFIG_ARM64_CRYPTO=y 123CONFIG_ARM64_CRYPTO=y
109CONFIG_CRYPTO_SHA1_ARM64_CE=y 124CONFIG_CRYPTO_SHA1_ARM64_CE=y
diff --git a/arch/arm64/crypto/ghash-ce-core.S b/arch/arm64/crypto/ghash-ce-core.S
index b9e6eaf41c9b..dc457015884e 100644
--- a/arch/arm64/crypto/ghash-ce-core.S
+++ b/arch/arm64/crypto/ghash-ce-core.S
@@ -3,14 +3,6 @@
3 * 3 *
4 * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org> 4 * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
5 * 5 *
6 * Based on arch/x86/crypto/ghash-pmullni-intel_asm.S
7 *
8 * Copyright (c) 2009 Intel Corp.
9 * Author: Huang Ying <ying.huang@intel.com>
10 * Vinodh Gopal
11 * Erdinc Ozturk
12 * Deniz Karakoyunlu
13 *
14 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published 7 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation. 8 * by the Free Software Foundation.
@@ -19,13 +11,15 @@
19#include <linux/linkage.h> 11#include <linux/linkage.h>
20#include <asm/assembler.h> 12#include <asm/assembler.h>
21 13
22 DATA .req v0 14 SHASH .req v0
23 SHASH .req v1 15 SHASH2 .req v1
24 IN1 .req v2
25 T1 .req v2 16 T1 .req v2
26 T2 .req v3 17 T2 .req v3
27 T3 .req v4 18 MASK .req v4
28 VZR .req v5 19 XL .req v5
20 XM .req v6
21 XH .req v7
22 IN1 .req v7
29 23
30 .text 24 .text
31 .arch armv8-a+crypto 25 .arch armv8-a+crypto
@@ -35,61 +29,51 @@
35 * struct ghash_key const *k, const char *head) 29 * struct ghash_key const *k, const char *head)
36 */ 30 */
37ENTRY(pmull_ghash_update) 31ENTRY(pmull_ghash_update)
38 ld1 {DATA.16b}, [x1]
39 ld1 {SHASH.16b}, [x3] 32 ld1 {SHASH.16b}, [x3]
40 eor VZR.16b, VZR.16b, VZR.16b 33 ld1 {XL.16b}, [x1]
34 movi MASK.16b, #0xe1
35 ext SHASH2.16b, SHASH.16b, SHASH.16b, #8
36 shl MASK.2d, MASK.2d, #57
37 eor SHASH2.16b, SHASH2.16b, SHASH.16b
41 38
42 /* do the head block first, if supplied */ 39 /* do the head block first, if supplied */
43 cbz x4, 0f 40 cbz x4, 0f
44 ld1 {IN1.2d}, [x4] 41 ld1 {T1.2d}, [x4]
45 b 1f 42 b 1f
46 43
470: ld1 {IN1.2d}, [x2], #16 440: ld1 {T1.2d}, [x2], #16
48 sub w0, w0, #1 45 sub w0, w0, #1
491: ext IN1.16b, IN1.16b, IN1.16b, #8
50CPU_LE( rev64 IN1.16b, IN1.16b )
51 eor DATA.16b, DATA.16b, IN1.16b
52 46
53 /* multiply DATA by SHASH in GF(2^128) */ 471: /* multiply XL by SHASH in GF(2^128) */
54 ext T2.16b, DATA.16b, DATA.16b, #8 48CPU_LE( rev64 T1.16b, T1.16b )
55 ext T3.16b, SHASH.16b, SHASH.16b, #8
56 eor T2.16b, T2.16b, DATA.16b
57 eor T3.16b, T3.16b, SHASH.16b
58 49
59 pmull2 T1.1q, SHASH.2d, DATA.2d // a1 * b1 50 ext T2.16b, XL.16b, XL.16b, #8
60 pmull DATA.1q, SHASH.1d, DATA.1d // a0 * b0 51 ext IN1.16b, T1.16b, T1.16b, #8
61 pmull T2.1q, T2.1d, T3.1d // (a1 + a0)(b1 + b0) 52 eor T1.16b, T1.16b, T2.16b
62 eor T2.16b, T2.16b, T1.16b // (a0 * b1) + (a1 * b0) 53 eor XL.16b, XL.16b, IN1.16b
63 eor T2.16b, T2.16b, DATA.16b
64 54
65 ext T3.16b, VZR.16b, T2.16b, #8 55 pmull2 XH.1q, SHASH.2d, XL.2d // a1 * b1
66 ext T2.16b, T2.16b, VZR.16b, #8 56 eor T1.16b, T1.16b, XL.16b
67 eor DATA.16b, DATA.16b, T3.16b 57 pmull XL.1q, SHASH.1d, XL.1d // a0 * b0
68 eor T1.16b, T1.16b, T2.16b // <T1:DATA> is result of 58 pmull XM.1q, SHASH2.1d, T1.1d // (a1 + a0)(b1 + b0)
69 // carry-less multiplication
70 59
71 /* first phase of the reduction */ 60 ext T1.16b, XL.16b, XH.16b, #8
72 shl T3.2d, DATA.2d, #1 61 eor T2.16b, XL.16b, XH.16b
73 eor T3.16b, T3.16b, DATA.16b 62 eor XM.16b, XM.16b, T1.16b
74 shl T3.2d, T3.2d, #5 63 eor XM.16b, XM.16b, T2.16b
75 eor T3.16b, T3.16b, DATA.16b 64 pmull T2.1q, XL.1d, MASK.1d
76 shl T3.2d, T3.2d, #57
77 ext T2.16b, VZR.16b, T3.16b, #8
78 ext T3.16b, T3.16b, VZR.16b, #8
79 eor DATA.16b, DATA.16b, T2.16b
80 eor T1.16b, T1.16b, T3.16b
81 65
82 /* second phase of the reduction */ 66 mov XH.d[0], XM.d[1]
83 ushr T2.2d, DATA.2d, #5 67 mov XM.d[1], XL.d[0]
84 eor T2.16b, T2.16b, DATA.16b 68
85 ushr T2.2d, T2.2d, #1 69 eor XL.16b, XM.16b, T2.16b
86 eor T2.16b, T2.16b, DATA.16b 70 ext T2.16b, XL.16b, XL.16b, #8
87 ushr T2.2d, T2.2d, #1 71 pmull XL.1q, XL.1d, MASK.1d
88 eor T1.16b, T1.16b, T2.16b 72 eor T2.16b, T2.16b, XH.16b
89 eor DATA.16b, DATA.16b, T1.16b 73 eor XL.16b, XL.16b, T2.16b
90 74
91 cbnz w0, 0b 75 cbnz w0, 0b
92 76
93 st1 {DATA.16b}, [x1] 77 st1 {XL.16b}, [x1]
94 ret 78 ret
95ENDPROC(pmull_ghash_update) 79ENDPROC(pmull_ghash_update)
diff --git a/arch/arm64/crypto/ghash-ce-glue.c b/arch/arm64/crypto/ghash-ce-glue.c
index b92baf3f68c7..833ec1e3f3e9 100644
--- a/arch/arm64/crypto/ghash-ce-glue.c
+++ b/arch/arm64/crypto/ghash-ce-glue.c
@@ -67,11 +67,12 @@ static int ghash_update(struct shash_desc *desc, const u8 *src,
67 blocks = len / GHASH_BLOCK_SIZE; 67 blocks = len / GHASH_BLOCK_SIZE;
68 len %= GHASH_BLOCK_SIZE; 68 len %= GHASH_BLOCK_SIZE;
69 69
70 kernel_neon_begin_partial(6); 70 kernel_neon_begin_partial(8);
71 pmull_ghash_update(blocks, ctx->digest, src, key, 71 pmull_ghash_update(blocks, ctx->digest, src, key,
72 partial ? ctx->buf : NULL); 72 partial ? ctx->buf : NULL);
73 kernel_neon_end(); 73 kernel_neon_end();
74 src += blocks * GHASH_BLOCK_SIZE; 74 src += blocks * GHASH_BLOCK_SIZE;
75 partial = 0;
75 } 76 }
76 if (len) 77 if (len)
77 memcpy(ctx->buf + partial, src, len); 78 memcpy(ctx->buf + partial, src, len);
@@ -88,7 +89,7 @@ static int ghash_final(struct shash_desc *desc, u8 *dst)
88 89
89 memset(ctx->buf + partial, 0, GHASH_BLOCK_SIZE - partial); 90 memset(ctx->buf + partial, 0, GHASH_BLOCK_SIZE - partial);
90 91
91 kernel_neon_begin_partial(6); 92 kernel_neon_begin_partial(8);
92 pmull_ghash_update(1, ctx->digest, ctx->buf, key, NULL); 93 pmull_ghash_update(1, ctx->digest, ctx->buf, key, NULL);
93 kernel_neon_end(); 94 kernel_neon_end();
94 } 95 }
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 42c7eecd2bb6..0b3fcf86e6ba 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -30,7 +30,6 @@ generic-y += msgbuf.h
30generic-y += mutex.h 30generic-y += mutex.h
31generic-y += pci.h 31generic-y += pci.h
32generic-y += poll.h 32generic-y += poll.h
33generic-y += posix_types.h
34generic-y += preempt.h 33generic-y += preempt.h
35generic-y += resource.h 34generic-y += resource.h
36generic-y += rwsem.h 35generic-y += rwsem.h
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index 3a4572ec3273..dc82e52acdb3 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -26,8 +26,6 @@
26#include <xen/xen.h> 26#include <xen/xen.h>
27#include <asm/xen/hypervisor.h> 27#include <asm/xen/hypervisor.h>
28 28
29#define ARCH_HAS_DMA_GET_REQUIRED_MASK
30
31#define DMA_ERROR_CODE (~(dma_addr_t)0) 29#define DMA_ERROR_CODE (~(dma_addr_t)0)
32extern struct dma_map_ops *dma_ops; 30extern struct dma_map_ops *dma_ops;
33extern struct dma_map_ops coherent_swiotlb_dma_ops; 31extern struct dma_map_ops coherent_swiotlb_dma_ops;
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 598cc384fc1c..579702086488 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -246,7 +246,7 @@ static inline pmd_t pte_pmd(pte_t pte)
246#define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd))) 246#define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
247#define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd))) 247#define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
248#define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd))) 248#define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
249#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) &= ~PMD_TYPE_MASK)) 249#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) & ~PMD_TYPE_MASK))
250 250
251#define __HAVE_ARCH_PMD_WRITE 251#define __HAVE_ARCH_PMD_WRITE
252#define pmd_write(pmd) pte_write(pmd_pte(pmd)) 252#define pmd_write(pmd) pte_write(pmd_pte(pmd))
diff --git a/arch/arm64/include/uapi/asm/posix_types.h b/arch/arm64/include/uapi/asm/posix_types.h
new file mode 100644
index 000000000000..7985ff60ca3f
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/posix_types.h
@@ -0,0 +1,10 @@
1#ifndef __ASM_POSIX_TYPES_H
2#define __ASM_POSIX_TYPES_H
3
4typedef unsigned short __kernel_old_uid_t;
5typedef unsigned short __kernel_old_gid_t;
6#define __kernel_old_uid_t __kernel_old_uid_t
7
8#include <asm-generic/posix_types.h>
9
10#endif /* __ASM_POSIX_TYPES_H */
diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h
index b72cf405b3fe..ee469be1ae1d 100644
--- a/arch/arm64/include/uapi/asm/sigcontext.h
+++ b/arch/arm64/include/uapi/asm/sigcontext.h
@@ -58,7 +58,7 @@ struct fpsimd_context {
58 58
59struct esr_context { 59struct esr_context {
60 struct _aarch64_ctx head; 60 struct _aarch64_ctx head;
61 u64 esr; 61 __u64 esr;
62}; 62};
63 63
64#endif /* _UAPI__ASM_SIGCONTEXT_H */ 64#endif /* _UAPI__ASM_SIGCONTEXT_H */
diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S
index b051871f2965..aa5f9fcbf9ee 100644
--- a/arch/arm64/kernel/entry-ftrace.S
+++ b/arch/arm64/kernel/entry-ftrace.S
@@ -205,7 +205,7 @@ ENDPROC(ftrace_graph_caller)
205 * 205 *
206 * Run ftrace_return_to_handler() before going back to parent. 206 * Run ftrace_return_to_handler() before going back to parent.
207 * @fp is checked against the value passed by ftrace_graph_caller() 207 * @fp is checked against the value passed by ftrace_graph_caller()
208 * only when CONFIG_FUNCTION_GRAPH_FP_TEST is enabled. 208 * only when CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST is enabled.
209 */ 209 */
210ENTRY(return_to_handler) 210ENTRY(return_to_handler)
211 str x0, [sp, #-16]! 211 str x0, [sp, #-16]!
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index bf017f4ffb4f..9ce04ba6bcb0 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -279,7 +279,6 @@ el1_sp_pc:
279 */ 279 */
280 mrs x0, far_el1 280 mrs x0, far_el1
281 enable_dbg 281 enable_dbg
282 mov x1, x25
283 mov x2, sp 282 mov x2, sp
284 b do_sp_pc_abort 283 b do_sp_pc_abort
285el1_undef: 284el1_undef:
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 3e926b9c0641..9fde010c945f 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -655,11 +655,16 @@ static int compat_gpr_get(struct task_struct *target,
655 reg = task_pt_regs(target)->regs[idx]; 655 reg = task_pt_regs(target)->regs[idx];
656 } 656 }
657 657
658 ret = copy_to_user(ubuf, &reg, sizeof(reg)); 658 if (kbuf) {
659 if (ret) 659 memcpy(kbuf, &reg, sizeof(reg));
660 break; 660 kbuf += sizeof(reg);
661 661 } else {
662 ubuf += sizeof(reg); 662 ret = copy_to_user(ubuf, &reg, sizeof(reg));
663 if (ret)
664 break;
665
666 ubuf += sizeof(reg);
667 }
663 } 668 }
664 669
665 return ret; 670 return ret;
@@ -689,11 +694,16 @@ static int compat_gpr_set(struct task_struct *target,
689 unsigned int idx = start + i; 694 unsigned int idx = start + i;
690 compat_ulong_t reg; 695 compat_ulong_t reg;
691 696
692 ret = copy_from_user(&reg, ubuf, sizeof(reg)); 697 if (kbuf) {
693 if (ret) 698 memcpy(&reg, kbuf, sizeof(reg));
694 return ret; 699 kbuf += sizeof(reg);
700 } else {
701 ret = copy_from_user(&reg, ubuf, sizeof(reg));
702 if (ret)
703 return ret;
695 704
696 ubuf += sizeof(reg); 705 ubuf += sizeof(reg);
706 }
697 707
698 switch (idx) { 708 switch (idx) {
699 case 15: 709 case 15:
@@ -827,6 +837,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
827 compat_ulong_t val) 837 compat_ulong_t val)
828{ 838{
829 int ret; 839 int ret;
840 mm_segment_t old_fs = get_fs();
830 841
831 if (off & 3 || off >= COMPAT_USER_SZ) 842 if (off & 3 || off >= COMPAT_USER_SZ)
832 return -EIO; 843 return -EIO;
@@ -834,10 +845,13 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
834 if (off >= sizeof(compat_elf_gregset_t)) 845 if (off >= sizeof(compat_elf_gregset_t))
835 return 0; 846 return 0;
836 847
848 set_fs(KERNEL_DS);
837 ret = copy_regset_from_user(tsk, &user_aarch32_view, 849 ret = copy_regset_from_user(tsk, &user_aarch32_view,
838 REGSET_COMPAT_GPR, off, 850 REGSET_COMPAT_GPR, off,
839 sizeof(compat_ulong_t), 851 sizeof(compat_ulong_t),
840 &val); 852 &val);
853 set_fs(old_fs);
854
841 return ret; 855 return ret;
842} 856}
843 857
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 091d428d64ac..f43db8a69262 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -71,7 +71,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
71 /* 4GB maximum for 32-bit only capable devices */ 71 /* 4GB maximum for 32-bit only capable devices */
72 if (IS_ENABLED(CONFIG_ZONE_DMA)) { 72 if (IS_ENABLED(CONFIG_ZONE_DMA)) {
73 unsigned long max_dma_phys = 73 unsigned long max_dma_phys =
74 (unsigned long)dma_to_phys(NULL, DMA_BIT_MASK(32) + 1); 74 (unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1);
75 max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT)); 75 max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT));
76 zone_size[ZONE_DMA] = max_dma - min; 76 zone_size[ZONE_DMA] = max_dma - min;
77 } 77 }
@@ -126,6 +126,8 @@ static void arm64_memory_present(void)
126 126
127void __init arm64_memblock_init(void) 127void __init arm64_memblock_init(void)
128{ 128{
129 phys_addr_t dma_phys_limit = 0;
130
129 /* Register the kernel text, kernel data and initrd with memblock */ 131 /* Register the kernel text, kernel data and initrd with memblock */
130 memblock_reserve(__pa(_text), _end - _text); 132 memblock_reserve(__pa(_text), _end - _text);
131#ifdef CONFIG_BLK_DEV_INITRD 133#ifdef CONFIG_BLK_DEV_INITRD
@@ -141,7 +143,11 @@ void __init arm64_memblock_init(void)
141 memblock_reserve(__pa(idmap_pg_dir), IDMAP_DIR_SIZE); 143 memblock_reserve(__pa(idmap_pg_dir), IDMAP_DIR_SIZE);
142 144
143 early_init_fdt_scan_reserved_mem(); 145 early_init_fdt_scan_reserved_mem();
144 dma_contiguous_reserve(0); 146
147 /* 4GB maximum for 32-bit only capable devices */
148 if (IS_ENABLED(CONFIG_ZONE_DMA))
149 dma_phys_limit = dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1;
150 dma_contiguous_reserve(dma_phys_limit);
145 151
146 memblock_allow_resize(); 152 memblock_allow_resize();
147 memblock_dump_all(); 153 memblock_dump_all();
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 1a871b78e570..344387a55406 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -242,7 +242,7 @@ struct ioc {
242 struct pci_dev *sac_only_dev; 242 struct pci_dev *sac_only_dev;
243}; 243};
244 244
245static struct ioc *ioc_list; 245static struct ioc *ioc_list, *ioc_found;
246static int reserve_sba_gart = 1; 246static int reserve_sba_gart = 1;
247 247
248static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); 248static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
@@ -1809,20 +1809,13 @@ static struct ioc_iommu ioc_iommu_info[] __initdata = {
1809 { SX2000_IOC_ID, "sx2000", NULL }, 1809 { SX2000_IOC_ID, "sx2000", NULL },
1810}; 1810};
1811 1811
1812static struct ioc * 1812static void ioc_init(unsigned long hpa, struct ioc *ioc)
1813ioc_init(unsigned long hpa, void *handle)
1814{ 1813{
1815 struct ioc *ioc;
1816 struct ioc_iommu *info; 1814 struct ioc_iommu *info;
1817 1815
1818 ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
1819 if (!ioc)
1820 return NULL;
1821
1822 ioc->next = ioc_list; 1816 ioc->next = ioc_list;
1823 ioc_list = ioc; 1817 ioc_list = ioc;
1824 1818
1825 ioc->handle = handle;
1826 ioc->ioc_hpa = ioremap(hpa, 0x1000); 1819 ioc->ioc_hpa = ioremap(hpa, 0x1000);
1827 1820
1828 ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID); 1821 ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID);
@@ -1863,8 +1856,6 @@ ioc_init(unsigned long hpa, void *handle)
1863 "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n", 1856 "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n",
1864 ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF, 1857 ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF,
1865 hpa, ioc->iov_size >> 20, ioc->ibase); 1858 hpa, ioc->iov_size >> 20, ioc->ibase);
1866
1867 return ioc;
1868} 1859}
1869 1860
1870 1861
@@ -2031,22 +2022,21 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
2031#endif 2022#endif
2032} 2023}
2033 2024
2034static int 2025static void acpi_sba_ioc_add(struct ioc *ioc)
2035acpi_sba_ioc_add(struct acpi_device *device,
2036 const struct acpi_device_id *not_used)
2037{ 2026{
2038 struct ioc *ioc; 2027 acpi_handle handle = ioc->handle;
2039 acpi_status status; 2028 acpi_status status;
2040 u64 hpa, length; 2029 u64 hpa, length;
2041 struct acpi_device_info *adi; 2030 struct acpi_device_info *adi;
2042 2031
2043 status = hp_acpi_csr_space(device->handle, &hpa, &length); 2032 ioc_found = ioc->next;
2033 status = hp_acpi_csr_space(handle, &hpa, &length);
2044 if (ACPI_FAILURE(status)) 2034 if (ACPI_FAILURE(status))
2045 return 1; 2035 goto err;
2046 2036
2047 status = acpi_get_object_info(device->handle, &adi); 2037 status = acpi_get_object_info(handle, &adi);
2048 if (ACPI_FAILURE(status)) 2038 if (ACPI_FAILURE(status))
2049 return 1; 2039 goto err;
2050 2040
2051 /* 2041 /*
2052 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI 2042 * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI
@@ -2067,13 +2057,13 @@ acpi_sba_ioc_add(struct acpi_device *device,
2067 if (!iovp_shift) 2057 if (!iovp_shift)
2068 iovp_shift = 12; 2058 iovp_shift = 12;
2069 2059
2070 ioc = ioc_init(hpa, device->handle); 2060 ioc_init(hpa, ioc);
2071 if (!ioc)
2072 return 1;
2073
2074 /* setup NUMA node association */ 2061 /* setup NUMA node association */
2075 sba_map_ioc_to_node(ioc, device->handle); 2062 sba_map_ioc_to_node(ioc, handle);
2076 return 0; 2063 return;
2064
2065 err:
2066 kfree(ioc);
2077} 2067}
2078 2068
2079static const struct acpi_device_id hp_ioc_iommu_device_ids[] = { 2069static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
@@ -2081,9 +2071,26 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
2081 {"HWP0004", 0}, 2071 {"HWP0004", 0},
2082 {"", 0}, 2072 {"", 0},
2083}; 2073};
2074
2075static int acpi_sba_ioc_attach(struct acpi_device *device,
2076 const struct acpi_device_id *not_used)
2077{
2078 struct ioc *ioc;
2079
2080 ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
2081 if (!ioc)
2082 return -ENOMEM;
2083
2084 ioc->next = ioc_found;
2085 ioc_found = ioc;
2086 ioc->handle = device->handle;
2087 return 1;
2088}
2089
2090
2084static struct acpi_scan_handler acpi_sba_ioc_handler = { 2091static struct acpi_scan_handler acpi_sba_ioc_handler = {
2085 .ids = hp_ioc_iommu_device_ids, 2092 .ids = hp_ioc_iommu_device_ids,
2086 .attach = acpi_sba_ioc_add, 2093 .attach = acpi_sba_ioc_attach,
2087}; 2094};
2088 2095
2089static int __init acpi_sba_ioc_init_acpi(void) 2096static int __init acpi_sba_ioc_init_acpi(void)
@@ -2118,9 +2125,12 @@ sba_init(void)
2118#endif 2125#endif
2119 2126
2120 /* 2127 /*
2121 * ioc_list should be populated by the acpi_sba_ioc_handler's .attach() 2128 * ioc_found should be populated by the acpi_sba_ioc_handler's .attach()
2122 * routine, but that only happens if acpi_scan_init() has already run. 2129 * routine, but that only happens if acpi_scan_init() has already run.
2123 */ 2130 */
2131 while (ioc_found)
2132 acpi_sba_ioc_add(ioc_found);
2133
2124 if (!ioc_list) { 2134 if (!ioc_list) {
2125#ifdef CONFIG_IA64_GENERIC 2135#ifdef CONFIG_IA64_GENERIC
2126 /* 2136 /*
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig
index 8df022c43af7..fd09a10a2b53 100644
--- a/arch/s390/configs/default_defconfig
+++ b/arch/s390/configs/default_defconfig
@@ -45,7 +45,8 @@ CONFIG_SOLARIS_X86_PARTITION=y
45CONFIG_UNIXWARE_DISKLABEL=y 45CONFIG_UNIXWARE_DISKLABEL=y
46CONFIG_CFQ_GROUP_IOSCHED=y 46CONFIG_CFQ_GROUP_IOSCHED=y
47CONFIG_DEFAULT_DEADLINE=y 47CONFIG_DEFAULT_DEADLINE=y
48CONFIG_MARCH_Z9_109=y 48CONFIG_MARCH_Z196=y
49CONFIG_TUNE_ZEC12=y
49CONFIG_NR_CPUS=256 50CONFIG_NR_CPUS=256
50CONFIG_PREEMPT=y 51CONFIG_PREEMPT=y
51CONFIG_HZ_100=y 52CONFIG_HZ_100=y
@@ -240,7 +241,6 @@ CONFIG_IP_VS_PE_SIP=m
240CONFIG_NF_CONNTRACK_IPV4=m 241CONFIG_NF_CONNTRACK_IPV4=m
241# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 242# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
242CONFIG_NF_TABLES_IPV4=m 243CONFIG_NF_TABLES_IPV4=m
243CONFIG_NFT_REJECT_IPV4=m
244CONFIG_NFT_CHAIN_ROUTE_IPV4=m 244CONFIG_NFT_CHAIN_ROUTE_IPV4=m
245CONFIG_NFT_CHAIN_NAT_IPV4=m 245CONFIG_NFT_CHAIN_NAT_IPV4=m
246CONFIG_NF_TABLES_ARP=m 246CONFIG_NF_TABLES_ARP=m
@@ -456,6 +456,7 @@ CONFIG_TN3270_FS=y
456CONFIG_WATCHDOG=y 456CONFIG_WATCHDOG=y
457CONFIG_WATCHDOG_NOWAYOUT=y 457CONFIG_WATCHDOG_NOWAYOUT=y
458CONFIG_SOFT_WATCHDOG=m 458CONFIG_SOFT_WATCHDOG=m
459CONFIG_DIAG288_WATCHDOG=m
459# CONFIG_HID is not set 460# CONFIG_HID is not set
460# CONFIG_USB_SUPPORT is not set 461# CONFIG_USB_SUPPORT is not set
461CONFIG_INFINIBAND=m 462CONFIG_INFINIBAND=m
diff --git a/arch/s390/configs/gcov_defconfig b/arch/s390/configs/gcov_defconfig
index c81a74e3e25a..b061180d3544 100644
--- a/arch/s390/configs/gcov_defconfig
+++ b/arch/s390/configs/gcov_defconfig
@@ -45,7 +45,8 @@ CONFIG_SOLARIS_X86_PARTITION=y
45CONFIG_UNIXWARE_DISKLABEL=y 45CONFIG_UNIXWARE_DISKLABEL=y
46CONFIG_CFQ_GROUP_IOSCHED=y 46CONFIG_CFQ_GROUP_IOSCHED=y
47CONFIG_DEFAULT_DEADLINE=y 47CONFIG_DEFAULT_DEADLINE=y
48CONFIG_MARCH_Z9_109=y 48CONFIG_MARCH_Z196=y
49CONFIG_TUNE_ZEC12=y
49CONFIG_NR_CPUS=256 50CONFIG_NR_CPUS=256
50CONFIG_HZ_100=y 51CONFIG_HZ_100=y
51CONFIG_MEMORY_HOTPLUG=y 52CONFIG_MEMORY_HOTPLUG=y
@@ -238,7 +239,6 @@ CONFIG_IP_VS_PE_SIP=m
238CONFIG_NF_CONNTRACK_IPV4=m 239CONFIG_NF_CONNTRACK_IPV4=m
239# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 240# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
240CONFIG_NF_TABLES_IPV4=m 241CONFIG_NF_TABLES_IPV4=m
241CONFIG_NFT_REJECT_IPV4=m
242CONFIG_NFT_CHAIN_ROUTE_IPV4=m 242CONFIG_NFT_CHAIN_ROUTE_IPV4=m
243CONFIG_NFT_CHAIN_NAT_IPV4=m 243CONFIG_NFT_CHAIN_NAT_IPV4=m
244CONFIG_NF_TABLES_ARP=m 244CONFIG_NF_TABLES_ARP=m
@@ -453,6 +453,7 @@ CONFIG_TN3270_FS=y
453CONFIG_WATCHDOG=y 453CONFIG_WATCHDOG=y
454CONFIG_WATCHDOG_NOWAYOUT=y 454CONFIG_WATCHDOG_NOWAYOUT=y
455CONFIG_SOFT_WATCHDOG=m 455CONFIG_SOFT_WATCHDOG=m
456CONFIG_DIAG288_WATCHDOG=m
456# CONFIG_HID is not set 457# CONFIG_HID is not set
457# CONFIG_USB_SUPPORT is not set 458# CONFIG_USB_SUPPORT is not set
458CONFIG_INFINIBAND=m 459CONFIG_INFINIBAND=m
diff --git a/arch/s390/configs/performance_defconfig b/arch/s390/configs/performance_defconfig
index b5ba8fe1cc64..d279baa08014 100644
--- a/arch/s390/configs/performance_defconfig
+++ b/arch/s390/configs/performance_defconfig
@@ -43,7 +43,8 @@ CONFIG_SOLARIS_X86_PARTITION=y
43CONFIG_UNIXWARE_DISKLABEL=y 43CONFIG_UNIXWARE_DISKLABEL=y
44CONFIG_CFQ_GROUP_IOSCHED=y 44CONFIG_CFQ_GROUP_IOSCHED=y
45CONFIG_DEFAULT_DEADLINE=y 45CONFIG_DEFAULT_DEADLINE=y
46CONFIG_MARCH_Z9_109=y 46CONFIG_MARCH_Z196=y
47CONFIG_TUNE_ZEC12=y
47CONFIG_NR_CPUS=256 48CONFIG_NR_CPUS=256
48CONFIG_HZ_100=y 49CONFIG_HZ_100=y
49CONFIG_MEMORY_HOTPLUG=y 50CONFIG_MEMORY_HOTPLUG=y
@@ -236,7 +237,6 @@ CONFIG_IP_VS_PE_SIP=m
236CONFIG_NF_CONNTRACK_IPV4=m 237CONFIG_NF_CONNTRACK_IPV4=m
237# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 238# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
238CONFIG_NF_TABLES_IPV4=m 239CONFIG_NF_TABLES_IPV4=m
239CONFIG_NFT_REJECT_IPV4=m
240CONFIG_NFT_CHAIN_ROUTE_IPV4=m 240CONFIG_NFT_CHAIN_ROUTE_IPV4=m
241CONFIG_NFT_CHAIN_NAT_IPV4=m 241CONFIG_NFT_CHAIN_NAT_IPV4=m
242CONFIG_NF_TABLES_ARP=m 242CONFIG_NF_TABLES_ARP=m
@@ -451,6 +451,7 @@ CONFIG_TN3270_FS=y
451CONFIG_WATCHDOG=y 451CONFIG_WATCHDOG=y
452CONFIG_WATCHDOG_NOWAYOUT=y 452CONFIG_WATCHDOG_NOWAYOUT=y
453CONFIG_SOFT_WATCHDOG=m 453CONFIG_SOFT_WATCHDOG=m
454CONFIG_DIAG288_WATCHDOG=m
454# CONFIG_HID is not set 455# CONFIG_HID is not set
455# CONFIG_USB_SUPPORT is not set 456# CONFIG_USB_SUPPORT is not set
456CONFIG_INFINIBAND=m 457CONFIG_INFINIBAND=m
diff --git a/arch/s390/configs/zfcpdump_defconfig b/arch/s390/configs/zfcpdump_defconfig
index cef073ca1f07..948e0e057a23 100644
--- a/arch/s390/configs/zfcpdump_defconfig
+++ b/arch/s390/configs/zfcpdump_defconfig
@@ -8,7 +8,8 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
8CONFIG_PARTITION_ADVANCED=y 8CONFIG_PARTITION_ADVANCED=y
9CONFIG_IBM_PARTITION=y 9CONFIG_IBM_PARTITION=y
10CONFIG_DEFAULT_DEADLINE=y 10CONFIG_DEFAULT_DEADLINE=y
11CONFIG_MARCH_Z9_109=y 11CONFIG_MARCH_Z196=y
12CONFIG_TUNE_ZEC12=y
12# CONFIG_COMPAT is not set 13# CONFIG_COMPAT is not set
13CONFIG_NR_CPUS=2 14CONFIG_NR_CPUS=2
14# CONFIG_HOTPLUG_CPU is not set 15# CONFIG_HOTPLUG_CPU is not set
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 4557cb7ffddf..2e56498a40df 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -135,8 +135,8 @@ CONFIG_PROVE_LOCKING=y
135CONFIG_LOCK_STAT=y 135CONFIG_LOCK_STAT=y
136CONFIG_DEBUG_LOCKDEP=y 136CONFIG_DEBUG_LOCKDEP=y
137CONFIG_DEBUG_ATOMIC_SLEEP=y 137CONFIG_DEBUG_ATOMIC_SLEEP=y
138CONFIG_DEBUG_WRITECOUNT=y
139CONFIG_DEBUG_LIST=y 138CONFIG_DEBUG_LIST=y
139CONFIG_DEBUG_PI_LIST=y
140CONFIG_DEBUG_SG=y 140CONFIG_DEBUG_SG=y
141CONFIG_DEBUG_NOTIFIERS=y 141CONFIG_DEBUG_NOTIFIERS=y
142CONFIG_PROVE_RCU=y 142CONFIG_PROVE_RCU=y
@@ -199,4 +199,10 @@ CONFIG_CRYPTO_SHA512_S390=m
199CONFIG_CRYPTO_DES_S390=m 199CONFIG_CRYPTO_DES_S390=m
200CONFIG_CRYPTO_AES_S390=m 200CONFIG_CRYPTO_AES_S390=m
201CONFIG_CRC7=m 201CONFIG_CRC7=m
202# CONFIG_XZ_DEC_X86 is not set
203# CONFIG_XZ_DEC_POWERPC is not set
204# CONFIG_XZ_DEC_IA64 is not set
205# CONFIG_XZ_DEC_ARM is not set
206# CONFIG_XZ_DEC_ARMTHUMB is not set
207# CONFIG_XZ_DEC_SPARC is not set
202CONFIG_CMM=m 208CONFIG_CMM=m
diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h
index c28f32a45af5..3815bfea1b2d 100644
--- a/arch/s390/include/asm/mmu_context.h
+++ b/arch/s390/include/asm/mmu_context.h
@@ -33,10 +33,9 @@ static inline int init_new_context(struct task_struct *tsk,
33 33
34static inline void set_user_asce(struct mm_struct *mm) 34static inline void set_user_asce(struct mm_struct *mm)
35{ 35{
36 pgd_t *pgd = mm->pgd; 36 S390_lowcore.user_asce = mm->context.asce_bits | __pa(mm->pgd);
37 37 if (current->thread.mm_segment.ar4)
38 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd); 38 __ctl_load(S390_lowcore.user_asce, 7, 7);
39 set_fs(current->thread.mm_segment);
40 set_cpu_flag(CIF_ASCE); 39 set_cpu_flag(CIF_ASCE);
41} 40}
42 41
@@ -70,12 +69,11 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
70 /* Clear old ASCE by loading the kernel ASCE. */ 69 /* Clear old ASCE by loading the kernel ASCE. */
71 __ctl_load(S390_lowcore.kernel_asce, 1, 1); 70 __ctl_load(S390_lowcore.kernel_asce, 1, 1);
72 __ctl_load(S390_lowcore.kernel_asce, 7, 7); 71 __ctl_load(S390_lowcore.kernel_asce, 7, 7);
73 /* Delay loading of the new ASCE to control registers CR1 & CR7 */
74 set_cpu_flag(CIF_ASCE);
75 atomic_inc(&next->context.attach_count); 72 atomic_inc(&next->context.attach_count);
76 atomic_dec(&prev->context.attach_count); 73 atomic_dec(&prev->context.attach_count);
77 if (MACHINE_HAS_TLB_LC) 74 if (MACHINE_HAS_TLB_LC)
78 cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask); 75 cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask);
76 S390_lowcore.user_asce = next->context.asce_bits | __pa(next->pgd);
79} 77}
80 78
81#define finish_arch_post_lock_switch finish_arch_post_lock_switch 79#define finish_arch_post_lock_switch finish_arch_post_lock_switch
@@ -84,17 +82,18 @@ static inline void finish_arch_post_lock_switch(void)
84 struct task_struct *tsk = current; 82 struct task_struct *tsk = current;
85 struct mm_struct *mm = tsk->mm; 83 struct mm_struct *mm = tsk->mm;
86 84
87 if (!mm) 85 load_kernel_asce();
88 return; 86 if (mm) {
89 preempt_disable(); 87 preempt_disable();
90 while (atomic_read(&mm->context.attach_count) >> 16) 88 while (atomic_read(&mm->context.attach_count) >> 16)
91 cpu_relax(); 89 cpu_relax();
92 90
93 cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); 91 cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm));
94 set_user_asce(mm); 92 if (mm->context.flush_mm)
95 if (mm->context.flush_mm) 93 __tlb_flush_mm(mm);
96 __tlb_flush_mm(mm); 94 preempt_enable();
97 preempt_enable(); 95 }
96 set_fs(current->thread.mm_segment);
98} 97}
99 98
100#define enter_lazy_tlb(mm,tsk) do { } while (0) 99#define enter_lazy_tlb(mm,tsk) do { } while (0)
diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h
index 29c81f82705e..df38c70cd59e 100644
--- a/arch/s390/include/asm/switch_to.h
+++ b/arch/s390/include/asm/switch_to.h
@@ -134,8 +134,4 @@ static inline void restore_access_regs(unsigned int *acrs)
134 prev = __switch_to(prev,next); \ 134 prev = __switch_to(prev,next); \
135} while (0) 135} while (0)
136 136
137#define finish_arch_switch(prev) do { \
138 set_fs(current->thread.mm_segment); \
139} while (0)
140
141#endif /* __ASM_SWITCH_TO_H */ 137#endif /* __ASM_SWITCH_TO_H */
diff --git a/arch/s390/include/uapi/asm/ucontext.h b/arch/s390/include/uapi/asm/ucontext.h
index 200e06325c6a..3e077b2a4705 100644
--- a/arch/s390/include/uapi/asm/ucontext.h
+++ b/arch/s390/include/uapi/asm/ucontext.h
@@ -16,7 +16,9 @@ struct ucontext_extended {
16 struct ucontext *uc_link; 16 struct ucontext *uc_link;
17 stack_t uc_stack; 17 stack_t uc_stack;
18 _sigregs uc_mcontext; 18 _sigregs uc_mcontext;
19 unsigned long uc_sigmask[2]; 19 sigset_t uc_sigmask;
20 /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
21 unsigned char __unused[128 - sizeof(sigset_t)];
20 unsigned long uc_gprs_high[16]; 22 unsigned long uc_gprs_high[16];
21}; 23};
22 24
@@ -27,7 +29,9 @@ struct ucontext {
27 struct ucontext *uc_link; 29 struct ucontext *uc_link;
28 stack_t uc_stack; 30 stack_t uc_stack;
29 _sigregs uc_mcontext; 31 _sigregs uc_mcontext;
30 sigset_t uc_sigmask; /* mask last for extensibility */ 32 sigset_t uc_sigmask;
33 /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
34 unsigned char __unused[128 - sizeof(sigset_t)];
31}; 35};
32 36
33#endif /* !_ASM_S390_UCONTEXT_H */ 37#endif /* !_ASM_S390_UCONTEXT_H */
diff --git a/arch/s390/kernel/compat_linux.h b/arch/s390/kernel/compat_linux.h
index 39ddfdb40ae8..70d4b7c4beaa 100644
--- a/arch/s390/kernel/compat_linux.h
+++ b/arch/s390/kernel/compat_linux.h
@@ -69,7 +69,9 @@ struct ucontext32 {
69 __u32 uc_link; /* pointer */ 69 __u32 uc_link; /* pointer */
70 compat_stack_t uc_stack; 70 compat_stack_t uc_stack;
71 _sigregs32 uc_mcontext; 71 _sigregs32 uc_mcontext;
72 compat_sigset_t uc_sigmask; /* mask last for extensibility */ 72 compat_sigset_t uc_sigmask;
73 /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */
74 unsigned char __unused[128 - sizeof(compat_sigset_t)];
73}; 75};
74 76
75struct stat64_emu31; 77struct stat64_emu31;
diff --git a/arch/sparc/crypto/aes_glue.c b/arch/sparc/crypto/aes_glue.c
index 503e6d96ad4e..df922f52d76d 100644
--- a/arch/sparc/crypto/aes_glue.c
+++ b/arch/sparc/crypto/aes_glue.c
@@ -124,7 +124,7 @@ extern void aes_sparc64_ctr_crypt_256(const u64 *key, const u64 *input,
124 u64 *output, unsigned int len, 124 u64 *output, unsigned int len,
125 u64 *iv); 125 u64 *iv);
126 126
127struct aes_ops aes128_ops = { 127static struct aes_ops aes128_ops = {
128 .encrypt = aes_sparc64_encrypt_128, 128 .encrypt = aes_sparc64_encrypt_128,
129 .decrypt = aes_sparc64_decrypt_128, 129 .decrypt = aes_sparc64_decrypt_128,
130 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_128, 130 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_128,
@@ -136,7 +136,7 @@ struct aes_ops aes128_ops = {
136 .ctr_crypt = aes_sparc64_ctr_crypt_128, 136 .ctr_crypt = aes_sparc64_ctr_crypt_128,
137}; 137};
138 138
139struct aes_ops aes192_ops = { 139static struct aes_ops aes192_ops = {
140 .encrypt = aes_sparc64_encrypt_192, 140 .encrypt = aes_sparc64_encrypt_192,
141 .decrypt = aes_sparc64_decrypt_192, 141 .decrypt = aes_sparc64_decrypt_192,
142 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_192, 142 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_192,
@@ -148,7 +148,7 @@ struct aes_ops aes192_ops = {
148 .ctr_crypt = aes_sparc64_ctr_crypt_192, 148 .ctr_crypt = aes_sparc64_ctr_crypt_192,
149}; 149};
150 150
151struct aes_ops aes256_ops = { 151static struct aes_ops aes256_ops = {
152 .encrypt = aes_sparc64_encrypt_256, 152 .encrypt = aes_sparc64_encrypt_256,
153 .decrypt = aes_sparc64_decrypt_256, 153 .decrypt = aes_sparc64_decrypt_256,
154 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_256, 154 .load_encrypt_keys = aes_sparc64_load_encrypt_keys_256,
diff --git a/arch/sparc/include/asm/atomic_32.h b/arch/sparc/include/asm/atomic_32.h
index f08fe51b264d..7aed2be45b44 100644
--- a/arch/sparc/include/asm/atomic_32.h
+++ b/arch/sparc/include/asm/atomic_32.h
@@ -20,11 +20,11 @@
20 20
21#define ATOMIC_INIT(i) { (i) } 21#define ATOMIC_INIT(i) { (i) }
22 22
23extern int __atomic_add_return(int, atomic_t *); 23int __atomic_add_return(int, atomic_t *);
24extern int atomic_cmpxchg(atomic_t *, int, int); 24int atomic_cmpxchg(atomic_t *, int, int);
25#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 25#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
26extern int __atomic_add_unless(atomic_t *, int, int); 26int __atomic_add_unless(atomic_t *, int, int);
27extern void atomic_set(atomic_t *, int); 27void atomic_set(atomic_t *, int);
28 28
29#define atomic_read(v) (*(volatile int *)&(v)->counter) 29#define atomic_read(v) (*(volatile int *)&(v)->counter)
30 30
diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
index 8b2f1bde2889..bb894c8bec56 100644
--- a/arch/sparc/include/asm/atomic_64.h
+++ b/arch/sparc/include/asm/atomic_64.h
@@ -20,15 +20,15 @@
20#define atomic_set(v, i) (((v)->counter) = i) 20#define atomic_set(v, i) (((v)->counter) = i)
21#define atomic64_set(v, i) (((v)->counter) = i) 21#define atomic64_set(v, i) (((v)->counter) = i)
22 22
23extern void atomic_add(int, atomic_t *); 23void atomic_add(int, atomic_t *);
24extern void atomic64_add(long, atomic64_t *); 24void atomic64_add(long, atomic64_t *);
25extern void atomic_sub(int, atomic_t *); 25void atomic_sub(int, atomic_t *);
26extern void atomic64_sub(long, atomic64_t *); 26void atomic64_sub(long, atomic64_t *);
27 27
28extern int atomic_add_ret(int, atomic_t *); 28int atomic_add_ret(int, atomic_t *);
29extern long atomic64_add_ret(long, atomic64_t *); 29long atomic64_add_ret(long, atomic64_t *);
30extern int atomic_sub_ret(int, atomic_t *); 30int atomic_sub_ret(int, atomic_t *);
31extern long atomic64_sub_ret(long, atomic64_t *); 31long atomic64_sub_ret(long, atomic64_t *);
32 32
33#define atomic_dec_return(v) atomic_sub_ret(1, v) 33#define atomic_dec_return(v) atomic_sub_ret(1, v)
34#define atomic64_dec_return(v) atomic64_sub_ret(1, v) 34#define atomic64_dec_return(v) atomic64_sub_ret(1, v)
@@ -107,6 +107,6 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
107 107
108#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 108#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
109 109
110extern long atomic64_dec_if_positive(atomic64_t *v); 110long atomic64_dec_if_positive(atomic64_t *v);
111 111
112#endif /* !(__ARCH_SPARC64_ATOMIC__) */ 112#endif /* !(__ARCH_SPARC64_ATOMIC__) */
diff --git a/arch/sparc/include/asm/auxio.h b/arch/sparc/include/asm/auxio.h
index 13dc67f03011..3e09a07b77e9 100644
--- a/arch/sparc/include/asm/auxio.h
+++ b/arch/sparc/include/asm/auxio.h
@@ -1,5 +1,12 @@
1#ifndef ___ASM_SPARC_AUXIO_H 1#ifndef ___ASM_SPARC_AUXIO_H
2#define ___ASM_SPARC_AUXIO_H 2#define ___ASM_SPARC_AUXIO_H
3
4#ifndef __ASSEMBLY__
5
6extern void __iomem *auxio_register;
7
8#endif /* ifndef __ASSEMBLY__ */
9
3#if defined(__sparc__) && defined(__arch64__) 10#if defined(__sparc__) && defined(__arch64__)
4#include <asm/auxio_64.h> 11#include <asm/auxio_64.h>
5#else 12#else
diff --git a/arch/sparc/include/asm/auxio_32.h b/arch/sparc/include/asm/auxio_32.h
index 3a319775ae37..5d685df427b4 100644
--- a/arch/sparc/include/asm/auxio_32.h
+++ b/arch/sparc/include/asm/auxio_32.h
@@ -34,8 +34,8 @@
34 * NOTE: these routines are implementation dependent-- 34 * NOTE: these routines are implementation dependent--
35 * understand the hardware you are querying! 35 * understand the hardware you are querying!
36 */ 36 */
37extern void set_auxio(unsigned char bits_on, unsigned char bits_off); 37void set_auxio(unsigned char bits_on, unsigned char bits_off);
38extern unsigned char get_auxio(void); /* .../asm/floppy.h */ 38unsigned char get_auxio(void); /* .../asm/floppy.h */
39 39
40/* 40/*
41 * The following routines are provided for driver-compatibility 41 * The following routines are provided for driver-compatibility
@@ -78,7 +78,7 @@ do { \
78 78
79 79
80/* AUXIO2 (Power Off Control) */ 80/* AUXIO2 (Power Off Control) */
81extern __volatile__ unsigned char * auxio_power_register; 81extern volatile u8 __iomem *auxio_power_register;
82 82
83#define AUXIO_POWER_DETECT_FAILURE 32 83#define AUXIO_POWER_DETECT_FAILURE 32
84#define AUXIO_POWER_CLEAR_FAILURE 2 84#define AUXIO_POWER_CLEAR_FAILURE 2
diff --git a/arch/sparc/include/asm/auxio_64.h b/arch/sparc/include/asm/auxio_64.h
index f61cd1e3e395..6079e59a7ad1 100644
--- a/arch/sparc/include/asm/auxio_64.h
+++ b/arch/sparc/include/asm/auxio_64.h
@@ -75,8 +75,6 @@
75 75
76#ifndef __ASSEMBLY__ 76#ifndef __ASSEMBLY__
77 77
78extern void __iomem *auxio_register;
79
80#define AUXIO_LTE_ON 1 78#define AUXIO_LTE_ON 1
81#define AUXIO_LTE_OFF 0 79#define AUXIO_LTE_OFF 0
82 80
@@ -84,7 +82,7 @@ extern void __iomem *auxio_register;
84 * 82 *
85 * on - AUXIO_LTE_ON or AUXIO_LTE_OFF 83 * on - AUXIO_LTE_ON or AUXIO_LTE_OFF
86 */ 84 */
87extern void auxio_set_lte(int on); 85void auxio_set_lte(int on);
88 86
89#define AUXIO_LED_ON 1 87#define AUXIO_LED_ON 1
90#define AUXIO_LED_OFF 0 88#define AUXIO_LED_OFF 0
@@ -93,7 +91,7 @@ extern void auxio_set_lte(int on);
93 * 91 *
94 * on - AUXIO_LED_ON or AUXIO_LED_OFF 92 * on - AUXIO_LED_ON or AUXIO_LED_OFF
95 */ 93 */
96extern void auxio_set_led(int on); 94void auxio_set_led(int on);
97 95
98#endif /* ifndef __ASSEMBLY__ */ 96#endif /* ifndef __ASSEMBLY__ */
99 97
diff --git a/arch/sparc/include/asm/bitext.h b/arch/sparc/include/asm/bitext.h
index 297b2f2fcb49..9c988bf3adb6 100644
--- a/arch/sparc/include/asm/bitext.h
+++ b/arch/sparc/include/asm/bitext.h
@@ -20,8 +20,8 @@ struct bit_map {
20 int num_colors; 20 int num_colors;
21}; 21};
22 22
23extern int bit_map_string_get(struct bit_map *t, int len, int align); 23int bit_map_string_get(struct bit_map *t, int len, int align);
24extern void bit_map_clear(struct bit_map *t, int offset, int len); 24void bit_map_clear(struct bit_map *t, int offset, int len);
25extern void bit_map_init(struct bit_map *t, unsigned long *map, int size); 25void bit_map_init(struct bit_map *t, unsigned long *map, int size);
26 26
27#endif /* defined(_SPARC_BITEXT_H) */ 27#endif /* defined(_SPARC_BITEXT_H) */
diff --git a/arch/sparc/include/asm/bitops_32.h b/arch/sparc/include/asm/bitops_32.h
index 88c9a962502c..600ed1d9c8c8 100644
--- a/arch/sparc/include/asm/bitops_32.h
+++ b/arch/sparc/include/asm/bitops_32.h
@@ -18,9 +18,9 @@
18#error only <linux/bitops.h> can be included directly 18#error only <linux/bitops.h> can be included directly
19#endif 19#endif
20 20
21extern unsigned long ___set_bit(unsigned long *addr, unsigned long mask); 21unsigned long ___set_bit(unsigned long *addr, unsigned long mask);
22extern unsigned long ___clear_bit(unsigned long *addr, unsigned long mask); 22unsigned long ___clear_bit(unsigned long *addr, unsigned long mask);
23extern unsigned long ___change_bit(unsigned long *addr, unsigned long mask); 23unsigned long ___change_bit(unsigned long *addr, unsigned long mask);
24 24
25/* 25/*
26 * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0' 26 * Set bit 'nr' in 32-bit quantity at address 'addr' where bit '0'
diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h
index f1a051ca301a..2d522402a937 100644
--- a/arch/sparc/include/asm/bitops_64.h
+++ b/arch/sparc/include/asm/bitops_64.h
@@ -15,12 +15,12 @@
15#include <asm/byteorder.h> 15#include <asm/byteorder.h>
16#include <asm/barrier.h> 16#include <asm/barrier.h>
17 17
18extern int test_and_set_bit(unsigned long nr, volatile unsigned long *addr); 18int test_and_set_bit(unsigned long nr, volatile unsigned long *addr);
19extern int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr); 19int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr);
20extern int test_and_change_bit(unsigned long nr, volatile unsigned long *addr); 20int test_and_change_bit(unsigned long nr, volatile unsigned long *addr);
21extern void set_bit(unsigned long nr, volatile unsigned long *addr); 21void set_bit(unsigned long nr, volatile unsigned long *addr);
22extern void clear_bit(unsigned long nr, volatile unsigned long *addr); 22void clear_bit(unsigned long nr, volatile unsigned long *addr);
23extern void change_bit(unsigned long nr, volatile unsigned long *addr); 23void change_bit(unsigned long nr, volatile unsigned long *addr);
24 24
25#include <asm-generic/bitops/non-atomic.h> 25#include <asm-generic/bitops/non-atomic.h>
26 26
@@ -30,8 +30,8 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);
30 30
31#ifdef __KERNEL__ 31#ifdef __KERNEL__
32 32
33extern int ffs(int x); 33int ffs(int x);
34extern unsigned long __ffs(unsigned long); 34unsigned long __ffs(unsigned long);
35 35
36#include <asm-generic/bitops/ffz.h> 36#include <asm-generic/bitops/ffz.h>
37#include <asm-generic/bitops/sched.h> 37#include <asm-generic/bitops/sched.h>
@@ -41,10 +41,10 @@ extern unsigned long __ffs(unsigned long);
41 * of bits set) of a N-bit word 41 * of bits set) of a N-bit word
42 */ 42 */
43 43
44extern unsigned long __arch_hweight64(__u64 w); 44unsigned long __arch_hweight64(__u64 w);
45extern unsigned int __arch_hweight32(unsigned int w); 45unsigned int __arch_hweight32(unsigned int w);
46extern unsigned int __arch_hweight16(unsigned int w); 46unsigned int __arch_hweight16(unsigned int w);
47extern unsigned int __arch_hweight8(unsigned int w); 47unsigned int __arch_hweight8(unsigned int w);
48 48
49#include <asm-generic/bitops/const_hweight.h> 49#include <asm-generic/bitops/const_hweight.h>
50#include <asm-generic/bitops/lock.h> 50#include <asm-generic/bitops/lock.h>
diff --git a/arch/sparc/include/asm/btext.h b/arch/sparc/include/asm/btext.h
index 9b2bc6b6ed0a..75a32b109e15 100644
--- a/arch/sparc/include/asm/btext.h
+++ b/arch/sparc/include/asm/btext.h
@@ -1,6 +1,6 @@
1#ifndef _SPARC_BTEXT_H 1#ifndef _SPARC_BTEXT_H
2#define _SPARC_BTEXT_H 2#define _SPARC_BTEXT_H
3 3
4extern int btext_find_display(void); 4int btext_find_display(void);
5 5
6#endif /* _SPARC_BTEXT_H */ 6#endif /* _SPARC_BTEXT_H */
diff --git a/arch/sparc/include/asm/bug.h b/arch/sparc/include/asm/bug.h
index 6bd9f43cb5a5..eaa8f8d38125 100644
--- a/arch/sparc/include/asm/bug.h
+++ b/arch/sparc/include/asm/bug.h
@@ -5,7 +5,7 @@
5#include <linux/compiler.h> 5#include <linux/compiler.h>
6 6
7#ifdef CONFIG_DEBUG_BUGVERBOSE 7#ifdef CONFIG_DEBUG_BUGVERBOSE
8extern void do_BUG(const char *file, int line); 8void do_BUG(const char *file, int line);
9#define BUG() do { \ 9#define BUG() do { \
10 do_BUG(__FILE__, __LINE__); \ 10 do_BUG(__FILE__, __LINE__); \
11 __builtin_trap(); \ 11 __builtin_trap(); \
@@ -20,6 +20,6 @@ extern void do_BUG(const char *file, int line);
20#include <asm-generic/bug.h> 20#include <asm-generic/bug.h>
21 21
22struct pt_regs; 22struct pt_regs;
23extern void die_if_kernel(char *str, struct pt_regs *regs) __attribute__ ((noreturn)); 23void __noreturn die_if_kernel(char *str, struct pt_regs *regs);
24 24
25#endif 25#endif
diff --git a/arch/sparc/include/asm/cacheflush_32.h b/arch/sparc/include/asm/cacheflush_32.h
index bb014c24f318..12164006181c 100644
--- a/arch/sparc/include/asm/cacheflush_32.h
+++ b/arch/sparc/include/asm/cacheflush_32.h
@@ -36,7 +36,7 @@
36#define flush_page_for_dma(addr) \ 36#define flush_page_for_dma(addr) \
37 sparc32_cachetlb_ops->page_for_dma(addr) 37 sparc32_cachetlb_ops->page_for_dma(addr)
38 38
39extern void sparc_flush_page_to_ram(struct page *page); 39void sparc_flush_page_to_ram(struct page *page);
40 40
41#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 41#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
42#define flush_dcache_page(page) sparc_flush_page_to_ram(page) 42#define flush_dcache_page(page) sparc_flush_page_to_ram(page)
@@ -51,8 +51,8 @@ extern void sparc_flush_page_to_ram(struct page *page);
51 * way the windows are all clean for the next process and the stack 51 * way the windows are all clean for the next process and the stack
52 * frames are up to date. 52 * frames are up to date.
53 */ 53 */
54extern void flush_user_windows(void); 54void flush_user_windows(void);
55extern void kill_user_windows(void); 55void kill_user_windows(void);
56extern void flushw_all(void); 56void flushw_all(void);
57 57
58#endif /* _SPARC_CACHEFLUSH_H */ 58#endif /* _SPARC_CACHEFLUSH_H */
diff --git a/arch/sparc/include/asm/cacheflush_64.h b/arch/sparc/include/asm/cacheflush_64.h
index 301736d9e7a1..38965379e350 100644
--- a/arch/sparc/include/asm/cacheflush_64.h
+++ b/arch/sparc/include/asm/cacheflush_64.h
@@ -10,7 +10,7 @@
10/* Cache flush operations. */ 10/* Cache flush operations. */
11#define flushw_all() __asm__ __volatile__("flushw") 11#define flushw_all() __asm__ __volatile__("flushw")
12 12
13extern void __flushw_user(void); 13void __flushw_user(void);
14#define flushw_user() __flushw_user() 14#define flushw_user() __flushw_user()
15 15
16#define flush_user_windows flushw_user 16#define flush_user_windows flushw_user
@@ -30,29 +30,29 @@ extern void __flushw_user(void);
30 * use block commit stores (which invalidate icache lines) during 30 * use block commit stores (which invalidate icache lines) during
31 * module load, so we need this. 31 * module load, so we need this.
32 */ 32 */
33extern void flush_icache_range(unsigned long start, unsigned long end); 33void flush_icache_range(unsigned long start, unsigned long end);
34extern void __flush_icache_page(unsigned long); 34void __flush_icache_page(unsigned long);
35 35
36extern void __flush_dcache_page(void *addr, int flush_icache); 36void __flush_dcache_page(void *addr, int flush_icache);
37extern void flush_dcache_page_impl(struct page *page); 37void flush_dcache_page_impl(struct page *page);
38#ifdef CONFIG_SMP 38#ifdef CONFIG_SMP
39extern void smp_flush_dcache_page_impl(struct page *page, int cpu); 39void smp_flush_dcache_page_impl(struct page *page, int cpu);
40extern void flush_dcache_page_all(struct mm_struct *mm, struct page *page); 40void flush_dcache_page_all(struct mm_struct *mm, struct page *page);
41#else 41#else
42#define smp_flush_dcache_page_impl(page,cpu) flush_dcache_page_impl(page) 42#define smp_flush_dcache_page_impl(page,cpu) flush_dcache_page_impl(page)
43#define flush_dcache_page_all(mm,page) flush_dcache_page_impl(page) 43#define flush_dcache_page_all(mm,page) flush_dcache_page_impl(page)
44#endif 44#endif
45 45
46extern void __flush_dcache_range(unsigned long start, unsigned long end); 46void __flush_dcache_range(unsigned long start, unsigned long end);
47#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 47#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
48extern void flush_dcache_page(struct page *page); 48void flush_dcache_page(struct page *page);
49 49
50#define flush_icache_page(vma, pg) do { } while(0) 50#define flush_icache_page(vma, pg) do { } while(0)
51#define flush_icache_user_range(vma,pg,adr,len) do { } while (0) 51#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
52 52
53extern void flush_ptrace_access(struct vm_area_struct *, struct page *, 53void flush_ptrace_access(struct vm_area_struct *, struct page *,
54 unsigned long uaddr, void *kaddr, 54 unsigned long uaddr, void *kaddr,
55 unsigned long len, int write); 55 unsigned long len, int write);
56 56
57#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 57#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
58 do { \ 58 do { \
diff --git a/arch/sparc/include/asm/checksum_32.h b/arch/sparc/include/asm/checksum_32.h
index 04471dc64847..426b2389a1c2 100644
--- a/arch/sparc/include/asm/checksum_32.h
+++ b/arch/sparc/include/asm/checksum_32.h
@@ -29,7 +29,7 @@
29 * 29 *
30 * it's best to have buff aligned on a 32-bit boundary 30 * it's best to have buff aligned on a 32-bit boundary
31 */ 31 */
32extern __wsum csum_partial(const void *buff, int len, __wsum sum); 32__wsum csum_partial(const void *buff, int len, __wsum sum);
33 33
34/* the same as csum_partial, but copies from fs:src while it 34/* the same as csum_partial, but copies from fs:src while it
35 * checksums 35 * checksums
@@ -38,7 +38,7 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
38 * better 64-bit) boundary 38 * better 64-bit) boundary
39 */ 39 */
40 40
41extern unsigned int __csum_partial_copy_sparc_generic (const unsigned char *, unsigned char *); 41unsigned int __csum_partial_copy_sparc_generic (const unsigned char *, unsigned char *);
42 42
43static inline __wsum 43static inline __wsum
44csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum) 44csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
diff --git a/arch/sparc/include/asm/checksum_64.h b/arch/sparc/include/asm/checksum_64.h
index 2ff81ae8f3af..b8779a6a5911 100644
--- a/arch/sparc/include/asm/checksum_64.h
+++ b/arch/sparc/include/asm/checksum_64.h
@@ -29,7 +29,7 @@
29 * 29 *
30 * it's best to have buff aligned on a 32-bit boundary 30 * it's best to have buff aligned on a 32-bit boundary
31 */ 31 */
32extern __wsum csum_partial(const void * buff, int len, __wsum sum); 32__wsum csum_partial(const void * buff, int len, __wsum sum);
33 33
34/* the same as csum_partial, but copies from user space while it 34/* the same as csum_partial, but copies from user space while it
35 * checksums 35 * checksums
@@ -37,12 +37,12 @@ extern __wsum csum_partial(const void * buff, int len, __wsum sum);
37 * here even more important to align src and dst on a 32-bit (or even 37 * here even more important to align src and dst on a 32-bit (or even
38 * better 64-bit) boundary 38 * better 64-bit) boundary
39 */ 39 */
40extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, 40__wsum csum_partial_copy_nocheck(const void *src, void *dst,
41 int len, __wsum sum); 41 int len, __wsum sum);
42 42
43extern long __csum_partial_copy_from_user(const void __user *src, 43long __csum_partial_copy_from_user(const void __user *src,
44 void *dst, int len, 44 void *dst, int len,
45 __wsum sum); 45 __wsum sum);
46 46
47static inline __wsum 47static inline __wsum
48csum_partial_copy_from_user(const void __user *src, 48csum_partial_copy_from_user(const void __user *src,
@@ -59,9 +59,9 @@ csum_partial_copy_from_user(const void __user *src,
59 * Copy and checksum to user 59 * Copy and checksum to user
60 */ 60 */
61#define HAVE_CSUM_COPY_USER 61#define HAVE_CSUM_COPY_USER
62extern long __csum_partial_copy_to_user(const void *src, 62long __csum_partial_copy_to_user(const void *src,
63 void __user *dst, int len, 63 void __user *dst, int len,
64 __wsum sum); 64 __wsum sum);
65 65
66static inline __wsum 66static inline __wsum
67csum_and_copy_to_user(const void *src, 67csum_and_copy_to_user(const void *src,
@@ -77,7 +77,7 @@ csum_and_copy_to_user(const void *src,
77/* ihl is always 5 or greater, almost always is 5, and iph is word aligned 77/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
78 * the majority of the time. 78 * the majority of the time.
79 */ 79 */
80extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl); 80__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
81 81
82/* Fold a partial checksum without adding pseudo headers. */ 82/* Fold a partial checksum without adding pseudo headers. */
83static inline __sum16 csum_fold(__wsum sum) 83static inline __sum16 csum_fold(__wsum sum)
@@ -96,9 +96,9 @@ static inline __sum16 csum_fold(__wsum sum)
96} 96}
97 97
98static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr, 98static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
99 unsigned int len, 99 unsigned int len,
100 unsigned short proto, 100 unsigned short proto,
101 __wsum sum) 101 __wsum sum)
102{ 102{
103 __asm__ __volatile__( 103 __asm__ __volatile__(
104" addcc %1, %0, %0\n" 104" addcc %1, %0, %0\n"
@@ -116,9 +116,9 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
116 * returns a 16-bit checksum, already complemented 116 * returns a 16-bit checksum, already complemented
117 */ 117 */
118static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, 118static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
119 unsigned short len, 119 unsigned short len,
120 unsigned short proto, 120 unsigned short proto,
121 __wsum sum) 121 __wsum sum)
122{ 122{
123 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 123 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
124} 124}
diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 1fae1a02e3c2..32c29a133f9d 100644
--- a/arch/sparc/include/asm/cmpxchg_32.h
+++ b/arch/sparc/include/asm/cmpxchg_32.h
@@ -20,7 +20,7 @@ static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned lon
20 return val; 20 return val;
21} 21}
22 22
23extern void __xchg_called_with_bad_pointer(void); 23void __xchg_called_with_bad_pointer(void);
24 24
25static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) 25static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size)
26{ 26{
@@ -45,9 +45,9 @@ static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int
45#define __HAVE_ARCH_CMPXCHG 1 45#define __HAVE_ARCH_CMPXCHG 1
46 46
47/* bug catcher for when unsupported size is used - won't link */ 47/* bug catcher for when unsupported size is used - won't link */
48extern void __cmpxchg_called_with_bad_pointer(void); 48void __cmpxchg_called_with_bad_pointer(void);
49/* we only need to support cmpxchg of a u32 on sparc */ 49/* we only need to support cmpxchg of a u32 on sparc */
50extern unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_); 50unsigned long __cmpxchg_u32(volatile u32 *m, u32 old, u32 new_);
51 51
52/* don't worry...optimizer will get rid of most of this */ 52/* don't worry...optimizer will get rid of most of this */
53static inline unsigned long 53static inline unsigned long
diff --git a/arch/sparc/include/asm/cmpxchg_64.h b/arch/sparc/include/asm/cmpxchg_64.h
index 4adefe8e2885..0e1ed6cfbf68 100644
--- a/arch/sparc/include/asm/cmpxchg_64.h
+++ b/arch/sparc/include/asm/cmpxchg_64.h
@@ -42,7 +42,7 @@ static inline unsigned long xchg64(__volatile__ unsigned long *m, unsigned long
42 42
43#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 43#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
44 44
45extern void __xchg_called_with_bad_pointer(void); 45void __xchg_called_with_bad_pointer(void);
46 46
47static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, 47static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr,
48 int size) 48 int size)
@@ -91,7 +91,7 @@ __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
91 91
92/* This function doesn't exist, so you'll get a linker error 92/* This function doesn't exist, so you'll get a linker error
93 if something tries to do an invalid cmpxchg(). */ 93 if something tries to do an invalid cmpxchg(). */
94extern void __cmpxchg_called_with_bad_pointer(void); 94void __cmpxchg_called_with_bad_pointer(void);
95 95
96static inline unsigned long 96static inline unsigned long
97__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) 97__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
diff --git a/arch/sparc/include/asm/cpudata.h b/arch/sparc/include/asm/cpudata.h
index b5976de7cacd..128b56b08676 100644
--- a/arch/sparc/include/asm/cpudata.h
+++ b/arch/sparc/include/asm/cpudata.h
@@ -1,5 +1,15 @@
1#ifndef ___ASM_SPARC_CPUDATA_H 1#ifndef ___ASM_SPARC_CPUDATA_H
2#define ___ASM_SPARC_CPUDATA_H 2#define ___ASM_SPARC_CPUDATA_H
3
4#ifndef __ASSEMBLY__
5
6#include <linux/threads.h>
7#include <linux/percpu.h>
8
9extern const struct seq_operations cpuinfo_op;
10
11#endif /* !(__ASSEMBLY__) */
12
3#if defined(__sparc__) && defined(__arch64__) 13#if defined(__sparc__) && defined(__arch64__)
4#include <asm/cpudata_64.h> 14#include <asm/cpudata_64.h>
5#else 15#else
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
index 050ef35b9dcf..0e594076912c 100644
--- a/arch/sparc/include/asm/cpudata_64.h
+++ b/arch/sparc/include/asm/cpudata_64.h
@@ -8,9 +8,6 @@
8 8
9#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
10 10
11#include <linux/percpu.h>
12#include <linux/threads.h>
13
14typedef struct { 11typedef struct {
15 /* Dcache line 1 */ 12 /* Dcache line 1 */
16 unsigned int __softirq_pending; /* must be 1st, see rtrap.S */ 13 unsigned int __softirq_pending; /* must be 1st, see rtrap.S */
@@ -35,8 +32,6 @@ DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
35#define cpu_data(__cpu) per_cpu(__cpu_data, (__cpu)) 32#define cpu_data(__cpu) per_cpu(__cpu_data, (__cpu))
36#define local_cpu_data() __get_cpu_var(__cpu_data) 33#define local_cpu_data() __get_cpu_var(__cpu_data)
37 34
38extern const struct seq_operations cpuinfo_op;
39
40#endif /* !(__ASSEMBLY__) */ 35#endif /* !(__ASSEMBLY__) */
41 36
42#include <asm/trap_block.h> 37#include <asm/trap_block.h>
diff --git a/arch/sparc/include/asm/delay_32.h b/arch/sparc/include/asm/delay_32.h
index bc9aba2bead6..3fb8ca144b4f 100644
--- a/arch/sparc/include/asm/delay_32.h
+++ b/arch/sparc/include/asm/delay_32.h
@@ -20,8 +20,8 @@ static inline void __delay(unsigned long loops)
20} 20}
21 21
22/* This is too messy with inline asm on the Sparc. */ 22/* This is too messy with inline asm on the Sparc. */
23extern void __udelay(unsigned long usecs, unsigned long lpj); 23void __udelay(unsigned long usecs, unsigned long lpj);
24extern void __ndelay(unsigned long nsecs, unsigned long lpj); 24void __ndelay(unsigned long nsecs, unsigned long lpj);
25 25
26#ifdef CONFIG_SMP 26#ifdef CONFIG_SMP
27#define __udelay_val cpu_data(smp_processor_id()).udelay_val 27#define __udelay_val cpu_data(smp_processor_id()).udelay_val
diff --git a/arch/sparc/include/asm/delay_64.h b/arch/sparc/include/asm/delay_64.h
index a77aa622d762..0ba5424856d8 100644
--- a/arch/sparc/include/asm/delay_64.h
+++ b/arch/sparc/include/asm/delay_64.h
@@ -8,8 +8,8 @@
8 8
9#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
10 10
11extern void __delay(unsigned long loops); 11void __delay(unsigned long loops);
12extern void udelay(unsigned long usecs); 12void udelay(unsigned long usecs);
13#define mdelay(n) udelay((n) * 1000) 13#define mdelay(n) udelay((n) * 1000)
14 14
15#endif /* !__ASSEMBLY__ */ 15#endif /* !__ASSEMBLY__ */
diff --git a/arch/sparc/include/asm/device.h b/arch/sparc/include/asm/device.h
index daa6a8a5e9cd..bb3f0b0c6754 100644
--- a/arch/sparc/include/asm/device.h
+++ b/arch/sparc/include/asm/device.h
@@ -19,7 +19,7 @@ struct dev_archdata {
19 int numa_node; 19 int numa_node;
20}; 20};
21 21
22extern void of_propagate_archdata(struct platform_device *bus); 22void of_propagate_archdata(struct platform_device *bus);
23 23
24struct pdev_archdata { 24struct pdev_archdata {
25 struct resource resource[PROMREG_MAX]; 25 struct resource resource[PROMREG_MAX];
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 05fe53f5346e..1ee02710b2dc 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -7,7 +7,7 @@
7 7
8#define DMA_ERROR_CODE (~(dma_addr_t)0x0) 8#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
9 9
10extern int dma_supported(struct device *dev, u64 mask); 10int dma_supported(struct device *dev, u64 mask);
11 11
12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
diff --git a/arch/sparc/include/asm/ebus_dma.h b/arch/sparc/include/asm/ebus_dma.h
index f07a5b541c98..fcfb4948147f 100644
--- a/arch/sparc/include/asm/ebus_dma.h
+++ b/arch/sparc/include/asm/ebus_dma.h
@@ -22,14 +22,14 @@ struct ebus_dma_info {
22 unsigned char name[64]; 22 unsigned char name[64];
23}; 23};
24 24
25extern int ebus_dma_register(struct ebus_dma_info *p); 25int ebus_dma_register(struct ebus_dma_info *p);
26extern int ebus_dma_irq_enable(struct ebus_dma_info *p, int on); 26int ebus_dma_irq_enable(struct ebus_dma_info *p, int on);
27extern void ebus_dma_unregister(struct ebus_dma_info *p); 27void ebus_dma_unregister(struct ebus_dma_info *p);
28extern int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr, 28int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr,
29 size_t len); 29 size_t len);
30extern void ebus_dma_prepare(struct ebus_dma_info *p, int write); 30void ebus_dma_prepare(struct ebus_dma_info *p, int write);
31extern unsigned int ebus_dma_residue(struct ebus_dma_info *p); 31unsigned int ebus_dma_residue(struct ebus_dma_info *p);
32extern unsigned int ebus_dma_addr(struct ebus_dma_info *p); 32unsigned int ebus_dma_addr(struct ebus_dma_info *p);
33extern void ebus_dma_enable(struct ebus_dma_info *p, int on); 33void ebus_dma_enable(struct ebus_dma_info *p, int on);
34 34
35#endif /* __ASM_SPARC_EBUS_DMA_H */ 35#endif /* __ASM_SPARC_EBUS_DMA_H */
diff --git a/arch/sparc/include/asm/floppy_32.h b/arch/sparc/include/asm/floppy_32.h
index fb3f16954c69..071b83e52f15 100644
--- a/arch/sparc/include/asm/floppy_32.h
+++ b/arch/sparc/include/asm/floppy_32.h
@@ -9,11 +9,12 @@
9#include <linux/of.h> 9#include <linux/of.h>
10#include <linux/of_device.h> 10#include <linux/of_device.h>
11 11
12#include <asm/page.h>
13#include <asm/pgtable.h> 12#include <asm/pgtable.h>
14#include <asm/idprom.h> 13#include <asm/idprom.h>
15#include <asm/oplib.h> 14#include <asm/oplib.h>
16#include <asm/auxio.h> 15#include <asm/auxio.h>
16#include <asm/setup.h>
17#include <asm/page.h>
17#include <asm/irq.h> 18#include <asm/irq.h>
18 19
19/* We don't need no stinkin' I/O port allocation crap. */ 20/* We don't need no stinkin' I/O port allocation crap. */
@@ -49,7 +50,6 @@ struct sun_flpy_controller {
49 50
50/* You'll only ever find one controller on a SparcStation anyways. */ 51/* You'll only ever find one controller on a SparcStation anyways. */
51static struct sun_flpy_controller *sun_fdc = NULL; 52static struct sun_flpy_controller *sun_fdc = NULL;
52extern volatile unsigned char *fdc_status;
53 53
54struct sun_floppy_ops { 54struct sun_floppy_ops {
55 unsigned char (*fd_inb)(int port); 55 unsigned char (*fd_inb)(int port);
@@ -212,13 +212,6 @@ static void sun_82077_fd_outb(unsigned char value, int port)
212 * underruns. If non-zero, doing_pdma encodes the direction of 212 * underruns. If non-zero, doing_pdma encodes the direction of
213 * the transfer for debugging. 1=read 2=write 213 * the transfer for debugging. 1=read 2=write
214 */ 214 */
215extern char *pdma_vaddr;
216extern unsigned long pdma_size;
217extern volatile int doing_pdma;
218
219/* This is software state */
220extern char *pdma_base;
221extern unsigned long pdma_areasize;
222 215
223/* Common routines to all controller types on the Sparc. */ 216/* Common routines to all controller types on the Sparc. */
224static inline void virtual_dma_init(void) 217static inline void virtual_dma_init(void)
@@ -263,8 +256,7 @@ static inline void sun_fd_enable_dma(void)
263 pdma_areasize = pdma_size; 256 pdma_areasize = pdma_size;
264} 257}
265 258
266extern int sparc_floppy_request_irq(unsigned int irq, 259int sparc_floppy_request_irq(unsigned int irq, irq_handler_t irq_handler);
267 irq_handler_t irq_handler);
268 260
269static int sun_fd_request_irq(void) 261static int sun_fd_request_irq(void)
270{ 262{
diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
index 7c90c50c200d..625756406a7e 100644
--- a/arch/sparc/include/asm/floppy_64.h
+++ b/arch/sparc/include/asm/floppy_64.h
@@ -296,7 +296,7 @@ struct sun_pci_dma_op {
296static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL}; 296static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL};
297static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL}; 297static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL};
298 298
299extern irqreturn_t floppy_interrupt(int irq, void *dev_id); 299irqreturn_t floppy_interrupt(int irq, void *dev_id);
300 300
301static unsigned char sun_pci_fd_inb(unsigned long port) 301static unsigned char sun_pci_fd_inb(unsigned long port)
302{ 302{
diff --git a/arch/sparc/include/asm/ftrace.h b/arch/sparc/include/asm/ftrace.h
index b0f18e9893db..9ec94ad116fb 100644
--- a/arch/sparc/include/asm/ftrace.h
+++ b/arch/sparc/include/asm/ftrace.h
@@ -6,7 +6,7 @@
6#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */ 6#define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
7 7
8#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
9extern void _mcount(void); 9void _mcount(void);
10#endif 10#endif
11 11
12#endif 12#endif
@@ -22,4 +22,8 @@ struct dyn_arch_ftrace {
22}; 22};
23#endif /* CONFIG_DYNAMIC_FTRACE */ 23#endif /* CONFIG_DYNAMIC_FTRACE */
24 24
25unsigned long prepare_ftrace_return(unsigned long parent,
26 unsigned long self_addr,
27 unsigned long frame_pointer);
28
25#endif /* _ASM_SPARC64_FTRACE */ 29#endif /* _ASM_SPARC64_FTRACE */
diff --git a/arch/sparc/include/asm/highmem.h b/arch/sparc/include/asm/highmem.h
index 4f9e15c757e2..92ded294a4ec 100644
--- a/arch/sparc/include/asm/highmem.h
+++ b/arch/sparc/include/asm/highmem.h
@@ -31,7 +31,7 @@ extern unsigned long highstart_pfn, highend_pfn;
31extern pgprot_t kmap_prot; 31extern pgprot_t kmap_prot;
32extern pte_t *pkmap_page_table; 32extern pte_t *pkmap_page_table;
33 33
34extern void kmap_init(void) __init; 34void kmap_init(void) __init;
35 35
36/* 36/*
37 * Right now we initialize only a single pte table. It can be extended 37 * Right now we initialize only a single pte table. It can be extended
@@ -49,8 +49,8 @@ extern void kmap_init(void) __init;
49 49
50#define PKMAP_END (PKMAP_ADDR(LAST_PKMAP)) 50#define PKMAP_END (PKMAP_ADDR(LAST_PKMAP))
51 51
52extern void *kmap_high(struct page *page); 52void *kmap_high(struct page *page);
53extern void kunmap_high(struct page *page); 53void kunmap_high(struct page *page);
54 54
55static inline void *kmap(struct page *page) 55static inline void *kmap(struct page *page)
56{ 56{
@@ -68,8 +68,8 @@ static inline void kunmap(struct page *page)
68 kunmap_high(page); 68 kunmap_high(page);
69} 69}
70 70
71extern void *kmap_atomic(struct page *page); 71void *kmap_atomic(struct page *page);
72extern void __kunmap_atomic(void *kvaddr); 72void __kunmap_atomic(void *kvaddr);
73 73
74#define flush_cache_kmaps() flush_cache_all() 74#define flush_cache_kmaps() flush_cache_all()
75 75
diff --git a/arch/sparc/include/asm/hvtramp.h b/arch/sparc/include/asm/hvtramp.h
index b2b9b947b3a4..04b56f862bbe 100644
--- a/arch/sparc/include/asm/hvtramp.h
+++ b/arch/sparc/include/asm/hvtramp.h
@@ -19,7 +19,7 @@ struct hvtramp_descr {
19 struct hvtramp_mapping maps[1]; 19 struct hvtramp_mapping maps[1];
20}; 20};
21 21
22extern void hv_cpu_startup(unsigned long hvdescr_pa); 22void hv_cpu_startup(unsigned long hvdescr_pa);
23 23
24#endif 24#endif
25 25
diff --git a/arch/sparc/include/asm/hypervisor.h b/arch/sparc/include/asm/hypervisor.h
index ca121f0fa3ec..94b39caea3eb 100644
--- a/arch/sparc/include/asm/hypervisor.h
+++ b/arch/sparc/include/asm/hypervisor.h
@@ -98,7 +98,7 @@
98#define HV_FAST_MACH_EXIT 0x00 98#define HV_FAST_MACH_EXIT 0x00
99 99
100#ifndef __ASSEMBLY__ 100#ifndef __ASSEMBLY__
101extern void sun4v_mach_exit(unsigned long exit_code); 101void sun4v_mach_exit(unsigned long exit_code);
102#endif 102#endif
103 103
104/* Domain services. */ 104/* Domain services. */
@@ -127,9 +127,9 @@ extern void sun4v_mach_exit(unsigned long exit_code);
127#define HV_FAST_MACH_DESC 0x01 127#define HV_FAST_MACH_DESC 0x01
128 128
129#ifndef __ASSEMBLY__ 129#ifndef __ASSEMBLY__
130extern unsigned long sun4v_mach_desc(unsigned long buffer_pa, 130unsigned long sun4v_mach_desc(unsigned long buffer_pa,
131 unsigned long buf_len, 131 unsigned long buf_len,
132 unsigned long *real_buf_len); 132 unsigned long *real_buf_len);
133#endif 133#endif
134 134
135/* mach_sir() 135/* mach_sir()
@@ -148,7 +148,7 @@ extern unsigned long sun4v_mach_desc(unsigned long buffer_pa,
148#define HV_FAST_MACH_SIR 0x02 148#define HV_FAST_MACH_SIR 0x02
149 149
150#ifndef __ASSEMBLY__ 150#ifndef __ASSEMBLY__
151extern void sun4v_mach_sir(void); 151void sun4v_mach_sir(void);
152#endif 152#endif
153 153
154/* mach_set_watchdog() 154/* mach_set_watchdog()
@@ -204,8 +204,8 @@ extern void sun4v_mach_sir(void);
204#define HV_FAST_MACH_SET_WATCHDOG 0x05 204#define HV_FAST_MACH_SET_WATCHDOG 0x05
205 205
206#ifndef __ASSEMBLY__ 206#ifndef __ASSEMBLY__
207extern unsigned long sun4v_mach_set_watchdog(unsigned long timeout, 207unsigned long sun4v_mach_set_watchdog(unsigned long timeout,
208 unsigned long *orig_timeout); 208 unsigned long *orig_timeout);
209#endif 209#endif
210 210
211/* CPU services. 211/* CPU services.
@@ -250,10 +250,10 @@ extern unsigned long sun4v_mach_set_watchdog(unsigned long timeout,
250#define HV_FAST_CPU_START 0x10 250#define HV_FAST_CPU_START 0x10
251 251
252#ifndef __ASSEMBLY__ 252#ifndef __ASSEMBLY__
253extern unsigned long sun4v_cpu_start(unsigned long cpuid, 253unsigned long sun4v_cpu_start(unsigned long cpuid,
254 unsigned long pc, 254 unsigned long pc,
255 unsigned long rtba, 255 unsigned long rtba,
256 unsigned long arg0); 256 unsigned long arg0);
257#endif 257#endif
258 258
259/* cpu_stop() 259/* cpu_stop()
@@ -278,7 +278,7 @@ extern unsigned long sun4v_cpu_start(unsigned long cpuid,
278#define HV_FAST_CPU_STOP 0x11 278#define HV_FAST_CPU_STOP 0x11
279 279
280#ifndef __ASSEMBLY__ 280#ifndef __ASSEMBLY__
281extern unsigned long sun4v_cpu_stop(unsigned long cpuid); 281unsigned long sun4v_cpu_stop(unsigned long cpuid);
282#endif 282#endif
283 283
284/* cpu_yield() 284/* cpu_yield()
@@ -295,7 +295,7 @@ extern unsigned long sun4v_cpu_stop(unsigned long cpuid);
295#define HV_FAST_CPU_YIELD 0x12 295#define HV_FAST_CPU_YIELD 0x12
296 296
297#ifndef __ASSEMBLY__ 297#ifndef __ASSEMBLY__
298extern unsigned long sun4v_cpu_yield(void); 298unsigned long sun4v_cpu_yield(void);
299#endif 299#endif
300 300
301/* cpu_qconf() 301/* cpu_qconf()
@@ -341,9 +341,9 @@ extern unsigned long sun4v_cpu_yield(void);
341#define HV_CPU_QUEUE_NONRES_ERROR 0x3f 341#define HV_CPU_QUEUE_NONRES_ERROR 0x3f
342 342
343#ifndef __ASSEMBLY__ 343#ifndef __ASSEMBLY__
344extern unsigned long sun4v_cpu_qconf(unsigned long type, 344unsigned long sun4v_cpu_qconf(unsigned long type,
345 unsigned long queue_paddr, 345 unsigned long queue_paddr,
346 unsigned long num_queue_entries); 346 unsigned long num_queue_entries);
347#endif 347#endif
348 348
349/* cpu_qinfo() 349/* cpu_qinfo()
@@ -394,7 +394,9 @@ extern unsigned long sun4v_cpu_qconf(unsigned long type,
394#define HV_FAST_CPU_MONDO_SEND 0x42 394#define HV_FAST_CPU_MONDO_SEND 0x42
395 395
396#ifndef __ASSEMBLY__ 396#ifndef __ASSEMBLY__
397extern unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, unsigned long cpu_list_pa, unsigned long mondo_block_pa); 397unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count,
398 unsigned long cpu_list_pa,
399 unsigned long mondo_block_pa);
398#endif 400#endif
399 401
400/* cpu_myid() 402/* cpu_myid()
@@ -425,7 +427,7 @@ extern unsigned long sun4v_cpu_mondo_send(unsigned long cpu_count, unsigned long
425#define HV_CPU_STATE_ERROR 0x03 427#define HV_CPU_STATE_ERROR 0x03
426 428
427#ifndef __ASSEMBLY__ 429#ifndef __ASSEMBLY__
428extern long sun4v_cpu_state(unsigned long cpuid); 430long sun4v_cpu_state(unsigned long cpuid);
429#endif 431#endif
430 432
431/* cpu_set_rtba() 433/* cpu_set_rtba()
@@ -625,8 +627,8 @@ struct hv_fault_status {
625#define HV_FAST_MMU_TSB_CTX0 0x20 627#define HV_FAST_MMU_TSB_CTX0 0x20
626 628
627#ifndef __ASSEMBLY__ 629#ifndef __ASSEMBLY__
628extern unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions, 630unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions,
629 unsigned long tsb_desc_ra); 631 unsigned long tsb_desc_ra);
630#endif 632#endif
631 633
632/* mmu_tsb_ctxnon0() 634/* mmu_tsb_ctxnon0()
@@ -710,7 +712,7 @@ extern unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions,
710#define HV_FAST_MMU_DEMAP_ALL 0x24 712#define HV_FAST_MMU_DEMAP_ALL 0x24
711 713
712#ifndef __ASSEMBLY__ 714#ifndef __ASSEMBLY__
713extern void sun4v_mmu_demap_all(void); 715void sun4v_mmu_demap_all(void);
714#endif 716#endif
715 717
716/* mmu_map_perm_addr() 718/* mmu_map_perm_addr()
@@ -740,10 +742,10 @@ extern void sun4v_mmu_demap_all(void);
740#define HV_FAST_MMU_MAP_PERM_ADDR 0x25 742#define HV_FAST_MMU_MAP_PERM_ADDR 0x25
741 743
742#ifndef __ASSEMBLY__ 744#ifndef __ASSEMBLY__
743extern unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr, 745unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr,
744 unsigned long set_to_zero, 746 unsigned long set_to_zero,
745 unsigned long tte, 747 unsigned long tte,
746 unsigned long flags); 748 unsigned long flags);
747#endif 749#endif
748 750
749/* mmu_fault_area_conf() 751/* mmu_fault_area_conf()
@@ -945,7 +947,7 @@ extern unsigned long sun4v_mmu_map_perm_addr(unsigned long vaddr,
945#define HV_FAST_TOD_GET 0x50 947#define HV_FAST_TOD_GET 0x50
946 948
947#ifndef __ASSEMBLY__ 949#ifndef __ASSEMBLY__
948extern unsigned long sun4v_tod_get(unsigned long *time); 950unsigned long sun4v_tod_get(unsigned long *time);
949#endif 951#endif
950 952
951/* tod_set() 953/* tod_set()
@@ -962,7 +964,7 @@ extern unsigned long sun4v_tod_get(unsigned long *time);
962#define HV_FAST_TOD_SET 0x51 964#define HV_FAST_TOD_SET 0x51
963 965
964#ifndef __ASSEMBLY__ 966#ifndef __ASSEMBLY__
965extern unsigned long sun4v_tod_set(unsigned long time); 967unsigned long sun4v_tod_set(unsigned long time);
966#endif 968#endif
967 969
968/* Console services */ 970/* Console services */
@@ -1038,14 +1040,14 @@ extern unsigned long sun4v_tod_set(unsigned long time);
1038#define HV_FAST_CONS_WRITE 0x63 1040#define HV_FAST_CONS_WRITE 0x63
1039 1041
1040#ifndef __ASSEMBLY__ 1042#ifndef __ASSEMBLY__
1041extern long sun4v_con_getchar(long *status); 1043long sun4v_con_getchar(long *status);
1042extern long sun4v_con_putchar(long c); 1044long sun4v_con_putchar(long c);
1043extern long sun4v_con_read(unsigned long buffer, 1045long sun4v_con_read(unsigned long buffer,
1044 unsigned long size, 1046 unsigned long size,
1045 unsigned long *bytes_read); 1047 unsigned long *bytes_read);
1046extern unsigned long sun4v_con_write(unsigned long buffer, 1048unsigned long sun4v_con_write(unsigned long buffer,
1047 unsigned long size, 1049 unsigned long size,
1048 unsigned long *bytes_written); 1050 unsigned long *bytes_written);
1049#endif 1051#endif
1050 1052
1051/* mach_set_soft_state() 1053/* mach_set_soft_state()
@@ -1080,8 +1082,8 @@ extern unsigned long sun4v_con_write(unsigned long buffer,
1080#define HV_SOFT_STATE_TRANSITION 0x02 1082#define HV_SOFT_STATE_TRANSITION 0x02
1081 1083
1082#ifndef __ASSEMBLY__ 1084#ifndef __ASSEMBLY__
1083extern unsigned long sun4v_mach_set_soft_state(unsigned long soft_state, 1085unsigned long sun4v_mach_set_soft_state(unsigned long soft_state,
1084 unsigned long msg_string_ra); 1086 unsigned long msg_string_ra);
1085#endif 1087#endif
1086 1088
1087/* mach_get_soft_state() 1089/* mach_get_soft_state()
@@ -1159,20 +1161,20 @@ extern unsigned long sun4v_mach_set_soft_state(unsigned long soft_state,
1159#define HV_FAST_SVC_CLRSTATUS 0x84 1161#define HV_FAST_SVC_CLRSTATUS 0x84
1160 1162
1161#ifndef __ASSEMBLY__ 1163#ifndef __ASSEMBLY__
1162extern unsigned long sun4v_svc_send(unsigned long svc_id, 1164unsigned long sun4v_svc_send(unsigned long svc_id,
1163 unsigned long buffer, 1165 unsigned long buffer,
1164 unsigned long buffer_size, 1166 unsigned long buffer_size,
1165 unsigned long *sent_bytes); 1167 unsigned long *sent_bytes);
1166extern unsigned long sun4v_svc_recv(unsigned long svc_id, 1168unsigned long sun4v_svc_recv(unsigned long svc_id,
1167 unsigned long buffer, 1169 unsigned long buffer,
1168 unsigned long buffer_size, 1170 unsigned long buffer_size,
1169 unsigned long *recv_bytes); 1171 unsigned long *recv_bytes);
1170extern unsigned long sun4v_svc_getstatus(unsigned long svc_id, 1172unsigned long sun4v_svc_getstatus(unsigned long svc_id,
1171 unsigned long *status_bits); 1173 unsigned long *status_bits);
1172extern unsigned long sun4v_svc_setstatus(unsigned long svc_id, 1174unsigned long sun4v_svc_setstatus(unsigned long svc_id,
1173 unsigned long status_bits); 1175 unsigned long status_bits);
1174extern unsigned long sun4v_svc_clrstatus(unsigned long svc_id, 1176unsigned long sun4v_svc_clrstatus(unsigned long svc_id,
1175 unsigned long status_bits); 1177 unsigned long status_bits);
1176#endif 1178#endif
1177 1179
1178/* Trap trace services. 1180/* Trap trace services.
@@ -1458,8 +1460,8 @@ struct hv_trap_trace_entry {
1458#define HV_FAST_INTR_DEVINO2SYSINO 0xa0 1460#define HV_FAST_INTR_DEVINO2SYSINO 0xa0
1459 1461
1460#ifndef __ASSEMBLY__ 1462#ifndef __ASSEMBLY__
1461extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle, 1463unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
1462 unsigned long devino); 1464 unsigned long devino);
1463#endif 1465#endif
1464 1466
1465/* intr_getenabled() 1467/* intr_getenabled()
@@ -1476,7 +1478,7 @@ extern unsigned long sun4v_devino_to_sysino(unsigned long devhandle,
1476#define HV_FAST_INTR_GETENABLED 0xa1 1478#define HV_FAST_INTR_GETENABLED 0xa1
1477 1479
1478#ifndef __ASSEMBLY__ 1480#ifndef __ASSEMBLY__
1479extern unsigned long sun4v_intr_getenabled(unsigned long sysino); 1481unsigned long sun4v_intr_getenabled(unsigned long sysino);
1480#endif 1482#endif
1481 1483
1482/* intr_setenabled() 1484/* intr_setenabled()
@@ -1492,7 +1494,8 @@ extern unsigned long sun4v_intr_getenabled(unsigned long sysino);
1492#define HV_FAST_INTR_SETENABLED 0xa2 1494#define HV_FAST_INTR_SETENABLED 0xa2
1493 1495
1494#ifndef __ASSEMBLY__ 1496#ifndef __ASSEMBLY__
1495extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long intr_enabled); 1497unsigned long sun4v_intr_setenabled(unsigned long sysino,
1498 unsigned long intr_enabled);
1496#endif 1499#endif
1497 1500
1498/* intr_getstate() 1501/* intr_getstate()
@@ -1508,7 +1511,7 @@ extern unsigned long sun4v_intr_setenabled(unsigned long sysino, unsigned long i
1508#define HV_FAST_INTR_GETSTATE 0xa3 1511#define HV_FAST_INTR_GETSTATE 0xa3
1509 1512
1510#ifndef __ASSEMBLY__ 1513#ifndef __ASSEMBLY__
1511extern unsigned long sun4v_intr_getstate(unsigned long sysino); 1514unsigned long sun4v_intr_getstate(unsigned long sysino);
1512#endif 1515#endif
1513 1516
1514/* intr_setstate() 1517/* intr_setstate()
@@ -1528,7 +1531,7 @@ extern unsigned long sun4v_intr_getstate(unsigned long sysino);
1528#define HV_FAST_INTR_SETSTATE 0xa4 1531#define HV_FAST_INTR_SETSTATE 0xa4
1529 1532
1530#ifndef __ASSEMBLY__ 1533#ifndef __ASSEMBLY__
1531extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state); 1534unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long intr_state);
1532#endif 1535#endif
1533 1536
1534/* intr_gettarget() 1537/* intr_gettarget()
@@ -1546,7 +1549,7 @@ extern unsigned long sun4v_intr_setstate(unsigned long sysino, unsigned long int
1546#define HV_FAST_INTR_GETTARGET 0xa5 1549#define HV_FAST_INTR_GETTARGET 0xa5
1547 1550
1548#ifndef __ASSEMBLY__ 1551#ifndef __ASSEMBLY__
1549extern unsigned long sun4v_intr_gettarget(unsigned long sysino); 1552unsigned long sun4v_intr_gettarget(unsigned long sysino);
1550#endif 1553#endif
1551 1554
1552/* intr_settarget() 1555/* intr_settarget()
@@ -1563,7 +1566,7 @@ extern unsigned long sun4v_intr_gettarget(unsigned long sysino);
1563#define HV_FAST_INTR_SETTARGET 0xa6 1566#define HV_FAST_INTR_SETTARGET 0xa6
1564 1567
1565#ifndef __ASSEMBLY__ 1568#ifndef __ASSEMBLY__
1566extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid); 1569unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cpuid);
1567#endif 1570#endif
1568 1571
1569/* vintr_get_cookie() 1572/* vintr_get_cookie()
@@ -1647,30 +1650,30 @@ extern unsigned long sun4v_intr_settarget(unsigned long sysino, unsigned long cp
1647#define HV_FAST_VINTR_SET_TARGET 0xae 1650#define HV_FAST_VINTR_SET_TARGET 0xae
1648 1651
1649#ifndef __ASSEMBLY__ 1652#ifndef __ASSEMBLY__
1650extern unsigned long sun4v_vintr_get_cookie(unsigned long dev_handle, 1653unsigned long sun4v_vintr_get_cookie(unsigned long dev_handle,
1651 unsigned long dev_ino, 1654 unsigned long dev_ino,
1652 unsigned long *cookie); 1655 unsigned long *cookie);
1653extern unsigned long sun4v_vintr_set_cookie(unsigned long dev_handle, 1656unsigned long sun4v_vintr_set_cookie(unsigned long dev_handle,
1654 unsigned long dev_ino, 1657 unsigned long dev_ino,
1655 unsigned long cookie); 1658 unsigned long cookie);
1656extern unsigned long sun4v_vintr_get_valid(unsigned long dev_handle, 1659unsigned long sun4v_vintr_get_valid(unsigned long dev_handle,
1657 unsigned long dev_ino, 1660 unsigned long dev_ino,
1658 unsigned long *valid); 1661 unsigned long *valid);
1659extern unsigned long sun4v_vintr_set_valid(unsigned long dev_handle, 1662unsigned long sun4v_vintr_set_valid(unsigned long dev_handle,
1660 unsigned long dev_ino, 1663 unsigned long dev_ino,
1661 unsigned long valid); 1664 unsigned long valid);
1662extern unsigned long sun4v_vintr_get_state(unsigned long dev_handle, 1665unsigned long sun4v_vintr_get_state(unsigned long dev_handle,
1663 unsigned long dev_ino, 1666 unsigned long dev_ino,
1664 unsigned long *state); 1667 unsigned long *state);
1665extern unsigned long sun4v_vintr_set_state(unsigned long dev_handle, 1668unsigned long sun4v_vintr_set_state(unsigned long dev_handle,
1666 unsigned long dev_ino, 1669 unsigned long dev_ino,
1667 unsigned long state); 1670 unsigned long state);
1668extern unsigned long sun4v_vintr_get_target(unsigned long dev_handle, 1671unsigned long sun4v_vintr_get_target(unsigned long dev_handle,
1669 unsigned long dev_ino, 1672 unsigned long dev_ino,
1670 unsigned long *cpuid); 1673 unsigned long *cpuid);
1671extern unsigned long sun4v_vintr_set_target(unsigned long dev_handle, 1674unsigned long sun4v_vintr_set_target(unsigned long dev_handle,
1672 unsigned long dev_ino, 1675 unsigned long dev_ino,
1673 unsigned long cpuid); 1676 unsigned long cpuid);
1674#endif 1677#endif
1675 1678
1676/* PCI IO services. 1679/* PCI IO services.
@@ -2627,50 +2630,50 @@ struct ldc_mtable_entry {
2627#define HV_FAST_LDC_REVOKE 0xef 2630#define HV_FAST_LDC_REVOKE 0xef
2628 2631
2629#ifndef __ASSEMBLY__ 2632#ifndef __ASSEMBLY__
2630extern unsigned long sun4v_ldc_tx_qconf(unsigned long channel, 2633unsigned long sun4v_ldc_tx_qconf(unsigned long channel,
2631 unsigned long ra, 2634 unsigned long ra,
2632 unsigned long num_entries); 2635 unsigned long num_entries);
2633extern unsigned long sun4v_ldc_tx_qinfo(unsigned long channel, 2636unsigned long sun4v_ldc_tx_qinfo(unsigned long channel,
2634 unsigned long *ra, 2637 unsigned long *ra,
2635 unsigned long *num_entries); 2638 unsigned long *num_entries);
2636extern unsigned long sun4v_ldc_tx_get_state(unsigned long channel, 2639unsigned long sun4v_ldc_tx_get_state(unsigned long channel,
2637 unsigned long *head_off, 2640 unsigned long *head_off,
2638 unsigned long *tail_off, 2641 unsigned long *tail_off,
2639 unsigned long *chan_state); 2642 unsigned long *chan_state);
2640extern unsigned long sun4v_ldc_tx_set_qtail(unsigned long channel, 2643unsigned long sun4v_ldc_tx_set_qtail(unsigned long channel,
2641 unsigned long tail_off); 2644 unsigned long tail_off);
2642extern unsigned long sun4v_ldc_rx_qconf(unsigned long channel, 2645unsigned long sun4v_ldc_rx_qconf(unsigned long channel,
2643 unsigned long ra, 2646 unsigned long ra,
2644 unsigned long num_entries); 2647 unsigned long num_entries);
2645extern unsigned long sun4v_ldc_rx_qinfo(unsigned long channel, 2648unsigned long sun4v_ldc_rx_qinfo(unsigned long channel,
2646 unsigned long *ra, 2649 unsigned long *ra,
2647 unsigned long *num_entries); 2650 unsigned long *num_entries);
2648extern unsigned long sun4v_ldc_rx_get_state(unsigned long channel, 2651unsigned long sun4v_ldc_rx_get_state(unsigned long channel,
2649 unsigned long *head_off, 2652 unsigned long *head_off,
2650 unsigned long *tail_off, 2653 unsigned long *tail_off,
2651 unsigned long *chan_state); 2654 unsigned long *chan_state);
2652extern unsigned long sun4v_ldc_rx_set_qhead(unsigned long channel, 2655unsigned long sun4v_ldc_rx_set_qhead(unsigned long channel,
2653 unsigned long head_off); 2656 unsigned long head_off);
2654extern unsigned long sun4v_ldc_set_map_table(unsigned long channel, 2657unsigned long sun4v_ldc_set_map_table(unsigned long channel,
2655 unsigned long ra, 2658 unsigned long ra,
2656 unsigned long num_entries); 2659 unsigned long num_entries);
2657extern unsigned long sun4v_ldc_get_map_table(unsigned long channel, 2660unsigned long sun4v_ldc_get_map_table(unsigned long channel,
2658 unsigned long *ra, 2661 unsigned long *ra,
2659 unsigned long *num_entries); 2662 unsigned long *num_entries);
2660extern unsigned long sun4v_ldc_copy(unsigned long channel, 2663unsigned long sun4v_ldc_copy(unsigned long channel,
2661 unsigned long dir_code, 2664 unsigned long dir_code,
2662 unsigned long tgt_raddr, 2665 unsigned long tgt_raddr,
2663 unsigned long lcl_raddr, 2666 unsigned long lcl_raddr,
2664 unsigned long len, 2667 unsigned long len,
2665 unsigned long *actual_len); 2668 unsigned long *actual_len);
2666extern unsigned long sun4v_ldc_mapin(unsigned long channel, 2669unsigned long sun4v_ldc_mapin(unsigned long channel,
2667 unsigned long cookie, 2670 unsigned long cookie,
2668 unsigned long *ra, 2671 unsigned long *ra,
2669 unsigned long *perm); 2672 unsigned long *perm);
2670extern unsigned long sun4v_ldc_unmap(unsigned long ra); 2673unsigned long sun4v_ldc_unmap(unsigned long ra);
2671extern unsigned long sun4v_ldc_revoke(unsigned long channel, 2674unsigned long sun4v_ldc_revoke(unsigned long channel,
2672 unsigned long cookie, 2675 unsigned long cookie,
2673 unsigned long mte_cookie); 2676 unsigned long mte_cookie);
2674#endif 2677#endif
2675 2678
2676/* Performance counter services. */ 2679/* Performance counter services. */
@@ -2727,14 +2730,14 @@ extern unsigned long sun4v_ldc_revoke(unsigned long channel,
2727#define HV_FAST_N2_SET_PERFREG 0x105 2730#define HV_FAST_N2_SET_PERFREG 0x105
2728 2731
2729#ifndef __ASSEMBLY__ 2732#ifndef __ASSEMBLY__
2730extern unsigned long sun4v_niagara_getperf(unsigned long reg, 2733unsigned long sun4v_niagara_getperf(unsigned long reg,
2731 unsigned long *val); 2734 unsigned long *val);
2732extern unsigned long sun4v_niagara_setperf(unsigned long reg, 2735unsigned long sun4v_niagara_setperf(unsigned long reg,
2733 unsigned long val); 2736 unsigned long val);
2734extern unsigned long sun4v_niagara2_getperf(unsigned long reg, 2737unsigned long sun4v_niagara2_getperf(unsigned long reg,
2735 unsigned long *val); 2738 unsigned long *val);
2736extern unsigned long sun4v_niagara2_setperf(unsigned long reg, 2739unsigned long sun4v_niagara2_setperf(unsigned long reg,
2737 unsigned long val); 2740 unsigned long val);
2738#endif 2741#endif
2739 2742
2740/* MMU statistics services. 2743/* MMU statistics services.
@@ -2829,8 +2832,8 @@ struct hv_mmu_statistics {
2829#define HV_FAST_MMUSTAT_INFO 0x103 2832#define HV_FAST_MMUSTAT_INFO 0x103
2830 2833
2831#ifndef __ASSEMBLY__ 2834#ifndef __ASSEMBLY__
2832extern unsigned long sun4v_mmustat_conf(unsigned long ra, unsigned long *orig_ra); 2835unsigned long sun4v_mmustat_conf(unsigned long ra, unsigned long *orig_ra);
2833extern unsigned long sun4v_mmustat_info(unsigned long *ra); 2836unsigned long sun4v_mmustat_info(unsigned long *ra);
2834#endif 2837#endif
2835 2838
2836/* NCS crypto services */ 2839/* NCS crypto services */
@@ -2919,9 +2922,9 @@ struct hv_ncs_qtail_update_arg {
2919#define HV_FAST_NCS_REQUEST 0x110 2922#define HV_FAST_NCS_REQUEST 0x110
2920 2923
2921#ifndef __ASSEMBLY__ 2924#ifndef __ASSEMBLY__
2922extern unsigned long sun4v_ncs_request(unsigned long request, 2925unsigned long sun4v_ncs_request(unsigned long request,
2923 unsigned long arg_ra, 2926 unsigned long arg_ra,
2924 unsigned long arg_size); 2927 unsigned long arg_size);
2925#endif 2928#endif
2926 2929
2927#define HV_FAST_FIRE_GET_PERFREG 0x120 2930#define HV_FAST_FIRE_GET_PERFREG 0x120
@@ -2930,18 +2933,18 @@ extern unsigned long sun4v_ncs_request(unsigned long request,
2930#define HV_FAST_REBOOT_DATA_SET 0x172 2933#define HV_FAST_REBOOT_DATA_SET 0x172
2931 2934
2932#ifndef __ASSEMBLY__ 2935#ifndef __ASSEMBLY__
2933extern unsigned long sun4v_reboot_data_set(unsigned long ra, 2936unsigned long sun4v_reboot_data_set(unsigned long ra,
2934 unsigned long len); 2937 unsigned long len);
2935#endif 2938#endif
2936 2939
2937#define HV_FAST_VT_GET_PERFREG 0x184 2940#define HV_FAST_VT_GET_PERFREG 0x184
2938#define HV_FAST_VT_SET_PERFREG 0x185 2941#define HV_FAST_VT_SET_PERFREG 0x185
2939 2942
2940#ifndef __ASSEMBLY__ 2943#ifndef __ASSEMBLY__
2941extern unsigned long sun4v_vt_get_perfreg(unsigned long reg_num, 2944unsigned long sun4v_vt_get_perfreg(unsigned long reg_num,
2942 unsigned long *reg_val); 2945 unsigned long *reg_val);
2943extern unsigned long sun4v_vt_set_perfreg(unsigned long reg_num, 2946unsigned long sun4v_vt_set_perfreg(unsigned long reg_num,
2944 unsigned long reg_val); 2947 unsigned long reg_val);
2945#endif 2948#endif
2946 2949
2947/* Function numbers for HV_CORE_TRAP. */ 2950/* Function numbers for HV_CORE_TRAP. */
@@ -2978,21 +2981,21 @@ extern unsigned long sun4v_vt_set_perfreg(unsigned long reg_num,
2978#define HV_GRP_DIAG 0x0300 2981#define HV_GRP_DIAG 0x0300
2979 2982
2980#ifndef __ASSEMBLY__ 2983#ifndef __ASSEMBLY__
2981extern unsigned long sun4v_get_version(unsigned long group, 2984unsigned long sun4v_get_version(unsigned long group,
2982 unsigned long *major, 2985 unsigned long *major,
2983 unsigned long *minor); 2986 unsigned long *minor);
2984extern unsigned long sun4v_set_version(unsigned long group, 2987unsigned long sun4v_set_version(unsigned long group,
2985 unsigned long major, 2988 unsigned long major,
2986 unsigned long minor, 2989 unsigned long minor,
2987 unsigned long *actual_minor); 2990 unsigned long *actual_minor);
2988 2991
2989extern int sun4v_hvapi_register(unsigned long group, unsigned long major, 2992int sun4v_hvapi_register(unsigned long group, unsigned long major,
2990 unsigned long *minor); 2993 unsigned long *minor);
2991extern void sun4v_hvapi_unregister(unsigned long group); 2994void sun4v_hvapi_unregister(unsigned long group);
2992extern int sun4v_hvapi_get(unsigned long group, 2995int sun4v_hvapi_get(unsigned long group,
2993 unsigned long *major, 2996 unsigned long *major,
2994 unsigned long *minor); 2997 unsigned long *minor);
2995extern void sun4v_hvapi_init(void); 2998void sun4v_hvapi_init(void);
2996#endif 2999#endif
2997 3000
2998#endif /* !(_SPARC64_HYPERVISOR_H) */ 3001#endif /* !(_SPARC64_HYPERVISOR_H) */
diff --git a/arch/sparc/include/asm/idprom.h b/arch/sparc/include/asm/idprom.h
index 6976aa2439c6..3793f7f91c42 100644
--- a/arch/sparc/include/asm/idprom.h
+++ b/arch/sparc/include/asm/idprom.h
@@ -20,6 +20,6 @@ struct idprom {
20}; 20};
21 21
22extern struct idprom *idprom; 22extern struct idprom *idprom;
23extern void idprom_init(void); 23void idprom_init(void);
24 24
25#endif /* !(_SPARC_IDPROM_H) */ 25#endif /* !(_SPARC_IDPROM_H) */
diff --git a/arch/sparc/include/asm/io-unit.h b/arch/sparc/include/asm/io-unit.h
index 01ab2f613e91..04a9701e7202 100644
--- a/arch/sparc/include/asm/io-unit.h
+++ b/arch/sparc/include/asm/io-unit.h
@@ -43,7 +43,7 @@
43struct iounit_struct { 43struct iounit_struct {
44 unsigned long bmap[(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 3)) / sizeof(unsigned long)]; 44 unsigned long bmap[(IOUNIT_DMA_SIZE >> (PAGE_SHIFT + 3)) / sizeof(unsigned long)];
45 spinlock_t lock; 45 spinlock_t lock;
46 iopte_t *page_table; 46 iopte_t __iomem *page_table;
47 unsigned long rotor[3]; 47 unsigned long rotor[3];
48 unsigned long limit[4]; 48 unsigned long limit[4];
49}; 49};
diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index c1acbd891cbc..9f532902627c 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -2,191 +2,94 @@
2#define __SPARC_IO_H 2#define __SPARC_IO_H
3 3
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/types.h>
6#include <linux/ioport.h> /* struct resource */ 5#include <linux/ioport.h> /* struct resource */
7 6
8#include <asm/page.h> /* IO address mapping routines need this */ 7#define readb_relaxed(__addr) readb(__addr)
9#include <asm-generic/pci_iomap.h> 8#define readw_relaxed(__addr) readw(__addr)
10 9#define readl_relaxed(__addr) readl(__addr)
11#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
12
13static inline u32 flip_dword (u32 l)
14{
15 return ((l&0xff)<<24) | (((l>>8)&0xff)<<16) | (((l>>16)&0xff)<<8)| ((l>>24)&0xff);
16}
17
18static inline u16 flip_word (u16 w)
19{
20 return ((w&0xff) << 8) | ((w>>8)&0xff);
21}
22
23#define mmiowb()
24
25/*
26 * Memory mapped I/O to PCI
27 */
28
29static inline u8 __raw_readb(const volatile void __iomem *addr)
30{
31 return *(__force volatile u8 *)addr;
32}
33
34static inline u16 __raw_readw(const volatile void __iomem *addr)
35{
36 return *(__force volatile u16 *)addr;
37}
38
39static inline u32 __raw_readl(const volatile void __iomem *addr)
40{
41 return *(__force volatile u32 *)addr;
42}
43 10
44static inline void __raw_writeb(u8 b, volatile void __iomem *addr) 11#define IO_SPACE_LIMIT 0xffffffff
45{
46 *(__force volatile u8 *)addr = b;
47}
48 12
49static inline void __raw_writew(u16 w, volatile void __iomem *addr) 13#define memset_io(d,c,sz) _memset_io(d,c,sz)
50{ 14#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
51 *(__force volatile u16 *)addr = w; 15#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
52}
53 16
54static inline void __raw_writel(u32 l, volatile void __iomem *addr) 17#include <asm-generic/io.h>
55{
56 *(__force volatile u32 *)addr = l;
57}
58 18
59static inline u8 __readb(const volatile void __iomem *addr) 19static inline void _memset_io(volatile void __iomem *dst,
20 int c, __kernel_size_t n)
60{ 21{
61 return *(__force volatile u8 *)addr; 22 volatile void __iomem *d = dst;
62}
63 23
64static inline u16 __readw(const volatile void __iomem *addr) 24 while (n--) {
65{ 25 writeb(c, d);
66 return flip_word(*(__force volatile u16 *)addr); 26 d++;
27 }
67} 28}
68 29
69static inline u32 __readl(const volatile void __iomem *addr) 30static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
31 __kernel_size_t n)
70{ 32{
71 return flip_dword(*(__force volatile u32 *)addr); 33 char *d = dst;
72}
73 34
74static inline void __writeb(u8 b, volatile void __iomem *addr) 35 while (n--) {
75{ 36 char tmp = readb(src);
76 *(__force volatile u8 *)addr = b; 37 *d++ = tmp;
38 src++;
39 }
77} 40}
78 41
79static inline void __writew(u16 w, volatile void __iomem *addr) 42static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
43 __kernel_size_t n)
80{ 44{
81 *(__force volatile u16 *)addr = flip_word(w); 45 const char *s = src;
82} 46 volatile void __iomem *d = dst;
83 47
84static inline void __writel(u32 l, volatile void __iomem *addr) 48 while (n--) {
85{ 49 char tmp = *s++;
86 *(__force volatile u32 *)addr = flip_dword(l); 50 writeb(tmp, d);
51 d++;
52 }
87} 53}
88 54
89#define readb(__addr) __readb(__addr)
90#define readw(__addr) __readw(__addr)
91#define readl(__addr) __readl(__addr)
92#define readb_relaxed(__addr) readb(__addr)
93#define readw_relaxed(__addr) readw(__addr)
94#define readl_relaxed(__addr) readl(__addr)
95
96#define writeb(__b, __addr) __writeb((__b),(__addr))
97#define writew(__w, __addr) __writew((__w),(__addr))
98#define writel(__l, __addr) __writel((__l),(__addr))
99
100/*
101 * I/O space operations
102 *
103 * Arrangement on a Sun is somewhat complicated.
104 *
105 * First of all, we want to use standard Linux drivers
106 * for keyboard, PC serial, etc. These drivers think
107 * they access I/O space and use inb/outb.
108 * On the other hand, EBus bridge accepts PCI *memory*
109 * cycles and converts them into ISA *I/O* cycles.
110 * Ergo, we want inb & outb to generate PCI memory cycles.
111 *
112 * If we want to issue PCI *I/O* cycles, we do this
113 * with a low 64K fixed window in PCIC. This window gets
114 * mapped somewhere into virtual kernel space and we
115 * can use inb/outb again.
116 */
117#define inb_local(__addr) __readb((void __iomem *)(unsigned long)(__addr))
118#define inb(__addr) __readb((void __iomem *)(unsigned long)(__addr))
119#define inw(__addr) __readw((void __iomem *)(unsigned long)(__addr))
120#define inl(__addr) __readl((void __iomem *)(unsigned long)(__addr))
121
122#define outb_local(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr))
123#define outb(__b, __addr) __writeb(__b, (void __iomem *)(unsigned long)(__addr))
124#define outw(__w, __addr) __writew(__w, (void __iomem *)(unsigned long)(__addr))
125#define outl(__l, __addr) __writel(__l, (void __iomem *)(unsigned long)(__addr))
126
127#define inb_p(__addr) inb(__addr)
128#define outb_p(__b, __addr) outb(__b, __addr)
129#define inw_p(__addr) inw(__addr)
130#define outw_p(__w, __addr) outw(__w, __addr)
131#define inl_p(__addr) inl(__addr)
132#define outl_p(__l, __addr) outl(__l, __addr)
133
134void outsb(unsigned long addr, const void *src, unsigned long cnt);
135void outsw(unsigned long addr, const void *src, unsigned long cnt);
136void outsl(unsigned long addr, const void *src, unsigned long cnt);
137void insb(unsigned long addr, void *dst, unsigned long count);
138void insw(unsigned long addr, void *dst, unsigned long count);
139void insl(unsigned long addr, void *dst, unsigned long count);
140
141#define IO_SPACE_LIMIT 0xffffffff
142
143/* 55/*
144 * SBus accessors. 56 * SBus accessors.
145 * 57 *
146 * SBus has only one, memory mapped, I/O space. 58 * SBus has only one, memory mapped, I/O space.
147 * We do not need to flip bytes for SBus of course. 59 * We do not need to flip bytes for SBus of course.
148 */ 60 */
149static inline u8 _sbus_readb(const volatile void __iomem *addr) 61static inline u8 sbus_readb(const volatile void __iomem *addr)
150{ 62{
151 return *(__force volatile u8 *)addr; 63 return *(__force volatile u8 *)addr;
152} 64}
153 65
154static inline u16 _sbus_readw(const volatile void __iomem *addr) 66static inline u16 sbus_readw(const volatile void __iomem *addr)
155{ 67{
156 return *(__force volatile u16 *)addr; 68 return *(__force volatile u16 *)addr;
157} 69}
158 70
159static inline u32 _sbus_readl(const volatile void __iomem *addr) 71static inline u32 sbus_readl(const volatile void __iomem *addr)
160{ 72{
161 return *(__force volatile u32 *)addr; 73 return *(__force volatile u32 *)addr;
162} 74}
163 75
164static inline void _sbus_writeb(u8 b, volatile void __iomem *addr) 76static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
165{ 77{
166 *(__force volatile u8 *)addr = b; 78 *(__force volatile u8 *)addr = b;
167} 79}
168 80
169static inline void _sbus_writew(u16 w, volatile void __iomem *addr) 81static inline void sbus_writew(u16 w, volatile void __iomem *addr)
170{ 82{
171 *(__force volatile u16 *)addr = w; 83 *(__force volatile u16 *)addr = w;
172} 84}
173 85
174static inline void _sbus_writel(u32 l, volatile void __iomem *addr) 86static inline void sbus_writel(u32 l, volatile void __iomem *addr)
175{ 87{
176 *(__force volatile u32 *)addr = l; 88 *(__force volatile u32 *)addr = l;
177} 89}
178 90
179/* 91static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
180 * The only reason for #define's is to hide casts to unsigned long. 92 __kernel_size_t n)
181 */
182#define sbus_readb(__addr) _sbus_readb(__addr)
183#define sbus_readw(__addr) _sbus_readw(__addr)
184#define sbus_readl(__addr) _sbus_readl(__addr)
185#define sbus_writeb(__b, __addr) _sbus_writeb(__b, __addr)
186#define sbus_writew(__w, __addr) _sbus_writew(__w, __addr)
187#define sbus_writel(__l, __addr) _sbus_writel(__l, __addr)
188
189static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_size_t n)
190{ 93{
191 while(n--) { 94 while(n--) {
192 sbus_writeb(c, __dst); 95 sbus_writeb(c, __dst);
@@ -194,22 +97,9 @@ static inline void sbus_memset_io(volatile void __iomem *__dst, int c, __kernel_
194 } 97 }
195} 98}
196 99
197static inline void 100static inline void sbus_memcpy_fromio(void *dst,
198_memset_io(volatile void __iomem *dst, int c, __kernel_size_t n) 101 const volatile void __iomem *src,
199{ 102 __kernel_size_t n)
200 volatile void __iomem *d = dst;
201
202 while (n--) {
203 writeb(c, d);
204 d++;
205 }
206}
207
208#define memset_io(d,c,sz) _memset_io(d,c,sz)
209
210static inline void
211_sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
212 __kernel_size_t n)
213{ 103{
214 char *d = dst; 104 char *d = dst;
215 105
@@ -220,25 +110,9 @@ _sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
220 } 110 }
221} 111}
222 112
223#define sbus_memcpy_fromio(d, s, sz) _sbus_memcpy_fromio(d, s, sz) 113static inline void sbus_memcpy_toio(volatile void __iomem *dst,
224 114 const void *src,
225static inline void 115 __kernel_size_t n)
226_memcpy_fromio(void *dst, const volatile void __iomem *src, __kernel_size_t n)
227{
228 char *d = dst;
229
230 while (n--) {
231 char tmp = readb(src);
232 *d++ = tmp;
233 src++;
234 }
235}
236
237#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
238
239static inline void
240_sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
241 __kernel_size_t n)
242{ 116{
243 const char *s = src; 117 const char *s = src;
244 volatile void __iomem *d = dst; 118 volatile void __iomem *d = dst;
@@ -250,81 +124,26 @@ _sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
250 } 124 }
251} 125}
252 126
253#define sbus_memcpy_toio(d, s, sz) _sbus_memcpy_toio(d, s, sz)
254
255static inline void
256_memcpy_toio(volatile void __iomem *dst, const void *src, __kernel_size_t n)
257{
258 const char *s = src;
259 volatile void __iomem *d = dst;
260
261 while (n--) {
262 char tmp = *s++;
263 writeb(tmp, d);
264 d++;
265 }
266}
267
268#define memcpy_toio(d,s,sz) _memcpy_toio(d,s,sz)
269
270#ifdef __KERNEL__ 127#ifdef __KERNEL__
271 128
272/* 129/*
273 * Bus number may be embedded in the higher bits of the physical address. 130 * Bus number may be embedded in the higher bits of the physical address.
274 * This is why we have no bus number argument to ioremap(). 131 * This is why we have no bus number argument to ioremap().
275 */ 132 */
276extern void __iomem *ioremap(unsigned long offset, unsigned long size); 133void __iomem *ioremap(unsigned long offset, unsigned long size);
277#define ioremap_nocache(X,Y) ioremap((X),(Y)) 134#define ioremap_nocache(X,Y) ioremap((X),(Y))
278#define ioremap_wc(X,Y) ioremap((X),(Y)) 135#define ioremap_wc(X,Y) ioremap((X),(Y))
279extern void iounmap(volatile void __iomem *addr); 136void iounmap(volatile void __iomem *addr);
280
281#define ioread8(X) readb(X)
282#define ioread16(X) readw(X)
283#define ioread16be(X) __raw_readw(X)
284#define ioread32(X) readl(X)
285#define ioread32be(X) __raw_readl(X)
286#define iowrite8(val,X) writeb(val,X)
287#define iowrite16(val,X) writew(val,X)
288#define iowrite16be(val,X) __raw_writew(val,X)
289#define iowrite32(val,X) writel(val,X)
290#define iowrite32be(val,X) __raw_writel(val,X)
291
292static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count)
293{
294 insb((unsigned long __force)port, buf, count);
295}
296static inline void ioread16_rep(void __iomem *port, void *buf, unsigned long count)
297{
298 insw((unsigned long __force)port, buf, count);
299}
300
301static inline void ioread32_rep(void __iomem *port, void *buf, unsigned long count)
302{
303 insl((unsigned long __force)port, buf, count);
304}
305
306static inline void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count)
307{
308 outsb((unsigned long __force)port, buf, count);
309}
310
311static inline void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count)
312{
313 outsw((unsigned long __force)port, buf, count);
314}
315
316static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count)
317{
318 outsl((unsigned long __force)port, buf, count);
319}
320 137
321/* Create a virtual mapping cookie for an IO port range */ 138/* Create a virtual mapping cookie for an IO port range */
322extern void __iomem *ioport_map(unsigned long port, unsigned int nr); 139void __iomem *ioport_map(unsigned long port, unsigned int nr);
323extern void ioport_unmap(void __iomem *); 140void ioport_unmap(void __iomem *);
324 141
325/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 142/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
326struct pci_dev; 143struct pci_dev;
327extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 144void pci_iounmap(struct pci_dev *dev, void __iomem *);
145
146
328 147
329/* 148/*
330 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c, 149 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
@@ -343,21 +162,11 @@ static inline int sbus_can_burst64(void)
343 return 0; /* actually, sparc_cpu_model==sun4d */ 162 return 0; /* actually, sparc_cpu_model==sun4d */
344} 163}
345struct device; 164struct device;
346extern void sbus_set_sbus64(struct device *, int); 165void sbus_set_sbus64(struct device *, int);
347 166
348#endif 167#endif
349 168
350#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1 169#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED 1
351 170
352/*
353 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
354 * access
355 */
356#define xlate_dev_mem_ptr(p) __va(p)
357
358/*
359 * Convert a virtual cached pointer to an uncached pointer
360 */
361#define xlate_dev_kmem_ptr(p) p
362 171
363#endif /* !(__SPARC_IO_H) */ 172#endif /* !(__SPARC_IO_H) */
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index 09b0b88aeb2a..05381c3a4228 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -15,7 +15,6 @@
15 15
16/* BIO layer definitions. */ 16/* BIO layer definitions. */
17extern unsigned long kern_base, kern_size; 17extern unsigned long kern_base, kern_size;
18#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
19 18
20static inline u8 _inb(unsigned long addr) 19static inline u8 _inb(unsigned long addr)
21{ 20{
@@ -91,12 +90,12 @@ static inline void _outl(u32 l, unsigned long addr)
91#define inl_p(__addr) inl(__addr) 90#define inl_p(__addr) inl(__addr)
92#define outl_p(__l, __addr) outl(__l, __addr) 91#define outl_p(__l, __addr) outl(__l, __addr)
93 92
94extern void outsb(unsigned long, const void *, unsigned long); 93void outsb(unsigned long, const void *, unsigned long);
95extern void outsw(unsigned long, const void *, unsigned long); 94void outsw(unsigned long, const void *, unsigned long);
96extern void outsl(unsigned long, const void *, unsigned long); 95void outsl(unsigned long, const void *, unsigned long);
97extern void insb(unsigned long, void *, unsigned long); 96void insb(unsigned long, void *, unsigned long);
98extern void insw(unsigned long, void *, unsigned long); 97void insw(unsigned long, void *, unsigned long);
99extern void insl(unsigned long, void *, unsigned long); 98void insl(unsigned long, void *, unsigned long);
100 99
101static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count) 100static inline void ioread8_rep(void __iomem *port, void *buf, unsigned long count)
102{ 101{
@@ -509,12 +508,12 @@ static inline void iounmap(volatile void __iomem *addr)
509#define iowrite32be(val,X) __raw_writel(val,X) 508#define iowrite32be(val,X) __raw_writel(val,X)
510 509
511/* Create a virtual mapping cookie for an IO port range */ 510/* Create a virtual mapping cookie for an IO port range */
512extern void __iomem *ioport_map(unsigned long port, unsigned int nr); 511void __iomem *ioport_map(unsigned long port, unsigned int nr);
513extern void ioport_unmap(void __iomem *); 512void ioport_unmap(void __iomem *);
514 513
515/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ 514/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
516struct pci_dev; 515struct pci_dev;
517extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 516void pci_iounmap(struct pci_dev *dev, void __iomem *);
518 517
519static inline int sbus_can_dma_64bit(void) 518static inline int sbus_can_dma_64bit(void)
520{ 519{
@@ -525,7 +524,7 @@ static inline int sbus_can_burst64(void)
525 return 1; 524 return 1;
526} 525}
527struct device; 526struct device;
528extern void sbus_set_sbus64(struct device *, int); 527void sbus_set_sbus64(struct device *, int);
529 528
530/* 529/*
531 * Convert a physical pointer to a virtual kernel pointer for /dev/mem 530 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
diff --git a/arch/sparc/include/asm/iommu_32.h b/arch/sparc/include/asm/iommu_32.h
index 70c589c05a10..f6c066b52fd6 100644
--- a/arch/sparc/include/asm/iommu_32.h
+++ b/arch/sparc/include/asm/iommu_32.h
@@ -99,7 +99,7 @@ struct iommu_regs {
99#define IOPTE_WAZ 0x00000001 /* Write as zeros */ 99#define IOPTE_WAZ 0x00000001 /* Write as zeros */
100 100
101struct iommu_struct { 101struct iommu_struct {
102 struct iommu_regs *regs; 102 struct iommu_regs __iomem *regs;
103 iopte_t *page_table; 103 iopte_t *page_table;
104 /* For convenience */ 104 /* For convenience */
105 unsigned long start; /* First managed virtual address */ 105 unsigned long start; /* First managed virtual address */
@@ -108,14 +108,14 @@ struct iommu_struct {
108 struct bit_map usemap; 108 struct bit_map usemap;
109}; 109};
110 110
111static inline void iommu_invalidate(struct iommu_regs *regs) 111static inline void iommu_invalidate(struct iommu_regs __iomem *regs)
112{ 112{
113 regs->tlbflush = 0; 113 sbus_writel(0, &regs->tlbflush);
114} 114}
115 115
116static inline void iommu_invalidate_page(struct iommu_regs *regs, unsigned long ba) 116static inline void iommu_invalidate_page(struct iommu_regs __iomem *regs, unsigned long ba)
117{ 117{
118 regs->pageflush = (ba & PAGE_MASK); 118 sbus_writel(ba & PAGE_MASK, &regs->pageflush);
119} 119}
120 120
121#endif /* !(_SPARC_IOMMU_H) */ 121#endif /* !(_SPARC_IOMMU_H) */
diff --git a/arch/sparc/include/asm/iommu_64.h b/arch/sparc/include/asm/iommu_64.h
index caf798b56191..2b9321ab064d 100644
--- a/arch/sparc/include/asm/iommu_64.h
+++ b/arch/sparc/include/asm/iommu_64.h
@@ -58,8 +58,8 @@ struct strbuf {
58 volatile unsigned long __flushflag_buf[(64+(64-1)) / sizeof(long)]; 58 volatile unsigned long __flushflag_buf[(64+(64-1)) / sizeof(long)];
59}; 59};
60 60
61extern int iommu_table_init(struct iommu *iommu, int tsbsize, 61int iommu_table_init(struct iommu *iommu, int tsbsize,
62 u32 dma_offset, u32 dma_addr_mask, 62 u32 dma_offset, u32 dma_addr_mask,
63 int numa_node); 63 int numa_node);
64 64
65#endif /* !(_SPARC64_IOMMU_H) */ 65#endif /* !(_SPARC64_IOMMU_H) */
diff --git a/arch/sparc/include/asm/irq_32.h b/arch/sparc/include/asm/irq_32.h
index 2ae3acaeb1b3..eecd3d8442c9 100644
--- a/arch/sparc/include/asm/irq_32.h
+++ b/arch/sparc/include/asm/irq_32.h
@@ -16,7 +16,8 @@
16 16
17#define irq_canonicalize(irq) (irq) 17#define irq_canonicalize(irq) (irq)
18 18
19extern void __init init_IRQ(void); 19void __init init_IRQ(void);
20void __init sun4d_init_sbi_irq(void);
20 21
21#define NO_IRQ 0xffffffff 22#define NO_IRQ 0xffffffff
22 23
diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h
index abf6afe82ca8..375cffcf7dbd 100644
--- a/arch/sparc/include/asm/irq_64.h
+++ b/arch/sparc/include/asm/irq_64.h
@@ -39,32 +39,32 @@
39 */ 39 */
40#define NR_IRQS 255 40#define NR_IRQS 255
41 41
42extern void irq_install_pre_handler(int irq, 42void irq_install_pre_handler(int irq,
43 void (*func)(unsigned int, void *, void *), 43 void (*func)(unsigned int, void *, void *),
44 void *arg1, void *arg2); 44 void *arg1, void *arg2);
45#define irq_canonicalize(irq) (irq) 45#define irq_canonicalize(irq) (irq)
46extern unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap); 46unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap);
47extern unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino); 47unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino);
48extern unsigned int sun4v_build_virq(u32 devhandle, unsigned int devino); 48unsigned int sun4v_build_virq(u32 devhandle, unsigned int devino);
49extern unsigned int sun4v_build_msi(u32 devhandle, unsigned int *irq_p, 49unsigned int sun4v_build_msi(u32 devhandle, unsigned int *irq_p,
50 unsigned int msi_devino_start, 50 unsigned int msi_devino_start,
51 unsigned int msi_devino_end); 51 unsigned int msi_devino_end);
52extern void sun4v_destroy_msi(unsigned int irq); 52void sun4v_destroy_msi(unsigned int irq);
53extern unsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p, 53unsigned int sun4u_build_msi(u32 portid, unsigned int *irq_p,
54 unsigned int msi_devino_start, 54 unsigned int msi_devino_start,
55 unsigned int msi_devino_end, 55 unsigned int msi_devino_end,
56 unsigned long imap_base, 56 unsigned long imap_base,
57 unsigned long iclr_base); 57 unsigned long iclr_base);
58extern void sun4u_destroy_msi(unsigned int irq); 58void sun4u_destroy_msi(unsigned int irq);
59 59
60extern unsigned char irq_alloc(unsigned int dev_handle, 60unsigned char irq_alloc(unsigned int dev_handle,
61 unsigned int dev_ino); 61 unsigned int dev_ino);
62#ifdef CONFIG_PCI_MSI 62#ifdef CONFIG_PCI_MSI
63extern void irq_free(unsigned int irq); 63void irq_free(unsigned int irq);
64#endif 64#endif
65 65
66extern void __init init_IRQ(void); 66void __init init_IRQ(void);
67extern void fixup_irqs(void); 67void fixup_irqs(void);
68 68
69static inline void set_softint(unsigned long bits) 69static inline void set_softint(unsigned long bits)
70{ 70{
diff --git a/arch/sparc/include/asm/irqflags_32.h b/arch/sparc/include/asm/irqflags_32.h
index e414c06615c1..71cc284f55c5 100644
--- a/arch/sparc/include/asm/irqflags_32.h
+++ b/arch/sparc/include/asm/irqflags_32.h
@@ -15,9 +15,9 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <asm/psr.h> 16#include <asm/psr.h>
17 17
18extern void arch_local_irq_restore(unsigned long); 18void arch_local_irq_restore(unsigned long);
19extern unsigned long arch_local_irq_save(void); 19unsigned long arch_local_irq_save(void);
20extern void arch_local_irq_enable(void); 20void arch_local_irq_enable(void);
21 21
22static inline notrace unsigned long arch_local_save_flags(void) 22static inline notrace unsigned long arch_local_save_flags(void)
23{ 23{
diff --git a/arch/sparc/include/asm/kdebug_64.h b/arch/sparc/include/asm/kdebug_64.h
index feb3578e12c4..04465de8f3b5 100644
--- a/arch/sparc/include/asm/kdebug_64.h
+++ b/arch/sparc/include/asm/kdebug_64.h
@@ -3,7 +3,7 @@
3 3
4struct pt_regs; 4struct pt_regs;
5 5
6extern void bad_trap(struct pt_regs *, long); 6void bad_trap(struct pt_regs *, long);
7 7
8/* Grossly misnamed. */ 8/* Grossly misnamed. */
9enum die_val { 9enum die_val {
diff --git a/arch/sparc/include/asm/kgdb.h b/arch/sparc/include/asm/kgdb.h
index b6ef301d05bf..47366af7a589 100644
--- a/arch/sparc/include/asm/kgdb.h
+++ b/arch/sparc/include/asm/kgdb.h
@@ -28,9 +28,12 @@ enum regnames {
28#define NUMREGBYTES ((GDB_CSR + 1) * 4) 28#define NUMREGBYTES ((GDB_CSR + 1) * 4)
29#else 29#else
30#define NUMREGBYTES ((GDB_Y + 1) * 8) 30#define NUMREGBYTES ((GDB_Y + 1) * 8)
31
32struct pt_regs;
33asmlinkage void kgdb_trap(unsigned long trap_level, struct pt_regs *regs);
31#endif 34#endif
32 35
33extern void arch_kgdb_breakpoint(void); 36void arch_kgdb_breakpoint(void);
34 37
35#define BREAK_INSTR_SIZE 4 38#define BREAK_INSTR_SIZE 4
36#define CACHE_FLUSH_IS_SAFE 1 39#define CACHE_FLUSH_IS_SAFE 1
diff --git a/arch/sparc/include/asm/kprobes.h b/arch/sparc/include/asm/kprobes.h
index 5879d71afdaa..a145d798e112 100644
--- a/arch/sparc/include/asm/kprobes.h
+++ b/arch/sparc/include/asm/kprobes.h
@@ -43,7 +43,9 @@ struct kprobe_ctlblk {
43 struct prev_kprobe prev_kprobe; 43 struct prev_kprobe prev_kprobe;
44}; 44};
45 45
46extern int kprobe_exceptions_notify(struct notifier_block *self, 46int kprobe_exceptions_notify(struct notifier_block *self,
47 unsigned long val, void *data); 47 unsigned long val, void *data);
48extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr); 48int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
49asmlinkage void __kprobes kprobe_trap(unsigned long trap_level,
50 struct pt_regs *regs);
49#endif /* _SPARC64_KPROBES_H */ 51#endif /* _SPARC64_KPROBES_H */
diff --git a/arch/sparc/include/asm/ldc.h b/arch/sparc/include/asm/ldc.h
index bdb524a7b814..c8c67f621f4f 100644
--- a/arch/sparc/include/asm/ldc.h
+++ b/arch/sparc/include/asm/ldc.h
@@ -4,9 +4,9 @@
4#include <asm/hypervisor.h> 4#include <asm/hypervisor.h>
5 5
6extern int ldom_domaining_enabled; 6extern int ldom_domaining_enabled;
7extern void ldom_set_var(const char *var, const char *value); 7void ldom_set_var(const char *var, const char *value);
8extern void ldom_reboot(const char *boot_command); 8void ldom_reboot(const char *boot_command);
9extern void ldom_power_off(void); 9void ldom_power_off(void);
10 10
11/* The event handler will be evoked when link state changes 11/* The event handler will be evoked when link state changes
12 * or data becomes available on the receive side. 12 * or data becomes available on the receive side.
@@ -51,30 +51,30 @@ struct ldc_channel_config {
51struct ldc_channel; 51struct ldc_channel;
52 52
53/* Allocate state for a channel. */ 53/* Allocate state for a channel. */
54extern struct ldc_channel *ldc_alloc(unsigned long id, 54struct ldc_channel *ldc_alloc(unsigned long id,
55 const struct ldc_channel_config *cfgp, 55 const struct ldc_channel_config *cfgp,
56 void *event_arg); 56 void *event_arg);
57 57
58/* Shut down and free state for a channel. */ 58/* Shut down and free state for a channel. */
59extern void ldc_free(struct ldc_channel *lp); 59void ldc_free(struct ldc_channel *lp);
60 60
61/* Register TX and RX queues of the link with the hypervisor. */ 61/* Register TX and RX queues of the link with the hypervisor. */
62extern int ldc_bind(struct ldc_channel *lp, const char *name); 62int ldc_bind(struct ldc_channel *lp, const char *name);
63 63
64/* For non-RAW protocols we need to complete a handshake before 64/* For non-RAW protocols we need to complete a handshake before
65 * communication can proceed. ldc_connect() does that, if the 65 * communication can proceed. ldc_connect() does that, if the
66 * handshake completes successfully, an LDC_EVENT_UP event will 66 * handshake completes successfully, an LDC_EVENT_UP event will
67 * be sent up to the driver. 67 * be sent up to the driver.
68 */ 68 */
69extern int ldc_connect(struct ldc_channel *lp); 69int ldc_connect(struct ldc_channel *lp);
70extern int ldc_disconnect(struct ldc_channel *lp); 70int ldc_disconnect(struct ldc_channel *lp);
71 71
72extern int ldc_state(struct ldc_channel *lp); 72int ldc_state(struct ldc_channel *lp);
73 73
74/* Read and write operations. Only valid when the link is up. */ 74/* Read and write operations. Only valid when the link is up. */
75extern int ldc_write(struct ldc_channel *lp, const void *buf, 75int ldc_write(struct ldc_channel *lp, const void *buf,
76 unsigned int size); 76 unsigned int size);
77extern int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size); 77int ldc_read(struct ldc_channel *lp, void *buf, unsigned int size);
78 78
79#define LDC_MAP_SHADOW 0x01 79#define LDC_MAP_SHADOW 0x01
80#define LDC_MAP_DIRECT 0x02 80#define LDC_MAP_DIRECT 0x02
@@ -92,22 +92,22 @@ struct ldc_trans_cookie {
92}; 92};
93 93
94struct scatterlist; 94struct scatterlist;
95extern int ldc_map_sg(struct ldc_channel *lp, 95int ldc_map_sg(struct ldc_channel *lp,
96 struct scatterlist *sg, int num_sg, 96 struct scatterlist *sg, int num_sg,
97 struct ldc_trans_cookie *cookies, int ncookies, 97 struct ldc_trans_cookie *cookies, int ncookies,
98 unsigned int map_perm); 98 unsigned int map_perm);
99 99
100extern int ldc_map_single(struct ldc_channel *lp, 100int ldc_map_single(struct ldc_channel *lp,
101 void *buf, unsigned int len, 101 void *buf, unsigned int len,
102 struct ldc_trans_cookie *cookies, int ncookies, 102 struct ldc_trans_cookie *cookies, int ncookies,
103 unsigned int map_perm); 103 unsigned int map_perm);
104 104
105extern void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies, 105void ldc_unmap(struct ldc_channel *lp, struct ldc_trans_cookie *cookies,
106 int ncookies); 106 int ncookies);
107 107
108extern int ldc_copy(struct ldc_channel *lp, int copy_dir, 108int ldc_copy(struct ldc_channel *lp, int copy_dir,
109 void *buf, unsigned int len, unsigned long offset, 109 void *buf, unsigned int len, unsigned long offset,
110 struct ldc_trans_cookie *cookies, int ncookies); 110 struct ldc_trans_cookie *cookies, int ncookies);
111 111
112static inline int ldc_get_dring_entry(struct ldc_channel *lp, 112static inline int ldc_get_dring_entry(struct ldc_channel *lp,
113 void *buf, unsigned int len, 113 void *buf, unsigned int len,
@@ -127,12 +127,12 @@ static inline int ldc_put_dring_entry(struct ldc_channel *lp,
127 return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies); 127 return ldc_copy(lp, LDC_COPY_OUT, buf, len, offset, cookies, ncookies);
128} 128}
129 129
130extern void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len, 130void *ldc_alloc_exp_dring(struct ldc_channel *lp, unsigned int len,
131 struct ldc_trans_cookie *cookies, 131 struct ldc_trans_cookie *cookies,
132 int *ncookies, unsigned int map_perm); 132 int *ncookies, unsigned int map_perm);
133 133
134extern void ldc_free_exp_dring(struct ldc_channel *lp, void *buf, 134void ldc_free_exp_dring(struct ldc_channel *lp, void *buf,
135 unsigned int len, 135 unsigned int len,
136 struct ldc_trans_cookie *cookies, int ncookies); 136 struct ldc_trans_cookie *cookies, int ncookies);
137 137
138#endif /* _SPARC64_LDC_H */ 138#endif /* _SPARC64_LDC_H */
diff --git a/arch/sparc/include/asm/leon.h b/arch/sparc/include/asm/leon.h
index c2f6ff6d7a35..204771cd74a5 100644
--- a/arch/sparc/include/asm/leon.h
+++ b/arch/sparc/include/asm/leon.h
@@ -82,8 +82,8 @@ static inline unsigned long leon_load_reg(unsigned long paddr)
82#define LEON_BYPASS_LOAD_PA(x) leon_load_reg((unsigned long)(x)) 82#define LEON_BYPASS_LOAD_PA(x) leon_load_reg((unsigned long)(x))
83#define LEON_BYPASS_STORE_PA(x, v) leon_store_reg((unsigned long)(x), (unsigned long)(v)) 83#define LEON_BYPASS_STORE_PA(x, v) leon_store_reg((unsigned long)(x), (unsigned long)(v))
84 84
85extern void leon_switch_mm(void); 85void leon_switch_mm(void);
86extern void leon_init_IRQ(void); 86void leon_init_IRQ(void);
87 87
88static inline unsigned long sparc_leon3_get_dcachecfg(void) 88static inline unsigned long sparc_leon3_get_dcachecfg(void)
89{ 89{
@@ -196,14 +196,14 @@ static inline int sparc_leon3_cpuid(void)
196#ifndef __ASSEMBLY__ 196#ifndef __ASSEMBLY__
197struct vm_area_struct; 197struct vm_area_struct;
198 198
199extern unsigned long leon_swprobe(unsigned long vaddr, unsigned long *paddr); 199unsigned long leon_swprobe(unsigned long vaddr, unsigned long *paddr);
200extern void leon_flush_icache_all(void); 200void leon_flush_icache_all(void);
201extern void leon_flush_dcache_all(void); 201void leon_flush_dcache_all(void);
202extern void leon_flush_cache_all(void); 202void leon_flush_cache_all(void);
203extern void leon_flush_tlb_all(void); 203void leon_flush_tlb_all(void);
204extern int leon_flush_during_switch; 204extern int leon_flush_during_switch;
205extern int leon_flush_needed(void); 205int leon_flush_needed(void);
206extern void leon_flush_pcache_all(struct vm_area_struct *vma, unsigned long page); 206void leon_flush_pcache_all(struct vm_area_struct *vma, unsigned long page);
207 207
208/* struct that hold LEON3 cache configuration registers */ 208/* struct that hold LEON3 cache configuration registers */
209struct leon3_cacheregs { 209struct leon3_cacheregs {
@@ -217,29 +217,29 @@ struct leon3_cacheregs {
217 217
218struct device_node; 218struct device_node;
219struct task_struct; 219struct task_struct;
220extern unsigned int leon_build_device_irq(unsigned int real_irq, 220unsigned int leon_build_device_irq(unsigned int real_irq,
221 irq_flow_handler_t flow_handler, 221 irq_flow_handler_t flow_handler,
222 const char *name, int do_ack); 222 const char *name, int do_ack);
223extern void leon_update_virq_handling(unsigned int virq, 223void leon_update_virq_handling(unsigned int virq,
224 irq_flow_handler_t flow_handler, 224 irq_flow_handler_t flow_handler,
225 const char *name, int do_ack); 225 const char *name, int do_ack);
226extern void leon_init_timers(void); 226void leon_init_timers(void);
227extern void leon_trans_init(struct device_node *dp); 227void leon_trans_init(struct device_node *dp);
228extern void leon_node_init(struct device_node *dp, struct device_node ***nextp); 228void leon_node_init(struct device_node *dp, struct device_node ***nextp);
229extern void init_leon(void); 229void init_leon(void);
230extern void poke_leonsparc(void); 230void poke_leonsparc(void);
231extern void leon3_getCacheRegs(struct leon3_cacheregs *regs); 231void leon3_getCacheRegs(struct leon3_cacheregs *regs);
232extern int leon3_ticker_irq; 232extern int leon3_ticker_irq;
233 233
234#ifdef CONFIG_SMP 234#ifdef CONFIG_SMP
235extern int leon_smp_nrcpus(void); 235int leon_smp_nrcpus(void);
236extern void leon_clear_profile_irq(int cpu); 236void leon_clear_profile_irq(int cpu);
237extern void leon_smp_done(void); 237void leon_smp_done(void);
238extern void leon_boot_cpus(void); 238void leon_boot_cpus(void);
239extern int leon_boot_one_cpu(int i, struct task_struct *); 239int leon_boot_one_cpu(int i, struct task_struct *);
240void leon_init_smp(void); 240void leon_init_smp(void);
241void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu); 241void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu);
242extern irqreturn_t leon_percpu_timer_interrupt(int irq, void *unused); 242irqreturn_t leon_percpu_timer_interrupt(int irq, void *unused);
243 243
244extern unsigned int smpleon_ipi[]; 244extern unsigned int smpleon_ipi[];
245extern unsigned int linux_trap_ipi15_leon[]; 245extern unsigned int linux_trap_ipi15_leon[];
diff --git a/arch/sparc/include/asm/leon_pci.h b/arch/sparc/include/asm/leon_pci.h
index bfd3ab3092b5..049d067ed8be 100644
--- a/arch/sparc/include/asm/leon_pci.h
+++ b/arch/sparc/include/asm/leon_pci.h
@@ -16,7 +16,7 @@ struct leon_pci_info {
16 int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin); 16 int (*map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
17}; 17};
18 18
19extern void leon_pci_init(struct platform_device *ofdev, 19void leon_pci_init(struct platform_device *ofdev,
20 struct leon_pci_info *info); 20 struct leon_pci_info *info);
21 21
22#endif /* _ASM_LEON_PCI_H_ */ 22#endif /* _ASM_LEON_PCI_H_ */
diff --git a/arch/sparc/include/asm/mc146818rtc.h b/arch/sparc/include/asm/mc146818rtc.h
index 67ed9e3a0235..d8e72f37dc4b 100644
--- a/arch/sparc/include/asm/mc146818rtc.h
+++ b/arch/sparc/include/asm/mc146818rtc.h
@@ -1,5 +1,10 @@
1#ifndef ___ASM_SPARC_MC146818RTC_H 1#ifndef ___ASM_SPARC_MC146818RTC_H
2#define ___ASM_SPARC_MC146818RTC_H 2#define ___ASM_SPARC_MC146818RTC_H
3
4#include <linux/spinlock.h>
5
6extern spinlock_t rtc_lock;
7
3#if defined(__sparc__) && defined(__arch64__) 8#if defined(__sparc__) && defined(__arch64__)
4#include <asm/mc146818rtc_64.h> 9#include <asm/mc146818rtc_64.h>
5#else 10#else
diff --git a/arch/sparc/include/asm/mdesc.h b/arch/sparc/include/asm/mdesc.h
index 139097f3a67b..aebeb88f70db 100644
--- a/arch/sparc/include/asm/mdesc.h
+++ b/arch/sparc/include/asm/mdesc.h
@@ -12,13 +12,13 @@ struct mdesc_handle;
12 * the first argument to all of the operational calls that work 12 * the first argument to all of the operational calls that work
13 * on mdescs. 13 * on mdescs.
14 */ 14 */
15extern struct mdesc_handle *mdesc_grab(void); 15struct mdesc_handle *mdesc_grab(void);
16extern void mdesc_release(struct mdesc_handle *); 16void mdesc_release(struct mdesc_handle *);
17 17
18#define MDESC_NODE_NULL (~(u64)0) 18#define MDESC_NODE_NULL (~(u64)0)
19 19
20extern u64 mdesc_node_by_name(struct mdesc_handle *handle, 20u64 mdesc_node_by_name(struct mdesc_handle *handle,
21 u64 from_node, const char *name); 21 u64 from_node, const char *name);
22#define mdesc_for_each_node_by_name(__hdl, __node, __name) \ 22#define mdesc_for_each_node_by_name(__hdl, __node, __name) \
23 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \ 23 for (__node = mdesc_node_by_name(__hdl, MDESC_NODE_NULL, __name); \
24 (__node) != MDESC_NODE_NULL; \ 24 (__node) != MDESC_NODE_NULL; \
@@ -34,9 +34,9 @@ extern u64 mdesc_node_by_name(struct mdesc_handle *handle,
34 * 34 *
35 * These same rules apply to mdesc_node_name(). 35 * These same rules apply to mdesc_node_name().
36 */ 36 */
37extern const void *mdesc_get_property(struct mdesc_handle *handle, 37const void *mdesc_get_property(struct mdesc_handle *handle,
38 u64 node, const char *name, int *lenp); 38 u64 node, const char *name, int *lenp);
39extern const char *mdesc_node_name(struct mdesc_handle *hp, u64 node); 39const char *mdesc_node_name(struct mdesc_handle *hp, u64 node);
40 40
41/* MD arc iteration, the standard sequence is: 41/* MD arc iteration, the standard sequence is:
42 * 42 *
@@ -50,16 +50,16 @@ extern const char *mdesc_node_name(struct mdesc_handle *hp, u64 node);
50#define MDESC_ARC_TYPE_FWD "fwd" 50#define MDESC_ARC_TYPE_FWD "fwd"
51#define MDESC_ARC_TYPE_BACK "back" 51#define MDESC_ARC_TYPE_BACK "back"
52 52
53extern u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from, 53u64 mdesc_next_arc(struct mdesc_handle *handle, u64 from,
54 const char *arc_type); 54 const char *arc_type);
55#define mdesc_for_each_arc(__arc, __hdl, __node, __type) \ 55#define mdesc_for_each_arc(__arc, __hdl, __node, __type) \
56 for (__arc = mdesc_next_arc(__hdl, __node, __type); \ 56 for (__arc = mdesc_next_arc(__hdl, __node, __type); \
57 (__arc) != MDESC_NODE_NULL; \ 57 (__arc) != MDESC_NODE_NULL; \
58 __arc = mdesc_next_arc(__hdl, __arc, __type)) 58 __arc = mdesc_next_arc(__hdl, __arc, __type))
59 59
60extern u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc); 60u64 mdesc_arc_target(struct mdesc_handle *hp, u64 arc);
61 61
62extern void mdesc_update(void); 62void mdesc_update(void);
63 63
64struct mdesc_notifier_client { 64struct mdesc_notifier_client {
65 void (*add)(struct mdesc_handle *handle, u64 node); 65 void (*add)(struct mdesc_handle *handle, u64 node);
@@ -69,12 +69,12 @@ struct mdesc_notifier_client {
69 struct mdesc_notifier_client *next; 69 struct mdesc_notifier_client *next;
70}; 70};
71 71
72extern void mdesc_register_notifier(struct mdesc_notifier_client *client); 72void mdesc_register_notifier(struct mdesc_notifier_client *client);
73 73
74extern void mdesc_fill_in_cpu_data(cpumask_t *mask); 74void mdesc_fill_in_cpu_data(cpumask_t *mask);
75extern void mdesc_populate_present_mask(cpumask_t *mask); 75void mdesc_populate_present_mask(cpumask_t *mask);
76extern void mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask); 76void mdesc_get_page_sizes(cpumask_t *mask, unsigned long *pgsz_mask);
77 77
78extern void sun4v_mdesc_init(void); 78void sun4v_mdesc_init(void);
79 79
80#endif 80#endif
diff --git a/arch/sparc/include/asm/mmu_64.h b/arch/sparc/include/asm/mmu_64.h
index f668797ae234..70067ce184b1 100644
--- a/arch/sparc/include/asm/mmu_64.h
+++ b/arch/sparc/include/asm/mmu_64.h
@@ -67,9 +67,9 @@ struct tsb {
67 unsigned long pte; 67 unsigned long pte;
68} __attribute__((aligned(TSB_ENTRY_ALIGNMENT))); 68} __attribute__((aligned(TSB_ENTRY_ALIGNMENT)));
69 69
70extern void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte); 70void __tsb_insert(unsigned long ent, unsigned long tag, unsigned long pte);
71extern void tsb_flush(unsigned long ent, unsigned long tag); 71void tsb_flush(unsigned long ent, unsigned long tag);
72extern void tsb_init(struct tsb *tsb, unsigned long size); 72void tsb_init(struct tsb *tsb, unsigned long size);
73 73
74struct tsb_config { 74struct tsb_config {
75 struct tsb *tsb; 75 struct tsb *tsb;
diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h
index 3d528f06e4b0..b84be675e507 100644
--- a/arch/sparc/include/asm/mmu_context_64.h
+++ b/arch/sparc/include/asm/mmu_context_64.h
@@ -17,20 +17,20 @@ extern spinlock_t ctx_alloc_lock;
17extern unsigned long tlb_context_cache; 17extern unsigned long tlb_context_cache;
18extern unsigned long mmu_context_bmap[]; 18extern unsigned long mmu_context_bmap[];
19 19
20extern void get_new_mmu_context(struct mm_struct *mm); 20void get_new_mmu_context(struct mm_struct *mm);
21#ifdef CONFIG_SMP 21#ifdef CONFIG_SMP
22extern void smp_new_mmu_context_version(void); 22void smp_new_mmu_context_version(void);
23#else 23#else
24#define smp_new_mmu_context_version() do { } while (0) 24#define smp_new_mmu_context_version() do { } while (0)
25#endif 25#endif
26 26
27extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm); 27int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
28extern void destroy_context(struct mm_struct *mm); 28void destroy_context(struct mm_struct *mm);
29 29
30extern void __tsb_context_switch(unsigned long pgd_pa, 30void __tsb_context_switch(unsigned long pgd_pa,
31 struct tsb_config *tsb_base, 31 struct tsb_config *tsb_base,
32 struct tsb_config *tsb_huge, 32 struct tsb_config *tsb_huge,
33 unsigned long tsb_descr_pa); 33 unsigned long tsb_descr_pa);
34 34
35static inline void tsb_context_switch(struct mm_struct *mm) 35static inline void tsb_context_switch(struct mm_struct *mm)
36{ 36{
@@ -46,9 +46,11 @@ static inline void tsb_context_switch(struct mm_struct *mm)
46 , __pa(&mm->context.tsb_descr[0])); 46 , __pa(&mm->context.tsb_descr[0]));
47} 47}
48 48
49extern void tsb_grow(struct mm_struct *mm, unsigned long tsb_index, unsigned long mm_rss); 49void tsb_grow(struct mm_struct *mm,
50 unsigned long tsb_index,
51 unsigned long mm_rss);
50#ifdef CONFIG_SMP 52#ifdef CONFIG_SMP
51extern void smp_tsb_sync(struct mm_struct *mm); 53void smp_tsb_sync(struct mm_struct *mm);
52#else 54#else
53#define smp_tsb_sync(__mm) do { } while (0) 55#define smp_tsb_sync(__mm) do { } while (0)
54#endif 56#endif
@@ -66,7 +68,7 @@ extern void smp_tsb_sync(struct mm_struct *mm);
66 : "r" (CTX_HWBITS((__mm)->context)), \ 68 : "r" (CTX_HWBITS((__mm)->context)), \
67 "r" (SECONDARY_CONTEXT), "i" (ASI_DMMU), "i" (ASI_MMU)) 69 "r" (SECONDARY_CONTEXT), "i" (ASI_DMMU), "i" (ASI_MMU))
68 70
69extern void __flush_tlb_mm(unsigned long, unsigned long); 71void __flush_tlb_mm(unsigned long, unsigned long);
70 72
71/* Switch the current MM context. */ 73/* Switch the current MM context. */
72static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk) 74static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk)
diff --git a/arch/sparc/include/asm/nmi.h b/arch/sparc/include/asm/nmi.h
index 72e6500e7ab0..26ad2b2607c6 100644
--- a/arch/sparc/include/asm/nmi.h
+++ b/arch/sparc/include/asm/nmi.h
@@ -1,13 +1,13 @@
1#ifndef __NMI_H 1#ifndef __NMI_H
2#define __NMI_H 2#define __NMI_H
3 3
4extern int __init nmi_init(void); 4int __init nmi_init(void);
5extern void perfctr_irq(int irq, struct pt_regs *regs); 5void perfctr_irq(int irq, struct pt_regs *regs);
6extern void nmi_adjust_hz(unsigned int new_hz); 6void nmi_adjust_hz(unsigned int new_hz);
7 7
8extern atomic_t nmi_active; 8extern atomic_t nmi_active;
9 9
10extern void start_nmi_watchdog(void *unused); 10void start_nmi_watchdog(void *unused);
11extern void stop_nmi_watchdog(void *unused); 11void stop_nmi_watchdog(void *unused);
12 12
13#endif /* __NMI_H */ 13#endif /* __NMI_H */
diff --git a/arch/sparc/include/asm/oplib_32.h b/arch/sparc/include/asm/oplib_32.h
index c72f3045820c..56a09b9d7b1b 100644
--- a/arch/sparc/include/asm/oplib_32.h
+++ b/arch/sparc/include/asm/oplib_32.h
@@ -43,28 +43,28 @@ extern struct linux_nodeops *prom_nodeops;
43/* You must call prom_init() before using any of the library services, 43/* You must call prom_init() before using any of the library services,
44 * preferably as early as possible. Pass it the romvec pointer. 44 * preferably as early as possible. Pass it the romvec pointer.
45 */ 45 */
46extern void prom_init(struct linux_romvec *rom_ptr); 46void prom_init(struct linux_romvec *rom_ptr);
47 47
48/* Boot argument acquisition, returns the boot command line string. */ 48/* Boot argument acquisition, returns the boot command line string. */
49extern char *prom_getbootargs(void); 49char *prom_getbootargs(void);
50 50
51/* Miscellaneous routines, don't really fit in any category per se. */ 51/* Miscellaneous routines, don't really fit in any category per se. */
52 52
53/* Reboot the machine with the command line passed. */ 53/* Reboot the machine with the command line passed. */
54extern void prom_reboot(char *boot_command); 54void prom_reboot(char *boot_command);
55 55
56/* Evaluate the forth string passed. */ 56/* Evaluate the forth string passed. */
57extern void prom_feval(char *forth_string); 57void prom_feval(char *forth_string);
58 58
59/* Enter the prom, with possibility of continuation with the 'go' 59/* Enter the prom, with possibility of continuation with the 'go'
60 * command in newer proms. 60 * command in newer proms.
61 */ 61 */
62extern void prom_cmdline(void); 62void prom_cmdline(void);
63 63
64/* Enter the prom, with no chance of continuation for the stand-alone 64/* Enter the prom, with no chance of continuation for the stand-alone
65 * which calls this. 65 * which calls this.
66 */ 66 */
67extern void __noreturn prom_halt(void); 67void __noreturn prom_halt(void);
68 68
69/* Set the PROM 'sync' callback function to the passed function pointer. 69/* Set the PROM 'sync' callback function to the passed function pointer.
70 * When the user gives the 'sync' command at the prom prompt while the 70 * When the user gives the 'sync' command at the prom prompt while the
@@ -73,37 +73,37 @@ extern void __noreturn prom_halt(void);
73 * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX 73 * XXX The arguments are different on V0 vs. V2->higher proms, grrr! XXX
74 */ 74 */
75typedef void (*sync_func_t)(void); 75typedef void (*sync_func_t)(void);
76extern void prom_setsync(sync_func_t func_ptr); 76void prom_setsync(sync_func_t func_ptr);
77 77
78/* Acquire the IDPROM of the root node in the prom device tree. This 78/* Acquire the IDPROM of the root node in the prom device tree. This
79 * gets passed a buffer where you would like it stuffed. The return value 79 * gets passed a buffer where you would like it stuffed. The return value
80 * is the format type of this idprom or 0xff on error. 80 * is the format type of this idprom or 0xff on error.
81 */ 81 */
82extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size); 82unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
83 83
84/* Get the prom major version. */ 84/* Get the prom major version. */
85extern int prom_version(void); 85int prom_version(void);
86 86
87/* Get the prom plugin revision. */ 87/* Get the prom plugin revision. */
88extern int prom_getrev(void); 88int prom_getrev(void);
89 89
90/* Get the prom firmware revision. */ 90/* Get the prom firmware revision. */
91extern int prom_getprev(void); 91int prom_getprev(void);
92 92
93/* Write a buffer of characters to the console. */ 93/* Write a buffer of characters to the console. */
94extern void prom_console_write_buf(const char *buf, int len); 94void prom_console_write_buf(const char *buf, int len);
95 95
96/* Prom's internal routines, don't use in kernel/boot code. */ 96/* Prom's internal routines, don't use in kernel/boot code. */
97extern __printf(1, 2) void prom_printf(const char *fmt, ...); 97__printf(1, 2) void prom_printf(const char *fmt, ...);
98extern void prom_write(const char *buf, unsigned int len); 98void prom_write(const char *buf, unsigned int len);
99 99
100/* Multiprocessor operations... */ 100/* Multiprocessor operations... */
101 101
102/* Start the CPU with the given device tree node, context table, and context 102/* Start the CPU with the given device tree node, context table, and context
103 * at the passed program counter. 103 * at the passed program counter.
104 */ 104 */
105extern int prom_startcpu(int cpunode, struct linux_prom_registers *context_table, 105int prom_startcpu(int cpunode, struct linux_prom_registers *context_table,
106 int context, char *program_counter); 106 int context, char *program_counter);
107 107
108/* Initialize the memory lists based upon the prom version. */ 108/* Initialize the memory lists based upon the prom version. */
109void prom_meminit(void); 109void prom_meminit(void);
@@ -111,65 +111,65 @@ void prom_meminit(void);
111/* PROM device tree traversal functions... */ 111/* PROM device tree traversal functions... */
112 112
113/* Get the child node of the given node, or zero if no child exists. */ 113/* Get the child node of the given node, or zero if no child exists. */
114extern phandle prom_getchild(phandle parent_node); 114phandle prom_getchild(phandle parent_node);
115 115
116/* Get the next sibling node of the given node, or zero if no further 116/* Get the next sibling node of the given node, or zero if no further
117 * siblings exist. 117 * siblings exist.
118 */ 118 */
119extern phandle prom_getsibling(phandle node); 119phandle prom_getsibling(phandle node);
120 120
121/* Get the length, at the passed node, of the given property type. 121/* Get the length, at the passed node, of the given property type.
122 * Returns -1 on error (ie. no such property at this node). 122 * Returns -1 on error (ie. no such property at this node).
123 */ 123 */
124extern int prom_getproplen(phandle thisnode, const char *property); 124int prom_getproplen(phandle thisnode, const char *property);
125 125
126/* Fetch the requested property using the given buffer. Returns 126/* Fetch the requested property using the given buffer. Returns
127 * the number of bytes the prom put into your buffer or -1 on error. 127 * the number of bytes the prom put into your buffer or -1 on error.
128 */ 128 */
129extern int __must_check prom_getproperty(phandle thisnode, const char *property, 129int __must_check prom_getproperty(phandle thisnode, const char *property,
130 char *prop_buffer, int propbuf_size); 130 char *prop_buffer, int propbuf_size);
131 131
132/* Acquire an integer property. */ 132/* Acquire an integer property. */
133extern int prom_getint(phandle node, char *property); 133int prom_getint(phandle node, char *property);
134 134
135/* Acquire an integer property, with a default value. */ 135/* Acquire an integer property, with a default value. */
136extern int prom_getintdefault(phandle node, char *property, int defval); 136int prom_getintdefault(phandle node, char *property, int defval);
137 137
138/* Acquire a boolean property, 0=FALSE 1=TRUE. */ 138/* Acquire a boolean property, 0=FALSE 1=TRUE. */
139extern int prom_getbool(phandle node, char *prop); 139int prom_getbool(phandle node, char *prop);
140 140
141/* Acquire a string property, null string on error. */ 141/* Acquire a string property, null string on error. */
142extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize); 142void prom_getstring(phandle node, char *prop, char *buf, int bufsize);
143 143
144/* Search all siblings starting at the passed node for "name" matching 144/* Search all siblings starting at the passed node for "name" matching
145 * the given string. Returns the node on success, zero on failure. 145 * the given string. Returns the node on success, zero on failure.
146 */ 146 */
147extern phandle prom_searchsiblings(phandle node_start, char *name); 147phandle prom_searchsiblings(phandle node_start, char *name);
148 148
149/* Returns the next property after the passed property for the given 149/* Returns the next property after the passed property for the given
150 * node. Returns null string on failure. 150 * node. Returns null string on failure.
151 */ 151 */
152extern char *prom_nextprop(phandle node, char *prev_property, char *buffer); 152char *prom_nextprop(phandle node, char *prev_property, char *buffer);
153 153
154/* Returns phandle of the path specified */ 154/* Returns phandle of the path specified */
155extern phandle prom_finddevice(char *name); 155phandle prom_finddevice(char *name);
156 156
157/* Set the indicated property at the given node with the passed value. 157/* Set the indicated property at the given node with the passed value.
158 * Returns the number of bytes of your value that the prom took. 158 * Returns the number of bytes of your value that the prom took.
159 */ 159 */
160extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 160int prom_setprop(phandle node, const char *prop_name, char *prop_value,
161 int value_size); 161 int value_size);
162 162
163extern phandle prom_inst2pkg(int); 163phandle prom_inst2pkg(int);
164 164
165/* Dorking with Bus ranges... */ 165/* Dorking with Bus ranges... */
166 166
167/* Apply promlib probes OBIO ranges to registers. */ 167/* Apply promlib probes OBIO ranges to registers. */
168extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs); 168void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);
169 169
170/* Apply ranges of any prom node (and optionally parent node as well) to registers. */ 170/* Apply ranges of any prom node (and optionally parent node as well) to registers. */
171extern void prom_apply_generic_ranges(phandle node, phandle parent, 171void prom_apply_generic_ranges(phandle node, phandle parent,
172 struct linux_prom_registers *sbusregs, int nregs); 172 struct linux_prom_registers *sbusregs, int nregs);
173 173
174void prom_ranges_init(void); 174void prom_ranges_init(void);
175 175
diff --git a/arch/sparc/include/asm/oplib_64.h b/arch/sparc/include/asm/oplib_64.h
index a12dbe3b7762..f34682430fcf 100644
--- a/arch/sparc/include/asm/oplib_64.h
+++ b/arch/sparc/include/asm/oplib_64.h
@@ -62,100 +62,100 @@ struct linux_mem_p1275 {
62/* You must call prom_init() before using any of the library services, 62/* You must call prom_init() before using any of the library services,
63 * preferably as early as possible. Pass it the romvec pointer. 63 * preferably as early as possible. Pass it the romvec pointer.
64 */ 64 */
65extern void prom_init(void *cif_handler, void *cif_stack); 65void prom_init(void *cif_handler, void *cif_stack);
66 66
67/* Boot argument acquisition, returns the boot command line string. */ 67/* Boot argument acquisition, returns the boot command line string. */
68extern char *prom_getbootargs(void); 68char *prom_getbootargs(void);
69 69
70/* Miscellaneous routines, don't really fit in any category per se. */ 70/* Miscellaneous routines, don't really fit in any category per se. */
71 71
72/* Reboot the machine with the command line passed. */ 72/* Reboot the machine with the command line passed. */
73extern void prom_reboot(const char *boot_command); 73void prom_reboot(const char *boot_command);
74 74
75/* Evaluate the forth string passed. */ 75/* Evaluate the forth string passed. */
76extern void prom_feval(const char *forth_string); 76void prom_feval(const char *forth_string);
77 77
78/* Enter the prom, with possibility of continuation with the 'go' 78/* Enter the prom, with possibility of continuation with the 'go'
79 * command in newer proms. 79 * command in newer proms.
80 */ 80 */
81extern void prom_cmdline(void); 81void prom_cmdline(void);
82 82
83/* Enter the prom, with no chance of continuation for the stand-alone 83/* Enter the prom, with no chance of continuation for the stand-alone
84 * which calls this. 84 * which calls this.
85 */ 85 */
86extern void prom_halt(void) __attribute__ ((noreturn)); 86void prom_halt(void) __attribute__ ((noreturn));
87 87
88/* Halt and power-off the machine. */ 88/* Halt and power-off the machine. */
89extern void prom_halt_power_off(void) __attribute__ ((noreturn)); 89void prom_halt_power_off(void) __attribute__ ((noreturn));
90 90
91/* Acquire the IDPROM of the root node in the prom device tree. This 91/* Acquire the IDPROM of the root node in the prom device tree. This
92 * gets passed a buffer where you would like it stuffed. The return value 92 * gets passed a buffer where you would like it stuffed. The return value
93 * is the format type of this idprom or 0xff on error. 93 * is the format type of this idprom or 0xff on error.
94 */ 94 */
95extern unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size); 95unsigned char prom_get_idprom(char *idp_buffer, int idpbuf_size);
96 96
97/* Write a buffer of characters to the console. */ 97/* Write a buffer of characters to the console. */
98extern void prom_console_write_buf(const char *buf, int len); 98void prom_console_write_buf(const char *buf, int len);
99 99
100/* Prom's internal routines, don't use in kernel/boot code. */ 100/* Prom's internal routines, don't use in kernel/boot code. */
101extern __printf(1, 2) void prom_printf(const char *fmt, ...); 101__printf(1, 2) void prom_printf(const char *fmt, ...);
102extern void prom_write(const char *buf, unsigned int len); 102void prom_write(const char *buf, unsigned int len);
103 103
104/* Multiprocessor operations... */ 104/* Multiprocessor operations... */
105#ifdef CONFIG_SMP 105#ifdef CONFIG_SMP
106/* Start the CPU with the given device tree node at the passed program 106/* Start the CPU with the given device tree node at the passed program
107 * counter with the given arg passed in via register %o0. 107 * counter with the given arg passed in via register %o0.
108 */ 108 */
109extern void prom_startcpu(int cpunode, unsigned long pc, unsigned long arg); 109void prom_startcpu(int cpunode, unsigned long pc, unsigned long arg);
110 110
111/* Start the CPU with the given cpu ID at the passed program 111/* Start the CPU with the given cpu ID at the passed program
112 * counter with the given arg passed in via register %o0. 112 * counter with the given arg passed in via register %o0.
113 */ 113 */
114extern void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg); 114void prom_startcpu_cpuid(int cpuid, unsigned long pc, unsigned long arg);
115 115
116/* Stop the CPU with the given cpu ID. */ 116/* Stop the CPU with the given cpu ID. */
117extern void prom_stopcpu_cpuid(int cpuid); 117void prom_stopcpu_cpuid(int cpuid);
118 118
119/* Stop the current CPU. */ 119/* Stop the current CPU. */
120extern void prom_stopself(void); 120void prom_stopself(void);
121 121
122/* Idle the current CPU. */ 122/* Idle the current CPU. */
123extern void prom_idleself(void); 123void prom_idleself(void);
124 124
125/* Resume the CPU with the passed device tree node. */ 125/* Resume the CPU with the passed device tree node. */
126extern void prom_resumecpu(int cpunode); 126void prom_resumecpu(int cpunode);
127#endif 127#endif
128 128
129/* Power management interfaces. */ 129/* Power management interfaces. */
130 130
131/* Put the current CPU to sleep. */ 131/* Put the current CPU to sleep. */
132extern void prom_sleepself(void); 132void prom_sleepself(void);
133 133
134/* Put the entire system to sleep. */ 134/* Put the entire system to sleep. */
135extern int prom_sleepsystem(void); 135int prom_sleepsystem(void);
136 136
137/* Initiate a wakeup event. */ 137/* Initiate a wakeup event. */
138extern int prom_wakeupsystem(void); 138int prom_wakeupsystem(void);
139 139
140/* MMU and memory related OBP interfaces. */ 140/* MMU and memory related OBP interfaces. */
141 141
142/* Get unique string identifying SIMM at given physical address. */ 142/* Get unique string identifying SIMM at given physical address. */
143extern int prom_getunumber(int syndrome_code, 143int prom_getunumber(int syndrome_code,
144 unsigned long phys_addr, 144 unsigned long phys_addr,
145 char *buf, int buflen); 145 char *buf, int buflen);
146 146
147/* Retain physical memory to the caller across soft resets. */ 147/* Retain physical memory to the caller across soft resets. */
148extern int prom_retain(const char *name, unsigned long size, 148int prom_retain(const char *name, unsigned long size,
149 unsigned long align, unsigned long *paddr); 149 unsigned long align, unsigned long *paddr);
150 150
151/* Load explicit I/D TLB entries into the calling processor. */ 151/* Load explicit I/D TLB entries into the calling processor. */
152extern long prom_itlb_load(unsigned long index, 152long prom_itlb_load(unsigned long index,
153 unsigned long tte_data, 153 unsigned long tte_data,
154 unsigned long vaddr); 154 unsigned long vaddr);
155 155
156extern long prom_dtlb_load(unsigned long index, 156long prom_dtlb_load(unsigned long index,
157 unsigned long tte_data, 157 unsigned long tte_data,
158 unsigned long vaddr); 158 unsigned long vaddr);
159 159
160/* Map/Unmap client program address ranges. First the format of 160/* Map/Unmap client program address ranges. First the format of
161 * the mapping mode argument. 161 * the mapping mode argument.
@@ -170,81 +170,81 @@ extern long prom_dtlb_load(unsigned long index,
170#define PROM_MAP_IE 0x0100 /* Invert-Endianness */ 170#define PROM_MAP_IE 0x0100 /* Invert-Endianness */
171#define PROM_MAP_DEFAULT (PROM_MAP_WRITE | PROM_MAP_READ | PROM_MAP_EXEC | PROM_MAP_CACHED) 171#define PROM_MAP_DEFAULT (PROM_MAP_WRITE | PROM_MAP_READ | PROM_MAP_EXEC | PROM_MAP_CACHED)
172 172
173extern int prom_map(int mode, unsigned long size, 173int prom_map(int mode, unsigned long size,
174 unsigned long vaddr, unsigned long paddr); 174 unsigned long vaddr, unsigned long paddr);
175extern void prom_unmap(unsigned long size, unsigned long vaddr); 175void prom_unmap(unsigned long size, unsigned long vaddr);
176 176
177 177
178/* PROM device tree traversal functions... */ 178/* PROM device tree traversal functions... */
179 179
180/* Get the child node of the given node, or zero if no child exists. */ 180/* Get the child node of the given node, or zero if no child exists. */
181extern phandle prom_getchild(phandle parent_node); 181phandle prom_getchild(phandle parent_node);
182 182
183/* Get the next sibling node of the given node, or zero if no further 183/* Get the next sibling node of the given node, or zero if no further
184 * siblings exist. 184 * siblings exist.
185 */ 185 */
186extern phandle prom_getsibling(phandle node); 186phandle prom_getsibling(phandle node);
187 187
188/* Get the length, at the passed node, of the given property type. 188/* Get the length, at the passed node, of the given property type.
189 * Returns -1 on error (ie. no such property at this node). 189 * Returns -1 on error (ie. no such property at this node).
190 */ 190 */
191extern int prom_getproplen(phandle thisnode, const char *property); 191int prom_getproplen(phandle thisnode, const char *property);
192 192
193/* Fetch the requested property using the given buffer. Returns 193/* Fetch the requested property using the given buffer. Returns
194 * the number of bytes the prom put into your buffer or -1 on error. 194 * the number of bytes the prom put into your buffer or -1 on error.
195 */ 195 */
196extern int prom_getproperty(phandle thisnode, const char *property, 196int prom_getproperty(phandle thisnode, const char *property,
197 char *prop_buffer, int propbuf_size); 197 char *prop_buffer, int propbuf_size);
198 198
199/* Acquire an integer property. */ 199/* Acquire an integer property. */
200extern int prom_getint(phandle node, const char *property); 200int prom_getint(phandle node, const char *property);
201 201
202/* Acquire an integer property, with a default value. */ 202/* Acquire an integer property, with a default value. */
203extern int prom_getintdefault(phandle node, const char *property, int defval); 203int prom_getintdefault(phandle node, const char *property, int defval);
204 204
205/* Acquire a boolean property, 0=FALSE 1=TRUE. */ 205/* Acquire a boolean property, 0=FALSE 1=TRUE. */
206extern int prom_getbool(phandle node, const char *prop); 206int prom_getbool(phandle node, const char *prop);
207 207
208/* Acquire a string property, null string on error. */ 208/* Acquire a string property, null string on error. */
209extern void prom_getstring(phandle node, const char *prop, char *buf, 209void prom_getstring(phandle node, const char *prop, char *buf,
210 int bufsize); 210 int bufsize);
211 211
212/* Does the passed node have the given "name"? YES=1 NO=0 */ 212/* Does the passed node have the given "name"? YES=1 NO=0 */
213extern int prom_nodematch(phandle thisnode, const char *name); 213int prom_nodematch(phandle thisnode, const char *name);
214 214
215/* Search all siblings starting at the passed node for "name" matching 215/* Search all siblings starting at the passed node for "name" matching
216 * the given string. Returns the node on success, zero on failure. 216 * the given string. Returns the node on success, zero on failure.
217 */ 217 */
218extern phandle prom_searchsiblings(phandle node_start, const char *name); 218phandle prom_searchsiblings(phandle node_start, const char *name);
219 219
220/* Return the first property type, as a string, for the given node. 220/* Return the first property type, as a string, for the given node.
221 * Returns a null string on error. Buffer should be at least 32B long. 221 * Returns a null string on error. Buffer should be at least 32B long.
222 */ 222 */
223extern char *prom_firstprop(phandle node, char *buffer); 223char *prom_firstprop(phandle node, char *buffer);
224 224
225/* Returns the next property after the passed property for the given 225/* Returns the next property after the passed property for the given
226 * node. Returns null string on failure. Buffer should be at least 32B long. 226 * node. Returns null string on failure. Buffer should be at least 32B long.
227 */ 227 */
228extern char *prom_nextprop(phandle node, const char *prev_property, char *buf); 228char *prom_nextprop(phandle node, const char *prev_property, char *buf);
229 229
230/* Returns 1 if the specified node has given property. */ 230/* Returns 1 if the specified node has given property. */
231extern int prom_node_has_property(phandle node, const char *property); 231int prom_node_has_property(phandle node, const char *property);
232 232
233/* Returns phandle of the path specified */ 233/* Returns phandle of the path specified */
234extern phandle prom_finddevice(const char *name); 234phandle prom_finddevice(const char *name);
235 235
236/* Set the indicated property at the given node with the passed value. 236/* Set the indicated property at the given node with the passed value.
237 * Returns the number of bytes of your value that the prom took. 237 * Returns the number of bytes of your value that the prom took.
238 */ 238 */
239extern int prom_setprop(phandle node, const char *prop_name, char *prop_value, 239int prom_setprop(phandle node, const char *prop_name, char *prop_value,
240 int value_size); 240 int value_size);
241 241
242extern phandle prom_inst2pkg(int); 242phandle prom_inst2pkg(int);
243extern void prom_sun4v_guest_soft_state(void); 243void prom_sun4v_guest_soft_state(void);
244 244
245extern int prom_ihandle2path(int handle, char *buffer, int bufsize); 245int prom_ihandle2path(int handle, char *buffer, int bufsize);
246 246
247/* Client interface level routines. */ 247/* Client interface level routines. */
248extern void p1275_cmd_direct(unsigned long *); 248void p1275_cmd_direct(unsigned long *);
249 249
250#endif /* !(__SPARC64_OPLIB_H) */ 250#endif /* !(__SPARC64_OPLIB_H) */
diff --git a/arch/sparc/include/asm/page.h b/arch/sparc/include/asm/page.h
index f21de0349025..1be2fdec6268 100644
--- a/arch/sparc/include/asm/page.h
+++ b/arch/sparc/include/asm/page.h
@@ -1,5 +1,8 @@
1#ifndef ___ASM_SPARC_PAGE_H 1#ifndef ___ASM_SPARC_PAGE_H
2#define ___ASM_SPARC_PAGE_H 2#define ___ASM_SPARC_PAGE_H
3
4#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
5
3#if defined(__sparc__) && defined(__arch64__) 6#if defined(__sparc__) && defined(__arch64__)
4#include <asm/page_64.h> 7#include <asm/page_64.h>
5#else 8#else
diff --git a/arch/sparc/include/asm/page_64.h b/arch/sparc/include/asm/page_64.h
index aac53fcea807..bf109984a032 100644
--- a/arch/sparc/include/asm/page_64.h
+++ b/arch/sparc/include/asm/page_64.h
@@ -31,17 +31,17 @@
31 31
32#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) 32#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
33struct pt_regs; 33struct pt_regs;
34extern void hugetlb_setup(struct pt_regs *regs); 34void hugetlb_setup(struct pt_regs *regs);
35#endif 35#endif
36 36
37#define WANT_PAGE_VIRTUAL 37#define WANT_PAGE_VIRTUAL
38 38
39extern void _clear_page(void *page); 39void _clear_page(void *page);
40#define clear_page(X) _clear_page((void *)(X)) 40#define clear_page(X) _clear_page((void *)(X))
41struct page; 41struct page;
42extern void clear_user_page(void *addr, unsigned long vaddr, struct page *page); 42void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
43#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE) 43#define copy_page(X,Y) memcpy((void *)(X), (void *)(Y), PAGE_SIZE)
44extern void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage); 44void copy_user_page(void *to, void *from, unsigned long vaddr, struct page *topage);
45 45
46/* Unlike sparc32, sparc64's parameter passing API is more 46/* Unlike sparc32, sparc64's parameter passing API is more
47 * sane in that structures which as small enough are passed 47 * sane in that structures which as small enough are passed
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index c6c7396e7627..bd00a6226169 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -52,7 +52,7 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
52 52
53/* Return the index of the PCI controller for device PDEV. */ 53/* Return the index of the PCI controller for device PDEV. */
54 54
55extern int pci_domain_nr(struct pci_bus *bus); 55int pci_domain_nr(struct pci_bus *bus);
56static inline int pci_proc_domain(struct pci_bus *bus) 56static inline int pci_proc_domain(struct pci_bus *bus)
57{ 57{
58 return 1; 58 return 1;
@@ -64,9 +64,9 @@ static inline int pci_proc_domain(struct pci_bus *bus)
64#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA 64#define HAVE_ARCH_PCI_GET_UNMAPPED_AREA
65#define get_pci_unmapped_area get_fb_unmapped_area 65#define get_pci_unmapped_area get_fb_unmapped_area
66 66
67extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 67int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
68 enum pci_mmap_state mmap_state, 68 enum pci_mmap_state mmap_state,
69 int write_combine); 69 int write_combine);
70 70
71static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 71static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
72{ 72{
@@ -74,9 +74,9 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
74} 74}
75 75
76#define HAVE_ARCH_PCI_RESOURCE_TO_USER 76#define HAVE_ARCH_PCI_RESOURCE_TO_USER
77extern void pci_resource_to_user(const struct pci_dev *dev, int bar, 77void pci_resource_to_user(const struct pci_dev *dev, int bar,
78 const struct resource *rsrc, 78 const struct resource *rsrc,
79 resource_size_t *start, resource_size_t *end); 79 resource_size_t *start, resource_size_t *end);
80#endif /* __KERNEL__ */ 80#endif /* __KERNEL__ */
81 81
82#endif /* __SPARC64_PCI_H */ 82#endif /* __SPARC64_PCI_H */
diff --git a/arch/sparc/include/asm/pcic.h b/arch/sparc/include/asm/pcic.h
index 6676cbcc8b6a..f41706792592 100644
--- a/arch/sparc/include/asm/pcic.h
+++ b/arch/sparc/include/asm/pcic.h
@@ -30,10 +30,10 @@ struct linux_pcic {
30}; 30};
31 31
32#ifdef CONFIG_PCIC_PCI 32#ifdef CONFIG_PCIC_PCI
33extern int pcic_present(void); 33int pcic_present(void);
34extern int pcic_probe(void); 34int pcic_probe(void);
35extern void pci_time_init(void); 35void pci_time_init(void);
36extern void sun4m_pci_init_IRQ(void); 36void sun4m_pci_init_IRQ(void);
37#else 37#else
38static inline int pcic_present(void) { return 0; } 38static inline int pcic_present(void) { return 0; }
39static inline int pcic_probe(void) { return 0; } 39static inline int pcic_probe(void) { return 0; }
diff --git a/arch/sparc/include/asm/pcr.h b/arch/sparc/include/asm/pcr.h
index 942bb17f60cd..cdf800c3326c 100644
--- a/arch/sparc/include/asm/pcr.h
+++ b/arch/sparc/include/asm/pcr.h
@@ -12,8 +12,8 @@ struct pcr_ops {
12}; 12};
13extern const struct pcr_ops *pcr_ops; 13extern const struct pcr_ops *pcr_ops;
14 14
15extern void deferred_pcr_work_irq(int irq, struct pt_regs *regs); 15void deferred_pcr_work_irq(int irq, struct pt_regs *regs);
16extern void schedule_deferred_pcr_work(void); 16void schedule_deferred_pcr_work(void);
17 17
18#define PCR_PIC_PRIV 0x00000001 /* PIC access is privileged */ 18#define PCR_PIC_PRIV 0x00000001 /* PIC access is privileged */
19#define PCR_STRACE 0x00000002 /* Trace supervisor events */ 19#define PCR_STRACE 0x00000002 /* Trace supervisor events */
@@ -45,6 +45,6 @@ extern void schedule_deferred_pcr_work(void);
45#define PCR_N4_PICNHT 0x00020000 /* PIC non-hypervisor trap */ 45#define PCR_N4_PICNHT 0x00020000 /* PIC non-hypervisor trap */
46#define PCR_N4_NTC 0x00040000 /* Next-To-Commit wrap */ 46#define PCR_N4_NTC 0x00040000 /* Next-To-Commit wrap */
47 47
48extern int pcr_arch_init(void); 48int pcr_arch_init(void);
49 49
50#endif /* __PCR_H */ 50#endif /* __PCR_H */
diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
index 9b1c36de0f18..a3890da94428 100644
--- a/arch/sparc/include/asm/pgalloc_32.h
+++ b/arch/sparc/include/asm/pgalloc_32.h
@@ -14,6 +14,8 @@ struct page;
14void *srmmu_get_nocache(int size, int align); 14void *srmmu_get_nocache(int size, int align);
15void srmmu_free_nocache(void *addr, int size); 15void srmmu_free_nocache(void *addr, int size);
16 16
17extern struct resource sparc_iomap;
18
17#define check_pgt_cache() do { } while (0) 19#define check_pgt_cache() do { } while (0)
18 20
19pgd_t *get_pgd_fast(void); 21pgd_t *get_pgd_fast(void);
diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
index bcfe063bce23..39a7ac49b00c 100644
--- a/arch/sparc/include/asm/pgalloc_64.h
+++ b/arch/sparc/include/asm/pgalloc_64.h
@@ -38,12 +38,12 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
38 kmem_cache_free(pgtable_cache, pmd); 38 kmem_cache_free(pgtable_cache, pmd);
39} 39}
40 40
41extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 41pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42 unsigned long address); 42 unsigned long address);
43extern pgtable_t pte_alloc_one(struct mm_struct *mm, 43pgtable_t pte_alloc_one(struct mm_struct *mm,
44 unsigned long address); 44 unsigned long address);
45extern void pte_free_kernel(struct mm_struct *mm, pte_t *pte); 45void pte_free_kernel(struct mm_struct *mm, pte_t *pte);
46extern void pte_free(struct mm_struct *mm, pgtable_t ptepage); 46void pte_free(struct mm_struct *mm, pgtable_t ptepage);
47 47
48#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(MM, PMD, PTE) 48#define pmd_populate_kernel(MM, PMD, PTE) pmd_set(MM, PMD, PTE)
49#define pmd_populate(MM, PMD, PTE) pmd_set(MM, PMD, PTE) 49#define pmd_populate(MM, PMD, PTE) pmd_set(MM, PMD, PTE)
@@ -51,12 +51,12 @@ extern void pte_free(struct mm_struct *mm, pgtable_t ptepage);
51 51
52#define check_pgt_cache() do { } while (0) 52#define check_pgt_cache() do { } while (0)
53 53
54extern void pgtable_free(void *table, bool is_page); 54void pgtable_free(void *table, bool is_page);
55 55
56#ifdef CONFIG_SMP 56#ifdef CONFIG_SMP
57 57
58struct mmu_gather; 58struct mmu_gather;
59extern void tlb_remove_table(struct mmu_gather *, void *); 59void tlb_remove_table(struct mmu_gather *, void *);
60 60
61static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page) 61static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, bool is_page)
62{ 62{
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 502f632f6cc7..b9b91ae19fe1 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -25,8 +25,9 @@
25struct vm_area_struct; 25struct vm_area_struct;
26struct page; 26struct page;
27 27
28extern void load_mmu(void); 28void load_mmu(void);
29extern unsigned long calc_highpages(void); 29unsigned long calc_highpages(void);
30unsigned long __init bootmem_init(unsigned long *pages_avail);
30 31
31#define pte_ERROR(e) __builtin_trap() 32#define pte_ERROR(e) __builtin_trap()
32#define pmd_ERROR(e) __builtin_trap() 33#define pmd_ERROR(e) __builtin_trap()
@@ -56,7 +57,7 @@ extern unsigned long calc_highpages(void);
56 * srmmu.c will assign the real one (which is dynamically sized) */ 57 * srmmu.c will assign the real one (which is dynamically sized) */
57#define swapper_pg_dir NULL 58#define swapper_pg_dir NULL
58 59
59extern void paging_init(void); 60void paging_init(void);
60 61
61extern unsigned long ptr_in_current_pgd; 62extern unsigned long ptr_in_current_pgd;
62 63
@@ -428,8 +429,8 @@ extern unsigned long *sparc_valid_addr_bitmap;
428#define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) 429#define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4))
429#define GET_PFN(pfn) (pfn & 0x0fffffffUL) 430#define GET_PFN(pfn) (pfn & 0x0fffffffUL)
430 431
431extern int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, 432int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long,
432 unsigned long, pgprot_t); 433 unsigned long, pgprot_t);
433 434
434static inline int io_remap_pfn_range(struct vm_area_struct *vma, 435static inline int io_remap_pfn_range(struct vm_area_struct *vma,
435 unsigned long from, unsigned long pfn, 436 unsigned long from, unsigned long pfn,
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 1a49ffdf9da9..3770bf5c6e1b 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -210,9 +210,9 @@ static inline bool kern_addr_valid(unsigned long addr)
210 210
211#ifndef __ASSEMBLY__ 211#ifndef __ASSEMBLY__
212 212
213extern pte_t mk_pte_io(unsigned long, pgprot_t, int, unsigned long); 213pte_t mk_pte_io(unsigned long, pgprot_t, int, unsigned long);
214 214
215extern unsigned long pte_sz_bits(unsigned long size); 215unsigned long pte_sz_bits(unsigned long size);
216 216
217extern pgprot_t PAGE_KERNEL; 217extern pgprot_t PAGE_KERNEL;
218extern pgprot_t PAGE_KERNEL_LOCKED; 218extern pgprot_t PAGE_KERNEL_LOCKED;
@@ -780,8 +780,8 @@ static inline int pmd_present(pmd_t pmd)
780 !__kern_addr_valid(pud_val(pud))) 780 !__kern_addr_valid(pud_val(pud)))
781 781
782#ifdef CONFIG_TRANSPARENT_HUGEPAGE 782#ifdef CONFIG_TRANSPARENT_HUGEPAGE
783extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, 783void set_pmd_at(struct mm_struct *mm, unsigned long addr,
784 pmd_t *pmdp, pmd_t pmd); 784 pmd_t *pmdp, pmd_t pmd);
785#else 785#else
786static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, 786static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
787 pmd_t *pmdp, pmd_t pmd) 787 pmd_t *pmdp, pmd_t pmd)
@@ -840,8 +840,8 @@ static inline unsigned long __pmd_page(pmd_t pmd)
840#define pte_unmap(pte) do { } while (0) 840#define pte_unmap(pte) do { } while (0)
841 841
842/* Actual page table PTE updates. */ 842/* Actual page table PTE updates. */
843extern void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, 843void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr,
844 pte_t *ptep, pte_t orig, int fullmm); 844 pte_t *ptep, pte_t orig, int fullmm);
845 845
846#define __HAVE_ARCH_PMDP_GET_AND_CLEAR 846#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
847static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, 847static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm,
@@ -900,28 +900,28 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
900extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 900extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
901extern pmd_t swapper_low_pmd_dir[PTRS_PER_PMD]; 901extern pmd_t swapper_low_pmd_dir[PTRS_PER_PMD];
902 902
903extern void paging_init(void); 903void paging_init(void);
904extern unsigned long find_ecache_flush_span(unsigned long size); 904unsigned long find_ecache_flush_span(unsigned long size);
905 905
906struct seq_file; 906struct seq_file;
907extern void mmu_info(struct seq_file *); 907void mmu_info(struct seq_file *);
908 908
909struct vm_area_struct; 909struct vm_area_struct;
910extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *); 910void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
911#ifdef CONFIG_TRANSPARENT_HUGEPAGE 911#ifdef CONFIG_TRANSPARENT_HUGEPAGE
912extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr, 912void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
913 pmd_t *pmd); 913 pmd_t *pmd);
914 914
915#define __HAVE_ARCH_PMDP_INVALIDATE 915#define __HAVE_ARCH_PMDP_INVALIDATE
916extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, 916extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
917 pmd_t *pmdp); 917 pmd_t *pmdp);
918 918
919#define __HAVE_ARCH_PGTABLE_DEPOSIT 919#define __HAVE_ARCH_PGTABLE_DEPOSIT
920extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, 920void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
921 pgtable_t pgtable); 921 pgtable_t pgtable);
922 922
923#define __HAVE_ARCH_PGTABLE_WITHDRAW 923#define __HAVE_ARCH_PGTABLE_WITHDRAW
924extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp); 924pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
925#endif 925#endif
926 926
927/* Encode and de-code a swap entry */ 927/* Encode and de-code a swap entry */
@@ -937,12 +937,12 @@ extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
937#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 937#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
938 938
939/* File offset in PTE support. */ 939/* File offset in PTE support. */
940extern unsigned long pte_file(pte_t); 940unsigned long pte_file(pte_t);
941#define pte_to_pgoff(pte) (pte_val(pte) >> PAGE_SHIFT) 941#define pte_to_pgoff(pte) (pte_val(pte) >> PAGE_SHIFT)
942extern pte_t pgoff_to_pte(unsigned long); 942pte_t pgoff_to_pte(unsigned long);
943#define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL) 943#define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL)
944 944
945extern int page_in_phys_avail(unsigned long paddr); 945int page_in_phys_avail(unsigned long paddr);
946 946
947/* 947/*
948 * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in 948 * For sparc32&64, the pfn in io_remap_pfn_range() carries <iospace> in
@@ -952,8 +952,8 @@ extern int page_in_phys_avail(unsigned long paddr);
952#define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4)) 952#define GET_IOSPACE(pfn) (pfn >> (BITS_PER_LONG - 4))
953#define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL) 953#define GET_PFN(pfn) (pfn & 0x0fffffffffffffffUL)
954 954
955extern int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long, 955int remap_pfn_range(struct vm_area_struct *, unsigned long, unsigned long,
956 unsigned long, pgprot_t); 956 unsigned long, pgprot_t);
957 957
958static inline int io_remap_pfn_range(struct vm_area_struct *vma, 958static inline int io_remap_pfn_range(struct vm_area_struct *vma,
959 unsigned long from, unsigned long pfn, 959 unsigned long from, unsigned long pfn,
@@ -981,20 +981,20 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
981/* We provide a special get_unmapped_area for framebuffer mmaps to try and use 981/* We provide a special get_unmapped_area for framebuffer mmaps to try and use
982 * the largest alignment possible such that larget PTEs can be used. 982 * the largest alignment possible such that larget PTEs can be used.
983 */ 983 */
984extern unsigned long get_fb_unmapped_area(struct file *filp, unsigned long, 984unsigned long get_fb_unmapped_area(struct file *filp, unsigned long,
985 unsigned long, unsigned long, 985 unsigned long, unsigned long,
986 unsigned long); 986 unsigned long);
987#define HAVE_ARCH_FB_UNMAPPED_AREA 987#define HAVE_ARCH_FB_UNMAPPED_AREA
988 988
989extern void pgtable_cache_init(void); 989void pgtable_cache_init(void);
990extern void sun4v_register_fault_status(void); 990void sun4v_register_fault_status(void);
991extern void sun4v_ktsb_register(void); 991void sun4v_ktsb_register(void);
992extern void __init cheetah_ecache_flush_init(void); 992void __init cheetah_ecache_flush_init(void);
993extern void sun4v_patch_tlb_handlers(void); 993void sun4v_patch_tlb_handlers(void);
994 994
995extern unsigned long cmdline_memory_size; 995extern unsigned long cmdline_memory_size;
996 996
997extern asmlinkage void do_sparc64_fault(struct pt_regs *regs); 997asmlinkage void do_sparc64_fault(struct pt_regs *regs);
998 998
999#endif /* !(__ASSEMBLY__) */ 999#endif /* !(__ASSEMBLY__) */
1000 1000
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h
index 2c7baa4c4505..a564817bbc2e 100644
--- a/arch/sparc/include/asm/processor_32.h
+++ b/arch/sparc/include/asm/processor_32.h
@@ -74,7 +74,7 @@ struct thread_struct {
74} 74}
75 75
76/* Return saved PC of a blocked thread. */ 76/* Return saved PC of a blocked thread. */
77extern unsigned long thread_saved_pc(struct task_struct *t); 77unsigned long thread_saved_pc(struct task_struct *t);
78 78
79/* Do necessary setup to start up a newly executed thread. */ 79/* Do necessary setup to start up a newly executed thread. */
80static inline void start_thread(struct pt_regs * regs, unsigned long pc, 80static inline void start_thread(struct pt_regs * regs, unsigned long pc,
@@ -107,7 +107,7 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,
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)
109 109
110extern unsigned long get_wchan(struct task_struct *); 110unsigned long get_wchan(struct task_struct *);
111 111
112#define task_pt_regs(tsk) ((tsk)->thread.kregs) 112#define task_pt_regs(tsk) ((tsk)->thread.kregs)
113#define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc) 113#define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc)
@@ -116,6 +116,7 @@ extern unsigned long get_wchan(struct task_struct *);
116#ifdef __KERNEL__ 116#ifdef __KERNEL__
117 117
118extern struct task_struct *last_task_used_math; 118extern struct task_struct *last_task_used_math;
119int do_mathemu(struct pt_regs *regs, struct task_struct *fpt);
119 120
120#define cpu_relax() barrier() 121#define cpu_relax() barrier()
121extern void (*sparc_idle)(void); 122extern void (*sparc_idle)(void);
diff --git a/arch/sparc/include/asm/processor_64.h b/arch/sparc/include/asm/processor_64.h
index 4c3f7f01c709..7028fe1a7c04 100644
--- a/arch/sparc/include/asm/processor_64.h
+++ b/arch/sparc/include/asm/processor_64.h
@@ -95,7 +95,7 @@ struct thread_struct {
95 95
96/* Return saved PC of a blocked thread. */ 96/* Return saved PC of a blocked thread. */
97struct task_struct; 97struct task_struct;
98extern unsigned long thread_saved_pc(struct task_struct *); 98unsigned long thread_saved_pc(struct task_struct *);
99 99
100/* On Uniprocessor, even in RMO processes see TSO semantics */ 100/* On Uniprocessor, even in RMO processes see TSO semantics */
101#ifdef CONFIG_SMP 101#ifdef CONFIG_SMP
@@ -194,7 +194,7 @@ do { \
194/* Free all resources held by a thread. */ 194/* Free all resources held by a thread. */
195#define release_thread(tsk) do { } while (0) 195#define release_thread(tsk) do { } while (0)
196 196
197extern unsigned long get_wchan(struct task_struct *task); 197unsigned long get_wchan(struct task_struct *task);
198 198
199#define task_pt_regs(tsk) (task_thread_info(tsk)->kregs) 199#define task_pt_regs(tsk) (task_thread_info(tsk)->kregs)
200#define KSTK_EIP(tsk) (task_pt_regs(tsk)->tpc) 200#define KSTK_EIP(tsk) (task_pt_regs(tsk)->tpc)
@@ -253,6 +253,8 @@ static inline void prefetchw(const void *x)
253 253
254#define HAVE_ARCH_PICK_MMAP_LAYOUT 254#define HAVE_ARCH_PICK_MMAP_LAYOUT
255 255
256int do_mathemu(struct pt_regs *regs, struct fpustate *f, bool illegal_insn_trap);
257
256#endif /* !(__ASSEMBLY__) */ 258#endif /* !(__ASSEMBLY__) */
257 259
258#endif /* !(__ASM_SPARC64_PROCESSOR_H) */ 260#endif /* !(__ASM_SPARC64_PROCESSOR_H) */
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index 11ebd659e7b6..d955c8df62d6 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -36,28 +36,28 @@ struct of_irq_controller {
36 void *data; 36 void *data;
37}; 37};
38 38
39extern struct device_node *of_find_node_by_cpuid(int cpuid); 39struct device_node *of_find_node_by_cpuid(int cpuid);
40extern int of_set_property(struct device_node *node, const char *name, void *val, int len); 40int of_set_property(struct device_node *node, const char *name, void *val, int len);
41extern struct mutex of_set_property_mutex; 41extern struct mutex of_set_property_mutex;
42extern int of_getintprop_default(struct device_node *np, 42int of_getintprop_default(struct device_node *np,
43 const char *name, 43 const char *name,
44 int def); 44 int def);
45extern int of_find_in_proplist(const char *list, const char *match, int len); 45int of_find_in_proplist(const char *list, const char *match, int len);
46 46
47extern void prom_build_devicetree(void); 47void prom_build_devicetree(void);
48extern void of_populate_present_mask(void); 48void of_populate_present_mask(void);
49extern void of_fill_in_cpu_data(void); 49void of_fill_in_cpu_data(void);
50 50
51struct resource; 51struct resource;
52extern void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name); 52void __iomem *of_ioremap(struct resource *res, unsigned long offset, unsigned long size, char *name);
53extern void of_iounmap(struct resource *res, void __iomem *base, unsigned long size); 53void of_iounmap(struct resource *res, void __iomem *base, unsigned long size);
54 54
55extern struct device_node *of_console_device; 55extern struct device_node *of_console_device;
56extern char *of_console_path; 56extern char *of_console_path;
57extern char *of_console_options; 57extern char *of_console_options;
58 58
59extern void irq_trans_init(struct device_node *dp); 59void irq_trans_init(struct device_node *dp);
60extern char *build_path_component(struct device_node *dp); 60char *build_path_component(struct device_node *dp);
61 61
62#endif /* __KERNEL__ */ 62#endif /* __KERNEL__ */
63#endif /* _SPARC_PROM_H */ 63#endif /* _SPARC_PROM_H */
diff --git a/arch/sparc/include/asm/ptrace.h b/arch/sparc/include/asm/ptrace.h
index bdfafd7af46f..bac6a946ee00 100644
--- a/arch/sparc/include/asm/ptrace.h
+++ b/arch/sparc/include/asm/ptrace.h
@@ -73,7 +73,7 @@ static inline long regs_return_value(struct pt_regs *regs)
73 return regs->u_regs[UREG_I0]; 73 return regs->u_regs[UREG_I0];
74} 74}
75#ifdef CONFIG_SMP 75#ifdef CONFIG_SMP
76extern unsigned long profile_pc(struct pt_regs *); 76unsigned long profile_pc(struct pt_regs *);
77#else 77#else
78#define profile_pc(regs) instruction_pointer(regs) 78#define profile_pc(regs) instruction_pointer(regs)
79#endif 79#endif
diff --git a/arch/sparc/include/asm/setup.h b/arch/sparc/include/asm/setup.h
index 5e35e0517318..f5fffd84d0dd 100644
--- a/arch/sparc/include/asm/setup.h
+++ b/arch/sparc/include/asm/setup.h
@@ -4,8 +4,9 @@
4#ifndef _SPARC_SETUP_H 4#ifndef _SPARC_SETUP_H
5#define _SPARC_SETUP_H 5#define _SPARC_SETUP_H
6 6
7#include <uapi/asm/setup.h> 7#include <linux/interrupt.h>
8 8
9#include <uapi/asm/setup.h>
9 10
10extern char reboot_command[]; 11extern char reboot_command[];
11 12
@@ -22,9 +23,43 @@ static inline int con_is_present(void)
22{ 23{
23 return serial_console ? 0 : 1; 24 return serial_console ? 0 : 1;
24} 25}
26
27/* from irq_32.c */
28extern volatile unsigned char *fdc_status;
29extern char *pdma_vaddr;
30extern unsigned long pdma_size;
31extern volatile int doing_pdma;
32
33/* This is software state */
34extern char *pdma_base;
35extern unsigned long pdma_areasize;
36
37int sparc_floppy_request_irq(unsigned int irq, irq_handler_t irq_handler);
38
39/* setup_32.c */
40extern unsigned long cmdline_memory_size;
41
42/* devices.c */
43void __init device_scan(void);
44
45/* unaligned_32.c */
46unsigned long safe_compute_effective_address(struct pt_regs *, unsigned int);
47
48#endif
49
50#ifdef CONFIG_SPARC64
51/* unaligned_64.c */
52int handle_ldf_stq(u32 insn, struct pt_regs *regs);
53void handle_ld_nf(u32 insn, struct pt_regs *regs);
54
55/* init_64.c */
56extern atomic_t dcpage_flushes;
57extern atomic_t dcpage_flushes_xcall;
58
59extern int sysctl_tsb_ratio;
25#endif 60#endif
26 61
27extern void sun_do_break(void); 62void sun_do_break(void);
28extern int stop_a_enabled; 63extern int stop_a_enabled;
29extern int scons_pwroff; 64extern int scons_pwroff;
30 65
diff --git a/arch/sparc/include/asm/sfp-machine_32.h b/arch/sparc/include/asm/sfp-machine_32.h
index 01d9c3b5a73b..838c9d58f3b4 100644
--- a/arch/sparc/include/asm/sfp-machine_32.h
+++ b/arch/sparc/include/asm/sfp-machine_32.h
@@ -79,9 +79,9 @@
79 __asm__ ("addcc %r7,%8,%2\n\t" \ 79 __asm__ ("addcc %r7,%8,%2\n\t" \
80 "addxcc %r5,%6,%1\n\t" \ 80 "addxcc %r5,%6,%1\n\t" \
81 "addx %r3,%4,%0\n" \ 81 "addx %r3,%4,%0\n" \
82 : "=r" ((USItype)(r2)), \ 82 : "=r" (r2), \
83 "=&r" ((USItype)(r1)), \ 83 "=&r" (r1), \
84 "=&r" ((USItype)(r0)) \ 84 "=&r" (r0) \
85 : "%rJ" ((USItype)(x2)), \ 85 : "%rJ" ((USItype)(x2)), \
86 "rI" ((USItype)(y2)), \ 86 "rI" ((USItype)(y2)), \
87 "%rJ" ((USItype)(x1)), \ 87 "%rJ" ((USItype)(x1)), \
@@ -94,9 +94,9 @@
94 __asm__ ("subcc %r7,%8,%2\n\t" \ 94 __asm__ ("subcc %r7,%8,%2\n\t" \
95 "subxcc %r5,%6,%1\n\t" \ 95 "subxcc %r5,%6,%1\n\t" \
96 "subx %r3,%4,%0\n" \ 96 "subx %r3,%4,%0\n" \
97 : "=r" ((USItype)(r2)), \ 97 : "=r" (r2), \
98 "=&r" ((USItype)(r1)), \ 98 "=&r" (r1), \
99 "=&r" ((USItype)(r0)) \ 99 "=&r" (r0) \
100 : "%rJ" ((USItype)(x2)), \ 100 : "%rJ" ((USItype)(x2)), \
101 "rI" ((USItype)(y2)), \ 101 "rI" ((USItype)(y2)), \
102 "%rJ" ((USItype)(x1)), \ 102 "%rJ" ((USItype)(x1)), \
@@ -115,8 +115,8 @@
115 "addxcc %r6,%7,%0\n\t" \ 115 "addxcc %r6,%7,%0\n\t" \
116 "addxcc %r4,%5,%%g2\n\t" \ 116 "addxcc %r4,%5,%%g2\n\t" \
117 "addx %r2,%3,%%g1\n\t" \ 117 "addx %r2,%3,%%g1\n\t" \
118 : "=&r" ((USItype)(r1)), \ 118 : "=&r" (r1), \
119 "=&r" ((USItype)(r0)) \ 119 "=&r" (r0) \
120 : "%rJ" ((USItype)(x3)), \ 120 : "%rJ" ((USItype)(x3)), \
121 "rI" ((USItype)(y3)), \ 121 "rI" ((USItype)(y3)), \
122 "%rJ" ((USItype)(x2)), \ 122 "%rJ" ((USItype)(x2)), \
@@ -140,8 +140,8 @@
140 "subxcc %r6,%7,%0\n\t" \ 140 "subxcc %r6,%7,%0\n\t" \
141 "subxcc %r4,%5,%%g2\n\t" \ 141 "subxcc %r4,%5,%%g2\n\t" \
142 "subx %r2,%3,%%g1\n\t" \ 142 "subx %r2,%3,%%g1\n\t" \
143 : "=&r" ((USItype)(r1)), \ 143 : "=&r" (r1), \
144 "=&r" ((USItype)(r0)) \ 144 "=&r" (r0) \
145 : "%rJ" ((USItype)(x3)), \ 145 : "%rJ" ((USItype)(x3)), \
146 "rI" ((USItype)(y3)), \ 146 "rI" ((USItype)(y3)), \
147 "%rJ" ((USItype)(x2)), \ 147 "%rJ" ((USItype)(x2)), \
@@ -164,10 +164,10 @@
164 "addxcc %2,%%g0,%2\n\t" \ 164 "addxcc %2,%%g0,%2\n\t" \
165 "addxcc %1,%%g0,%1\n\t" \ 165 "addxcc %1,%%g0,%1\n\t" \
166 "addx %0,%%g0,%0\n\t" \ 166 "addx %0,%%g0,%0\n\t" \
167 : "=&r" ((USItype)(x3)), \ 167 : "=&r" (x3), \
168 "=&r" ((USItype)(x2)), \ 168 "=&r" (x2), \
169 "=&r" ((USItype)(x1)), \ 169 "=&r" (x1), \
170 "=&r" ((USItype)(x0)) \ 170 "=&r" (x0) \
171 : "rI" ((USItype)(i)), \ 171 : "rI" ((USItype)(i)), \
172 "0" ((USItype)(x3)), \ 172 "0" ((USItype)(x3)), \
173 "1" ((USItype)(x2)), \ 173 "1" ((USItype)(x2)), \
diff --git a/arch/sparc/include/asm/smp_32.h b/arch/sparc/include/asm/smp_32.h
index 3c8917f054de..7c24e08a88d2 100644
--- a/arch/sparc/include/asm/smp_32.h
+++ b/arch/sparc/include/asm/smp_32.h
@@ -93,15 +93,15 @@ static inline void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
93 arg1, arg2, arg3, arg4); 93 arg1, arg2, arg3, arg4);
94} 94}
95 95
96extern void arch_send_call_function_single_ipi(int cpu); 96void arch_send_call_function_single_ipi(int cpu);
97extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); 97void arch_send_call_function_ipi_mask(const struct cpumask *mask);
98 98
99static inline int cpu_logical_map(int cpu) 99static inline int cpu_logical_map(int cpu)
100{ 100{
101 return cpu; 101 return cpu;
102} 102}
103 103
104extern int hard_smp_processor_id(void); 104int hard_smp_processor_id(void);
105 105
106#define raw_smp_processor_id() (current_thread_info()->cpu) 106#define raw_smp_processor_id() (current_thread_info()->cpu)
107 107
diff --git a/arch/sparc/include/asm/smp_64.h b/arch/sparc/include/asm/smp_64.h
index 05710393959f..26d9e7726867 100644
--- a/arch/sparc/include/asm/smp_64.h
+++ b/arch/sparc/include/asm/smp_64.h
@@ -33,29 +33,35 @@
33DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 33DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
34extern cpumask_t cpu_core_map[NR_CPUS]; 34extern cpumask_t cpu_core_map[NR_CPUS];
35 35
36extern void arch_send_call_function_single_ipi(int cpu); 36void arch_send_call_function_single_ipi(int cpu);
37extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); 37void arch_send_call_function_ipi_mask(const struct cpumask *mask);
38 38
39/* 39/*
40 * General functions that each host system must provide. 40 * General functions that each host system must provide.
41 */ 41 */
42 42
43extern int hard_smp_processor_id(void); 43int hard_smp_processor_id(void);
44#define raw_smp_processor_id() (current_thread_info()->cpu) 44#define raw_smp_processor_id() (current_thread_info()->cpu)
45 45
46extern void smp_fill_in_sib_core_maps(void); 46void smp_fill_in_sib_core_maps(void);
47extern void cpu_play_dead(void); 47void cpu_play_dead(void);
48 48
49extern void smp_fetch_global_regs(void); 49void smp_fetch_global_regs(void);
50extern void smp_fetch_global_pmu(void); 50void smp_fetch_global_pmu(void);
51 51
52struct seq_file; 52struct seq_file;
53void smp_bogo(struct seq_file *); 53void smp_bogo(struct seq_file *);
54void smp_info(struct seq_file *); 54void smp_info(struct seq_file *);
55 55
56void smp_callin(void);
57void cpu_panic(void);
58void smp_synchronize_tick_client(void);
59void smp_capture(void);
60void smp_release(void);
61
56#ifdef CONFIG_HOTPLUG_CPU 62#ifdef CONFIG_HOTPLUG_CPU
57extern int __cpu_disable(void); 63int __cpu_disable(void);
58extern void __cpu_die(unsigned int cpu); 64void __cpu_die(unsigned int cpu);
59#endif 65#endif
60 66
61#endif /* !(__ASSEMBLY__) */ 67#endif /* !(__ASSEMBLY__) */
diff --git a/arch/sparc/include/asm/spitfire.h b/arch/sparc/include/asm/spitfire.h
index 6b67e50fb9b4..3fc58691dbd0 100644
--- a/arch/sparc/include/asm/spitfire.h
+++ b/arch/sparc/include/asm/spitfire.h
@@ -62,7 +62,7 @@ extern enum ultra_tlb_layout tlb_type;
62extern int sun4v_chip_type; 62extern int sun4v_chip_type;
63 63
64extern int cheetah_pcache_forced_on; 64extern int cheetah_pcache_forced_on;
65extern void cheetah_enable_pcache(void); 65void cheetah_enable_pcache(void);
66 66
67#define sparc64_highest_locked_tlbent() \ 67#define sparc64_highest_locked_tlbent() \
68 (tlb_type == spitfire ? \ 68 (tlb_type == spitfire ? \
diff --git a/arch/sparc/include/asm/stacktrace.h b/arch/sparc/include/asm/stacktrace.h
index 6cee39adf6d6..c30d066f3048 100644
--- a/arch/sparc/include/asm/stacktrace.h
+++ b/arch/sparc/include/asm/stacktrace.h
@@ -1,6 +1,6 @@
1#ifndef _SPARC64_STACKTRACE_H 1#ifndef _SPARC64_STACKTRACE_H
2#define _SPARC64_STACKTRACE_H 2#define _SPARC64_STACKTRACE_H
3 3
4extern void stack_trace_flush(void); 4void stack_trace_flush(void);
5 5
6#endif /* _SPARC64_STACKTRACE_H */ 6#endif /* _SPARC64_STACKTRACE_H */
diff --git a/arch/sparc/include/asm/starfire.h b/arch/sparc/include/asm/starfire.h
index d56ce60a5992..c100dc27a0a9 100644
--- a/arch/sparc/include/asm/starfire.h
+++ b/arch/sparc/include/asm/starfire.h
@@ -11,10 +11,10 @@
11 11
12extern int this_is_starfire; 12extern int this_is_starfire;
13 13
14extern void check_if_starfire(void); 14void check_if_starfire(void);
15extern int starfire_hard_smp_processor_id(void); 15int starfire_hard_smp_processor_id(void);
16extern void starfire_hookup(int); 16void starfire_hookup(int);
17extern unsigned int starfire_translate(unsigned long imap, unsigned int upaid); 17unsigned int starfire_translate(unsigned long imap, unsigned int upaid);
18 18
19#endif 19#endif
20#endif 20#endif
diff --git a/arch/sparc/include/asm/string_32.h b/arch/sparc/include/asm/string_32.h
index 12f67857152e..69974e924611 100644
--- a/arch/sparc/include/asm/string_32.h
+++ b/arch/sparc/include/asm/string_32.h
@@ -15,7 +15,7 @@
15 15
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17 17
18extern void __memmove(void *,const void *,__kernel_size_t); 18void __memmove(void *,const void *,__kernel_size_t);
19 19
20#ifndef EXPORT_SYMTAB_STROPS 20#ifndef EXPORT_SYMTAB_STROPS
21 21
@@ -40,8 +40,8 @@ extern void __memmove(void *,const void *,__kernel_size_t);
40#undef memscan 40#undef memscan
41#define memscan(__arg0, __char, __arg2) \ 41#define memscan(__arg0, __char, __arg2) \
42({ \ 42({ \
43 extern void *__memscan_zero(void *, size_t); \ 43 void *__memscan_zero(void *, size_t); \
44 extern void *__memscan_generic(void *, int, size_t); \ 44 void *__memscan_generic(void *, int, size_t); \
45 void *__retval, *__addr = (__arg0); \ 45 void *__retval, *__addr = (__arg0); \
46 size_t __size = (__arg2); \ 46 size_t __size = (__arg2); \
47 \ 47 \
@@ -54,14 +54,14 @@ extern void __memmove(void *,const void *,__kernel_size_t);
54}) 54})
55 55
56#define __HAVE_ARCH_MEMCMP 56#define __HAVE_ARCH_MEMCMP
57extern int memcmp(const void *,const void *,__kernel_size_t); 57int memcmp(const void *,const void *,__kernel_size_t);
58 58
59/* Now the str*() stuff... */ 59/* Now the str*() stuff... */
60#define __HAVE_ARCH_STRLEN 60#define __HAVE_ARCH_STRLEN
61extern __kernel_size_t strlen(const char *); 61__kernel_size_t strlen(const char *);
62 62
63#define __HAVE_ARCH_STRNCMP 63#define __HAVE_ARCH_STRNCMP
64extern int strncmp(const char *, const char *, __kernel_size_t); 64int strncmp(const char *, const char *, __kernel_size_t);
65 65
66#endif /* !EXPORT_SYMTAB_STROPS */ 66#endif /* !EXPORT_SYMTAB_STROPS */
67 67
diff --git a/arch/sparc/include/asm/string_64.h b/arch/sparc/include/asm/string_64.h
index 9623bc213158..5936b8ff3c05 100644
--- a/arch/sparc/include/asm/string_64.h
+++ b/arch/sparc/include/asm/string_64.h
@@ -19,7 +19,7 @@
19 19
20/* First the mem*() things. */ 20/* First the mem*() things. */
21#define __HAVE_ARCH_MEMMOVE 21#define __HAVE_ARCH_MEMMOVE
22extern void *memmove(void *, const void *, __kernel_size_t); 22void *memmove(void *, const void *, __kernel_size_t);
23 23
24#define __HAVE_ARCH_MEMCPY 24#define __HAVE_ARCH_MEMCPY
25#define memcpy(t, f, n) __builtin_memcpy(t, f, n) 25#define memcpy(t, f, n) __builtin_memcpy(t, f, n)
@@ -32,8 +32,8 @@ extern void *memmove(void *, const void *, __kernel_size_t);
32#undef memscan 32#undef memscan
33#define memscan(__arg0, __char, __arg2) \ 33#define memscan(__arg0, __char, __arg2) \
34({ \ 34({ \
35 extern void *__memscan_zero(void *, size_t); \ 35 void *__memscan_zero(void *, size_t); \
36 extern void *__memscan_generic(void *, int, size_t); \ 36 void *__memscan_generic(void *, int, size_t); \
37 void *__retval, *__addr = (__arg0); \ 37 void *__retval, *__addr = (__arg0); \
38 size_t __size = (__arg2); \ 38 size_t __size = (__arg2); \
39 \ 39 \
@@ -46,14 +46,14 @@ extern void *memmove(void *, const void *, __kernel_size_t);
46}) 46})
47 47
48#define __HAVE_ARCH_MEMCMP 48#define __HAVE_ARCH_MEMCMP
49extern int memcmp(const void *,const void *,__kernel_size_t); 49int memcmp(const void *,const void *,__kernel_size_t);
50 50
51/* Now the str*() stuff... */ 51/* Now the str*() stuff... */
52#define __HAVE_ARCH_STRLEN 52#define __HAVE_ARCH_STRLEN
53extern __kernel_size_t strlen(const char *); 53__kernel_size_t strlen(const char *);
54 54
55#define __HAVE_ARCH_STRNCMP 55#define __HAVE_ARCH_STRNCMP
56extern int strncmp(const char *, const char *, __kernel_size_t); 56int strncmp(const char *, const char *, __kernel_size_t);
57 57
58#endif /* !EXPORT_SYMTAB_STROPS */ 58#endif /* !EXPORT_SYMTAB_STROPS */
59 59
diff --git a/arch/sparc/include/asm/switch_to_32.h b/arch/sparc/include/asm/switch_to_32.h
index e32e82b76eed..16f10374feb3 100644
--- a/arch/sparc/include/asm/switch_to_32.h
+++ b/arch/sparc/include/asm/switch_to_32.h
@@ -99,8 +99,8 @@ extern struct thread_info *current_set[NR_CPUS];
99 "o0", "o1", "o2", "o3", "o7"); \ 99 "o0", "o1", "o2", "o3", "o7"); \
100 } while(0) 100 } while(0)
101 101
102extern void fpsave(unsigned long *fpregs, unsigned long *fsr, 102void fpsave(unsigned long *fpregs, unsigned long *fsr,
103 void *fpqueue, unsigned long *fpqdepth); 103 void *fpqueue, unsigned long *fpqdepth);
104extern void synchronize_user_stack(void); 104void synchronize_user_stack(void);
105 105
106#endif /* __SPARC_SWITCH_TO_H */ 106#endif /* __SPARC_SWITCH_TO_H */
diff --git a/arch/sparc/include/asm/switch_to_64.h b/arch/sparc/include/asm/switch_to_64.h
index 8d284801f232..10e76332dc99 100644
--- a/arch/sparc/include/asm/switch_to_64.h
+++ b/arch/sparc/include/asm/switch_to_64.h
@@ -65,7 +65,7 @@ do { save_and_clear_fpu(); \
65 "o0", "o1", "o2", "o3", "o4", "o5", "o7"); \ 65 "o0", "o1", "o2", "o3", "o4", "o5", "o7"); \
66} while(0) 66} while(0)
67 67
68extern void synchronize_user_stack(void); 68void synchronize_user_stack(void);
69extern void fault_in_user_windows(void); 69void fault_in_user_windows(void);
70 70
71#endif /* __SPARC64_SWITCH_TO_64_H */ 71#endif /* __SPARC64_SWITCH_TO_64_H */
diff --git a/arch/sparc/include/asm/syscalls.h b/arch/sparc/include/asm/syscalls.h
index bf8972adea17..b0a0db8ea61a 100644
--- a/arch/sparc/include/asm/syscalls.h
+++ b/arch/sparc/include/asm/syscalls.h
@@ -3,9 +3,9 @@
3 3
4struct pt_regs; 4struct pt_regs;
5 5
6extern asmlinkage long sparc_do_fork(unsigned long clone_flags, 6asmlinkage long sparc_do_fork(unsigned long clone_flags,
7 unsigned long stack_start, 7 unsigned long stack_start,
8 struct pt_regs *regs, 8 struct pt_regs *regs,
9 unsigned long stack_size); 9 unsigned long stack_size);
10 10
11#endif /* _SPARC64_SYSCALLS_H */ 11#endif /* _SPARC64_SYSCALLS_H */
diff --git a/arch/sparc/include/asm/timer_32.h b/arch/sparc/include/asm/timer_32.h
index 72f40a546de3..f8e708a0aa58 100644
--- a/arch/sparc/include/asm/timer_32.h
+++ b/arch/sparc/include/asm/timer_32.h
@@ -32,13 +32,13 @@ static inline unsigned int timer_value(unsigned int value)
32 return (value + 1) << TIMER_VALUE_SHIFT; 32 return (value + 1) << TIMER_VALUE_SHIFT;
33} 33}
34 34
35extern __volatile__ unsigned int *master_l10_counter; 35extern volatile u32 __iomem *master_l10_counter;
36 36
37extern irqreturn_t notrace timer_interrupt(int dummy, void *dev_id); 37irqreturn_t notrace timer_interrupt(int dummy, void *dev_id);
38 38
39#ifdef CONFIG_SMP 39#ifdef CONFIG_SMP
40DECLARE_PER_CPU(struct clock_event_device, sparc32_clockevent); 40DECLARE_PER_CPU(struct clock_event_device, sparc32_clockevent);
41extern void register_percpu_ce(int cpu); 41void register_percpu_ce(int cpu);
42#endif 42#endif
43 43
44#endif /* !(_SPARC_TIMER_H) */ 44#endif /* !(_SPARC_TIMER_H) */
diff --git a/arch/sparc/include/asm/timer_64.h b/arch/sparc/include/asm/timer_64.h
index 01197d8215c4..fce415034000 100644
--- a/arch/sparc/include/asm/timer_64.h
+++ b/arch/sparc/include/asm/timer_64.h
@@ -23,8 +23,8 @@ struct sparc64_tick_ops {
23 23
24extern struct sparc64_tick_ops *tick_ops; 24extern struct sparc64_tick_ops *tick_ops;
25 25
26extern unsigned long sparc64_get_clock_tick(unsigned int cpu); 26unsigned long sparc64_get_clock_tick(unsigned int cpu);
27extern void setup_sparc64_timer(void); 27void setup_sparc64_timer(void);
28extern void __init time_init(void); 28void __init time_init(void);
29 29
30#endif /* _SPARC64_TIMER_H */ 30#endif /* _SPARC64_TIMER_H */
diff --git a/arch/sparc/include/asm/tlb_64.h b/arch/sparc/include/asm/tlb_64.h
index 190e18913cc6..4cb392f75d2b 100644
--- a/arch/sparc/include/asm/tlb_64.h
+++ b/arch/sparc/include/asm/tlb_64.h
@@ -8,19 +8,19 @@
8#include <asm/mmu_context.h> 8#include <asm/mmu_context.h>
9 9
10#ifdef CONFIG_SMP 10#ifdef CONFIG_SMP
11extern void smp_flush_tlb_pending(struct mm_struct *, 11void smp_flush_tlb_pending(struct mm_struct *,
12 unsigned long, unsigned long *); 12 unsigned long, unsigned long *);
13#endif 13#endif
14 14
15#ifdef CONFIG_SMP 15#ifdef CONFIG_SMP
16extern void smp_flush_tlb_mm(struct mm_struct *mm); 16void smp_flush_tlb_mm(struct mm_struct *mm);
17#define do_flush_tlb_mm(mm) smp_flush_tlb_mm(mm) 17#define do_flush_tlb_mm(mm) smp_flush_tlb_mm(mm)
18#else 18#else
19#define do_flush_tlb_mm(mm) __flush_tlb_mm(CTX_HWBITS(mm->context), SECONDARY_CONTEXT) 19#define do_flush_tlb_mm(mm) __flush_tlb_mm(CTX_HWBITS(mm->context), SECONDARY_CONTEXT)
20#endif 20#endif
21 21
22extern void __flush_tlb_pending(unsigned long, unsigned long, unsigned long *); 22void __flush_tlb_pending(unsigned long, unsigned long, unsigned long *);
23extern void flush_tlb_pending(void); 23void flush_tlb_pending(void);
24 24
25#define tlb_start_vma(tlb, vma) do { } while (0) 25#define tlb_start_vma(tlb, vma) do { } while (0)
26#define tlb_end_vma(tlb, vma) do { } while (0) 26#define tlb_end_vma(tlb, vma) do { } while (0)
diff --git a/arch/sparc/include/asm/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h
index 3c3c89f52643..816d8202fa0a 100644
--- a/arch/sparc/include/asm/tlbflush_64.h
+++ b/arch/sparc/include/asm/tlbflush_64.h
@@ -14,9 +14,9 @@ struct tlb_batch {
14 unsigned long vaddrs[TLB_BATCH_NR]; 14 unsigned long vaddrs[TLB_BATCH_NR];
15}; 15};
16 16
17extern void flush_tsb_kernel_range(unsigned long start, unsigned long end); 17void flush_tsb_kernel_range(unsigned long start, unsigned long end);
18extern void flush_tsb_user(struct tlb_batch *tb); 18void flush_tsb_user(struct tlb_batch *tb);
19extern void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr); 19void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr);
20 20
21/* TLB flush operations. */ 21/* TLB flush operations. */
22 22
@@ -36,15 +36,15 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
36 36
37#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE 37#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
38 38
39extern void flush_tlb_pending(void); 39void flush_tlb_pending(void);
40extern void arch_enter_lazy_mmu_mode(void); 40void arch_enter_lazy_mmu_mode(void);
41extern void arch_leave_lazy_mmu_mode(void); 41void arch_leave_lazy_mmu_mode(void);
42#define arch_flush_lazy_mmu_mode() do {} while (0) 42#define arch_flush_lazy_mmu_mode() do {} while (0)
43 43
44/* Local cpu only. */ 44/* Local cpu only. */
45extern void __flush_tlb_all(void); 45void __flush_tlb_all(void);
46extern void __flush_tlb_page(unsigned long context, unsigned long vaddr); 46void __flush_tlb_page(unsigned long context, unsigned long vaddr);
47extern void __flush_tlb_kernel_range(unsigned long start, unsigned long end); 47void __flush_tlb_kernel_range(unsigned long start, unsigned long end);
48 48
49#ifndef CONFIG_SMP 49#ifndef CONFIG_SMP
50 50
@@ -60,8 +60,8 @@ static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vad
60 60
61#else /* CONFIG_SMP */ 61#else /* CONFIG_SMP */
62 62
63extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end); 63void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
64extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr); 64void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr);
65 65
66#define flush_tlb_kernel_range(start, end) \ 66#define flush_tlb_kernel_range(start, end) \
67do { flush_tsb_kernel_range(start,end); \ 67do { flush_tsb_kernel_range(start,end); \
diff --git a/arch/sparc/include/asm/topology_64.h b/arch/sparc/include/asm/topology_64.h
index a2d10fc64faf..ed8f071132e4 100644
--- a/arch/sparc/include/asm/topology_64.h
+++ b/arch/sparc/include/asm/topology_64.h
@@ -18,7 +18,7 @@ static inline int cpu_to_node(int cpu)
18 18
19struct pci_bus; 19struct pci_bus;
20#ifdef CONFIG_PCI 20#ifdef CONFIG_PCI
21extern int pcibus_to_node(struct pci_bus *pbus); 21int pcibus_to_node(struct pci_bus *pbus);
22#else 22#else
23static inline int pcibus_to_node(struct pci_bus *pbus) 23static inline int pcibus_to_node(struct pci_bus *pbus)
24{ 24{
diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h
index 7e26b2db6211..6fd4436d32f0 100644
--- a/arch/sparc/include/asm/trap_block.h
+++ b/arch/sparc/include/asm/trap_block.h
@@ -51,11 +51,11 @@ struct trap_per_cpu {
51 unsigned long __per_cpu_base; 51 unsigned long __per_cpu_base;
52} __attribute__((aligned(64))); 52} __attribute__((aligned(64)));
53extern struct trap_per_cpu trap_block[NR_CPUS]; 53extern struct trap_per_cpu trap_block[NR_CPUS];
54extern void init_cur_cpu_trap(struct thread_info *); 54void init_cur_cpu_trap(struct thread_info *);
55extern void setup_tba(void); 55void setup_tba(void);
56extern int ncpus_probed; 56extern int ncpus_probed;
57 57
58extern unsigned long real_hard_smp_processor_id(void); 58unsigned long real_hard_smp_processor_id(void);
59 59
60struct cpuid_patch_entry { 60struct cpuid_patch_entry {
61 unsigned int addr; 61 unsigned int addr;
diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
index 0167d26d0d1d..bd56c28fff9f 100644
--- a/arch/sparc/include/asm/uaccess.h
+++ b/arch/sparc/include/asm/uaccess.h
@@ -9,6 +9,6 @@
9#define user_addr_max() \ 9#define user_addr_max() \
10 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL) 10 (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL)
11 11
12extern long strncpy_from_user(char *dest, const char __user *src, long count); 12long strncpy_from_user(char *dest, const char __user *src, long count);
13 13
14#endif 14#endif
diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 53a28dd59f59..9634d086fc56 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -78,9 +78,9 @@ struct exception_table_entry
78}; 78};
79 79
80/* Returns 0 if exception not found and fixup otherwise. */ 80/* Returns 0 if exception not found and fixup otherwise. */
81extern unsigned long search_extables_range(unsigned long addr, unsigned long *g2); 81unsigned long search_extables_range(unsigned long addr, unsigned long *g2);
82 82
83extern void __ret_efault(void); 83void __ret_efault(void);
84 84
85/* Uh, these should become the main single-value transfer routines.. 85/* Uh, these should become the main single-value transfer routines..
86 * They automatically use the right size if we just have the right 86 * They automatically use the right size if we just have the right
@@ -152,7 +152,7 @@ __asm__ __volatile__( \
152 : "=&r" (ret) : "r" (x), "m" (*__m(addr)), \ 152 : "=&r" (ret) : "r" (x), "m" (*__m(addr)), \
153 "i" (-EFAULT)) 153 "i" (-EFAULT))
154 154
155extern int __put_user_bad(void); 155int __put_user_bad(void);
156 156
157#define __get_user_check(x,addr,size,type) ({ \ 157#define __get_user_check(x,addr,size,type) ({ \
158register int __gu_ret; \ 158register int __gu_ret; \
@@ -244,9 +244,9 @@ __asm__ __volatile__( \
244 ".previous\n\t" \ 244 ".previous\n\t" \
245 : "=&r" (x) : "m" (*__m(addr)), "i" (retval)) 245 : "=&r" (x) : "m" (*__m(addr)), "i" (retval))
246 246
247extern int __get_user_bad(void); 247int __get_user_bad(void);
248 248
249extern unsigned long __copy_user(void __user *to, const void __user *from, unsigned long size); 249unsigned long __copy_user(void __user *to, const void __user *from, unsigned long size);
250 250
251static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n) 251static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
252{ 252{
@@ -306,8 +306,8 @@ static inline unsigned long clear_user(void __user *addr, unsigned long n)
306 return n; 306 return n;
307} 307}
308 308
309extern __must_check long strlen_user(const char __user *str); 309__must_check long strlen_user(const char __user *str);
310extern __must_check long strnlen_user(const char __user *str, long n); 310__must_check long strnlen_user(const char __user *str, long n);
311 311
312#endif /* __ASSEMBLY__ */ 312#endif /* __ASSEMBLY__ */
313 313
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index ad7e178337f1..c990a5e577f0 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -76,8 +76,8 @@ struct exception_table_entry {
76 unsigned int insn, fixup; 76 unsigned int insn, fixup;
77}; 77};
78 78
79extern void __ret_efault(void); 79void __ret_efault(void);
80extern void __retl_efault(void); 80void __retl_efault(void);
81 81
82/* Uh, these should become the main single-value transfer routines.. 82/* Uh, these should become the main single-value transfer routines..
83 * They automatically use the right size if we just have the right 83 * They automatically use the right size if we just have the right
@@ -134,7 +134,7 @@ __asm__ __volatile__( \
134 : "=r" (ret) : "r" (x), "r" (__m(addr)), \ 134 : "=r" (ret) : "r" (x), "r" (__m(addr)), \
135 "i" (-EFAULT)) 135 "i" (-EFAULT))
136 136
137extern int __put_user_bad(void); 137int __put_user_bad(void);
138 138
139#define __get_user_nocheck(data,addr,size,type) ({ \ 139#define __get_user_nocheck(data,addr,size,type) ({ \
140register int __gu_ret; \ 140register int __gu_ret; \
@@ -204,13 +204,13 @@ __asm__ __volatile__( \
204 ".previous\n\t" \ 204 ".previous\n\t" \
205 : "=r" (x) : "r" (__m(addr)), "i" (retval)) 205 : "=r" (x) : "r" (__m(addr)), "i" (retval))
206 206
207extern int __get_user_bad(void); 207int __get_user_bad(void);
208 208
209extern unsigned long __must_check ___copy_from_user(void *to, 209unsigned long __must_check ___copy_from_user(void *to,
210 const void __user *from, 210 const void __user *from,
211 unsigned long size); 211 unsigned long size);
212extern unsigned long copy_from_user_fixup(void *to, const void __user *from, 212unsigned long copy_from_user_fixup(void *to, const void __user *from,
213 unsigned long size); 213 unsigned long size);
214static inline unsigned long __must_check 214static inline unsigned long __must_check
215copy_from_user(void *to, const void __user *from, unsigned long size) 215copy_from_user(void *to, const void __user *from, unsigned long size)
216{ 216{
@@ -223,11 +223,11 @@ copy_from_user(void *to, const void __user *from, unsigned long size)
223} 223}
224#define __copy_from_user copy_from_user 224#define __copy_from_user copy_from_user
225 225
226extern unsigned long __must_check ___copy_to_user(void __user *to, 226unsigned long __must_check ___copy_to_user(void __user *to,
227 const void *from, 227 const void *from,
228 unsigned long size); 228 unsigned long size);
229extern unsigned long copy_to_user_fixup(void __user *to, const void *from, 229unsigned long copy_to_user_fixup(void __user *to, const void *from,
230 unsigned long size); 230 unsigned long size);
231static inline unsigned long __must_check 231static inline unsigned long __must_check
232copy_to_user(void __user *to, const void *from, unsigned long size) 232copy_to_user(void __user *to, const void *from, unsigned long size)
233{ 233{
@@ -239,11 +239,11 @@ copy_to_user(void __user *to, const void *from, unsigned long size)
239} 239}
240#define __copy_to_user copy_to_user 240#define __copy_to_user copy_to_user
241 241
242extern unsigned long __must_check ___copy_in_user(void __user *to, 242unsigned long __must_check ___copy_in_user(void __user *to,
243 const void __user *from, 243 const void __user *from,
244 unsigned long size); 244 unsigned long size);
245extern unsigned long copy_in_user_fixup(void __user *to, void __user *from, 245unsigned long copy_in_user_fixup(void __user *to, void __user *from,
246 unsigned long size); 246 unsigned long size);
247static inline unsigned long __must_check 247static inline unsigned long __must_check
248copy_in_user(void __user *to, void __user *from, unsigned long size) 248copy_in_user(void __user *to, void __user *from, unsigned long size)
249{ 249{
@@ -255,20 +255,20 @@ copy_in_user(void __user *to, void __user *from, unsigned long size)
255} 255}
256#define __copy_in_user copy_in_user 256#define __copy_in_user copy_in_user
257 257
258extern unsigned long __must_check __clear_user(void __user *, unsigned long); 258unsigned long __must_check __clear_user(void __user *, unsigned long);
259 259
260#define clear_user __clear_user 260#define clear_user __clear_user
261 261
262extern __must_check long strlen_user(const char __user *str); 262__must_check long strlen_user(const char __user *str);
263extern __must_check long strnlen_user(const char __user *str, long n); 263__must_check long strnlen_user(const char __user *str, long n);
264 264
265#define __copy_to_user_inatomic __copy_to_user 265#define __copy_to_user_inatomic __copy_to_user
266#define __copy_from_user_inatomic __copy_from_user 266#define __copy_from_user_inatomic __copy_from_user
267 267
268struct pt_regs; 268struct pt_regs;
269extern unsigned long compute_effective_address(struct pt_regs *, 269unsigned long compute_effective_address(struct pt_regs *,
270 unsigned int insn, 270 unsigned int insn,
271 unsigned int rd); 271 unsigned int rd);
272 272
273#endif /* __ASSEMBLY__ */ 273#endif /* __ASSEMBLY__ */
274 274
diff --git a/arch/sparc/include/asm/vio.h b/arch/sparc/include/asm/vio.h
index 432afa838861..e0f6c399f1d0 100644
--- a/arch/sparc/include/asm/vio.h
+++ b/arch/sparc/include/asm/vio.h
@@ -372,14 +372,14 @@ do { if (vio->debug & VIO_DEBUG_##TYPE) \
372 vio->vdev->channel_id, ## a); \ 372 vio->vdev->channel_id, ## a); \
373} while (0) 373} while (0)
374 374
375extern int __vio_register_driver(struct vio_driver *drv, struct module *owner, 375int __vio_register_driver(struct vio_driver *drv, struct module *owner,
376 const char *mod_name); 376 const char *mod_name);
377/* 377/*
378 * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded 378 * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded
379 */ 379 */
380#define vio_register_driver(driver) \ 380#define vio_register_driver(driver) \
381 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) 381 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
382extern void vio_unregister_driver(struct vio_driver *drv); 382void vio_unregister_driver(struct vio_driver *drv);
383 383
384static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 384static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
385{ 385{
@@ -391,21 +391,21 @@ static inline struct vio_dev *to_vio_dev(struct device *dev)
391 return container_of(dev, struct vio_dev, dev); 391 return container_of(dev, struct vio_dev, dev);
392} 392}
393 393
394extern int vio_ldc_send(struct vio_driver_state *vio, void *data, int len); 394int vio_ldc_send(struct vio_driver_state *vio, void *data, int len);
395extern void vio_link_state_change(struct vio_driver_state *vio, int event); 395void vio_link_state_change(struct vio_driver_state *vio, int event);
396extern void vio_conn_reset(struct vio_driver_state *vio); 396void vio_conn_reset(struct vio_driver_state *vio);
397extern int vio_control_pkt_engine(struct vio_driver_state *vio, void *pkt); 397int vio_control_pkt_engine(struct vio_driver_state *vio, void *pkt);
398extern int vio_validate_sid(struct vio_driver_state *vio, 398int vio_validate_sid(struct vio_driver_state *vio,
399 struct vio_msg_tag *tp); 399 struct vio_msg_tag *tp);
400extern u32 vio_send_sid(struct vio_driver_state *vio); 400u32 vio_send_sid(struct vio_driver_state *vio);
401extern int vio_ldc_alloc(struct vio_driver_state *vio, 401int vio_ldc_alloc(struct vio_driver_state *vio,
402 struct ldc_channel_config *base_cfg, void *event_arg); 402 struct ldc_channel_config *base_cfg, void *event_arg);
403extern void vio_ldc_free(struct vio_driver_state *vio); 403void vio_ldc_free(struct vio_driver_state *vio);
404extern int vio_driver_init(struct vio_driver_state *vio, struct vio_dev *vdev, 404int vio_driver_init(struct vio_driver_state *vio, struct vio_dev *vdev,
405 u8 dev_class, struct vio_version *ver_table, 405 u8 dev_class, struct vio_version *ver_table,
406 int ver_table_size, struct vio_driver_ops *ops, 406 int ver_table_size, struct vio_driver_ops *ops,
407 char *name); 407 char *name);
408 408
409extern void vio_port_up(struct vio_driver_state *vio); 409void vio_port_up(struct vio_driver_state *vio);
410 410
411#endif /* _SPARC64_VIO_H */ 411#endif /* _SPARC64_VIO_H */
diff --git a/arch/sparc/include/asm/visasm.h b/arch/sparc/include/asm/visasm.h
index 39ca301920db..b26673759283 100644
--- a/arch/sparc/include/asm/visasm.h
+++ b/arch/sparc/include/asm/visasm.h
@@ -57,7 +57,8 @@ static inline void save_and_clear_fpu(void) {
57" " : : "i" (FPRS_FEF|FPRS_DU) : 57" " : : "i" (FPRS_FEF|FPRS_DU) :
58 "o5", "g1", "g2", "g3", "g7", "cc"); 58 "o5", "g1", "g2", "g3", "g7", "cc");
59} 59}
60extern int vis_emul(struct pt_regs *, unsigned int); 60
61int vis_emul(struct pt_regs *, unsigned int);
61#endif 62#endif
62 63
63#endif /* _SPARC64_ASI_H */ 64#endif /* _SPARC64_ASI_H */
diff --git a/arch/sparc/include/asm/xor_64.h b/arch/sparc/include/asm/xor_64.h
index ee8edc68423e..50c882856031 100644
--- a/arch/sparc/include/asm/xor_64.h
+++ b/arch/sparc/include/asm/xor_64.h
@@ -20,13 +20,13 @@
20 20
21#include <asm/spitfire.h> 21#include <asm/spitfire.h>
22 22
23extern void xor_vis_2(unsigned long, unsigned long *, unsigned long *); 23void xor_vis_2(unsigned long, unsigned long *, unsigned long *);
24extern void xor_vis_3(unsigned long, unsigned long *, unsigned long *, 24void xor_vis_3(unsigned long, unsigned long *, unsigned long *,
25 unsigned long *); 25 unsigned long *);
26extern void xor_vis_4(unsigned long, unsigned long *, unsigned long *, 26void xor_vis_4(unsigned long, unsigned long *, unsigned long *,
27 unsigned long *, unsigned long *); 27 unsigned long *, unsigned long *);
28extern void xor_vis_5(unsigned long, unsigned long *, unsigned long *, 28void xor_vis_5(unsigned long, unsigned long *, unsigned long *,
29 unsigned long *, unsigned long *, unsigned long *); 29 unsigned long *, unsigned long *, unsigned long *);
30 30
31/* XXX Ugh, write cheetah versions... -DaveM */ 31/* XXX Ugh, write cheetah versions... -DaveM */
32 32
@@ -38,13 +38,13 @@ static struct xor_block_template xor_block_VIS = {
38 .do_5 = xor_vis_5, 38 .do_5 = xor_vis_5,
39}; 39};
40 40
41extern void xor_niagara_2(unsigned long, unsigned long *, unsigned long *); 41void xor_niagara_2(unsigned long, unsigned long *, unsigned long *);
42extern void xor_niagara_3(unsigned long, unsigned long *, unsigned long *, 42void xor_niagara_3(unsigned long, unsigned long *, unsigned long *,
43 unsigned long *); 43 unsigned long *);
44extern void xor_niagara_4(unsigned long, unsigned long *, unsigned long *, 44void xor_niagara_4(unsigned long, unsigned long *, unsigned long *,
45 unsigned long *, unsigned long *); 45 unsigned long *, unsigned long *);
46extern void xor_niagara_5(unsigned long, unsigned long *, unsigned long *, 46void xor_niagara_5(unsigned long, unsigned long *, unsigned long *,
47 unsigned long *, unsigned long *, unsigned long *); 47 unsigned long *, unsigned long *, unsigned long *);
48 48
49static struct xor_block_template xor_block_niagara = { 49static struct xor_block_template xor_block_niagara = {
50 .name = "Niagara", 50 .name = "Niagara",
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index d15cc1794b0e..7cf9c6ea3f1f 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -42,7 +42,6 @@ obj-y += time_$(BITS).o
42obj-$(CONFIG_SPARC32) += windows.o 42obj-$(CONFIG_SPARC32) += windows.o
43obj-y += cpu.o 43obj-y += cpu.o
44obj-$(CONFIG_SPARC32) += devices.o 44obj-$(CONFIG_SPARC32) += devices.o
45obj-$(CONFIG_SPARC32) += tadpole.o
46obj-y += ptrace_$(BITS).o 45obj-y += ptrace_$(BITS).o
47obj-y += unaligned_$(BITS).o 46obj-y += unaligned_$(BITS).o
48obj-y += una_asm_$(BITS).o 47obj-y += una_asm_$(BITS).o
diff --git a/arch/sparc/kernel/audit.c b/arch/sparc/kernel/audit.c
index 8fff0ac63d56..24361b494a93 100644
--- a/arch/sparc/kernel/audit.c
+++ b/arch/sparc/kernel/audit.c
@@ -3,6 +3,8 @@
3#include <linux/audit.h> 3#include <linux/audit.h>
4#include <asm/unistd.h> 4#include <asm/unistd.h>
5 5
6#include "kernel.h"
7
6static unsigned dir_class[] = { 8static unsigned dir_class[] = {
7#include <asm-generic/audit_dir_write.h> 9#include <asm-generic/audit_dir_write.h>
8~0U 10~0U
@@ -40,7 +42,6 @@ int audit_classify_arch(int arch)
40int audit_classify_syscall(int abi, unsigned syscall) 42int audit_classify_syscall(int abi, unsigned syscall)
41{ 43{
42#ifdef CONFIG_COMPAT 44#ifdef CONFIG_COMPAT
43 extern int sparc32_classify_syscall(unsigned);
44 if (abi == AUDIT_ARCH_SPARC) 45 if (abi == AUDIT_ARCH_SPARC)
45 return sparc32_classify_syscall(syscall); 46 return sparc32_classify_syscall(syscall);
46#endif 47#endif
@@ -61,11 +62,6 @@ int audit_classify_syscall(int abi, unsigned syscall)
61static int __init audit_classes_init(void) 62static int __init audit_classes_init(void)
62{ 63{
63#ifdef CONFIG_COMPAT 64#ifdef CONFIG_COMPAT
64 extern __u32 sparc32_dir_class[];
65 extern __u32 sparc32_write_class[];
66 extern __u32 sparc32_read_class[];
67 extern __u32 sparc32_chattr_class[];
68 extern __u32 sparc32_signal_class[];
69 audit_register_class(AUDIT_CLASS_WRITE_32, sparc32_write_class); 65 audit_register_class(AUDIT_CLASS_WRITE_32, sparc32_write_class);
70 audit_register_class(AUDIT_CLASS_READ_32, sparc32_read_class); 66 audit_register_class(AUDIT_CLASS_READ_32, sparc32_read_class);
71 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, sparc32_dir_class); 67 audit_register_class(AUDIT_CLASS_DIR_WRITE_32, sparc32_dir_class);
diff --git a/arch/sparc/kernel/auxio_32.c b/arch/sparc/kernel/auxio_32.c
index e20cc55fb768..ae88c223e4d3 100644
--- a/arch/sparc/kernel/auxio_32.c
+++ b/arch/sparc/kernel/auxio_32.c
@@ -9,12 +9,15 @@
9#include <linux/of.h> 9#include <linux/of.h>
10#include <linux/of_device.h> 10#include <linux/of_device.h>
11#include <linux/export.h> 11#include <linux/export.h>
12
12#include <asm/oplib.h> 13#include <asm/oplib.h>
13#include <asm/io.h> 14#include <asm/io.h>
14#include <asm/auxio.h> 15#include <asm/auxio.h>
15#include <asm/string.h> /* memset(), Linux has no bzero() */ 16#include <asm/string.h> /* memset(), Linux has no bzero() */
16#include <asm/cpu_type.h> 17#include <asm/cpu_type.h>
17 18
19#include "kernel.h"
20
18/* Probe and map in the Auxiliary I/O register */ 21/* Probe and map in the Auxiliary I/O register */
19 22
20/* auxio_register is not static because it is referenced 23/* auxio_register is not static because it is referenced
@@ -103,7 +106,7 @@ EXPORT_SYMBOL(set_auxio);
103 106
104/* sun4m power control register (AUXIO2) */ 107/* sun4m power control register (AUXIO2) */
105 108
106volatile unsigned char * auxio_power_register = NULL; 109volatile u8 __iomem *auxio_power_register = NULL;
107 110
108void __init auxio_power_probe(void) 111void __init auxio_power_probe(void)
109{ 112{
@@ -127,8 +130,8 @@ void __init auxio_power_probe(void)
127 r.flags = regs.which_io & 0xF; 130 r.flags = regs.which_io & 0xF;
128 r.start = regs.phys_addr; 131 r.start = regs.phys_addr;
129 r.end = regs.phys_addr + regs.reg_size - 1; 132 r.end = regs.phys_addr + regs.reg_size - 1;
130 auxio_power_register = (unsigned char *) of_ioremap(&r, 0, 133 auxio_power_register =
131 regs.reg_size, "auxpower"); 134 (u8 __iomem *)of_ioremap(&r, 0, regs.reg_size, "auxpower");
132 135
133 /* Display a quick message on the console. */ 136 /* Display a quick message on the console. */
134 if (auxio_power_register) 137 if (auxio_power_register)
diff --git a/arch/sparc/kernel/btext.c b/arch/sparc/kernel/btext.c
index 57073e56ba9e..987f7ec497cc 100644
--- a/arch/sparc/kernel/btext.c
+++ b/arch/sparc/kernel/btext.c
@@ -137,7 +137,7 @@ static void scrollscreen(void)
137} 137}
138#endif /* ndef NO_SCROLL */ 138#endif /* ndef NO_SCROLL */
139 139
140void btext_drawchar(char c) 140static void btext_drawchar(char c)
141{ 141{
142 int cline = 0; 142 int cline = 0;
143#ifdef NO_SCROLL 143#ifdef NO_SCROLL
diff --git a/arch/sparc/kernel/compat_audit.c b/arch/sparc/kernel/compat_audit.c
index d865575b25bf..7062263d09c1 100644
--- a/arch/sparc/kernel/compat_audit.c
+++ b/arch/sparc/kernel/compat_audit.c
@@ -1,5 +1,6 @@
1#define __32bit_syscall_numbers__ 1#define __32bit_syscall_numbers__
2#include <asm/unistd.h> 2#include <asm/unistd.h>
3#include "kernel.h"
3 4
4unsigned sparc32_dir_class[] = { 5unsigned sparc32_dir_class[] = {
5#include <asm-generic/audit_dir_write.h> 6#include <asm-generic/audit_dir_write.h>
diff --git a/arch/sparc/kernel/cpu.c b/arch/sparc/kernel/cpu.c
index 5c5125895db8..82a3a71c451e 100644
--- a/arch/sparc/kernel/cpu.c
+++ b/arch/sparc/kernel/cpu.c
@@ -22,6 +22,7 @@
22#include <asm/cpudata.h> 22#include <asm/cpudata.h>
23 23
24#include "kernel.h" 24#include "kernel.h"
25#include "entry.h"
25 26
26DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; 27DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
27EXPORT_PER_CPU_SYMBOL(__cpu_data); 28EXPORT_PER_CPU_SYMBOL(__cpu_data);
diff --git a/arch/sparc/kernel/cpumap.h b/arch/sparc/kernel/cpumap.h
index e639880ab864..9dac398c434a 100644
--- a/arch/sparc/kernel/cpumap.h
+++ b/arch/sparc/kernel/cpumap.h
@@ -2,8 +2,8 @@
2#define _CPUMAP_H 2#define _CPUMAP_H
3 3
4#ifdef CONFIG_SMP 4#ifdef CONFIG_SMP
5extern void cpu_map_rebuild(void); 5void cpu_map_rebuild(void);
6extern int map_to_cpu(unsigned int index); 6int map_to_cpu(unsigned int index);
7#define cpu_map_init() cpu_map_rebuild() 7#define cpu_map_init() cpu_map_rebuild()
8#else 8#else
9#define cpu_map_init() do {} while (0) 9#define cpu_map_init() do {} while (0)
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index 3d465e87f7e2..8d5d09f09caf 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -19,8 +19,9 @@
19#include <asm/smp.h> 19#include <asm/smp.h>
20#include <asm/cpudata.h> 20#include <asm/cpudata.h>
21#include <asm/cpu_type.h> 21#include <asm/cpu_type.h>
22#include <asm/setup.h>
22 23
23extern void clock_stop_probe(void); /* tadpole.c */ 24#include "kernel.h"
24 25
25static char *cpu_mid_prop(void) 26static char *cpu_mid_prop(void)
26{ 27{
@@ -131,11 +132,6 @@ void __init device_scan(void)
131 } 132 }
132#endif /* !CONFIG_SMP */ 133#endif /* !CONFIG_SMP */
133 134
134 { 135 auxio_probe();
135 extern void auxio_probe(void); 136 auxio_power_probe();
136 extern void auxio_power_probe(void);
137 auxio_probe();
138 auxio_power_probe();
139 }
140 clock_stop_probe();
141} 137}
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
index 140966fbd303..ebaba6167dd4 100644
--- a/arch/sparc/kernel/entry.h
+++ b/arch/sparc/kernel/entry.h
@@ -6,40 +6,39 @@
6#include <linux/init.h> 6#include <linux/init.h>
7 7
8/* irq */ 8/* irq */
9extern void handler_irq(int irq, struct pt_regs *regs); 9void handler_irq(int irq, struct pt_regs *regs);
10 10
11#ifdef CONFIG_SPARC32 11#ifdef CONFIG_SPARC32
12/* traps */ 12/* traps */
13extern void do_hw_interrupt(struct pt_regs *regs, unsigned long type); 13void do_hw_interrupt(struct pt_regs *regs, unsigned long type);
14extern void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, 14void do_illegal_instruction(struct pt_regs *regs, unsigned long pc,
15 unsigned long npc, unsigned long psr); 15 unsigned long npc, unsigned long psr);
16 16
17extern void do_priv_instruction(struct pt_regs *regs, unsigned long pc, 17void do_priv_instruction(struct pt_regs *regs, unsigned long pc,
18 unsigned long npc, unsigned long psr); 18 unsigned long npc, unsigned long psr);
19extern void do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc, 19void do_memaccess_unaligned(struct pt_regs *regs, unsigned long pc,
20 unsigned long npc, 20 unsigned long npc, unsigned long psr);
21 unsigned long psr); 21void do_fpd_trap(struct pt_regs *regs, unsigned long pc,
22extern void do_fpd_trap(struct pt_regs *regs, unsigned long pc, 22 unsigned long npc, unsigned long psr);
23void do_fpe_trap(struct pt_regs *regs, unsigned long pc,
24 unsigned long npc, unsigned long psr);
25void handle_tag_overflow(struct pt_regs *regs, unsigned long pc,
26 unsigned long npc, unsigned long psr);
27void handle_watchpoint(struct pt_regs *regs, unsigned long pc,
28 unsigned long npc, unsigned long psr);
29void handle_reg_access(struct pt_regs *regs, unsigned long pc,
30 unsigned long npc, unsigned long psr);
31void handle_cp_disabled(struct pt_regs *regs, unsigned long pc,
23 unsigned long npc, unsigned long psr); 32 unsigned long npc, unsigned long psr);
24extern void do_fpe_trap(struct pt_regs *regs, unsigned long pc, 33void handle_cp_exception(struct pt_regs *regs, unsigned long pc,
25 unsigned long npc, unsigned long psr); 34 unsigned long npc, unsigned long psr);
26extern void handle_tag_overflow(struct pt_regs *regs, unsigned long pc,
27 unsigned long npc, unsigned long psr);
28extern void handle_watchpoint(struct pt_regs *regs, unsigned long pc,
29 unsigned long npc, unsigned long psr);
30extern void handle_reg_access(struct pt_regs *regs, unsigned long pc,
31 unsigned long npc, unsigned long psr);
32extern void handle_cp_disabled(struct pt_regs *regs, unsigned long pc,
33 unsigned long npc, unsigned long psr);
34extern void handle_cp_exception(struct pt_regs *regs, unsigned long pc,
35 unsigned long npc, unsigned long psr);
36 35
37 36
38 37
39/* entry.S */ 38/* entry.S */
40extern void fpsave(unsigned long *fpregs, unsigned long *fsr, 39void fpsave(unsigned long *fpregs, unsigned long *fsr,
41 void *fpqueue, unsigned long *fpqdepth); 40 void *fpqueue, unsigned long *fpqdepth);
42extern void fpload(unsigned long *fpregs, unsigned long *fsr); 41void fpload(unsigned long *fpregs, unsigned long *fsr);
43 42
44#else /* CONFIG_SPARC32 */ 43#else /* CONFIG_SPARC32 */
45 44
@@ -66,123 +65,123 @@ struct pause_patch_entry {
66extern struct pause_patch_entry __pause_3insn_patch, 65extern struct pause_patch_entry __pause_3insn_patch,
67 __pause_3insn_patch_end; 66 __pause_3insn_patch_end;
68 67
69extern void __init per_cpu_patch(void); 68void __init per_cpu_patch(void);
70extern void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *, 69void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
71 struct sun4v_1insn_patch_entry *); 70 struct sun4v_1insn_patch_entry *);
72extern void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *, 71void sun4v_patch_2insn_range(struct sun4v_2insn_patch_entry *,
73 struct sun4v_2insn_patch_entry *); 72 struct sun4v_2insn_patch_entry *);
74extern void __init sun4v_patch(void); 73void __init sun4v_patch(void);
75extern void __init boot_cpu_id_too_large(int cpu); 74void __init boot_cpu_id_too_large(int cpu);
76extern unsigned int dcache_parity_tl1_occurred; 75extern unsigned int dcache_parity_tl1_occurred;
77extern unsigned int icache_parity_tl1_occurred; 76extern unsigned int icache_parity_tl1_occurred;
78 77
79extern asmlinkage void sparc_breakpoint(struct pt_regs *regs); 78asmlinkage void sparc_breakpoint(struct pt_regs *regs);
80extern void timer_interrupt(int irq, struct pt_regs *regs); 79void timer_interrupt(int irq, struct pt_regs *regs);
81 80
82extern void do_notify_resume(struct pt_regs *regs, 81void do_notify_resume(struct pt_regs *regs,
83 unsigned long orig_i0, 82 unsigned long orig_i0,
84 unsigned long thread_info_flags); 83 unsigned long thread_info_flags);
85 84
86extern asmlinkage int syscall_trace_enter(struct pt_regs *regs); 85asmlinkage int syscall_trace_enter(struct pt_regs *regs);
87extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); 86asmlinkage void syscall_trace_leave(struct pt_regs *regs);
88 87
89extern void bad_trap_tl1(struct pt_regs *regs, long lvl); 88void bad_trap_tl1(struct pt_regs *regs, long lvl);
90 89
91extern void do_fpieee(struct pt_regs *regs); 90void do_fpieee(struct pt_regs *regs);
92extern void do_fpother(struct pt_regs *regs); 91void do_fpother(struct pt_regs *regs);
93extern void do_tof(struct pt_regs *regs); 92void do_tof(struct pt_regs *regs);
94extern void do_div0(struct pt_regs *regs); 93void do_div0(struct pt_regs *regs);
95extern void do_illegal_instruction(struct pt_regs *regs); 94void do_illegal_instruction(struct pt_regs *regs);
96extern void mem_address_unaligned(struct pt_regs *regs, 95void mem_address_unaligned(struct pt_regs *regs,
97 unsigned long sfar, 96 unsigned long sfar,
98 unsigned long sfsr); 97 unsigned long sfsr);
99extern void sun4v_do_mna(struct pt_regs *regs, 98void sun4v_do_mna(struct pt_regs *regs,
100 unsigned long addr, 99 unsigned long addr,
101 unsigned long type_ctx); 100 unsigned long type_ctx);
102extern void do_privop(struct pt_regs *regs); 101void do_privop(struct pt_regs *regs);
103extern void do_privact(struct pt_regs *regs); 102void do_privact(struct pt_regs *regs);
104extern void do_cee(struct pt_regs *regs); 103void do_cee(struct pt_regs *regs);
105extern void do_cee_tl1(struct pt_regs *regs); 104void do_cee_tl1(struct pt_regs *regs);
106extern void do_dae_tl1(struct pt_regs *regs); 105void do_dae_tl1(struct pt_regs *regs);
107extern void do_iae_tl1(struct pt_regs *regs); 106void do_iae_tl1(struct pt_regs *regs);
108extern void do_div0_tl1(struct pt_regs *regs); 107void do_div0_tl1(struct pt_regs *regs);
109extern void do_fpdis_tl1(struct pt_regs *regs); 108void do_fpdis_tl1(struct pt_regs *regs);
110extern void do_fpieee_tl1(struct pt_regs *regs); 109void do_fpieee_tl1(struct pt_regs *regs);
111extern void do_fpother_tl1(struct pt_regs *regs); 110void do_fpother_tl1(struct pt_regs *regs);
112extern void do_ill_tl1(struct pt_regs *regs); 111void do_ill_tl1(struct pt_regs *regs);
113extern void do_irq_tl1(struct pt_regs *regs); 112void do_irq_tl1(struct pt_regs *regs);
114extern void do_lddfmna_tl1(struct pt_regs *regs); 113void do_lddfmna_tl1(struct pt_regs *regs);
115extern void do_stdfmna_tl1(struct pt_regs *regs); 114void do_stdfmna_tl1(struct pt_regs *regs);
116extern void do_paw(struct pt_regs *regs); 115void do_paw(struct pt_regs *regs);
117extern void do_paw_tl1(struct pt_regs *regs); 116void do_paw_tl1(struct pt_regs *regs);
118extern void do_vaw(struct pt_regs *regs); 117void do_vaw(struct pt_regs *regs);
119extern void do_vaw_tl1(struct pt_regs *regs); 118void do_vaw_tl1(struct pt_regs *regs);
120extern void do_tof_tl1(struct pt_regs *regs); 119void do_tof_tl1(struct pt_regs *regs);
121extern void do_getpsr(struct pt_regs *regs); 120void do_getpsr(struct pt_regs *regs);
122 121
123extern void spitfire_insn_access_exception(struct pt_regs *regs, 122void spitfire_insn_access_exception(struct pt_regs *regs,
124 unsigned long sfsr, 123 unsigned long sfsr,
125 unsigned long sfar); 124 unsigned long sfar);
126extern void spitfire_insn_access_exception_tl1(struct pt_regs *regs, 125void spitfire_insn_access_exception_tl1(struct pt_regs *regs,
127 unsigned long sfsr, 126 unsigned long sfsr,
128 unsigned long sfar); 127 unsigned long sfar);
129extern void spitfire_data_access_exception(struct pt_regs *regs, 128void spitfire_data_access_exception(struct pt_regs *regs,
130 unsigned long sfsr, 129 unsigned long sfsr,
131 unsigned long sfar); 130 unsigned long sfar);
132extern void spitfire_data_access_exception_tl1(struct pt_regs *regs, 131void spitfire_data_access_exception_tl1(struct pt_regs *regs,
133 unsigned long sfsr, 132 unsigned long sfsr,
134 unsigned long sfar); 133 unsigned long sfar);
135extern void spitfire_access_error(struct pt_regs *regs, 134void spitfire_access_error(struct pt_regs *regs,
136 unsigned long status_encoded, 135 unsigned long status_encoded,
137 unsigned long afar); 136 unsigned long afar);
138 137
139extern void cheetah_fecc_handler(struct pt_regs *regs, 138void cheetah_fecc_handler(struct pt_regs *regs,
140 unsigned long afsr, 139 unsigned long afsr,
141 unsigned long afar); 140 unsigned long afar);
142extern void cheetah_cee_handler(struct pt_regs *regs, 141void cheetah_cee_handler(struct pt_regs *regs,
143 unsigned long afsr, 142 unsigned long afsr,
144 unsigned long afar); 143 unsigned long afar);
145extern void cheetah_deferred_handler(struct pt_regs *regs, 144void cheetah_deferred_handler(struct pt_regs *regs,
146 unsigned long afsr, 145 unsigned long afsr,
147 unsigned long afar); 146 unsigned long afar);
148extern void cheetah_plus_parity_error(int type, struct pt_regs *regs); 147void cheetah_plus_parity_error(int type, struct pt_regs *regs);
149 148
150extern void sun4v_insn_access_exception(struct pt_regs *regs, 149void sun4v_insn_access_exception(struct pt_regs *regs,
151 unsigned long addr, 150 unsigned long addr,
152 unsigned long type_ctx); 151 unsigned long type_ctx);
153extern void sun4v_insn_access_exception_tl1(struct pt_regs *regs, 152void sun4v_insn_access_exception_tl1(struct pt_regs *regs,
154 unsigned long addr, 153 unsigned long addr,
155 unsigned long type_ctx); 154 unsigned long type_ctx);
156extern void sun4v_data_access_exception(struct pt_regs *regs, 155void sun4v_data_access_exception(struct pt_regs *regs,
157 unsigned long addr, 156 unsigned long addr,
158 unsigned long type_ctx); 157 unsigned long type_ctx);
159extern void sun4v_data_access_exception_tl1(struct pt_regs *regs, 158void sun4v_data_access_exception_tl1(struct pt_regs *regs,
160 unsigned long addr, 159 unsigned long addr,
161 unsigned long type_ctx); 160 unsigned long type_ctx);
162extern void sun4v_resum_error(struct pt_regs *regs, 161void sun4v_resum_error(struct pt_regs *regs,
163 unsigned long offset); 162 unsigned long offset);
164extern void sun4v_resum_overflow(struct pt_regs *regs); 163void sun4v_resum_overflow(struct pt_regs *regs);
165extern void sun4v_nonresum_error(struct pt_regs *regs, 164void sun4v_nonresum_error(struct pt_regs *regs,
166 unsigned long offset); 165 unsigned long offset);
167extern void sun4v_nonresum_overflow(struct pt_regs *regs); 166void sun4v_nonresum_overflow(struct pt_regs *regs);
168 167
169extern unsigned long sun4v_err_itlb_vaddr; 168extern unsigned long sun4v_err_itlb_vaddr;
170extern unsigned long sun4v_err_itlb_ctx; 169extern unsigned long sun4v_err_itlb_ctx;
171extern unsigned long sun4v_err_itlb_pte; 170extern unsigned long sun4v_err_itlb_pte;
172extern unsigned long sun4v_err_itlb_error; 171extern unsigned long sun4v_err_itlb_error;
173 172
174extern void sun4v_itlb_error_report(struct pt_regs *regs, int tl); 173void sun4v_itlb_error_report(struct pt_regs *regs, int tl);
175 174
176extern unsigned long sun4v_err_dtlb_vaddr; 175extern unsigned long sun4v_err_dtlb_vaddr;
177extern unsigned long sun4v_err_dtlb_ctx; 176extern unsigned long sun4v_err_dtlb_ctx;
178extern unsigned long sun4v_err_dtlb_pte; 177extern unsigned long sun4v_err_dtlb_pte;
179extern unsigned long sun4v_err_dtlb_error; 178extern unsigned long sun4v_err_dtlb_error;
180 179
181extern void sun4v_dtlb_error_report(struct pt_regs *regs, int tl); 180void sun4v_dtlb_error_report(struct pt_regs *regs, int tl);
182extern void hypervisor_tlbop_error(unsigned long err, 181void hypervisor_tlbop_error(unsigned long err,
183 unsigned long op); 182 unsigned long op);
184extern void hypervisor_tlbop_error_xcall(unsigned long err, 183void hypervisor_tlbop_error_xcall(unsigned long err,
185 unsigned long op); 184 unsigned long op);
186 185
187/* WARNING: The error trap handlers in assembly know the precise 186/* WARNING: The error trap handlers in assembly know the precise
188 * layout of the following structure. 187 * layout of the following structure.
@@ -248,8 +247,8 @@ struct ino_bucket {
248extern struct ino_bucket *ivector_table; 247extern struct ino_bucket *ivector_table;
249extern unsigned long ivector_table_pa; 248extern unsigned long ivector_table_pa;
250 249
251extern void init_irqwork_curcpu(void); 250void init_irqwork_curcpu(void);
252extern void sun4v_register_mondo_queues(int this_cpu); 251void sun4v_register_mondo_queues(int this_cpu);
253 252
254#endif /* CONFIG_SPARC32 */ 253#endif /* CONFIG_SPARC32 */
255#endif /* _ENTRY_H */ 254#endif /* _ENTRY_H */
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 76663b019eb5..bfa4d0c2df42 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -21,6 +21,7 @@
21#include <asm/iommu.h> 21#include <asm/iommu.h>
22 22
23#include "iommu_common.h" 23#include "iommu_common.h"
24#include "kernel.h"
24 25
25#define STC_CTXMATCH_ADDR(STC, CTX) \ 26#define STC_CTXMATCH_ADDR(STC, CTX) \
26 ((STC)->strbuf_ctxmatch_base + ((CTX) << 3)) 27 ((STC)->strbuf_ctxmatch_base + ((CTX) << 3))
@@ -840,8 +841,6 @@ static struct dma_map_ops sun4u_dma_ops = {
840struct dma_map_ops *dma_ops = &sun4u_dma_ops; 841struct dma_map_ops *dma_ops = &sun4u_dma_ops;
841EXPORT_SYMBOL(dma_ops); 842EXPORT_SYMBOL(dma_ops);
842 843
843extern int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
844
845int dma_supported(struct device *dev, u64 device_mask) 844int dma_supported(struct device *dev, u64 device_mask)
846{ 845{
847 struct iommu *iommu = dev->archdata.iommu; 846 struct iommu *iommu = dev->archdata.iommu;
diff --git a/arch/sparc/kernel/iommu_common.h b/arch/sparc/kernel/iommu_common.h
index 591f5879039c..1ec0de4156e7 100644
--- a/arch/sparc/kernel/iommu_common.h
+++ b/arch/sparc/kernel/iommu_common.h
@@ -48,12 +48,12 @@ static inline int is_span_boundary(unsigned long entry,
48 return iommu_is_span_boundary(entry, nr, shift, boundary_size); 48 return iommu_is_span_boundary(entry, nr, shift, boundary_size);
49} 49}
50 50
51extern unsigned long iommu_range_alloc(struct device *dev, 51unsigned long iommu_range_alloc(struct device *dev,
52 struct iommu *iommu, 52 struct iommu *iommu,
53 unsigned long npages, 53 unsigned long npages,
54 unsigned long *handle); 54 unsigned long *handle);
55extern void iommu_range_free(struct iommu *iommu, 55void iommu_range_free(struct iommu *iommu,
56 dma_addr_t dma_addr, 56 dma_addr_t dma_addr,
57 unsigned long npages); 57 unsigned long npages);
58 58
59#endif /* _IOMMU_COMMON_H */ 59#endif /* _IOMMU_COMMON_H */
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
index e7e215dfa866..7f08ec8a7c68 100644
--- a/arch/sparc/kernel/ioport.c
+++ b/arch/sparc/kernel/ioport.c
@@ -186,7 +186,7 @@ static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
186 186
187 if (name == NULL) name = "???"; 187 if (name == NULL) name = "???";
188 188
189 if ((xres = xres_alloc()) != 0) { 189 if ((xres = xres_alloc()) != NULL) {
190 tack = xres->xname; 190 tack = xres->xname;
191 res = &xres->xres; 191 res = &xres->xres;
192 } else { 192 } else {
@@ -400,7 +400,7 @@ static void sbus_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
400 BUG(); 400 BUG();
401} 401}
402 402
403struct dma_map_ops sbus_dma_ops = { 403static struct dma_map_ops sbus_dma_ops = {
404 .alloc = sbus_alloc_coherent, 404 .alloc = sbus_alloc_coherent,
405 .free = sbus_free_coherent, 405 .free = sbus_free_coherent,
406 .map_page = sbus_map_page, 406 .map_page = sbus_map_page,
@@ -681,7 +681,7 @@ static int sparc_io_proc_show(struct seq_file *m, void *v)
681 const char *nm; 681 const char *nm;
682 682
683 for (r = root->child; r != NULL; r = r->sibling) { 683 for (r = root->child; r != NULL; r = r->sibling) {
684 if ((nm = r->name) == 0) nm = "???"; 684 if ((nm = r->name) == NULL) nm = "???";
685 seq_printf(m, "%016llx-%016llx: %s\n", 685 seq_printf(m, "%016llx-%016llx: %s\n",
686 (unsigned long long)r->start, 686 (unsigned long long)r->start,
687 (unsigned long long)r->end, nm); 687 (unsigned long long)r->end, nm);
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
index b66b6aad1d6d..70a0b8ddd0ba 100644
--- a/arch/sparc/kernel/irq.h
+++ b/arch/sparc/kernel/irq.h
@@ -82,11 +82,20 @@ void handler_irq(unsigned int pil, struct pt_regs *regs);
82 82
83unsigned long leon_get_irqmask(unsigned int irq); 83unsigned long leon_get_irqmask(unsigned int irq);
84 84
85/* irq_32.c */
86void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs);
87
88/* sun4m_irq.c */
89void sun4m_nmi(struct pt_regs *regs);
90
91/* sun4d_irq.c */
92void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs);
93
85#ifdef CONFIG_SMP 94#ifdef CONFIG_SMP
86 95
87/* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */ 96/* All SUN4D IPIs are sent on this IRQ, may be shared with hard IRQs */
88#define SUN4D_IPI_IRQ 13 97#define SUN4D_IPI_IRQ 13
89 98
90extern void sun4d_ipi_interrupt(void); 99void sun4d_ipi_interrupt(void);
91 100
92#endif 101#endif
diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index c145f6fd123b..a979e99f8751 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -17,6 +17,7 @@
17 17
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19#include <asm/cpudata.h> 19#include <asm/cpudata.h>
20#include <asm/setup.h>
20#include <asm/pcic.h> 21#include <asm/pcic.h>
21#include <asm/leon.h> 22#include <asm/leon.h>
22 23
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index a702d9ab019c..e7f652be9e61 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -2,6 +2,7 @@
2#define __SPARC_KERNEL_H 2#define __SPARC_KERNEL_H
3 3
4#include <linux/interrupt.h> 4#include <linux/interrupt.h>
5#include <linux/ftrace.h>
5 6
6#include <asm/traps.h> 7#include <asm/traps.h>
7#include <asm/head.h> 8#include <asm/head.h>
@@ -15,62 +16,111 @@ extern int ncpus_probed;
15#ifdef CONFIG_SPARC64 16#ifdef CONFIG_SPARC64
16/* setup_64.c */ 17/* setup_64.c */
17struct seq_file; 18struct seq_file;
18extern void cpucap_info(struct seq_file *); 19void cpucap_info(struct seq_file *);
19 20
20static inline unsigned long kimage_addr_to_ra(const char *p) 21static inline unsigned long kimage_addr_to_ra(const void *p)
21{ 22{
22 unsigned long val = (unsigned long) p; 23 unsigned long val = (unsigned long) p;
23 24
24 return kern_base + (val - KERNBASE); 25 return kern_base + (val - KERNBASE);
25} 26}
27
28/* sys_sparc_64.c */
29asmlinkage long sys_kern_features(void);
30
31/* unaligned_64.c */
32asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn);
33int handle_popc(u32 insn, struct pt_regs *regs);
34void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr);
35void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr);
36
37/* smp_64.c */
38void __irq_entry smp_call_function_client(int irq, struct pt_regs *regs);
39void __irq_entry smp_call_function_single_client(int irq, struct pt_regs *regs);
40void __irq_entry smp_new_mmu_context_version_client(int irq, struct pt_regs *regs);
41void __irq_entry smp_penguin_jailcell(int irq, struct pt_regs *regs);
42void __irq_entry smp_receive_signal_client(int irq, struct pt_regs *regs);
43
44/* kgdb_64.c */
45void __irq_entry smp_kgdb_capture_client(int irq, struct pt_regs *regs);
46
47/* pci.c */
48int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask);
49
50/* signal32.c */
51void do_sigreturn32(struct pt_regs *regs);
52asmlinkage void do_rt_sigreturn32(struct pt_regs *regs);
53void do_signal32(struct pt_regs * regs);
54asmlinkage int do_sys32_sigstack(u32 u_ssptr, u32 u_ossptr, unsigned long sp);
55
56/* compat_audit.c */
57extern unsigned sparc32_dir_class[];
58extern unsigned sparc32_chattr_class[];
59extern unsigned sparc32_write_class[];
60extern unsigned sparc32_read_class[];
61extern unsigned sparc32_signal_class[];
62int sparc32_classify_syscall(unsigned syscall);
26#endif 63#endif
27 64
28#ifdef CONFIG_SPARC32 65#ifdef CONFIG_SPARC32
29/* setup_32.c */ 66/* setup_32.c */
67struct linux_romvec;
30void sparc32_start_kernel(struct linux_romvec *rp); 68void sparc32_start_kernel(struct linux_romvec *rp);
31 69
32/* cpu.c */ 70/* cpu.c */
33extern void cpu_probe(void); 71void cpu_probe(void);
34 72
35/* traps_32.c */ 73/* traps_32.c */
36extern void handle_hw_divzero(struct pt_regs *regs, unsigned long pc, 74void handle_hw_divzero(struct pt_regs *regs, unsigned long pc,
37 unsigned long npc, unsigned long psr); 75 unsigned long npc, unsigned long psr);
38/* irq_32.c */ 76/* irq_32.c */
39extern struct irqaction static_irqaction[]; 77extern struct irqaction static_irqaction[];
40extern int static_irq_count; 78extern int static_irq_count;
41extern spinlock_t irq_action_lock; 79extern spinlock_t irq_action_lock;
42 80
43extern void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs); 81void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs);
44extern void init_IRQ(void); 82void init_IRQ(void);
45 83
46/* sun4m_irq.c */ 84/* sun4m_irq.c */
47extern void sun4m_init_IRQ(void); 85void sun4m_init_IRQ(void);
48extern void sun4m_unmask_profile_irq(void); 86void sun4m_unmask_profile_irq(void);
49extern void sun4m_clear_profile_irq(int cpu); 87void sun4m_clear_profile_irq(int cpu);
50 88
51/* sun4m_smp.c */ 89/* sun4m_smp.c */
52void sun4m_cpu_pre_starting(void *arg); 90void sun4m_cpu_pre_starting(void *arg);
53void sun4m_cpu_pre_online(void *arg); 91void sun4m_cpu_pre_online(void *arg);
92void __init smp4m_boot_cpus(void);
93int smp4m_boot_one_cpu(int i, struct task_struct *idle);
94void __init smp4m_smp_done(void);
95void smp4m_cross_call_irq(void);
96void smp4m_percpu_timer_interrupt(struct pt_regs *regs);
54 97
55/* sun4d_irq.c */ 98/* sun4d_irq.c */
56extern spinlock_t sun4d_imsk_lock; 99extern spinlock_t sun4d_imsk_lock;
57 100
58extern void sun4d_init_IRQ(void); 101void sun4d_init_IRQ(void);
59extern int sun4d_request_irq(unsigned int irq, 102int sun4d_request_irq(unsigned int irq,
60 irq_handler_t handler, 103 irq_handler_t handler,
61 unsigned long irqflags, 104 unsigned long irqflags,
62 const char *devname, void *dev_id); 105 const char *devname, void *dev_id);
63extern int show_sun4d_interrupts(struct seq_file *, void *); 106int show_sun4d_interrupts(struct seq_file *, void *);
64extern void sun4d_distribute_irqs(void); 107void sun4d_distribute_irqs(void);
65extern void sun4d_free_irq(unsigned int irq, void *dev_id); 108void sun4d_free_irq(unsigned int irq, void *dev_id);
66 109
67/* sun4d_smp.c */ 110/* sun4d_smp.c */
68void sun4d_cpu_pre_starting(void *arg); 111void sun4d_cpu_pre_starting(void *arg);
69void sun4d_cpu_pre_online(void *arg); 112void sun4d_cpu_pre_online(void *arg);
113void __init smp4d_boot_cpus(void);
114int smp4d_boot_one_cpu(int i, struct task_struct *idle);
115void __init smp4d_smp_done(void);
116void smp4d_cross_call_irq(void);
117void smp4d_percpu_timer_interrupt(struct pt_regs *regs);
70 118
71/* leon_smp.c */ 119/* leon_smp.c */
72void leon_cpu_pre_starting(void *arg); 120void leon_cpu_pre_starting(void *arg);
73void leon_cpu_pre_online(void *arg); 121void leon_cpu_pre_online(void *arg);
122void leonsmp_ipi_interrupt(void);
123void leon_cross_call_irq(void);
74 124
75/* head_32.S */ 125/* head_32.S */
76extern unsigned int t_nmi[]; 126extern unsigned int t_nmi[];
@@ -89,12 +139,48 @@ extern unsigned int real_irq_entry[];
89extern unsigned int smp4d_ticker[]; 139extern unsigned int smp4d_ticker[];
90extern unsigned int patchme_maybe_smp_msg[]; 140extern unsigned int patchme_maybe_smp_msg[];
91 141
92extern void floppy_hardint(void); 142void floppy_hardint(void);
93 143
94/* trampoline_32.S */ 144/* trampoline_32.S */
95extern unsigned long sun4m_cpu_startup; 145extern unsigned long sun4m_cpu_startup;
96extern unsigned long sun4d_cpu_startup; 146extern unsigned long sun4d_cpu_startup;
97 147
148/* process_32.c */
149asmlinkage int sparc_do_fork(unsigned long clone_flags,
150 unsigned long stack_start,
151 struct pt_regs *regs,
152 unsigned long stack_size);
153
154/* signal_32.c */
155asmlinkage void do_sigreturn(struct pt_regs *regs);
156asmlinkage void do_rt_sigreturn(struct pt_regs *regs);
157void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
158 unsigned long thread_info_flags);
159asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
160 struct sigstack __user *ossptr,
161 unsigned long sp);
162
163/* ptrace_32.c */
164asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p);
165
166/* unaligned_32.c */
167asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn);
168asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn);
169
170/* windows.c */
171void try_to_clear_window_buffer(struct pt_regs *regs, int who);
172
173/* auxio_32.c */
174void __init auxio_probe(void);
175void __init auxio_power_probe(void);
176
177/* pcic.c */
178extern void __iomem *pcic_regs;
179void pcic_nmi(unsigned int pend, struct pt_regs *regs);
180
181/* time_32.c */
182void __init time_init(void);
183
98#else /* CONFIG_SPARC32 */ 184#else /* CONFIG_SPARC32 */
99#endif /* CONFIG_SPARC32 */ 185#endif /* CONFIG_SPARC32 */
100#endif /* !(__SPARC_KERNEL_H) */ 186#endif /* !(__SPARC_KERNEL_H) */
diff --git a/arch/sparc/kernel/kgdb_64.c b/arch/sparc/kernel/kgdb_64.c
index b45fe3fb4d2c..cbf21d0870e0 100644
--- a/arch/sparc/kernel/kgdb_64.c
+++ b/arch/sparc/kernel/kgdb_64.c
@@ -13,6 +13,8 @@
13#include <asm/ptrace.h> 13#include <asm/ptrace.h>
14#include <asm/irq.h> 14#include <asm/irq.h>
15 15
16#include "kernel.h"
17
16void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) 18void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
17{ 19{
18 struct reg_window *win; 20 struct reg_window *win;
diff --git a/arch/sparc/kernel/kprobes.c b/arch/sparc/kernel/kprobes.c
index 1b0973503197..98d712843413 100644
--- a/arch/sparc/kernel/kprobes.c
+++ b/arch/sparc/kernel/kprobes.c
@@ -512,7 +512,8 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri,
512/* 512/*
513 * Called when the probe at kretprobe trampoline is hit 513 * Called when the probe at kretprobe trampoline is hit
514 */ 514 */
515int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) 515static int __kprobes trampoline_probe_handler(struct kprobe *p,
516 struct pt_regs *regs)
516{ 517{
517 struct kretprobe_instance *ri = NULL; 518 struct kretprobe_instance *ri = NULL;
518 struct hlist_head *head, empty_rp; 519 struct hlist_head *head, empty_rp;
@@ -576,7 +577,7 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
576 return 1; 577 return 1;
577} 578}
578 579
579void kretprobe_trampoline_holder(void) 580static void __used kretprobe_trampoline_holder(void)
580{ 581{
581 asm volatile(".global kretprobe_trampoline\n" 582 asm volatile(".global kretprobe_trampoline\n"
582 "kretprobe_trampoline:\n" 583 "kretprobe_trampoline:\n"
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index b7c68976cbc7..683c4af999de 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -32,12 +32,12 @@ struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base addr
32 32
33int leondebug_irq_disable; 33int leondebug_irq_disable;
34int leon_debug_irqout; 34int leon_debug_irqout;
35static int dummy_master_l10_counter; 35static volatile u32 dummy_master_l10_counter;
36unsigned long amba_system_id; 36unsigned long amba_system_id;
37static DEFINE_SPINLOCK(leon_irq_lock); 37static DEFINE_SPINLOCK(leon_irq_lock);
38 38
39static unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */
39unsigned long leon3_gptimer_irq; /* interrupt controller irq number */ 40unsigned long leon3_gptimer_irq; /* interrupt controller irq number */
40unsigned long leon3_gptimer_idx; /* Timer Index (0..6) within Timer Core */
41unsigned int sparc_leon_eirq; 41unsigned int sparc_leon_eirq;
42#define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu]) 42#define LEON_IMASK(cpu) (&leon3_irqctrl_regs->mask[cpu])
43#define LEON_IACK (&leon3_irqctrl_regs->iclear) 43#define LEON_IACK (&leon3_irqctrl_regs->iclear)
@@ -65,7 +65,7 @@ static void leon_handle_ext_irq(unsigned int irq, struct irq_desc *desc)
65} 65}
66 66
67/* The extended IRQ controller has been found, this function registers it */ 67/* The extended IRQ controller has been found, this function registers it */
68void leon_eirq_setup(unsigned int eirq) 68static void leon_eirq_setup(unsigned int eirq)
69{ 69{
70 unsigned long mask, oldmask; 70 unsigned long mask, oldmask;
71 unsigned int veirq; 71 unsigned int veirq;
@@ -270,7 +270,7 @@ static u32 leon_cycles_offset(void)
270#ifdef CONFIG_SMP 270#ifdef CONFIG_SMP
271 271
272/* smp clockevent irq */ 272/* smp clockevent irq */
273irqreturn_t leon_percpu_timer_ce_interrupt(int irq, void *unused) 273static irqreturn_t leon_percpu_timer_ce_interrupt(int irq, void *unused)
274{ 274{
275 struct clock_event_device *ce; 275 struct clock_event_device *ce;
276 int cpu = smp_processor_id(); 276 int cpu = smp_processor_id();
@@ -313,7 +313,7 @@ void __init leon_init_timers(void)
313 313
314 leondebug_irq_disable = 0; 314 leondebug_irq_disable = 0;
315 leon_debug_irqout = 0; 315 leon_debug_irqout = 0;
316 master_l10_counter = (unsigned int *)&dummy_master_l10_counter; 316 master_l10_counter = (u32 __iomem *)&dummy_master_l10_counter;
317 dummy_master_l10_counter = 0; 317 dummy_master_l10_counter = 0;
318 318
319 rootnp = of_find_node_by_path("/ambapp0"); 319 rootnp = of_find_node_by_path("/ambapp0");
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index e16c4157e1ae..899b7203a4e4 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -98,82 +98,3 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
98{ 98{
99 return res->start; 99 return res->start;
100} 100}
101
102/* in/out routines taken from pcic.c
103 *
104 * This probably belongs here rather than ioport.c because
105 * we do not want this crud linked into SBus kernels.
106 * Also, think for a moment about likes of floppy.c that
107 * include architecture specific parts. They may want to redefine ins/outs.
108 *
109 * We do not use horrible macros here because we want to
110 * advance pointer by sizeof(size).
111 */
112void outsb(unsigned long addr, const void *src, unsigned long count)
113{
114 while (count) {
115 count -= 1;
116 outb(*(const char *)src, addr);
117 src += 1;
118 /* addr += 1; */
119 }
120}
121EXPORT_SYMBOL(outsb);
122
123void outsw(unsigned long addr, const void *src, unsigned long count)
124{
125 while (count) {
126 count -= 2;
127 outw(*(const short *)src, addr);
128 src += 2;
129 /* addr += 2; */
130 }
131}
132EXPORT_SYMBOL(outsw);
133
134void outsl(unsigned long addr, const void *src, unsigned long count)
135{
136 while (count) {
137 count -= 4;
138 outl(*(const long *)src, addr);
139 src += 4;
140 /* addr += 4; */
141 }
142}
143EXPORT_SYMBOL(outsl);
144
145void insb(unsigned long addr, void *dst, unsigned long count)
146{
147 while (count) {
148 count -= 1;
149 *(unsigned char *)dst = inb(addr);
150 dst += 1;
151 /* addr += 1; */
152 }
153}
154EXPORT_SYMBOL(insb);
155
156void insw(unsigned long addr, void *dst, unsigned long count)
157{
158 while (count) {
159 count -= 2;
160 *(unsigned short *)dst = inw(addr);
161 dst += 2;
162 /* addr += 2; */
163 }
164}
165EXPORT_SYMBOL(insw);
166
167void insl(unsigned long addr, void *dst, unsigned long count)
168{
169 while (count) {
170 count -= 4;
171 /*
172 * XXX I am sure we are in for an unaligned trap here.
173 */
174 *(unsigned long *)dst = inl(addr);
175 dst += 4;
176 /* addr += 4; */
177 }
178}
179EXPORT_SYMBOL(insl);
diff --git a/arch/sparc/kernel/leon_pci_grpci1.c b/arch/sparc/kernel/leon_pci_grpci1.c
index 6df26e37f879..c8bf26edfa7c 100644
--- a/arch/sparc/kernel/leon_pci_grpci1.c
+++ b/arch/sparc/kernel/leon_pci_grpci1.c
@@ -80,7 +80,7 @@ struct grpci1_regs {
80 80
81struct grpci1_priv { 81struct grpci1_priv {
82 struct leon_pci_info info; /* must be on top of this structure */ 82 struct leon_pci_info info; /* must be on top of this structure */
83 struct grpci1_regs *regs; /* GRPCI register map */ 83 struct grpci1_regs __iomem *regs; /* GRPCI register map */
84 struct device *dev; 84 struct device *dev;
85 int pci_err_mask; /* STATUS register error mask */ 85 int pci_err_mask; /* STATUS register error mask */
86 int irq; /* LEON irqctrl GRPCI IRQ */ 86 int irq; /* LEON irqctrl GRPCI IRQ */
@@ -101,7 +101,7 @@ static struct grpci1_priv *grpci1priv;
101static int grpci1_cfg_w32(struct grpci1_priv *priv, unsigned int bus, 101static int grpci1_cfg_w32(struct grpci1_priv *priv, unsigned int bus,
102 unsigned int devfn, int where, u32 val); 102 unsigned int devfn, int where, u32 val);
103 103
104int grpci1_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 104static int grpci1_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
105{ 105{
106 struct grpci1_priv *priv = dev->bus->sysdata; 106 struct grpci1_priv *priv = dev->bus->sysdata;
107 int irq_group; 107 int irq_group;
@@ -144,7 +144,7 @@ static int grpci1_cfg_r32(struct grpci1_priv *priv, unsigned int bus,
144 grpci1_cfg_w32(priv, TGT, 0, PCI_COMMAND, tmp); 144 grpci1_cfg_w32(priv, TGT, 0, PCI_COMMAND, tmp);
145 } else { 145 } else {
146 /* Bus always little endian (unaffected by byte-swapping) */ 146 /* Bus always little endian (unaffected by byte-swapping) */
147 *val = flip_dword(tmp); 147 *val = swab32(tmp);
148 } 148 }
149 149
150 return 0; 150 return 0;
@@ -197,7 +197,7 @@ static int grpci1_cfg_w32(struct grpci1_priv *priv, unsigned int bus,
197 197
198 pci_conf = (unsigned int *) (priv->pci_conf | 198 pci_conf = (unsigned int *) (priv->pci_conf |
199 (devfn << 8) | (where & 0xfc)); 199 (devfn << 8) | (where & 0xfc));
200 LEON3_BYPASS_STORE_PA(pci_conf, flip_dword(val)); 200 LEON3_BYPASS_STORE_PA(pci_conf, swab32(val));
201 201
202 return 0; 202 return 0;
203} 203}
@@ -417,10 +417,10 @@ out:
417 * BAR1: peripheral DMA to host's memory (size at least 256MByte) 417 * BAR1: peripheral DMA to host's memory (size at least 256MByte)
418 * BAR2..BAR5: not implemented in hardware 418 * BAR2..BAR5: not implemented in hardware
419 */ 419 */
420void grpci1_hw_init(struct grpci1_priv *priv) 420static void grpci1_hw_init(struct grpci1_priv *priv)
421{ 421{
422 u32 ahbadr, bar_sz, data, pciadr; 422 u32 ahbadr, bar_sz, data, pciadr;
423 struct grpci1_regs *regs = priv->regs; 423 struct grpci1_regs __iomem *regs = priv->regs;
424 424
425 /* set 1:1 mapping between AHB -> PCI memory space */ 425 /* set 1:1 mapping between AHB -> PCI memory space */
426 REGSTORE(regs->cfg_stat, priv->pci_area & 0xf0000000); 426 REGSTORE(regs->cfg_stat, priv->pci_area & 0xf0000000);
@@ -509,7 +509,7 @@ static irqreturn_t grpci1_err_interrupt(int irq, void *arg)
509 509
510static int grpci1_of_probe(struct platform_device *ofdev) 510static int grpci1_of_probe(struct platform_device *ofdev)
511{ 511{
512 struct grpci1_regs *regs; 512 struct grpci1_regs __iomem *regs;
513 struct grpci1_priv *priv; 513 struct grpci1_priv *priv;
514 int err, len; 514 int err, len;
515 const int *tmp; 515 const int *tmp;
@@ -690,7 +690,7 @@ err3:
690err2: 690err2:
691 release_resource(&priv->info.mem_space); 691 release_resource(&priv->info.mem_space);
692err1: 692err1:
693 iounmap((void *)priv->pci_io_va); 693 iounmap((void __iomem *)priv->pci_io_va);
694 grpci1priv = NULL; 694 grpci1priv = NULL;
695 return err; 695 return err;
696} 696}
diff --git a/arch/sparc/kernel/leon_pci_grpci2.c b/arch/sparc/kernel/leon_pci_grpci2.c
index 24d6a4446349..e433a4d69fe0 100644
--- a/arch/sparc/kernel/leon_pci_grpci2.c
+++ b/arch/sparc/kernel/leon_pci_grpci2.c
@@ -191,7 +191,7 @@ struct grpci2_cap_first {
191 191
192struct grpci2_priv { 192struct grpci2_priv {
193 struct leon_pci_info info; /* must be on top of this structure */ 193 struct leon_pci_info info; /* must be on top of this structure */
194 struct grpci2_regs *regs; 194 struct grpci2_regs __iomem *regs;
195 char irq; 195 char irq;
196 char irq_mode; /* IRQ Mode from CAPSTS REG */ 196 char irq_mode; /* IRQ Mode from CAPSTS REG */
197 char bt_enabled; 197 char bt_enabled;
@@ -215,10 +215,10 @@ struct grpci2_priv {
215 struct grpci2_barcfg tgtbars[6]; 215 struct grpci2_barcfg tgtbars[6];
216}; 216};
217 217
218DEFINE_SPINLOCK(grpci2_dev_lock); 218static DEFINE_SPINLOCK(grpci2_dev_lock);
219struct grpci2_priv *grpci2priv; 219static struct grpci2_priv *grpci2priv;
220 220
221int grpci2_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 221static int grpci2_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
222{ 222{
223 struct grpci2_priv *priv = dev->bus->sysdata; 223 struct grpci2_priv *priv = dev->bus->sysdata;
224 int irq_group; 224 int irq_group;
@@ -270,7 +270,7 @@ static int grpci2_cfg_r32(struct grpci2_priv *priv, unsigned int bus,
270 *val = 0xffffffff; 270 *val = 0xffffffff;
271 } else { 271 } else {
272 /* Bus always little endian (unaffected by byte-swapping) */ 272 /* Bus always little endian (unaffected by byte-swapping) */
273 *val = flip_dword(tmp); 273 *val = swab32(tmp);
274 } 274 }
275 275
276 return 0; 276 return 0;
@@ -328,7 +328,7 @@ static int grpci2_cfg_w32(struct grpci2_priv *priv, unsigned int bus,
328 328
329 pci_conf = (unsigned int *) (priv->pci_conf | 329 pci_conf = (unsigned int *) (priv->pci_conf |
330 (devfn << 8) | (where & 0xfc)); 330 (devfn << 8) | (where & 0xfc));
331 LEON3_BYPASS_STORE_PA(pci_conf, flip_dword(val)); 331 LEON3_BYPASS_STORE_PA(pci_conf, swab32(val));
332 332
333 /* Wait until GRPCI2 signals that CFG access is done, it should be 333 /* Wait until GRPCI2 signals that CFG access is done, it should be
334 * done instantaneously unless a DMA operation is ongoing... 334 * done instantaneously unless a DMA operation is ongoing...
@@ -561,10 +561,10 @@ out:
561 return virq; 561 return virq;
562} 562}
563 563
564void grpci2_hw_init(struct grpci2_priv *priv) 564static void grpci2_hw_init(struct grpci2_priv *priv)
565{ 565{
566 u32 ahbadr, pciadr, bar_sz, capptr, io_map, data; 566 u32 ahbadr, pciadr, bar_sz, capptr, io_map, data;
567 struct grpci2_regs *regs = priv->regs; 567 struct grpci2_regs __iomem *regs = priv->regs;
568 int i; 568 int i;
569 struct grpci2_barcfg *barcfg = priv->tgtbars; 569 struct grpci2_barcfg *barcfg = priv->tgtbars;
570 570
@@ -655,7 +655,7 @@ static irqreturn_t grpci2_jump_interrupt(int irq, void *arg)
655static irqreturn_t grpci2_err_interrupt(int irq, void *arg) 655static irqreturn_t grpci2_err_interrupt(int irq, void *arg)
656{ 656{
657 struct grpci2_priv *priv = arg; 657 struct grpci2_priv *priv = arg;
658 struct grpci2_regs *regs = priv->regs; 658 struct grpci2_regs __iomem *regs = priv->regs;
659 unsigned int status; 659 unsigned int status;
660 660
661 status = REGLOAD(regs->sts_cap); 661 status = REGLOAD(regs->sts_cap);
@@ -682,7 +682,7 @@ static irqreturn_t grpci2_err_interrupt(int irq, void *arg)
682 682
683static int grpci2_of_probe(struct platform_device *ofdev) 683static int grpci2_of_probe(struct platform_device *ofdev)
684{ 684{
685 struct grpci2_regs *regs; 685 struct grpci2_regs __iomem *regs;
686 struct grpci2_priv *priv; 686 struct grpci2_priv *priv;
687 int err, i, len; 687 int err, i, len;
688 const int *tmp; 688 const int *tmp;
@@ -878,7 +878,7 @@ err4:
878 release_resource(&priv->info.mem_space); 878 release_resource(&priv->info.mem_space);
879err3: 879err3:
880 err = -ENOMEM; 880 err = -ENOMEM;
881 iounmap((void *)priv->pci_io_va); 881 iounmap((void __iomem *)priv->pci_io_va);
882err2: 882err2:
883 kfree(priv); 883 kfree(priv);
884err1: 884err1:
diff --git a/arch/sparc/kernel/leon_pmc.c b/arch/sparc/kernel/leon_pmc.c
index b0b3967a2dd2..ddcf950282ed 100644
--- a/arch/sparc/kernel/leon_pmc.c
+++ b/arch/sparc/kernel/leon_pmc.c
@@ -12,14 +12,14 @@
12#include <asm/processor.h> 12#include <asm/processor.h>
13 13
14/* List of Systems that need fixup instructions around power-down instruction */ 14/* List of Systems that need fixup instructions around power-down instruction */
15unsigned int pmc_leon_fixup_ids[] = { 15static unsigned int pmc_leon_fixup_ids[] = {
16 AEROFLEX_UT699, 16 AEROFLEX_UT699,
17 GAISLER_GR712RC, 17 GAISLER_GR712RC,
18 LEON4_NEXTREME1, 18 LEON4_NEXTREME1,
19 0 19 0
20}; 20};
21 21
22int pmc_leon_need_fixup(void) 22static int pmc_leon_need_fixup(void)
23{ 23{
24 unsigned int systemid = amba_system_id >> 16; 24 unsigned int systemid = amba_system_id >> 16;
25 unsigned int *id; 25 unsigned int *id;
@@ -38,7 +38,7 @@ int pmc_leon_need_fixup(void)
38 * CPU idle callback function for systems that need some extra handling 38 * CPU idle callback function for systems that need some extra handling
39 * See .../arch/sparc/kernel/process.c 39 * See .../arch/sparc/kernel/process.c
40 */ 40 */
41void pmc_leon_idle_fixup(void) 41static void pmc_leon_idle_fixup(void)
42{ 42{
43 /* Prepare an address to a non-cachable region. APB is always 43 /* Prepare an address to a non-cachable region. APB is always
44 * none-cachable. One instruction is executed after the Sleep 44 * none-cachable. One instruction is executed after the Sleep
@@ -62,7 +62,7 @@ void pmc_leon_idle_fixup(void)
62 * CPU idle callback function 62 * CPU idle callback function
63 * See .../arch/sparc/kernel/process.c 63 * See .../arch/sparc/kernel/process.c
64 */ 64 */
65void pmc_leon_idle(void) 65static void pmc_leon_idle(void)
66{ 66{
67 /* Interrupts need to be enabled to not hang the CPU */ 67 /* Interrupts need to be enabled to not hang the CPU */
68 local_irq_enable(); 68 local_irq_enable();
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 6edf955f987c..018ef11f57df 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -130,7 +130,7 @@ void leon_configure_cache_smp(void)
130 local_ops->tlb_all(); 130 local_ops->tlb_all();
131} 131}
132 132
133void leon_smp_setbroadcast(unsigned int mask) 133static void leon_smp_setbroadcast(unsigned int mask)
134{ 134{
135 int broadcast = 135 int broadcast =
136 ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >> 136 ((LEON3_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpstatus)) >>
@@ -148,13 +148,6 @@ void leon_smp_setbroadcast(unsigned int mask)
148 LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpbroadcast), mask); 148 LEON_BYPASS_STORE_PA(&(leon3_irqctrl_regs->mpbroadcast), mask);
149} 149}
150 150
151unsigned int leon_smp_getbroadcast(void)
152{
153 unsigned int mask;
154 mask = LEON_BYPASS_LOAD_PA(&(leon3_irqctrl_regs->mpbroadcast));
155 return mask;
156}
157
158int leon_smp_nrcpus(void) 151int leon_smp_nrcpus(void)
159{ 152{
160 int nrcpu = 153 int nrcpu =
@@ -266,10 +259,6 @@ void __init leon_smp_done(void)
266 259
267} 260}
268 261
269void leon_irq_rotate(int cpu)
270{
271}
272
273struct leon_ipi_work { 262struct leon_ipi_work {
274 int single; 263 int single;
275 int msk; 264 int msk;
diff --git a/arch/sparc/kernel/of_device_common.c b/arch/sparc/kernel/of_device_common.c
index 3241f56331c2..de0ee3971f00 100644
--- a/arch/sparc/kernel/of_device_common.c
+++ b/arch/sparc/kernel/of_device_common.c
@@ -5,8 +5,10 @@
5#include <linux/mod_devicetable.h> 5#include <linux/mod_devicetable.h>
6#include <linux/errno.h> 6#include <linux/errno.h>
7#include <linux/irq.h> 7#include <linux/irq.h>
8#include <linux/of_device.h>
9#include <linux/of_platform.h> 8#include <linux/of_platform.h>
9#include <linux/of_address.h>
10#include <linux/of_device.h>
11#include <linux/of_irq.h>
10 12
11#include "of_device_common.h" 13#include "of_device_common.h"
12 14
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 857ad77df9c0..539babf00bb2 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -28,6 +28,7 @@
28#include <asm/apb.h> 28#include <asm/apb.h>
29 29
30#include "pci_impl.h" 30#include "pci_impl.h"
31#include "kernel.h"
31 32
32/* List of all PCI controllers found in the system. */ 33/* List of all PCI controllers found in the system. */
33struct pci_pbm_info *pci_pbm_root = NULL; 34struct pci_pbm_info *pci_pbm_root = NULL;
diff --git a/arch/sparc/kernel/pci_impl.h b/arch/sparc/kernel/pci_impl.h
index 5f688531f48c..75803c780af3 100644
--- a/arch/sparc/kernel/pci_impl.h
+++ b/arch/sparc/kernel/pci_impl.h
@@ -48,8 +48,8 @@ struct sparc64_msiq_ops {
48 unsigned long devino); 48 unsigned long devino);
49}; 49};
50 50
51extern void sparc64_pbm_msi_init(struct pci_pbm_info *pbm, 51void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
52 const struct sparc64_msiq_ops *ops); 52 const struct sparc64_msiq_ops *ops);
53 53
54struct sparc64_msiq_cookie { 54struct sparc64_msiq_cookie {
55 struct pci_pbm_info *pbm; 55 struct pci_pbm_info *pbm;
@@ -158,23 +158,23 @@ extern struct pci_pbm_info *pci_pbm_root;
158extern int pci_num_pbms; 158extern int pci_num_pbms;
159 159
160/* PCI bus scanning and fixup support. */ 160/* PCI bus scanning and fixup support. */
161extern void pci_get_pbm_props(struct pci_pbm_info *pbm); 161void pci_get_pbm_props(struct pci_pbm_info *pbm);
162extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, 162struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
163 struct device *parent); 163 struct device *parent);
164extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm); 164void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
165 165
166/* Error reporting support. */ 166/* Error reporting support. */
167extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *); 167void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
168extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *); 168void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
169extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *); 169void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
170 170
171/* Configuration space access. */ 171/* Configuration space access. */
172extern void pci_config_read8(u8 *addr, u8 *ret); 172void pci_config_read8(u8 *addr, u8 *ret);
173extern void pci_config_read16(u16 *addr, u16 *ret); 173void pci_config_read16(u16 *addr, u16 *ret);
174extern void pci_config_read32(u32 *addr, u32 *ret); 174void pci_config_read32(u32 *addr, u32 *ret);
175extern void pci_config_write8(u8 *addr, u8 val); 175void pci_config_write8(u8 *addr, u8 val);
176extern void pci_config_write16(u16 *addr, u16 val); 176void pci_config_write16(u16 *addr, u16 val);
177extern void pci_config_write32(u32 *addr, u32 val); 177void pci_config_write32(u32 *addr, u32 val);
178 178
179extern struct pci_ops sun4u_pci_ops; 179extern struct pci_ops sun4u_pci_ops;
180extern struct pci_ops sun4v_pci_ops; 180extern struct pci_ops sun4v_pci_ops;
diff --git a/arch/sparc/kernel/pci_sun4v.h b/arch/sparc/kernel/pci_sun4v.h
index 8e9fc3a5b4f5..5642212390b2 100644
--- a/arch/sparc/kernel/pci_sun4v.h
+++ b/arch/sparc/kernel/pci_sun4v.h
@@ -6,87 +6,87 @@
6#ifndef _PCI_SUN4V_H 6#ifndef _PCI_SUN4V_H
7#define _PCI_SUN4V_H 7#define _PCI_SUN4V_H
8 8
9extern long pci_sun4v_iommu_map(unsigned long devhandle, 9long pci_sun4v_iommu_map(unsigned long devhandle,
10 unsigned long tsbid, 10 unsigned long tsbid,
11 unsigned long num_ttes, 11 unsigned long num_ttes,
12 unsigned long io_attributes, 12 unsigned long io_attributes,
13 unsigned long io_page_list_pa); 13 unsigned long io_page_list_pa);
14extern unsigned long pci_sun4v_iommu_demap(unsigned long devhandle, 14unsigned long pci_sun4v_iommu_demap(unsigned long devhandle,
15 unsigned long tsbid, 15 unsigned long tsbid,
16 unsigned long num_ttes); 16 unsigned long num_ttes);
17extern unsigned long pci_sun4v_iommu_getmap(unsigned long devhandle, 17unsigned long pci_sun4v_iommu_getmap(unsigned long devhandle,
18 unsigned long tsbid, 18 unsigned long tsbid,
19 unsigned long *io_attributes, 19 unsigned long *io_attributes,
20 unsigned long *real_address); 20 unsigned long *real_address);
21extern unsigned long pci_sun4v_config_get(unsigned long devhandle, 21unsigned long pci_sun4v_config_get(unsigned long devhandle,
22 unsigned long pci_device, 22 unsigned long pci_device,
23 unsigned long config_offset, 23 unsigned long config_offset,
24 unsigned long size); 24 unsigned long size);
25extern int pci_sun4v_config_put(unsigned long devhandle, 25int pci_sun4v_config_put(unsigned long devhandle,
26 unsigned long pci_device, 26 unsigned long pci_device,
27 unsigned long config_offset, 27 unsigned long config_offset,
28 unsigned long size, 28 unsigned long size,
29 unsigned long data); 29 unsigned long data);
30 30
31extern unsigned long pci_sun4v_msiq_conf(unsigned long devhandle, 31unsigned long pci_sun4v_msiq_conf(unsigned long devhandle,
32 unsigned long msiqid, 32 unsigned long msiqid,
33 unsigned long msiq_paddr, 33 unsigned long msiq_paddr,
34 unsigned long num_entries); 34 unsigned long num_entries);
35extern unsigned long pci_sun4v_msiq_info(unsigned long devhandle, 35unsigned long pci_sun4v_msiq_info(unsigned long devhandle,
36 unsigned long msiqid, 36 unsigned long msiqid,
37 unsigned long *msiq_paddr, 37 unsigned long *msiq_paddr,
38 unsigned long *num_entries); 38 unsigned long *num_entries);
39extern unsigned long pci_sun4v_msiq_getvalid(unsigned long devhandle, 39unsigned long pci_sun4v_msiq_getvalid(unsigned long devhandle,
40 unsigned long msiqid, 40 unsigned long msiqid,
41 unsigned long *valid); 41 unsigned long *valid);
42extern unsigned long pci_sun4v_msiq_setvalid(unsigned long devhandle, 42unsigned long pci_sun4v_msiq_setvalid(unsigned long devhandle,
43 unsigned long msiqid, 43 unsigned long msiqid,
44 unsigned long valid); 44 unsigned long valid);
45extern unsigned long pci_sun4v_msiq_getstate(unsigned long devhandle, 45unsigned long pci_sun4v_msiq_getstate(unsigned long devhandle,
46 unsigned long msiqid, 46 unsigned long msiqid,
47 unsigned long *state); 47 unsigned long *state);
48extern unsigned long pci_sun4v_msiq_setstate(unsigned long devhandle, 48unsigned long pci_sun4v_msiq_setstate(unsigned long devhandle,
49 unsigned long msiqid, 49 unsigned long msiqid,
50 unsigned long state); 50 unsigned long state);
51extern unsigned long pci_sun4v_msiq_gethead(unsigned long devhandle, 51unsigned long pci_sun4v_msiq_gethead(unsigned long devhandle,
52 unsigned long msiqid, 52 unsigned long msiqid,
53 unsigned long *head); 53 unsigned long *head);
54extern unsigned long pci_sun4v_msiq_sethead(unsigned long devhandle, 54unsigned long pci_sun4v_msiq_sethead(unsigned long devhandle,
55 unsigned long msiqid, 55 unsigned long msiqid,
56 unsigned long head); 56 unsigned long head);
57extern unsigned long pci_sun4v_msiq_gettail(unsigned long devhandle, 57unsigned long pci_sun4v_msiq_gettail(unsigned long devhandle,
58 unsigned long msiqid, 58 unsigned long msiqid,
59 unsigned long *head); 59 unsigned long *head);
60extern unsigned long pci_sun4v_msi_getvalid(unsigned long devhandle, 60unsigned long pci_sun4v_msi_getvalid(unsigned long devhandle,
61 unsigned long msinum, 61 unsigned long msinum,
62 unsigned long *valid); 62 unsigned long *valid);
63extern unsigned long pci_sun4v_msi_setvalid(unsigned long devhandle, 63unsigned long pci_sun4v_msi_setvalid(unsigned long devhandle,
64 unsigned long msinum, 64 unsigned long msinum,
65 unsigned long valid); 65 unsigned long valid);
66extern unsigned long pci_sun4v_msi_getmsiq(unsigned long devhandle, 66unsigned long pci_sun4v_msi_getmsiq(unsigned long devhandle,
67 unsigned long msinum, 67 unsigned long msinum,
68 unsigned long *msiq); 68 unsigned long *msiq);
69extern unsigned long pci_sun4v_msi_setmsiq(unsigned long devhandle, 69unsigned long pci_sun4v_msi_setmsiq(unsigned long devhandle,
70 unsigned long msinum, 70 unsigned long msinum,
71 unsigned long msiq, 71 unsigned long msiq,
72 unsigned long msitype); 72 unsigned long msitype);
73extern unsigned long pci_sun4v_msi_getstate(unsigned long devhandle, 73unsigned long pci_sun4v_msi_getstate(unsigned long devhandle,
74 unsigned long msinum, 74 unsigned long msinum,
75 unsigned long *state); 75 unsigned long *state);
76extern unsigned long pci_sun4v_msi_setstate(unsigned long devhandle, 76unsigned long pci_sun4v_msi_setstate(unsigned long devhandle,
77 unsigned long msinum, 77 unsigned long msinum,
78 unsigned long state); 78 unsigned long state);
79extern unsigned long pci_sun4v_msg_getmsiq(unsigned long devhandle, 79unsigned long pci_sun4v_msg_getmsiq(unsigned long devhandle,
80 unsigned long msinum, 80 unsigned long msinum,
81 unsigned long *msiq); 81 unsigned long *msiq);
82extern unsigned long pci_sun4v_msg_setmsiq(unsigned long devhandle, 82unsigned long pci_sun4v_msg_setmsiq(unsigned long devhandle,
83 unsigned long msinum, 83 unsigned long msinum,
84 unsigned long msiq); 84 unsigned long msiq);
85extern unsigned long pci_sun4v_msg_getvalid(unsigned long devhandle, 85unsigned long pci_sun4v_msg_getvalid(unsigned long devhandle,
86 unsigned long msinum, 86 unsigned long msinum,
87 unsigned long *valid); 87 unsigned long *valid);
88extern unsigned long pci_sun4v_msg_setvalid(unsigned long devhandle, 88unsigned long pci_sun4v_msg_setvalid(unsigned long devhandle,
89 unsigned long msinum, 89 unsigned long msinum,
90 unsigned long valid); 90 unsigned long valid);
91 91
92#endif /* !(_PCI_SUN4V_H) */ 92#endif /* !(_PCI_SUN4V_H) */
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 09f4fdd8d808..6cc78c213c01 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -36,6 +36,7 @@
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <asm/irq_regs.h> 37#include <asm/irq_regs.h>
38 38
39#include "kernel.h"
39#include "irq.h" 40#include "irq.h"
40 41
41/* 42/*
@@ -162,8 +163,8 @@ static int pcic0_up;
162static struct linux_pcic pcic0; 163static struct linux_pcic pcic0;
163 164
164void __iomem *pcic_regs; 165void __iomem *pcic_regs;
165volatile int pcic_speculative; 166static volatile int pcic_speculative;
166volatile int pcic_trapped; 167static volatile int pcic_trapped;
167 168
168/* forward */ 169/* forward */
169unsigned int pcic_build_device_irq(struct platform_device *op, 170unsigned int pcic_build_device_irq(struct platform_device *op,
@@ -329,7 +330,7 @@ int __init pcic_probe(void)
329 330
330 pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr"; 331 pcic->pcic_res_cfg_addr.name = "pcic_cfg_addr";
331 if ((pcic->pcic_config_space_addr = 332 if ((pcic->pcic_config_space_addr =
332 ioremap(regs[2].phys_addr, regs[2].reg_size * 2)) == 0) { 333 ioremap(regs[2].phys_addr, regs[2].reg_size * 2)) == NULL) {
333 prom_printf("PCIC: Error, cannot map " 334 prom_printf("PCIC: Error, cannot map "
334 "PCI Configuration Space Address.\n"); 335 "PCI Configuration Space Address.\n");
335 prom_halt(); 336 prom_halt();
@@ -341,7 +342,7 @@ int __init pcic_probe(void)
341 */ 342 */
342 pcic->pcic_res_cfg_data.name = "pcic_cfg_data"; 343 pcic->pcic_res_cfg_data.name = "pcic_cfg_data";
343 if ((pcic->pcic_config_space_data = 344 if ((pcic->pcic_config_space_data =
344 ioremap(regs[3].phys_addr, regs[3].reg_size * 2)) == 0) { 345 ioremap(regs[3].phys_addr, regs[3].reg_size * 2)) == NULL) {
345 prom_printf("PCIC: Error, cannot map " 346 prom_printf("PCIC: Error, cannot map "
346 "PCI Configuration Space Data.\n"); 347 "PCI Configuration Space Data.\n");
347 prom_halt(); 348 prom_halt();
@@ -353,7 +354,6 @@ int __init pcic_probe(void)
353 strcpy(pbm->prom_name, namebuf); 354 strcpy(pbm->prom_name, namebuf);
354 355
355 { 356 {
356 extern volatile int t_nmi[4];
357 extern int pcic_nmi_trap_patch[4]; 357 extern int pcic_nmi_trap_patch[4];
358 358
359 t_nmi[0] = pcic_nmi_trap_patch[0]; 359 t_nmi[0] = pcic_nmi_trap_patch[0];
@@ -536,7 +536,7 @@ pcic_fill_irq(struct linux_pcic *pcic, struct pci_dev *dev, int node)
536 prom_getstring(node, "name", namebuf, sizeof(namebuf)); 536 prom_getstring(node, "name", namebuf, sizeof(namebuf));
537 } 537 }
538 538
539 if ((p = pcic->pcic_imap) == 0) { 539 if ((p = pcic->pcic_imap) == NULL) {
540 dev->irq = 0; 540 dev->irq = 0;
541 return; 541 return;
542 } 542 }
@@ -670,30 +670,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
670 } 670 }
671} 671}
672 672
673/*
674 * pcic_pin_to_irq() is exported to bus probing code
675 */
676unsigned int
677pcic_pin_to_irq(unsigned int pin, const char *name)
678{
679 struct linux_pcic *pcic = &pcic0;
680 unsigned int irq;
681 unsigned int ivec;
682
683 if (pin < 4) {
684 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_LO);
685 irq = ivec >> (pin << 2) & 0xF;
686 } else if (pin < 8) {
687 ivec = readw(pcic->pcic_regs+PCI_INT_SELECT_HI);
688 irq = ivec >> ((pin-4) << 2) & 0xF;
689 } else { /* Corrupted map */
690 printk("PCIC: BAD PIN %d FOR %s\n", pin, name);
691 for (;;) {} /* XXX Cannot panic properly in case of PROLL */
692 }
693/* P3 */ /* printk("PCIC: dev %s pin %d ivec 0x%x irq %x\n", name, pin, ivec, irq); */
694 return irq;
695}
696
697/* Makes compiler happy */ 673/* Makes compiler happy */
698static volatile int pcic_timer_dummy; 674static volatile int pcic_timer_dummy;
699 675
@@ -783,7 +759,7 @@ int pcibios_enable_device(struct pci_dev *pdev, int mask)
783void pcic_nmi(unsigned int pend, struct pt_regs *regs) 759void pcic_nmi(unsigned int pend, struct pt_regs *regs)
784{ 760{
785 761
786 pend = flip_dword(pend); 762 pend = swab32(pend);
787 763
788 if (!pcic_speculative || (pend & PCI_SYS_INT_PENDING_PIO) == 0) { 764 if (!pcic_speculative || (pend & PCI_SYS_INT_PENDING_PIO) == 0) {
789 /* 765 /*
@@ -875,82 +851,4 @@ void __init sun4m_pci_init_IRQ(void)
875 sparc_config.load_profile_irq = pcic_load_profile_irq; 851 sparc_config.load_profile_irq = pcic_load_profile_irq;
876} 852}
877 853
878/*
879 * This probably belongs here rather than ioport.c because
880 * we do not want this crud linked into SBus kernels.
881 * Also, think for a moment about likes of floppy.c that
882 * include architecture specific parts. They may want to redefine ins/outs.
883 *
884 * We do not use horrible macros here because we want to
885 * advance pointer by sizeof(size).
886 */
887void outsb(unsigned long addr, const void *src, unsigned long count)
888{
889 while (count) {
890 count -= 1;
891 outb(*(const char *)src, addr);
892 src += 1;
893 /* addr += 1; */
894 }
895}
896EXPORT_SYMBOL(outsb);
897
898void outsw(unsigned long addr, const void *src, unsigned long count)
899{
900 while (count) {
901 count -= 2;
902 outw(*(const short *)src, addr);
903 src += 2;
904 /* addr += 2; */
905 }
906}
907EXPORT_SYMBOL(outsw);
908
909void outsl(unsigned long addr, const void *src, unsigned long count)
910{
911 while (count) {
912 count -= 4;
913 outl(*(const long *)src, addr);
914 src += 4;
915 /* addr += 4; */
916 }
917}
918EXPORT_SYMBOL(outsl);
919
920void insb(unsigned long addr, void *dst, unsigned long count)
921{
922 while (count) {
923 count -= 1;
924 *(unsigned char *)dst = inb(addr);
925 dst += 1;
926 /* addr += 1; */
927 }
928}
929EXPORT_SYMBOL(insb);
930
931void insw(unsigned long addr, void *dst, unsigned long count)
932{
933 while (count) {
934 count -= 2;
935 *(unsigned short *)dst = inw(addr);
936 dst += 2;
937 /* addr += 2; */
938 }
939}
940EXPORT_SYMBOL(insw);
941
942void insl(unsigned long addr, void *dst, unsigned long count)
943{
944 while (count) {
945 count -= 4;
946 /*
947 * XXX I am sure we are in for an unaligned trap here.
948 */
949 *(unsigned long *)dst = inl(addr);
950 dst += 4;
951 /* addr += 4; */
952 }
953}
954EXPORT_SYMBOL(insl);
955
956subsys_initcall(pcic_init); 854subsys_initcall(pcic_init);
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index b5c38faa4ead..8efd33753ad3 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -110,7 +110,7 @@ struct cpu_hw_events {
110 110
111 unsigned int group_flag; 111 unsigned int group_flag;
112}; 112};
113DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, }; 113static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = { .enabled = 1, };
114 114
115/* An event map describes the characteristics of a performance 115/* An event map describes the characteristics of a performance
116 * counter event. In particular it gives the encoding as well as 116 * counter event. In particular it gives the encoding as well as
@@ -1153,7 +1153,7 @@ static void perf_stop_nmi_watchdog(void *unused)
1153 cpuc->pcr[i] = pcr_ops->read_pcr(i); 1153 cpuc->pcr[i] = pcr_ops->read_pcr(i);
1154} 1154}
1155 1155
1156void perf_event_grab_pmc(void) 1156static void perf_event_grab_pmc(void)
1157{ 1157{
1158 if (atomic_inc_not_zero(&active_events)) 1158 if (atomic_inc_not_zero(&active_events))
1159 return; 1159 return;
@@ -1169,7 +1169,7 @@ void perf_event_grab_pmc(void)
1169 mutex_unlock(&pmc_grab_mutex); 1169 mutex_unlock(&pmc_grab_mutex);
1170} 1170}
1171 1171
1172void perf_event_release_pmc(void) 1172static void perf_event_release_pmc(void)
1173{ 1173{
1174 if (atomic_dec_and_mutex_lock(&active_events, &pmc_grab_mutex)) { 1174 if (atomic_dec_and_mutex_lock(&active_events, &pmc_grab_mutex)) {
1175 if (atomic_read(&nmi_active) == 0) 1175 if (atomic_read(&nmi_active) == 0)
@@ -1669,7 +1669,7 @@ static bool __init supported_pmu(void)
1669 return false; 1669 return false;
1670} 1670}
1671 1671
1672int __init init_hw_perf_events(void) 1672static int __init init_hw_perf_events(void)
1673{ 1673{
1674 pr_info("Performance events: "); 1674 pr_info("Performance events: ");
1675 1675
@@ -1742,10 +1742,11 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
1742 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 __user *usf;
1746 struct sparc_stackf sf;
1746 unsigned long pc; 1747 unsigned long pc;
1747 1748
1748 usf = (struct sparc_stackf *) ufp; 1749 usf = (struct sparc_stackf __user *)ufp;
1749 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf))) 1750 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf)))
1750 break; 1751 break;
1751 1752
@@ -1765,17 +1766,19 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
1765 unsigned long pc; 1766 unsigned long pc;
1766 1767
1767 if (thread32_stack_is_64bit(ufp)) { 1768 if (thread32_stack_is_64bit(ufp)) {
1768 struct sparc_stackf *usf, sf; 1769 struct sparc_stackf __user *usf;
1770 struct sparc_stackf sf;
1769 1771
1770 ufp += STACK_BIAS; 1772 ufp += STACK_BIAS;
1771 usf = (struct sparc_stackf *) ufp; 1773 usf = (struct sparc_stackf __user *)ufp;
1772 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf))) 1774 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf)))
1773 break; 1775 break;
1774 pc = sf.callers_pc & 0xffffffff; 1776 pc = sf.callers_pc & 0xffffffff;
1775 ufp = ((unsigned long) sf.fp) & 0xffffffff; 1777 ufp = ((unsigned long) sf.fp) & 0xffffffff;
1776 } else { 1778 } else {
1777 struct sparc_stackf32 *usf, sf; 1779 struct sparc_stackf32 __user *usf;
1778 usf = (struct sparc_stackf32 *) ufp; 1780 struct sparc_stackf32 sf;
1781 usf = (struct sparc_stackf32 __user *)ufp;
1779 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf))) 1782 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf)))
1780 break; 1783 break;
1781 pc = sf.callers_pc; 1784 pc = sf.callers_pc;
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 510baec1b69b..50e7b626afe8 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -10,6 +10,7 @@
10 10
11#include <stdarg.h> 11#include <stdarg.h>
12 12
13#include <linux/elfcore.h>
13#include <linux/errno.h> 14#include <linux/errno.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
@@ -23,6 +24,7 @@
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include <linux/pm.h> 25#include <linux/pm.h>
25#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/cpu.h>
26 28
27#include <asm/auxio.h> 29#include <asm/auxio.h>
28#include <asm/oplib.h> 30#include <asm/oplib.h>
@@ -38,6 +40,8 @@
38#include <asm/unistd.h> 40#include <asm/unistd.h>
39#include <asm/setup.h> 41#include <asm/setup.h>
40 42
43#include "kernel.h"
44
41/* 45/*
42 * Power management idle function 46 * Power management idle function
43 * Set in pm platform drivers (apc.c and pmc.c) 47 * Set in pm platform drivers (apc.c and pmc.c)
@@ -102,8 +106,12 @@ void machine_restart(char * cmd)
102void machine_power_off(void) 106void machine_power_off(void)
103{ 107{
104 if (auxio_power_register && 108 if (auxio_power_register &&
105 (strcmp(of_console_device->type, "serial") || scons_pwroff)) 109 (strcmp(of_console_device->type, "serial") || scons_pwroff)) {
106 *auxio_power_register |= AUXIO_POWER_OFF; 110 u8 power_register = sbus_readb(auxio_power_register);
111 power_register |= AUXIO_POWER_OFF;
112 sbus_writeb(power_register, auxio_power_register);
113 }
114
107 machine_halt(); 115 machine_halt();
108} 116}
109 117
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index d7b4967f8fa6..b2988f25e230 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -88,7 +88,7 @@ void arch_cpu_idle(void)
88} 88}
89 89
90#ifdef CONFIG_HOTPLUG_CPU 90#ifdef CONFIG_HOTPLUG_CPU
91void arch_cpu_idle_dead() 91void arch_cpu_idle_dead(void)
92{ 92{
93 sched_preempt_enable_no_resched(); 93 sched_preempt_enable_no_resched();
94 cpu_play_dead(); 94 cpu_play_dead();
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index cf5fe1c0b024..890281b12b28 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -4,7 +4,7 @@
4#include <linux/spinlock.h> 4#include <linux/spinlock.h>
5#include <asm/prom.h> 5#include <asm/prom.h>
6 6
7extern void of_console_init(void); 7void of_console_init(void);
8 8
9extern unsigned int prom_early_allocated; 9extern unsigned int prom_early_allocated;
10 10
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index 9a690d39c01b..20cc5d80a471 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -15,11 +15,12 @@
15 * 2 of the License, or (at your option) any later version. 15 * 2 of the License, or (at your option) any later version.
16 */ 16 */
17 17
18#include <linux/memblock.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/types.h>
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/types.h>
22#include <linux/cpu.h>
21#include <linux/mm.h> 23#include <linux/mm.h>
22#include <linux/memblock.h>
23#include <linux/of.h> 24#include <linux/of.h>
24 25
25#include <asm/prom.h> 26#include <asm/prom.h>
diff --git a/arch/sparc/kernel/psycho_common.h b/arch/sparc/kernel/psycho_common.h
index 590b4ed8ab5e..05a6e30a928e 100644
--- a/arch/sparc/kernel/psycho_common.h
+++ b/arch/sparc/kernel/psycho_common.h
@@ -30,19 +30,19 @@ enum psycho_error_type {
30 UE_ERR, CE_ERR, PCI_ERR 30 UE_ERR, CE_ERR, PCI_ERR
31}; 31};
32 32
33extern void psycho_check_iommu_error(struct pci_pbm_info *pbm, 33void psycho_check_iommu_error(struct pci_pbm_info *pbm,
34 unsigned long afsr, 34 unsigned long afsr,
35 unsigned long afar, 35 unsigned long afar,
36 enum psycho_error_type type); 36 enum psycho_error_type type);
37 37
38extern irqreturn_t psycho_pcierr_intr(int irq, void *dev_id); 38irqreturn_t psycho_pcierr_intr(int irq, void *dev_id);
39 39
40extern int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize, 40int psycho_iommu_init(struct pci_pbm_info *pbm, int tsbsize,
41 u32 dvma_offset, u32 dma_mask, 41 u32 dvma_offset, u32 dma_mask,
42 unsigned long write_complete_offset); 42 unsigned long write_complete_offset);
43 43
44extern void psycho_pbm_init_common(struct pci_pbm_info *pbm, 44void psycho_pbm_init_common(struct pci_pbm_info *pbm,
45 struct platform_device *op, 45 struct platform_device *op,
46 const char *chip_name, int chip_type); 46 const char *chip_name, int chip_type);
47 47
48#endif /* _PSYCHO_COMMON_H */ 48#endif /* _PSYCHO_COMMON_H */
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
index 896ba7c5cd8e..a331fdc11a2c 100644
--- a/arch/sparc/kernel/ptrace_32.c
+++ b/arch/sparc/kernel/ptrace_32.c
@@ -26,6 +26,8 @@
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
28 28
29#include "kernel.h"
30
29/* #define ALLOW_INIT_TRACING */ 31/* #define ALLOW_INIT_TRACING */
30 32
31/* 33/*
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 1434526970a6..baef495c06bd 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -267,7 +267,7 @@ static __init void leon_patch(void)
267} 267}
268 268
269struct tt_entry *sparc_ttable; 269struct tt_entry *sparc_ttable;
270struct pt_regs fake_swapper_regs; 270static struct pt_regs fake_swapper_regs;
271 271
272/* Called from head_32.S - before we have setup anything 272/* Called from head_32.S - before we have setup anything
273 * in the kernel. Be very careful with what you do here. 273 * in the kernel. Be very careful with what you do here.
@@ -365,7 +365,7 @@ void __init setup_arch(char **cmdline_p)
365 365
366 prom_setsync(prom_sync_me); 366 prom_setsync(prom_sync_me);
367 367
368 if((boot_flags&BOOTME_DEBUG) && (linux_dbvec!=0) && 368 if((boot_flags & BOOTME_DEBUG) && (linux_dbvec != NULL) &&
369 ((*(short *)linux_dbvec) != -1)) { 369 ((*(short *)linux_dbvec) != -1)) {
370 printk("Booted under KADB. Syncing trap table.\n"); 370 printk("Booted under KADB. Syncing trap table.\n");
371 (*(linux_dbvec->teach_debugger))(); 371 (*(linux_dbvec->teach_debugger))();
diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c
index ee789d2ef05d..62deba7be1a9 100644
--- a/arch/sparc/kernel/signal32.c
+++ b/arch/sparc/kernel/signal32.c
@@ -31,6 +31,7 @@
31#include <asm/switch_to.h> 31#include <asm/switch_to.h>
32 32
33#include "sigutil.h" 33#include "sigutil.h"
34#include "kernel.h"
34 35
35/* This magic should be in g_upper[0] for all upper parts 36/* This magic should be in g_upper[0] for all upper parts
36 * to be valid. 37 * to be valid.
@@ -145,7 +146,7 @@ void do_sigreturn32(struct pt_regs *regs)
145 unsigned int psr; 146 unsigned int psr;
146 unsigned pc, npc; 147 unsigned pc, npc;
147 sigset_t set; 148 sigset_t set;
148 unsigned seta[_COMPAT_NSIG_WORDS]; 149 compat_sigset_t seta;
149 int err, i; 150 int err, i;
150 151
151 /* Always make any pending restarted system calls return -EINTR */ 152 /* Always make any pending restarted system calls return -EINTR */
@@ -209,17 +210,13 @@ void do_sigreturn32(struct pt_regs *regs)
209 if (restore_rwin_state(compat_ptr(rwin_save))) 210 if (restore_rwin_state(compat_ptr(rwin_save)))
210 goto segv; 211 goto segv;
211 } 212 }
212 err |= __get_user(seta[0], &sf->info.si_mask); 213 err |= __get_user(seta.sig[0], &sf->info.si_mask);
213 err |= copy_from_user(seta+1, &sf->extramask, 214 err |= copy_from_user(&seta.sig[1], &sf->extramask,
214 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); 215 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
215 if (err) 216 if (err)
216 goto segv; 217 goto segv;
217 switch (_NSIG_WORDS) { 218
218 case 4: set.sig[3] = seta[6] + (((long)seta[7]) << 32); 219 set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
219 case 3: set.sig[2] = seta[4] + (((long)seta[5]) << 32);
220 case 2: set.sig[1] = seta[2] + (((long)seta[3]) << 32);
221 case 1: set.sig[0] = seta[0] + (((long)seta[1]) << 32);
222 }
223 set_current_blocked(&set); 220 set_current_blocked(&set);
224 return; 221 return;
225 222
@@ -303,12 +300,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
303 goto segv; 300 goto segv;
304 } 301 }
305 302
306 switch (_NSIG_WORDS) { 303 set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
307 case 4: set.sig[3] = seta.sig[6] + (((long)seta.sig[7]) << 32);
308 case 3: set.sig[2] = seta.sig[4] + (((long)seta.sig[5]) << 32);
309 case 2: set.sig[1] = seta.sig[2] + (((long)seta.sig[3]) << 32);
310 case 1: set.sig[0] = seta.sig[0] + (((long)seta.sig[1]) << 32);
311 }
312 set_current_blocked(&set); 304 set_current_blocked(&set);
313 return; 305 return;
314segv: 306segv:
@@ -417,7 +409,7 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs,
417 void __user *tail; 409 void __user *tail;
418 int sigframe_size; 410 int sigframe_size;
419 u32 psr; 411 u32 psr;
420 unsigned int seta[_COMPAT_NSIG_WORDS]; 412 compat_sigset_t seta;
421 413
422 /* 1. Make sure everything is clean */ 414 /* 1. Make sure everything is clean */
423 synchronize_user_stack(); 415 synchronize_user_stack();
@@ -481,18 +473,14 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs,
481 err |= __put_user(0, &sf->rwin_save); 473 err |= __put_user(0, &sf->rwin_save);
482 } 474 }
483 475
484 switch (_NSIG_WORDS) { 476 /* If these change we need to know - assignments to seta relies on these sizes */
485 case 4: seta[7] = (oldset->sig[3] >> 32); 477 BUILD_BUG_ON(_NSIG_WORDS != 1);
486 seta[6] = oldset->sig[3]; 478 BUILD_BUG_ON(_COMPAT_NSIG_WORDS != 2);
487 case 3: seta[5] = (oldset->sig[2] >> 32); 479 seta.sig[1] = (oldset->sig[0] >> 32);
488 seta[4] = oldset->sig[2]; 480 seta.sig[0] = oldset->sig[0];
489 case 2: seta[3] = (oldset->sig[1] >> 32); 481
490 seta[2] = oldset->sig[1]; 482 err |= __put_user(seta.sig[0], &sf->info.si_mask);
491 case 1: seta[1] = (oldset->sig[0] >> 32); 483 err |= __copy_to_user(sf->extramask, &seta.sig[1],
492 seta[0] = oldset->sig[0];
493 }
494 err |= __put_user(seta[0], &sf->info.si_mask);
495 err |= __copy_to_user(sf->extramask, seta + 1,
496 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int)); 484 (_COMPAT_NSIG_WORDS - 1) * sizeof(unsigned int));
497 485
498 if (!wsaved) { 486 if (!wsaved) {
@@ -622,16 +610,8 @@ static int setup_rt_frame32(struct ksignal *ksig, struct pt_regs *regs,
622 /* Setup sigaltstack */ 610 /* Setup sigaltstack */
623 err |= __compat_save_altstack(&sf->stack, regs->u_regs[UREG_FP]); 611 err |= __compat_save_altstack(&sf->stack, regs->u_regs[UREG_FP]);
624 612
625 switch (_NSIG_WORDS) { 613 seta.sig[1] = (oldset->sig[0] >> 32);
626 case 4: seta.sig[7] = (oldset->sig[3] >> 32); 614 seta.sig[0] = oldset->sig[0];
627 seta.sig[6] = oldset->sig[3];
628 case 3: seta.sig[5] = (oldset->sig[2] >> 32);
629 seta.sig[4] = oldset->sig[2];
630 case 2: seta.sig[3] = (oldset->sig[1] >> 32);
631 seta.sig[2] = oldset->sig[1];
632 case 1: seta.sig[1] = (oldset->sig[0] >> 32);
633 seta.sig[0] = oldset->sig[0];
634 }
635 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t)); 615 err |= __copy_to_user(&sf->mask, &seta, sizeof(compat_sigset_t));
636 616
637 if (!wsaved) { 617 if (!wsaved) {
diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c
index 7d5d8e1f8415..9ee72fc8e0e4 100644
--- a/arch/sparc/kernel/signal_32.c
+++ b/arch/sparc/kernel/signal_32.c
@@ -28,6 +28,7 @@
28#include <asm/switch_to.h> 28#include <asm/switch_to.h>
29 29
30#include "sigutil.h" 30#include "sigutil.h"
31#include "kernel.h"
31 32
32extern void fpsave(unsigned long *fpregs, unsigned long *fsr, 33extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
33 void *fpqueue, unsigned long *fpqdepth); 34 void *fpqueue, unsigned long *fpqdepth);
@@ -341,7 +342,7 @@ static int setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs,
341 err |= __put_user(0, &sf->extra_size); 342 err |= __put_user(0, &sf->extra_size);
342 343
343 if (psr & PSR_EF) { 344 if (psr & PSR_EF) {
344 __siginfo_fpu_t *fp = tail; 345 __siginfo_fpu_t __user *fp = tail;
345 tail += sizeof(*fp); 346 tail += sizeof(*fp);
346 err |= save_fpu_state(regs, fp); 347 err |= save_fpu_state(regs, fp);
347 err |= __put_user(fp, &sf->fpu_save); 348 err |= __put_user(fp, &sf->fpu_save);
@@ -349,7 +350,7 @@ static int setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs,
349 err |= __put_user(0, &sf->fpu_save); 350 err |= __put_user(0, &sf->fpu_save);
350 } 351 }
351 if (wsaved) { 352 if (wsaved) {
352 __siginfo_rwin_t *rwp = tail; 353 __siginfo_rwin_t __user *rwp = tail;
353 tail += sizeof(*rwp); 354 tail += sizeof(*rwp);
354 err |= save_rwin_state(wsaved, rwp); 355 err |= save_rwin_state(wsaved, rwp);
355 err |= __put_user(rwp, &sf->rwin_save); 356 err |= __put_user(rwp, &sf->rwin_save);
@@ -517,9 +518,9 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
517 } 518 }
518} 519}
519 520
520asmlinkage int 521asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
521do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr, 522 struct sigstack __user *ossptr,
522 unsigned long sp) 523 unsigned long sp)
523{ 524{
524 int ret = -EFAULT; 525 int ret = -EFAULT;
525 526
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index cd91d010e6d3..1a6999868031 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -35,9 +35,10 @@
35#include <asm/switch_to.h> 35#include <asm/switch_to.h>
36#include <asm/cacheflush.h> 36#include <asm/cacheflush.h>
37 37
38#include "entry.h"
39#include "systbls.h"
40#include "sigutil.h" 38#include "sigutil.h"
39#include "systbls.h"
40#include "kernel.h"
41#include "entry.h"
41 42
42/* {set, get}context() needed for 64-bit SparcLinux userland. */ 43/* {set, get}context() needed for 64-bit SparcLinux userland. */
43asmlinkage void sparc64_set_context(struct pt_regs *regs) 44asmlinkage void sparc64_set_context(struct pt_regs *regs)
@@ -492,7 +493,6 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
492 493
493#ifdef CONFIG_COMPAT 494#ifdef CONFIG_COMPAT
494 if (test_thread_flag(TIF_32BIT)) { 495 if (test_thread_flag(TIF_32BIT)) {
495 extern void do_signal32(struct pt_regs *);
496 do_signal32(regs); 496 do_signal32(regs);
497 return; 497 return;
498 } 498 }
diff --git a/arch/sparc/kernel/smp_32.c b/arch/sparc/kernel/smp_32.c
index a102bfba6ea8..7958242d63c5 100644
--- a/arch/sparc/kernel/smp_32.c
+++ b/arch/sparc/kernel/smp_32.c
@@ -20,6 +20,7 @@
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/cache.h> 21#include <linux/cache.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/profile.h>
23#include <linux/cpu.h> 24#include <linux/cpu.h>
24 25
25#include <asm/ptrace.h> 26#include <asm/ptrace.h>
@@ -75,8 +76,6 @@ void smp_store_cpu_info(int id)
75 76
76void __init smp_cpus_done(unsigned int max_cpus) 77void __init smp_cpus_done(unsigned int max_cpus)
77{ 78{
78 extern void smp4m_smp_done(void);
79 extern void smp4d_smp_done(void);
80 unsigned long bogosum = 0; 79 unsigned long bogosum = 0;
81 int cpu, num = 0; 80 int cpu, num = 0;
82 81
@@ -183,8 +182,6 @@ int setup_profiling_timer(unsigned int multiplier)
183 182
184void __init smp_prepare_cpus(unsigned int max_cpus) 183void __init smp_prepare_cpus(unsigned int max_cpus)
185{ 184{
186 extern void __init smp4m_boot_cpus(void);
187 extern void __init smp4d_boot_cpus(void);
188 int i, cpuid, extra; 185 int i, cpuid, extra;
189 186
190 printk("Entering SMP Mode...\n"); 187 printk("Entering SMP Mode...\n");
@@ -261,8 +258,6 @@ void __init smp_prepare_boot_cpu(void)
261 258
262int __cpu_up(unsigned int cpu, struct task_struct *tidle) 259int __cpu_up(unsigned int cpu, struct task_struct *tidle)
263{ 260{
264 extern int smp4m_boot_one_cpu(int, struct task_struct *);
265 extern int smp4d_boot_one_cpu(int, struct task_struct *);
266 int ret=0; 261 int ret=0;
267 262
268 switch(sparc_cpu_model) { 263 switch(sparc_cpu_model) {
@@ -297,7 +292,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
297 return ret; 292 return ret;
298} 293}
299 294
300void arch_cpu_pre_starting(void *arg) 295static void arch_cpu_pre_starting(void *arg)
301{ 296{
302 local_ops->cache_all(); 297 local_ops->cache_all();
303 local_ops->tlb_all(); 298 local_ops->tlb_all();
@@ -317,7 +312,7 @@ void arch_cpu_pre_starting(void *arg)
317 } 312 }
318} 313}
319 314
320void arch_cpu_pre_online(void *arg) 315static void arch_cpu_pre_online(void *arg)
321{ 316{
322 unsigned int cpuid = hard_smp_processor_id(); 317 unsigned int cpuid = hard_smp_processor_id();
323 318
@@ -344,7 +339,7 @@ void arch_cpu_pre_online(void *arg)
344 } 339 }
345} 340}
346 341
347void sparc_start_secondary(void *arg) 342static void sparc_start_secondary(void *arg)
348{ 343{
349 unsigned int cpu; 344 unsigned int cpu;
350 345
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 745a3633ce14..41aa2478f3ca 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -25,6 +25,7 @@
25#include <linux/ftrace.h> 25#include <linux/ftrace.h>
26#include <linux/cpu.h> 26#include <linux/cpu.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/kgdb.h>
28 29
29#include <asm/head.h> 30#include <asm/head.h>
30#include <asm/ptrace.h> 31#include <asm/ptrace.h>
@@ -35,6 +36,7 @@
35#include <asm/hvtramp.h> 36#include <asm/hvtramp.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/timer.h> 38#include <asm/timer.h>
39#include <asm/setup.h>
38 40
39#include <asm/irq.h> 41#include <asm/irq.h>
40#include <asm/irq_regs.h> 42#include <asm/irq_regs.h>
@@ -52,6 +54,7 @@
52#include <asm/pcr.h> 54#include <asm/pcr.h>
53 55
54#include "cpumap.h" 56#include "cpumap.h"
57#include "kernel.h"
55 58
56DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE; 59DEFINE_PER_CPU(cpumask_t, cpu_sibling_map) = CPU_MASK_NONE;
57cpumask_t cpu_core_map[NR_CPUS] __read_mostly = 60cpumask_t cpu_core_map[NR_CPUS] __read_mostly =
@@ -272,14 +275,6 @@ static void smp_synchronize_one_tick(int cpu)
272} 275}
273 276
274#if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU) 277#if defined(CONFIG_SUN_LDOMS) && defined(CONFIG_HOTPLUG_CPU)
275/* XXX Put this in some common place. XXX */
276static unsigned long kimage_addr_to_ra(void *p)
277{
278 unsigned long val = (unsigned long) p;
279
280 return kern_base + (val - KERNBASE);
281}
282
283static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, 278static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg,
284 void **descrp) 279 void **descrp)
285{ 280{
@@ -867,11 +862,6 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
867#endif 862#endif
868extern unsigned long xcall_flush_dcache_page_spitfire; 863extern unsigned long xcall_flush_dcache_page_spitfire;
869 864
870#ifdef CONFIG_DEBUG_DCFLUSH
871extern atomic_t dcpage_flushes;
872extern atomic_t dcpage_flushes_xcall;
873#endif
874
875static inline void __local_flush_dcache_page(struct page *page) 865static inline void __local_flush_dcache_page(struct page *page)
876{ 866{
877#ifdef DCACHE_ALIASING_POSSIBLE 867#ifdef DCACHE_ALIASING_POSSIBLE
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index f8933be3ca8b..a1bb2675b280 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -143,7 +143,7 @@ static void sun4d_sbus_handler_irq(int sbusl)
143 } 143 }
144} 144}
145 145
146void sun4d_handler_irq(int pil, struct pt_regs *regs) 146void sun4d_handler_irq(unsigned int pil, struct pt_regs *regs)
147{ 147{
148 struct pt_regs *old_regs; 148 struct pt_regs *old_regs;
149 /* SBUS IRQ level (1 - 7) */ 149 /* SBUS IRQ level (1 - 7) */
@@ -236,7 +236,7 @@ static void sun4d_shutdown_irq(struct irq_data *data)
236 irq_unlink(data->irq); 236 irq_unlink(data->irq);
237} 237}
238 238
239struct irq_chip sun4d_irq = { 239static struct irq_chip sun4d_irq = {
240 .name = "sun4d", 240 .name = "sun4d",
241 .irq_startup = sun4d_startup_irq, 241 .irq_startup = sun4d_startup_irq,
242 .irq_shutdown = sun4d_shutdown_irq, 242 .irq_shutdown = sun4d_shutdown_irq,
@@ -285,9 +285,9 @@ static void __init sun4d_load_profile_irqs(void)
285 } 285 }
286} 286}
287 287
288unsigned int _sun4d_build_device_irq(unsigned int real_irq, 288static unsigned int _sun4d_build_device_irq(unsigned int real_irq,
289 unsigned int pil, 289 unsigned int pil,
290 unsigned int board) 290 unsigned int board)
291{ 291{
292 struct sun4d_handler_data *handler_data; 292 struct sun4d_handler_data *handler_data;
293 unsigned int irq; 293 unsigned int irq;
@@ -320,8 +320,8 @@ err_out:
320 320
321 321
322 322
323unsigned int sun4d_build_device_irq(struct platform_device *op, 323static unsigned int sun4d_build_device_irq(struct platform_device *op,
324 unsigned int real_irq) 324 unsigned int real_irq)
325{ 325{
326 struct device_node *dp = op->dev.of_node; 326 struct device_node *dp = op->dev.of_node;
327 struct device_node *board_parent, *bus = dp->parent; 327 struct device_node *board_parent, *bus = dp->parent;
@@ -383,7 +383,8 @@ err_out:
383 return irq; 383 return irq;
384} 384}
385 385
386unsigned int sun4d_build_timer_irq(unsigned int board, unsigned int real_irq) 386static unsigned int sun4d_build_timer_irq(unsigned int board,
387 unsigned int real_irq)
387{ 388{
388 return _sun4d_build_device_irq(real_irq, real_irq, board); 389 return _sun4d_build_device_irq(real_irq, real_irq, board);
389} 390}
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index 71368850dfc0..022c30c72ebd 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -49,6 +49,8 @@
49#include <asm/mmu_context.h> 49#include <asm/mmu_context.h>
50#include <asm/compat_signal.h> 50#include <asm/compat_signal.h>
51 51
52#include "systbls.h"
53
52asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low) 54asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low)
53{ 55{
54 if ((int)high < 0) 56 if ((int)high < 0)
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
index 3a8d1844402e..646988d4c1a3 100644
--- a/arch/sparc/kernel/sys_sparc_32.c
+++ b/arch/sparc/kernel/sys_sparc_32.c
@@ -24,6 +24,8 @@
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/unistd.h> 25#include <asm/unistd.h>
26 26
27#include "systbls.h"
28
27/* #define DEBUG_UNIMP_SYSCALL */ 29/* #define DEBUG_UNIMP_SYSCALL */
28 30
29/* XXX Make this per-binary type, this way we can detect the type of 31/* XXX Make this per-binary type, this way we can detect the type of
@@ -68,7 +70,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
68 * sys_pipe() is the normal C calling standard for creating 70 * sys_pipe() is the normal C calling standard for creating
69 * a pipe. It's not the way unix traditionally does this, though. 71 * a pipe. It's not the way unix traditionally does this, though.
70 */ 72 */
71asmlinkage int sparc_pipe(struct pt_regs *regs) 73asmlinkage long sparc_pipe(struct pt_regs *regs)
72{ 74{
73 int fd[2]; 75 int fd[2];
74 int error; 76 int error;
@@ -93,7 +95,7 @@ int sparc_mmap_check(unsigned long addr, unsigned long len)
93 95
94/* Linux version of mmap */ 96/* Linux version of mmap */
95 97
96asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len, 98asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
97 unsigned long prot, unsigned long flags, unsigned long fd, 99 unsigned long prot, unsigned long flags, unsigned long fd,
98 unsigned long pgoff) 100 unsigned long pgoff)
99{ 101{
@@ -103,7 +105,7 @@ asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
103 pgoff >> (PAGE_SHIFT - 12)); 105 pgoff >> (PAGE_SHIFT - 12));
104} 106}
105 107
106asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len, 108asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
107 unsigned long prot, unsigned long flags, unsigned long fd, 109 unsigned long prot, unsigned long flags, unsigned long fd,
108 unsigned long off) 110 unsigned long off)
109{ 111{
@@ -197,7 +199,7 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig,
197 return ret; 199 return ret;
198} 200}
199 201
200asmlinkage int sys_getdomainname(char __user *name, int len) 202asmlinkage long sys_getdomainname(char __user *name, int len)
201{ 203{
202 int nlen, err; 204 int nlen, err;
203 205
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index beb0b5a5f21f..c85403d0496c 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -31,6 +31,7 @@
31#include <asm/unistd.h> 31#include <asm/unistd.h>
32 32
33#include "entry.h" 33#include "entry.h"
34#include "kernel.h"
34#include "systbls.h" 35#include "systbls.h"
35 36
36/* #define DEBUG_UNIMP_SYSCALL */ 37/* #define DEBUG_UNIMP_SYSCALL */
diff --git a/arch/sparc/kernel/systbls.h b/arch/sparc/kernel/systbls.h
index 26e6dd72e92a..2dab8236d490 100644
--- a/arch/sparc/kernel/systbls.h
+++ b/arch/sparc/kernel/systbls.h
@@ -1,41 +1,103 @@
1#ifndef _SYSTBLS_H 1#ifndef _SYSTBLS_H
2#define _SYSTBLS_H 2#define _SYSTBLS_H
3 3
4#include <linux/signal.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/compat.h>
5#include <linux/types.h> 7#include <linux/types.h>
6#include <linux/signal.h> 8
7#include <asm/utrap.h> 9#include <asm/utrap.h>
8 10
9extern asmlinkage unsigned long sys_getpagesize(void); 11asmlinkage unsigned long sys_getpagesize(void);
10extern asmlinkage long sparc_pipe(struct pt_regs *regs); 12asmlinkage long sparc_pipe(struct pt_regs *regs);
11extern asmlinkage long sys_sparc_ipc(unsigned int call, int first, 13asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs);
12 unsigned long second, 14asmlinkage long sys_getdomainname(char __user *name, int len);
13 unsigned long third, 15void do_rt_sigreturn(struct pt_regs *regs);
14 void __user *ptr, long fifth); 16asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
15extern asmlinkage long sparc64_personality(unsigned long personality); 17 unsigned long prot, unsigned long flags,
16extern asmlinkage long sys64_munmap(unsigned long addr, size_t len); 18 unsigned long fd, unsigned long off);
17extern asmlinkage unsigned long sys64_mremap(unsigned long addr, 19asmlinkage void sparc_breakpoint(struct pt_regs *regs);
18 unsigned long old_len, 20
19 unsigned long new_len, 21#ifdef CONFIG_SPARC32
20 unsigned long flags, 22asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
21 unsigned long new_addr); 23 unsigned long prot, unsigned long flags,
22extern asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs); 24 unsigned long fd, unsigned long pgoff);
23extern asmlinkage long sys_getdomainname(char __user *name, int len); 25long sparc_remap_file_pages(unsigned long start, unsigned long size,
24extern asmlinkage long sys_utrap_install(utrap_entry_t type, 26 unsigned long prot, unsigned long pgoff,
25 utrap_handler_t new_p, 27 unsigned long flags);
26 utrap_handler_t new_d,
27 utrap_handler_t __user *old_p,
28 utrap_handler_t __user *old_d);
29extern asmlinkage long sparc_memory_ordering(unsigned long model,
30 struct pt_regs *regs);
31extern asmlinkage long sys_rt_sigaction(int sig,
32 const struct sigaction __user *act,
33 struct sigaction __user *oact,
34 void __user *restorer,
35 size_t sigsetsize);
36 28
37extern asmlinkage void sparc64_set_context(struct pt_regs *regs); 29#endif /* CONFIG_SPARC32 */
38extern asmlinkage void sparc64_get_context(struct pt_regs *regs);
39extern void do_rt_sigreturn(struct pt_regs *regs);
40 30
31#ifdef CONFIG_SPARC64
32asmlinkage long sys_sparc_ipc(unsigned int call, int first,
33 unsigned long second,
34 unsigned long third,
35 void __user *ptr, long fifth);
36asmlinkage long sparc64_personality(unsigned long personality);
37asmlinkage long sys64_munmap(unsigned long addr, size_t len);
38asmlinkage unsigned long sys64_mremap(unsigned long addr,
39 unsigned long old_len,
40 unsigned long new_len,
41 unsigned long flags,
42 unsigned long new_addr);
43asmlinkage long sys_utrap_install(utrap_entry_t type,
44 utrap_handler_t new_p,
45 utrap_handler_t new_d,
46 utrap_handler_t __user *old_p,
47 utrap_handler_t __user *old_d);
48asmlinkage long sparc_memory_ordering(unsigned long model,
49 struct pt_regs *regs);
50asmlinkage void sparc64_set_context(struct pt_regs *regs);
51asmlinkage void sparc64_get_context(struct pt_regs *regs);
52asmlinkage long sys32_truncate64(const char __user * path,
53 unsigned long high,
54 unsigned long low);
55asmlinkage long sys32_ftruncate64(unsigned int fd,
56 unsigned long high,
57 unsigned long low);
58struct compat_stat64;
59asmlinkage long compat_sys_stat64(const char __user * filename,
60 struct compat_stat64 __user *statbuf);
61asmlinkage long compat_sys_lstat64(const char __user * filename,
62 struct compat_stat64 __user *statbuf);
63asmlinkage long compat_sys_fstat64(unsigned int fd,
64 struct compat_stat64 __user * statbuf);
65asmlinkage long compat_sys_fstatat64(unsigned int dfd,
66 const char __user *filename,
67 struct compat_stat64 __user * statbuf, int flag);
68asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
69 char __user *ubuf,
70 compat_size_t count,
71 unsigned long poshi,
72 unsigned long poslo);
73asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd,
74 char __user *ubuf,
75 compat_size_t count,
76 unsigned long poshi,
77 unsigned long poslo);
78asmlinkage long compat_sys_readahead(int fd,
79 unsigned long offhi,
80 unsigned long offlo,
81 compat_size_t count);
82long compat_sys_fadvise64(int fd,
83 unsigned long offhi,
84 unsigned long offlo,
85 compat_size_t len, int advice);
86long compat_sys_fadvise64_64(int fd,
87 unsigned long offhi, unsigned long offlo,
88 unsigned long lenhi, unsigned long lenlo,
89 int advice);
90long sys32_sync_file_range(unsigned int fd,
91 unsigned long off_high, unsigned long off_low,
92 unsigned long nb_high, unsigned long nb_low,
93 unsigned int flags);
94asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
95 u32 lenhi, u32 lenlo);
96asmlinkage long compat_sys_fstat64(unsigned int fd,
97 struct compat_stat64 __user * statbuf);
98asmlinkage long compat_sys_fstatat64(unsigned int dfd,
99 const char __user *filename,
100 struct compat_stat64 __user * statbuf,
101 int flag);
102#endif /* CONFIG_SPARC64 */
41#endif /* _SYSTBLS_H */ 103#endif /* _SYSTBLS_H */
diff --git a/arch/sparc/kernel/tadpole.c b/arch/sparc/kernel/tadpole.c
deleted file mode 100644
index 9aba8bd5a78b..000000000000
--- a/arch/sparc/kernel/tadpole.c
+++ /dev/null
@@ -1,126 +0,0 @@
1/* tadpole.c: Probing for the tadpole clock stopping h/w at boot time.
2 *
3 * Copyright (C) 1996 David Redman (djhr@tadpole.co.uk)
4 */
5
6#include <linux/string.h>
7#include <linux/kernel.h>
8#include <linux/sched.h>
9#include <linux/init.h>
10
11#include <asm/asi.h>
12#include <asm/oplib.h>
13#include <asm/io.h>
14
15#define MACIO_SCSI_CSR_ADDR 0x78400000
16#define MACIO_EN_DMA 0x00000200
17#define CLOCK_INIT_DONE 1
18
19static int clk_state;
20static volatile unsigned char *clk_ctrl;
21void (*cpu_pwr_save)(void);
22
23static inline unsigned int ldphys(unsigned int addr)
24{
25 unsigned long data;
26
27 __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
28 "=r" (data) :
29 "r" (addr), "i" (ASI_M_BYPASS));
30 return data;
31}
32
33static void clk_init(void)
34{
35 __asm__ __volatile__("mov 0x6c, %%g1\n\t"
36 "mov 0x4c, %%g2\n\t"
37 "mov 0xdf, %%g3\n\t"
38 "stb %%g1, [%0+3]\n\t"
39 "stb %%g2, [%0+3]\n\t"
40 "stb %%g3, [%0+3]\n\t" : :
41 "r" (clk_ctrl) :
42 "g1", "g2", "g3");
43}
44
45static void clk_slow(void)
46{
47 __asm__ __volatile__("mov 0xcc, %%g2\n\t"
48 "mov 0x4c, %%g3\n\t"
49 "mov 0xcf, %%g4\n\t"
50 "mov 0xdf, %%g5\n\t"
51 "stb %%g2, [%0+3]\n\t"
52 "stb %%g3, [%0+3]\n\t"
53 "stb %%g4, [%0+3]\n\t"
54 "stb %%g5, [%0+3]\n\t" : :
55 "r" (clk_ctrl) :
56 "g2", "g3", "g4", "g5");
57}
58
59/*
60 * Tadpole is guaranteed to be UP, using local_irq_save.
61 */
62static void tsu_clockstop(void)
63{
64 unsigned int mcsr;
65 unsigned long flags;
66
67 if (!clk_ctrl)
68 return;
69 if (!(clk_state & CLOCK_INIT_DONE)) {
70 local_irq_save(flags);
71 clk_init();
72 clk_state |= CLOCK_INIT_DONE; /* all done */
73 local_irq_restore(flags);
74 return;
75 }
76 if (!(clk_ctrl[2] & 1))
77 return; /* no speed up yet */
78
79 local_irq_save(flags);
80
81 /* if SCSI DMA in progress, don't slow clock */
82 mcsr = ldphys(MACIO_SCSI_CSR_ADDR);
83 if ((mcsr&MACIO_EN_DMA) != 0) {
84 local_irq_restore(flags);
85 return;
86 }
87 /* TODO... the minimum clock setting ought to increase the
88 * memory refresh interval..
89 */
90 clk_slow();
91 local_irq_restore(flags);
92}
93
94static void swift_clockstop(void)
95{
96 if (!clk_ctrl)
97 return;
98 clk_ctrl[0] = 0;
99}
100
101void __init clock_stop_probe(void)
102{
103 phandle node, clk_nd;
104 char name[20];
105
106 prom_getstring(prom_root_node, "name", name, sizeof(name));
107 if (strncmp(name, "Tadpole", 7))
108 return;
109 node = prom_getchild(prom_root_node);
110 node = prom_searchsiblings(node, "obio");
111 node = prom_getchild(node);
112 clk_nd = prom_searchsiblings(node, "clk-ctrl");
113 if (!clk_nd)
114 return;
115 printk("Clock Stopping h/w detected... ");
116 clk_ctrl = (char *) prom_getint(clk_nd, "address");
117 clk_state = 0;
118 if (name[10] == '\0') {
119 cpu_pwr_save = tsu_clockstop;
120 printk("enabled (S3)\n");
121 } else if ((name[10] == 'X') || (name[10] == 'G')) {
122 cpu_pwr_save = swift_clockstop;
123 printk("enabled (%s)\n",name+7);
124 } else
125 printk("disabled %s\n",name+7);
126}
diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c
index c4c27b0f9063..5923d1e4e7c9 100644
--- a/arch/sparc/kernel/time_32.c
+++ b/arch/sparc/kernel/time_32.c
@@ -36,6 +36,7 @@
36#include <linux/of_device.h> 36#include <linux/of_device.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38 38
39#include <asm/mc146818rtc.h>
39#include <asm/oplib.h> 40#include <asm/oplib.h>
40#include <asm/timex.h> 41#include <asm/timex.h>
41#include <asm/timer.h> 42#include <asm/timer.h>
@@ -47,6 +48,7 @@
47#include <asm/irq_regs.h> 48#include <asm/irq_regs.h>
48#include <asm/setup.h> 49#include <asm/setup.h>
49 50
51#include "kernel.h"
50#include "irq.h" 52#include "irq.h"
51 53
52static __cacheline_aligned_in_smp DEFINE_SEQLOCK(timer_cs_lock); 54static __cacheline_aligned_in_smp DEFINE_SEQLOCK(timer_cs_lock);
@@ -83,7 +85,7 @@ unsigned long profile_pc(struct pt_regs *regs)
83 85
84EXPORT_SYMBOL(profile_pc); 86EXPORT_SYMBOL(profile_pc);
85 87
86__volatile__ unsigned int *master_l10_counter; 88volatile u32 __iomem *master_l10_counter;
87 89
88int update_persistent_clock(struct timespec now) 90int update_persistent_clock(struct timespec now)
89{ 91{
@@ -143,9 +145,9 @@ static __init void setup_timer_ce(void)
143 145
144static unsigned int sbus_cycles_offset(void) 146static unsigned int sbus_cycles_offset(void)
145{ 147{
146 unsigned int val, offset; 148 u32 val, offset;
147 149
148 val = *master_l10_counter; 150 val = sbus_readl(master_l10_counter);
149 offset = (val >> TIMER_VALUE_SHIFT) & TIMER_VALUE_MASK; 151 offset = (val >> TIMER_VALUE_SHIFT) & TIMER_VALUE_MASK;
150 152
151 /* Limit hit? */ 153 /* Limit hit? */
diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
index 662982946a89..6fd386c5232a 100644
--- a/arch/sparc/kernel/traps_32.c
+++ b/arch/sparc/kernel/traps_32.c
@@ -44,7 +44,7 @@ static void instruction_dump(unsigned long *pc)
44#define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t") 44#define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
45#define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t") 45#define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
46 46
47void die_if_kernel(char *str, struct pt_regs *regs) 47void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
48{ 48{
49 static int die_counter; 49 static int die_counter;
50 int count = 0; 50 int count = 0;
@@ -219,8 +219,6 @@ static unsigned long fake_fsr;
219static unsigned long fake_queue[32] __attribute__ ((aligned (8))); 219static unsigned long fake_queue[32] __attribute__ ((aligned (8)));
220static unsigned long fake_depth; 220static unsigned long fake_depth;
221 221
222extern int do_mathemu(struct pt_regs *, struct task_struct *);
223
224void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc, 222void do_fpe_trap(struct pt_regs *regs, unsigned long pc, unsigned long npc,
225 unsigned long psr) 223 unsigned long psr)
226{ 224{
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index 4ced92f05358..fb6640ec8557 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -43,8 +43,10 @@
43#include <asm/prom.h> 43#include <asm/prom.h>
44#include <asm/memctrl.h> 44#include <asm/memctrl.h>
45#include <asm/cacheflush.h> 45#include <asm/cacheflush.h>
46#include <asm/setup.h>
46 47
47#include "entry.h" 48#include "entry.h"
49#include "kernel.h"
48#include "kstack.h" 50#include "kstack.h"
49 51
50/* When an irrecoverable trap occurs at tl > 0, the trap entry 52/* When an irrecoverable trap occurs at tl > 0, the trap entry
@@ -2209,8 +2211,6 @@ out:
2209 exception_exit(prev_state); 2211 exception_exit(prev_state);
2210} 2212}
2211 2213
2212extern int do_mathemu(struct pt_regs *, struct fpustate *, bool);
2213
2214void do_fpother(struct pt_regs *regs) 2214void do_fpother(struct pt_regs *regs)
2215{ 2215{
2216 enum ctx_state prev_state = exception_enter(); 2216 enum ctx_state prev_state = exception_enter();
@@ -2383,7 +2383,7 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
2383 return (struct reg_window *) (fp + STACK_BIAS); 2383 return (struct reg_window *) (fp + STACK_BIAS);
2384} 2384}
2385 2385
2386void die_if_kernel(char *str, struct pt_regs *regs) 2386void __noreturn die_if_kernel(char *str, struct pt_regs *regs)
2387{ 2387{
2388 static int die_counter; 2388 static int die_counter;
2389 int count = 0; 2389 int count = 0;
@@ -2433,9 +2433,6 @@ EXPORT_SYMBOL(die_if_kernel);
2433#define VIS_OPCODE_MASK ((0x3 << 30) | (0x3f << 19)) 2433#define VIS_OPCODE_MASK ((0x3 << 30) | (0x3f << 19))
2434#define VIS_OPCODE_VAL ((0x2 << 30) | (0x36 << 19)) 2434#define VIS_OPCODE_VAL ((0x2 << 30) | (0x36 << 19))
2435 2435
2436extern int handle_popc(u32 insn, struct pt_regs *regs);
2437extern int handle_ldf_stq(u32 insn, struct pt_regs *regs);
2438
2439void do_illegal_instruction(struct pt_regs *regs) 2436void do_illegal_instruction(struct pt_regs *regs)
2440{ 2437{
2441 enum ctx_state prev_state = exception_enter(); 2438 enum ctx_state prev_state = exception_enter();
@@ -2486,8 +2483,6 @@ out:
2486 exception_exit(prev_state); 2483 exception_exit(prev_state);
2487} 2484}
2488 2485
2489extern void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn);
2490
2491void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr) 2486void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr)
2492{ 2487{
2493 enum ctx_state prev_state = exception_enter(); 2488 enum ctx_state prev_state = exception_enter();
diff --git a/arch/sparc/kernel/unaligned_32.c b/arch/sparc/kernel/unaligned_32.c
index c0ec89786193..c5c61b3c6b56 100644
--- a/arch/sparc/kernel/unaligned_32.c
+++ b/arch/sparc/kernel/unaligned_32.c
@@ -16,6 +16,10 @@
16#include <linux/smp.h> 16#include <linux/smp.h>
17#include <linux/perf_event.h> 17#include <linux/perf_event.h>
18 18
19#include <asm/setup.h>
20
21#include "kernel.h"
22
19enum direction { 23enum direction {
20 load, /* ld, ldd, ldh, ldsh */ 24 load, /* ld, ldd, ldh, ldsh */
21 store, /* st, std, sth, stsh */ 25 store, /* st, std, sth, stsh */
diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
index 35ab8b60d256..62098a89bbbf 100644
--- a/arch/sparc/kernel/unaligned_64.c
+++ b/arch/sparc/kernel/unaligned_64.c
@@ -24,8 +24,10 @@
24#include <linux/context_tracking.h> 24#include <linux/context_tracking.h>
25#include <asm/fpumacro.h> 25#include <asm/fpumacro.h>
26#include <asm/cacheflush.h> 26#include <asm/cacheflush.h>
27#include <asm/setup.h>
27 28
28#include "entry.h" 29#include "entry.h"
30#include "kernel.h"
29 31
30enum direction { 32enum direction {
31 load, /* ld, ldd, ldh, ldsh */ 33 load, /* ld, ldd, ldh, ldsh */
diff --git a/arch/sparc/kernel/windows.c b/arch/sparc/kernel/windows.c
index 3107381e576d..87bab0a3857a 100644
--- a/arch/sparc/kernel/windows.c
+++ b/arch/sparc/kernel/windows.c
@@ -10,8 +10,11 @@
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12 12
13#include <asm/cacheflush.h>
13#include <asm/uaccess.h> 14#include <asm/uaccess.h>
14 15
16#include "kernel.h"
17
15/* Do save's until all user register windows are out of the cpu. */ 18/* Do save's until all user register windows are out of the cpu. */
16void flush_user_windows(void) 19void flush_user_windows(void)
17{ 20{
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index dbe119b63b48..3269b0234093 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -41,7 +41,7 @@ lib-$(CONFIG_SPARC64) += GENpatch.o GENpage.o GENbzero.o
41lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o 41lib-$(CONFIG_SPARC64) += copy_in_user.o user_fixup.o memmove.o
42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o 42lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
43 43
44obj-y += iomap.o 44obj-$(CONFIG_SPARC64) += iomap.o
45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o 45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
46obj-y += ksyms.o 46obj-y += ksyms.o
47obj-$(CONFIG_SPARC64) += PeeCeeI.o 47obj-$(CONFIG_SPARC64) += PeeCeeI.o
diff --git a/arch/sparc/math-emu/sfp-util_32.h b/arch/sparc/math-emu/sfp-util_32.h
index d1b2aff3c259..bb587d5f3d9d 100644
--- a/arch/sparc/math-emu/sfp-util_32.h
+++ b/arch/sparc/math-emu/sfp-util_32.h
@@ -4,20 +4,20 @@
4#include <asm/byteorder.h> 4#include <asm/byteorder.h>
5 5
6#define add_ssaaaa(sh, sl, ah, al, bh, bl) \ 6#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
7 __asm__ ("addcc %r4,%5,%1\n\t" \ 7 __asm__ ("addcc %r4,%5,%1\n\t" \
8 "addx %r2,%3,%0\n" \ 8 "addx %r2,%3,%0\n" \
9 : "=r" ((USItype)(sh)), \ 9 : "=r" (sh), \
10 "=&r" ((USItype)(sl)) \ 10 "=&r" (sl) \
11 : "%rJ" ((USItype)(ah)), \ 11 : "%rJ" ((USItype)(ah)), \
12 "rI" ((USItype)(bh)), \ 12 "rI" ((USItype)(bh)), \
13 "%rJ" ((USItype)(al)), \ 13 "%rJ" ((USItype)(al)), \
14 "rI" ((USItype)(bl)) \ 14 "rI" ((USItype)(bl)) \
15 : "cc") 15 : "cc")
16#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ 16#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
17 __asm__ ("subcc %r4,%5,%1\n\t" \ 17 __asm__ ("subcc %r4,%5,%1\n\t" \
18 "subx %r2,%3,%0\n" \ 18 "subx %r2,%3,%0\n" \
19 : "=r" ((USItype)(sh)), \ 19 : "=r" (sh), \
20 "=&r" ((USItype)(sl)) \ 20 "=&r" (sl) \
21 : "rJ" ((USItype)(ah)), \ 21 : "rJ" ((USItype)(ah)), \
22 "rI" ((USItype)(bh)), \ 22 "rI" ((USItype)(bh)), \
23 "rJ" ((USItype)(al)), \ 23 "rJ" ((USItype)(al)), \
@@ -65,8 +65,8 @@
65 "mulscc %%g1,0,%%g1\n\t" \ 65 "mulscc %%g1,0,%%g1\n\t" \
66 "add %%g1,%%g2,%0\n\t" \ 66 "add %%g1,%%g2,%0\n\t" \
67 "rd %%y,%1\n" \ 67 "rd %%y,%1\n" \
68 : "=r" ((USItype)(w1)), \ 68 : "=r" (w1), \
69 "=r" ((USItype)(w0)) \ 69 "=r" (w0) \
70 : "%rI" ((USItype)(u)), \ 70 : "%rI" ((USItype)(u)), \
71 "r" ((USItype)(v)) \ 71 "r" ((USItype)(v)) \
72 : "%g1", "%g2", "cc") 72 : "%g1", "%g2", "cc")
@@ -98,8 +98,8 @@
98 "sub %1,%2,%1\n\t" \ 98 "sub %1,%2,%1\n\t" \
99 "3: xnor %0,0,%0\n\t" \ 99 "3: xnor %0,0,%0\n\t" \
100 "! End of inline udiv_qrnnd\n" \ 100 "! End of inline udiv_qrnnd\n" \
101 : "=&r" ((USItype)(q)), \ 101 : "=&r" (q), \
102 "=&r" ((USItype)(r)) \ 102 "=&r" (r) \
103 : "r" ((USItype)(d)), \ 103 : "r" ((USItype)(d)), \
104 "1" ((USItype)(n1)), \ 104 "1" ((USItype)(n1)), \
105 "0" ((USItype)(n0)) : "%g1", "cc") 105 "0" ((USItype)(n0)) : "%g1", "cc")
diff --git a/arch/sparc/math-emu/sfp-util_64.h b/arch/sparc/math-emu/sfp-util_64.h
index 425d3cf01af4..51320a861cc2 100644
--- a/arch/sparc/math-emu/sfp-util_64.h
+++ b/arch/sparc/math-emu/sfp-util_64.h
@@ -17,8 +17,8 @@
17 "bcs,a,pn %%xcc, 1f\n\t" \ 17 "bcs,a,pn %%xcc, 1f\n\t" \
18 "add %0, 1, %0\n" \ 18 "add %0, 1, %0\n" \
19 "1:" \ 19 "1:" \
20 : "=r" ((UDItype)(sh)), \ 20 : "=r" (sh), \
21 "=&r" ((UDItype)(sl)) \ 21 "=&r" (sl) \
22 : "r" ((UDItype)(ah)), \ 22 : "r" ((UDItype)(ah)), \
23 "r" ((UDItype)(bh)), \ 23 "r" ((UDItype)(bh)), \
24 "r" ((UDItype)(al)), \ 24 "r" ((UDItype)(al)), \
@@ -31,8 +31,8 @@
31 "bcs,a,pn %%xcc, 1f\n\t" \ 31 "bcs,a,pn %%xcc, 1f\n\t" \
32 "sub %0, 1, %0\n" \ 32 "sub %0, 1, %0\n" \
33 "1:" \ 33 "1:" \
34 : "=r" ((UDItype)(sh)), \ 34 : "=r" (sh), \
35 "=&r" ((UDItype)(sl)) \ 35 "=&r" (sl) \
36 : "r" ((UDItype)(ah)), \ 36 : "r" ((UDItype)(ah)), \
37 "r" ((UDItype)(bh)), \ 37 "r" ((UDItype)(bh)), \
38 "r" ((UDItype)(al)), \ 38 "r" ((UDItype)(al)), \
@@ -64,8 +64,8 @@
64 "sllx %3,32,%3\n\t" \ 64 "sllx %3,32,%3\n\t" \
65 "add %1,%3,%1\n\t" \ 65 "add %1,%3,%1\n\t" \
66 "add %5,%2,%0" \ 66 "add %5,%2,%0" \
67 : "=r" ((UDItype)(wh)), \ 67 : "=r" (wh), \
68 "=&r" ((UDItype)(wl)), \ 68 "=&r" (wl), \
69 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \ 69 "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
70 : "r" ((UDItype)(u)), \ 70 : "r" ((UDItype)(u)), \
71 "r" ((UDItype)(v)) \ 71 "r" ((UDItype)(v)) \
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index 59dbd4645725..908e8c17c902 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -26,14 +26,14 @@
26#include <asm/pgtable.h> 26#include <asm/pgtable.h>
27#include <asm/openprom.h> 27#include <asm/openprom.h>
28#include <asm/oplib.h> 28#include <asm/oplib.h>
29#include <asm/setup.h>
29#include <asm/smp.h> 30#include <asm/smp.h>
30#include <asm/traps.h> 31#include <asm/traps.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32 33
33int show_unhandled_signals = 1; 34#include "mm_32.h"
34 35
35static void unhandled_fault(unsigned long, struct task_struct *, 36int show_unhandled_signals = 1;
36 struct pt_regs *) __attribute__ ((noreturn));
37 37
38static void __noreturn unhandled_fault(unsigned long address, 38static void __noreturn unhandled_fault(unsigned long address,
39 struct task_struct *tsk, 39 struct task_struct *tsk,
@@ -141,9 +141,6 @@ static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs,
141 force_sig_info (sig, &info, current); 141 force_sig_info (sig, &info, current);
142} 142}
143 143
144extern unsigned long safe_compute_effective_address(struct pt_regs *,
145 unsigned int);
146
147static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault) 144static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
148{ 145{
149 unsigned int insn; 146 unsigned int insn;
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index 4ced3fc66130..587cd0565128 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -32,6 +32,7 @@
32#include <asm/lsu.h> 32#include <asm/lsu.h>
33#include <asm/sections.h> 33#include <asm/sections.h>
34#include <asm/mmu_context.h> 34#include <asm/mmu_context.h>
35#include <asm/setup.h>
35 36
36int show_unhandled_signals = 1; 37int show_unhandled_signals = 1;
37 38
@@ -196,9 +197,6 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
196 force_sig_info(sig, &info, current); 197 force_sig_info(sig, &info, current);
197} 198}
198 199
199extern int handle_ldf_stq(u32, struct pt_regs *);
200extern int handle_ld_nf(u32, struct pt_regs *);
201
202static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn) 200static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)
203{ 201{
204 if (!insn) { 202 if (!insn) {
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index db6987082805..eb8287155279 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -31,10 +31,13 @@
31#include <asm/pgtable.h> 31#include <asm/pgtable.h>
32#include <asm/vaddrs.h> 32#include <asm/vaddrs.h>
33#include <asm/pgalloc.h> /* bug in asm-generic/tlb.h: check_pgt_cache */ 33#include <asm/pgalloc.h> /* bug in asm-generic/tlb.h: check_pgt_cache */
34#include <asm/setup.h>
34#include <asm/tlb.h> 35#include <asm/tlb.h>
35#include <asm/prom.h> 36#include <asm/prom.h>
36#include <asm/leon.h> 37#include <asm/leon.h>
37 38
39#include "mm_32.h"
40
38unsigned long *sparc_valid_addr_bitmap; 41unsigned long *sparc_valid_addr_bitmap;
39EXPORT_SYMBOL(sparc_valid_addr_bitmap); 42EXPORT_SYMBOL(sparc_valid_addr_bitmap);
40 43
@@ -63,7 +66,6 @@ void show_mem(unsigned int filter)
63} 66}
64 67
65 68
66extern unsigned long cmdline_memory_size;
67unsigned long last_valid_pfn; 69unsigned long last_valid_pfn;
68 70
69unsigned long calc_highpages(void) 71unsigned long calc_highpages(void)
@@ -246,9 +248,6 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
246 * init routine based upon the Sun model type on the Sparc. 248 * init routine based upon the Sun model type on the Sparc.
247 * 249 *
248 */ 250 */
249extern void srmmu_paging_init(void);
250extern void device_scan(void);
251
252void __init paging_init(void) 251void __init paging_init(void)
253{ 252{
254 srmmu_paging_init(); 253 srmmu_paging_init();
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index ed3c969a5f4c..16b58ff11e65 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -47,6 +47,7 @@
47#include <asm/prom.h> 47#include <asm/prom.h>
48#include <asm/mdesc.h> 48#include <asm/mdesc.h>
49#include <asm/cpudata.h> 49#include <asm/cpudata.h>
50#include <asm/setup.h>
50#include <asm/irq.h> 51#include <asm/irq.h>
51 52
52#include "init_64.h" 53#include "init_64.h"
@@ -794,11 +795,11 @@ struct node_mem_mask {
794static struct node_mem_mask node_masks[MAX_NUMNODES]; 795static struct node_mem_mask node_masks[MAX_NUMNODES];
795static int num_node_masks; 796static int num_node_masks;
796 797
798#ifdef CONFIG_NEED_MULTIPLE_NODES
799
797int numa_cpu_lookup_table[NR_CPUS]; 800int numa_cpu_lookup_table[NR_CPUS];
798cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES]; 801cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES];
799 802
800#ifdef CONFIG_NEED_MULTIPLE_NODES
801
802struct mdesc_mblock { 803struct mdesc_mblock {
803 u64 base; 804 u64 base;
804 u64 size; 805 u64 size;
@@ -887,17 +888,21 @@ static void __init allocate_node_data(int nid)
887 888
888static void init_node_masks_nonnuma(void) 889static void init_node_masks_nonnuma(void)
889{ 890{
891#ifdef CONFIG_NEED_MULTIPLE_NODES
890 int i; 892 int i;
893#endif
891 894
892 numadbg("Initializing tables for non-numa.\n"); 895 numadbg("Initializing tables for non-numa.\n");
893 896
894 node_masks[0].mask = node_masks[0].val = 0; 897 node_masks[0].mask = node_masks[0].val = 0;
895 num_node_masks = 1; 898 num_node_masks = 1;
896 899
900#ifdef CONFIG_NEED_MULTIPLE_NODES
897 for (i = 0; i < NR_CPUS; i++) 901 for (i = 0; i < NR_CPUS; i++)
898 numa_cpu_lookup_table[i] = 0; 902 numa_cpu_lookup_table[i] = 0;
899 903
900 cpumask_setall(&numa_cpumask_lookup_table[0]); 904 cpumask_setall(&numa_cpumask_lookup_table[0]);
905#endif
901} 906}
902 907
903#ifdef CONFIG_NEED_MULTIPLE_NODES 908#ifdef CONFIG_NEED_MULTIPLE_NODES
diff --git a/arch/sparc/mm/init_64.h b/arch/sparc/mm/init_64.h
index 5d3782deb403..0668b364f44d 100644
--- a/arch/sparc/mm/init_64.h
+++ b/arch/sparc/mm/init_64.h
@@ -21,7 +21,7 @@ extern unsigned int sparc64_highest_unlocked_tlb_ent;
21extern unsigned long sparc64_kern_pri_context; 21extern unsigned long sparc64_kern_pri_context;
22extern unsigned long sparc64_kern_pri_nuc_bits; 22extern unsigned long sparc64_kern_pri_nuc_bits;
23extern unsigned long sparc64_kern_sec_context; 23extern unsigned long sparc64_kern_sec_context;
24extern void mmu_info(struct seq_file *m); 24void mmu_info(struct seq_file *m);
25 25
26struct linux_prom_translation { 26struct linux_prom_translation {
27 unsigned long virt; 27 unsigned long virt;
@@ -36,7 +36,7 @@ extern unsigned int prom_trans_ents;
36/* Exported for SMP bootup purposes. */ 36/* Exported for SMP bootup purposes. */
37extern unsigned long kern_locked_tte_data; 37extern unsigned long kern_locked_tte_data;
38 38
39extern void prom_world(int enter); 39void prom_world(int enter);
40 40
41#ifdef CONFIG_SPARSEMEM_VMEMMAP 41#ifdef CONFIG_SPARSEMEM_VMEMMAP
42#define VMEMMAP_CHUNK_SHIFT 22 42#define VMEMMAP_CHUNK_SHIFT 22
diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c
index eb99862e9654..f311bf219016 100644
--- a/arch/sparc/mm/io-unit.c
+++ b/arch/sparc/mm/io-unit.c
@@ -25,6 +25,8 @@
25#include <asm/dma.h> 25#include <asm/dma.h>
26#include <asm/oplib.h> 26#include <asm/oplib.h>
27 27
28#include "mm_32.h"
29
28/* #define IOUNIT_DEBUG */ 30/* #define IOUNIT_DEBUG */
29#ifdef IOUNIT_DEBUG 31#ifdef IOUNIT_DEBUG
30#define IOD(x) printk(x) 32#define IOD(x) printk(x)
@@ -38,7 +40,8 @@
38static void __init iounit_iommu_init(struct platform_device *op) 40static void __init iounit_iommu_init(struct platform_device *op)
39{ 41{
40 struct iounit_struct *iounit; 42 struct iounit_struct *iounit;
41 iopte_t *xpt, *xptend; 43 iopte_t __iomem *xpt;
44 iopte_t __iomem *xptend;
42 45
43 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); 46 iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC);
44 if (!iounit) { 47 if (!iounit) {
@@ -62,10 +65,10 @@ static void __init iounit_iommu_init(struct platform_device *op)
62 op->dev.archdata.iommu = iounit; 65 op->dev.archdata.iommu = iounit;
63 iounit->page_table = xpt; 66 iounit->page_table = xpt;
64 spin_lock_init(&iounit->lock); 67 spin_lock_init(&iounit->lock);
65 68
66 for (xptend = iounit->page_table + (16 * PAGE_SIZE) / sizeof(iopte_t); 69 xptend = iounit->page_table + (16 * PAGE_SIZE) / sizeof(iopte_t);
67 xpt < xptend;) 70 for (; xpt < xptend; xpt++)
68 iopte_val(*xpt++) = 0; 71 sbus_writel(0, xpt);
69} 72}
70 73
71static int __init iounit_init(void) 74static int __init iounit_init(void)
@@ -130,7 +133,7 @@ nexti: scan = find_next_zero_bit(iounit->bmap, limit, scan);
130 vaddr = IOUNIT_DMA_BASE + (scan << PAGE_SHIFT) + (vaddr & ~PAGE_MASK); 133 vaddr = IOUNIT_DMA_BASE + (scan << PAGE_SHIFT) + (vaddr & ~PAGE_MASK);
131 for (k = 0; k < npages; k++, iopte = __iopte(iopte_val(iopte) + 0x100), scan++) { 134 for (k = 0; k < npages; k++, iopte = __iopte(iopte_val(iopte) + 0x100), scan++) {
132 set_bit(scan, iounit->bmap); 135 set_bit(scan, iounit->bmap);
133 iounit->page_table[scan] = iopte; 136 sbus_writel(iopte, &iounit->page_table[scan]);
134 } 137 }
135 IOD(("%08lx\n", vaddr)); 138 IOD(("%08lx\n", vaddr));
136 return vaddr; 139 return vaddr;
@@ -202,7 +205,7 @@ static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned lon
202 struct iounit_struct *iounit = dev->archdata.iommu; 205 struct iounit_struct *iounit = dev->archdata.iommu;
203 unsigned long page, end; 206 unsigned long page, end;
204 pgprot_t dvma_prot; 207 pgprot_t dvma_prot;
205 iopte_t *iopte; 208 iopte_t __iomem *iopte;
206 209
207 *pba = addr; 210 *pba = addr;
208 211
@@ -224,8 +227,8 @@ static int iounit_map_dma_area(struct device *dev, dma_addr_t *pba, unsigned lon
224 227
225 i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT); 228 i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
226 229
227 iopte = (iopte_t *)(iounit->page_table + i); 230 iopte = iounit->page_table + i;
228 *iopte = MKIOPTE(__pa(page)); 231 sbus_writel(MKIOPTE(__pa(page)), iopte);
229 } 232 }
230 addr += PAGE_SIZE; 233 addr += PAGE_SIZE;
231 va += PAGE_SIZE; 234 va += PAGE_SIZE;
diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c
index 28f96f27c768..491511d37e37 100644
--- a/arch/sparc/mm/iommu.c
+++ b/arch/sparc/mm/iommu.c
@@ -27,6 +27,8 @@
27#include <asm/iommu.h> 27#include <asm/iommu.h>
28#include <asm/dma.h> 28#include <asm/dma.h>
29 29
30#include "mm_32.h"
31
30/* 32/*
31 * This can be sized dynamically, but we will do this 33 * This can be sized dynamically, but we will do this
32 * only when we have a guidance about actual I/O pressures. 34 * only when we have a guidance about actual I/O pressures.
@@ -37,9 +39,6 @@
37#define IOMMU_NPTES (IOMMU_WINSIZE/PAGE_SIZE) /* 64K PTEs, 256KB */ 39#define IOMMU_NPTES (IOMMU_WINSIZE/PAGE_SIZE) /* 64K PTEs, 256KB */
38#define IOMMU_ORDER 6 /* 4096 * (1<<6) */ 40#define IOMMU_ORDER 6 /* 4096 * (1<<6) */
39 41
40/* srmmu.c */
41extern int viking_mxcc_present;
42extern int flush_page_for_dma_global;
43static int viking_flush; 42static int viking_flush;
44/* viking.S */ 43/* viking.S */
45extern void viking_flush_page(unsigned long page); 44extern void viking_flush_page(unsigned long page);
@@ -59,6 +58,8 @@ static void __init sbus_iommu_init(struct platform_device *op)
59 struct iommu_struct *iommu; 58 struct iommu_struct *iommu;
60 unsigned int impl, vers; 59 unsigned int impl, vers;
61 unsigned long *bitmap; 60 unsigned long *bitmap;
61 unsigned long control;
62 unsigned long base;
62 unsigned long tmp; 63 unsigned long tmp;
63 64
64 iommu = kmalloc(sizeof(struct iommu_struct), GFP_KERNEL); 65 iommu = kmalloc(sizeof(struct iommu_struct), GFP_KERNEL);
@@ -73,12 +74,14 @@ static void __init sbus_iommu_init(struct platform_device *op)
73 prom_printf("Cannot map IOMMU registers\n"); 74 prom_printf("Cannot map IOMMU registers\n");
74 prom_halt(); 75 prom_halt();
75 } 76 }
76 impl = (iommu->regs->control & IOMMU_CTRL_IMPL) >> 28; 77
77 vers = (iommu->regs->control & IOMMU_CTRL_VERS) >> 24; 78 control = sbus_readl(&iommu->regs->control);
78 tmp = iommu->regs->control; 79 impl = (control & IOMMU_CTRL_IMPL) >> 28;
79 tmp &= ~(IOMMU_CTRL_RNGE); 80 vers = (control & IOMMU_CTRL_VERS) >> 24;
80 tmp |= (IOMMU_RNGE_256MB | IOMMU_CTRL_ENAB); 81 control &= ~(IOMMU_CTRL_RNGE);
81 iommu->regs->control = tmp; 82 control |= (IOMMU_RNGE_256MB | IOMMU_CTRL_ENAB);
83 sbus_writel(control, &iommu->regs->control);
84
82 iommu_invalidate(iommu->regs); 85 iommu_invalidate(iommu->regs);
83 iommu->start = IOMMU_START; 86 iommu->start = IOMMU_START;
84 iommu->end = 0xffffffff; 87 iommu->end = 0xffffffff;
@@ -100,7 +103,9 @@ static void __init sbus_iommu_init(struct platform_device *op)
100 memset(iommu->page_table, 0, IOMMU_NPTES*sizeof(iopte_t)); 103 memset(iommu->page_table, 0, IOMMU_NPTES*sizeof(iopte_t));
101 flush_cache_all(); 104 flush_cache_all();
102 flush_tlb_all(); 105 flush_tlb_all();
103 iommu->regs->base = __pa((unsigned long) iommu->page_table) >> 4; 106
107 base = __pa((unsigned long)iommu->page_table) >> 4;
108 sbus_writel(base, &iommu->regs->base);
104 iommu_invalidate(iommu->regs); 109 iommu_invalidate(iommu->regs);
105 110
106 bitmap = kmalloc(IOMMU_NPTES>>3, GFP_KERNEL); 111 bitmap = kmalloc(IOMMU_NPTES>>3, GFP_KERNEL);
diff --git a/arch/sparc/mm/leon_mm.c b/arch/sparc/mm/leon_mm.c
index 5bed085a2c17..3b17b6f7895a 100644
--- a/arch/sparc/mm/leon_mm.c
+++ b/arch/sparc/mm/leon_mm.c
@@ -15,10 +15,10 @@
15#include <asm/leon.h> 15#include <asm/leon.h>
16#include <asm/tlbflush.h> 16#include <asm/tlbflush.h>
17 17
18#include "srmmu.h" 18#include "mm_32.h"
19 19
20int leon_flush_during_switch = 1; 20int leon_flush_during_switch = 1;
21int srmmu_swprobe_trace; 21static int srmmu_swprobe_trace;
22 22
23static inline unsigned long leon_get_ctable_ptr(void) 23static inline unsigned long leon_get_ctable_ptr(void)
24{ 24{
diff --git a/arch/sparc/mm/mm_32.h b/arch/sparc/mm/mm_32.h
new file mode 100644
index 000000000000..a6c27ca9a721
--- /dev/null
+++ b/arch/sparc/mm/mm_32.h
@@ -0,0 +1,24 @@
1/* fault_32.c - visible as they are called from assembler */
2asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc,
3 unsigned long address);
4asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
5 unsigned long address);
6
7void window_overflow_fault(void);
8void window_underflow_fault(unsigned long sp);
9void window_ret_fault(struct pt_regs *regs);
10
11/* srmmu.c */
12extern char *srmmu_name;
13extern int viking_mxcc_present;
14extern int flush_page_for_dma_global;
15
16extern void (*poke_srmmu)(void);
17
18void __init srmmu_paging_init(void);
19
20/* iommu.c */
21void ld_mmu_iommu(void);
22
23/* io-unit.c */
24void ld_mmu_iounit(void);
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index cfbe53c17b0d..be65f035d18a 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -49,7 +49,7 @@
49#include <asm/mxcc.h> 49#include <asm/mxcc.h>
50#include <asm/ross.h> 50#include <asm/ross.h>
51 51
52#include "srmmu.h" 52#include "mm_32.h"
53 53
54enum mbus_module srmmu_modtype; 54enum mbus_module srmmu_modtype;
55static unsigned int hwbug_bitmask; 55static unsigned int hwbug_bitmask;
@@ -100,7 +100,6 @@ static unsigned long srmmu_nocache_end;
100#define SRMMU_NOCACHE_ALIGN_MAX (sizeof(ctxd_t)*SRMMU_MAX_CONTEXTS) 100#define SRMMU_NOCACHE_ALIGN_MAX (sizeof(ctxd_t)*SRMMU_MAX_CONTEXTS)
101 101
102void *srmmu_nocache_pool; 102void *srmmu_nocache_pool;
103void *srmmu_nocache_bitmap;
104static struct bit_map srmmu_nocache_map; 103static struct bit_map srmmu_nocache_map;
105 104
106static inline int srmmu_pmd_none(pmd_t pmd) 105static inline int srmmu_pmd_none(pmd_t pmd)
@@ -173,7 +172,7 @@ static void *__srmmu_get_nocache(int size, int align)
173 printk(KERN_ERR "srmmu: out of nocache %d: %d/%d\n", 172 printk(KERN_ERR "srmmu: out of nocache %d: %d/%d\n",
174 size, (int) srmmu_nocache_size, 173 size, (int) srmmu_nocache_size,
175 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT); 174 srmmu_nocache_map.used << SRMMU_NOCACHE_BITMAP_SHIFT);
176 return 0; 175 return NULL;
177 } 176 }
178 177
179 addr = SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT); 178 addr = SRMMU_NOCACHE_VADDR + (offset << SRMMU_NOCACHE_BITMAP_SHIFT);
@@ -269,6 +268,7 @@ static void __init srmmu_nocache_calcsize(void)
269 268
270static void __init srmmu_nocache_init(void) 269static void __init srmmu_nocache_init(void)
271{ 270{
271 void *srmmu_nocache_bitmap;
272 unsigned int bitmap_bits; 272 unsigned int bitmap_bits;
273 pgd_t *pgd; 273 pgd_t *pgd;
274 pmd_t *pmd; 274 pmd_t *pmd;
@@ -728,7 +728,7 @@ static inline unsigned long srmmu_probe(unsigned long vaddr)
728 "=r" (retval) : 728 "=r" (retval) :
729 "r" (vaddr | 0x400), "i" (ASI_M_FLUSH_PROBE)); 729 "r" (vaddr | 0x400), "i" (ASI_M_FLUSH_PROBE));
730 } else { 730 } else {
731 retval = leon_swprobe(vaddr, 0); 731 retval = leon_swprobe(vaddr, NULL);
732 } 732 }
733 return retval; 733 return retval;
734} 734}
@@ -865,8 +865,6 @@ static void __init map_kernel(void)
865 865
866void (*poke_srmmu)(void) = NULL; 866void (*poke_srmmu)(void) = NULL;
867 867
868extern unsigned long bootmem_init(unsigned long *pages_avail);
869
870void __init srmmu_paging_init(void) 868void __init srmmu_paging_init(void)
871{ 869{
872 int i; 870 int i;
@@ -1771,9 +1769,6 @@ static struct sparc32_cachetlb_ops smp_cachetlb_ops = {
1771/* Load up routines and constants for sun4m and sun4d mmu */ 1769/* Load up routines and constants for sun4m and sun4d mmu */
1772void __init load_mmu(void) 1770void __init load_mmu(void)
1773{ 1771{
1774 extern void ld_mmu_iommu(void);
1775 extern void ld_mmu_iounit(void);
1776
1777 /* Functions */ 1772 /* Functions */
1778 get_srmmu_type(); 1773 get_srmmu_type();
1779 1774
diff --git a/arch/sparc/mm/srmmu.h b/arch/sparc/mm/srmmu.h
deleted file mode 100644
index 5703274ccf89..000000000000
--- a/arch/sparc/mm/srmmu.h
+++ /dev/null
@@ -1,4 +0,0 @@
1/* srmmu.c */
2extern char *srmmu_name;
3
4extern void (*poke_srmmu)(void);
diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
index fe19b81acc09..a06576683c38 100644
--- a/arch/sparc/mm/tsb.c
+++ b/arch/sparc/mm/tsb.c
@@ -9,6 +9,7 @@
9#include <asm/page.h> 9#include <asm/page.h>
10#include <asm/pgtable.h> 10#include <asm/pgtable.h>
11#include <asm/mmu_context.h> 11#include <asm/mmu_context.h>
12#include <asm/setup.h>
12#include <asm/tsb.h> 13#include <asm/tsb.h>
13#include <asm/tlb.h> 14#include <asm/tlb.h>
14#include <asm/oplib.h> 15#include <asm/oplib.h>
diff --git a/arch/sparc/prom/misc_64.c b/arch/sparc/prom/misc_64.c
index f178b9dcc7b7..53a696d3eb3b 100644
--- a/arch/sparc/prom/misc_64.c
+++ b/arch/sparc/prom/misc_64.c
@@ -81,11 +81,6 @@ void prom_feval(const char *fstring)
81} 81}
82EXPORT_SYMBOL(prom_feval); 82EXPORT_SYMBOL(prom_feval);
83 83
84#ifdef CONFIG_SMP
85extern void smp_capture(void);
86extern void smp_release(void);
87#endif
88
89/* Drop into the prom, with the chance to continue with the 'go' 84/* Drop into the prom, with the chance to continue with the 'go'
90 * prom command. 85 * prom command.
91 */ 86 */
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index aafad6fa1667..928237a7b9ca 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -51,9 +51,6 @@ config ARCH_HAS_ILOG2_U32
51config ARCH_HAS_ILOG2_U64 51config ARCH_HAS_ILOG2_U64
52 bool 52 bool
53 53
54config ARCH_HAS_CPUFREQ
55 bool
56
57config GENERIC_HWEIGHT 54config GENERIC_HWEIGHT
58 def_bool y 55 def_bool y
59 56
@@ -87,7 +84,6 @@ config ARCH_PUV3
87 select GENERIC_CLOCKEVENTS 84 select GENERIC_CLOCKEVENTS
88 select HAVE_CLK 85 select HAVE_CLK
89 select ARCH_REQUIRE_GPIOLIB 86 select ARCH_REQUIRE_GPIOLIB
90 select ARCH_HAS_CPUFREQ
91 87
92# CONFIGs for ARCH_PUV3 88# CONFIGs for ARCH_PUV3
93 89
@@ -198,9 +194,7 @@ menu "Power management options"
198 194
199source "kernel/power/Kconfig" 195source "kernel/power/Kconfig"
200 196
201if ARCH_HAS_CPUFREQ
202source "drivers/cpufreq/Kconfig" 197source "drivers/cpufreq/Kconfig"
203endif
204 198
205config ARCH_SUSPEND_POSSIBLE 199config ARCH_SUSPEND_POSSIBLE
206 def_bool y if !ARCH_FPGA 200 def_bool y if !ARCH_FPGA
diff --git a/arch/unicore32/include/asm/io.h b/arch/unicore32/include/asm/io.h
index 39decb6e6f57..cb1d8fd2b16b 100644
--- a/arch/unicore32/include/asm/io.h
+++ b/arch/unicore32/include/asm/io.h
@@ -39,10 +39,37 @@ extern void __uc32_iounmap(volatile void __iomem *addr);
39#define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size) 39#define ioremap_nocache(cookie, size) __uc32_ioremap(cookie, size)
40#define iounmap(cookie) __uc32_iounmap(cookie) 40#define iounmap(cookie) __uc32_iounmap(cookie)
41 41
42#define readb_relaxed readb
43#define readw_relaxed readw
44#define readl_relaxed readl
45
42#define HAVE_ARCH_PIO_SIZE 46#define HAVE_ARCH_PIO_SIZE
43#define PIO_OFFSET (unsigned int)(PCI_IOBASE) 47#define PIO_OFFSET (unsigned int)(PCI_IOBASE)
44#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT) 48#define PIO_MASK (unsigned int)(IO_SPACE_LIMIT)
45#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1) 49#define PIO_RESERVED (PIO_OFFSET + PIO_MASK + 1)
46 50
51#ifdef CONFIG_STRICT_DEVMEM
52
53#include <linux/ioport.h>
54#include <linux/mm.h>
55
56/*
57 * devmem_is_allowed() checks to see if /dev/mem access to a certain
58 * address is valid. The argument is a physical page number.
59 * We mimic x86 here by disallowing access to system RAM as well as
60 * device-exclusive MMIO regions. This effectively disable read()/write()
61 * on /dev/mem.
62 */
63static inline int devmem_is_allowed(unsigned long pfn)
64{
65 if (iomem_is_exclusive(pfn << PAGE_SHIFT))
66 return 0;
67 if (!page_is_ram(pfn))
68 return 1;
69 return 0;
70}
71
72#endif /* CONFIG_STRICT_DEVMEM */
73
47#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
48#endif /* __UNICORE_IO_H__ */ 75#endif /* __UNICORE_IO_H__ */
diff --git a/arch/unicore32/include/asm/pgtable.h b/arch/unicore32/include/asm/pgtable.h
index 233c25880df4..ed6f7d000fba 100644
--- a/arch/unicore32/include/asm/pgtable.h
+++ b/arch/unicore32/include/asm/pgtable.h
@@ -87,16 +87,16 @@ extern pgprot_t pgprot_kernel;
87 87
88#define PAGE_NONE pgprot_user 88#define PAGE_NONE pgprot_user
89#define PAGE_SHARED __pgprot(pgprot_val(pgprot_user | PTE_READ \ 89#define PAGE_SHARED __pgprot(pgprot_val(pgprot_user | PTE_READ \
90 | PTE_WRITE) 90 | PTE_WRITE))
91#define PAGE_SHARED_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \ 91#define PAGE_SHARED_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \
92 | PTE_WRITE \ 92 | PTE_WRITE \
93 | PTE_EXEC) 93 | PTE_EXEC))
94#define PAGE_COPY __pgprot(pgprot_val(pgprot_user | PTE_READ) 94#define PAGE_COPY __pgprot(pgprot_val(pgprot_user | PTE_READ)
95#define PAGE_COPY_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \ 95#define PAGE_COPY_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \
96 | PTE_EXEC) 96 | PTE_EXEC))
97#define PAGE_READONLY __pgprot(pgprot_val(pgprot_user | PTE_READ) 97#define PAGE_READONLY __pgprot(pgprot_val(pgprot_user | PTE_READ))
98#define PAGE_READONLY_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \ 98#define PAGE_READONLY_EXEC __pgprot(pgprot_val(pgprot_user | PTE_READ \
99 | PTE_EXEC) 99 | PTE_EXEC))
100#define PAGE_KERNEL pgprot_kernel 100#define PAGE_KERNEL pgprot_kernel
101#define PAGE_KERNEL_EXEC __pgprot(pgprot_val(pgprot_kernel | PTE_EXEC)) 101#define PAGE_KERNEL_EXEC __pgprot(pgprot_val(pgprot_kernel | PTE_EXEC))
102 102
diff --git a/arch/unicore32/include/asm/ptrace.h b/arch/unicore32/include/asm/ptrace.h
index 9df53d991c78..02bf5a415bf5 100644
--- a/arch/unicore32/include/asm/ptrace.h
+++ b/arch/unicore32/include/asm/ptrace.h
@@ -55,6 +55,7 @@ static inline int valid_user_regs(struct pt_regs *regs)
55 55
56#define instruction_pointer(regs) ((regs)->UCreg_pc) 56#define instruction_pointer(regs) ((regs)->UCreg_pc)
57#define user_stack_pointer(regs) ((regs)->UCreg_sp) 57#define user_stack_pointer(regs) ((regs)->UCreg_sp)
58#define profile_pc(regs) instruction_pointer(regs)
58 59
59#endif /* __ASSEMBLY__ */ 60#endif /* __ASSEMBLY__ */
60#endif 61#endif
diff --git a/arch/unicore32/kernel/clock.c b/arch/unicore32/kernel/clock.c
index 18d4563e6fa5..b1ca775f6f6e 100644
--- a/arch/unicore32/kernel/clock.c
+++ b/arch/unicore32/kernel/clock.c
@@ -179,7 +179,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
179 } 179 }
180#ifdef CONFIG_CPU_FREQ 180#ifdef CONFIG_CPU_FREQ
181 if (clk == &clk_mclk_clk) { 181 if (clk == &clk_mclk_clk) {
182 u32 pll_rate, divstatus = PM_DIVSTATUS; 182 u32 pll_rate, divstatus = readl(PM_DIVSTATUS);
183 int ret, i; 183 int ret, i;
184 184
185 /* lookup mclk_clk_table */ 185 /* lookup mclk_clk_table */
@@ -201,10 +201,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
201 / (((divstatus & 0x0000f000) >> 12) + 1); 201 / (((divstatus & 0x0000f000) >> 12) + 1);
202 202
203 /* set pll sys cfg reg. */ 203 /* set pll sys cfg reg. */
204 PM_PLLSYSCFG = pll_rate; 204 writel(pll_rate, PM_PLLSYSCFG);
205 205
206 PM_PMCR = PM_PMCR_CFBSYS; 206 writel(PM_PMCR_CFBSYS, PM_PMCR);
207 while ((PM_PLLDFCDONE & PM_PLLDFCDONE_SYSDFC) 207 while ((readl(PM_PLLDFCDONE) & PM_PLLDFCDONE_SYSDFC)
208 != PM_PLLDFCDONE_SYSDFC) 208 != PM_PLLDFCDONE_SYSDFC)
209 udelay(100); 209 udelay(100);
210 /* about 1ms */ 210 /* about 1ms */
diff --git a/arch/unicore32/kernel/ksyms.c b/arch/unicore32/kernel/ksyms.c
index d285d71cbe35..0323528a80fd 100644
--- a/arch/unicore32/kernel/ksyms.c
+++ b/arch/unicore32/kernel/ksyms.c
@@ -23,41 +23,15 @@
23 23
24#include "ksyms.h" 24#include "ksyms.h"
25 25
26EXPORT_SYMBOL(find_first_bit);
27EXPORT_SYMBOL(find_first_zero_bit);
26EXPORT_SYMBOL(find_next_zero_bit); 28EXPORT_SYMBOL(find_next_zero_bit);
27EXPORT_SYMBOL(find_next_bit); 29EXPORT_SYMBOL(find_next_bit);
28 30
29EXPORT_SYMBOL(__backtrace);
30
31 /* platform dependent support */ 31 /* platform dependent support */
32EXPORT_SYMBOL(__udelay); 32EXPORT_SYMBOL(__udelay);
33EXPORT_SYMBOL(__const_udelay); 33EXPORT_SYMBOL(__const_udelay);
34 34
35 /* networking */
36EXPORT_SYMBOL(csum_partial);
37EXPORT_SYMBOL(csum_partial_copy_from_user);
38EXPORT_SYMBOL(csum_partial_copy_nocheck);
39EXPORT_SYMBOL(__csum_ipv6_magic);
40
41 /* io */
42#ifndef __raw_readsb
43EXPORT_SYMBOL(__raw_readsb);
44#endif
45#ifndef __raw_readsw
46EXPORT_SYMBOL(__raw_readsw);
47#endif
48#ifndef __raw_readsl
49EXPORT_SYMBOL(__raw_readsl);
50#endif
51#ifndef __raw_writesb
52EXPORT_SYMBOL(__raw_writesb);
53#endif
54#ifndef __raw_writesw
55EXPORT_SYMBOL(__raw_writesw);
56#endif
57#ifndef __raw_writesl
58EXPORT_SYMBOL(__raw_writesl);
59#endif
60
61 /* string / mem functions */ 35 /* string / mem functions */
62EXPORT_SYMBOL(strchr); 36EXPORT_SYMBOL(strchr);
63EXPORT_SYMBOL(strrchr); 37EXPORT_SYMBOL(strrchr);
@@ -76,23 +50,12 @@ EXPORT_SYMBOL(__copy_from_user);
76EXPORT_SYMBOL(__copy_to_user); 50EXPORT_SYMBOL(__copy_to_user);
77EXPORT_SYMBOL(__clear_user); 51EXPORT_SYMBOL(__clear_user);
78 52
79EXPORT_SYMBOL(__get_user_1);
80EXPORT_SYMBOL(__get_user_2);
81EXPORT_SYMBOL(__get_user_4);
82
83EXPORT_SYMBOL(__put_user_1);
84EXPORT_SYMBOL(__put_user_2);
85EXPORT_SYMBOL(__put_user_4);
86EXPORT_SYMBOL(__put_user_8);
87
88EXPORT_SYMBOL(__ashldi3); 53EXPORT_SYMBOL(__ashldi3);
89EXPORT_SYMBOL(__ashrdi3); 54EXPORT_SYMBOL(__ashrdi3);
90EXPORT_SYMBOL(__divsi3); 55EXPORT_SYMBOL(__divsi3);
91EXPORT_SYMBOL(__lshrdi3); 56EXPORT_SYMBOL(__lshrdi3);
92EXPORT_SYMBOL(__modsi3); 57EXPORT_SYMBOL(__modsi3);
93EXPORT_SYMBOL(__muldi3);
94EXPORT_SYMBOL(__ucmpdi2); 58EXPORT_SYMBOL(__ucmpdi2);
95EXPORT_SYMBOL(__udivsi3); 59EXPORT_SYMBOL(__udivsi3);
96EXPORT_SYMBOL(__umodsi3); 60EXPORT_SYMBOL(__umodsi3);
97EXPORT_SYMBOL(__bswapsi2);
98 61
diff --git a/arch/unicore32/kernel/ksyms.h b/arch/unicore32/kernel/ksyms.h
index 185cdc712d03..31472ad9467a 100644
--- a/arch/unicore32/kernel/ksyms.h
+++ b/arch/unicore32/kernel/ksyms.h
@@ -8,8 +8,6 @@ extern void __ashrdi3(void);
8extern void __divsi3(void); 8extern void __divsi3(void);
9extern void __lshrdi3(void); 9extern void __lshrdi3(void);
10extern void __modsi3(void); 10extern void __modsi3(void);
11extern void __muldi3(void);
12extern void __ucmpdi2(void); 11extern void __ucmpdi2(void);
13extern void __udivsi3(void); 12extern void __udivsi3(void);
14extern void __umodsi3(void); 13extern void __umodsi3(void);
15extern void __bswapsi2(void);
diff --git a/arch/unicore32/kernel/module.c b/arch/unicore32/kernel/module.c
index 16bd1495b934..dc41f6dfedb6 100644
--- a/arch/unicore32/kernel/module.c
+++ b/arch/unicore32/kernel/module.c
@@ -24,14 +24,9 @@
24 24
25void *module_alloc(unsigned long size) 25void *module_alloc(unsigned long size)
26{ 26{
27 struct vm_struct *area; 27 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
28 28 GFP_KERNEL, PAGE_KERNEL_EXEC, NUMA_NO_NODE,
29 size = PAGE_ALIGN(size); 29 __builtin_return_address(0));
30 area = __get_vm_area(size, VM_ALLOC, MODULES_VADDR, MODULES_END);
31 if (!area)
32 return NULL;
33
34 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
35} 30}
36 31
37int 32int
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 778ebba80827..b008e9961465 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -60,6 +60,7 @@ void machine_halt(void)
60 * Function pointers to optional machine specific functions 60 * Function pointers to optional machine specific functions
61 */ 61 */
62void (*pm_power_off)(void) = NULL; 62void (*pm_power_off)(void) = NULL;
63EXPORT_SYMBOL(pm_power_off);
63 64
64void machine_power_off(void) 65void machine_power_off(void)
65{ 66{
diff --git a/arch/unicore32/kernel/setup.c b/arch/unicore32/kernel/setup.c
index 87adbf5ebfe0..3fa317f96122 100644
--- a/arch/unicore32/kernel/setup.c
+++ b/arch/unicore32/kernel/setup.c
@@ -53,6 +53,10 @@ struct stack {
53 53
54static struct stack stacks[NR_CPUS]; 54static struct stack stacks[NR_CPUS];
55 55
56#ifdef CONFIG_VGA_CONSOLE
57struct screen_info screen_info;
58#endif
59
56char elf_platform[ELF_PLATFORM_SIZE]; 60char elf_platform[ELF_PLATFORM_SIZE];
57EXPORT_SYMBOL(elf_platform); 61EXPORT_SYMBOL(elf_platform);
58 62
diff --git a/arch/unicore32/mm/alignment.c b/arch/unicore32/mm/alignment.c
index de7dc5fdd58b..24e836023e6c 100644
--- a/arch/unicore32/mm/alignment.c
+++ b/arch/unicore32/mm/alignment.c
@@ -21,6 +21,7 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/uaccess.h> 22#include <linux/uaccess.h>
23 23
24#include <asm/pgtable.h>
24#include <asm/tlbflush.h> 25#include <asm/tlbflush.h>
25#include <asm/unaligned.h> 26#include <asm/unaligned.h>
26 27
diff --git a/arch/unicore32/mm/proc-syms.c b/arch/unicore32/mm/proc-syms.c
index f30071e3665d..21c00fc85c99 100644
--- a/arch/unicore32/mm/proc-syms.c
+++ b/arch/unicore32/mm/proc-syms.c
@@ -19,5 +19,7 @@
19EXPORT_SYMBOL(cpu_dcache_clean_area); 19EXPORT_SYMBOL(cpu_dcache_clean_area);
20EXPORT_SYMBOL(cpu_set_pte); 20EXPORT_SYMBOL(cpu_set_pte);
21 21
22EXPORT_SYMBOL(__cpuc_coherent_kern_range);
23
22EXPORT_SYMBOL(__cpuc_dma_flush_range); 24EXPORT_SYMBOL(__cpuc_dma_flush_range);
23EXPORT_SYMBOL(__cpuc_dma_clean_range); 25EXPORT_SYMBOL(__cpuc_dma_clean_range);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index fcefdda5136d..a8f749ef0fdc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1672,7 +1672,6 @@ config RELOCATABLE
1672config RANDOMIZE_BASE 1672config RANDOMIZE_BASE
1673 bool "Randomize the address of the kernel image" 1673 bool "Randomize the address of the kernel image"
1674 depends on RELOCATABLE 1674 depends on RELOCATABLE
1675 depends on !HIBERNATION
1676 default n 1675 default n
1677 ---help--- 1676 ---help---
1678 Randomizes the physical and virtual address at which the 1677 Randomizes the physical and virtual address at which the
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
index 4dbf967da50d..fc6091abedb7 100644
--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -289,10 +289,17 @@ unsigned char *choose_kernel_location(unsigned char *input,
289 unsigned long choice = (unsigned long)output; 289 unsigned long choice = (unsigned long)output;
290 unsigned long random; 290 unsigned long random;
291 291
292#ifdef CONFIG_HIBERNATION
293 if (!cmdline_find_option_bool("kaslr")) {
294 debug_putstr("KASLR disabled by default...\n");
295 goto out;
296 }
297#else
292 if (cmdline_find_option_bool("nokaslr")) { 298 if (cmdline_find_option_bool("nokaslr")) {
293 debug_putstr("KASLR disabled...\n"); 299 debug_putstr("KASLR disabled by cmdline...\n");
294 goto out; 300 goto out;
295 } 301 }
302#endif
296 303
297 /* Record the various known unsafe memory ranges. */ 304 /* Record the various known unsafe memory ranges. */
298 mem_avoid_init((unsigned long)input, input_size, 305 mem_avoid_init((unsigned long)input, input_size,
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index c6eb418c5627..0d0e922fafc1 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -343,6 +343,7 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
343 if (poke_int3_handler(regs)) 343 if (poke_int3_handler(regs))
344 return; 344 return;
345 345
346 prev_state = exception_enter();
346#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP 347#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
347 if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP, 348 if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
348 SIGTRAP) == NOTIFY_STOP) 349 SIGTRAP) == NOTIFY_STOP)
@@ -351,9 +352,8 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
351 352
352#ifdef CONFIG_KPROBES 353#ifdef CONFIG_KPROBES
353 if (kprobe_int3_handler(regs)) 354 if (kprobe_int3_handler(regs))
354 return; 355 goto exit;
355#endif 356#endif
356 prev_state = exception_enter();
357 357
358 if (notify_die(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP, 358 if (notify_die(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
359 SIGTRAP) == NOTIFY_STOP) 359 SIGTRAP) == NOTIFY_STOP)
@@ -433,6 +433,8 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
433 unsigned long dr6; 433 unsigned long dr6;
434 int si_code; 434 int si_code;
435 435
436 prev_state = exception_enter();
437
436 get_debugreg(dr6, 6); 438 get_debugreg(dr6, 6);
437 439
438 /* Filter out all the reserved bits which are preset to 1 */ 440 /* Filter out all the reserved bits which are preset to 1 */
@@ -465,7 +467,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
465 if (kprobe_debug_handler(regs)) 467 if (kprobe_debug_handler(regs))
466 goto exit; 468 goto exit;
467#endif 469#endif
468 prev_state = exception_enter();
469 470
470 if (notify_die(DIE_DEBUG, "debug", regs, (long)&dr6, error_code, 471 if (notify_die(DIE_DEBUG, "debug", regs, (long)&dr6, error_code,
471 SIGTRAP) == NOTIFY_STOP) 472 SIGTRAP) == NOTIFY_STOP)
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index f17b29210ac4..ffb101e45731 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1537,7 +1537,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
1537 if (!xen_pvh_domain()) 1537 if (!xen_pvh_domain())
1538 pv_cpu_ops = xen_cpu_ops; 1538 pv_cpu_ops = xen_cpu_ops;
1539 1539
1540 x86_init.resources.memory_setup = xen_memory_setup; 1540 if (xen_feature(XENFEAT_auto_translated_physmap))
1541 x86_init.resources.memory_setup = xen_auto_xlated_memory_setup;
1542 else
1543 x86_init.resources.memory_setup = xen_memory_setup;
1541 x86_init.oem.arch_setup = xen_arch_setup; 1544 x86_init.oem.arch_setup = xen_arch_setup;
1542 x86_init.oem.banner = xen_banner; 1545 x86_init.oem.banner = xen_banner;
1543 1546
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 821a11ada590..2e555163c2fe 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -27,7 +27,6 @@
27#include <xen/interface/memory.h> 27#include <xen/interface/memory.h>
28#include <xen/interface/physdev.h> 28#include <xen/interface/physdev.h>
29#include <xen/features.h> 29#include <xen/features.h>
30#include "mmu.h"
31#include "xen-ops.h" 30#include "xen-ops.h"
32#include "vdso.h" 31#include "vdso.h"
33 32
@@ -82,9 +81,6 @@ static void __init xen_add_extra_mem(u64 start, u64 size)
82 81
83 memblock_reserve(start, size); 82 memblock_reserve(start, size);
84 83
85 if (xen_feature(XENFEAT_auto_translated_physmap))
86 return;
87
88 xen_max_p2m_pfn = PFN_DOWN(start + size); 84 xen_max_p2m_pfn = PFN_DOWN(start + size);
89 for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) { 85 for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) {
90 unsigned long mfn = pfn_to_mfn(pfn); 86 unsigned long mfn = pfn_to_mfn(pfn);
@@ -107,7 +103,6 @@ static unsigned long __init xen_do_chunk(unsigned long start,
107 .domid = DOMID_SELF 103 .domid = DOMID_SELF
108 }; 104 };
109 unsigned long len = 0; 105 unsigned long len = 0;
110 int xlated_phys = xen_feature(XENFEAT_auto_translated_physmap);
111 unsigned long pfn; 106 unsigned long pfn;
112 int ret; 107 int ret;
113 108
@@ -121,7 +116,7 @@ static unsigned long __init xen_do_chunk(unsigned long start,
121 continue; 116 continue;
122 frame = mfn; 117 frame = mfn;
123 } else { 118 } else {
124 if (!xlated_phys && mfn != INVALID_P2M_ENTRY) 119 if (mfn != INVALID_P2M_ENTRY)
125 continue; 120 continue;
126 frame = pfn; 121 frame = pfn;
127 } 122 }
@@ -159,13 +154,6 @@ static unsigned long __init xen_do_chunk(unsigned long start,
159static unsigned long __init xen_release_chunk(unsigned long start, 154static unsigned long __init xen_release_chunk(unsigned long start,
160 unsigned long end) 155 unsigned long end)
161{ 156{
162 /*
163 * Xen already ballooned out the E820 non RAM regions for us
164 * and set them up properly in EPT.
165 */
166 if (xen_feature(XENFEAT_auto_translated_physmap))
167 return end - start;
168
169 return xen_do_chunk(start, end, true); 157 return xen_do_chunk(start, end, true);
170} 158}
171 159
@@ -234,13 +222,7 @@ static void __init xen_set_identity_and_release_chunk(
234 * (except for the ISA region which must be 1:1 mapped) to 222 * (except for the ISA region which must be 1:1 mapped) to
235 * release the refcounts (in Xen) on the original frames. 223 * release the refcounts (in Xen) on the original frames.
236 */ 224 */
237 225 for (pfn = start_pfn; pfn <= max_pfn_mapped && pfn < end_pfn; pfn++) {
238 /*
239 * PVH E820 matches the hypervisor's P2M which means we need to
240 * account for the proper values of *release and *identity.
241 */
242 for (pfn = start_pfn; !xen_feature(XENFEAT_auto_translated_physmap) &&
243 pfn <= max_pfn_mapped && pfn < end_pfn; pfn++) {
244 pte_t pte = __pte_ma(0); 226 pte_t pte = __pte_ma(0);
245 227
246 if (pfn < PFN_UP(ISA_END_ADDRESS)) 228 if (pfn < PFN_UP(ISA_END_ADDRESS))
@@ -518,6 +500,35 @@ char * __init xen_memory_setup(void)
518} 500}
519 501
520/* 502/*
503 * Machine specific memory setup for auto-translated guests.
504 */
505char * __init xen_auto_xlated_memory_setup(void)
506{
507 static struct e820entry map[E820MAX] __initdata;
508
509 struct xen_memory_map memmap;
510 int i;
511 int rc;
512
513 memmap.nr_entries = E820MAX;
514 set_xen_guest_handle(memmap.buffer, map);
515
516 rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
517 if (rc < 0)
518 panic("No memory map (%d)\n", rc);
519
520 sanitize_e820_map(map, ARRAY_SIZE(map), &memmap.nr_entries);
521
522 for (i = 0; i < memmap.nr_entries; i++)
523 e820_add_region(map[i].addr, map[i].size, map[i].type);
524
525 memblock_reserve(__pa(xen_start_info->mfn_list),
526 xen_start_info->pt_base - xen_start_info->mfn_list);
527
528 return "Xen";
529}
530
531/*
521 * Set the bit indicating "nosegneg" library variants should be used. 532 * Set the bit indicating "nosegneg" library variants should be used.
522 * We only need to bother in pure 32-bit mode; compat 32-bit processes 533 * We only need to bother in pure 32-bit mode; compat 32-bit processes
523 * can have un-truncated segments, so wrapping around is allowed. 534 * can have un-truncated segments, so wrapping around is allowed.
@@ -590,13 +601,7 @@ void xen_enable_syscall(void)
590 } 601 }
591#endif /* CONFIG_X86_64 */ 602#endif /* CONFIG_X86_64 */
592} 603}
593void xen_enable_nmi(void) 604
594{
595#ifdef CONFIG_X86_64
596 if (register_callback(CALLBACKTYPE_nmi, (char *)nmi))
597 BUG();
598#endif
599}
600void __init xen_pvmmu_arch_setup(void) 605void __init xen_pvmmu_arch_setup(void)
601{ 606{
602 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); 607 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
@@ -611,7 +616,6 @@ void __init xen_pvmmu_arch_setup(void)
611 616
612 xen_enable_sysenter(); 617 xen_enable_sysenter();
613 xen_enable_syscall(); 618 xen_enable_syscall();
614 xen_enable_nmi();
615} 619}
616 620
617/* This function is not called for HVM domains */ 621/* This function is not called for HVM domains */
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index c834d4b231f0..97d87659f779 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -36,6 +36,7 @@ void xen_mm_unpin_all(void);
36void xen_set_pat(u64); 36void xen_set_pat(u64);
37 37
38char * __init xen_memory_setup(void); 38char * __init xen_memory_setup(void);
39char * xen_auto_xlated_memory_setup(void);
39void __init xen_arch_setup(void); 40void __init xen_arch_setup(void);
40void xen_enable_sysenter(void); 41void xen_enable_sysenter(void);
41void xen_enable_syscall(void); 42void xen_enable_syscall(void);
diff --git a/block/blk-core.c b/block/blk-core.c
index f6f6b9af3e3f..6f8dba161bfe 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -3312,8 +3312,7 @@ int __init blk_dev_init(void)
3312 3312
3313 /* used for unplugging and affects IO latency/throughput - HIGHPRI */ 3313 /* used for unplugging and affects IO latency/throughput - HIGHPRI */
3314 kblockd_workqueue = alloc_workqueue("kblockd", 3314 kblockd_workqueue = alloc_workqueue("kblockd",
3315 WQ_MEM_RECLAIM | WQ_HIGHPRI | 3315 WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
3316 WQ_POWER_EFFICIENT, 0);
3317 if (!kblockd_workqueue) 3316 if (!kblockd_workqueue)
3318 panic("Failed to create kblockd\n"); 3317 panic("Failed to create kblockd\n");
3319 3318
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 8ffee4b5f93d..3cb5e9e7108a 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -422,44 +422,6 @@ void blk_insert_flush(struct request *rq)
422} 422}
423 423
424/** 424/**
425 * blk_abort_flushes - @q is being aborted, abort flush requests
426 * @q: request_queue being aborted
427 *
428 * To be called from elv_abort_queue(). @q is being aborted. Prepare all
429 * FLUSH/FUA requests for abortion.
430 *
431 * CONTEXT:
432 * spin_lock_irq(q->queue_lock)
433 */
434void blk_abort_flushes(struct request_queue *q)
435{
436 struct request *rq, *n;
437 int i;
438
439 /*
440 * Requests in flight for data are already owned by the dispatch
441 * queue or the device driver. Just restore for normal completion.
442 */
443 list_for_each_entry_safe(rq, n, &q->flush_data_in_flight, flush.list) {
444 list_del_init(&rq->flush.list);
445 blk_flush_restore_request(rq);
446 }
447
448 /*
449 * We need to give away requests on flush queues. Restore for
450 * normal completion and put them on the dispatch queue.
451 */
452 for (i = 0; i < ARRAY_SIZE(q->flush_queue); i++) {
453 list_for_each_entry_safe(rq, n, &q->flush_queue[i],
454 flush.list) {
455 list_del_init(&rq->flush.list);
456 blk_flush_restore_request(rq);
457 list_add_tail(&rq->queuelist, &q->queue_head);
458 }
459 }
460}
461
462/**
463 * blkdev_issue_flush - queue a flush 425 * blkdev_issue_flush - queue a flush
464 * @bdev: blockdev to issue flush for 426 * @bdev: blockdev to issue flush for
465 * @gfp_mask: memory allocation flags (for bio_alloc) 427 * @gfp_mask: memory allocation flags (for bio_alloc)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 1aab39f71d95..c1b92426c95e 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -43,9 +43,16 @@ bool blk_mq_has_free_tags(struct blk_mq_tags *tags)
43 return bt_has_free_tags(&tags->bitmap_tags); 43 return bt_has_free_tags(&tags->bitmap_tags);
44} 44}
45 45
46static inline void bt_index_inc(unsigned int *index) 46static inline int bt_index_inc(int index)
47{ 47{
48 *index = (*index + 1) & (BT_WAIT_QUEUES - 1); 48 return (index + 1) & (BT_WAIT_QUEUES - 1);
49}
50
51static inline void bt_index_atomic_inc(atomic_t *index)
52{
53 int old = atomic_read(index);
54 int new = bt_index_inc(old);
55 atomic_cmpxchg(index, old, new);
49} 56}
50 57
51/* 58/*
@@ -69,14 +76,14 @@ static void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags)
69 int i, wake_index; 76 int i, wake_index;
70 77
71 bt = &tags->bitmap_tags; 78 bt = &tags->bitmap_tags;
72 wake_index = bt->wake_index; 79 wake_index = atomic_read(&bt->wake_index);
73 for (i = 0; i < BT_WAIT_QUEUES; i++) { 80 for (i = 0; i < BT_WAIT_QUEUES; i++) {
74 struct bt_wait_state *bs = &bt->bs[wake_index]; 81 struct bt_wait_state *bs = &bt->bs[wake_index];
75 82
76 if (waitqueue_active(&bs->wait)) 83 if (waitqueue_active(&bs->wait))
77 wake_up(&bs->wait); 84 wake_up(&bs->wait);
78 85
79 bt_index_inc(&wake_index); 86 wake_index = bt_index_inc(wake_index);
80 } 87 }
81} 88}
82 89
@@ -212,12 +219,14 @@ static struct bt_wait_state *bt_wait_ptr(struct blk_mq_bitmap_tags *bt,
212 struct blk_mq_hw_ctx *hctx) 219 struct blk_mq_hw_ctx *hctx)
213{ 220{
214 struct bt_wait_state *bs; 221 struct bt_wait_state *bs;
222 int wait_index;
215 223
216 if (!hctx) 224 if (!hctx)
217 return &bt->bs[0]; 225 return &bt->bs[0];
218 226
219 bs = &bt->bs[hctx->wait_index]; 227 wait_index = atomic_read(&hctx->wait_index);
220 bt_index_inc(&hctx->wait_index); 228 bs = &bt->bs[wait_index];
229 bt_index_atomic_inc(&hctx->wait_index);
221 return bs; 230 return bs;
222} 231}
223 232
@@ -239,18 +248,12 @@ static int bt_get(struct blk_mq_alloc_data *data,
239 248
240 bs = bt_wait_ptr(bt, hctx); 249 bs = bt_wait_ptr(bt, hctx);
241 do { 250 do {
242 bool was_empty;
243
244 was_empty = list_empty(&wait.task_list);
245 prepare_to_wait(&bs->wait, &wait, TASK_UNINTERRUPTIBLE); 251 prepare_to_wait(&bs->wait, &wait, TASK_UNINTERRUPTIBLE);
246 252
247 tag = __bt_get(hctx, bt, last_tag); 253 tag = __bt_get(hctx, bt, last_tag);
248 if (tag != -1) 254 if (tag != -1)
249 break; 255 break;
250 256
251 if (was_empty)
252 atomic_set(&bs->wait_cnt, bt->wake_cnt);
253
254 blk_mq_put_ctx(data->ctx); 257 blk_mq_put_ctx(data->ctx);
255 258
256 io_schedule(); 259 io_schedule();
@@ -313,18 +316,19 @@ static struct bt_wait_state *bt_wake_ptr(struct blk_mq_bitmap_tags *bt)
313{ 316{
314 int i, wake_index; 317 int i, wake_index;
315 318
316 wake_index = bt->wake_index; 319 wake_index = atomic_read(&bt->wake_index);
317 for (i = 0; i < BT_WAIT_QUEUES; i++) { 320 for (i = 0; i < BT_WAIT_QUEUES; i++) {
318 struct bt_wait_state *bs = &bt->bs[wake_index]; 321 struct bt_wait_state *bs = &bt->bs[wake_index];
319 322
320 if (waitqueue_active(&bs->wait)) { 323 if (waitqueue_active(&bs->wait)) {
321 if (wake_index != bt->wake_index) 324 int o = atomic_read(&bt->wake_index);
322 bt->wake_index = wake_index; 325 if (wake_index != o)
326 atomic_cmpxchg(&bt->wake_index, o, wake_index);
323 327
324 return bs; 328 return bs;
325 } 329 }
326 330
327 bt_index_inc(&wake_index); 331 wake_index = bt_index_inc(wake_index);
328 } 332 }
329 333
330 return NULL; 334 return NULL;
@@ -334,6 +338,7 @@ static void bt_clear_tag(struct blk_mq_bitmap_tags *bt, unsigned int tag)
334{ 338{
335 const int index = TAG_TO_INDEX(bt, tag); 339 const int index = TAG_TO_INDEX(bt, tag);
336 struct bt_wait_state *bs; 340 struct bt_wait_state *bs;
341 int wait_cnt;
337 342
338 /* 343 /*
339 * The unlock memory barrier need to order access to req in free 344 * The unlock memory barrier need to order access to req in free
@@ -342,10 +347,19 @@ static void bt_clear_tag(struct blk_mq_bitmap_tags *bt, unsigned int tag)
342 clear_bit_unlock(TAG_TO_BIT(bt, tag), &bt->map[index].word); 347 clear_bit_unlock(TAG_TO_BIT(bt, tag), &bt->map[index].word);
343 348
344 bs = bt_wake_ptr(bt); 349 bs = bt_wake_ptr(bt);
345 if (bs && atomic_dec_and_test(&bs->wait_cnt)) { 350 if (!bs)
346 atomic_set(&bs->wait_cnt, bt->wake_cnt); 351 return;
347 bt_index_inc(&bt->wake_index); 352
353 wait_cnt = atomic_dec_return(&bs->wait_cnt);
354 if (wait_cnt == 0) {
355wake:
356 atomic_add(bt->wake_cnt, &bs->wait_cnt);
357 bt_index_atomic_inc(&bt->wake_index);
348 wake_up(&bs->wait); 358 wake_up(&bs->wait);
359 } else if (wait_cnt < 0) {
360 wait_cnt = atomic_inc_return(&bs->wait_cnt);
361 if (!wait_cnt)
362 goto wake;
349 } 363 }
350} 364}
351 365
@@ -499,10 +513,13 @@ static int bt_alloc(struct blk_mq_bitmap_tags *bt, unsigned int depth,
499 return -ENOMEM; 513 return -ENOMEM;
500 } 514 }
501 515
502 for (i = 0; i < BT_WAIT_QUEUES; i++) 516 bt_update_count(bt, depth);
517
518 for (i = 0; i < BT_WAIT_QUEUES; i++) {
503 init_waitqueue_head(&bt->bs[i].wait); 519 init_waitqueue_head(&bt->bs[i].wait);
520 atomic_set(&bt->bs[i].wait_cnt, bt->wake_cnt);
521 }
504 522
505 bt_update_count(bt, depth);
506 return 0; 523 return 0;
507} 524}
508 525
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index 98696a65d4d4..6206ed17ef76 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -24,7 +24,7 @@ struct blk_mq_bitmap_tags {
24 unsigned int map_nr; 24 unsigned int map_nr;
25 struct blk_align_bitmap *map; 25 struct blk_align_bitmap *map;
26 26
27 unsigned int wake_index; 27 atomic_t wake_index;
28 struct bt_wait_state *bs; 28 struct bt_wait_state *bs;
29}; 29};
30 30
diff --git a/block/blk-mq.c b/block/blk-mq.c
index e11f5f8e0313..0ef2dc7f01bf 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -109,7 +109,7 @@ static void blk_mq_queue_exit(struct request_queue *q)
109 __percpu_counter_add(&q->mq_usage_counter, -1, 1000000); 109 __percpu_counter_add(&q->mq_usage_counter, -1, 1000000);
110} 110}
111 111
112static void __blk_mq_drain_queue(struct request_queue *q) 112void blk_mq_drain_queue(struct request_queue *q)
113{ 113{
114 while (true) { 114 while (true) {
115 s64 count; 115 s64 count;
@@ -120,7 +120,7 @@ static void __blk_mq_drain_queue(struct request_queue *q)
120 120
121 if (count == 0) 121 if (count == 0)
122 break; 122 break;
123 blk_mq_run_queues(q, false); 123 blk_mq_start_hw_queues(q);
124 msleep(10); 124 msleep(10);
125 } 125 }
126} 126}
@@ -139,12 +139,7 @@ static void blk_mq_freeze_queue(struct request_queue *q)
139 spin_unlock_irq(q->queue_lock); 139 spin_unlock_irq(q->queue_lock);
140 140
141 if (drain) 141 if (drain)
142 __blk_mq_drain_queue(q); 142 blk_mq_drain_queue(q);
143}
144
145void blk_mq_drain_queue(struct request_queue *q)
146{
147 __blk_mq_drain_queue(q);
148} 143}
149 144
150static void blk_mq_unfreeze_queue(struct request_queue *q) 145static void blk_mq_unfreeze_queue(struct request_queue *q)
diff --git a/block/blk.h b/block/blk.h
index 45385e9abf6f..6748c4f8d7a1 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -84,7 +84,6 @@ static inline void blk_clear_rq_complete(struct request *rq)
84#define ELV_ON_HASH(rq) ((rq)->cmd_flags & REQ_HASHED) 84#define ELV_ON_HASH(rq) ((rq)->cmd_flags & REQ_HASHED)
85 85
86void blk_insert_flush(struct request *rq); 86void blk_insert_flush(struct request *rq);
87void blk_abort_flushes(struct request_queue *q);
88 87
89static inline struct request *__elv_next_request(struct request_queue *q) 88static inline struct request *__elv_next_request(struct request_queue *q)
90{ 89{
diff --git a/block/elevator.c b/block/elevator.c
index f35edddfe9b5..34bded18910e 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -729,26 +729,6 @@ int elv_may_queue(struct request_queue *q, int rw)
729 return ELV_MQUEUE_MAY; 729 return ELV_MQUEUE_MAY;
730} 730}
731 731
732void elv_abort_queue(struct request_queue *q)
733{
734 struct request *rq;
735
736 blk_abort_flushes(q);
737
738 while (!list_empty(&q->queue_head)) {
739 rq = list_entry_rq(q->queue_head.next);
740 rq->cmd_flags |= REQ_QUIET;
741 trace_block_rq_abort(q, rq);
742 /*
743 * Mark this request as started so we don't trigger
744 * any debug logic in the end I/O path.
745 */
746 blk_start_request(rq);
747 __blk_end_request_all(rq, -EIO);
748 }
749}
750EXPORT_SYMBOL(elv_abort_queue);
751
752void elv_completed_request(struct request_queue *q, struct request *rq) 732void elv_completed_request(struct request_queue *q, struct request *rq)
753{ 733{
754 struct elevator_queue *e = q->elevator; 734 struct elevator_queue *e = q->elevator;
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 63407d264885..9cb65b0e7597 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -34,6 +34,9 @@ ACPI_MODULE_NAME("acpi_lpss");
34 34
35/* Offsets relative to LPSS_PRIVATE_OFFSET */ 35/* Offsets relative to LPSS_PRIVATE_OFFSET */
36#define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16)) 36#define LPSS_CLK_DIVIDER_DEF_MASK (BIT(1) | BIT(16))
37#define LPSS_RESETS 0x04
38#define LPSS_RESETS_RESET_FUNC BIT(0)
39#define LPSS_RESETS_RESET_APB BIT(1)
37#define LPSS_GENERAL 0x08 40#define LPSS_GENERAL 0x08
38#define LPSS_GENERAL_LTR_MODE_SW BIT(2) 41#define LPSS_GENERAL_LTR_MODE_SW BIT(2)
39#define LPSS_GENERAL_UART_RTS_OVRD BIT(3) 42#define LPSS_GENERAL_UART_RTS_OVRD BIT(3)
@@ -99,6 +102,17 @@ static void lpss_uart_setup(struct lpss_private_data *pdata)
99 writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset); 102 writel(reg | LPSS_GENERAL_UART_RTS_OVRD, pdata->mmio_base + offset);
100} 103}
101 104
105static void lpss_i2c_setup(struct lpss_private_data *pdata)
106{
107 unsigned int offset;
108 u32 val;
109
110 offset = pdata->dev_desc->prv_offset + LPSS_RESETS;
111 val = readl(pdata->mmio_base + offset);
112 val |= LPSS_RESETS_RESET_APB | LPSS_RESETS_RESET_FUNC;
113 writel(val, pdata->mmio_base + offset);
114}
115
102static struct lpss_device_desc lpt_dev_desc = { 116static struct lpss_device_desc lpt_dev_desc = {
103 .clk_required = true, 117 .clk_required = true,
104 .prv_offset = 0x800, 118 .prv_offset = 0x800,
@@ -171,6 +185,7 @@ static struct lpss_device_desc byt_i2c_dev_desc = {
171 .prv_offset = 0x800, 185 .prv_offset = 0x800,
172 .save_ctx = true, 186 .save_ctx = true,
173 .shared_clock = &i2c_clock, 187 .shared_clock = &i2c_clock,
188 .setup = lpss_i2c_setup,
174}; 189};
175 190
176#else 191#else
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e48fc98e71c4..0d7116f34b95 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -32,6 +32,7 @@
32#include <linux/jiffies.h> 32#include <linux/jiffies.h>
33#include <linux/async.h> 33#include <linux/async.h>
34#include <linux/dmi.h> 34#include <linux/dmi.h>
35#include <linux/delay.h>
35#include <linux/slab.h> 36#include <linux/slab.h>
36#include <linux/suspend.h> 37#include <linux/suspend.h>
37#include <asm/unaligned.h> 38#include <asm/unaligned.h>
@@ -70,6 +71,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
70MODULE_LICENSE("GPL"); 71MODULE_LICENSE("GPL");
71 72
72static int battery_bix_broken_package; 73static int battery_bix_broken_package;
74static int battery_notification_delay_ms;
73static unsigned int cache_time = 1000; 75static unsigned int cache_time = 1000;
74module_param(cache_time, uint, 0644); 76module_param(cache_time, uint, 0644);
75MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); 77MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -930,7 +932,10 @@ static ssize_t acpi_battery_write_alarm(struct file *file,
930 goto end; 932 goto end;
931 } 933 }
932 alarm_string[count] = '\0'; 934 alarm_string[count] = '\0';
933 battery->alarm = simple_strtol(alarm_string, NULL, 0); 935 if (kstrtoint(alarm_string, 0, &battery->alarm)) {
936 result = -EINVAL;
937 goto end;
938 }
934 result = acpi_battery_set_alarm(battery); 939 result = acpi_battery_set_alarm(battery);
935 end: 940 end:
936 if (!result) 941 if (!result)
@@ -1062,6 +1067,14 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
1062 if (!battery) 1067 if (!battery)
1063 return; 1068 return;
1064 old = battery->bat.dev; 1069 old = battery->bat.dev;
1070 /*
1071 * On Acer Aspire V5-573G notifications are sometimes triggered too
1072 * early. For example, when AC is unplugged and notification is
1073 * triggered, battery state is still reported as "Full", and changes to
1074 * "Discharging" only after short delay, without any notification.
1075 */
1076 if (battery_notification_delay_ms > 0)
1077 msleep(battery_notification_delay_ms);
1065 if (event == ACPI_BATTERY_NOTIFY_INFO) 1078 if (event == ACPI_BATTERY_NOTIFY_INFO)
1066 acpi_battery_refresh(battery); 1079 acpi_battery_refresh(battery);
1067 acpi_battery_update(battery, false); 1080 acpi_battery_update(battery, false);
@@ -1106,14 +1119,35 @@ static int battery_notify(struct notifier_block *nb,
1106 return 0; 1119 return 0;
1107} 1120}
1108 1121
1122static int battery_bix_broken_package_quirk(const struct dmi_system_id *d)
1123{
1124 battery_bix_broken_package = 1;
1125 return 0;
1126}
1127
1128static int battery_notification_delay_quirk(const struct dmi_system_id *d)
1129{
1130 battery_notification_delay_ms = 1000;
1131 return 0;
1132}
1133
1109static struct dmi_system_id bat_dmi_table[] = { 1134static struct dmi_system_id bat_dmi_table[] = {
1110 { 1135 {
1136 .callback = battery_bix_broken_package_quirk,
1111 .ident = "NEC LZ750/LS", 1137 .ident = "NEC LZ750/LS",
1112 .matches = { 1138 .matches = {
1113 DMI_MATCH(DMI_SYS_VENDOR, "NEC"), 1139 DMI_MATCH(DMI_SYS_VENDOR, "NEC"),
1114 DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"), 1140 DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"),
1115 }, 1141 },
1116 }, 1142 },
1143 {
1144 .callback = battery_notification_delay_quirk,
1145 .ident = "Acer Aspire V5-573G",
1146 .matches = {
1147 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
1148 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"),
1149 },
1150 },
1117 {}, 1151 {},
1118}; 1152};
1119 1153
@@ -1227,8 +1261,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1227 if (acpi_disabled) 1261 if (acpi_disabled)
1228 return; 1262 return;
1229 1263
1230 if (dmi_check_system(bat_dmi_table)) 1264 dmi_check_system(bat_dmi_table);
1231 battery_bix_broken_package = 1;
1232 1265
1233#ifdef CONFIG_ACPI_PROCFS_POWER 1266#ifdef CONFIG_ACPI_PROCFS_POWER
1234 acpi_battery_dir = acpi_lock_battery_dir(); 1267 acpi_battery_dir = acpi_lock_battery_dir();
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3f2bdc812d23..bad25b070fe0 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -235,7 +235,8 @@ void acpi_os_vprintf(const char *fmt, va_list args)
235static unsigned long acpi_rsdp; 235static unsigned long acpi_rsdp;
236static int __init setup_acpi_rsdp(char *arg) 236static int __init setup_acpi_rsdp(char *arg)
237{ 237{
238 acpi_rsdp = simple_strtoul(arg, NULL, 16); 238 if (kstrtoul(arg, 16, &acpi_rsdp))
239 return -EINVAL;
239 return 0; 240 return 0;
240} 241}
241early_param("acpi_rsdp", setup_acpi_rsdp); 242early_param("acpi_rsdp", setup_acpi_rsdp);
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 05550ba44d32..6d5a6cda0734 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -360,7 +360,8 @@ static int __init acpi_parse_apic_instance(char *str)
360 if (!str) 360 if (!str)
361 return -EINVAL; 361 return -EINVAL;
362 362
363 acpi_apic_instance = simple_strtoul(str, NULL, 0); 363 if (kstrtoint(str, 0, &acpi_apic_instance))
364 return -EINVAL;
364 365
365 pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance); 366 pr_notice("Shall use APIC/MADT table %d\n", acpi_apic_instance);
366 367
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 77087a29b127..a3b042c4d448 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -79,7 +79,7 @@ MODULE_PARM_DESC(home_node, "Home node for the device");
79 79
80static int queue_mode = NULL_Q_MQ; 80static int queue_mode = NULL_Q_MQ;
81module_param(queue_mode, int, S_IRUGO); 81module_param(queue_mode, int, S_IRUGO);
82MODULE_PARM_DESC(use_mq, "Use blk-mq interface (0=bio,1=rq,2=multiqueue)"); 82MODULE_PARM_DESC(queue_mode, "Block interface to use (0=bio,1=rq,2=multiqueue)");
83 83
84static int gb = 250; 84static int gb = 250;
85module_param(gb, int, S_IRUGO); 85module_param(gb, int, S_IRUGO);
@@ -227,7 +227,10 @@ static void null_cmd_end_timer(struct nullb_cmd *cmd)
227 227
228static void null_softirq_done_fn(struct request *rq) 228static void null_softirq_done_fn(struct request *rq)
229{ 229{
230 end_cmd(blk_mq_rq_to_pdu(rq)); 230 if (queue_mode == NULL_Q_MQ)
231 end_cmd(blk_mq_rq_to_pdu(rq));
232 else
233 end_cmd(rq->special);
231} 234}
232 235
233static inline void null_handle_cmd(struct nullb_cmd *cmd) 236static inline void null_handle_cmd(struct nullb_cmd *cmd)
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index a118ec1650fa..1f37d9870e7a 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -45,7 +45,7 @@ config OMAP_INTERCONNECT
45 45
46config ARM_CCI 46config ARM_CCI
47 bool "ARM CCI driver support" 47 bool "ARM CCI driver support"
48 depends on ARM 48 depends on ARM && OF && CPU_V7
49 help 49 help
50 Driver supporting the CCI cache coherent interconnect for ARM 50 Driver supporting the CCI cache coherent interconnect for ARM
51 platforms. 51 platforms.
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 4ad71ef2cd59..0a7ac0a7b252 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -980,7 +980,6 @@ static void push_to_pool(struct work_struct *work)
980static size_t account(struct entropy_store *r, size_t nbytes, int min, 980static size_t account(struct entropy_store *r, size_t nbytes, int min,
981 int reserved) 981 int reserved)
982{ 982{
983 int have_bytes;
984 int entropy_count, orig; 983 int entropy_count, orig;
985 size_t ibytes; 984 size_t ibytes;
986 985
@@ -989,17 +988,19 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
989 /* Can we pull enough? */ 988 /* Can we pull enough? */
990retry: 989retry:
991 entropy_count = orig = ACCESS_ONCE(r->entropy_count); 990 entropy_count = orig = ACCESS_ONCE(r->entropy_count);
992 have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
993 ibytes = nbytes; 991 ibytes = nbytes;
994 /* If limited, never pull more than available */ 992 /* If limited, never pull more than available */
995 if (r->limit) 993 if (r->limit) {
996 ibytes = min_t(size_t, ibytes, have_bytes - reserved); 994 int have_bytes = entropy_count >> (ENTROPY_SHIFT + 3);
995
996 if ((have_bytes -= reserved) < 0)
997 have_bytes = 0;
998 ibytes = min_t(size_t, ibytes, have_bytes);
999 }
997 if (ibytes < min) 1000 if (ibytes < min)
998 ibytes = 0; 1001 ibytes = 0;
999 if (have_bytes >= ibytes + reserved) 1002 if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0)
1000 entropy_count -= ibytes << (ENTROPY_SHIFT + 3); 1003 entropy_count = 0;
1001 else
1002 entropy_count = reserved << (ENTROPY_SHIFT + 3);
1003 1004
1004 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) 1005 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
1005 goto retry; 1006 goto retry;
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index e473d6555f96..ffe350f86bca 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -186,6 +186,8 @@ config CPU_FREQ_GOV_CONSERVATIVE
186config GENERIC_CPUFREQ_CPU0 186config GENERIC_CPUFREQ_CPU0
187 tristate "Generic CPU0 cpufreq driver" 187 tristate "Generic CPU0 cpufreq driver"
188 depends on HAVE_CLK && OF 188 depends on HAVE_CLK && OF
189 # if CPU_THERMAL is on and THERMAL=m, CPU0 cannot be =y:
190 depends on !CPU_THERMAL || THERMAL
189 select PM_OPP 191 select PM_OPP
190 help 192 help
191 This adds a generic cpufreq driver for CPU0 frequency management. 193 This adds a generic cpufreq driver for CPU0 frequency management.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index aed2b0cb83dc..62259d27f03e 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu)
2242 struct cpufreq_policy new_policy; 2242 struct cpufreq_policy new_policy;
2243 int ret; 2243 int ret;
2244 2244
2245 if (!policy) { 2245 if (!policy)
2246 ret = -ENODEV; 2246 return -ENODEV;
2247 goto no_policy;
2248 }
2249 2247
2250 down_write(&policy->rwsem); 2248 down_write(&policy->rwsem);
2251 2249
@@ -2264,7 +2262,7 @@ int cpufreq_update_policy(unsigned int cpu)
2264 new_policy.cur = cpufreq_driver->get(cpu); 2262 new_policy.cur = cpufreq_driver->get(cpu);
2265 if (WARN_ON(!new_policy.cur)) { 2263 if (WARN_ON(!new_policy.cur)) {
2266 ret = -EIO; 2264 ret = -EIO;
2267 goto no_policy; 2265 goto unlock;
2268 } 2266 }
2269 2267
2270 if (!policy->cur) { 2268 if (!policy->cur) {
@@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu)
2279 2277
2280 ret = cpufreq_set_policy(policy, &new_policy); 2278 ret = cpufreq_set_policy(policy, &new_policy);
2281 2279
2280unlock:
2282 up_write(&policy->rwsem); 2281 up_write(&policy->rwsem);
2283 2282
2284 cpufreq_cpu_put(policy); 2283 cpufreq_cpu_put(policy);
2285no_policy:
2286 return ret; 2284 return ret;
2287} 2285}
2288EXPORT_SYMBOL(cpufreq_update_policy); 2286EXPORT_SYMBOL(cpufreq_update_policy);
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4e7f492ad583..924bb2d42b1c 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -196,10 +196,7 @@ static signed int pid_calc(struct _pid *pid, int32_t busy)
196 pid->last_err = fp_error; 196 pid->last_err = fp_error;
197 197
198 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; 198 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm;
199 if (result >= 0) 199 result = result + (1 << (FRAC_BITS-1));
200 result = result + (1 << (FRAC_BITS-1));
201 else
202 result = result - (1 << (FRAC_BITS-1));
203 return (signed int)fp_toint(result); 200 return (signed int)fp_toint(result);
204} 201}
205 202
diff --git a/drivers/cpuidle/cpuidle-armada-370-xp.c b/drivers/cpuidle/cpuidle-armada-370-xp.c
index 28587d0f3947..a5fba0287bfb 100644
--- a/drivers/cpuidle/cpuidle-armada-370-xp.c
+++ b/drivers/cpuidle/cpuidle-armada-370-xp.c
@@ -55,7 +55,7 @@ static struct cpuidle_driver armada_370_xp_idle_driver = {
55 .power_usage = 50, 55 .power_usage = 50,
56 .target_residency = 100, 56 .target_residency = 100,
57 .flags = CPUIDLE_FLAG_TIME_VALID, 57 .flags = CPUIDLE_FLAG_TIME_VALID,
58 .name = "MV CPU IDLE", 58 .name = "Idle",
59 .desc = "CPU power down", 59 .desc = "CPU power down",
60 }, 60 },
61 .states[2] = { 61 .states[2] = {
@@ -65,7 +65,7 @@ static struct cpuidle_driver armada_370_xp_idle_driver = {
65 .target_residency = 1000, 65 .target_residency = 1000,
66 .flags = CPUIDLE_FLAG_TIME_VALID | 66 .flags = CPUIDLE_FLAG_TIME_VALID |
67 ARMADA_370_XP_FLAG_DEEP_IDLE, 67 ARMADA_370_XP_FLAG_DEEP_IDLE,
68 .name = "MV CPU DEEP IDLE", 68 .name = "Deep idle",
69 .desc = "CPU and L2 Fabric power down", 69 .desc = "CPU and L2 Fabric power down",
70 }, 70 },
71 .state_count = ARMADA_370_XP_MAX_STATES, 71 .state_count = ARMADA_370_XP_MAX_STATES,
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index 7c2497dea1e9..0dc57d5ecd10 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -64,6 +64,7 @@
64void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx, 64void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx,
65 uint32_t flags) 65 uint32_t flags)
66{ 66{
67 memset(ctx, 0, sizeof(*ctx));
67 ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class); 68 ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class);
68 INIT_LIST_HEAD(&ctx->locked); 69 INIT_LIST_HEAD(&ctx->locked);
69} 70}
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 4c22a5b7f4c5..6c656392d67d 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -36,6 +36,8 @@
36#include "i915_drv.h" 36#include "i915_drv.h"
37#include "i915_trace.h" 37#include "i915_trace.h"
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/console.h>
40#include <linux/vt.h>
39#include <linux/vgaarb.h> 41#include <linux/vgaarb.h>
40#include <linux/acpi.h> 42#include <linux/acpi.h>
41#include <linux/pnp.h> 43#include <linux/pnp.h>
@@ -1386,7 +1388,6 @@ cleanup_gem:
1386 i915_gem_context_fini(dev); 1388 i915_gem_context_fini(dev);
1387 mutex_unlock(&dev->struct_mutex); 1389 mutex_unlock(&dev->struct_mutex);
1388 WARN_ON(dev_priv->mm.aliasing_ppgtt); 1390 WARN_ON(dev_priv->mm.aliasing_ppgtt);
1389 drm_mm_takedown(&dev_priv->gtt.base.mm);
1390cleanup_irq: 1391cleanup_irq:
1391 drm_irq_uninstall(dev); 1392 drm_irq_uninstall(dev);
1392cleanup_gem_stolen: 1393cleanup_gem_stolen:
@@ -1450,6 +1451,38 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
1450} 1451}
1451#endif 1452#endif
1452 1453
1454#if !defined(CONFIG_VGA_CONSOLE)
1455static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
1456{
1457 return 0;
1458}
1459#elif !defined(CONFIG_DUMMY_CONSOLE)
1460static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
1461{
1462 return -ENODEV;
1463}
1464#else
1465static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
1466{
1467 int ret;
1468
1469 DRM_INFO("Replacing VGA console driver\n");
1470
1471 console_lock();
1472 ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
1473 if (ret == 0) {
1474 ret = do_unregister_con_driver(&vga_con);
1475
1476 /* Ignore "already unregistered". */
1477 if (ret == -ENODEV)
1478 ret = 0;
1479 }
1480 console_unlock();
1481
1482 return ret;
1483}
1484#endif
1485
1453static void i915_dump_device_info(struct drm_i915_private *dev_priv) 1486static void i915_dump_device_info(struct drm_i915_private *dev_priv)
1454{ 1487{
1455 const struct intel_device_info *info = &dev_priv->info; 1488 const struct intel_device_info *info = &dev_priv->info;
@@ -1623,8 +1656,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1623 if (ret) 1656 if (ret)
1624 goto out_regs; 1657 goto out_regs;
1625 1658
1626 if (drm_core_check_feature(dev, DRIVER_MODESET)) 1659 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1660 ret = i915_kick_out_vgacon(dev_priv);
1661 if (ret) {
1662 DRM_ERROR("failed to remove conflicting VGA console\n");
1663 goto out_gtt;
1664 }
1665
1627 i915_kick_out_firmware_fb(dev_priv); 1666 i915_kick_out_firmware_fb(dev_priv);
1667 }
1628 1668
1629 pci_set_master(dev->pdev); 1669 pci_set_master(dev->pdev);
1630 1670
@@ -1756,8 +1796,6 @@ out_mtrrfree:
1756 arch_phys_wc_del(dev_priv->gtt.mtrr); 1796 arch_phys_wc_del(dev_priv->gtt.mtrr);
1757 io_mapping_free(dev_priv->gtt.mappable); 1797 io_mapping_free(dev_priv->gtt.mappable);
1758out_gtt: 1798out_gtt:
1759 list_del(&dev_priv->gtt.base.global_link);
1760 drm_mm_takedown(&dev_priv->gtt.base.mm);
1761 dev_priv->gtt.base.cleanup(&dev_priv->gtt.base); 1799 dev_priv->gtt.base.cleanup(&dev_priv->gtt.base);
1762out_regs: 1800out_regs:
1763 intel_uncore_fini(dev); 1801 intel_uncore_fini(dev);
@@ -1846,7 +1884,6 @@ int i915_driver_unload(struct drm_device *dev)
1846 i915_free_hws(dev); 1884 i915_free_hws(dev);
1847 } 1885 }
1848 1886
1849 list_del(&dev_priv->gtt.base.global_link);
1850 WARN_ON(!list_empty(&dev_priv->vm_list)); 1887 WARN_ON(!list_empty(&dev_priv->vm_list));
1851 1888
1852 drm_vblank_cleanup(dev); 1889 drm_vblank_cleanup(dev);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index eec820aec022..8b3cde703364 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1992,7 +1992,10 @@ static void gen6_gmch_remove(struct i915_address_space *vm)
1992 1992
1993 struct i915_gtt *gtt = container_of(vm, struct i915_gtt, base); 1993 struct i915_gtt *gtt = container_of(vm, struct i915_gtt, base);
1994 1994
1995 drm_mm_takedown(&vm->mm); 1995 if (drm_mm_initialized(&vm->mm)) {
1996 drm_mm_takedown(&vm->mm);
1997 list_del(&vm->global_link);
1998 }
1996 iounmap(gtt->gsm); 1999 iounmap(gtt->gsm);
1997 teardown_scratch_page(vm->dev); 2000 teardown_scratch_page(vm->dev);
1998} 2001}
@@ -2025,6 +2028,10 @@ static int i915_gmch_probe(struct drm_device *dev,
2025 2028
2026static void i915_gmch_remove(struct i915_address_space *vm) 2029static void i915_gmch_remove(struct i915_address_space *vm)
2027{ 2030{
2031 if (drm_mm_initialized(&vm->mm)) {
2032 drm_mm_takedown(&vm->mm);
2033 list_del(&vm->global_link);
2034 }
2028 intel_gmch_remove(); 2035 intel_gmch_remove();
2029} 2036}
2030 2037
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 87ec60e181a7..66cf41765bf9 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -888,6 +888,8 @@ static void i915_gem_record_rings(struct drm_device *dev,
888 for (i = 0; i < I915_NUM_RINGS; i++) { 888 for (i = 0; i < I915_NUM_RINGS; i++) {
889 struct intel_engine_cs *ring = &dev_priv->ring[i]; 889 struct intel_engine_cs *ring = &dev_priv->ring[i];
890 890
891 error->ring[i].pid = -1;
892
891 if (ring->dev == NULL) 893 if (ring->dev == NULL)
892 continue; 894 continue;
893 895
@@ -895,7 +897,6 @@ static void i915_gem_record_rings(struct drm_device *dev,
895 897
896 i915_record_ring_state(dev, ring, &error->ring[i]); 898 i915_record_ring_state(dev, ring, &error->ring[i]);
897 899
898 error->ring[i].pid = -1;
899 request = i915_gem_find_active_request(ring); 900 request = i915_gem_find_active_request(ring);
900 if (request) { 901 if (request) {
901 /* We need to copy these to an anonymous buffer 902 /* We need to copy these to an anonymous buffer
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6f8017a7e937..267f069765ad 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2847,10 +2847,14 @@ static int semaphore_passed(struct intel_engine_cs *ring)
2847 struct intel_engine_cs *signaller; 2847 struct intel_engine_cs *signaller;
2848 u32 seqno, ctl; 2848 u32 seqno, ctl;
2849 2849
2850 ring->hangcheck.deadlock = true; 2850 ring->hangcheck.deadlock++;
2851 2851
2852 signaller = semaphore_waits_for(ring, &seqno); 2852 signaller = semaphore_waits_for(ring, &seqno);
2853 if (signaller == NULL || signaller->hangcheck.deadlock) 2853 if (signaller == NULL)
2854 return -1;
2855
2856 /* Prevent pathological recursion due to driver bugs */
2857 if (signaller->hangcheck.deadlock >= I915_NUM_RINGS)
2854 return -1; 2858 return -1;
2855 2859
2856 /* cursory check for an unkickable deadlock */ 2860 /* cursory check for an unkickable deadlock */
@@ -2858,7 +2862,13 @@ static int semaphore_passed(struct intel_engine_cs *ring)
2858 if (ctl & RING_WAIT_SEMAPHORE && semaphore_passed(signaller) < 0) 2862 if (ctl & RING_WAIT_SEMAPHORE && semaphore_passed(signaller) < 0)
2859 return -1; 2863 return -1;
2860 2864
2861 return i915_seqno_passed(signaller->get_seqno(signaller, false), seqno); 2865 if (i915_seqno_passed(signaller->get_seqno(signaller, false), seqno))
2866 return 1;
2867
2868 if (signaller->hangcheck.deadlock)
2869 return -1;
2870
2871 return 0;
2862} 2872}
2863 2873
2864static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) 2874static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
@@ -2867,7 +2877,7 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
2867 int i; 2877 int i;
2868 2878
2869 for_each_ring(ring, dev_priv, i) 2879 for_each_ring(ring, dev_priv, i)
2870 ring->hangcheck.deadlock = false; 2880 ring->hangcheck.deadlock = 0;
2871} 2881}
2872 2882
2873static enum intel_ring_hangcheck_action 2883static enum intel_ring_hangcheck_action
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 5e6c888b4928..38a98570d10c 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -798,9 +798,6 @@ static void i965_enable_backlight(struct intel_connector *connector)
798 ctl = freq << 16; 798 ctl = freq << 16;
799 I915_WRITE(BLC_PWM_CTL, ctl); 799 I915_WRITE(BLC_PWM_CTL, ctl);
800 800
801 /* XXX: combine this into above write? */
802 intel_panel_actually_set_backlight(connector, panel->backlight.level);
803
804 ctl2 = BLM_PIPE(pipe); 801 ctl2 = BLM_PIPE(pipe);
805 if (panel->backlight.combination_mode) 802 if (panel->backlight.combination_mode)
806 ctl2 |= BLM_COMBINATION_MODE; 803 ctl2 |= BLM_COMBINATION_MODE;
@@ -809,6 +806,8 @@ static void i965_enable_backlight(struct intel_connector *connector)
809 I915_WRITE(BLC_PWM_CTL2, ctl2); 806 I915_WRITE(BLC_PWM_CTL2, ctl2);
810 POSTING_READ(BLC_PWM_CTL2); 807 POSTING_READ(BLC_PWM_CTL2);
811 I915_WRITE(BLC_PWM_CTL2, ctl2 | BLM_PWM_ENABLE); 808 I915_WRITE(BLC_PWM_CTL2, ctl2 | BLM_PWM_ENABLE);
809
810 intel_panel_actually_set_backlight(connector, panel->backlight.level);
812} 811}
813 812
814static void vlv_enable_backlight(struct intel_connector *connector) 813static void vlv_enable_backlight(struct intel_connector *connector)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index d1e53abec1b5..54242e4f6f4c 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -511,8 +511,7 @@ void intel_update_fbc(struct drm_device *dev)
511 obj = intel_fb->obj; 511 obj = intel_fb->obj;
512 adjusted_mode = &intel_crtc->config.adjusted_mode; 512 adjusted_mode = &intel_crtc->config.adjusted_mode;
513 513
514 if (i915.enable_fbc < 0 && 514 if (i915.enable_fbc < 0) {
515 INTEL_INFO(dev)->gen <= 7 && !IS_HASWELL(dev)) {
516 if (set_no_fbc_reason(dev_priv, FBC_CHIP_DEFAULT)) 515 if (set_no_fbc_reason(dev_priv, FBC_CHIP_DEFAULT))
517 DRM_DEBUG_KMS("disabled per chip default\n"); 516 DRM_DEBUG_KMS("disabled per chip default\n");
518 goto out_disable; 517 goto out_disable;
@@ -3506,15 +3505,11 @@ static void gen8_enable_rps(struct drm_device *dev)
3506 3505
3507 I915_WRITE(GEN6_RP_IDLE_HYSTERSIS, 10); 3506 I915_WRITE(GEN6_RP_IDLE_HYSTERSIS, 10);
3508 3507
3509 /* WaDisablePwrmtrEvent:chv (pre-production hw) */
3510 I915_WRITE(0xA80C, I915_READ(0xA80C) & 0x00ffffff);
3511 I915_WRITE(0xA810, I915_READ(0xA810) & 0xffffff00);
3512
3513 /* 5: Enable RPS */ 3508 /* 5: Enable RPS */
3514 I915_WRITE(GEN6_RP_CONTROL, 3509 I915_WRITE(GEN6_RP_CONTROL,
3515 GEN6_RP_MEDIA_TURBO | 3510 GEN6_RP_MEDIA_TURBO |
3516 GEN6_RP_MEDIA_HW_NORMAL_MODE | 3511 GEN6_RP_MEDIA_HW_NORMAL_MODE |
3517 GEN6_RP_MEDIA_IS_GFX | /* WaSetMaskForGfxBusyness:chv (pre-production hw ?) */ 3512 GEN6_RP_MEDIA_IS_GFX |
3518 GEN6_RP_ENABLE | 3513 GEN6_RP_ENABLE |
3519 GEN6_RP_UP_BUSY_AVG | 3514 GEN6_RP_UP_BUSY_AVG |
3520 GEN6_RP_DOWN_IDLE_AVG); 3515 GEN6_RP_DOWN_IDLE_AVG);
@@ -6024,30 +6019,32 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
6024static struct i915_power_domains *hsw_pwr; 6019static struct i915_power_domains *hsw_pwr;
6025 6020
6026/* Display audio driver power well request */ 6021/* Display audio driver power well request */
6027void i915_request_power_well(void) 6022int i915_request_power_well(void)
6028{ 6023{
6029 struct drm_i915_private *dev_priv; 6024 struct drm_i915_private *dev_priv;
6030 6025
6031 if (WARN_ON(!hsw_pwr)) 6026 if (!hsw_pwr)
6032 return; 6027 return -ENODEV;
6033 6028
6034 dev_priv = container_of(hsw_pwr, struct drm_i915_private, 6029 dev_priv = container_of(hsw_pwr, struct drm_i915_private,
6035 power_domains); 6030 power_domains);
6036 intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO); 6031 intel_display_power_get(dev_priv, POWER_DOMAIN_AUDIO);
6032 return 0;
6037} 6033}
6038EXPORT_SYMBOL_GPL(i915_request_power_well); 6034EXPORT_SYMBOL_GPL(i915_request_power_well);
6039 6035
6040/* Display audio driver power well release */ 6036/* Display audio driver power well release */
6041void i915_release_power_well(void) 6037int i915_release_power_well(void)
6042{ 6038{
6043 struct drm_i915_private *dev_priv; 6039 struct drm_i915_private *dev_priv;
6044 6040
6045 if (WARN_ON(!hsw_pwr)) 6041 if (!hsw_pwr)
6046 return; 6042 return -ENODEV;
6047 6043
6048 dev_priv = container_of(hsw_pwr, struct drm_i915_private, 6044 dev_priv = container_of(hsw_pwr, struct drm_i915_private,
6049 power_domains); 6045 power_domains);
6050 intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO); 6046 intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
6047 return 0;
6051} 6048}
6052EXPORT_SYMBOL_GPL(i915_release_power_well); 6049EXPORT_SYMBOL_GPL(i915_release_power_well);
6053 6050
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 910c83cf7d44..e72017bdcd7f 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -55,7 +55,7 @@ struct intel_ring_hangcheck {
55 u32 seqno; 55 u32 seqno;
56 int score; 56 int score;
57 enum intel_ring_hangcheck_action action; 57 enum intel_ring_hangcheck_action action;
58 bool deadlock; 58 int deadlock;
59}; 59};
60 60
61struct intel_ringbuffer { 61struct intel_ringbuffer {
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 6a4d5bc17697..20375cc7f82d 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1385,7 +1385,9 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
1385 >> SDVO_PORT_MULTIPLY_SHIFT) + 1; 1385 >> SDVO_PORT_MULTIPLY_SHIFT) + 1;
1386 } 1386 }
1387 1387
1388 dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier; 1388 dotclock = pipe_config->port_clock;
1389 if (pipe_config->pixel_multiplier)
1390 dotclock /= pipe_config->pixel_multiplier;
1389 1391
1390 if (HAS_PCH_SPLIT(dev)) 1392 if (HAS_PCH_SPLIT(dev))
1391 ironlake_check_encoder_dotclock(pipe_config, dotclock); 1393 ironlake_check_encoder_dotclock(pipe_config, dotclock);
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 79cba593df0d..4f6fef7ac069 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -320,7 +320,8 @@ static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
320 struct drm_i915_private *dev_priv = dev->dev_private; 320 struct drm_i915_private *dev_priv = dev->dev_private;
321 unsigned long irqflags; 321 unsigned long irqflags;
322 322
323 del_timer_sync(&dev_priv->uncore.force_wake_timer); 323 if (del_timer_sync(&dev_priv->uncore.force_wake_timer))
324 gen6_force_wake_timer((unsigned long)dev_priv);
324 325
325 /* Hold uncore.lock across reset to prevent any register access 326 /* Hold uncore.lock across reset to prevent any register access
326 * with forcewake not set correctly 327 * with forcewake not set correctly
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index 2b6156d0e4b5..8b307e143632 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -140,6 +140,7 @@ nouveau-y += core/subdev/i2c/nv4e.o
140nouveau-y += core/subdev/i2c/nv50.o 140nouveau-y += core/subdev/i2c/nv50.o
141nouveau-y += core/subdev/i2c/nv94.o 141nouveau-y += core/subdev/i2c/nv94.o
142nouveau-y += core/subdev/i2c/nvd0.o 142nouveau-y += core/subdev/i2c/nvd0.o
143nouveau-y += core/subdev/i2c/gf117.o
143nouveau-y += core/subdev/i2c/nve0.o 144nouveau-y += core/subdev/i2c/nve0.o
144nouveau-y += core/subdev/ibus/nvc0.o 145nouveau-y += core/subdev/ibus/nvc0.o
145nouveau-y += core/subdev/ibus/nve0.o 146nouveau-y += core/subdev/ibus/nve0.o
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
index f199957995fa..8d55ed633b19 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
@@ -314,7 +314,7 @@ nvc0_identify(struct nouveau_device *device)
314 device->cname = "GF117"; 314 device->cname = "GF117";
315 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 315 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
316 device->oclass[NVDEV_SUBDEV_GPIO ] = nvd0_gpio_oclass; 316 device->oclass[NVDEV_SUBDEV_GPIO ] = nvd0_gpio_oclass;
317 device->oclass[NVDEV_SUBDEV_I2C ] = nvd0_i2c_oclass; 317 device->oclass[NVDEV_SUBDEV_I2C ] = gf117_i2c_oclass;
318 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 318 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
319 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 319 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
320 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 320 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/base.c b/drivers/gpu/drm/nouveau/core/engine/disp/base.c
index c41f656abe64..9c38c5e40500 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/base.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/base.c
@@ -99,8 +99,10 @@ _nouveau_disp_dtor(struct nouveau_object *object)
99 99
100 nouveau_event_destroy(&disp->vblank); 100 nouveau_event_destroy(&disp->vblank);
101 101
102 list_for_each_entry_safe(outp, outt, &disp->outp, head) { 102 if (disp->outp.next) {
103 nouveau_object_ref(NULL, (struct nouveau_object **)&outp); 103 list_for_each_entry_safe(outp, outt, &disp->outp, head) {
104 nouveau_object_ref(NULL, (struct nouveau_object **)&outp);
105 }
104 } 106 }
105 107
106 nouveau_engine_destroy(&disp->base); 108 nouveau_engine_destroy(&disp->base);
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/dport.c b/drivers/gpu/drm/nouveau/core/engine/disp/dport.c
index 39562d48101d..5a5b59b21130 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/dport.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/dport.c
@@ -241,7 +241,9 @@ dp_link_train_eq(struct dp_state *dp)
241 dp_set_training_pattern(dp, 2); 241 dp_set_training_pattern(dp, 2);
242 242
243 do { 243 do {
244 if (dp_link_train_update(dp, dp->pc2, 400)) 244 if ((tries &&
245 dp_link_train_commit(dp, dp->pc2)) ||
246 dp_link_train_update(dp, dp->pc2, 400))
245 break; 247 break;
246 248
247 eq_done = !!(dp->stat[2] & DPCD_LS04_INTERLANE_ALIGN_DONE); 249 eq_done = !!(dp->stat[2] & DPCD_LS04_INTERLANE_ALIGN_DONE);
@@ -253,9 +255,6 @@ dp_link_train_eq(struct dp_state *dp)
253 !(lane & DPCD_LS02_LANE0_SYMBOL_LOCKED)) 255 !(lane & DPCD_LS02_LANE0_SYMBOL_LOCKED))
254 eq_done = false; 256 eq_done = false;
255 } 257 }
256
257 if (dp_link_train_commit(dp, dp->pc2))
258 break;
259 } while (!eq_done && cr_done && ++tries <= 5); 258 } while (!eq_done && cr_done && ++tries <= 5);
260 259
261 return eq_done ? 0 : -1; 260 return eq_done ? 0 : -1;
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index 1e85f36c705f..26e962b7e702 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -1270,7 +1270,7 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk, u32 *conf)
1270 i--; 1270 i--;
1271 1271
1272 outp = exec_lookup(priv, head, i, ctrl, &data, &ver, &hdr, &cnt, &len, &info1); 1272 outp = exec_lookup(priv, head, i, ctrl, &data, &ver, &hdr, &cnt, &len, &info1);
1273 if (!data) 1273 if (!outp)
1274 return NULL; 1274 return NULL;
1275 1275
1276 if (outp->info.location == 0) { 1276 if (outp->info.location == 0) {
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/gpc.fuc b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/gpc.fuc
index 2f7345f7fe07..7445f12b1d9e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/gpc.fuc
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/gpc.fuc
@@ -54,7 +54,7 @@ mmio_list_base:
54#ifdef INCLUDE_CODE 54#ifdef INCLUDE_CODE
55// reports an exception to the host 55// reports an exception to the host
56// 56//
57// In: $r15 error code (see nvc0.fuc) 57// In: $r15 error code (see os.h)
58// 58//
59error: 59error:
60 push $r14 60 push $r14
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hub.fuc b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hub.fuc
index c8ddb8d71b91..b4ad18bf5a26 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hub.fuc
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hub.fuc
@@ -49,7 +49,7 @@ hub_mmio_list_next:
49#ifdef INCLUDE_CODE 49#ifdef INCLUDE_CODE
50// reports an exception to the host 50// reports an exception to the host
51// 51//
52// In: $r15 error code (see nvc0.fuc) 52// In: $r15 error code (see os.h)
53// 53//
54error: 54error:
55 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(5), 0, $r15) 55 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(5), 0, $r15)
@@ -343,13 +343,25 @@ ih:
343 ih_no_ctxsw: 343 ih_no_ctxsw:
344 and $r11 $r10 NV_PGRAPH_FECS_INTR_FWMTHD 344 and $r11 $r10 NV_PGRAPH_FECS_INTR_FWMTHD
345 bra e #ih_no_fwmthd 345 bra e #ih_no_fwmthd
346 // none we handle, ack, and fall-through to unhandled 346 // none we handle; report to host and ack
347 nv_rd32($r15, NV_PGRAPH_TRAPPED_DATA_LO)
348 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(4), 0, $r15)
349 nv_rd32($r15, NV_PGRAPH_TRAPPED_ADDR)
350 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(3), 0, $r15)
351 extr $r14 $r15 16:18
352 shl b32 $r14 $r14 2
353 imm32($r15, NV_PGRAPH_FE_OBJECT_TABLE(0))
354 add b32 $r14 $r15
355 call(nv_rd32)
356 nv_iowr(NV_PGRAPH_FECS_CC_SCRATCH_VAL(2), 0, $r15)
357 mov $r15 E_BAD_FWMTHD
358 call(error)
347 mov $r11 0x100 359 mov $r11 0x100
348 nv_wr32(0x400144, $r11) 360 nv_wr32(0x400144, $r11)
349 361
350 // anything we didn't handle, bring it to the host's attention 362 // anything we didn't handle, bring it to the host's attention
351 ih_no_fwmthd: 363 ih_no_fwmthd:
352 mov $r11 0x104 // FIFO | CHSW 364 mov $r11 0x504 // FIFO | CHSW | FWMTHD
353 not b32 $r11 365 not b32 $r11
354 and $r11 $r10 $r11 366 and $r11 $r10 $r11
355 bra e #ih_no_other 367 bra e #ih_no_other
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubgm107.fuc5.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubgm107.fuc5.h
index 214dd16ec566..5f953c5c20b7 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubgm107.fuc5.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubgm107.fuc5.h
@@ -478,10 +478,10 @@ uint32_t gm107_grhub_code[] = {
478 0x01040080, 478 0x01040080,
479 0xbd0001f6, 479 0xbd0001f6,
480 0x01004104, 480 0x01004104,
481 0x627e020f, 481 0xa87e020f,
482 0x717e0006, 482 0xb77e0006,
483 0x100f0006, 483 0x100f0006,
484 0x0006b37e, 484 0x0006f97e,
485 0x98000e98, 485 0x98000e98,
486 0x207e010f, 486 0x207e010f,
487 0x14950001, 487 0x14950001,
@@ -523,8 +523,8 @@ uint32_t gm107_grhub_code[] = {
523 0x800040b7, 523 0x800040b7,
524 0xf40132b6, 524 0xf40132b6,
525 0x000fb41b, 525 0x000fb41b,
526 0x0006b37e, 526 0x0006f97e,
527 0x627e000f, 527 0xa87e000f,
528 0x00800006, 528 0x00800006,
529 0x01f60201, 529 0x01f60201,
530 0xbd04bd00, 530 0xbd04bd00,
@@ -554,7 +554,7 @@ uint32_t gm107_grhub_code[] = {
554 0x0009f602, 554 0x0009f602,
555 0x32f404bd, 555 0x32f404bd,
556 0x0231f401, 556 0x0231f401,
557 0x0008367e, 557 0x00087c7e,
558 0x99f094bd, 558 0x99f094bd,
559 0x17008007, 559 0x17008007,
560 0x0009f602, 560 0x0009f602,
@@ -563,7 +563,7 @@ uint32_t gm107_grhub_code[] = {
563 0x37008006, 563 0x37008006,
564 0x0009f602, 564 0x0009f602,
565 0x31f404bd, 565 0x31f404bd,
566 0x08367e01, 566 0x087c7e01,
567 0xf094bd00, 567 0xf094bd00,
568 0x00800699, 568 0x00800699,
569 0x09f60217, 569 0x09f60217,
@@ -572,7 +572,7 @@ uint32_t gm107_grhub_code[] = {
572 0x20f92f0e, 572 0x20f92f0e,
573 0x32f412b2, 573 0x32f412b2,
574 0x0232f401, 574 0x0232f401,
575 0x0008367e, 575 0x00087c7e,
576 0x008020fc, 576 0x008020fc,
577 0x02f602c0, 577 0x02f602c0,
578 0xf404bd00, 578 0xf404bd00,
@@ -580,7 +580,7 @@ uint32_t gm107_grhub_code[] = {
580 0x23c8130e, 580 0x23c8130e,
581 0x0d0bf41f, 581 0x0d0bf41f,
582 0xf40131f4, 582 0xf40131f4,
583 0x367e0232, 583 0x7c7e0232,
584/* 0x054e: chsw_done */ 584/* 0x054e: chsw_done */
585 0x01020008, 585 0x01020008,
586 0x02c30080, 586 0x02c30080,
@@ -593,7 +593,7 @@ uint32_t gm107_grhub_code[] = {
593 0xb0ff2a0e, 593 0xb0ff2a0e,
594 0x1bf401e4, 594 0x1bf401e4,
595 0x7ef2b20c, 595 0x7ef2b20c,
596 0xf40007d6, 596 0xf400081c,
597/* 0x057a: main_not_ctx_chan */ 597/* 0x057a: main_not_ctx_chan */
598 0xe4b0400e, 598 0xe4b0400e,
599 0x2c1bf402, 599 0x2c1bf402,
@@ -602,7 +602,7 @@ uint32_t gm107_grhub_code[] = {
602 0x0009f602, 602 0x0009f602,
603 0x32f404bd, 603 0x32f404bd,
604 0x0232f401, 604 0x0232f401,
605 0x0008367e, 605 0x00087c7e,
606 0x99f094bd, 606 0x99f094bd,
607 0x17008007, 607 0x17008007,
608 0x0009f602, 608 0x0009f602,
@@ -642,238 +642,238 @@ uint32_t gm107_grhub_code[] = {
642/* 0x061a: ih_no_ctxsw */ 642/* 0x061a: ih_no_ctxsw */
643 0xabe40000, 643 0xabe40000,
644 0x0bf40400, 644 0x0bf40400,
645 0x01004b10, 645 0x07088e56,
646 0x448ebfb2,
647 0x8f7e4001,
648/* 0x062e: ih_no_fwmthd */
649 0x044b0000,
650 0xffb0bd01,
651 0x0bf4b4ab,
652 0x0700800c,
653 0x000bf603,
654/* 0x0642: ih_no_other */
655 0x004004bd,
656 0x000af601,
657 0xf0fc04bd,
658 0xd0fce0fc,
659 0xa0fcb0fc,
660 0x80fc90fc,
661 0xfc0088fe,
662 0x0032f480,
663/* 0x0662: ctx_4170s */
664 0xf5f001f8,
665 0x8effb210,
666 0x7e404170,
667 0xf800008f,
668/* 0x0671: ctx_4170w */
669 0x41708e00,
670 0x00657e40, 646 0x00657e40,
671 0xf0ffb200, 647 0x80ffb200,
672 0x1bf410f4, 648 0xf6020400,
673/* 0x0683: ctx_redswitch */
674 0x4e00f8f3,
675 0xe5f00200,
676 0x20e5f040,
677 0x8010e5f0,
678 0xf6018500,
679 0x04bd000e,
680/* 0x069a: ctx_redswitch_delay */
681 0xf2b6080f,
682 0xfd1bf401,
683 0x0400e5f1,
684 0x0100e5f1,
685 0x01850080,
686 0xbd000ef6,
687/* 0x06b3: ctx_86c */
688 0x8000f804,
689 0xf6022300,
690 0x04bd000f, 649 0x04bd000f,
691 0x148effb2, 650 0x4007048e,
692 0x8f7e408a, 651 0x0000657e,
693 0xffb20000, 652 0x0080ffb2,
694 0x41a88c8e, 653 0x0ff60203,
654 0xc704bd00,
655 0xee9450fe,
656 0x07008f02,
657 0x00efbb40,
658 0x0000657e,
659 0x02020080,
660 0xbd000ff6,
661 0x7e030f04,
662 0x4b0002f8,
663 0xbfb20100,
664 0x4001448e,
695 0x00008f7e, 665 0x00008f7e,
696/* 0x06d2: ctx_mem */ 666/* 0x0674: ih_no_fwmthd */
697 0x008000f8, 667 0xbd05044b,
698 0x0ff60284, 668 0xb4abffb0,
699/* 0x06db: ctx_mem_wait */ 669 0x800c0bf4,
700 0x8f04bd00, 670 0xf6030700,
701 0xcf028400, 671 0x04bd000b,
702 0xfffd00ff, 672/* 0x0688: ih_no_other */
703 0xf61bf405, 673 0xf6010040,
704/* 0x06ea: ctx_load */ 674 0x04bd000a,
705 0x94bd00f8, 675 0xe0fcf0fc,
706 0x800599f0, 676 0xb0fcd0fc,
707 0xf6023700, 677 0x90fca0fc,
708 0x04bd0009, 678 0x88fe80fc,
709 0xb87e0c0a, 679 0xf480fc00,
710 0xf4bd0000, 680 0x01f80032,
711 0x02890080, 681/* 0x06a8: ctx_4170s */
682 0xb210f5f0,
683 0x41708eff,
684 0x008f7e40,
685/* 0x06b7: ctx_4170w */
686 0x8e00f800,
687 0x7e404170,
688 0xb2000065,
689 0x10f4f0ff,
690 0xf8f31bf4,
691/* 0x06c9: ctx_redswitch */
692 0x02004e00,
693 0xf040e5f0,
694 0xe5f020e5,
695 0x85008010,
696 0x000ef601,
697 0x080f04bd,
698/* 0x06e0: ctx_redswitch_delay */
699 0xf401f2b6,
700 0xe5f1fd1b,
701 0xe5f10400,
702 0x00800100,
703 0x0ef60185,
704 0xf804bd00,
705/* 0x06f9: ctx_86c */
706 0x23008000,
707 0x000ff602,
708 0xffb204bd,
709 0x408a148e,
710 0x00008f7e,
711 0x8c8effb2,
712 0x8f7e41a8,
713 0x00f80000,
714/* 0x0718: ctx_mem */
715 0x02840080,
712 0xbd000ff6, 716 0xbd000ff6,
713 0xc1008004, 717/* 0x0721: ctx_mem_wait */
714 0x0002f602, 718 0x84008f04,
715 0x008004bd, 719 0x00ffcf02,
716 0x02f60283, 720 0xf405fffd,
717 0x0f04bd00, 721 0x00f8f61b,
718 0x06d27e07, 722/* 0x0730: ctx_load */
719 0xc0008000, 723 0x99f094bd,
720 0x0002f602, 724 0x37008005,
721 0x0bfe04bd, 725 0x0009f602,
722 0x1f2af000, 726 0x0c0a04bd,
723 0xb60424b6, 727 0x0000b87e,
724 0x94bd0220, 728 0x0080f4bd,
725 0x800899f0, 729 0x0ff60289,
726 0xf6023700, 730 0x8004bd00,
727 0x04bd0009, 731 0xf602c100,
728 0x02810080, 732 0x04bd0002,
729 0xbd0002f6, 733 0x02830080,
730 0x0000d204,
731 0x25f08000,
732 0x88008002,
733 0x0002f602,
734 0x100104bd,
735 0xf0020042,
736 0x12fa0223,
737 0xbd03f805,
738 0x0899f094,
739 0x02170080,
740 0xbd0009f6,
741 0x81019804,
742 0x981814b6,
743 0x25b68002,
744 0x0512fd08,
745 0xbd1601b5,
746 0x0999f094,
747 0x02370080,
748 0xbd0009f6,
749 0x81008004,
750 0x0001f602,
751 0x010204bd,
752 0x02880080,
753 0xbd0002f6, 734 0xbd0002f6,
754 0x01004104, 735 0x7e070f04,
755 0xfa0613f0, 736 0x80000718,
756 0x03f80501, 737 0xf602c000,
738 0x04bd0002,
739 0xf0000bfe,
740 0x24b61f2a,
741 0x0220b604,
757 0x99f094bd, 742 0x99f094bd,
758 0x17008009, 743 0x37008008,
759 0x0009f602, 744 0x0009f602,
760 0x94bd04bd, 745 0x008004bd,
761 0x800599f0, 746 0x02f60281,
747 0xd204bd00,
748 0x80000000,
749 0x800225f0,
750 0xf6028800,
751 0x04bd0002,
752 0x00421001,
753 0x0223f002,
754 0xf80512fa,
755 0xf094bd03,
756 0x00800899,
757 0x09f60217,
758 0x9804bd00,
759 0x14b68101,
760 0x80029818,
761 0xfd0825b6,
762 0x01b50512,
763 0xf094bd16,
764 0x00800999,
765 0x09f60237,
766 0x8004bd00,
767 0xf6028100,
768 0x04bd0001,
769 0x00800102,
770 0x02f60288,
771 0x4104bd00,
772 0x13f00100,
773 0x0501fa06,
774 0x94bd03f8,
775 0x800999f0,
762 0xf6021700, 776 0xf6021700,
763 0x04bd0009, 777 0x04bd0009,
764/* 0x07d6: ctx_chan */ 778 0x99f094bd,
765 0xea7e00f8, 779 0x17008005,
766 0x0c0a0006, 780 0x0009f602,
767 0x0000b87e, 781 0x00f804bd,
768 0xd27e050f, 782/* 0x081c: ctx_chan */
769 0x00f80006, 783 0x0007307e,
770/* 0x07e8: ctx_mmio_exec */ 784 0xb87e0c0a,
771 0x80410398, 785 0x050f0000,
786 0x0007187e,
787/* 0x082e: ctx_mmio_exec */
788 0x039800f8,
789 0x81008041,
790 0x0003f602,
791 0x34bd04bd,
792/* 0x083c: ctx_mmio_loop */
793 0xf4ff34c4,
794 0x00450e1b,
795 0x0653f002,
796 0xf80535fa,
797/* 0x084d: ctx_mmio_pull */
798 0x804e9803,
799 0x7e814f98,
800 0xb600008f,
801 0x12b60830,
802 0xdf1bf401,
803/* 0x0860: ctx_mmio_done */
804 0x80160398,
772 0xf6028100, 805 0xf6028100,
773 0x04bd0003, 806 0x04bd0003,
774/* 0x07f6: ctx_mmio_loop */ 807 0x414000b5,
775 0x34c434bd, 808 0x13f00100,
776 0x0e1bf4ff, 809 0x0601fa06,
777 0xf0020045, 810 0x00f803f8,
778 0x35fa0653, 811/* 0x087c: ctx_xfer */
779/* 0x0807: ctx_mmio_pull */ 812 0x0080040e,
780 0x9803f805, 813 0x0ef60302,
781 0x4f98804e, 814/* 0x0887: ctx_xfer_idle */
782 0x008f7e81, 815 0x8e04bd00,
783 0x0830b600, 816 0xcf030000,
784 0xf40112b6, 817 0xe4f100ee,
785/* 0x081a: ctx_mmio_done */ 818 0x1bf42000,
786 0x0398df1b, 819 0x0611f4f5,
787 0x81008016, 820/* 0x089b: ctx_xfer_pre */
788 0x0003f602, 821 0x0f0c02f4,
789 0x00b504bd, 822 0x06f97e10,
790 0x01004140, 823 0x1b11f400,
791 0xfa0613f0, 824/* 0x08a4: ctx_xfer_pre_load */
792 0x03f80601, 825 0xa87e020f,
793/* 0x0836: ctx_xfer */ 826 0xb77e0006,
794 0x040e00f8, 827 0xc97e0006,
795 0x03020080, 828 0xf4bd0006,
796 0xbd000ef6, 829 0x0006a87e,
797/* 0x0841: ctx_xfer_idle */ 830 0x0007307e,
798 0x00008e04, 831/* 0x08bc: ctx_xfer_exec */
799 0x00eecf03, 832 0xbd160198,
800 0x2000e4f1, 833 0x05008024,
801 0xf4f51bf4, 834 0x0002f601,
802 0x02f40611, 835 0x1fb204bd,
803/* 0x0855: ctx_xfer_pre */ 836 0x41a5008e,
804 0x7e100f0c,
805 0xf40006b3,
806/* 0x085e: ctx_xfer_pre_load */
807 0x020f1b11,
808 0x0006627e,
809 0x0006717e,
810 0x0006837e,
811 0x627ef4bd,
812 0xea7e0006,
813/* 0x0876: ctx_xfer_exec */
814 0x01980006,
815 0x8024bd16,
816 0xf6010500,
817 0x04bd0002,
818 0x008e1fb2,
819 0x8f7e41a5,
820 0xfcf00000,
821 0x022cf001,
822 0xfd0124b6,
823 0xffb205f2,
824 0x41a5048e,
825 0x00008f7e, 837 0x00008f7e,
826 0x0002167e, 838 0xf001fcf0,
827 0xfc8024bd, 839 0x24b6022c,
828 0x02f60247, 840 0x05f2fd01,
829 0xf004bd00, 841 0x048effb2,
830 0x20b6012c, 842 0x8f7e41a5,
831 0x4afc8003, 843 0x167e0000,
832 0x0002f602, 844 0x24bd0002,
833 0xacf004bd, 845 0x0247fc80,
834 0x06a5f001, 846 0xbd0002f6,
835 0x0c98000b, 847 0x012cf004,
836 0x010d9800, 848 0x800320b6,
837 0x3d7e000e, 849 0xf6024afc,
838 0x080a0001, 850 0x04bd0002,
839 0x0000ec7e, 851 0xf001acf0,
840 0x00020a7e, 852 0x000b06a5,
841 0x0a1201f4, 853 0x98000c98,
842 0x00b87e0c, 854 0x000e010d,
843 0x7e050f00, 855 0x00013d7e,
844 0xf40006d2, 856 0xec7e080a,
845/* 0x08f2: ctx_xfer_post */ 857 0x0a7e0000,
846 0x020f2d02, 858 0x01f40002,
847 0x0006627e, 859 0x7e0c0a12,
848 0xb37ef4bd, 860 0x0f0000b8,
849 0x277e0006, 861 0x07187e05,
850 0x717e0002, 862 0x2d02f400,
863/* 0x0938: ctx_xfer_post */
864 0xa87e020f,
851 0xf4bd0006, 865 0xf4bd0006,
852 0x0006627e, 866 0x0006f97e,
853 0x981011f4, 867 0x0002277e,
854 0x11fd4001, 868 0x0006b77e,
855 0x070bf405, 869 0xa87ef4bd,
856 0x0007e87e, 870 0x11f40006,
857/* 0x091c: ctx_xfer_no_post_mmio */ 871 0x40019810,
858/* 0x091c: ctx_xfer_done */ 872 0xf40511fd,
859 0x000000f8, 873 0x2e7e070b,
860 0x00000000, 874/* 0x0962: ctx_xfer_no_post_mmio */
861 0x00000000, 875/* 0x0962: ctx_xfer_done */
862 0x00000000, 876 0x00f80008,
863 0x00000000,
864 0x00000000,
865 0x00000000,
866 0x00000000,
867 0x00000000,
868 0x00000000,
869 0x00000000,
870 0x00000000,
871 0x00000000,
872 0x00000000,
873 0x00000000,
874 0x00000000,
875 0x00000000,
876 0x00000000,
877 0x00000000, 877 0x00000000,
878 0x00000000, 878 0x00000000,
879 0x00000000, 879 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnv108.fuc5.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnv108.fuc5.h
index 64dfd75192bf..e49b5a877ae4 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnv108.fuc5.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnv108.fuc5.h
@@ -478,10 +478,10 @@ uint32_t nv108_grhub_code[] = {
478 0x01040080, 478 0x01040080,
479 0xbd0001f6, 479 0xbd0001f6,
480 0x01004104, 480 0x01004104,
481 0x627e020f, 481 0xa87e020f,
482 0x717e0006, 482 0xb77e0006,
483 0x100f0006, 483 0x100f0006,
484 0x0006b37e, 484 0x0006f97e,
485 0x98000e98, 485 0x98000e98,
486 0x207e010f, 486 0x207e010f,
487 0x14950001, 487 0x14950001,
@@ -523,8 +523,8 @@ uint32_t nv108_grhub_code[] = {
523 0x800040b7, 523 0x800040b7,
524 0xf40132b6, 524 0xf40132b6,
525 0x000fb41b, 525 0x000fb41b,
526 0x0006b37e, 526 0x0006f97e,
527 0x627e000f, 527 0xa87e000f,
528 0x00800006, 528 0x00800006,
529 0x01f60201, 529 0x01f60201,
530 0xbd04bd00, 530 0xbd04bd00,
@@ -554,7 +554,7 @@ uint32_t nv108_grhub_code[] = {
554 0x0009f602, 554 0x0009f602,
555 0x32f404bd, 555 0x32f404bd,
556 0x0231f401, 556 0x0231f401,
557 0x0008367e, 557 0x00087c7e,
558 0x99f094bd, 558 0x99f094bd,
559 0x17008007, 559 0x17008007,
560 0x0009f602, 560 0x0009f602,
@@ -563,7 +563,7 @@ uint32_t nv108_grhub_code[] = {
563 0x37008006, 563 0x37008006,
564 0x0009f602, 564 0x0009f602,
565 0x31f404bd, 565 0x31f404bd,
566 0x08367e01, 566 0x087c7e01,
567 0xf094bd00, 567 0xf094bd00,
568 0x00800699, 568 0x00800699,
569 0x09f60217, 569 0x09f60217,
@@ -572,7 +572,7 @@ uint32_t nv108_grhub_code[] = {
572 0x20f92f0e, 572 0x20f92f0e,
573 0x32f412b2, 573 0x32f412b2,
574 0x0232f401, 574 0x0232f401,
575 0x0008367e, 575 0x00087c7e,
576 0x008020fc, 576 0x008020fc,
577 0x02f602c0, 577 0x02f602c0,
578 0xf404bd00, 578 0xf404bd00,
@@ -580,7 +580,7 @@ uint32_t nv108_grhub_code[] = {
580 0x23c8130e, 580 0x23c8130e,
581 0x0d0bf41f, 581 0x0d0bf41f,
582 0xf40131f4, 582 0xf40131f4,
583 0x367e0232, 583 0x7c7e0232,
584/* 0x054e: chsw_done */ 584/* 0x054e: chsw_done */
585 0x01020008, 585 0x01020008,
586 0x02c30080, 586 0x02c30080,
@@ -593,7 +593,7 @@ uint32_t nv108_grhub_code[] = {
593 0xb0ff2a0e, 593 0xb0ff2a0e,
594 0x1bf401e4, 594 0x1bf401e4,
595 0x7ef2b20c, 595 0x7ef2b20c,
596 0xf40007d6, 596 0xf400081c,
597/* 0x057a: main_not_ctx_chan */ 597/* 0x057a: main_not_ctx_chan */
598 0xe4b0400e, 598 0xe4b0400e,
599 0x2c1bf402, 599 0x2c1bf402,
@@ -602,7 +602,7 @@ uint32_t nv108_grhub_code[] = {
602 0x0009f602, 602 0x0009f602,
603 0x32f404bd, 603 0x32f404bd,
604 0x0232f401, 604 0x0232f401,
605 0x0008367e, 605 0x00087c7e,
606 0x99f094bd, 606 0x99f094bd,
607 0x17008007, 607 0x17008007,
608 0x0009f602, 608 0x0009f602,
@@ -642,238 +642,238 @@ uint32_t nv108_grhub_code[] = {
642/* 0x061a: ih_no_ctxsw */ 642/* 0x061a: ih_no_ctxsw */
643 0xabe40000, 643 0xabe40000,
644 0x0bf40400, 644 0x0bf40400,
645 0x01004b10, 645 0x07088e56,
646 0x448ebfb2,
647 0x8f7e4001,
648/* 0x062e: ih_no_fwmthd */
649 0x044b0000,
650 0xffb0bd01,
651 0x0bf4b4ab,
652 0x0700800c,
653 0x000bf603,
654/* 0x0642: ih_no_other */
655 0x004004bd,
656 0x000af601,
657 0xf0fc04bd,
658 0xd0fce0fc,
659 0xa0fcb0fc,
660 0x80fc90fc,
661 0xfc0088fe,
662 0x0032f480,
663/* 0x0662: ctx_4170s */
664 0xf5f001f8,
665 0x8effb210,
666 0x7e404170,
667 0xf800008f,
668/* 0x0671: ctx_4170w */
669 0x41708e00,
670 0x00657e40, 646 0x00657e40,
671 0xf0ffb200, 647 0x80ffb200,
672 0x1bf410f4, 648 0xf6020400,
673/* 0x0683: ctx_redswitch */
674 0x4e00f8f3,
675 0xe5f00200,
676 0x20e5f040,
677 0x8010e5f0,
678 0xf6018500,
679 0x04bd000e,
680/* 0x069a: ctx_redswitch_delay */
681 0xf2b6080f,
682 0xfd1bf401,
683 0x0400e5f1,
684 0x0100e5f1,
685 0x01850080,
686 0xbd000ef6,
687/* 0x06b3: ctx_86c */
688 0x8000f804,
689 0xf6022300,
690 0x04bd000f, 649 0x04bd000f,
691 0x148effb2, 650 0x4007048e,
692 0x8f7e408a, 651 0x0000657e,
693 0xffb20000, 652 0x0080ffb2,
694 0x41a88c8e, 653 0x0ff60203,
654 0xc704bd00,
655 0xee9450fe,
656 0x07008f02,
657 0x00efbb40,
658 0x0000657e,
659 0x02020080,
660 0xbd000ff6,
661 0x7e030f04,
662 0x4b0002f8,
663 0xbfb20100,
664 0x4001448e,
695 0x00008f7e, 665 0x00008f7e,
696/* 0x06d2: ctx_mem */ 666/* 0x0674: ih_no_fwmthd */
697 0x008000f8, 667 0xbd05044b,
698 0x0ff60284, 668 0xb4abffb0,
699/* 0x06db: ctx_mem_wait */ 669 0x800c0bf4,
700 0x8f04bd00, 670 0xf6030700,
701 0xcf028400, 671 0x04bd000b,
702 0xfffd00ff, 672/* 0x0688: ih_no_other */
703 0xf61bf405, 673 0xf6010040,
704/* 0x06ea: ctx_load */ 674 0x04bd000a,
705 0x94bd00f8, 675 0xe0fcf0fc,
706 0x800599f0, 676 0xb0fcd0fc,
707 0xf6023700, 677 0x90fca0fc,
708 0x04bd0009, 678 0x88fe80fc,
709 0xb87e0c0a, 679 0xf480fc00,
710 0xf4bd0000, 680 0x01f80032,
711 0x02890080, 681/* 0x06a8: ctx_4170s */
682 0xb210f5f0,
683 0x41708eff,
684 0x008f7e40,
685/* 0x06b7: ctx_4170w */
686 0x8e00f800,
687 0x7e404170,
688 0xb2000065,
689 0x10f4f0ff,
690 0xf8f31bf4,
691/* 0x06c9: ctx_redswitch */
692 0x02004e00,
693 0xf040e5f0,
694 0xe5f020e5,
695 0x85008010,
696 0x000ef601,
697 0x080f04bd,
698/* 0x06e0: ctx_redswitch_delay */
699 0xf401f2b6,
700 0xe5f1fd1b,
701 0xe5f10400,
702 0x00800100,
703 0x0ef60185,
704 0xf804bd00,
705/* 0x06f9: ctx_86c */
706 0x23008000,
707 0x000ff602,
708 0xffb204bd,
709 0x408a148e,
710 0x00008f7e,
711 0x8c8effb2,
712 0x8f7e41a8,
713 0x00f80000,
714/* 0x0718: ctx_mem */
715 0x02840080,
712 0xbd000ff6, 716 0xbd000ff6,
713 0xc1008004, 717/* 0x0721: ctx_mem_wait */
714 0x0002f602, 718 0x84008f04,
715 0x008004bd, 719 0x00ffcf02,
716 0x02f60283, 720 0xf405fffd,
717 0x0f04bd00, 721 0x00f8f61b,
718 0x06d27e07, 722/* 0x0730: ctx_load */
719 0xc0008000, 723 0x99f094bd,
720 0x0002f602, 724 0x37008005,
721 0x0bfe04bd, 725 0x0009f602,
722 0x1f2af000, 726 0x0c0a04bd,
723 0xb60424b6, 727 0x0000b87e,
724 0x94bd0220, 728 0x0080f4bd,
725 0x800899f0, 729 0x0ff60289,
726 0xf6023700, 730 0x8004bd00,
727 0x04bd0009, 731 0xf602c100,
728 0x02810080, 732 0x04bd0002,
729 0xbd0002f6, 733 0x02830080,
730 0x0000d204,
731 0x25f08000,
732 0x88008002,
733 0x0002f602,
734 0x100104bd,
735 0xf0020042,
736 0x12fa0223,
737 0xbd03f805,
738 0x0899f094,
739 0x02170080,
740 0xbd0009f6,
741 0x81019804,
742 0x981814b6,
743 0x25b68002,
744 0x0512fd08,
745 0xbd1601b5,
746 0x0999f094,
747 0x02370080,
748 0xbd0009f6,
749 0x81008004,
750 0x0001f602,
751 0x010204bd,
752 0x02880080,
753 0xbd0002f6, 734 0xbd0002f6,
754 0x01004104, 735 0x7e070f04,
755 0xfa0613f0, 736 0x80000718,
756 0x03f80501, 737 0xf602c000,
738 0x04bd0002,
739 0xf0000bfe,
740 0x24b61f2a,
741 0x0220b604,
757 0x99f094bd, 742 0x99f094bd,
758 0x17008009, 743 0x37008008,
759 0x0009f602, 744 0x0009f602,
760 0x94bd04bd, 745 0x008004bd,
761 0x800599f0, 746 0x02f60281,
747 0xd204bd00,
748 0x80000000,
749 0x800225f0,
750 0xf6028800,
751 0x04bd0002,
752 0x00421001,
753 0x0223f002,
754 0xf80512fa,
755 0xf094bd03,
756 0x00800899,
757 0x09f60217,
758 0x9804bd00,
759 0x14b68101,
760 0x80029818,
761 0xfd0825b6,
762 0x01b50512,
763 0xf094bd16,
764 0x00800999,
765 0x09f60237,
766 0x8004bd00,
767 0xf6028100,
768 0x04bd0001,
769 0x00800102,
770 0x02f60288,
771 0x4104bd00,
772 0x13f00100,
773 0x0501fa06,
774 0x94bd03f8,
775 0x800999f0,
762 0xf6021700, 776 0xf6021700,
763 0x04bd0009, 777 0x04bd0009,
764/* 0x07d6: ctx_chan */ 778 0x99f094bd,
765 0xea7e00f8, 779 0x17008005,
766 0x0c0a0006, 780 0x0009f602,
767 0x0000b87e, 781 0x00f804bd,
768 0xd27e050f, 782/* 0x081c: ctx_chan */
769 0x00f80006, 783 0x0007307e,
770/* 0x07e8: ctx_mmio_exec */ 784 0xb87e0c0a,
771 0x80410398, 785 0x050f0000,
786 0x0007187e,
787/* 0x082e: ctx_mmio_exec */
788 0x039800f8,
789 0x81008041,
790 0x0003f602,
791 0x34bd04bd,
792/* 0x083c: ctx_mmio_loop */
793 0xf4ff34c4,
794 0x00450e1b,
795 0x0653f002,
796 0xf80535fa,
797/* 0x084d: ctx_mmio_pull */
798 0x804e9803,
799 0x7e814f98,
800 0xb600008f,
801 0x12b60830,
802 0xdf1bf401,
803/* 0x0860: ctx_mmio_done */
804 0x80160398,
772 0xf6028100, 805 0xf6028100,
773 0x04bd0003, 806 0x04bd0003,
774/* 0x07f6: ctx_mmio_loop */ 807 0x414000b5,
775 0x34c434bd, 808 0x13f00100,
776 0x0e1bf4ff, 809 0x0601fa06,
777 0xf0020045, 810 0x00f803f8,
778 0x35fa0653, 811/* 0x087c: ctx_xfer */
779/* 0x0807: ctx_mmio_pull */ 812 0x0080040e,
780 0x9803f805, 813 0x0ef60302,
781 0x4f98804e, 814/* 0x0887: ctx_xfer_idle */
782 0x008f7e81, 815 0x8e04bd00,
783 0x0830b600, 816 0xcf030000,
784 0xf40112b6, 817 0xe4f100ee,
785/* 0x081a: ctx_mmio_done */ 818 0x1bf42000,
786 0x0398df1b, 819 0x0611f4f5,
787 0x81008016, 820/* 0x089b: ctx_xfer_pre */
788 0x0003f602, 821 0x0f0c02f4,
789 0x00b504bd, 822 0x06f97e10,
790 0x01004140, 823 0x1b11f400,
791 0xfa0613f0, 824/* 0x08a4: ctx_xfer_pre_load */
792 0x03f80601, 825 0xa87e020f,
793/* 0x0836: ctx_xfer */ 826 0xb77e0006,
794 0x040e00f8, 827 0xc97e0006,
795 0x03020080, 828 0xf4bd0006,
796 0xbd000ef6, 829 0x0006a87e,
797/* 0x0841: ctx_xfer_idle */ 830 0x0007307e,
798 0x00008e04, 831/* 0x08bc: ctx_xfer_exec */
799 0x00eecf03, 832 0xbd160198,
800 0x2000e4f1, 833 0x05008024,
801 0xf4f51bf4, 834 0x0002f601,
802 0x02f40611, 835 0x1fb204bd,
803/* 0x0855: ctx_xfer_pre */ 836 0x41a5008e,
804 0x7e100f0c,
805 0xf40006b3,
806/* 0x085e: ctx_xfer_pre_load */
807 0x020f1b11,
808 0x0006627e,
809 0x0006717e,
810 0x0006837e,
811 0x627ef4bd,
812 0xea7e0006,
813/* 0x0876: ctx_xfer_exec */
814 0x01980006,
815 0x8024bd16,
816 0xf6010500,
817 0x04bd0002,
818 0x008e1fb2,
819 0x8f7e41a5,
820 0xfcf00000,
821 0x022cf001,
822 0xfd0124b6,
823 0xffb205f2,
824 0x41a5048e,
825 0x00008f7e, 837 0x00008f7e,
826 0x0002167e, 838 0xf001fcf0,
827 0xfc8024bd, 839 0x24b6022c,
828 0x02f60247, 840 0x05f2fd01,
829 0xf004bd00, 841 0x048effb2,
830 0x20b6012c, 842 0x8f7e41a5,
831 0x4afc8003, 843 0x167e0000,
832 0x0002f602, 844 0x24bd0002,
833 0xacf004bd, 845 0x0247fc80,
834 0x06a5f001, 846 0xbd0002f6,
835 0x0c98000b, 847 0x012cf004,
836 0x010d9800, 848 0x800320b6,
837 0x3d7e000e, 849 0xf6024afc,
838 0x080a0001, 850 0x04bd0002,
839 0x0000ec7e, 851 0xf001acf0,
840 0x00020a7e, 852 0x000b06a5,
841 0x0a1201f4, 853 0x98000c98,
842 0x00b87e0c, 854 0x000e010d,
843 0x7e050f00, 855 0x00013d7e,
844 0xf40006d2, 856 0xec7e080a,
845/* 0x08f2: ctx_xfer_post */ 857 0x0a7e0000,
846 0x020f2d02, 858 0x01f40002,
847 0x0006627e, 859 0x7e0c0a12,
848 0xb37ef4bd, 860 0x0f0000b8,
849 0x277e0006, 861 0x07187e05,
850 0x717e0002, 862 0x2d02f400,
863/* 0x0938: ctx_xfer_post */
864 0xa87e020f,
851 0xf4bd0006, 865 0xf4bd0006,
852 0x0006627e, 866 0x0006f97e,
853 0x981011f4, 867 0x0002277e,
854 0x11fd4001, 868 0x0006b77e,
855 0x070bf405, 869 0xa87ef4bd,
856 0x0007e87e, 870 0x11f40006,
857/* 0x091c: ctx_xfer_no_post_mmio */ 871 0x40019810,
858/* 0x091c: ctx_xfer_done */ 872 0xf40511fd,
859 0x000000f8, 873 0x2e7e070b,
860 0x00000000, 874/* 0x0962: ctx_xfer_no_post_mmio */
861 0x00000000, 875/* 0x0962: ctx_xfer_done */
862 0x00000000, 876 0x00f80008,
863 0x00000000,
864 0x00000000,
865 0x00000000,
866 0x00000000,
867 0x00000000,
868 0x00000000,
869 0x00000000,
870 0x00000000,
871 0x00000000,
872 0x00000000,
873 0x00000000,
874 0x00000000,
875 0x00000000,
876 0x00000000,
877 0x00000000, 877 0x00000000,
878 0x00000000, 878 0x00000000,
879 0x00000000, 879 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvc0.fuc.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvc0.fuc.h
index f8f7b278a13f..92dfe6a4ac87 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvc0.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvc0.fuc.h
@@ -528,10 +528,10 @@ uint32_t nvc0_grhub_code[] = {
528 0x0001d001, 528 0x0001d001,
529 0x17f104bd, 529 0x17f104bd,
530 0xf7f00100, 530 0xf7f00100,
531 0xb521f502, 531 0x0d21f502,
532 0xc721f507, 532 0x1f21f508,
533 0x10f7f007, 533 0x10f7f008,
534 0x081421f5, 534 0x086c21f5,
535 0x98000e98, 535 0x98000e98,
536 0x21f5010f, 536 0x21f5010f,
537 0x14950150, 537 0x14950150,
@@ -574,9 +574,9 @@ uint32_t nvc0_grhub_code[] = {
574 0xb6800040, 574 0xb6800040,
575 0x1bf40132, 575 0x1bf40132,
576 0x00f7f0be, 576 0x00f7f0be,
577 0x081421f5, 577 0x086c21f5,
578 0xf500f7f0, 578 0xf500f7f0,
579 0xf107b521, 579 0xf1080d21,
580 0xf0010007, 580 0xf0010007,
581 0x01d00203, 581 0x01d00203,
582 0xbd04bd00, 582 0xbd04bd00,
@@ -610,8 +610,8 @@ uint32_t nvc0_grhub_code[] = {
610 0x09d00203, 610 0x09d00203,
611 0xf404bd00, 611 0xf404bd00,
612 0x31f40132, 612 0x31f40132,
613 0xe821f502, 613 0x4021f502,
614 0xf094bd09, 614 0xf094bd0a,
615 0x07f10799, 615 0x07f10799,
616 0x03f01700, 616 0x03f01700,
617 0x0009d002, 617 0x0009d002,
@@ -621,7 +621,7 @@ uint32_t nvc0_grhub_code[] = {
621 0x0203f00f, 621 0x0203f00f,
622 0xbd0009d0, 622 0xbd0009d0,
623 0x0131f404, 623 0x0131f404,
624 0x09e821f5, 624 0x0a4021f5,
625 0x99f094bd, 625 0x99f094bd,
626 0x0007f106, 626 0x0007f106,
627 0x0203f017, 627 0x0203f017,
@@ -631,7 +631,7 @@ uint32_t nvc0_grhub_code[] = {
631 0x12b920f9, 631 0x12b920f9,
632 0x0132f402, 632 0x0132f402,
633 0xf50232f4, 633 0xf50232f4,
634 0xfc09e821, 634 0xfc0a4021,
635 0x0007f120, 635 0x0007f120,
636 0x0203f0c0, 636 0x0203f0c0,
637 0xbd0002d0, 637 0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t nvc0_grhub_code[] = {
640 0xf41f23c8, 640 0xf41f23c8,
641 0x31f40d0b, 641 0x31f40d0b,
642 0x0232f401, 642 0x0232f401,
643 0x09e821f5, 643 0x0a4021f5,
644/* 0x063c: chsw_done */ 644/* 0x063c: chsw_done */
645 0xf10127f0, 645 0xf10127f0,
646 0xf0c30007, 646 0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t nvc0_grhub_code[] = {
654/* 0x0660: main_not_ctx_switch */ 654/* 0x0660: main_not_ctx_switch */
655 0xf401e4b0, 655 0xf401e4b0,
656 0xf2b90d1b, 656 0xf2b90d1b,
657 0x7821f502, 657 0xd021f502,
658 0x460ef409, 658 0x460ef409,
659/* 0x0670: main_not_ctx_chan */ 659/* 0x0670: main_not_ctx_chan */
660 0xf402e4b0, 660 0xf402e4b0,
@@ -664,8 +664,8 @@ uint32_t nvc0_grhub_code[] = {
664 0x09d00203, 664 0x09d00203,
665 0xf404bd00, 665 0xf404bd00,
666 0x32f40132, 666 0x32f40132,
667 0xe821f502, 667 0x4021f502,
668 0xf094bd09, 668 0xf094bd0a,
669 0x07f10799, 669 0x07f10799,
670 0x03f01700, 670 0x03f01700,
671 0x0009d002, 671 0x0009d002,
@@ -710,18 +710,40 @@ uint32_t nvc0_grhub_code[] = {
710/* 0x072b: ih_no_ctxsw */ 710/* 0x072b: ih_no_ctxsw */
711 0xe40421f4, 711 0xe40421f4,
712 0xf40400ab, 712 0xf40400ab,
713 0xb7f1140b, 713 0xe7f16c0b,
714 0xe3f00708,
715 0x6821f440,
716 0xf102ffb9,
717 0xf0040007,
718 0x0fd00203,
719 0xf104bd00,
720 0xf00704e7,
721 0x21f440e3,
722 0x02ffb968,
723 0x030007f1,
724 0xd00203f0,
725 0x04bd000f,
726 0x9450fec7,
727 0xf7f102ee,
728 0xf3f00700,
729 0x00efbb40,
730 0xf16821f4,
731 0xf0020007,
732 0x0fd00203,
733 0xf004bd00,
734 0x21f503f7,
735 0xb7f1037e,
714 0xbfb90100, 736 0xbfb90100,
715 0x44e7f102, 737 0x44e7f102,
716 0x40e3f001, 738 0x40e3f001,
717/* 0x0743: ih_no_fwmthd */ 739/* 0x079b: ih_no_fwmthd */
718 0xf19d21f4, 740 0xf19d21f4,
719 0xbd0104b7, 741 0xbd0504b7,
720 0xb4abffb0, 742 0xb4abffb0,
721 0xf10f0bf4, 743 0xf10f0bf4,
722 0xf0070007, 744 0xf0070007,
723 0x0bd00303, 745 0x0bd00303,
724/* 0x075b: ih_no_other */ 746/* 0x07b3: ih_no_other */
725 0xf104bd00, 747 0xf104bd00,
726 0xf0010007, 748 0xf0010007,
727 0x0ad00003, 749 0x0ad00003,
@@ -731,36 +753,36 @@ uint32_t nvc0_grhub_code[] = {
731 0xfc90fca0, 753 0xfc90fca0,
732 0x0088fe80, 754 0x0088fe80,
733 0x32f480fc, 755 0x32f480fc,
734/* 0x077f: ctx_4160s */ 756/* 0x07d7: ctx_4160s */
735 0xf001f800, 757 0xf001f800,
736 0xffb901f7, 758 0xffb901f7,
737 0x60e7f102, 759 0x60e7f102,
738 0x40e3f041, 760 0x40e3f041,
739/* 0x078f: ctx_4160s_wait */ 761/* 0x07e7: ctx_4160s_wait */
740 0xf19d21f4, 762 0xf19d21f4,
741 0xf04160e7, 763 0xf04160e7,
742 0x21f440e3, 764 0x21f440e3,
743 0x02ffb968, 765 0x02ffb968,
744 0xf404ffc8, 766 0xf404ffc8,
745 0x00f8f00b, 767 0x00f8f00b,
746/* 0x07a4: ctx_4160c */ 768/* 0x07fc: ctx_4160c */
747 0xffb9f4bd, 769 0xffb9f4bd,
748 0x60e7f102, 770 0x60e7f102,
749 0x40e3f041, 771 0x40e3f041,
750 0xf89d21f4, 772 0xf89d21f4,
751/* 0x07b5: ctx_4170s */ 773/* 0x080d: ctx_4170s */
752 0x10f5f000, 774 0x10f5f000,
753 0xf102ffb9, 775 0xf102ffb9,
754 0xf04170e7, 776 0xf04170e7,
755 0x21f440e3, 777 0x21f440e3,
756/* 0x07c7: ctx_4170w */ 778/* 0x081f: ctx_4170w */
757 0xf100f89d, 779 0xf100f89d,
758 0xf04170e7, 780 0xf04170e7,
759 0x21f440e3, 781 0x21f440e3,
760 0x02ffb968, 782 0x02ffb968,
761 0xf410f4f0, 783 0xf410f4f0,
762 0x00f8f01b, 784 0x00f8f01b,
763/* 0x07dc: ctx_redswitch */ 785/* 0x0834: ctx_redswitch */
764 0x0200e7f1, 786 0x0200e7f1,
765 0xf040e5f0, 787 0xf040e5f0,
766 0xe5f020e5, 788 0xe5f020e5,
@@ -768,7 +790,7 @@ uint32_t nvc0_grhub_code[] = {
768 0x0103f085, 790 0x0103f085,
769 0xbd000ed0, 791 0xbd000ed0,
770 0x08f7f004, 792 0x08f7f004,
771/* 0x07f8: ctx_redswitch_delay */ 793/* 0x0850: ctx_redswitch_delay */
772 0xf401f2b6, 794 0xf401f2b6,
773 0xe5f1fd1b, 795 0xe5f1fd1b,
774 0xe5f10400, 796 0xe5f10400,
@@ -776,7 +798,7 @@ uint32_t nvc0_grhub_code[] = {
776 0x03f08500, 798 0x03f08500,
777 0x000ed001, 799 0x000ed001,
778 0x00f804bd, 800 0x00f804bd,
779/* 0x0814: ctx_86c */ 801/* 0x086c: ctx_86c */
780 0x1b0007f1, 802 0x1b0007f1,
781 0xd00203f0, 803 0xd00203f0,
782 0x04bd000f, 804 0x04bd000f,
@@ -787,16 +809,16 @@ uint32_t nvc0_grhub_code[] = {
787 0xa86ce7f1, 809 0xa86ce7f1,
788 0xf441e3f0, 810 0xf441e3f0,
789 0x00f89d21, 811 0x00f89d21,
790/* 0x083c: ctx_mem */ 812/* 0x0894: ctx_mem */
791 0x840007f1, 813 0x840007f1,
792 0xd00203f0, 814 0xd00203f0,
793 0x04bd000f, 815 0x04bd000f,
794/* 0x0848: ctx_mem_wait */ 816/* 0x08a0: ctx_mem_wait */
795 0x8400f7f1, 817 0x8400f7f1,
796 0xcf02f3f0, 818 0xcf02f3f0,
797 0xfffd00ff, 819 0xfffd00ff,
798 0xf31bf405, 820 0xf31bf405,
799/* 0x085a: ctx_load */ 821/* 0x08b2: ctx_load */
800 0x94bd00f8, 822 0x94bd00f8,
801 0xf10599f0, 823 0xf10599f0,
802 0xf00f0007, 824 0xf00f0007,
@@ -814,7 +836,7 @@ uint32_t nvc0_grhub_code[] = {
814 0x02d00203, 836 0x02d00203,
815 0xf004bd00, 837 0xf004bd00,
816 0x21f507f7, 838 0x21f507f7,
817 0x07f1083c, 839 0x07f10894,
818 0x03f0c000, 840 0x03f0c000,
819 0x0002d002, 841 0x0002d002,
820 0x0bfe04bd, 842 0x0bfe04bd,
@@ -869,31 +891,31 @@ uint32_t nvc0_grhub_code[] = {
869 0x03f01700, 891 0x03f01700,
870 0x0009d002, 892 0x0009d002,
871 0x00f804bd, 893 0x00f804bd,
872/* 0x0978: ctx_chan */ 894/* 0x09d0: ctx_chan */
873 0x077f21f5, 895 0x07d721f5,
874 0x085a21f5, 896 0x08b221f5,
875 0xf40ca7f0, 897 0xf40ca7f0,
876 0xf7f0d021, 898 0xf7f0d021,
877 0x3c21f505, 899 0x9421f505,
878 0xa421f508, 900 0xfc21f508,
879/* 0x0993: ctx_mmio_exec */ 901/* 0x09eb: ctx_mmio_exec */
880 0x9800f807, 902 0x9800f807,
881 0x07f14103, 903 0x07f14103,
882 0x03f08100, 904 0x03f08100,
883 0x0003d002, 905 0x0003d002,
884 0x34bd04bd, 906 0x34bd04bd,
885/* 0x09a4: ctx_mmio_loop */ 907/* 0x09fc: ctx_mmio_loop */
886 0xf4ff34c4, 908 0xf4ff34c4,
887 0x57f10f1b, 909 0x57f10f1b,
888 0x53f00200, 910 0x53f00200,
889 0x0535fa06, 911 0x0535fa06,
890/* 0x09b6: ctx_mmio_pull */ 912/* 0x0a0e: ctx_mmio_pull */
891 0x4e9803f8, 913 0x4e9803f8,
892 0x814f9880, 914 0x814f9880,
893 0xb69d21f4, 915 0xb69d21f4,
894 0x12b60830, 916 0x12b60830,
895 0xdf1bf401, 917 0xdf1bf401,
896/* 0x09c8: ctx_mmio_done */ 918/* 0x0a20: ctx_mmio_done */
897 0xf1160398, 919 0xf1160398,
898 0xf0810007, 920 0xf0810007,
899 0x03d00203, 921 0x03d00203,
@@ -902,30 +924,30 @@ uint32_t nvc0_grhub_code[] = {
902 0x13f00100, 924 0x13f00100,
903 0x0601fa06, 925 0x0601fa06,
904 0x00f803f8, 926 0x00f803f8,
905/* 0x09e8: ctx_xfer */ 927/* 0x0a40: ctx_xfer */
906 0xf104e7f0, 928 0xf104e7f0,
907 0xf0020007, 929 0xf0020007,
908 0x0ed00303, 930 0x0ed00303,
909/* 0x09f7: ctx_xfer_idle */ 931/* 0x0a4f: ctx_xfer_idle */
910 0xf104bd00, 932 0xf104bd00,
911 0xf00000e7, 933 0xf00000e7,
912 0xeecf03e3, 934 0xeecf03e3,
913 0x00e4f100, 935 0x00e4f100,
914 0xf21bf420, 936 0xf21bf420,
915 0xf40611f4, 937 0xf40611f4,
916/* 0x0a0e: ctx_xfer_pre */ 938/* 0x0a66: ctx_xfer_pre */
917 0xf7f01102, 939 0xf7f01102,
918 0x1421f510, 940 0x6c21f510,
919 0x7f21f508, 941 0xd721f508,
920 0x1c11f407, 942 0x1c11f407,
921/* 0x0a1c: ctx_xfer_pre_load */ 943/* 0x0a74: ctx_xfer_pre_load */
922 0xf502f7f0, 944 0xf502f7f0,
923 0xf507b521, 945 0xf5080d21,
924 0xf507c721, 946 0xf5081f21,
925 0xbd07dc21, 947 0xbd083421,
926 0xb521f5f4, 948 0x0d21f5f4,
927 0x5a21f507, 949 0xb221f508,
928/* 0x0a35: ctx_xfer_exec */ 950/* 0x0a8d: ctx_xfer_exec */
929 0x16019808, 951 0x16019808,
930 0x07f124bd, 952 0x07f124bd,
931 0x03f00500, 953 0x03f00500,
@@ -960,23 +982,65 @@ uint32_t nvc0_grhub_code[] = {
960 0x1301f402, 982 0x1301f402,
961 0xf40ca7f0, 983 0xf40ca7f0,
962 0xf7f0d021, 984 0xf7f0d021,
963 0x3c21f505, 985 0x9421f505,
964 0x3202f408, 986 0x3202f408,
965/* 0x0ac4: ctx_xfer_post */ 987/* 0x0b1c: ctx_xfer_post */
966 0xf502f7f0, 988 0xf502f7f0,
967 0xbd07b521, 989 0xbd080d21,
968 0x1421f5f4, 990 0x6c21f5f4,
969 0x7f21f508, 991 0x7f21f508,
970 0xc721f502, 992 0x1f21f502,
971 0xf5f4bd07, 993 0xf5f4bd08,
972 0xf407b521, 994 0xf4080d21,
973 0x01981011, 995 0x01981011,
974 0x0511fd40, 996 0x0511fd40,
975 0xf5070bf4, 997 0xf5070bf4,
976/* 0x0aef: ctx_xfer_no_post_mmio */ 998/* 0x0b47: ctx_xfer_no_post_mmio */
977 0xf5099321, 999 0xf509eb21,
978/* 0x0af3: ctx_xfer_done */ 1000/* 0x0b4b: ctx_xfer_done */
979 0xf807a421, 1001 0xf807fc21,
1002 0x00000000,
1003 0x00000000,
1004 0x00000000,
1005 0x00000000,
1006 0x00000000,
1007 0x00000000,
1008 0x00000000,
1009 0x00000000,
1010 0x00000000,
1011 0x00000000,
1012 0x00000000,
1013 0x00000000,
1014 0x00000000,
1015 0x00000000,
1016 0x00000000,
1017 0x00000000,
1018 0x00000000,
1019 0x00000000,
1020 0x00000000,
1021 0x00000000,
1022 0x00000000,
1023 0x00000000,
1024 0x00000000,
1025 0x00000000,
1026 0x00000000,
1027 0x00000000,
1028 0x00000000,
1029 0x00000000,
1030 0x00000000,
1031 0x00000000,
1032 0x00000000,
1033 0x00000000,
1034 0x00000000,
1035 0x00000000,
1036 0x00000000,
1037 0x00000000,
1038 0x00000000,
1039 0x00000000,
1040 0x00000000,
1041 0x00000000,
1042 0x00000000,
1043 0x00000000,
980 0x00000000, 1044 0x00000000,
981 0x00000000, 1045 0x00000000,
982 0x00000000, 1046 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvd7.fuc.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvd7.fuc.h
index 624215a005b0..62b0c7601d8b 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvd7.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvd7.fuc.h
@@ -528,10 +528,10 @@ uint32_t nvd7_grhub_code[] = {
528 0x0001d001, 528 0x0001d001,
529 0x17f104bd, 529 0x17f104bd,
530 0xf7f00100, 530 0xf7f00100,
531 0xb521f502, 531 0x0d21f502,
532 0xc721f507, 532 0x1f21f508,
533 0x10f7f007, 533 0x10f7f008,
534 0x081421f5, 534 0x086c21f5,
535 0x98000e98, 535 0x98000e98,
536 0x21f5010f, 536 0x21f5010f,
537 0x14950150, 537 0x14950150,
@@ -574,9 +574,9 @@ uint32_t nvd7_grhub_code[] = {
574 0xb6800040, 574 0xb6800040,
575 0x1bf40132, 575 0x1bf40132,
576 0x00f7f0be, 576 0x00f7f0be,
577 0x081421f5, 577 0x086c21f5,
578 0xf500f7f0, 578 0xf500f7f0,
579 0xf107b521, 579 0xf1080d21,
580 0xf0010007, 580 0xf0010007,
581 0x01d00203, 581 0x01d00203,
582 0xbd04bd00, 582 0xbd04bd00,
@@ -610,8 +610,8 @@ uint32_t nvd7_grhub_code[] = {
610 0x09d00203, 610 0x09d00203,
611 0xf404bd00, 611 0xf404bd00,
612 0x31f40132, 612 0x31f40132,
613 0xe821f502, 613 0x4021f502,
614 0xf094bd09, 614 0xf094bd0a,
615 0x07f10799, 615 0x07f10799,
616 0x03f01700, 616 0x03f01700,
617 0x0009d002, 617 0x0009d002,
@@ -621,7 +621,7 @@ uint32_t nvd7_grhub_code[] = {
621 0x0203f00f, 621 0x0203f00f,
622 0xbd0009d0, 622 0xbd0009d0,
623 0x0131f404, 623 0x0131f404,
624 0x09e821f5, 624 0x0a4021f5,
625 0x99f094bd, 625 0x99f094bd,
626 0x0007f106, 626 0x0007f106,
627 0x0203f017, 627 0x0203f017,
@@ -631,7 +631,7 @@ uint32_t nvd7_grhub_code[] = {
631 0x12b920f9, 631 0x12b920f9,
632 0x0132f402, 632 0x0132f402,
633 0xf50232f4, 633 0xf50232f4,
634 0xfc09e821, 634 0xfc0a4021,
635 0x0007f120, 635 0x0007f120,
636 0x0203f0c0, 636 0x0203f0c0,
637 0xbd0002d0, 637 0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t nvd7_grhub_code[] = {
640 0xf41f23c8, 640 0xf41f23c8,
641 0x31f40d0b, 641 0x31f40d0b,
642 0x0232f401, 642 0x0232f401,
643 0x09e821f5, 643 0x0a4021f5,
644/* 0x063c: chsw_done */ 644/* 0x063c: chsw_done */
645 0xf10127f0, 645 0xf10127f0,
646 0xf0c30007, 646 0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t nvd7_grhub_code[] = {
654/* 0x0660: main_not_ctx_switch */ 654/* 0x0660: main_not_ctx_switch */
655 0xf401e4b0, 655 0xf401e4b0,
656 0xf2b90d1b, 656 0xf2b90d1b,
657 0x7821f502, 657 0xd021f502,
658 0x460ef409, 658 0x460ef409,
659/* 0x0670: main_not_ctx_chan */ 659/* 0x0670: main_not_ctx_chan */
660 0xf402e4b0, 660 0xf402e4b0,
@@ -664,8 +664,8 @@ uint32_t nvd7_grhub_code[] = {
664 0x09d00203, 664 0x09d00203,
665 0xf404bd00, 665 0xf404bd00,
666 0x32f40132, 666 0x32f40132,
667 0xe821f502, 667 0x4021f502,
668 0xf094bd09, 668 0xf094bd0a,
669 0x07f10799, 669 0x07f10799,
670 0x03f01700, 670 0x03f01700,
671 0x0009d002, 671 0x0009d002,
@@ -710,18 +710,40 @@ uint32_t nvd7_grhub_code[] = {
710/* 0x072b: ih_no_ctxsw */ 710/* 0x072b: ih_no_ctxsw */
711 0xe40421f4, 711 0xe40421f4,
712 0xf40400ab, 712 0xf40400ab,
713 0xb7f1140b, 713 0xe7f16c0b,
714 0xe3f00708,
715 0x6821f440,
716 0xf102ffb9,
717 0xf0040007,
718 0x0fd00203,
719 0xf104bd00,
720 0xf00704e7,
721 0x21f440e3,
722 0x02ffb968,
723 0x030007f1,
724 0xd00203f0,
725 0x04bd000f,
726 0x9450fec7,
727 0xf7f102ee,
728 0xf3f00700,
729 0x00efbb40,
730 0xf16821f4,
731 0xf0020007,
732 0x0fd00203,
733 0xf004bd00,
734 0x21f503f7,
735 0xb7f1037e,
714 0xbfb90100, 736 0xbfb90100,
715 0x44e7f102, 737 0x44e7f102,
716 0x40e3f001, 738 0x40e3f001,
717/* 0x0743: ih_no_fwmthd */ 739/* 0x079b: ih_no_fwmthd */
718 0xf19d21f4, 740 0xf19d21f4,
719 0xbd0104b7, 741 0xbd0504b7,
720 0xb4abffb0, 742 0xb4abffb0,
721 0xf10f0bf4, 743 0xf10f0bf4,
722 0xf0070007, 744 0xf0070007,
723 0x0bd00303, 745 0x0bd00303,
724/* 0x075b: ih_no_other */ 746/* 0x07b3: ih_no_other */
725 0xf104bd00, 747 0xf104bd00,
726 0xf0010007, 748 0xf0010007,
727 0x0ad00003, 749 0x0ad00003,
@@ -731,36 +753,36 @@ uint32_t nvd7_grhub_code[] = {
731 0xfc90fca0, 753 0xfc90fca0,
732 0x0088fe80, 754 0x0088fe80,
733 0x32f480fc, 755 0x32f480fc,
734/* 0x077f: ctx_4160s */ 756/* 0x07d7: ctx_4160s */
735 0xf001f800, 757 0xf001f800,
736 0xffb901f7, 758 0xffb901f7,
737 0x60e7f102, 759 0x60e7f102,
738 0x40e3f041, 760 0x40e3f041,
739/* 0x078f: ctx_4160s_wait */ 761/* 0x07e7: ctx_4160s_wait */
740 0xf19d21f4, 762 0xf19d21f4,
741 0xf04160e7, 763 0xf04160e7,
742 0x21f440e3, 764 0x21f440e3,
743 0x02ffb968, 765 0x02ffb968,
744 0xf404ffc8, 766 0xf404ffc8,
745 0x00f8f00b, 767 0x00f8f00b,
746/* 0x07a4: ctx_4160c */ 768/* 0x07fc: ctx_4160c */
747 0xffb9f4bd, 769 0xffb9f4bd,
748 0x60e7f102, 770 0x60e7f102,
749 0x40e3f041, 771 0x40e3f041,
750 0xf89d21f4, 772 0xf89d21f4,
751/* 0x07b5: ctx_4170s */ 773/* 0x080d: ctx_4170s */
752 0x10f5f000, 774 0x10f5f000,
753 0xf102ffb9, 775 0xf102ffb9,
754 0xf04170e7, 776 0xf04170e7,
755 0x21f440e3, 777 0x21f440e3,
756/* 0x07c7: ctx_4170w */ 778/* 0x081f: ctx_4170w */
757 0xf100f89d, 779 0xf100f89d,
758 0xf04170e7, 780 0xf04170e7,
759 0x21f440e3, 781 0x21f440e3,
760 0x02ffb968, 782 0x02ffb968,
761 0xf410f4f0, 783 0xf410f4f0,
762 0x00f8f01b, 784 0x00f8f01b,
763/* 0x07dc: ctx_redswitch */ 785/* 0x0834: ctx_redswitch */
764 0x0200e7f1, 786 0x0200e7f1,
765 0xf040e5f0, 787 0xf040e5f0,
766 0xe5f020e5, 788 0xe5f020e5,
@@ -768,7 +790,7 @@ uint32_t nvd7_grhub_code[] = {
768 0x0103f085, 790 0x0103f085,
769 0xbd000ed0, 791 0xbd000ed0,
770 0x08f7f004, 792 0x08f7f004,
771/* 0x07f8: ctx_redswitch_delay */ 793/* 0x0850: ctx_redswitch_delay */
772 0xf401f2b6, 794 0xf401f2b6,
773 0xe5f1fd1b, 795 0xe5f1fd1b,
774 0xe5f10400, 796 0xe5f10400,
@@ -776,7 +798,7 @@ uint32_t nvd7_grhub_code[] = {
776 0x03f08500, 798 0x03f08500,
777 0x000ed001, 799 0x000ed001,
778 0x00f804bd, 800 0x00f804bd,
779/* 0x0814: ctx_86c */ 801/* 0x086c: ctx_86c */
780 0x1b0007f1, 802 0x1b0007f1,
781 0xd00203f0, 803 0xd00203f0,
782 0x04bd000f, 804 0x04bd000f,
@@ -787,16 +809,16 @@ uint32_t nvd7_grhub_code[] = {
787 0xa86ce7f1, 809 0xa86ce7f1,
788 0xf441e3f0, 810 0xf441e3f0,
789 0x00f89d21, 811 0x00f89d21,
790/* 0x083c: ctx_mem */ 812/* 0x0894: ctx_mem */
791 0x840007f1, 813 0x840007f1,
792 0xd00203f0, 814 0xd00203f0,
793 0x04bd000f, 815 0x04bd000f,
794/* 0x0848: ctx_mem_wait */ 816/* 0x08a0: ctx_mem_wait */
795 0x8400f7f1, 817 0x8400f7f1,
796 0xcf02f3f0, 818 0xcf02f3f0,
797 0xfffd00ff, 819 0xfffd00ff,
798 0xf31bf405, 820 0xf31bf405,
799/* 0x085a: ctx_load */ 821/* 0x08b2: ctx_load */
800 0x94bd00f8, 822 0x94bd00f8,
801 0xf10599f0, 823 0xf10599f0,
802 0xf00f0007, 824 0xf00f0007,
@@ -814,7 +836,7 @@ uint32_t nvd7_grhub_code[] = {
814 0x02d00203, 836 0x02d00203,
815 0xf004bd00, 837 0xf004bd00,
816 0x21f507f7, 838 0x21f507f7,
817 0x07f1083c, 839 0x07f10894,
818 0x03f0c000, 840 0x03f0c000,
819 0x0002d002, 841 0x0002d002,
820 0x0bfe04bd, 842 0x0bfe04bd,
@@ -869,31 +891,31 @@ uint32_t nvd7_grhub_code[] = {
869 0x03f01700, 891 0x03f01700,
870 0x0009d002, 892 0x0009d002,
871 0x00f804bd, 893 0x00f804bd,
872/* 0x0978: ctx_chan */ 894/* 0x09d0: ctx_chan */
873 0x077f21f5, 895 0x07d721f5,
874 0x085a21f5, 896 0x08b221f5,
875 0xf40ca7f0, 897 0xf40ca7f0,
876 0xf7f0d021, 898 0xf7f0d021,
877 0x3c21f505, 899 0x9421f505,
878 0xa421f508, 900 0xfc21f508,
879/* 0x0993: ctx_mmio_exec */ 901/* 0x09eb: ctx_mmio_exec */
880 0x9800f807, 902 0x9800f807,
881 0x07f14103, 903 0x07f14103,
882 0x03f08100, 904 0x03f08100,
883 0x0003d002, 905 0x0003d002,
884 0x34bd04bd, 906 0x34bd04bd,
885/* 0x09a4: ctx_mmio_loop */ 907/* 0x09fc: ctx_mmio_loop */
886 0xf4ff34c4, 908 0xf4ff34c4,
887 0x57f10f1b, 909 0x57f10f1b,
888 0x53f00200, 910 0x53f00200,
889 0x0535fa06, 911 0x0535fa06,
890/* 0x09b6: ctx_mmio_pull */ 912/* 0x0a0e: ctx_mmio_pull */
891 0x4e9803f8, 913 0x4e9803f8,
892 0x814f9880, 914 0x814f9880,
893 0xb69d21f4, 915 0xb69d21f4,
894 0x12b60830, 916 0x12b60830,
895 0xdf1bf401, 917 0xdf1bf401,
896/* 0x09c8: ctx_mmio_done */ 918/* 0x0a20: ctx_mmio_done */
897 0xf1160398, 919 0xf1160398,
898 0xf0810007, 920 0xf0810007,
899 0x03d00203, 921 0x03d00203,
@@ -902,30 +924,30 @@ uint32_t nvd7_grhub_code[] = {
902 0x13f00100, 924 0x13f00100,
903 0x0601fa06, 925 0x0601fa06,
904 0x00f803f8, 926 0x00f803f8,
905/* 0x09e8: ctx_xfer */ 927/* 0x0a40: ctx_xfer */
906 0xf104e7f0, 928 0xf104e7f0,
907 0xf0020007, 929 0xf0020007,
908 0x0ed00303, 930 0x0ed00303,
909/* 0x09f7: ctx_xfer_idle */ 931/* 0x0a4f: ctx_xfer_idle */
910 0xf104bd00, 932 0xf104bd00,
911 0xf00000e7, 933 0xf00000e7,
912 0xeecf03e3, 934 0xeecf03e3,
913 0x00e4f100, 935 0x00e4f100,
914 0xf21bf420, 936 0xf21bf420,
915 0xf40611f4, 937 0xf40611f4,
916/* 0x0a0e: ctx_xfer_pre */ 938/* 0x0a66: ctx_xfer_pre */
917 0xf7f01102, 939 0xf7f01102,
918 0x1421f510, 940 0x6c21f510,
919 0x7f21f508, 941 0xd721f508,
920 0x1c11f407, 942 0x1c11f407,
921/* 0x0a1c: ctx_xfer_pre_load */ 943/* 0x0a74: ctx_xfer_pre_load */
922 0xf502f7f0, 944 0xf502f7f0,
923 0xf507b521, 945 0xf5080d21,
924 0xf507c721, 946 0xf5081f21,
925 0xbd07dc21, 947 0xbd083421,
926 0xb521f5f4, 948 0x0d21f5f4,
927 0x5a21f507, 949 0xb221f508,
928/* 0x0a35: ctx_xfer_exec */ 950/* 0x0a8d: ctx_xfer_exec */
929 0x16019808, 951 0x16019808,
930 0x07f124bd, 952 0x07f124bd,
931 0x03f00500, 953 0x03f00500,
@@ -960,23 +982,65 @@ uint32_t nvd7_grhub_code[] = {
960 0x1301f402, 982 0x1301f402,
961 0xf40ca7f0, 983 0xf40ca7f0,
962 0xf7f0d021, 984 0xf7f0d021,
963 0x3c21f505, 985 0x9421f505,
964 0x3202f408, 986 0x3202f408,
965/* 0x0ac4: ctx_xfer_post */ 987/* 0x0b1c: ctx_xfer_post */
966 0xf502f7f0, 988 0xf502f7f0,
967 0xbd07b521, 989 0xbd080d21,
968 0x1421f5f4, 990 0x6c21f5f4,
969 0x7f21f508, 991 0x7f21f508,
970 0xc721f502, 992 0x1f21f502,
971 0xf5f4bd07, 993 0xf5f4bd08,
972 0xf407b521, 994 0xf4080d21,
973 0x01981011, 995 0x01981011,
974 0x0511fd40, 996 0x0511fd40,
975 0xf5070bf4, 997 0xf5070bf4,
976/* 0x0aef: ctx_xfer_no_post_mmio */ 998/* 0x0b47: ctx_xfer_no_post_mmio */
977 0xf5099321, 999 0xf509eb21,
978/* 0x0af3: ctx_xfer_done */ 1000/* 0x0b4b: ctx_xfer_done */
979 0xf807a421, 1001 0xf807fc21,
1002 0x00000000,
1003 0x00000000,
1004 0x00000000,
1005 0x00000000,
1006 0x00000000,
1007 0x00000000,
1008 0x00000000,
1009 0x00000000,
1010 0x00000000,
1011 0x00000000,
1012 0x00000000,
1013 0x00000000,
1014 0x00000000,
1015 0x00000000,
1016 0x00000000,
1017 0x00000000,
1018 0x00000000,
1019 0x00000000,
1020 0x00000000,
1021 0x00000000,
1022 0x00000000,
1023 0x00000000,
1024 0x00000000,
1025 0x00000000,
1026 0x00000000,
1027 0x00000000,
1028 0x00000000,
1029 0x00000000,
1030 0x00000000,
1031 0x00000000,
1032 0x00000000,
1033 0x00000000,
1034 0x00000000,
1035 0x00000000,
1036 0x00000000,
1037 0x00000000,
1038 0x00000000,
1039 0x00000000,
1040 0x00000000,
1041 0x00000000,
1042 0x00000000,
1043 0x00000000,
980 0x00000000, 1044 0x00000000,
981 0x00000000, 1045 0x00000000,
982 0x00000000, 1046 0x00000000,
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnve0.fuc.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnve0.fuc.h
index 6547b3dfc7ed..51c3797d8537 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnve0.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnve0.fuc.h
@@ -528,10 +528,10 @@ uint32_t nve0_grhub_code[] = {
528 0x0001d001, 528 0x0001d001,
529 0x17f104bd, 529 0x17f104bd,
530 0xf7f00100, 530 0xf7f00100,
531 0x7f21f502, 531 0xd721f502,
532 0x9121f507, 532 0xe921f507,
533 0x10f7f007, 533 0x10f7f007,
534 0x07de21f5, 534 0x083621f5,
535 0x98000e98, 535 0x98000e98,
536 0x21f5010f, 536 0x21f5010f,
537 0x14950150, 537 0x14950150,
@@ -574,9 +574,9 @@ uint32_t nve0_grhub_code[] = {
574 0xb6800040, 574 0xb6800040,
575 0x1bf40132, 575 0x1bf40132,
576 0x00f7f0be, 576 0x00f7f0be,
577 0x07de21f5, 577 0x083621f5,
578 0xf500f7f0, 578 0xf500f7f0,
579 0xf1077f21, 579 0xf107d721,
580 0xf0010007, 580 0xf0010007,
581 0x01d00203, 581 0x01d00203,
582 0xbd04bd00, 582 0xbd04bd00,
@@ -610,8 +610,8 @@ uint32_t nve0_grhub_code[] = {
610 0x09d00203, 610 0x09d00203,
611 0xf404bd00, 611 0xf404bd00,
612 0x31f40132, 612 0x31f40132,
613 0xaa21f502, 613 0x0221f502,
614 0xf094bd09, 614 0xf094bd0a,
615 0x07f10799, 615 0x07f10799,
616 0x03f01700, 616 0x03f01700,
617 0x0009d002, 617 0x0009d002,
@@ -621,7 +621,7 @@ uint32_t nve0_grhub_code[] = {
621 0x0203f00f, 621 0x0203f00f,
622 0xbd0009d0, 622 0xbd0009d0,
623 0x0131f404, 623 0x0131f404,
624 0x09aa21f5, 624 0x0a0221f5,
625 0x99f094bd, 625 0x99f094bd,
626 0x0007f106, 626 0x0007f106,
627 0x0203f017, 627 0x0203f017,
@@ -631,7 +631,7 @@ uint32_t nve0_grhub_code[] = {
631 0x12b920f9, 631 0x12b920f9,
632 0x0132f402, 632 0x0132f402,
633 0xf50232f4, 633 0xf50232f4,
634 0xfc09aa21, 634 0xfc0a0221,
635 0x0007f120, 635 0x0007f120,
636 0x0203f0c0, 636 0x0203f0c0,
637 0xbd0002d0, 637 0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t nve0_grhub_code[] = {
640 0xf41f23c8, 640 0xf41f23c8,
641 0x31f40d0b, 641 0x31f40d0b,
642 0x0232f401, 642 0x0232f401,
643 0x09aa21f5, 643 0x0a0221f5,
644/* 0x063c: chsw_done */ 644/* 0x063c: chsw_done */
645 0xf10127f0, 645 0xf10127f0,
646 0xf0c30007, 646 0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t nve0_grhub_code[] = {
654/* 0x0660: main_not_ctx_switch */ 654/* 0x0660: main_not_ctx_switch */
655 0xf401e4b0, 655 0xf401e4b0,
656 0xf2b90d1b, 656 0xf2b90d1b,
657 0x4221f502, 657 0x9a21f502,
658 0x460ef409, 658 0x460ef409,
659/* 0x0670: main_not_ctx_chan */ 659/* 0x0670: main_not_ctx_chan */
660 0xf402e4b0, 660 0xf402e4b0,
@@ -664,8 +664,8 @@ uint32_t nve0_grhub_code[] = {
664 0x09d00203, 664 0x09d00203,
665 0xf404bd00, 665 0xf404bd00,
666 0x32f40132, 666 0x32f40132,
667 0xaa21f502, 667 0x0221f502,
668 0xf094bd09, 668 0xf094bd0a,
669 0x07f10799, 669 0x07f10799,
670 0x03f01700, 670 0x03f01700,
671 0x0009d002, 671 0x0009d002,
@@ -710,18 +710,40 @@ uint32_t nve0_grhub_code[] = {
710/* 0x072b: ih_no_ctxsw */ 710/* 0x072b: ih_no_ctxsw */
711 0xe40421f4, 711 0xe40421f4,
712 0xf40400ab, 712 0xf40400ab,
713 0xb7f1140b, 713 0xe7f16c0b,
714 0xe3f00708,
715 0x6821f440,
716 0xf102ffb9,
717 0xf0040007,
718 0x0fd00203,
719 0xf104bd00,
720 0xf00704e7,
721 0x21f440e3,
722 0x02ffb968,
723 0x030007f1,
724 0xd00203f0,
725 0x04bd000f,
726 0x9450fec7,
727 0xf7f102ee,
728 0xf3f00700,
729 0x00efbb40,
730 0xf16821f4,
731 0xf0020007,
732 0x0fd00203,
733 0xf004bd00,
734 0x21f503f7,
735 0xb7f1037e,
714 0xbfb90100, 736 0xbfb90100,
715 0x44e7f102, 737 0x44e7f102,
716 0x40e3f001, 738 0x40e3f001,
717/* 0x0743: ih_no_fwmthd */ 739/* 0x079b: ih_no_fwmthd */
718 0xf19d21f4, 740 0xf19d21f4,
719 0xbd0104b7, 741 0xbd0504b7,
720 0xb4abffb0, 742 0xb4abffb0,
721 0xf10f0bf4, 743 0xf10f0bf4,
722 0xf0070007, 744 0xf0070007,
723 0x0bd00303, 745 0x0bd00303,
724/* 0x075b: ih_no_other */ 746/* 0x07b3: ih_no_other */
725 0xf104bd00, 747 0xf104bd00,
726 0xf0010007, 748 0xf0010007,
727 0x0ad00003, 749 0x0ad00003,
@@ -731,19 +753,19 @@ uint32_t nve0_grhub_code[] = {
731 0xfc90fca0, 753 0xfc90fca0,
732 0x0088fe80, 754 0x0088fe80,
733 0x32f480fc, 755 0x32f480fc,
734/* 0x077f: ctx_4170s */ 756/* 0x07d7: ctx_4170s */
735 0xf001f800, 757 0xf001f800,
736 0xffb910f5, 758 0xffb910f5,
737 0x70e7f102, 759 0x70e7f102,
738 0x40e3f041, 760 0x40e3f041,
739 0xf89d21f4, 761 0xf89d21f4,
740/* 0x0791: ctx_4170w */ 762/* 0x07e9: ctx_4170w */
741 0x70e7f100, 763 0x70e7f100,
742 0x40e3f041, 764 0x40e3f041,
743 0xb96821f4, 765 0xb96821f4,
744 0xf4f002ff, 766 0xf4f002ff,
745 0xf01bf410, 767 0xf01bf410,
746/* 0x07a6: ctx_redswitch */ 768/* 0x07fe: ctx_redswitch */
747 0xe7f100f8, 769 0xe7f100f8,
748 0xe5f00200, 770 0xe5f00200,
749 0x20e5f040, 771 0x20e5f040,
@@ -751,7 +773,7 @@ uint32_t nve0_grhub_code[] = {
751 0xf0850007, 773 0xf0850007,
752 0x0ed00103, 774 0x0ed00103,
753 0xf004bd00, 775 0xf004bd00,
754/* 0x07c2: ctx_redswitch_delay */ 776/* 0x081a: ctx_redswitch_delay */
755 0xf2b608f7, 777 0xf2b608f7,
756 0xfd1bf401, 778 0xfd1bf401,
757 0x0400e5f1, 779 0x0400e5f1,
@@ -759,7 +781,7 @@ uint32_t nve0_grhub_code[] = {
759 0x850007f1, 781 0x850007f1,
760 0xd00103f0, 782 0xd00103f0,
761 0x04bd000e, 783 0x04bd000e,
762/* 0x07de: ctx_86c */ 784/* 0x0836: ctx_86c */
763 0x07f100f8, 785 0x07f100f8,
764 0x03f01b00, 786 0x03f01b00,
765 0x000fd002, 787 0x000fd002,
@@ -770,17 +792,17 @@ uint32_t nve0_grhub_code[] = {
770 0xe7f102ff, 792 0xe7f102ff,
771 0xe3f0a86c, 793 0xe3f0a86c,
772 0x9d21f441, 794 0x9d21f441,
773/* 0x0806: ctx_mem */ 795/* 0x085e: ctx_mem */
774 0x07f100f8, 796 0x07f100f8,
775 0x03f08400, 797 0x03f08400,
776 0x000fd002, 798 0x000fd002,
777/* 0x0812: ctx_mem_wait */ 799/* 0x086a: ctx_mem_wait */
778 0xf7f104bd, 800 0xf7f104bd,
779 0xf3f08400, 801 0xf3f08400,
780 0x00ffcf02, 802 0x00ffcf02,
781 0xf405fffd, 803 0xf405fffd,
782 0x00f8f31b, 804 0x00f8f31b,
783/* 0x0824: ctx_load */ 805/* 0x087c: ctx_load */
784 0x99f094bd, 806 0x99f094bd,
785 0x0007f105, 807 0x0007f105,
786 0x0203f00f, 808 0x0203f00f,
@@ -797,7 +819,7 @@ uint32_t nve0_grhub_code[] = {
797 0x0203f083, 819 0x0203f083,
798 0xbd0002d0, 820 0xbd0002d0,
799 0x07f7f004, 821 0x07f7f004,
800 0x080621f5, 822 0x085e21f5,
801 0xc00007f1, 823 0xc00007f1,
802 0xd00203f0, 824 0xd00203f0,
803 0x04bd0002, 825 0x04bd0002,
@@ -852,29 +874,29 @@ uint32_t nve0_grhub_code[] = {
852 0x170007f1, 874 0x170007f1,
853 0xd00203f0, 875 0xd00203f0,
854 0x04bd0009, 876 0x04bd0009,
855/* 0x0942: ctx_chan */ 877/* 0x099a: ctx_chan */
856 0x21f500f8, 878 0x21f500f8,
857 0xa7f00824, 879 0xa7f0087c,
858 0xd021f40c, 880 0xd021f40c,
859 0xf505f7f0, 881 0xf505f7f0,
860 0xf8080621, 882 0xf8085e21,
861/* 0x0955: ctx_mmio_exec */ 883/* 0x09ad: ctx_mmio_exec */
862 0x41039800, 884 0x41039800,
863 0x810007f1, 885 0x810007f1,
864 0xd00203f0, 886 0xd00203f0,
865 0x04bd0003, 887 0x04bd0003,
866/* 0x0966: ctx_mmio_loop */ 888/* 0x09be: ctx_mmio_loop */
867 0x34c434bd, 889 0x34c434bd,
868 0x0f1bf4ff, 890 0x0f1bf4ff,
869 0x020057f1, 891 0x020057f1,
870 0xfa0653f0, 892 0xfa0653f0,
871 0x03f80535, 893 0x03f80535,
872/* 0x0978: ctx_mmio_pull */ 894/* 0x09d0: ctx_mmio_pull */
873 0x98804e98, 895 0x98804e98,
874 0x21f4814f, 896 0x21f4814f,
875 0x0830b69d, 897 0x0830b69d,
876 0xf40112b6, 898 0xf40112b6,
877/* 0x098a: ctx_mmio_done */ 899/* 0x09e2: ctx_mmio_done */
878 0x0398df1b, 900 0x0398df1b,
879 0x0007f116, 901 0x0007f116,
880 0x0203f081, 902 0x0203f081,
@@ -883,30 +905,30 @@ uint32_t nve0_grhub_code[] = {
883 0x010017f1, 905 0x010017f1,
884 0xfa0613f0, 906 0xfa0613f0,
885 0x03f80601, 907 0x03f80601,
886/* 0x09aa: ctx_xfer */ 908/* 0x0a02: ctx_xfer */
887 0xe7f000f8, 909 0xe7f000f8,
888 0x0007f104, 910 0x0007f104,
889 0x0303f002, 911 0x0303f002,
890 0xbd000ed0, 912 0xbd000ed0,
891/* 0x09b9: ctx_xfer_idle */ 913/* 0x0a11: ctx_xfer_idle */
892 0x00e7f104, 914 0x00e7f104,
893 0x03e3f000, 915 0x03e3f000,
894 0xf100eecf, 916 0xf100eecf,
895 0xf42000e4, 917 0xf42000e4,
896 0x11f4f21b, 918 0x11f4f21b,
897 0x0d02f406, 919 0x0d02f406,
898/* 0x09d0: ctx_xfer_pre */ 920/* 0x0a28: ctx_xfer_pre */
899 0xf510f7f0, 921 0xf510f7f0,
900 0xf407de21, 922 0xf4083621,
901/* 0x09da: ctx_xfer_pre_load */ 923/* 0x0a32: ctx_xfer_pre_load */
902 0xf7f01c11, 924 0xf7f01c11,
903 0x7f21f502, 925 0xd721f502,
904 0x9121f507, 926 0xe921f507,
905 0xa621f507, 927 0xfe21f507,
906 0xf5f4bd07, 928 0xf5f4bd07,
907 0xf5077f21, 929 0xf507d721,
908/* 0x09f3: ctx_xfer_exec */ 930/* 0x0a4b: ctx_xfer_exec */
909 0x98082421, 931 0x98087c21,
910 0x24bd1601, 932 0x24bd1601,
911 0x050007f1, 933 0x050007f1,
912 0xd00103f0, 934 0xd00103f0,
@@ -941,21 +963,21 @@ uint32_t nve0_grhub_code[] = {
941 0xa7f01301, 963 0xa7f01301,
942 0xd021f40c, 964 0xd021f40c,
943 0xf505f7f0, 965 0xf505f7f0,
944 0xf4080621, 966 0xf4085e21,
945/* 0x0a82: ctx_xfer_post */ 967/* 0x0ada: ctx_xfer_post */
946 0xf7f02e02, 968 0xf7f02e02,
947 0x7f21f502, 969 0xd721f502,
948 0xf5f4bd07, 970 0xf5f4bd07,
949 0xf507de21, 971 0xf5083621,
950 0xf5027f21, 972 0xf5027f21,
951 0xbd079121, 973 0xbd07e921,
952 0x7f21f5f4, 974 0xd721f5f4,
953 0x1011f407, 975 0x1011f407,
954 0xfd400198, 976 0xfd400198,
955 0x0bf40511, 977 0x0bf40511,
956 0x5521f507, 978 0xad21f507,
957/* 0x0aad: ctx_xfer_no_post_mmio */ 979/* 0x0b05: ctx_xfer_no_post_mmio */
958/* 0x0aad: ctx_xfer_done */ 980/* 0x0b05: ctx_xfer_done */
959 0x0000f809, 981 0x0000f809,
960 0x00000000, 982 0x00000000,
961 0x00000000, 983 0x00000000,
@@ -977,4 +999,46 @@ uint32_t nve0_grhub_code[] = {
977 0x00000000, 999 0x00000000,
978 0x00000000, 1000 0x00000000,
979 0x00000000, 1001 0x00000000,
1002 0x00000000,
1003 0x00000000,
1004 0x00000000,
1005 0x00000000,
1006 0x00000000,
1007 0x00000000,
1008 0x00000000,
1009 0x00000000,
1010 0x00000000,
1011 0x00000000,
1012 0x00000000,
1013 0x00000000,
1014 0x00000000,
1015 0x00000000,
1016 0x00000000,
1017 0x00000000,
1018 0x00000000,
1019 0x00000000,
1020 0x00000000,
1021 0x00000000,
1022 0x00000000,
1023 0x00000000,
1024 0x00000000,
1025 0x00000000,
1026 0x00000000,
1027 0x00000000,
1028 0x00000000,
1029 0x00000000,
1030 0x00000000,
1031 0x00000000,
1032 0x00000000,
1033 0x00000000,
1034 0x00000000,
1035 0x00000000,
1036 0x00000000,
1037 0x00000000,
1038 0x00000000,
1039 0x00000000,
1040 0x00000000,
1041 0x00000000,
1042 0x00000000,
1043 0x00000000,
980}; 1044};
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvf0.fuc.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvf0.fuc.h
index a5aee5a4302f..a0af4b703a8e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvf0.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/hubnvf0.fuc.h
@@ -528,10 +528,10 @@ uint32_t nvf0_grhub_code[] = {
528 0x0001d001, 528 0x0001d001,
529 0x17f104bd, 529 0x17f104bd,
530 0xf7f00100, 530 0xf7f00100,
531 0x7f21f502, 531 0xd721f502,
532 0x9121f507, 532 0xe921f507,
533 0x10f7f007, 533 0x10f7f007,
534 0x07de21f5, 534 0x083621f5,
535 0x98000e98, 535 0x98000e98,
536 0x21f5010f, 536 0x21f5010f,
537 0x14950150, 537 0x14950150,
@@ -574,9 +574,9 @@ uint32_t nvf0_grhub_code[] = {
574 0xb6800040, 574 0xb6800040,
575 0x1bf40132, 575 0x1bf40132,
576 0x00f7f0be, 576 0x00f7f0be,
577 0x07de21f5, 577 0x083621f5,
578 0xf500f7f0, 578 0xf500f7f0,
579 0xf1077f21, 579 0xf107d721,
580 0xf0010007, 580 0xf0010007,
581 0x01d00203, 581 0x01d00203,
582 0xbd04bd00, 582 0xbd04bd00,
@@ -610,8 +610,8 @@ uint32_t nvf0_grhub_code[] = {
610 0x09d00203, 610 0x09d00203,
611 0xf404bd00, 611 0xf404bd00,
612 0x31f40132, 612 0x31f40132,
613 0xaa21f502, 613 0x0221f502,
614 0xf094bd09, 614 0xf094bd0a,
615 0x07f10799, 615 0x07f10799,
616 0x03f01700, 616 0x03f01700,
617 0x0009d002, 617 0x0009d002,
@@ -621,7 +621,7 @@ uint32_t nvf0_grhub_code[] = {
621 0x0203f037, 621 0x0203f037,
622 0xbd0009d0, 622 0xbd0009d0,
623 0x0131f404, 623 0x0131f404,
624 0x09aa21f5, 624 0x0a0221f5,
625 0x99f094bd, 625 0x99f094bd,
626 0x0007f106, 626 0x0007f106,
627 0x0203f017, 627 0x0203f017,
@@ -631,7 +631,7 @@ uint32_t nvf0_grhub_code[] = {
631 0x12b920f9, 631 0x12b920f9,
632 0x0132f402, 632 0x0132f402,
633 0xf50232f4, 633 0xf50232f4,
634 0xfc09aa21, 634 0xfc0a0221,
635 0x0007f120, 635 0x0007f120,
636 0x0203f0c0, 636 0x0203f0c0,
637 0xbd0002d0, 637 0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t nvf0_grhub_code[] = {
640 0xf41f23c8, 640 0xf41f23c8,
641 0x31f40d0b, 641 0x31f40d0b,
642 0x0232f401, 642 0x0232f401,
643 0x09aa21f5, 643 0x0a0221f5,
644/* 0x063c: chsw_done */ 644/* 0x063c: chsw_done */
645 0xf10127f0, 645 0xf10127f0,
646 0xf0c30007, 646 0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t nvf0_grhub_code[] = {
654/* 0x0660: main_not_ctx_switch */ 654/* 0x0660: main_not_ctx_switch */
655 0xf401e4b0, 655 0xf401e4b0,
656 0xf2b90d1b, 656 0xf2b90d1b,
657 0x4221f502, 657 0x9a21f502,
658 0x460ef409, 658 0x460ef409,
659/* 0x0670: main_not_ctx_chan */ 659/* 0x0670: main_not_ctx_chan */
660 0xf402e4b0, 660 0xf402e4b0,
@@ -664,8 +664,8 @@ uint32_t nvf0_grhub_code[] = {
664 0x09d00203, 664 0x09d00203,
665 0xf404bd00, 665 0xf404bd00,
666 0x32f40132, 666 0x32f40132,
667 0xaa21f502, 667 0x0221f502,
668 0xf094bd09, 668 0xf094bd0a,
669 0x07f10799, 669 0x07f10799,
670 0x03f01700, 670 0x03f01700,
671 0x0009d002, 671 0x0009d002,
@@ -710,18 +710,40 @@ uint32_t nvf0_grhub_code[] = {
710/* 0x072b: ih_no_ctxsw */ 710/* 0x072b: ih_no_ctxsw */
711 0xe40421f4, 711 0xe40421f4,
712 0xf40400ab, 712 0xf40400ab,
713 0xb7f1140b, 713 0xe7f16c0b,
714 0xe3f00708,
715 0x6821f440,
716 0xf102ffb9,
717 0xf0040007,
718 0x0fd00203,
719 0xf104bd00,
720 0xf00704e7,
721 0x21f440e3,
722 0x02ffb968,
723 0x030007f1,
724 0xd00203f0,
725 0x04bd000f,
726 0x9450fec7,
727 0xf7f102ee,
728 0xf3f00700,
729 0x00efbb40,
730 0xf16821f4,
731 0xf0020007,
732 0x0fd00203,
733 0xf004bd00,
734 0x21f503f7,
735 0xb7f1037e,
714 0xbfb90100, 736 0xbfb90100,
715 0x44e7f102, 737 0x44e7f102,
716 0x40e3f001, 738 0x40e3f001,
717/* 0x0743: ih_no_fwmthd */ 739/* 0x079b: ih_no_fwmthd */
718 0xf19d21f4, 740 0xf19d21f4,
719 0xbd0104b7, 741 0xbd0504b7,
720 0xb4abffb0, 742 0xb4abffb0,
721 0xf10f0bf4, 743 0xf10f0bf4,
722 0xf0070007, 744 0xf0070007,
723 0x0bd00303, 745 0x0bd00303,
724/* 0x075b: ih_no_other */ 746/* 0x07b3: ih_no_other */
725 0xf104bd00, 747 0xf104bd00,
726 0xf0010007, 748 0xf0010007,
727 0x0ad00003, 749 0x0ad00003,
@@ -731,19 +753,19 @@ uint32_t nvf0_grhub_code[] = {
731 0xfc90fca0, 753 0xfc90fca0,
732 0x0088fe80, 754 0x0088fe80,
733 0x32f480fc, 755 0x32f480fc,
734/* 0x077f: ctx_4170s */ 756/* 0x07d7: ctx_4170s */
735 0xf001f800, 757 0xf001f800,
736 0xffb910f5, 758 0xffb910f5,
737 0x70e7f102, 759 0x70e7f102,
738 0x40e3f041, 760 0x40e3f041,
739 0xf89d21f4, 761 0xf89d21f4,
740/* 0x0791: ctx_4170w */ 762/* 0x07e9: ctx_4170w */
741 0x70e7f100, 763 0x70e7f100,
742 0x40e3f041, 764 0x40e3f041,
743 0xb96821f4, 765 0xb96821f4,
744 0xf4f002ff, 766 0xf4f002ff,
745 0xf01bf410, 767 0xf01bf410,
746/* 0x07a6: ctx_redswitch */ 768/* 0x07fe: ctx_redswitch */
747 0xe7f100f8, 769 0xe7f100f8,
748 0xe5f00200, 770 0xe5f00200,
749 0x20e5f040, 771 0x20e5f040,
@@ -751,7 +773,7 @@ uint32_t nvf0_grhub_code[] = {
751 0xf0850007, 773 0xf0850007,
752 0x0ed00103, 774 0x0ed00103,
753 0xf004bd00, 775 0xf004bd00,
754/* 0x07c2: ctx_redswitch_delay */ 776/* 0x081a: ctx_redswitch_delay */
755 0xf2b608f7, 777 0xf2b608f7,
756 0xfd1bf401, 778 0xfd1bf401,
757 0x0400e5f1, 779 0x0400e5f1,
@@ -759,7 +781,7 @@ uint32_t nvf0_grhub_code[] = {
759 0x850007f1, 781 0x850007f1,
760 0xd00103f0, 782 0xd00103f0,
761 0x04bd000e, 783 0x04bd000e,
762/* 0x07de: ctx_86c */ 784/* 0x0836: ctx_86c */
763 0x07f100f8, 785 0x07f100f8,
764 0x03f02300, 786 0x03f02300,
765 0x000fd002, 787 0x000fd002,
@@ -770,17 +792,17 @@ uint32_t nvf0_grhub_code[] = {
770 0xe7f102ff, 792 0xe7f102ff,
771 0xe3f0a88c, 793 0xe3f0a88c,
772 0x9d21f441, 794 0x9d21f441,
773/* 0x0806: ctx_mem */ 795/* 0x085e: ctx_mem */
774 0x07f100f8, 796 0x07f100f8,
775 0x03f08400, 797 0x03f08400,
776 0x000fd002, 798 0x000fd002,
777/* 0x0812: ctx_mem_wait */ 799/* 0x086a: ctx_mem_wait */
778 0xf7f104bd, 800 0xf7f104bd,
779 0xf3f08400, 801 0xf3f08400,
780 0x00ffcf02, 802 0x00ffcf02,
781 0xf405fffd, 803 0xf405fffd,
782 0x00f8f31b, 804 0x00f8f31b,
783/* 0x0824: ctx_load */ 805/* 0x087c: ctx_load */
784 0x99f094bd, 806 0x99f094bd,
785 0x0007f105, 807 0x0007f105,
786 0x0203f037, 808 0x0203f037,
@@ -797,7 +819,7 @@ uint32_t nvf0_grhub_code[] = {
797 0x0203f083, 819 0x0203f083,
798 0xbd0002d0, 820 0xbd0002d0,
799 0x07f7f004, 821 0x07f7f004,
800 0x080621f5, 822 0x085e21f5,
801 0xc00007f1, 823 0xc00007f1,
802 0xd00203f0, 824 0xd00203f0,
803 0x04bd0002, 825 0x04bd0002,
@@ -852,29 +874,29 @@ uint32_t nvf0_grhub_code[] = {
852 0x170007f1, 874 0x170007f1,
853 0xd00203f0, 875 0xd00203f0,
854 0x04bd0009, 876 0x04bd0009,
855/* 0x0942: ctx_chan */ 877/* 0x099a: ctx_chan */
856 0x21f500f8, 878 0x21f500f8,
857 0xa7f00824, 879 0xa7f0087c,
858 0xd021f40c, 880 0xd021f40c,
859 0xf505f7f0, 881 0xf505f7f0,
860 0xf8080621, 882 0xf8085e21,
861/* 0x0955: ctx_mmio_exec */ 883/* 0x09ad: ctx_mmio_exec */
862 0x41039800, 884 0x41039800,
863 0x810007f1, 885 0x810007f1,
864 0xd00203f0, 886 0xd00203f0,
865 0x04bd0003, 887 0x04bd0003,
866/* 0x0966: ctx_mmio_loop */ 888/* 0x09be: ctx_mmio_loop */
867 0x34c434bd, 889 0x34c434bd,
868 0x0f1bf4ff, 890 0x0f1bf4ff,
869 0x020057f1, 891 0x020057f1,
870 0xfa0653f0, 892 0xfa0653f0,
871 0x03f80535, 893 0x03f80535,
872/* 0x0978: ctx_mmio_pull */ 894/* 0x09d0: ctx_mmio_pull */
873 0x98804e98, 895 0x98804e98,
874 0x21f4814f, 896 0x21f4814f,
875 0x0830b69d, 897 0x0830b69d,
876 0xf40112b6, 898 0xf40112b6,
877/* 0x098a: ctx_mmio_done */ 899/* 0x09e2: ctx_mmio_done */
878 0x0398df1b, 900 0x0398df1b,
879 0x0007f116, 901 0x0007f116,
880 0x0203f081, 902 0x0203f081,
@@ -883,30 +905,30 @@ uint32_t nvf0_grhub_code[] = {
883 0x010017f1, 905 0x010017f1,
884 0xfa0613f0, 906 0xfa0613f0,
885 0x03f80601, 907 0x03f80601,
886/* 0x09aa: ctx_xfer */ 908/* 0x0a02: ctx_xfer */
887 0xe7f000f8, 909 0xe7f000f8,
888 0x0007f104, 910 0x0007f104,
889 0x0303f002, 911 0x0303f002,
890 0xbd000ed0, 912 0xbd000ed0,
891/* 0x09b9: ctx_xfer_idle */ 913/* 0x0a11: ctx_xfer_idle */
892 0x00e7f104, 914 0x00e7f104,
893 0x03e3f000, 915 0x03e3f000,
894 0xf100eecf, 916 0xf100eecf,
895 0xf42000e4, 917 0xf42000e4,
896 0x11f4f21b, 918 0x11f4f21b,
897 0x0d02f406, 919 0x0d02f406,
898/* 0x09d0: ctx_xfer_pre */ 920/* 0x0a28: ctx_xfer_pre */
899 0xf510f7f0, 921 0xf510f7f0,
900 0xf407de21, 922 0xf4083621,
901/* 0x09da: ctx_xfer_pre_load */ 923/* 0x0a32: ctx_xfer_pre_load */
902 0xf7f01c11, 924 0xf7f01c11,
903 0x7f21f502, 925 0xd721f502,
904 0x9121f507, 926 0xe921f507,
905 0xa621f507, 927 0xfe21f507,
906 0xf5f4bd07, 928 0xf5f4bd07,
907 0xf5077f21, 929 0xf507d721,
908/* 0x09f3: ctx_xfer_exec */ 930/* 0x0a4b: ctx_xfer_exec */
909 0x98082421, 931 0x98087c21,
910 0x24bd1601, 932 0x24bd1601,
911 0x050007f1, 933 0x050007f1,
912 0xd00103f0, 934 0xd00103f0,
@@ -941,21 +963,21 @@ uint32_t nvf0_grhub_code[] = {
941 0xa7f01301, 963 0xa7f01301,
942 0xd021f40c, 964 0xd021f40c,
943 0xf505f7f0, 965 0xf505f7f0,
944 0xf4080621, 966 0xf4085e21,
945/* 0x0a82: ctx_xfer_post */ 967/* 0x0ada: ctx_xfer_post */
946 0xf7f02e02, 968 0xf7f02e02,
947 0x7f21f502, 969 0xd721f502,
948 0xf5f4bd07, 970 0xf5f4bd07,
949 0xf507de21, 971 0xf5083621,
950 0xf5027f21, 972 0xf5027f21,
951 0xbd079121, 973 0xbd07e921,
952 0x7f21f5f4, 974 0xd721f5f4,
953 0x1011f407, 975 0x1011f407,
954 0xfd400198, 976 0xfd400198,
955 0x0bf40511, 977 0x0bf40511,
956 0x5521f507, 978 0xad21f507,
957/* 0x0aad: ctx_xfer_no_post_mmio */ 979/* 0x0b05: ctx_xfer_no_post_mmio */
958/* 0x0aad: ctx_xfer_done */ 980/* 0x0b05: ctx_xfer_done */
959 0x0000f809, 981 0x0000f809,
960 0x00000000, 982 0x00000000,
961 0x00000000, 983 0x00000000,
@@ -977,4 +999,46 @@ uint32_t nvf0_grhub_code[] = {
977 0x00000000, 999 0x00000000,
978 0x00000000, 1000 0x00000000,
979 0x00000000, 1001 0x00000000,
1002 0x00000000,
1003 0x00000000,
1004 0x00000000,
1005 0x00000000,
1006 0x00000000,
1007 0x00000000,
1008 0x00000000,
1009 0x00000000,
1010 0x00000000,
1011 0x00000000,
1012 0x00000000,
1013 0x00000000,
1014 0x00000000,
1015 0x00000000,
1016 0x00000000,
1017 0x00000000,
1018 0x00000000,
1019 0x00000000,
1020 0x00000000,
1021 0x00000000,
1022 0x00000000,
1023 0x00000000,
1024 0x00000000,
1025 0x00000000,
1026 0x00000000,
1027 0x00000000,
1028 0x00000000,
1029 0x00000000,
1030 0x00000000,
1031 0x00000000,
1032 0x00000000,
1033 0x00000000,
1034 0x00000000,
1035 0x00000000,
1036 0x00000000,
1037 0x00000000,
1038 0x00000000,
1039 0x00000000,
1040 0x00000000,
1041 0x00000000,
1042 0x00000000,
1043 0x00000000,
980}; 1044};
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/macros.fuc b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/macros.fuc
index a47d49db5232..2a0b0f844299 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/macros.fuc
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/macros.fuc
@@ -30,6 +30,12 @@
30#define GK110 0xf0 30#define GK110 0xf0
31#define GK208 0x108 31#define GK208 0x108
32 32
33#define NV_PGRAPH_TRAPPED_ADDR 0x400704
34#define NV_PGRAPH_TRAPPED_DATA_LO 0x400708
35#define NV_PGRAPH_TRAPPED_DATA_HI 0x40070c
36
37#define NV_PGRAPH_FE_OBJECT_TABLE(n) ((n) * 4 + 0x400700)
38
33#define NV_PGRAPH_FECS_INTR_ACK 0x409004 39#define NV_PGRAPH_FECS_INTR_ACK 0x409004
34#define NV_PGRAPH_FECS_INTR 0x409008 40#define NV_PGRAPH_FECS_INTR 0x409008
35#define NV_PGRAPH_FECS_INTR_FWMTHD 0x00000400 41#define NV_PGRAPH_FECS_INTR_FWMTHD 0x00000400
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/os.h b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/os.h
index fd1d380de094..1718ae4e8224 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/fuc/os.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/fuc/os.h
@@ -3,5 +3,6 @@
3 3
4#define E_BAD_COMMAND 0x00000001 4#define E_BAD_COMMAND 0x00000001
5#define E_CMD_OVERFLOW 0x00000002 5#define E_CMD_OVERFLOW 0x00000002
6#define E_BAD_FWMTHD 0x00000003
6 7
7#endif 8#endif
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
index 1a2d56493cf6..20665c21d80e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
@@ -976,7 +976,6 @@ nv50_graph_init(struct nouveau_object *object)
976 break; 976 break;
977 case 0xa0: 977 case 0xa0:
978 default: 978 default:
979 nv_wr32(priv, 0x402cc0, 0x00000000);
980 if (nv_device(priv)->chipset == 0xa0 || 979 if (nv_device(priv)->chipset == 0xa0 ||
981 nv_device(priv)->chipset == 0xaa || 980 nv_device(priv)->chipset == 0xaa ||
982 nv_device(priv)->chipset == 0xac) { 981 nv_device(priv)->chipset == 0xac) {
@@ -991,10 +990,10 @@ nv50_graph_init(struct nouveau_object *object)
991 990
992 /* zero out zcull regions */ 991 /* zero out zcull regions */
993 for (i = 0; i < 8; i++) { 992 for (i = 0; i < 8; i++) {
994 nv_wr32(priv, 0x402c20 + (i * 8), 0x00000000); 993 nv_wr32(priv, 0x402c20 + (i * 0x10), 0x00000000);
995 nv_wr32(priv, 0x402c24 + (i * 8), 0x00000000); 994 nv_wr32(priv, 0x402c24 + (i * 0x10), 0x00000000);
996 nv_wr32(priv, 0x402c28 + (i * 8), 0x00000000); 995 nv_wr32(priv, 0x402c28 + (i * 0x10), 0x00000000);
997 nv_wr32(priv, 0x402c2c + (i * 8), 0x00000000); 996 nv_wr32(priv, 0x402c2c + (i * 0x10), 0x00000000);
998 } 997 }
999 return 0; 998 return 0;
1000} 999}
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
index bf7bdb1f291e..aa0838916354 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
@@ -789,17 +789,40 @@ nvc0_graph_ctxctl_debug(struct nvc0_graph_priv *priv)
789static void 789static void
790nvc0_graph_ctxctl_isr(struct nvc0_graph_priv *priv) 790nvc0_graph_ctxctl_isr(struct nvc0_graph_priv *priv)
791{ 791{
792 u32 ustat = nv_rd32(priv, 0x409c18); 792 u32 stat = nv_rd32(priv, 0x409c18);
793 793
794 if (ustat & 0x00000001) 794 if (stat & 0x00000001) {
795 nv_error(priv, "CTXCTL ucode error\n"); 795 u32 code = nv_rd32(priv, 0x409814);
796 if (ustat & 0x00080000) 796 if (code == E_BAD_FWMTHD) {
797 nv_error(priv, "CTXCTL watchdog timeout\n"); 797 u32 class = nv_rd32(priv, 0x409808);
798 if (ustat & ~0x00080001) 798 u32 addr = nv_rd32(priv, 0x40980c);
799 nv_error(priv, "CTXCTL 0x%08x\n", ustat); 799 u32 subc = (addr & 0x00070000) >> 16;
800 u32 mthd = (addr & 0x00003ffc);
801 u32 data = nv_rd32(priv, 0x409810);
802
803 nv_error(priv, "FECS MTHD subc %d class 0x%04x "
804 "mthd 0x%04x data 0x%08x\n",
805 subc, class, mthd, data);
800 806
801 nvc0_graph_ctxctl_debug(priv); 807 nv_wr32(priv, 0x409c20, 0x00000001);
802 nv_wr32(priv, 0x409c20, ustat); 808 stat &= ~0x00000001;
809 } else {
810 nv_error(priv, "FECS ucode error %d\n", code);
811 }
812 }
813
814 if (stat & 0x00080000) {
815 nv_error(priv, "FECS watchdog timeout\n");
816 nvc0_graph_ctxctl_debug(priv);
817 nv_wr32(priv, 0x409c20, 0x00080000);
818 stat &= ~0x00080000;
819 }
820
821 if (stat) {
822 nv_error(priv, "FECS 0x%08x\n", stat);
823 nvc0_graph_ctxctl_debug(priv);
824 nv_wr32(priv, 0x409c20, stat);
825 }
803} 826}
804 827
805static void 828static void
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h
index 75203a99d902..ffc289198dd8 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h
@@ -38,6 +38,8 @@
38#include <engine/fifo.h> 38#include <engine/fifo.h>
39#include <engine/graph.h> 39#include <engine/graph.h>
40 40
41#include "fuc/os.h"
42
41#define GPC_MAX 32 43#define GPC_MAX 32
42#define TPC_MAX (GPC_MAX * 8) 44#define TPC_MAX (GPC_MAX * 8)
43 45
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h b/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h
index db1b39d08013..825f7bb46b67 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/i2c.h
@@ -84,6 +84,7 @@ extern struct nouveau_oclass *nv4e_i2c_oclass;
84extern struct nouveau_oclass *nv50_i2c_oclass; 84extern struct nouveau_oclass *nv50_i2c_oclass;
85extern struct nouveau_oclass *nv94_i2c_oclass; 85extern struct nouveau_oclass *nv94_i2c_oclass;
86extern struct nouveau_oclass *nvd0_i2c_oclass; 86extern struct nouveau_oclass *nvd0_i2c_oclass;
87extern struct nouveau_oclass *gf117_i2c_oclass;
87extern struct nouveau_oclass *nve0_i2c_oclass; 88extern struct nouveau_oclass *nve0_i2c_oclass;
88 89
89static inline int 90static inline int
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c
index 4ac1aa30ea11..0e62a3240144 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nve0.c
@@ -307,7 +307,6 @@ calc_clk(struct nve0_clock_priv *priv,
307 info->dsrc = src0; 307 info->dsrc = src0;
308 if (div0) { 308 if (div0) {
309 info->ddiv |= 0x80000000; 309 info->ddiv |= 0x80000000;
310 info->ddiv |= div0 << 8;
311 info->ddiv |= div0; 310 info->ddiv |= div0;
312 } 311 }
313 if (div1D) { 312 if (div1D) {
@@ -352,7 +351,7 @@ nve0_clock_prog_0(struct nve0_clock_priv *priv, int clk)
352{ 351{
353 struct nve0_clock_info *info = &priv->eng[clk]; 352 struct nve0_clock_info *info = &priv->eng[clk];
354 if (!info->ssel) { 353 if (!info->ssel) {
355 nv_mask(priv, 0x1371d0 + (clk * 0x04), 0x80003f3f, info->ddiv); 354 nv_mask(priv, 0x1371d0 + (clk * 0x04), 0x8000003f, info->ddiv);
356 nv_wr32(priv, 0x137160 + (clk * 0x04), info->dsrc); 355 nv_wr32(priv, 0x137160 + (clk * 0x04), info->dsrc);
357 } 356 }
358} 357}
@@ -389,7 +388,10 @@ static void
389nve0_clock_prog_3(struct nve0_clock_priv *priv, int clk) 388nve0_clock_prog_3(struct nve0_clock_priv *priv, int clk)
390{ 389{
391 struct nve0_clock_info *info = &priv->eng[clk]; 390 struct nve0_clock_info *info = &priv->eng[clk];
392 nv_mask(priv, 0x137250 + (clk * 0x04), 0x00003f3f, info->mdiv); 391 if (info->ssel)
392 nv_mask(priv, 0x137250 + (clk * 0x04), 0x00003f00, info->mdiv);
393 else
394 nv_mask(priv, 0x137250 + (clk * 0x04), 0x0000003f, info->mdiv);
393} 395}
394 396
395static void 397static void
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
index 84c7efbc4f38..1ad3ea503133 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
@@ -262,8 +262,8 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
262 struct nve0_ram *ram = (void *)pfb->ram; 262 struct nve0_ram *ram = (void *)pfb->ram;
263 struct nve0_ramfuc *fuc = &ram->fuc; 263 struct nve0_ramfuc *fuc = &ram->fuc;
264 struct nouveau_ram_data *next = ram->base.next; 264 struct nouveau_ram_data *next = ram->base.next;
265 int vc = !(next->bios.ramcfg_11_02_08); 265 int vc = !next->bios.ramcfg_11_02_08;
266 int mv = !(next->bios.ramcfg_11_02_04); 266 int mv = !next->bios.ramcfg_11_02_04;
267 u32 mask, data; 267 u32 mask, data;
268 268
269 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000); 269 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000);
@@ -370,8 +370,8 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
370 } 370 }
371 } 371 }
372 372
373 if ( (next->bios.ramcfg_11_02_40) || 373 if (next->bios.ramcfg_11_02_40 ||
374 (next->bios.ramcfg_11_07_10)) { 374 next->bios.ramcfg_11_07_10) {
375 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000); 375 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000);
376 ram_nsec(fuc, 20000); 376 ram_nsec(fuc, 20000);
377 } 377 }
@@ -417,7 +417,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
417 ram_mask(fuc, 0x10f694, 0xff00ff00, data); 417 ram_mask(fuc, 0x10f694, 0xff00ff00, data);
418 } 418 }
419 419
420 if (ram->mode == 2 && (next->bios.ramcfg_11_08_10)) 420 if (ram->mode == 2 && next->bios.ramcfg_11_08_10)
421 data = 0x00000080; 421 data = 0x00000080;
422 else 422 else
423 data = 0x00000000; 423 data = 0x00000000;
@@ -425,13 +425,13 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
425 425
426 mask = 0x00070000; 426 mask = 0x00070000;
427 data = 0x00000000; 427 data = 0x00000000;
428 if (!(next->bios.ramcfg_11_02_80)) 428 if (!next->bios.ramcfg_11_02_80)
429 data |= 0x03000000; 429 data |= 0x03000000;
430 if (!(next->bios.ramcfg_11_02_40)) 430 if (!next->bios.ramcfg_11_02_40)
431 data |= 0x00002000; 431 data |= 0x00002000;
432 if (!(next->bios.ramcfg_11_07_10)) 432 if (!next->bios.ramcfg_11_07_10)
433 data |= 0x00004000; 433 data |= 0x00004000;
434 if (!(next->bios.ramcfg_11_07_08)) 434 if (!next->bios.ramcfg_11_07_08)
435 data |= 0x00000003; 435 data |= 0x00000003;
436 else 436 else
437 data |= 0x74000000; 437 data |= 0x74000000;
@@ -486,7 +486,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
486 486
487 data = mask = 0x00000000; 487 data = mask = 0x00000000;
488 if (NOTE00(ramcfg_02_03 != 0)) { 488 if (NOTE00(ramcfg_02_03 != 0)) {
489 data |= (next->bios.ramcfg_11_02_03) << 8; 489 data |= next->bios.ramcfg_11_02_03 << 8;
490 mask |= 0x00000300; 490 mask |= 0x00000300;
491 } 491 }
492 if (NOTE00(ramcfg_01_10)) { 492 if (NOTE00(ramcfg_01_10)) {
@@ -498,7 +498,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
498 498
499 data = mask = 0x00000000; 499 data = mask = 0x00000000;
500 if (NOTE00(timing_30_07 != 0)) { 500 if (NOTE00(timing_30_07 != 0)) {
501 data |= (next->bios.timing_20_30_07) << 28; 501 data |= next->bios.timing_20_30_07 << 28;
502 mask |= 0x70000000; 502 mask |= 0x70000000;
503 } 503 }
504 if (NOTE00(ramcfg_01_01)) { 504 if (NOTE00(ramcfg_01_01)) {
@@ -510,7 +510,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
510 510
511 data = mask = 0x00000000; 511 data = mask = 0x00000000;
512 if (NOTE00(timing_30_07 != 0)) { 512 if (NOTE00(timing_30_07 != 0)) {
513 data |= (next->bios.timing_20_30_07) << 28; 513 data |= next->bios.timing_20_30_07 << 28;
514 mask |= 0x70000000; 514 mask |= 0x70000000;
515 } 515 }
516 if (NOTE00(ramcfg_01_02)) { 516 if (NOTE00(ramcfg_01_02)) {
@@ -522,16 +522,16 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
522 522
523 mask = 0x33f00000; 523 mask = 0x33f00000;
524 data = 0x00000000; 524 data = 0x00000000;
525 if (!(next->bios.ramcfg_11_01_04)) 525 if (!next->bios.ramcfg_11_01_04)
526 data |= 0x20200000; 526 data |= 0x20200000;
527 if (!(next->bios.ramcfg_11_07_80)) 527 if (!next->bios.ramcfg_11_07_80)
528 data |= 0x12800000; 528 data |= 0x12800000;
529 /*XXX: see note above about there probably being some condition 529 /*XXX: see note above about there probably being some condition
530 * for the 10f824 stuff that uses ramcfg 3... 530 * for the 10f824 stuff that uses ramcfg 3...
531 */ 531 */
532 if ( (next->bios.ramcfg_11_03_f0)) { 532 if (next->bios.ramcfg_11_03_f0) {
533 if (next->bios.rammap_11_08_0c) { 533 if (next->bios.rammap_11_08_0c) {
534 if (!(next->bios.ramcfg_11_07_80)) 534 if (!next->bios.ramcfg_11_07_80)
535 mask |= 0x00000020; 535 mask |= 0x00000020;
536 else 536 else
537 data |= 0x00000020; 537 data |= 0x00000020;
@@ -563,7 +563,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
563 ram_wait(fuc, 0x100710, 0x80000000, 0x80000000, 200000); 563 ram_wait(fuc, 0x100710, 0x80000000, 0x80000000, 200000);
564 } 564 }
565 565
566 data = (next->bios.timing_20_30_07) << 8; 566 data = next->bios.timing_20_30_07 << 8;
567 if (next->bios.ramcfg_11_01_01) 567 if (next->bios.ramcfg_11_01_01)
568 data |= 0x80000000; 568 data |= 0x80000000;
569 ram_mask(fuc, 0x100778, 0x00000700, data); 569 ram_mask(fuc, 0x100778, 0x00000700, data);
@@ -588,7 +588,7 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
588 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */ 588 ram_wr32(fuc, 0x10f310, 0x00000001); /* REFRESH */
589 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */ 589 ram_wr32(fuc, 0x10f210, 0x80000000); /* REFRESH_AUTO = 1 */
590 590
591 if ((next->bios.ramcfg_11_08_10) && (ram->mode == 2) /*XXX*/) { 591 if (next->bios.ramcfg_11_08_10 && (ram->mode == 2) /*XXX*/) {
592 u32 temp = ram_mask(fuc, 0x10f294, 0xff000000, 0x24000000); 592 u32 temp = ram_mask(fuc, 0x10f294, 0xff000000, 0x24000000);
593 nve0_ram_train(fuc, 0xbc0e0000, 0xa4010000); /*XXX*/ 593 nve0_ram_train(fuc, 0xbc0e0000, 0xa4010000); /*XXX*/
594 ram_nsec(fuc, 1000); 594 ram_nsec(fuc, 1000);
@@ -621,8 +621,8 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
621 data = ram_rd32(fuc, 0x10f978); 621 data = ram_rd32(fuc, 0x10f978);
622 data &= ~0x00046144; 622 data &= ~0x00046144;
623 data |= 0x0000000b; 623 data |= 0x0000000b;
624 if (!(next->bios.ramcfg_11_07_08)) { 624 if (!next->bios.ramcfg_11_07_08) {
625 if (!(next->bios.ramcfg_11_07_04)) 625 if (!next->bios.ramcfg_11_07_04)
626 data |= 0x0000200c; 626 data |= 0x0000200c;
627 else 627 else
628 data |= 0x00000000; 628 data |= 0x00000000;
@@ -636,11 +636,11 @@ nve0_ram_calc_gddr5(struct nouveau_fb *pfb, u32 freq)
636 ram_wr32(fuc, 0x10f830, data); 636 ram_wr32(fuc, 0x10f830, data);
637 } 637 }
638 638
639 if (!(next->bios.ramcfg_11_07_08)) { 639 if (!next->bios.ramcfg_11_07_08) {
640 data = 0x88020000; 640 data = 0x88020000;
641 if ( (next->bios.ramcfg_11_07_04)) 641 if ( next->bios.ramcfg_11_07_04)
642 data |= 0x10000000; 642 data |= 0x10000000;
643 if (!(next->bios.rammap_11_08_10)) 643 if (!next->bios.rammap_11_08_10)
644 data |= 0x00080000; 644 data |= 0x00080000;
645 } else { 645 } else {
646 data = 0xa40e0000; 646 data = 0xa40e0000;
@@ -689,8 +689,8 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
689 const u32 runk0 = ram->fN1 << 16; 689 const u32 runk0 = ram->fN1 << 16;
690 const u32 runk1 = ram->fN1; 690 const u32 runk1 = ram->fN1;
691 struct nouveau_ram_data *next = ram->base.next; 691 struct nouveau_ram_data *next = ram->base.next;
692 int vc = !(next->bios.ramcfg_11_02_08); 692 int vc = !next->bios.ramcfg_11_02_08;
693 int mv = !(next->bios.ramcfg_11_02_04); 693 int mv = !next->bios.ramcfg_11_02_04;
694 u32 mask, data; 694 u32 mask, data;
695 695
696 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000); 696 ram_mask(fuc, 0x10f808, 0x40000000, 0x40000000);
@@ -705,7 +705,7 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
705 } 705 }
706 706
707 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000); 707 ram_mask(fuc, 0x10f200, 0x00000800, 0x00000000);
708 if ((next->bios.ramcfg_11_03_f0)) 708 if (next->bios.ramcfg_11_03_f0)
709 ram_mask(fuc, 0x10f808, 0x04000000, 0x04000000); 709 ram_mask(fuc, 0x10f808, 0x04000000, 0x04000000);
710 710
711 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */ 711 ram_wr32(fuc, 0x10f314, 0x00000001); /* PRECHARGE */
@@ -761,7 +761,7 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
761 761
762 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010); 762 ram_mask(fuc, 0x1373f4, 0x00000000, 0x00010010);
763 data = ram_rd32(fuc, 0x1373ec) & ~0x00030000; 763 data = ram_rd32(fuc, 0x1373ec) & ~0x00030000;
764 data |= (next->bios.ramcfg_11_03_30) << 12; 764 data |= next->bios.ramcfg_11_03_30 << 16;
765 ram_wr32(fuc, 0x1373ec, data); 765 ram_wr32(fuc, 0x1373ec, data);
766 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000); 766 ram_mask(fuc, 0x1373f4, 0x00000003, 0x00000000);
767 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000); 767 ram_mask(fuc, 0x1373f4, 0x00000010, 0x00000000);
@@ -793,8 +793,8 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
793 } 793 }
794 } 794 }
795 795
796 if ( (next->bios.ramcfg_11_02_40) || 796 if (next->bios.ramcfg_11_02_40 ||
797 (next->bios.ramcfg_11_07_10)) { 797 next->bios.ramcfg_11_07_10) {
798 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000); 798 ram_mask(fuc, 0x132040, 0x00010000, 0x00010000);
799 ram_nsec(fuc, 20000); 799 ram_nsec(fuc, 20000);
800 } 800 }
@@ -810,13 +810,13 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
810 810
811 mask = 0x00010000; 811 mask = 0x00010000;
812 data = 0x00000000; 812 data = 0x00000000;
813 if (!(next->bios.ramcfg_11_02_80)) 813 if (!next->bios.ramcfg_11_02_80)
814 data |= 0x03000000; 814 data |= 0x03000000;
815 if (!(next->bios.ramcfg_11_02_40)) 815 if (!next->bios.ramcfg_11_02_40)
816 data |= 0x00002000; 816 data |= 0x00002000;
817 if (!(next->bios.ramcfg_11_07_10)) 817 if (!next->bios.ramcfg_11_07_10)
818 data |= 0x00004000; 818 data |= 0x00004000;
819 if (!(next->bios.ramcfg_11_07_08)) 819 if (!next->bios.ramcfg_11_07_08)
820 data |= 0x00000003; 820 data |= 0x00000003;
821 else 821 else
822 data |= 0x14000000; 822 data |= 0x14000000;
@@ -844,16 +844,16 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
844 844
845 mask = 0x33f00000; 845 mask = 0x33f00000;
846 data = 0x00000000; 846 data = 0x00000000;
847 if (!(next->bios.ramcfg_11_01_04)) 847 if (!next->bios.ramcfg_11_01_04)
848 data |= 0x20200000; 848 data |= 0x20200000;
849 if (!(next->bios.ramcfg_11_07_80)) 849 if (!next->bios.ramcfg_11_07_80)
850 data |= 0x12800000; 850 data |= 0x12800000;
851 /*XXX: see note above about there probably being some condition 851 /*XXX: see note above about there probably being some condition
852 * for the 10f824 stuff that uses ramcfg 3... 852 * for the 10f824 stuff that uses ramcfg 3...
853 */ 853 */
854 if ( (next->bios.ramcfg_11_03_f0)) { 854 if (next->bios.ramcfg_11_03_f0) {
855 if (next->bios.rammap_11_08_0c) { 855 if (next->bios.rammap_11_08_0c) {
856 if (!(next->bios.ramcfg_11_07_80)) 856 if (!next->bios.ramcfg_11_07_80)
857 mask |= 0x00000020; 857 mask |= 0x00000020;
858 else 858 else
859 data |= 0x00000020; 859 data |= 0x00000020;
@@ -876,7 +876,7 @@ nve0_ram_calc_sddr3(struct nouveau_fb *pfb, u32 freq)
876 data = next->bios.timing_20_2c_1fc0; 876 data = next->bios.timing_20_2c_1fc0;
877 ram_mask(fuc, 0x10f24c, 0x7f000000, data << 24); 877 ram_mask(fuc, 0x10f24c, 0x7f000000, data << 24);
878 878
879 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8); 879 ram_mask(fuc, 0x10f224, 0x001f0000, next->bios.timing_20_30_f8 << 16);
880 880
881 ram_wr32(fuc, 0x10f090, 0x4000007f); 881 ram_wr32(fuc, 0x10f090, 0x4000007f);
882 ram_nsec(fuc, 1000); 882 ram_nsec(fuc, 1000);
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/gf117.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/gf117.c
new file mode 100644
index 000000000000..fa891c39866b
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/gf117.c
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include "nv50.h"
26
27struct nouveau_oclass *
28gf117_i2c_oclass = &(struct nouveau_i2c_impl) {
29 .base.handle = NV_SUBDEV(I2C, 0xd7),
30 .base.ofuncs = &(struct nouveau_ofuncs) {
31 .ctor = _nouveau_i2c_ctor,
32 .dtor = _nouveau_i2c_dtor,
33 .init = _nouveau_i2c_init,
34 .fini = _nouveau_i2c_fini,
35 },
36 .sclass = nvd0_i2c_sclass,
37 .pad_x = &nv04_i2c_pad_oclass,
38 .pad_s = &nv04_i2c_pad_oclass,
39}.base;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/ibus/nve0.c b/drivers/gpu/drm/nouveau/core/subdev/ibus/nve0.c
index 7120124dceac..ebef970a0645 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/ibus/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/ibus/nve0.c
@@ -95,6 +95,23 @@ nve0_ibus_intr(struct nouveau_subdev *subdev)
95} 95}
96 96
97static int 97static int
98nve0_ibus_init(struct nouveau_object *object)
99{
100 struct nve0_ibus_priv *priv = (void *)object;
101 int ret = nouveau_ibus_init(&priv->base);
102 if (ret == 0) {
103 nv_mask(priv, 0x122318, 0x0003ffff, 0x00001000);
104 nv_mask(priv, 0x12231c, 0x0003ffff, 0x00000200);
105 nv_mask(priv, 0x122310, 0x0003ffff, 0x00000800);
106 nv_mask(priv, 0x122348, 0x0003ffff, 0x00000100);
107 nv_mask(priv, 0x1223b0, 0x0003ffff, 0x00000fff);
108 nv_mask(priv, 0x122348, 0x0003ffff, 0x00000200);
109 nv_mask(priv, 0x122358, 0x0003ffff, 0x00002880);
110 }
111 return ret;
112}
113
114static int
98nve0_ibus_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 115nve0_ibus_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
99 struct nouveau_oclass *oclass, void *data, u32 size, 116 struct nouveau_oclass *oclass, void *data, u32 size,
100 struct nouveau_object **pobject) 117 struct nouveau_object **pobject)
@@ -117,7 +134,7 @@ nve0_ibus_oclass = {
117 .ofuncs = &(struct nouveau_ofuncs) { 134 .ofuncs = &(struct nouveau_ofuncs) {
118 .ctor = nve0_ibus_ctor, 135 .ctor = nve0_ibus_ctor,
119 .dtor = _nouveau_ibus_dtor, 136 .dtor = _nouveau_ibus_dtor,
120 .init = _nouveau_ibus_init, 137 .init = nve0_ibus_init,
121 .fini = _nouveau_ibus_fini, 138 .fini = _nouveau_ibus_fini,
122 }, 139 },
123}; 140};
diff --git a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/host.fuc b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/host.fuc
index 2284ecb1c9b8..c2bb616a8da5 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/host.fuc
+++ b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/host.fuc
@@ -83,7 +83,7 @@ host_send:
83 // increment GET 83 // increment GET
84 add b32 $r1 0x1 84 add b32 $r1 0x1
85 and $r14 $r1 #fifo_qmaskf 85 and $r14 $r1 #fifo_qmaskf
86 nv_iowr(NV_PPWR_FIFO_GET(0), $r1) 86 nv_iowr(NV_PPWR_FIFO_GET(0), $r14)
87 bra #host_send 87 bra #host_send
88 host_send_done: 88 host_send_done:
89 ret 89 ret
diff --git a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nv108.fuc.h b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nv108.fuc.h
index 4bd43a99fdcc..39a5dc150a05 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nv108.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nv108.fuc.h
@@ -1018,7 +1018,7 @@ uint32_t nv108_pwr_code[] = {
1018 0xb600023f, 1018 0xb600023f,
1019 0x1ec40110, 1019 0x1ec40110,
1020 0x04b0400f, 1020 0x04b0400f,
1021 0xbd0001f6, 1021 0xbd000ef6,
1022 0xc70ef404, 1022 0xc70ef404,
1023/* 0x0328: host_send_done */ 1023/* 0x0328: host_send_done */
1024/* 0x032a: host_recv */ 1024/* 0x032a: host_recv */
diff --git a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nva3.fuc.h b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nva3.fuc.h
index 5a73fa620978..254205cd5166 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nva3.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nva3.fuc.h
@@ -1124,7 +1124,7 @@ uint32_t nva3_pwr_code[] = {
1124 0x0f1ec401, 1124 0x0f1ec401,
1125 0x04b007f1, 1125 0x04b007f1,
1126 0xd00604b6, 1126 0xd00604b6,
1127 0x04bd0001, 1127 0x04bd000e,
1128/* 0x03cb: host_send_done */ 1128/* 0x03cb: host_send_done */
1129 0xf8ba0ef4, 1129 0xf8ba0ef4,
1130/* 0x03cd: host_recv */ 1130/* 0x03cd: host_recv */
diff --git a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvc0.fuc.h b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvc0.fuc.h
index 4dba00d2dd1a..7ac87405d01b 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvc0.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvc0.fuc.h
@@ -1124,7 +1124,7 @@ uint32_t nvc0_pwr_code[] = {
1124 0x0f1ec401, 1124 0x0f1ec401,
1125 0x04b007f1, 1125 0x04b007f1,
1126 0xd00604b6, 1126 0xd00604b6,
1127 0x04bd0001, 1127 0x04bd000e,
1128/* 0x03cb: host_send_done */ 1128/* 0x03cb: host_send_done */
1129 0xf8ba0ef4, 1129 0xf8ba0ef4,
1130/* 0x03cd: host_recv */ 1130/* 0x03cd: host_recv */
diff --git a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvd0.fuc.h b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvd0.fuc.h
index 5e24c6bc041d..cd9ff1a73284 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvd0.fuc.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/pwr/fuc/nvd0.fuc.h
@@ -1033,7 +1033,7 @@ uint32_t nvd0_pwr_code[] = {
1033 0xb6026b21, 1033 0xb6026b21,
1034 0x1ec40110, 1034 0x1ec40110,
1035 0xb007f10f, 1035 0xb007f10f,
1036 0x0001d004, 1036 0x000ed004,
1037 0x0ef404bd, 1037 0x0ef404bd,
1038/* 0x0365: host_send_done */ 1038/* 0x0365: host_send_done */
1039/* 0x0367: host_recv */ 1039/* 0x0367: host_recv */
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 26b5647188ef..47ad74255bf1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -736,6 +736,9 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
736 fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y, 736 fb->bits_per_pixel, fb->pitches[0], crtc->x, crtc->y,
737 new_bo->bo.offset }; 737 new_bo->bo.offset };
738 738
739 /* Keep vblanks on during flip, for the target crtc of this flip */
740 drm_vblank_get(dev, nouveau_crtc(crtc)->index);
741
739 /* Emit a page flip */ 742 /* Emit a page flip */
740 if (nv_device(drm->device)->card_type >= NV_50) { 743 if (nv_device(drm->device)->card_type >= NV_50) {
741 ret = nv50_display_flip_next(crtc, fb, chan, swap_interval); 744 ret = nv50_display_flip_next(crtc, fb, chan, swap_interval);
@@ -779,6 +782,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
779 return 0; 782 return 0;
780 783
781fail_unreserve: 784fail_unreserve:
785 drm_vblank_put(dev, nouveau_crtc(crtc)->index);
782 ttm_bo_unreserve(&old_bo->bo); 786 ttm_bo_unreserve(&old_bo->bo);
783fail_unpin: 787fail_unpin:
784 mutex_unlock(&chan->cli->mutex); 788 mutex_unlock(&chan->cli->mutex);
@@ -817,6 +821,9 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
817 drm_send_vblank_event(dev, crtcid, s->event); 821 drm_send_vblank_event(dev, crtcid, s->event);
818 } 822 }
819 823
824 /* Give up ownership of vblank for page-flipped crtc */
825 drm_vblank_put(dev, s->crtc);
826
820 list_del(&s->head); 827 list_del(&s->head);
821 if (ps) 828 if (ps)
822 *ps = *s; 829 *ps = *s;
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 26c12a3fe430..a03c73411a56 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1052,7 +1052,7 @@ static void atombios_crtc_set_pll(struct drm_crtc *crtc, struct drm_display_mode
1052 int encoder_mode = atombios_get_encoder_mode(radeon_crtc->encoder); 1052 int encoder_mode = atombios_get_encoder_mode(radeon_crtc->encoder);
1053 1053
1054 /* pass the actual clock to atombios_crtc_program_pll for DCE5,6 for HDMI */ 1054 /* pass the actual clock to atombios_crtc_program_pll for DCE5,6 for HDMI */
1055 if (ASIC_IS_DCE5(rdev) && !ASIC_IS_DCE8(rdev) && 1055 if (ASIC_IS_DCE5(rdev) &&
1056 (encoder_mode == ATOM_ENCODER_MODE_HDMI) && 1056 (encoder_mode == ATOM_ENCODER_MODE_HDMI) &&
1057 (radeon_crtc->bpc > 8)) 1057 (radeon_crtc->bpc > 8))
1058 clock = radeon_crtc->adjusted_clock; 1058 clock = radeon_crtc->adjusted_clock;
@@ -1136,6 +1136,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1136 u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE); 1136 u32 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_NONE);
1137 u32 tmp, viewport_w, viewport_h; 1137 u32 tmp, viewport_w, viewport_h;
1138 int r; 1138 int r;
1139 bool bypass_lut = false;
1139 1140
1140 /* no fb bound */ 1141 /* no fb bound */
1141 if (!atomic && !crtc->primary->fb) { 1142 if (!atomic && !crtc->primary->fb) {
@@ -1174,33 +1175,73 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1174 radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); 1175 radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
1175 radeon_bo_unreserve(rbo); 1176 radeon_bo_unreserve(rbo);
1176 1177
1177 switch (target_fb->bits_per_pixel) { 1178 switch (target_fb->pixel_format) {
1178 case 8: 1179 case DRM_FORMAT_C8:
1179 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) | 1180 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_8BPP) |
1180 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED)); 1181 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_INDEXED));
1181 break; 1182 break;
1182 case 15: 1183 case DRM_FORMAT_XRGB4444:
1184 case DRM_FORMAT_ARGB4444:
1185 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
1186 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB4444));
1187#ifdef __BIG_ENDIAN
1188 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1189#endif
1190 break;
1191 case DRM_FORMAT_XRGB1555:
1192 case DRM_FORMAT_ARGB1555:
1183 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | 1193 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
1184 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB1555)); 1194 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB1555));
1195#ifdef __BIG_ENDIAN
1196 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1197#endif
1198 break;
1199 case DRM_FORMAT_BGRX5551:
1200 case DRM_FORMAT_BGRA5551:
1201 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
1202 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_BGRA5551));
1203#ifdef __BIG_ENDIAN
1204 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1205#endif
1185 break; 1206 break;
1186 case 16: 1207 case DRM_FORMAT_RGB565:
1187 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) | 1208 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_16BPP) |
1188 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565)); 1209 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB565));
1189#ifdef __BIG_ENDIAN 1210#ifdef __BIG_ENDIAN
1190 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16); 1211 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN16);
1191#endif 1212#endif
1192 break; 1213 break;
1193 case 24: 1214 case DRM_FORMAT_XRGB8888:
1194 case 32: 1215 case DRM_FORMAT_ARGB8888:
1195 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) | 1216 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) |
1196 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888)); 1217 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB8888));
1197#ifdef __BIG_ENDIAN 1218#ifdef __BIG_ENDIAN
1198 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32); 1219 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32);
1199#endif 1220#endif
1200 break; 1221 break;
1222 case DRM_FORMAT_XRGB2101010:
1223 case DRM_FORMAT_ARGB2101010:
1224 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) |
1225 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_ARGB2101010));
1226#ifdef __BIG_ENDIAN
1227 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32);
1228#endif
1229 /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */
1230 bypass_lut = true;
1231 break;
1232 case DRM_FORMAT_BGRX1010102:
1233 case DRM_FORMAT_BGRA1010102:
1234 fb_format = (EVERGREEN_GRPH_DEPTH(EVERGREEN_GRPH_DEPTH_32BPP) |
1235 EVERGREEN_GRPH_FORMAT(EVERGREEN_GRPH_FORMAT_BGRA1010102));
1236#ifdef __BIG_ENDIAN
1237 fb_swap = EVERGREEN_GRPH_ENDIAN_SWAP(EVERGREEN_GRPH_ENDIAN_8IN32);
1238#endif
1239 /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */
1240 bypass_lut = true;
1241 break;
1201 default: 1242 default:
1202 DRM_ERROR("Unsupported screen depth %d\n", 1243 DRM_ERROR("Unsupported screen format %s\n",
1203 target_fb->bits_per_pixel); 1244 drm_get_format_name(target_fb->pixel_format));
1204 return -EINVAL; 1245 return -EINVAL;
1205 } 1246 }
1206 1247
@@ -1329,6 +1370,18 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1329 WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format); 1370 WREG32(EVERGREEN_GRPH_CONTROL + radeon_crtc->crtc_offset, fb_format);
1330 WREG32(EVERGREEN_GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap); 1371 WREG32(EVERGREEN_GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
1331 1372
1373 /*
1374 * The LUT only has 256 slots for indexing by a 8 bpc fb. Bypass the LUT
1375 * for > 8 bpc scanout to avoid truncation of fb indices to 8 msb's, to
1376 * retain the full precision throughout the pipeline.
1377 */
1378 WREG32_P(EVERGREEN_GRPH_LUT_10BIT_BYPASS_CONTROL + radeon_crtc->crtc_offset,
1379 (bypass_lut ? EVERGREEN_LUT_10BIT_BYPASS_EN : 0),
1380 ~EVERGREEN_LUT_10BIT_BYPASS_EN);
1381
1382 if (bypass_lut)
1383 DRM_DEBUG_KMS("Bypassing hardware LUT due to 10 bit fb scanout.\n");
1384
1332 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); 1385 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
1333 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); 1386 WREG32(EVERGREEN_GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);
1334 WREG32(EVERGREEN_GRPH_X_START + radeon_crtc->crtc_offset, 0); 1387 WREG32(EVERGREEN_GRPH_X_START + radeon_crtc->crtc_offset, 0);
@@ -1396,6 +1449,7 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1396 u32 fb_swap = R600_D1GRPH_SWAP_ENDIAN_NONE; 1449 u32 fb_swap = R600_D1GRPH_SWAP_ENDIAN_NONE;
1397 u32 tmp, viewport_w, viewport_h; 1450 u32 tmp, viewport_w, viewport_h;
1398 int r; 1451 int r;
1452 bool bypass_lut = false;
1399 1453
1400 /* no fb bound */ 1454 /* no fb bound */
1401 if (!atomic && !crtc->primary->fb) { 1455 if (!atomic && !crtc->primary->fb) {
@@ -1433,18 +1487,30 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1433 radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL); 1487 radeon_bo_get_tiling_flags(rbo, &tiling_flags, NULL);
1434 radeon_bo_unreserve(rbo); 1488 radeon_bo_unreserve(rbo);
1435 1489
1436 switch (target_fb->bits_per_pixel) { 1490 switch (target_fb->pixel_format) {
1437 case 8: 1491 case DRM_FORMAT_C8:
1438 fb_format = 1492 fb_format =
1439 AVIVO_D1GRPH_CONTROL_DEPTH_8BPP | 1493 AVIVO_D1GRPH_CONTROL_DEPTH_8BPP |
1440 AVIVO_D1GRPH_CONTROL_8BPP_INDEXED; 1494 AVIVO_D1GRPH_CONTROL_8BPP_INDEXED;
1441 break; 1495 break;
1442 case 15: 1496 case DRM_FORMAT_XRGB4444:
1497 case DRM_FORMAT_ARGB4444:
1498 fb_format =
1499 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP |
1500 AVIVO_D1GRPH_CONTROL_16BPP_ARGB4444;
1501#ifdef __BIG_ENDIAN
1502 fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT;
1503#endif
1504 break;
1505 case DRM_FORMAT_XRGB1555:
1443 fb_format = 1506 fb_format =
1444 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP | 1507 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP |
1445 AVIVO_D1GRPH_CONTROL_16BPP_ARGB1555; 1508 AVIVO_D1GRPH_CONTROL_16BPP_ARGB1555;
1509#ifdef __BIG_ENDIAN
1510 fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT;
1511#endif
1446 break; 1512 break;
1447 case 16: 1513 case DRM_FORMAT_RGB565:
1448 fb_format = 1514 fb_format =
1449 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP | 1515 AVIVO_D1GRPH_CONTROL_DEPTH_16BPP |
1450 AVIVO_D1GRPH_CONTROL_16BPP_RGB565; 1516 AVIVO_D1GRPH_CONTROL_16BPP_RGB565;
@@ -1452,8 +1518,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1452 fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT; 1518 fb_swap = R600_D1GRPH_SWAP_ENDIAN_16BIT;
1453#endif 1519#endif
1454 break; 1520 break;
1455 case 24: 1521 case DRM_FORMAT_XRGB8888:
1456 case 32: 1522 case DRM_FORMAT_ARGB8888:
1457 fb_format = 1523 fb_format =
1458 AVIVO_D1GRPH_CONTROL_DEPTH_32BPP | 1524 AVIVO_D1GRPH_CONTROL_DEPTH_32BPP |
1459 AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888; 1525 AVIVO_D1GRPH_CONTROL_32BPP_ARGB8888;
@@ -1461,9 +1527,20 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1461 fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT; 1527 fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT;
1462#endif 1528#endif
1463 break; 1529 break;
1530 case DRM_FORMAT_XRGB2101010:
1531 case DRM_FORMAT_ARGB2101010:
1532 fb_format =
1533 AVIVO_D1GRPH_CONTROL_DEPTH_32BPP |
1534 AVIVO_D1GRPH_CONTROL_32BPP_ARGB2101010;
1535#ifdef __BIG_ENDIAN
1536 fb_swap = R600_D1GRPH_SWAP_ENDIAN_32BIT;
1537#endif
1538 /* Greater 8 bpc fb needs to bypass hw-lut to retain precision */
1539 bypass_lut = true;
1540 break;
1464 default: 1541 default:
1465 DRM_ERROR("Unsupported screen depth %d\n", 1542 DRM_ERROR("Unsupported screen format %s\n",
1466 target_fb->bits_per_pixel); 1543 drm_get_format_name(target_fb->pixel_format));
1467 return -EINVAL; 1544 return -EINVAL;
1468 } 1545 }
1469 1546
@@ -1502,6 +1579,13 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc,
1502 if (rdev->family >= CHIP_R600) 1579 if (rdev->family >= CHIP_R600)
1503 WREG32(R600_D1GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap); 1580 WREG32(R600_D1GRPH_SWAP_CONTROL + radeon_crtc->crtc_offset, fb_swap);
1504 1581
1582 /* LUT only has 256 slots for 8 bpc fb. Bypass for > 8 bpc scanout for precision */
1583 WREG32_P(AVIVO_D1GRPH_LUT_SEL + radeon_crtc->crtc_offset,
1584 (bypass_lut ? AVIVO_LUT_10BIT_BYPASS_EN : 0), ~AVIVO_LUT_10BIT_BYPASS_EN);
1585
1586 if (bypass_lut)
1587 DRM_DEBUG_KMS("Bypassing hardware LUT due to 10 bit fb scanout.\n");
1588
1505 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0); 1589 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_X + radeon_crtc->crtc_offset, 0);
1506 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0); 1590 WREG32(AVIVO_D1GRPH_SURFACE_OFFSET_Y + radeon_crtc->crtc_offset, 0);
1507 WREG32(AVIVO_D1GRPH_X_START + radeon_crtc->crtc_offset, 0); 1591 WREG32(AVIVO_D1GRPH_X_START + radeon_crtc->crtc_offset, 0);
diff --git a/drivers/gpu/drm/radeon/evergreen_reg.h b/drivers/gpu/drm/radeon/evergreen_reg.h
index a0f63ff5a5e9..333d143fca2c 100644
--- a/drivers/gpu/drm/radeon/evergreen_reg.h
+++ b/drivers/gpu/drm/radeon/evergreen_reg.h
@@ -116,6 +116,8 @@
116# define EVERGREEN_GRPH_ARRAY_LINEAR_ALIGNED 1 116# define EVERGREEN_GRPH_ARRAY_LINEAR_ALIGNED 1
117# define EVERGREEN_GRPH_ARRAY_1D_TILED_THIN1 2 117# define EVERGREEN_GRPH_ARRAY_1D_TILED_THIN1 2
118# define EVERGREEN_GRPH_ARRAY_2D_TILED_THIN1 4 118# define EVERGREEN_GRPH_ARRAY_2D_TILED_THIN1 4
119#define EVERGREEN_GRPH_LUT_10BIT_BYPASS_CONTROL 0x6808
120# define EVERGREEN_LUT_10BIT_BYPASS_EN (1 << 8)
119#define EVERGREEN_GRPH_SWAP_CONTROL 0x680c 121#define EVERGREEN_GRPH_SWAP_CONTROL 0x680c
120# define EVERGREEN_GRPH_ENDIAN_SWAP(x) (((x) & 0x3) << 0) 122# define EVERGREEN_GRPH_ENDIAN_SWAP(x) (((x) & 0x3) << 0)
121# define EVERGREEN_GRPH_ENDIAN_NONE 0 123# define EVERGREEN_GRPH_ENDIAN_NONE 0
diff --git a/drivers/gpu/drm/radeon/r500_reg.h b/drivers/gpu/drm/radeon/r500_reg.h
index 1dd0d32993d5..136b7bc7cd20 100644
--- a/drivers/gpu/drm/radeon/r500_reg.h
+++ b/drivers/gpu/drm/radeon/r500_reg.h
@@ -402,6 +402,7 @@
402 * block and vice versa. This applies to GRPH, CUR, etc. 402 * block and vice versa. This applies to GRPH, CUR, etc.
403 */ 403 */
404#define AVIVO_D1GRPH_LUT_SEL 0x6108 404#define AVIVO_D1GRPH_LUT_SEL 0x6108
405# define AVIVO_LUT_10BIT_BYPASS_EN (1 << 8)
405#define AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS 0x6110 406#define AVIVO_D1GRPH_PRIMARY_SURFACE_ADDRESS 0x6110
406#define R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x6914 407#define R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x6914
407#define R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x6114 408#define R700_D2GRPH_PRIMARY_SURFACE_ADDRESS_HIGH 0x6114
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 933c5c39654d..1b9177ed181f 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -1288,17 +1288,15 @@ static int radeon_dvi_mode_valid(struct drm_connector *connector,
1288 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) || 1288 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D) ||
1289 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B)) 1289 (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_B))
1290 return MODE_OK; 1290 return MODE_OK;
1291 else if (radeon_connector->connector_object_id == CONNECTOR_OBJECT_ID_HDMI_TYPE_A) { 1291 else if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
1292 if (ASIC_IS_DCE6(rdev)) { 1292 /* HDMI 1.3+ supports max clock of 340 Mhz */
1293 /* HDMI 1.3+ supports max clock of 340 Mhz */ 1293 if (mode->clock > 340000)
1294 if (mode->clock > 340000)
1295 return MODE_CLOCK_HIGH;
1296 else
1297 return MODE_OK;
1298 } else
1299 return MODE_CLOCK_HIGH; 1294 return MODE_CLOCK_HIGH;
1300 } else 1295 else
1296 return MODE_OK;
1297 } else {
1301 return MODE_CLOCK_HIGH; 1298 return MODE_CLOCK_HIGH;
1299 }
1302 } 1300 }
1303 1301
1304 /* check against the max pixel clock */ 1302 /* check against the max pixel clock */
@@ -1549,6 +1547,8 @@ out:
1549static int radeon_dp_mode_valid(struct drm_connector *connector, 1547static int radeon_dp_mode_valid(struct drm_connector *connector,
1550 struct drm_display_mode *mode) 1548 struct drm_display_mode *mode)
1551{ 1549{
1550 struct drm_device *dev = connector->dev;
1551 struct radeon_device *rdev = dev->dev_private;
1552 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 1552 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1553 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv; 1553 struct radeon_connector_atom_dig *radeon_dig_connector = radeon_connector->con_priv;
1554 1554
@@ -1579,14 +1579,23 @@ static int radeon_dp_mode_valid(struct drm_connector *connector,
1579 return MODE_PANEL; 1579 return MODE_PANEL;
1580 } 1580 }
1581 } 1581 }
1582 return MODE_OK;
1583 } else { 1582 } else {
1584 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 1583 if ((radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
1585 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) 1584 (radeon_dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) {
1586 return radeon_dp_mode_valid_helper(connector, mode); 1585 return radeon_dp_mode_valid_helper(connector, mode);
1587 else 1586 } else {
1588 return MODE_OK; 1587 if (ASIC_IS_DCE6(rdev) && drm_detect_hdmi_monitor(radeon_connector->edid)) {
1588 /* HDMI 1.3+ supports max clock of 340 Mhz */
1589 if (mode->clock > 340000)
1590 return MODE_CLOCK_HIGH;
1591 } else {
1592 if (mode->clock > 165000)
1593 return MODE_CLOCK_HIGH;
1594 }
1595 }
1589 } 1596 }
1597
1598 return MODE_OK;
1590} 1599}
1591 1600
1592static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = { 1601static const struct drm_connector_helper_funcs radeon_dp_connector_helper_funcs = {
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 5ed617056b9c..8fc362aa6a1a 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -66,7 +66,8 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
66 (radeon_crtc->lut_b[i] << 0)); 66 (radeon_crtc->lut_b[i] << 0));
67 } 67 }
68 68
69 WREG32(AVIVO_D1GRPH_LUT_SEL + radeon_crtc->crtc_offset, radeon_crtc->crtc_id); 69 /* Only change bit 0 of LUT_SEL, other bits are set elsewhere */
70 WREG32_P(AVIVO_D1GRPH_LUT_SEL + radeon_crtc->crtc_offset, radeon_crtc->crtc_id, ~1);
70} 71}
71 72
72static void dce4_crtc_load_lut(struct drm_crtc *crtc) 73static void dce4_crtc_load_lut(struct drm_crtc *crtc)
@@ -357,8 +358,9 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id)
357 358
358 spin_unlock_irqrestore(&rdev->ddev->event_lock, flags); 359 spin_unlock_irqrestore(&rdev->ddev->event_lock, flags);
359 360
361 drm_vblank_put(rdev->ddev, radeon_crtc->crtc_id);
360 radeon_fence_unref(&work->fence); 362 radeon_fence_unref(&work->fence);
361 radeon_irq_kms_pflip_irq_get(rdev, work->crtc_id); 363 radeon_irq_kms_pflip_irq_put(rdev, work->crtc_id);
362 queue_work(radeon_crtc->flip_queue, &work->unpin_work); 364 queue_work(radeon_crtc->flip_queue, &work->unpin_work);
363} 365}
364 366
@@ -459,6 +461,12 @@ static void radeon_flip_work_func(struct work_struct *__work)
459 base &= ~7; 461 base &= ~7;
460 } 462 }
461 463
464 r = drm_vblank_get(crtc->dev, radeon_crtc->crtc_id);
465 if (r) {
466 DRM_ERROR("failed to get vblank before flip\n");
467 goto pflip_cleanup;
468 }
469
462 /* We borrow the event spin lock for protecting flip_work */ 470 /* We borrow the event spin lock for protecting flip_work */
463 spin_lock_irqsave(&crtc->dev->event_lock, flags); 471 spin_lock_irqsave(&crtc->dev->event_lock, flags);
464 472
@@ -473,6 +481,16 @@ static void radeon_flip_work_func(struct work_struct *__work)
473 481
474 return; 482 return;
475 483
484pflip_cleanup:
485 if (unlikely(radeon_bo_reserve(work->new_rbo, false) != 0)) {
486 DRM_ERROR("failed to reserve new rbo in error path\n");
487 goto cleanup;
488 }
489 if (unlikely(radeon_bo_unpin(work->new_rbo) != 0)) {
490 DRM_ERROR("failed to unpin new rbo in error path\n");
491 }
492 radeon_bo_unreserve(work->new_rbo);
493
476cleanup: 494cleanup:
477 drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base); 495 drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
478 radeon_fence_unref(&work->fence); 496 radeon_fence_unref(&work->fence);
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 620d1004a1e7..9f7d5859cf65 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -676,6 +676,16 @@ config I2C_RIIC
676 This driver can also be built as a module. If so, the module 676 This driver can also be built as a module. If so, the module
677 will be called i2c-riic. 677 will be called i2c-riic.
678 678
679config I2C_RK3X
680 tristate "Rockchip RK3xxx I2C adapter"
681 depends on OF
682 help
683 Say Y here to include support for the I2C adapter in Rockchip RK3xxx
684 SoCs.
685
686 This driver can also be built as a module. If so, the module will
687 be called i2c-rk3x.
688
679config HAVE_S3C2410_I2C 689config HAVE_S3C2410_I2C
680 bool 690 bool
681 help 691 help
@@ -764,6 +774,19 @@ config I2C_STU300
764 This driver can also be built as a module. If so, the module 774 This driver can also be built as a module. If so, the module
765 will be called i2c-stu300. 775 will be called i2c-stu300.
766 776
777config I2C_SUN6I_P2WI
778 tristate "Allwinner sun6i internal P2WI controller"
779 depends on RESET_CONTROLLER
780 depends on MACH_SUN6I || COMPILE_TEST
781 help
782 If you say yes to this option, support will be included for the
783 P2WI (Push/Pull 2 Wire Interface) controller embedded in some sunxi
784 SOCs.
785 The P2WI looks like an SMBus controller (which supports only byte
786 accesses), except that it only supports one slave device.
787 This interface is used to connect to specific PMIC devices (like the
788 AXP221).
789
767config I2C_TEGRA 790config I2C_TEGRA
768 tristate "NVIDIA Tegra internal I2C controller" 791 tristate "NVIDIA Tegra internal I2C controller"
769 depends on ARCH_TEGRA 792 depends on ARCH_TEGRA
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 298692cc6000..dd9a7f8e873f 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
66obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o 66obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o
67obj-$(CONFIG_I2C_QUP) += i2c-qup.o 67obj-$(CONFIG_I2C_QUP) += i2c-qup.o
68obj-$(CONFIG_I2C_RIIC) += i2c-riic.o 68obj-$(CONFIG_I2C_RIIC) += i2c-riic.o
69obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o
69obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o 70obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
70obj-$(CONFIG_I2C_S6000) += i2c-s6000.o 71obj-$(CONFIG_I2C_S6000) += i2c-s6000.o
71obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o 72obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
@@ -74,6 +75,7 @@ obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
74obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o 75obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o
75obj-$(CONFIG_I2C_ST) += i2c-st.o 76obj-$(CONFIG_I2C_ST) += i2c-st.o
76obj-$(CONFIG_I2C_STU300) += i2c-stu300.o 77obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
78obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
77obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o 79obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o
78obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o 80obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
79obj-$(CONFIG_I2C_WMT) += i2c-wmt.o 81obj-$(CONFIG_I2C_WMT) += i2c-wmt.o
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
new file mode 100644
index 000000000000..a9791509966a
--- /dev/null
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -0,0 +1,763 @@
1/*
2 * Driver for I2C adapter in Rockchip RK3xxx SoC
3 *
4 * Max Schwarz <max.schwarz@online.de>
5 * based on the patches by Rockchip Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/i2c.h>
15#include <linux/interrupt.h>
16#include <linux/errno.h>
17#include <linux/err.h>
18#include <linux/platform_device.h>
19#include <linux/io.h>
20#include <linux/of_address.h>
21#include <linux/of_irq.h>
22#include <linux/spinlock.h>
23#include <linux/clk.h>
24#include <linux/wait.h>
25#include <linux/mfd/syscon.h>
26#include <linux/regmap.h>
27
28
29/* Register Map */
30#define REG_CON 0x00 /* control register */
31#define REG_CLKDIV 0x04 /* clock divisor register */
32#define REG_MRXADDR 0x08 /* slave address for REGISTER_TX */
33#define REG_MRXRADDR 0x0c /* slave register address for REGISTER_TX */
34#define REG_MTXCNT 0x10 /* number of bytes to be transmitted */
35#define REG_MRXCNT 0x14 /* number of bytes to be received */
36#define REG_IEN 0x18 /* interrupt enable */
37#define REG_IPD 0x1c /* interrupt pending */
38#define REG_FCNT 0x20 /* finished count */
39
40/* Data buffer offsets */
41#define TXBUFFER_BASE 0x100
42#define RXBUFFER_BASE 0x200
43
44/* REG_CON bits */
45#define REG_CON_EN BIT(0)
46enum {
47 REG_CON_MOD_TX = 0, /* transmit data */
48 REG_CON_MOD_REGISTER_TX, /* select register and restart */
49 REG_CON_MOD_RX, /* receive data */
50 REG_CON_MOD_REGISTER_RX, /* broken: transmits read addr AND writes
51 * register addr */
52};
53#define REG_CON_MOD(mod) ((mod) << 1)
54#define REG_CON_MOD_MASK (BIT(1) | BIT(2))
55#define REG_CON_START BIT(3)
56#define REG_CON_STOP BIT(4)
57#define REG_CON_LASTACK BIT(5) /* 1: send NACK after last received byte */
58#define REG_CON_ACTACK BIT(6) /* 1: stop if NACK is received */
59
60/* REG_MRXADDR bits */
61#define REG_MRXADDR_VALID(x) BIT(24 + (x)) /* [x*8+7:x*8] of MRX[R]ADDR valid */
62
63/* REG_IEN/REG_IPD bits */
64#define REG_INT_BTF BIT(0) /* a byte was transmitted */
65#define REG_INT_BRF BIT(1) /* a byte was received */
66#define REG_INT_MBTF BIT(2) /* master data transmit finished */
67#define REG_INT_MBRF BIT(3) /* master data receive finished */
68#define REG_INT_START BIT(4) /* START condition generated */
69#define REG_INT_STOP BIT(5) /* STOP condition generated */
70#define REG_INT_NAKRCV BIT(6) /* NACK received */
71#define REG_INT_ALL 0x7f
72
73/* Constants */
74#define WAIT_TIMEOUT 200 /* ms */
75#define DEFAULT_SCL_RATE (100 * 1000) /* Hz */
76
77enum rk3x_i2c_state {
78 STATE_IDLE,
79 STATE_START,
80 STATE_READ,
81 STATE_WRITE,
82 STATE_STOP
83};
84
85/**
86 * @grf_offset: offset inside the grf regmap for setting the i2c type
87 */
88struct rk3x_i2c_soc_data {
89 int grf_offset;
90};
91
92struct rk3x_i2c {
93 struct i2c_adapter adap;
94 struct device *dev;
95 struct rk3x_i2c_soc_data *soc_data;
96
97 /* Hardware resources */
98 void __iomem *regs;
99 struct clk *clk;
100
101 /* Settings */
102 unsigned int scl_frequency;
103
104 /* Synchronization & notification */
105 spinlock_t lock;
106 wait_queue_head_t wait;
107 bool busy;
108
109 /* Current message */
110 struct i2c_msg *msg;
111 u8 addr;
112 unsigned int mode;
113 bool is_last_msg;
114
115 /* I2C state machine */
116 enum rk3x_i2c_state state;
117 unsigned int processed; /* sent/received bytes */
118 int error;
119};
120
121static inline void i2c_writel(struct rk3x_i2c *i2c, u32 value,
122 unsigned int offset)
123{
124 writel(value, i2c->regs + offset);
125}
126
127static inline u32 i2c_readl(struct rk3x_i2c *i2c, unsigned int offset)
128{
129 return readl(i2c->regs + offset);
130}
131
132/* Reset all interrupt pending bits */
133static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c)
134{
135 i2c_writel(i2c, REG_INT_ALL, REG_IPD);
136}
137
138/**
139 * Generate a START condition, which triggers a REG_INT_START interrupt.
140 */
141static void rk3x_i2c_start(struct rk3x_i2c *i2c)
142{
143 u32 val;
144
145 rk3x_i2c_clean_ipd(i2c);
146 i2c_writel(i2c, REG_INT_START, REG_IEN);
147
148 /* enable adapter with correct mode, send START condition */
149 val = REG_CON_EN | REG_CON_MOD(i2c->mode) | REG_CON_START;
150
151 /* if we want to react to NACK, set ACTACK bit */
152 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK))
153 val |= REG_CON_ACTACK;
154
155 i2c_writel(i2c, val, REG_CON);
156}
157
158/**
159 * Generate a STOP condition, which triggers a REG_INT_STOP interrupt.
160 *
161 * @error: Error code to return in rk3x_i2c_xfer
162 */
163static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error)
164{
165 unsigned int ctrl;
166
167 i2c->processed = 0;
168 i2c->msg = NULL;
169 i2c->error = error;
170
171 if (i2c->is_last_msg) {
172 /* Enable stop interrupt */
173 i2c_writel(i2c, REG_INT_STOP, REG_IEN);
174
175 i2c->state = STATE_STOP;
176
177 ctrl = i2c_readl(i2c, REG_CON);
178 ctrl |= REG_CON_STOP;
179 i2c_writel(i2c, ctrl, REG_CON);
180 } else {
181 /* Signal rk3x_i2c_xfer to start the next message. */
182 i2c->busy = false;
183 i2c->state = STATE_IDLE;
184
185 /*
186 * The HW is actually not capable of REPEATED START. But we can
187 * get the intended effect by resetting its internal state
188 * and issuing an ordinary START.
189 */
190 i2c_writel(i2c, 0, REG_CON);
191
192 /* signal that we are finished with the current msg */
193 wake_up(&i2c->wait);
194 }
195}
196
197/**
198 * Setup a read according to i2c->msg
199 */
200static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c)
201{
202 unsigned int len = i2c->msg->len - i2c->processed;
203 u32 con;
204
205 con = i2c_readl(i2c, REG_CON);
206
207 /*
208 * The hw can read up to 32 bytes at a time. If we need more than one
209 * chunk, send an ACK after the last byte of the current chunk.
210 */
211 if (unlikely(len > 32)) {
212 len = 32;
213 con &= ~REG_CON_LASTACK;
214 } else {
215 con |= REG_CON_LASTACK;
216 }
217
218 /* make sure we are in plain RX mode if we read a second chunk */
219 if (i2c->processed != 0) {
220 con &= ~REG_CON_MOD_MASK;
221 con |= REG_CON_MOD(REG_CON_MOD_RX);
222 }
223
224 i2c_writel(i2c, con, REG_CON);
225 i2c_writel(i2c, len, REG_MRXCNT);
226}
227
228/**
229 * Fill the transmit buffer with data from i2c->msg
230 */
231static void rk3x_i2c_fill_transmit_buf(struct rk3x_i2c *i2c)
232{
233 unsigned int i, j;
234 u32 cnt = 0;
235 u32 val;
236 u8 byte;
237
238 for (i = 0; i < 8; ++i) {
239 val = 0;
240 for (j = 0; j < 4; ++j) {
241 if (i2c->processed == i2c->msg->len)
242 break;
243
244 if (i2c->processed == 0 && cnt == 0)
245 byte = (i2c->addr & 0x7f) << 1;
246 else
247 byte = i2c->msg->buf[i2c->processed++];
248
249 val |= byte << (j * 8);
250 cnt++;
251 }
252
253 i2c_writel(i2c, val, TXBUFFER_BASE + 4 * i);
254
255 if (i2c->processed == i2c->msg->len)
256 break;
257 }
258
259 i2c_writel(i2c, cnt, REG_MTXCNT);
260}
261
262
263/* IRQ handlers for individual states */
264
265static void rk3x_i2c_handle_start(struct rk3x_i2c *i2c, unsigned int ipd)
266{
267 if (!(ipd & REG_INT_START)) {
268 rk3x_i2c_stop(i2c, -EIO);
269 dev_warn(i2c->dev, "unexpected irq in START: 0x%x\n", ipd);
270 rk3x_i2c_clean_ipd(i2c);
271 return;
272 }
273
274 /* ack interrupt */
275 i2c_writel(i2c, REG_INT_START, REG_IPD);
276
277 /* disable start bit */
278 i2c_writel(i2c, i2c_readl(i2c, REG_CON) & ~REG_CON_START, REG_CON);
279
280 /* enable appropriate interrupts and transition */
281 if (i2c->mode == REG_CON_MOD_TX) {
282 i2c_writel(i2c, REG_INT_MBTF | REG_INT_NAKRCV, REG_IEN);
283 i2c->state = STATE_WRITE;
284 rk3x_i2c_fill_transmit_buf(i2c);
285 } else {
286 /* in any other case, we are going to be reading. */
287 i2c_writel(i2c, REG_INT_MBRF | REG_INT_NAKRCV, REG_IEN);
288 i2c->state = STATE_READ;
289 rk3x_i2c_prepare_read(i2c);
290 }
291}
292
293static void rk3x_i2c_handle_write(struct rk3x_i2c *i2c, unsigned int ipd)
294{
295 if (!(ipd & REG_INT_MBTF)) {
296 rk3x_i2c_stop(i2c, -EIO);
297 dev_err(i2c->dev, "unexpected irq in WRITE: 0x%x\n", ipd);
298 rk3x_i2c_clean_ipd(i2c);
299 return;
300 }
301
302 /* ack interrupt */
303 i2c_writel(i2c, REG_INT_MBTF, REG_IPD);
304
305 /* are we finished? */
306 if (i2c->processed == i2c->msg->len)
307 rk3x_i2c_stop(i2c, i2c->error);
308 else
309 rk3x_i2c_fill_transmit_buf(i2c);
310}
311
312static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd)
313{
314 unsigned int i;
315 unsigned int len = i2c->msg->len - i2c->processed;
316 u32 uninitialized_var(val);
317 u8 byte;
318
319 /* we only care for MBRF here. */
320 if (!(ipd & REG_INT_MBRF))
321 return;
322
323 /* ack interrupt */
324 i2c_writel(i2c, REG_INT_MBRF, REG_IPD);
325
326 /* read the data from receive buffer */
327 for (i = 0; i < len; ++i) {
328 if (i % 4 == 0)
329 val = i2c_readl(i2c, RXBUFFER_BASE + (i / 4) * 4);
330
331 byte = (val >> ((i % 4) * 8)) & 0xff;
332 i2c->msg->buf[i2c->processed++] = byte;
333 }
334
335 /* are we finished? */
336 if (i2c->processed == i2c->msg->len)
337 rk3x_i2c_stop(i2c, i2c->error);
338 else
339 rk3x_i2c_prepare_read(i2c);
340}
341
342static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd)
343{
344 unsigned int con;
345
346 if (!(ipd & REG_INT_STOP)) {
347 rk3x_i2c_stop(i2c, -EIO);
348 dev_err(i2c->dev, "unexpected irq in STOP: 0x%x\n", ipd);
349 rk3x_i2c_clean_ipd(i2c);
350 return;
351 }
352
353 /* ack interrupt */
354 i2c_writel(i2c, REG_INT_STOP, REG_IPD);
355
356 /* disable STOP bit */
357 con = i2c_readl(i2c, REG_CON);
358 con &= ~REG_CON_STOP;
359 i2c_writel(i2c, con, REG_CON);
360
361 i2c->busy = false;
362 i2c->state = STATE_IDLE;
363
364 /* signal rk3x_i2c_xfer that we are finished */
365 wake_up(&i2c->wait);
366}
367
368static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id)
369{
370 struct rk3x_i2c *i2c = dev_id;
371 unsigned int ipd;
372
373 spin_lock(&i2c->lock);
374
375 ipd = i2c_readl(i2c, REG_IPD);
376 if (i2c->state == STATE_IDLE) {
377 dev_warn(i2c->dev, "irq in STATE_IDLE, ipd = 0x%x\n", ipd);
378 rk3x_i2c_clean_ipd(i2c);
379 goto out;
380 }
381
382 dev_dbg(i2c->dev, "IRQ: state %d, ipd: %x\n", i2c->state, ipd);
383
384 /* Clean interrupt bits we don't care about */
385 ipd &= ~(REG_INT_BRF | REG_INT_BTF);
386
387 if (ipd & REG_INT_NAKRCV) {
388 /*
389 * We got a NACK in the last operation. Depending on whether
390 * IGNORE_NAK is set, we have to stop the operation and report
391 * an error.
392 */
393 i2c_writel(i2c, REG_INT_NAKRCV, REG_IPD);
394
395 ipd &= ~REG_INT_NAKRCV;
396
397 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK))
398 rk3x_i2c_stop(i2c, -ENXIO);
399 }
400
401 /* is there anything left to handle? */
402 if (unlikely(ipd == 0))
403 goto out;
404
405 switch (i2c->state) {
406 case STATE_START:
407 rk3x_i2c_handle_start(i2c, ipd);
408 break;
409 case STATE_WRITE:
410 rk3x_i2c_handle_write(i2c, ipd);
411 break;
412 case STATE_READ:
413 rk3x_i2c_handle_read(i2c, ipd);
414 break;
415 case STATE_STOP:
416 rk3x_i2c_handle_stop(i2c, ipd);
417 break;
418 case STATE_IDLE:
419 break;
420 }
421
422out:
423 spin_unlock(&i2c->lock);
424 return IRQ_HANDLED;
425}
426
427static void rk3x_i2c_set_scl_rate(struct rk3x_i2c *i2c, unsigned long scl_rate)
428{
429 unsigned long i2c_rate = clk_get_rate(i2c->clk);
430 unsigned int div;
431
432 /* SCL rate = (clk rate) / (8 * DIV) */
433 div = DIV_ROUND_UP(i2c_rate, scl_rate * 8);
434
435 /* The lower and upper half of the CLKDIV reg describe the length of
436 * SCL low & high periods. */
437 div = DIV_ROUND_UP(div, 2);
438
439 i2c_writel(i2c, (div << 16) | (div & 0xffff), REG_CLKDIV);
440}
441
442/**
443 * Setup I2C registers for an I2C operation specified by msgs, num.
444 *
445 * Must be called with i2c->lock held.
446 *
447 * @msgs: I2C msgs to process
448 * @num: Number of msgs
449 *
450 * returns: Number of I2C msgs processed or negative in case of error
451 */
452static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num)
453{
454 u32 addr = (msgs[0].addr & 0x7f) << 1;
455 int ret = 0;
456
457 /*
458 * The I2C adapter can issue a small (len < 4) write packet before
459 * reading. This speeds up SMBus-style register reads.
460 * The MRXADDR/MRXRADDR hold the slave address and the slave register
461 * address in this case.
462 */
463
464 if (num >= 2 && msgs[0].len < 4 &&
465 !(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD)) {
466 u32 reg_addr = 0;
467 int i;
468
469 dev_dbg(i2c->dev, "Combined write/read from addr 0x%x\n",
470 addr >> 1);
471
472 /* Fill MRXRADDR with the register address(es) */
473 for (i = 0; i < msgs[0].len; ++i) {
474 reg_addr |= msgs[0].buf[i] << (i * 8);
475 reg_addr |= REG_MRXADDR_VALID(i);
476 }
477
478 /* msgs[0] is handled by hw. */
479 i2c->msg = &msgs[1];
480
481 i2c->mode = REG_CON_MOD_REGISTER_TX;
482
483 i2c_writel(i2c, addr | REG_MRXADDR_VALID(0), REG_MRXADDR);
484 i2c_writel(i2c, reg_addr, REG_MRXRADDR);
485
486 ret = 2;
487 } else {
488 /*
489 * We'll have to do it the boring way and process the msgs
490 * one-by-one.
491 */
492
493 if (msgs[0].flags & I2C_M_RD) {
494 addr |= 1; /* set read bit */
495
496 /*
497 * We have to transmit the slave addr first. Use
498 * MOD_REGISTER_TX for that purpose.
499 */
500 i2c->mode = REG_CON_MOD_REGISTER_TX;
501 i2c_writel(i2c, addr | REG_MRXADDR_VALID(0),
502 REG_MRXADDR);
503 i2c_writel(i2c, 0, REG_MRXRADDR);
504 } else {
505 i2c->mode = REG_CON_MOD_TX;
506 }
507
508 i2c->msg = &msgs[0];
509
510 ret = 1;
511 }
512
513 i2c->addr = msgs[0].addr;
514 i2c->busy = true;
515 i2c->state = STATE_START;
516 i2c->processed = 0;
517 i2c->error = 0;
518
519 rk3x_i2c_clean_ipd(i2c);
520
521 return ret;
522}
523
524static int rk3x_i2c_xfer(struct i2c_adapter *adap,
525 struct i2c_msg *msgs, int num)
526{
527 struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data;
528 unsigned long timeout, flags;
529 int ret = 0;
530 int i;
531
532 spin_lock_irqsave(&i2c->lock, flags);
533
534 clk_enable(i2c->clk);
535
536 /* The clock rate might have changed, so setup the divider again */
537 rk3x_i2c_set_scl_rate(i2c, i2c->scl_frequency);
538
539 i2c->is_last_msg = false;
540
541 /*
542 * Process msgs. We can handle more than one message at once (see
543 * rk3x_i2c_setup()).
544 */
545 for (i = 0; i < num; i += ret) {
546 ret = rk3x_i2c_setup(i2c, msgs + i, num - i);
547
548 if (ret < 0) {
549 dev_err(i2c->dev, "rk3x_i2c_setup() failed\n");
550 break;
551 }
552
553 if (i + ret >= num)
554 i2c->is_last_msg = true;
555
556 spin_unlock_irqrestore(&i2c->lock, flags);
557
558 rk3x_i2c_start(i2c);
559
560 timeout = wait_event_timeout(i2c->wait, !i2c->busy,
561 msecs_to_jiffies(WAIT_TIMEOUT));
562
563 spin_lock_irqsave(&i2c->lock, flags);
564
565 if (timeout == 0) {
566 dev_err(i2c->dev, "timeout, ipd: 0x%02x, state: %d\n",
567 i2c_readl(i2c, REG_IPD), i2c->state);
568
569 /* Force a STOP condition without interrupt */
570 i2c_writel(i2c, 0, REG_IEN);
571 i2c_writel(i2c, REG_CON_EN | REG_CON_STOP, REG_CON);
572
573 i2c->state = STATE_IDLE;
574
575 ret = -ETIMEDOUT;
576 break;
577 }
578
579 if (i2c->error) {
580 ret = i2c->error;
581 break;
582 }
583 }
584
585 clk_disable(i2c->clk);
586 spin_unlock_irqrestore(&i2c->lock, flags);
587
588 return ret;
589}
590
591static u32 rk3x_i2c_func(struct i2c_adapter *adap)
592{
593 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
594}
595
596static const struct i2c_algorithm rk3x_i2c_algorithm = {
597 .master_xfer = rk3x_i2c_xfer,
598 .functionality = rk3x_i2c_func,
599};
600
601static struct rk3x_i2c_soc_data soc_data[3] = {
602 { .grf_offset = 0x154 }, /* rk3066 */
603 { .grf_offset = 0x0a4 }, /* rk3188 */
604 { .grf_offset = -1 }, /* no I2C switching needed */
605};
606
607static const struct of_device_id rk3x_i2c_match[] = {
608 { .compatible = "rockchip,rk3066-i2c", .data = (void *)&soc_data[0] },
609 { .compatible = "rockchip,rk3188-i2c", .data = (void *)&soc_data[1] },
610 { .compatible = "rockchip,rk3288-i2c", .data = (void *)&soc_data[2] },
611 {},
612};
613
614static int rk3x_i2c_probe(struct platform_device *pdev)
615{
616 struct device_node *np = pdev->dev.of_node;
617 const struct of_device_id *match;
618 struct rk3x_i2c *i2c;
619 struct resource *mem;
620 int ret = 0;
621 int bus_nr;
622 u32 value;
623 int irq;
624
625 i2c = devm_kzalloc(&pdev->dev, sizeof(struct rk3x_i2c), GFP_KERNEL);
626 if (!i2c)
627 return -ENOMEM;
628
629 match = of_match_node(rk3x_i2c_match, np);
630 i2c->soc_data = (struct rk3x_i2c_soc_data *)match->data;
631
632 if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
633 &i2c->scl_frequency)) {
634 dev_info(&pdev->dev, "using default SCL frequency: %d\n",
635 DEFAULT_SCL_RATE);
636 i2c->scl_frequency = DEFAULT_SCL_RATE;
637 }
638
639 if (i2c->scl_frequency == 0 || i2c->scl_frequency > 400 * 1000) {
640 dev_warn(&pdev->dev, "invalid SCL frequency specified.\n");
641 dev_warn(&pdev->dev, "using default SCL frequency: %d\n",
642 DEFAULT_SCL_RATE);
643 i2c->scl_frequency = DEFAULT_SCL_RATE;
644 }
645
646 strlcpy(i2c->adap.name, "rk3x-i2c", sizeof(i2c->adap.name));
647 i2c->adap.owner = THIS_MODULE;
648 i2c->adap.algo = &rk3x_i2c_algorithm;
649 i2c->adap.retries = 3;
650 i2c->adap.dev.of_node = np;
651 i2c->adap.algo_data = i2c;
652 i2c->adap.dev.parent = &pdev->dev;
653
654 i2c->dev = &pdev->dev;
655
656 spin_lock_init(&i2c->lock);
657 init_waitqueue_head(&i2c->wait);
658
659 i2c->clk = devm_clk_get(&pdev->dev, NULL);
660 if (IS_ERR(i2c->clk)) {
661 dev_err(&pdev->dev, "cannot get clock\n");
662 return PTR_ERR(i2c->clk);
663 }
664
665 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
666 i2c->regs = devm_ioremap_resource(&pdev->dev, mem);
667 if (IS_ERR(i2c->regs))
668 return PTR_ERR(i2c->regs);
669
670 /* Try to set the I2C adapter number from dt */
671 bus_nr = of_alias_get_id(np, "i2c");
672
673 /*
674 * Switch to new interface if the SoC also offers the old one.
675 * The control bit is located in the GRF register space.
676 */
677 if (i2c->soc_data->grf_offset >= 0) {
678 struct regmap *grf;
679
680 grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
681 if (IS_ERR(grf)) {
682 dev_err(&pdev->dev,
683 "rk3x-i2c needs 'rockchip,grf' property\n");
684 return PTR_ERR(grf);
685 }
686
687 if (bus_nr < 0) {
688 dev_err(&pdev->dev, "rk3x-i2c needs i2cX alias");
689 return -EINVAL;
690 }
691
692 /* 27+i: write mask, 11+i: value */
693 value = BIT(27 + bus_nr) | BIT(11 + bus_nr);
694
695 ret = regmap_write(grf, i2c->soc_data->grf_offset, value);
696 if (ret != 0) {
697 dev_err(i2c->dev, "Could not write to GRF: %d\n", ret);
698 return ret;
699 }
700 }
701
702 /* IRQ setup */
703 irq = platform_get_irq(pdev, 0);
704 if (irq < 0) {
705 dev_err(&pdev->dev, "cannot find rk3x IRQ\n");
706 return irq;
707 }
708
709 ret = devm_request_irq(&pdev->dev, irq, rk3x_i2c_irq,
710 0, dev_name(&pdev->dev), i2c);
711 if (ret < 0) {
712 dev_err(&pdev->dev, "cannot request IRQ\n");
713 return ret;
714 }
715
716 platform_set_drvdata(pdev, i2c);
717
718 ret = clk_prepare(i2c->clk);
719 if (ret < 0) {
720 dev_err(&pdev->dev, "Could not prepare clock\n");
721 return ret;
722 }
723
724 ret = i2c_add_adapter(&i2c->adap);
725 if (ret < 0) {
726 dev_err(&pdev->dev, "Could not register adapter\n");
727 goto err_clk;
728 }
729
730 dev_info(&pdev->dev, "Initialized RK3xxx I2C bus at %p\n", i2c->regs);
731
732 return 0;
733
734err_clk:
735 clk_unprepare(i2c->clk);
736 return ret;
737}
738
739static int rk3x_i2c_remove(struct platform_device *pdev)
740{
741 struct rk3x_i2c *i2c = platform_get_drvdata(pdev);
742
743 i2c_del_adapter(&i2c->adap);
744 clk_unprepare(i2c->clk);
745
746 return 0;
747}
748
749static struct platform_driver rk3x_i2c_driver = {
750 .probe = rk3x_i2c_probe,
751 .remove = rk3x_i2c_remove,
752 .driver = {
753 .owner = THIS_MODULE,
754 .name = "rk3x-i2c",
755 .of_match_table = rk3x_i2c_match,
756 },
757};
758
759module_platform_driver(rk3x_i2c_driver);
760
761MODULE_DESCRIPTION("Rockchip RK3xxx I2C Bus driver");
762MODULE_AUTHOR("Max Schwarz <max.schwarz@online.de>");
763MODULE_LICENSE("GPL v2");
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
new file mode 100644
index 000000000000..09de4fd12d57
--- /dev/null
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -0,0 +1,345 @@
1/*
2 * P2WI (Push-Pull Two Wire Interface) bus driver.
3 *
4 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 *
10 * The P2WI controller looks like an SMBus controller which only supports byte
11 * data transfers. But, it differs from standard SMBus protocol on several
12 * aspects:
13 * - it supports only one slave device, and thus drop the address field
14 * - it adds a parity bit every 8bits of data
15 * - only one read access is required to read a byte (instead of a write
16 * followed by a read access in standard SMBus protocol)
17 * - there's no Ack bit after each byte transfer
18 *
19 * This means this bus cannot be used to interface with standard SMBus
20 * devices (the only known device to support this interface is the AXP221
21 * PMIC).
22 *
23 */
24#include <linux/clk.h>
25#include <linux/module.h>
26#include <linux/i2c.h>
27#include <linux/io.h>
28#include <linux/interrupt.h>
29#include <linux/module.h>
30#include <linux/of.h>
31#include <linux/platform_device.h>
32#include <linux/reset.h>
33
34
35/* P2WI registers */
36#define P2WI_CTRL 0x0
37#define P2WI_CCR 0x4
38#define P2WI_INTE 0x8
39#define P2WI_INTS 0xc
40#define P2WI_DADDR0 0x10
41#define P2WI_DADDR1 0x14
42#define P2WI_DLEN 0x18
43#define P2WI_DATA0 0x1c
44#define P2WI_DATA1 0x20
45#define P2WI_LCR 0x24
46#define P2WI_PMCR 0x28
47
48/* CTRL fields */
49#define P2WI_CTRL_START_TRANS BIT(7)
50#define P2WI_CTRL_ABORT_TRANS BIT(6)
51#define P2WI_CTRL_GLOBAL_INT_ENB BIT(1)
52#define P2WI_CTRL_SOFT_RST BIT(0)
53
54/* CLK CTRL fields */
55#define P2WI_CCR_SDA_OUT_DELAY(v) (((v) & 0x7) << 8)
56#define P2WI_CCR_MAX_CLK_DIV 0xff
57#define P2WI_CCR_CLK_DIV(v) ((v) & P2WI_CCR_MAX_CLK_DIV)
58
59/* STATUS fields */
60#define P2WI_INTS_TRANS_ERR_ID(v) (((v) >> 8) & 0xff)
61#define P2WI_INTS_LOAD_BSY BIT(2)
62#define P2WI_INTS_TRANS_ERR BIT(1)
63#define P2WI_INTS_TRANS_OVER BIT(0)
64
65/* DATA LENGTH fields*/
66#define P2WI_DLEN_READ BIT(4)
67#define P2WI_DLEN_DATA_LENGTH(v) ((v - 1) & 0x7)
68
69/* LINE CTRL fields*/
70#define P2WI_LCR_SCL_STATE BIT(5)
71#define P2WI_LCR_SDA_STATE BIT(4)
72#define P2WI_LCR_SCL_CTL BIT(3)
73#define P2WI_LCR_SCL_CTL_EN BIT(2)
74#define P2WI_LCR_SDA_CTL BIT(1)
75#define P2WI_LCR_SDA_CTL_EN BIT(0)
76
77/* PMU MODE CTRL fields */
78#define P2WI_PMCR_PMU_INIT_SEND BIT(31)
79#define P2WI_PMCR_PMU_INIT_DATA(v) (((v) & 0xff) << 16)
80#define P2WI_PMCR_PMU_MODE_REG(v) (((v) & 0xff) << 8)
81#define P2WI_PMCR_PMU_DEV_ADDR(v) ((v) & 0xff)
82
83#define P2WI_MAX_FREQ 6000000
84
85struct p2wi {
86 struct i2c_adapter adapter;
87 struct completion complete;
88 unsigned int status;
89 void __iomem *regs;
90 struct clk *clk;
91 struct reset_control *rstc;
92 int slave_addr;
93};
94
95static irqreturn_t p2wi_interrupt(int irq, void *dev_id)
96{
97 struct p2wi *p2wi = dev_id;
98 unsigned long status;
99
100 status = readl(p2wi->regs + P2WI_INTS);
101 p2wi->status = status;
102
103 /* Clear interrupts */
104 status &= (P2WI_INTS_LOAD_BSY | P2WI_INTS_TRANS_ERR |
105 P2WI_INTS_TRANS_OVER);
106 writel(status, p2wi->regs + P2WI_INTS);
107
108 complete(&p2wi->complete);
109
110 return IRQ_HANDLED;
111}
112
113static u32 p2wi_functionality(struct i2c_adapter *adap)
114{
115 return I2C_FUNC_SMBUS_BYTE_DATA;
116}
117
118static int p2wi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
119 unsigned short flags, char read_write,
120 u8 command, int size, union i2c_smbus_data *data)
121{
122 struct p2wi *p2wi = i2c_get_adapdata(adap);
123 unsigned long dlen = P2WI_DLEN_DATA_LENGTH(1);
124
125 if (p2wi->slave_addr >= 0 && addr != p2wi->slave_addr) {
126 dev_err(&adap->dev, "invalid P2WI address\n");
127 return -EINVAL;
128 }
129
130 if (!data)
131 return -EINVAL;
132
133 writel(command, p2wi->regs + P2WI_DADDR0);
134
135 if (read_write == I2C_SMBUS_READ)
136 dlen |= P2WI_DLEN_READ;
137 else
138 writel(data->byte, p2wi->regs + P2WI_DATA0);
139
140 writel(dlen, p2wi->regs + P2WI_DLEN);
141
142 if (readl(p2wi->regs + P2WI_CTRL) & P2WI_CTRL_START_TRANS) {
143 dev_err(&adap->dev, "P2WI bus busy\n");
144 return -EBUSY;
145 }
146
147 reinit_completion(&p2wi->complete);
148
149 writel(P2WI_INTS_LOAD_BSY | P2WI_INTS_TRANS_ERR | P2WI_INTS_TRANS_OVER,
150 p2wi->regs + P2WI_INTE);
151
152 writel(P2WI_CTRL_START_TRANS | P2WI_CTRL_GLOBAL_INT_ENB,
153 p2wi->regs + P2WI_CTRL);
154
155 wait_for_completion(&p2wi->complete);
156
157 if (p2wi->status & P2WI_INTS_LOAD_BSY) {
158 dev_err(&adap->dev, "P2WI bus busy\n");
159 return -EBUSY;
160 }
161
162 if (p2wi->status & P2WI_INTS_TRANS_ERR) {
163 dev_err(&adap->dev, "P2WI bus xfer error\n");
164 return -ENXIO;
165 }
166
167 if (read_write == I2C_SMBUS_READ)
168 data->byte = readl(p2wi->regs + P2WI_DATA0);
169
170 return 0;
171}
172
173static const struct i2c_algorithm p2wi_algo = {
174 .smbus_xfer = p2wi_smbus_xfer,
175 .functionality = p2wi_functionality,
176};
177
178static const struct of_device_id p2wi_of_match_table[] = {
179 { .compatible = "allwinner,sun6i-a31-p2wi" },
180 {}
181};
182MODULE_DEVICE_TABLE(of, p2wi_of_match_table);
183
184static int p2wi_probe(struct platform_device *pdev)
185{
186 struct device *dev = &pdev->dev;
187 struct device_node *np = dev->of_node;
188 struct device_node *childnp;
189 unsigned long parent_clk_freq;
190 u32 clk_freq = 100000;
191 struct resource *r;
192 struct p2wi *p2wi;
193 u32 slave_addr;
194 int clk_div;
195 int irq;
196 int ret;
197
198 of_property_read_u32(np, "clock-frequency", &clk_freq);
199 if (clk_freq > P2WI_MAX_FREQ) {
200 dev_err(dev,
201 "required clock-frequency (%u Hz) is too high (max = 6MHz)",
202 clk_freq);
203 return -EINVAL;
204 }
205
206 if (of_get_child_count(np) > 1) {
207 dev_err(dev, "P2WI only supports one slave device\n");
208 return -EINVAL;
209 }
210
211 p2wi = devm_kzalloc(dev, sizeof(struct p2wi), GFP_KERNEL);
212 if (!p2wi)
213 return -ENOMEM;
214
215 p2wi->slave_addr = -1;
216
217 /*
218 * Authorize a p2wi node without any children to be able to use an
219 * i2c-dev from userpace.
220 * In this case the slave_addr is set to -1 and won't be checked when
221 * launching a P2WI transfer.
222 */
223 childnp = of_get_next_available_child(np, NULL);
224 if (childnp) {
225 ret = of_property_read_u32(childnp, "reg", &slave_addr);
226 if (ret) {
227 dev_err(dev, "invalid slave address on node %s\n",
228 childnp->full_name);
229 return -EINVAL;
230 }
231
232 p2wi->slave_addr = slave_addr;
233 }
234
235 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
236 p2wi->regs = devm_ioremap_resource(dev, r);
237 if (IS_ERR(p2wi->regs))
238 return PTR_ERR(p2wi->regs);
239
240 strlcpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name));
241 irq = platform_get_irq(pdev, 0);
242 if (irq < 0) {
243 dev_err(dev, "failed to retrieve irq: %d\n", irq);
244 return irq;
245 }
246
247 p2wi->clk = devm_clk_get(dev, NULL);
248 if (IS_ERR(p2wi->clk)) {
249 ret = PTR_ERR(p2wi->clk);
250 dev_err(dev, "failed to retrieve clk: %d\n", ret);
251 return ret;
252 }
253
254 ret = clk_prepare_enable(p2wi->clk);
255 if (ret) {
256 dev_err(dev, "failed to enable clk: %d\n", ret);
257 return ret;
258 }
259
260 parent_clk_freq = clk_get_rate(p2wi->clk);
261
262 p2wi->rstc = devm_reset_control_get(dev, NULL);
263 if (IS_ERR(p2wi->rstc)) {
264 ret = PTR_ERR(p2wi->rstc);
265 dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
266 goto err_clk_disable;
267 }
268
269 ret = reset_control_deassert(p2wi->rstc);
270 if (ret) {
271 dev_err(dev, "failed to deassert reset line: %d\n", ret);
272 goto err_clk_disable;
273 }
274
275 init_completion(&p2wi->complete);
276 p2wi->adapter.dev.parent = dev;
277 p2wi->adapter.algo = &p2wi_algo;
278 p2wi->adapter.owner = THIS_MODULE;
279 p2wi->adapter.dev.of_node = pdev->dev.of_node;
280 platform_set_drvdata(pdev, p2wi);
281 i2c_set_adapdata(&p2wi->adapter, p2wi);
282
283 ret = devm_request_irq(dev, irq, p2wi_interrupt, 0, pdev->name, p2wi);
284 if (ret) {
285 dev_err(dev, "can't register interrupt handler irq%d: %d\n",
286 irq, ret);
287 goto err_reset_assert;
288 }
289
290 writel(P2WI_CTRL_SOFT_RST, p2wi->regs + P2WI_CTRL);
291
292 clk_div = parent_clk_freq / clk_freq;
293 if (!clk_div) {
294 dev_warn(dev,
295 "clock-frequency is too high, setting it to %lu Hz\n",
296 parent_clk_freq);
297 clk_div = 1;
298 } else if (clk_div > P2WI_CCR_MAX_CLK_DIV) {
299 dev_warn(dev,
300 "clock-frequency is too low, setting it to %lu Hz\n",
301 parent_clk_freq / P2WI_CCR_MAX_CLK_DIV);
302 clk_div = P2WI_CCR_MAX_CLK_DIV;
303 }
304
305 writel(P2WI_CCR_SDA_OUT_DELAY(1) | P2WI_CCR_CLK_DIV(clk_div),
306 p2wi->regs + P2WI_CCR);
307
308 ret = i2c_add_adapter(&p2wi->adapter);
309 if (!ret)
310 return 0;
311
312err_reset_assert:
313 reset_control_assert(p2wi->rstc);
314
315err_clk_disable:
316 clk_disable_unprepare(p2wi->clk);
317
318 return ret;
319}
320
321static int p2wi_remove(struct platform_device *dev)
322{
323 struct p2wi *p2wi = platform_get_drvdata(dev);
324
325 reset_control_assert(p2wi->rstc);
326 clk_disable_unprepare(p2wi->clk);
327 i2c_del_adapter(&p2wi->adapter);
328
329 return 0;
330}
331
332static struct platform_driver p2wi_driver = {
333 .probe = p2wi_probe,
334 .remove = p2wi_remove,
335 .driver = {
336 .owner = THIS_MODULE,
337 .name = "i2c-sunxi-p2wi",
338 .of_match_table = p2wi_of_match_table,
339 },
340};
341module_platform_driver(p2wi_driver);
342
343MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
344MODULE_DESCRIPTION("Allwinner P2WI driver");
345MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 8a5e67c4ced1..772e869c280e 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -510,12 +510,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)
510 return idev->num_channels; 510 return idev->num_channels;
511} 511}
512 512
513static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev, 513static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
514 struct at91_adc_trigger *triggers, 514 struct at91_adc_trigger *triggers,
515 const char *trigger_name) 515 const char *trigger_name)
516{ 516{
517 struct at91_adc_state *st = iio_priv(idev); 517 struct at91_adc_state *st = iio_priv(idev);
518 u8 value = 0;
519 int i; 518 int i;
520 519
521 for (i = 0; i < st->trigger_number; i++) { 520 for (i = 0; i < st->trigger_number; i++) {
@@ -528,15 +527,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
528 return -ENOMEM; 527 return -ENOMEM;
529 528
530 if (strcmp(trigger_name, name) == 0) { 529 if (strcmp(trigger_name, name) == 0) {
531 value = triggers[i].value;
532 kfree(name); 530 kfree(name);
533 break; 531 if (triggers[i].value == 0)
532 return -EINVAL;
533 return triggers[i].value;
534 } 534 }
535 535
536 kfree(name); 536 kfree(name);
537 } 537 }
538 538
539 return value; 539 return -EINVAL;
540} 540}
541 541
542static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) 542static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
@@ -546,14 +546,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
546 struct iio_buffer *buffer = idev->buffer; 546 struct iio_buffer *buffer = idev->buffer;
547 struct at91_adc_reg_desc *reg = st->registers; 547 struct at91_adc_reg_desc *reg = st->registers;
548 u32 status = at91_adc_readl(st, reg->trigger_register); 548 u32 status = at91_adc_readl(st, reg->trigger_register);
549 u8 value; 549 int value;
550 u8 bit; 550 u8 bit;
551 551
552 value = at91_adc_get_trigger_value_by_name(idev, 552 value = at91_adc_get_trigger_value_by_name(idev,
553 st->trigger_list, 553 st->trigger_list,
554 idev->trig->name); 554 idev->trig->name);
555 if (value == 0) 555 if (value < 0)
556 return -EINVAL; 556 return value;
557 557
558 if (state) { 558 if (state) {
559 st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL); 559 st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
index 6989c16aec2b..b58d6302521f 100644
--- a/drivers/iio/adc/men_z188_adc.c
+++ b/drivers/iio/adc/men_z188_adc.c
@@ -121,8 +121,8 @@ static int men_z188_probe(struct mcb_device *dev,
121 indio_dev->num_channels = ARRAY_SIZE(z188_adc_iio_channels); 121 indio_dev->num_channels = ARRAY_SIZE(z188_adc_iio_channels);
122 122
123 mem = mcb_request_mem(dev, "z188-adc"); 123 mem = mcb_request_mem(dev, "z188-adc");
124 if (!mem) 124 if (IS_ERR(mem))
125 return -ENOMEM; 125 return PTR_ERR(mem);
126 126
127 adc->base = ioremap(mem->start, resource_size(mem)); 127 adc->base = ioremap(mem->start, resource_size(mem));
128 if (adc->base == NULL) 128 if (adc->base == NULL)
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index 7de1c4c87942..eb86786e698e 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -645,6 +645,7 @@ int twl4030_get_madc_conversion(int channel_no)
645 req.channels = (1 << channel_no); 645 req.channels = (1 << channel_no);
646 req.method = TWL4030_MADC_SW2; 646 req.method = TWL4030_MADC_SW2;
647 req.active = 0; 647 req.active = 0;
648 req.raw = 0;
648 req.func_cb = NULL; 649 req.func_cb = NULL;
649 ret = twl4030_madc_conversion(&req); 650 ret = twl4030_madc_conversion(&req);
650 if (ret < 0) 651 if (ret < 0)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 73282cee0c81..a3109a6f4d86 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -75,6 +75,9 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
75 (s32)report_val); 75 (s32)report_val);
76 } 76 }
77 77
78 sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
79 st->power_state.index,
80 &state_val);
78 return 0; 81 return 0;
79} 82}
80EXPORT_SYMBOL(hid_sensor_power_state); 83EXPORT_SYMBOL(hid_sensor_power_state);
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 09ea5c481f4c..ea08313af0d2 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -373,8 +373,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
373{ 373{
374 struct ak8975_data *data = iio_priv(indio_dev); 374 struct ak8975_data *data = iio_priv(indio_dev);
375 struct i2c_client *client = data->client; 375 struct i2c_client *client = data->client;
376 u16 meas_reg;
377 s16 raw;
378 int ret; 376 int ret;
379 377
380 mutex_lock(&data->lock); 378 mutex_lock(&data->lock);
@@ -422,16 +420,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
422 dev_err(&client->dev, "Read axis data fails\n"); 420 dev_err(&client->dev, "Read axis data fails\n");
423 goto exit; 421 goto exit;
424 } 422 }
425 meas_reg = ret;
426 423
427 mutex_unlock(&data->lock); 424 mutex_unlock(&data->lock);
428 425
429 /* Endian conversion of the measured values. */
430 raw = (s16) (le16_to_cpu(meas_reg));
431
432 /* Clamp to valid range. */ 426 /* Clamp to valid range. */
433 raw = clamp_t(s16, raw, -4096, 4095); 427 *val = clamp_t(s16, ret, -4096, 4095);
434 *val = raw;
435 return IIO_VAL_INT; 428 return IIO_VAL_INT;
436 429
437exit: 430exit:
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index ba6d0c520e63..01b2e0b18878 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -98,7 +98,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
98 mutex_unlock(&data->lock); 98 mutex_unlock(&data->lock);
99 if (ret < 0) 99 if (ret < 0)
100 return ret; 100 return ret;
101 *val = sign_extend32(be32_to_cpu(tmp) >> 12, 23); 101 *val = be32_to_cpu(tmp) >> 12;
102 return IIO_VAL_INT; 102 return IIO_VAL_INT;
103 case IIO_TEMP: /* in 0.0625 celsius / LSB */ 103 case IIO_TEMP: /* in 0.0625 celsius / LSB */
104 mutex_lock(&data->lock); 104 mutex_lock(&data->lock);
@@ -112,7 +112,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
112 mutex_unlock(&data->lock); 112 mutex_unlock(&data->lock);
113 if (ret < 0) 113 if (ret < 0)
114 return ret; 114 return ret;
115 *val = sign_extend32(be32_to_cpu(tmp) >> 20, 15); 115 *val = sign_extend32(be32_to_cpu(tmp) >> 20, 11);
116 return IIO_VAL_INT; 116 return IIO_VAL_INT;
117 default: 117 default:
118 return -EINVAL; 118 return -EINVAL;
@@ -185,7 +185,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
185 BIT(IIO_CHAN_INFO_SCALE), 185 BIT(IIO_CHAN_INFO_SCALE),
186 .scan_index = 0, 186 .scan_index = 0,
187 .scan_type = { 187 .scan_type = {
188 .sign = 's', 188 .sign = 'u',
189 .realbits = 20, 189 .realbits = 20,
190 .storagebits = 32, 190 .storagebits = 32,
191 .shift = 12, 191 .shift = 12,
diff --git a/drivers/misc/vexpress-syscfg.c b/drivers/misc/vexpress-syscfg.c
index 73068e50e56d..3250fc1df0aa 100644
--- a/drivers/misc/vexpress-syscfg.c
+++ b/drivers/misc/vexpress-syscfg.c
@@ -199,7 +199,7 @@ static struct regmap *vexpress_syscfg_regmap_init(struct device *dev,
199 func = kzalloc(sizeof(*func) + sizeof(*func->template) * num, 199 func = kzalloc(sizeof(*func) + sizeof(*func->template) * num,
200 GFP_KERNEL); 200 GFP_KERNEL);
201 if (!func) 201 if (!func)
202 return NULL; 202 return ERR_PTR(-ENOMEM);
203 203
204 func->syscfg = syscfg; 204 func->syscfg = syscfg;
205 func->num_templates = num; 205 func->num_templates = num;
@@ -231,10 +231,14 @@ static struct regmap *vexpress_syscfg_regmap_init(struct device *dev,
231 func->regmap = regmap_init(dev, NULL, func, 231 func->regmap = regmap_init(dev, NULL, func,
232 &vexpress_syscfg_regmap_config); 232 &vexpress_syscfg_regmap_config);
233 233
234 if (IS_ERR(func->regmap)) 234 if (IS_ERR(func->regmap)) {
235 void *err = func->regmap;
236
235 kfree(func); 237 kfree(func);
236 else 238 return err;
237 list_add(&func->list, &syscfg->funcs); 239 }
240
241 list_add(&func->list, &syscfg->funcs);
238 242
239 return func->regmap; 243 return func->regmap;
240} 244}
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 2421835d5daf..191617492181 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -17,7 +17,8 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 * 19 *
20 * Maintained by: Dmitry Torokhov <dtor@vmware.com> 20 * Maintained by: Xavier Deguillard <xdeguillard@vmware.com>
21 * Philip Moltmann <moltmann@vmware.com>
21 */ 22 */
22 23
23/* 24/*
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 8368d96ae7b4..b9864806e9b8 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -227,7 +227,8 @@ static int __of_node_add(struct device_node *np)
227 np->kobj.kset = of_kset; 227 np->kobj.kset = of_kset;
228 if (!np->parent) { 228 if (!np->parent) {
229 /* Nodes without parents are new top level trees */ 229 /* Nodes without parents are new top level trees */
230 rc = kobject_add(&np->kobj, NULL, safe_name(&of_kset->kobj, "base")); 230 rc = kobject_add(&np->kobj, NULL, "%s",
231 safe_name(&of_kset->kobj, "base"));
231 } else { 232 } else {
232 name = safe_name(&np->parent->kobj, kbasename(np->full_name)); 233 name = safe_name(&np->parent->kobj, kbasename(np->full_name));
233 if (!name || !name[0]) 234 if (!name || !name[0])
@@ -1960,9 +1961,9 @@ int of_attach_node(struct device_node *np)
1960 1961
1961 raw_spin_lock_irqsave(&devtree_lock, flags); 1962 raw_spin_lock_irqsave(&devtree_lock, flags);
1962 np->sibling = np->parent->child; 1963 np->sibling = np->parent->child;
1963 np->allnext = of_allnodes; 1964 np->allnext = np->parent->allnext;
1965 np->parent->allnext = np;
1964 np->parent->child = np; 1966 np->parent->child = np;
1965 of_allnodes = np;
1966 of_node_clear_flag(np, OF_DETACHED); 1967 of_node_clear_flag(np, OF_DETACHED);
1967 raw_spin_unlock_irqrestore(&devtree_lock, flags); 1968 raw_spin_unlock_irqrestore(&devtree_lock, flags);
1968 1969
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 6c48d73a7fd7..500436f9be7f 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -166,10 +166,6 @@ static void of_dma_configure(struct platform_device *pdev)
166 int ret; 166 int ret;
167 struct device *dev = &pdev->dev; 167 struct device *dev = &pdev->dev;
168 168
169#if defined(CONFIG_MICROBLAZE)
170 pdev->archdata.dma_mask = 0xffffffffUL;
171#endif
172
173 /* 169 /*
174 * Set default dma-mask to 32 bit. Drivers are expected to setup 170 * Set default dma-mask to 32 bit. Drivers are expected to setup
175 * the correct supported dma_mask. 171 * the correct supported dma_mask.
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index 85585219ce82..ad9e0c9b7daf 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -433,6 +433,7 @@ static struct regulator_ops as3722_ldo3_extcntrl_ops = {
433}; 433};
434 434
435static const struct regulator_linear_range as3722_ldo_ranges[] = { 435static const struct regulator_linear_range as3722_ldo_ranges[] = {
436 REGULATOR_LINEAR_RANGE(0, 0x00, 0x00, 0),
436 REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000), 437 REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000),
437 REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000), 438 REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000),
438}; 439};
@@ -609,6 +610,7 @@ static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs)
609} 610}
610 611
611static const struct regulator_linear_range as3722_sd2345_ranges[] = { 612static const struct regulator_linear_range as3722_sd2345_ranges[] = {
613 REGULATOR_LINEAR_RANGE(0, 0x00, 0x00, 0),
612 REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), 614 REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500),
613 REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), 615 REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000),
614 REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000), 616 REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000),
diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 110a99ee1162..c8105182b8b8 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -255,7 +255,7 @@ static int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589)
255 struct device_node *node; 255 struct device_node *node;
256 int i, ret; 256 int i, ret;
257 257
258 node = of_find_node_by_name(dev->of_node, "regulators"); 258 node = of_get_child_by_name(dev->of_node, "regulators");
259 if (!node) { 259 if (!node) {
260 dev_err(dev, "regulators node not found\n"); 260 dev_err(dev, "regulators node not found\n");
261 return -EINVAL; 261 return -EINVAL;
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 864ed02ce4b7..b982f0ff4e01 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -37,12 +37,14 @@ struct regs_info {
37}; 37};
38 38
39static const struct regulator_linear_range smps_low_ranges[] = { 39static const struct regulator_linear_range smps_low_ranges[] = {
40 REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
40 REGULATOR_LINEAR_RANGE(500000, 0x1, 0x6, 0), 41 REGULATOR_LINEAR_RANGE(500000, 0x1, 0x6, 0),
41 REGULATOR_LINEAR_RANGE(510000, 0x7, 0x79, 10000), 42 REGULATOR_LINEAR_RANGE(510000, 0x7, 0x79, 10000),
42 REGULATOR_LINEAR_RANGE(1650000, 0x7A, 0x7f, 0), 43 REGULATOR_LINEAR_RANGE(1650000, 0x7A, 0x7f, 0),
43}; 44};
44 45
45static const struct regulator_linear_range smps_high_ranges[] = { 46static const struct regulator_linear_range smps_high_ranges[] = {
47 REGULATOR_LINEAR_RANGE(0, 0x0, 0x0, 0),
46 REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x6, 0), 48 REGULATOR_LINEAR_RANGE(1000000, 0x1, 0x6, 0),
47 REGULATOR_LINEAR_RANGE(1020000, 0x7, 0x79, 20000), 49 REGULATOR_LINEAR_RANGE(1020000, 0x7, 0x79, 20000),
48 REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0), 50 REGULATOR_LINEAR_RANGE(3300000, 0x7A, 0x7f, 0),
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index ce1743d0b679..5e343bab9458 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -44,7 +44,7 @@ config STE_MODEM_RPROC
44config DA8XX_REMOTEPROC 44config DA8XX_REMOTEPROC
45 tristate "DA8xx/OMAP-L13x remoteproc support" 45 tristate "DA8xx/OMAP-L13x remoteproc support"
46 depends on ARCH_DAVINCI_DA8XX 46 depends on ARCH_DAVINCI_DA8XX
47 select CMA 47 select CMA if MMU
48 select REMOTEPROC 48 select REMOTEPROC
49 select RPMSG 49 select RPMSG
50 help 50 help
diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 1ecfe3bd92ac..1cff2a21db67 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -71,7 +71,7 @@ static int puv3_rtc_setpie(struct device *dev, int enabled)
71{ 71{
72 unsigned int tmp; 72 unsigned int tmp;
73 73
74 dev_debug(dev, "%s: pie=%d\n", __func__, enabled); 74 dev_dbg(dev, "%s: pie=%d\n", __func__, enabled);
75 75
76 spin_lock_irq(&puv3_rtc_pie_lock); 76 spin_lock_irq(&puv3_rtc_pie_lock);
77 tmp = readl(RTC_RTSR) & ~RTC_RTSR_HZE; 77 tmp = readl(RTC_RTSR) & ~RTC_RTSR_HZE;
@@ -140,7 +140,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
140 rtc_tm_to_time(tm, &rtcalarm_count); 140 rtc_tm_to_time(tm, &rtcalarm_count);
141 writel(rtcalarm_count, RTC_RTAR); 141 writel(rtcalarm_count, RTC_RTAR);
142 142
143 puv3_rtc_setaie(&dev->dev, alrm->enabled); 143 puv3_rtc_setaie(dev, alrm->enabled);
144 144
145 if (alrm->enabled) 145 if (alrm->enabled)
146 enable_irq_wake(puv3_rtc_alarmno); 146 enable_irq_wake(puv3_rtc_alarmno);
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index ee0e85abe1fd..0f471750327e 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -593,7 +593,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
593 dev_info->start = dcssblk_find_lowest_addr(dev_info); 593 dev_info->start = dcssblk_find_lowest_addr(dev_info);
594 dev_info->end = dcssblk_find_highest_addr(dev_info); 594 dev_info->end = dcssblk_find_highest_addr(dev_info);
595 595
596 dev_set_name(&dev_info->dev, dev_info->segment_name); 596 dev_set_name(&dev_info->dev, "%s", dev_info->segment_name);
597 dev_info->dev.release = dcssblk_release_segment; 597 dev_info->dev.release = dcssblk_release_segment;
598 dev_info->dev.groups = dcssblk_dev_attr_groups; 598 dev_info->dev.groups = dcssblk_dev_attr_groups;
599 INIT_LIST_HEAD(&dev_info->lh); 599 INIT_LIST_HEAD(&dev_info->lh);
diff --git a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile
index 629fcc275e92..78b6ace7edcb 100644
--- a/drivers/s390/char/Makefile
+++ b/drivers/s390/char/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o
19obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o 19obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o
20obj-$(CONFIG_SCLP_ASYNC) += sclp_async.o 20obj-$(CONFIG_SCLP_ASYNC) += sclp_async.o
21 21
22obj-$(CONFIG_ZVM_WATCHDOG) += vmwatchdog.o
23obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o 22obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o
24obj-$(CONFIG_VMCP) += vmcp.o 23obj-$(CONFIG_VMCP) += vmcp.o
25 24
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index cd9c91909596..b9a9f721716d 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -838,8 +838,6 @@ sclp_vt220_con_init(void)
838{ 838{
839 int rc; 839 int rc;
840 840
841 if (!CONSOLE_IS_SCLP)
842 return 0;
843 rc = __sclp_vt220_init(sclp_console_pages); 841 rc = __sclp_vt220_init(sclp_console_pages);
844 if (rc) 842 if (rc)
845 return rc; 843 return rc;
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index cf31d3321dab..a8848db7b09d 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -761,7 +761,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
761 761
762 dev = kzalloc(sizeof(struct device), GFP_KERNEL); 762 dev = kzalloc(sizeof(struct device), GFP_KERNEL);
763 if (dev) { 763 if (dev) {
764 dev_set_name(dev, priv->internal_name); 764 dev_set_name(dev, "%s", priv->internal_name);
765 dev->bus = &iucv_bus; 765 dev->bus = &iucv_bus;
766 dev->parent = iucv_root; 766 dev->parent = iucv_root;
767 dev->driver = &vmlogrdr_driver; 767 dev->driver = &vmlogrdr_driver;
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
deleted file mode 100644
index d5eac985976b..000000000000
--- a/drivers/s390/char/vmwatchdog.c
+++ /dev/null
@@ -1,338 +0,0 @@
1/*
2 * Watchdog implementation based on z/VM Watchdog Timer API
3 *
4 * Copyright IBM Corp. 2004, 2009
5 *
6 * The user space watchdog daemon can use this driver as
7 * /dev/vmwatchdog to have z/VM execute the specified CP
8 * command when the timeout expires. The default command is
9 * "IPL", which which cause an immediate reboot.
10 */
11#define KMSG_COMPONENT "vmwatchdog"
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13
14#include <linux/init.h>
15#include <linux/fs.h>
16#include <linux/kernel.h>
17#include <linux/miscdevice.h>
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/slab.h>
21#include <linux/suspend.h>
22#include <linux/watchdog.h>
23
24#include <asm/ebcdic.h>
25#include <asm/io.h>
26#include <asm/uaccess.h>
27
28#define MAX_CMDLEN 240
29#define MIN_INTERVAL 15
30static char vmwdt_cmd[MAX_CMDLEN] = "IPL";
31static bool vmwdt_conceal;
32
33static bool vmwdt_nowayout = WATCHDOG_NOWAYOUT;
34
35MODULE_LICENSE("GPL");
36MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
37MODULE_DESCRIPTION("z/VM Watchdog Timer");
38module_param_string(cmd, vmwdt_cmd, MAX_CMDLEN, 0644);
39MODULE_PARM_DESC(cmd, "CP command that is run when the watchdog triggers");
40module_param_named(conceal, vmwdt_conceal, bool, 0644);
41MODULE_PARM_DESC(conceal, "Enable the CONCEAL CP option while the watchdog "
42 " is active");
43module_param_named(nowayout, vmwdt_nowayout, bool, 0);
44MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started"
45 " (default=CONFIG_WATCHDOG_NOWAYOUT)");
46MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
47
48static unsigned int vmwdt_interval = 60;
49static unsigned long vmwdt_is_open;
50static int vmwdt_expect_close;
51
52static DEFINE_MUTEX(vmwdt_mutex);
53
54#define VMWDT_OPEN 0 /* devnode is open or suspend in progress */
55#define VMWDT_RUNNING 1 /* The watchdog is armed */
56
57enum vmwdt_func {
58 /* function codes */
59 wdt_init = 0,
60 wdt_change = 1,
61 wdt_cancel = 2,
62 /* flags */
63 wdt_conceal = 0x80000000,
64};
65
66static int __diag288(enum vmwdt_func func, unsigned int timeout,
67 char *cmd, size_t len)
68{
69 register unsigned long __func asm("2") = func;
70 register unsigned long __timeout asm("3") = timeout;
71 register unsigned long __cmdp asm("4") = virt_to_phys(cmd);
72 register unsigned long __cmdl asm("5") = len;
73 int err;
74
75 err = -EINVAL;
76 asm volatile(
77 " diag %1,%3,0x288\n"
78 "0: la %0,0\n"
79 "1:\n"
80 EX_TABLE(0b,1b)
81 : "+d" (err) : "d"(__func), "d"(__timeout),
82 "d"(__cmdp), "d"(__cmdl) : "1", "cc");
83 return err;
84}
85
86static int vmwdt_keepalive(void)
87{
88 /* we allocate new memory every time to avoid having
89 * to track the state. static allocation is not an
90 * option since that might not be contiguous in real
91 * storage in case of a modular build */
92 static char *ebc_cmd;
93 size_t len;
94 int ret;
95 unsigned int func;
96
97 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
98 if (!ebc_cmd)
99 return -ENOMEM;
100
101 len = strlcpy(ebc_cmd, vmwdt_cmd, MAX_CMDLEN);
102 ASCEBC(ebc_cmd, MAX_CMDLEN);
103 EBC_TOUPPER(ebc_cmd, MAX_CMDLEN);
104
105 func = vmwdt_conceal ? (wdt_init | wdt_conceal) : wdt_init;
106 set_bit(VMWDT_RUNNING, &vmwdt_is_open);
107 ret = __diag288(func, vmwdt_interval, ebc_cmd, len);
108 WARN_ON(ret != 0);
109 kfree(ebc_cmd);
110 return ret;
111}
112
113static int vmwdt_disable(void)
114{
115 char cmd[] = {'\0'};
116 int ret = __diag288(wdt_cancel, 0, cmd, 0);
117 WARN_ON(ret != 0);
118 clear_bit(VMWDT_RUNNING, &vmwdt_is_open);
119 return ret;
120}
121
122static int __init vmwdt_probe(void)
123{
124 /* there is no real way to see if the watchdog is supported,
125 * so we try initializing it with a NOP command ("BEGIN")
126 * that won't cause any harm even if the following disable
127 * fails for some reason */
128 char ebc_begin[] = {
129 194, 197, 199, 201, 213
130 };
131 if (__diag288(wdt_init, 15, ebc_begin, sizeof(ebc_begin)) != 0)
132 return -EINVAL;
133 return vmwdt_disable();
134}
135
136static int vmwdt_open(struct inode *i, struct file *f)
137{
138 int ret;
139 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open))
140 return -EBUSY;
141 ret = vmwdt_keepalive();
142 if (ret)
143 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
144 return ret ? ret : nonseekable_open(i, f);
145}
146
147static int vmwdt_close(struct inode *i, struct file *f)
148{
149 if (vmwdt_expect_close == 42)
150 vmwdt_disable();
151 vmwdt_expect_close = 0;
152 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
153 return 0;
154}
155
156static struct watchdog_info vmwdt_info = {
157 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
158 .firmware_version = 0,
159 .identity = "z/VM Watchdog Timer",
160};
161
162static int __vmwdt_ioctl(unsigned int cmd, unsigned long arg)
163{
164 switch (cmd) {
165 case WDIOC_GETSUPPORT:
166 if (copy_to_user((void __user *)arg, &vmwdt_info,
167 sizeof(vmwdt_info)))
168 return -EFAULT;
169 return 0;
170 case WDIOC_GETSTATUS:
171 case WDIOC_GETBOOTSTATUS:
172 return put_user(0, (int __user *)arg);
173 case WDIOC_GETTEMP:
174 return -EINVAL;
175 case WDIOC_SETOPTIONS:
176 {
177 int options, ret;
178 if (get_user(options, (int __user *)arg))
179 return -EFAULT;
180 ret = -EINVAL;
181 if (options & WDIOS_DISABLECARD) {
182 ret = vmwdt_disable();
183 if (ret)
184 return ret;
185 }
186 if (options & WDIOS_ENABLECARD) {
187 ret = vmwdt_keepalive();
188 }
189 return ret;
190 }
191 case WDIOC_GETTIMEOUT:
192 return put_user(vmwdt_interval, (int __user *)arg);
193 case WDIOC_SETTIMEOUT:
194 {
195 int interval;
196 if (get_user(interval, (int __user *)arg))
197 return -EFAULT;
198 if (interval < MIN_INTERVAL)
199 return -EINVAL;
200 vmwdt_interval = interval;
201 }
202 return vmwdt_keepalive();
203 case WDIOC_KEEPALIVE:
204 return vmwdt_keepalive();
205 }
206 return -EINVAL;
207}
208
209static long vmwdt_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
210{
211 int rc;
212
213 mutex_lock(&vmwdt_mutex);
214 rc = __vmwdt_ioctl(cmd, arg);
215 mutex_unlock(&vmwdt_mutex);
216 return (long) rc;
217}
218
219static ssize_t vmwdt_write(struct file *f, const char __user *buf,
220 size_t count, loff_t *ppos)
221{
222 if(count) {
223 if (!vmwdt_nowayout) {
224 size_t i;
225
226 /* note: just in case someone wrote the magic character
227 * five months ago... */
228 vmwdt_expect_close = 0;
229
230 for (i = 0; i != count; i++) {
231 char c;
232 if (get_user(c, buf+i))
233 return -EFAULT;
234 if (c == 'V')
235 vmwdt_expect_close = 42;
236 }
237 }
238 /* someone wrote to us, we should restart timer */
239 vmwdt_keepalive();
240 }
241 return count;
242}
243
244static int vmwdt_resume(void)
245{
246 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
247 return NOTIFY_DONE;
248}
249
250/*
251 * It makes no sense to go into suspend while the watchdog is running.
252 * Depending on the memory size, the watchdog might trigger, while we
253 * are still saving the memory.
254 * We reuse the open flag to ensure that suspend and watchdog open are
255 * exclusive operations
256 */
257static int vmwdt_suspend(void)
258{
259 if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) {
260 pr_err("The system cannot be suspended while the watchdog"
261 " is in use\n");
262 return notifier_from_errno(-EBUSY);
263 }
264 if (test_bit(VMWDT_RUNNING, &vmwdt_is_open)) {
265 clear_bit(VMWDT_OPEN, &vmwdt_is_open);
266 pr_err("The system cannot be suspended while the watchdog"
267 " is running\n");
268 return notifier_from_errno(-EBUSY);
269 }
270 return NOTIFY_DONE;
271}
272
273/*
274 * This function is called for suspend and resume.
275 */
276static int vmwdt_power_event(struct notifier_block *this, unsigned long event,
277 void *ptr)
278{
279 switch (event) {
280 case PM_POST_HIBERNATION:
281 case PM_POST_SUSPEND:
282 return vmwdt_resume();
283 case PM_HIBERNATION_PREPARE:
284 case PM_SUSPEND_PREPARE:
285 return vmwdt_suspend();
286 default:
287 return NOTIFY_DONE;
288 }
289}
290
291static struct notifier_block vmwdt_power_notifier = {
292 .notifier_call = vmwdt_power_event,
293};
294
295static const struct file_operations vmwdt_fops = {
296 .open = &vmwdt_open,
297 .release = &vmwdt_close,
298 .unlocked_ioctl = &vmwdt_ioctl,
299 .write = &vmwdt_write,
300 .owner = THIS_MODULE,
301 .llseek = noop_llseek,
302};
303
304static struct miscdevice vmwdt_dev = {
305 .minor = WATCHDOG_MINOR,
306 .name = "watchdog",
307 .fops = &vmwdt_fops,
308};
309
310static int __init vmwdt_init(void)
311{
312 int ret;
313
314 ret = vmwdt_probe();
315 if (ret)
316 return ret;
317 ret = register_pm_notifier(&vmwdt_power_notifier);
318 if (ret)
319 return ret;
320 /*
321 * misc_register() has to be the last action in module_init(), because
322 * file operations will be available right after this.
323 */
324 ret = misc_register(&vmwdt_dev);
325 if (ret) {
326 unregister_pm_notifier(&vmwdt_power_notifier);
327 return ret;
328 }
329 return 0;
330}
331module_init(vmwdt_init);
332
333static void __exit vmwdt_exit(void)
334{
335 unregister_pm_notifier(&vmwdt_power_notifier);
336 misc_deregister(&vmwdt_dev);
337}
338module_exit(vmwdt_exit);
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index 445564c790f6..00bfbee0af9e 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -196,11 +196,11 @@ EXPORT_SYMBOL(airq_iv_release);
196 */ 196 */
197unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num) 197unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num)
198{ 198{
199 unsigned long bit, i; 199 unsigned long bit, i, flags;
200 200
201 if (!iv->avail || num == 0) 201 if (!iv->avail || num == 0)
202 return -1UL; 202 return -1UL;
203 spin_lock(&iv->lock); 203 spin_lock_irqsave(&iv->lock, flags);
204 bit = find_first_bit_inv(iv->avail, iv->bits); 204 bit = find_first_bit_inv(iv->avail, iv->bits);
205 while (bit + num <= iv->bits) { 205 while (bit + num <= iv->bits) {
206 for (i = 1; i < num; i++) 206 for (i = 1; i < num; i++)
@@ -218,9 +218,8 @@ unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num)
218 } 218 }
219 if (bit + num > iv->bits) 219 if (bit + num > iv->bits)
220 bit = -1UL; 220 bit = -1UL;
221 spin_unlock(&iv->lock); 221 spin_unlock_irqrestore(&iv->lock, flags);
222 return bit; 222 return bit;
223
224} 223}
225EXPORT_SYMBOL(airq_iv_alloc); 224EXPORT_SYMBOL(airq_iv_alloc);
226 225
@@ -232,11 +231,11 @@ EXPORT_SYMBOL(airq_iv_alloc);
232 */ 231 */
233void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num) 232void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num)
234{ 233{
235 unsigned long i; 234 unsigned long i, flags;
236 235
237 if (!iv->avail || num == 0) 236 if (!iv->avail || num == 0)
238 return; 237 return;
239 spin_lock(&iv->lock); 238 spin_lock_irqsave(&iv->lock, flags);
240 for (i = 0; i < num; i++) { 239 for (i = 0; i < num; i++) {
241 /* Clear (possibly left over) interrupt bit */ 240 /* Clear (possibly left over) interrupt bit */
242 clear_bit_inv(bit + i, iv->vector); 241 clear_bit_inv(bit + i, iv->vector);
@@ -248,7 +247,7 @@ void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num)
248 while (iv->end > 0 && !test_bit_inv(iv->end - 1, iv->avail)) 247 while (iv->end > 0 && !test_bit_inv(iv->end - 1, iv->avail))
249 iv->end--; 248 iv->end--;
250 } 249 }
251 spin_unlock(&iv->lock); 250 spin_unlock_irqrestore(&iv->lock, flags);
252} 251}
253EXPORT_SYMBOL(airq_iv_free); 252EXPORT_SYMBOL(airq_iv_free);
254 253
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index dfd7bc681c25..e443b0d0b236 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -184,7 +184,7 @@ static ssize_t ccwgroup_ungroup_store(struct device *dev,
184 const char *buf, size_t count) 184 const char *buf, size_t count)
185{ 185{
186 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); 186 struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
187 int rc; 187 int rc = 0;
188 188
189 /* Prevent concurrent online/offline processing and ungrouping. */ 189 /* Prevent concurrent online/offline processing and ungrouping. */
190 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) 190 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
@@ -196,11 +196,12 @@ static ssize_t ccwgroup_ungroup_store(struct device *dev,
196 196
197 if (device_remove_file_self(dev, attr)) 197 if (device_remove_file_self(dev, attr))
198 ccwgroup_ungroup(gdev); 198 ccwgroup_ungroup(gdev);
199 else
200 rc = -ENODEV;
199out: 201out:
200 if (rc) { 202 if (rc) {
201 if (rc != -EAGAIN) 203 /* Release onoff "lock" when ungrouping failed. */
202 /* Release onoff "lock" when ungrouping failed. */ 204 atomic_set(&gdev->onoff, 0);
203 atomic_set(&gdev->onoff, 0);
204 return rc; 205 return rc;
205 } 206 }
206 return count; 207 return count;
@@ -227,6 +228,7 @@ static void ccwgroup_ungroup_workfn(struct work_struct *work)
227 container_of(work, struct ccwgroup_device, ungroup_work); 228 container_of(work, struct ccwgroup_device, ungroup_work);
228 229
229 ccwgroup_ungroup(gdev); 230 ccwgroup_ungroup(gdev);
231 put_device(&gdev->dev);
230} 232}
231 233
232static void ccwgroup_release(struct device *dev) 234static void ccwgroup_release(struct device *dev)
@@ -412,8 +414,10 @@ static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action,
412{ 414{
413 struct ccwgroup_device *gdev = to_ccwgroupdev(data); 415 struct ccwgroup_device *gdev = to_ccwgroupdev(data);
414 416
415 if (action == BUS_NOTIFY_UNBIND_DRIVER) 417 if (action == BUS_NOTIFY_UNBIND_DRIVER) {
418 get_device(&gdev->dev);
416 schedule_work(&gdev->ungroup_work); 419 schedule_work(&gdev->ungroup_work);
420 }
417 421
418 return NOTIFY_OK; 422 return NOTIFY_OK;
419} 423}
@@ -582,11 +586,7 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
582 __ccwgroup_match_all))) { 586 __ccwgroup_match_all))) {
583 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); 587 struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
584 588
585 mutex_lock(&gdev->reg_mutex); 589 ccwgroup_ungroup(gdev);
586 __ccwgroup_remove_symlinks(gdev);
587 device_unregister(dev);
588 __ccwgroup_remove_cdev_refs(gdev);
589 mutex_unlock(&gdev->reg_mutex);
590 put_device(dev); 590 put_device(dev);
591 } 591 }
592 driver_unregister(&cdriver->driver); 592 driver_unregister(&cdriver->driver);
@@ -633,13 +633,7 @@ void ccwgroup_remove_ccwdev(struct ccw_device *cdev)
633 get_device(&gdev->dev); 633 get_device(&gdev->dev);
634 spin_unlock_irq(cdev->ccwlock); 634 spin_unlock_irq(cdev->ccwlock);
635 /* Unregister group device. */ 635 /* Unregister group device. */
636 mutex_lock(&gdev->reg_mutex); 636 ccwgroup_ungroup(gdev);
637 if (device_is_registered(&gdev->dev)) {
638 __ccwgroup_remove_symlinks(gdev);
639 device_unregister(&gdev->dev);
640 __ccwgroup_remove_cdev_refs(gdev);
641 }
642 mutex_unlock(&gdev->reg_mutex);
643 /* Release ccwgroup device reference for local processing. */ 637 /* Release ccwgroup device reference for local processing. */
644 put_device(&gdev->dev); 638 put_device(&gdev->dev);
645} 639}
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 77f9c92df4b9..2905d8b0ec95 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -602,6 +602,7 @@ void __init init_cio_interrupts(void)
602 602
603#ifdef CONFIG_CCW_CONSOLE 603#ifdef CONFIG_CCW_CONSOLE
604static struct subchannel *console_sch; 604static struct subchannel *console_sch;
605static struct lock_class_key console_sch_key;
605 606
606/* 607/*
607 * Use cio_tsch to update the subchannel status and call the interrupt handler 608 * Use cio_tsch to update the subchannel status and call the interrupt handler
@@ -686,6 +687,7 @@ struct subchannel *cio_probe_console(void)
686 if (IS_ERR(sch)) 687 if (IS_ERR(sch))
687 return sch; 688 return sch;
688 689
690 lockdep_set_class(sch->lock, &console_sch_key);
689 isc_register(CONSOLE_ISC); 691 isc_register(CONSOLE_ISC);
690 sch->config.isc = CONSOLE_ISC; 692 sch->config.isc = CONSOLE_ISC;
691 sch->config.intparm = (u32)(addr_t)sch; 693 sch->config.intparm = (u32)(addr_t)sch;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index d8d9b5b5cc56..dfef5e63cb7b 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -678,18 +678,11 @@ static const struct attribute_group *ccwdev_attr_groups[] = {
678 NULL, 678 NULL,
679}; 679};
680 680
681/* this is a simple abstraction for device_register that sets the 681static int ccw_device_add(struct ccw_device *cdev)
682 * correct bus type and adds the bus specific files */
683static int ccw_device_register(struct ccw_device *cdev)
684{ 682{
685 struct device *dev = &cdev->dev; 683 struct device *dev = &cdev->dev;
686 int ret;
687 684
688 dev->bus = &ccw_bus_type; 685 dev->bus = &ccw_bus_type;
689 ret = dev_set_name(&cdev->dev, "0.%x.%04x", cdev->private->dev_id.ssid,
690 cdev->private->dev_id.devno);
691 if (ret)
692 return ret;
693 return device_add(dev); 686 return device_add(dev);
694} 687}
695 688
@@ -764,22 +757,46 @@ static void ccw_device_todo(struct work_struct *work);
764static int io_subchannel_initialize_dev(struct subchannel *sch, 757static int io_subchannel_initialize_dev(struct subchannel *sch,
765 struct ccw_device *cdev) 758 struct ccw_device *cdev)
766{ 759{
767 cdev->private->cdev = cdev; 760 struct ccw_device_private *priv = cdev->private;
768 cdev->private->int_class = IRQIO_CIO; 761 int ret;
769 atomic_set(&cdev->private->onoff, 0); 762
763 priv->cdev = cdev;
764 priv->int_class = IRQIO_CIO;
765 priv->state = DEV_STATE_NOT_OPER;
766 priv->dev_id.devno = sch->schib.pmcw.dev;
767 priv->dev_id.ssid = sch->schid.ssid;
768 priv->schid = sch->schid;
769
770 INIT_WORK(&priv->todo_work, ccw_device_todo);
771 INIT_LIST_HEAD(&priv->cmb_list);
772 init_waitqueue_head(&priv->wait_q);
773 init_timer(&priv->timer);
774
775 atomic_set(&priv->onoff, 0);
776 cdev->ccwlock = sch->lock;
770 cdev->dev.parent = &sch->dev; 777 cdev->dev.parent = &sch->dev;
771 cdev->dev.release = ccw_device_release; 778 cdev->dev.release = ccw_device_release;
772 INIT_WORK(&cdev->private->todo_work, ccw_device_todo);
773 cdev->dev.groups = ccwdev_attr_groups; 779 cdev->dev.groups = ccwdev_attr_groups;
774 /* Do first half of device_register. */ 780 /* Do first half of device_register. */
775 device_initialize(&cdev->dev); 781 device_initialize(&cdev->dev);
782 ret = dev_set_name(&cdev->dev, "0.%x.%04x", cdev->private->dev_id.ssid,
783 cdev->private->dev_id.devno);
784 if (ret)
785 goto out_put;
776 if (!get_device(&sch->dev)) { 786 if (!get_device(&sch->dev)) {
777 /* Release reference from device_initialize(). */ 787 ret = -ENODEV;
778 put_device(&cdev->dev); 788 goto out_put;
779 return -ENODEV;
780 } 789 }
781 cdev->private->flags.initialized = 1; 790 priv->flags.initialized = 1;
791 spin_lock_irq(sch->lock);
792 sch_set_cdev(sch, cdev);
793 spin_unlock_irq(sch->lock);
782 return 0; 794 return 0;
795
796out_put:
797 /* Release reference from device_initialize(). */
798 put_device(&cdev->dev);
799 return ret;
783} 800}
784 801
785static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch) 802static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch)
@@ -858,7 +875,7 @@ static void io_subchannel_register(struct ccw_device *cdev)
858 dev_set_uevent_suppress(&sch->dev, 0); 875 dev_set_uevent_suppress(&sch->dev, 0);
859 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 876 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
860 /* make it known to the system */ 877 /* make it known to the system */
861 ret = ccw_device_register(cdev); 878 ret = ccw_device_add(cdev);
862 if (ret) { 879 if (ret) {
863 CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n", 880 CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n",
864 cdev->private->dev_id.ssid, 881 cdev->private->dev_id.ssid,
@@ -923,26 +940,11 @@ io_subchannel_recog_done(struct ccw_device *cdev)
923 940
924static void io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) 941static void io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
925{ 942{
926 struct ccw_device_private *priv;
927
928 cdev->ccwlock = sch->lock;
929
930 /* Init private data. */
931 priv = cdev->private;
932 priv->dev_id.devno = sch->schib.pmcw.dev;
933 priv->dev_id.ssid = sch->schid.ssid;
934 priv->schid = sch->schid;
935 priv->state = DEV_STATE_NOT_OPER;
936 INIT_LIST_HEAD(&priv->cmb_list);
937 init_waitqueue_head(&priv->wait_q);
938 init_timer(&priv->timer);
939
940 /* Increase counter of devices currently in recognition. */ 943 /* Increase counter of devices currently in recognition. */
941 atomic_inc(&ccw_device_init_count); 944 atomic_inc(&ccw_device_init_count);
942 945
943 /* Start async. device sensing. */ 946 /* Start async. device sensing. */
944 spin_lock_irq(sch->lock); 947 spin_lock_irq(sch->lock);
945 sch_set_cdev(sch, cdev);
946 ccw_device_recognition(cdev); 948 ccw_device_recognition(cdev);
947 spin_unlock_irq(sch->lock); 949 spin_unlock_irq(sch->lock);
948} 950}
@@ -1083,7 +1085,7 @@ static int io_subchannel_probe(struct subchannel *sch)
1083 dev_set_uevent_suppress(&sch->dev, 0); 1085 dev_set_uevent_suppress(&sch->dev, 0);
1084 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 1086 kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
1085 cdev = sch_get_cdev(sch); 1087 cdev = sch_get_cdev(sch);
1086 rc = ccw_device_register(cdev); 1088 rc = ccw_device_add(cdev);
1087 if (rc) { 1089 if (rc) {
1088 /* Release online reference. */ 1090 /* Release online reference. */
1089 put_device(&cdev->dev); 1091 put_device(&cdev->dev);
@@ -1597,7 +1599,6 @@ int __init ccw_device_enable_console(struct ccw_device *cdev)
1597 if (rc) 1599 if (rc)
1598 return rc; 1600 return rc;
1599 sch->driver = &io_subchannel_driver; 1601 sch->driver = &io_subchannel_driver;
1600 sch_set_cdev(sch, cdev);
1601 io_subchannel_recog(cdev, sch); 1602 io_subchannel_recog(cdev, sch);
1602 /* Now wait for the async. recognition to come to an end. */ 1603 /* Now wait for the async. recognition to come to an end. */
1603 spin_lock_irq(cdev->ccwlock); 1604 spin_lock_irq(cdev->ccwlock);
@@ -1639,6 +1640,7 @@ struct ccw_device * __init ccw_device_create_console(struct ccw_driver *drv)
1639 put_device(&sch->dev); 1640 put_device(&sch->dev);
1640 return ERR_PTR(-ENOMEM); 1641 return ERR_PTR(-ENOMEM);
1641 } 1642 }
1643 set_io_private(sch, io_priv);
1642 cdev = io_subchannel_create_ccwdev(sch); 1644 cdev = io_subchannel_create_ccwdev(sch);
1643 if (IS_ERR(cdev)) { 1645 if (IS_ERR(cdev)) {
1644 put_device(&sch->dev); 1646 put_device(&sch->dev);
@@ -1646,7 +1648,6 @@ struct ccw_device * __init ccw_device_create_console(struct ccw_driver *drv)
1646 return cdev; 1648 return cdev;
1647 } 1649 }
1648 cdev->drv = drv; 1650 cdev->drv = drv;
1649 set_io_private(sch, io_priv);
1650 ccw_device_set_int_class(cdev); 1651 ccw_device_set_int_class(cdev);
1651 return cdev; 1652 return cdev;
1652} 1653}
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index 4221b02085ad..f1f3baa8e6e4 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -7,6 +7,7 @@
7#include <linux/debugfs.h> 7#include <linux/debugfs.h>
8#include <linux/uaccess.h> 8#include <linux/uaccess.h>
9#include <linux/export.h> 9#include <linux/export.h>
10#include <linux/slab.h>
10#include <asm/debug.h> 11#include <asm/debug.h>
11#include "qdio_debug.h" 12#include "qdio_debug.h"
12#include "qdio.h" 13#include "qdio.h"
@@ -16,11 +17,51 @@ debug_info_t *qdio_dbf_error;
16 17
17static struct dentry *debugfs_root; 18static struct dentry *debugfs_root;
18#define QDIO_DEBUGFS_NAME_LEN 10 19#define QDIO_DEBUGFS_NAME_LEN 10
20#define QDIO_DBF_NAME_LEN 20
19 21
20void qdio_allocate_dbf(struct qdio_initialize *init_data, 22struct qdio_dbf_entry {
23 char dbf_name[QDIO_DBF_NAME_LEN];
24 debug_info_t *dbf_info;
25 struct list_head dbf_list;
26};
27
28static LIST_HEAD(qdio_dbf_list);
29static DEFINE_MUTEX(qdio_dbf_list_mutex);
30
31static debug_info_t *qdio_get_dbf_entry(char *name)
32{
33 struct qdio_dbf_entry *entry;
34 debug_info_t *rc = NULL;
35
36 mutex_lock(&qdio_dbf_list_mutex);
37 list_for_each_entry(entry, &qdio_dbf_list, dbf_list) {
38 if (strcmp(entry->dbf_name, name) == 0) {
39 rc = entry->dbf_info;
40 break;
41 }
42 }
43 mutex_unlock(&qdio_dbf_list_mutex);
44 return rc;
45}
46
47static void qdio_clear_dbf_list(void)
48{
49 struct qdio_dbf_entry *entry, *tmp;
50
51 mutex_lock(&qdio_dbf_list_mutex);
52 list_for_each_entry_safe(entry, tmp, &qdio_dbf_list, dbf_list) {
53 list_del(&entry->dbf_list);
54 debug_unregister(entry->dbf_info);
55 kfree(entry);
56 }
57 mutex_unlock(&qdio_dbf_list_mutex);
58}
59
60int qdio_allocate_dbf(struct qdio_initialize *init_data,
21 struct qdio_irq *irq_ptr) 61 struct qdio_irq *irq_ptr)
22{ 62{
23 char text[20]; 63 char text[QDIO_DBF_NAME_LEN];
64 struct qdio_dbf_entry *new_entry;
24 65
25 DBF_EVENT("qfmt:%1d", init_data->q_format); 66 DBF_EVENT("qfmt:%1d", init_data->q_format);
26 DBF_HEX(init_data->adapter_name, 8); 67 DBF_HEX(init_data->adapter_name, 8);
@@ -38,11 +79,34 @@ void qdio_allocate_dbf(struct qdio_initialize *init_data,
38 DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); 79 DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr);
39 80
40 /* allocate trace view for the interface */ 81 /* allocate trace view for the interface */
41 snprintf(text, 20, "qdio_%s", dev_name(&init_data->cdev->dev)); 82 snprintf(text, QDIO_DBF_NAME_LEN, "qdio_%s",
42 irq_ptr->debug_area = debug_register(text, 2, 1, 16); 83 dev_name(&init_data->cdev->dev));
43 debug_register_view(irq_ptr->debug_area, &debug_hex_ascii_view); 84 irq_ptr->debug_area = qdio_get_dbf_entry(text);
44 debug_set_level(irq_ptr->debug_area, DBF_WARN); 85 if (irq_ptr->debug_area)
45 DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); 86 DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf reused");
87 else {
88 irq_ptr->debug_area = debug_register(text, 2, 1, 16);
89 if (!irq_ptr->debug_area)
90 return -ENOMEM;
91 if (debug_register_view(irq_ptr->debug_area,
92 &debug_hex_ascii_view)) {
93 debug_unregister(irq_ptr->debug_area);
94 return -ENOMEM;
95 }
96 debug_set_level(irq_ptr->debug_area, DBF_WARN);
97 DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created");
98 new_entry = kzalloc(sizeof(struct qdio_dbf_entry), GFP_KERNEL);
99 if (!new_entry) {
100 debug_unregister(irq_ptr->debug_area);
101 return -ENOMEM;
102 }
103 strlcpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN);
104 new_entry->dbf_info = irq_ptr->debug_area;
105 mutex_lock(&qdio_dbf_list_mutex);
106 list_add(&new_entry->dbf_list, &qdio_dbf_list);
107 mutex_unlock(&qdio_dbf_list_mutex);
108 }
109 return 0;
46} 110}
47 111
48static int qstat_show(struct seq_file *m, void *v) 112static int qstat_show(struct seq_file *m, void *v)
@@ -300,6 +364,7 @@ int __init qdio_debug_init(void)
300 364
301void qdio_debug_exit(void) 365void qdio_debug_exit(void)
302{ 366{
367 qdio_clear_dbf_list();
303 debugfs_remove(debugfs_root); 368 debugfs_remove(debugfs_root);
304 if (qdio_dbf_setup) 369 if (qdio_dbf_setup)
305 debug_unregister(qdio_dbf_setup); 370 debug_unregister(qdio_dbf_setup);
diff --git a/drivers/s390/cio/qdio_debug.h b/drivers/s390/cio/qdio_debug.h
index dfac9bfefea3..f33ce8577619 100644
--- a/drivers/s390/cio/qdio_debug.h
+++ b/drivers/s390/cio/qdio_debug.h
@@ -75,7 +75,7 @@ static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr,
75 } 75 }
76} 76}
77 77
78void qdio_allocate_dbf(struct qdio_initialize *init_data, 78int qdio_allocate_dbf(struct qdio_initialize *init_data,
79 struct qdio_irq *irq_ptr); 79 struct qdio_irq *irq_ptr);
80void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, 80void qdio_setup_debug_entries(struct qdio_irq *irq_ptr,
81 struct ccw_device *cdev); 81 struct ccw_device *cdev);
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index 77466c4faabb..848e3b64ea6e 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -409,17 +409,16 @@ static inline void qdio_stop_polling(struct qdio_q *q)
409 set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); 409 set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT);
410} 410}
411 411
412static inline void account_sbals(struct qdio_q *q, int count) 412static inline void account_sbals(struct qdio_q *q, unsigned int count)
413{ 413{
414 int pos = 0; 414 int pos;
415 415
416 q->q_stats.nr_sbal_total += count; 416 q->q_stats.nr_sbal_total += count;
417 if (count == QDIO_MAX_BUFFERS_MASK) { 417 if (count == QDIO_MAX_BUFFERS_MASK) {
418 q->q_stats.nr_sbals[7]++; 418 q->q_stats.nr_sbals[7]++;
419 return; 419 return;
420 } 420 }
421 while (count >>= 1) 421 pos = ilog2(count);
422 pos++;
423 q->q_stats.nr_sbals[pos]++; 422 q->q_stats.nr_sbals[pos]++;
424} 423}
425 424
@@ -1234,12 +1233,10 @@ int qdio_free(struct ccw_device *cdev)
1234 return -ENODEV; 1233 return -ENODEV;
1235 1234
1236 DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no); 1235 DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no);
1236 DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf abandoned");
1237 mutex_lock(&irq_ptr->setup_mutex); 1237 mutex_lock(&irq_ptr->setup_mutex);
1238 1238
1239 if (irq_ptr->debug_area != NULL) { 1239 irq_ptr->debug_area = NULL;
1240 debug_unregister(irq_ptr->debug_area);
1241 irq_ptr->debug_area = NULL;
1242 }
1243 cdev->private->qdio_data = NULL; 1240 cdev->private->qdio_data = NULL;
1244 mutex_unlock(&irq_ptr->setup_mutex); 1241 mutex_unlock(&irq_ptr->setup_mutex);
1245 1242
@@ -1276,7 +1273,8 @@ int qdio_allocate(struct qdio_initialize *init_data)
1276 goto out_err; 1273 goto out_err;
1277 1274
1278 mutex_init(&irq_ptr->setup_mutex); 1275 mutex_init(&irq_ptr->setup_mutex);
1279 qdio_allocate_dbf(init_data, irq_ptr); 1276 if (qdio_allocate_dbf(init_data, irq_ptr))
1277 goto out_rel;
1280 1278
1281 /* 1279 /*
1282 * Allocate a page for the chsc calls in qdio_establish. 1280 * Allocate a page for the chsc calls in qdio_establish.
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 8eec1653c9cc..69ef4f8cfac8 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -77,12 +77,12 @@ MODULE_ALIAS("z90crypt");
77 * Module parameter 77 * Module parameter
78 */ 78 */
79int ap_domain_index = -1; /* Adjunct Processor Domain Index */ 79int ap_domain_index = -1; /* Adjunct Processor Domain Index */
80module_param_named(domain, ap_domain_index, int, 0000); 80module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP);
81MODULE_PARM_DESC(domain, "domain index for ap devices"); 81MODULE_PARM_DESC(domain, "domain index for ap devices");
82EXPORT_SYMBOL(ap_domain_index); 82EXPORT_SYMBOL(ap_domain_index);
83 83
84static int ap_thread_flag = 0; 84static int ap_thread_flag = 0;
85module_param_named(poll_thread, ap_thread_flag, int, 0000); 85module_param_named(poll_thread, ap_thread_flag, int, S_IRUSR|S_IRGRP);
86MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off)."); 86MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off).");
87 87
88static struct device *ap_root_device = NULL; 88static struct device *ap_root_device = NULL;
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 5222ebe15705..0e18c5dcd91f 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -356,7 +356,7 @@ struct zcrypt_ops *zcrypt_msgtype_request(unsigned char *name, int variant)
356 356
357 zops = __ops_lookup(name, variant); 357 zops = __ops_lookup(name, variant);
358 if (!zops) { 358 if (!zops) {
359 request_module(name); 359 request_module("%s", name);
360 zops = __ops_lookup(name, variant); 360 zops = __ops_lookup(name, variant);
361 } 361 }
362 if ((!zops) || (!try_module_get(zops->owner))) 362 if ((!zops) || (!try_module_get(zops->owner)))
diff --git a/drivers/scsi/mvsas/mv_94xx.c b/drivers/scsi/mvsas/mv_94xx.c
index 1e4479f3331a..9270d15ff1a4 100644
--- a/drivers/scsi/mvsas/mv_94xx.c
+++ b/drivers/scsi/mvsas/mv_94xx.c
@@ -564,7 +564,7 @@ static void mvs_94xx_interrupt_enable(struct mvs_info *mvi)
564 u32 tmp; 564 u32 tmp;
565 565
566 tmp = mr32(MVS_GBL_CTL); 566 tmp = mr32(MVS_GBL_CTL);
567 tmp |= (IRQ_SAS_A | IRQ_SAS_B); 567 tmp |= (MVS_IRQ_SAS_A | MVS_IRQ_SAS_B);
568 mw32(MVS_GBL_INT_STAT, tmp); 568 mw32(MVS_GBL_INT_STAT, tmp);
569 writel(tmp, regs + 0x0C); 569 writel(tmp, regs + 0x0C);
570 writel(tmp, regs + 0x10); 570 writel(tmp, regs + 0x10);
@@ -580,7 +580,7 @@ static void mvs_94xx_interrupt_disable(struct mvs_info *mvi)
580 580
581 tmp = mr32(MVS_GBL_CTL); 581 tmp = mr32(MVS_GBL_CTL);
582 582
583 tmp &= ~(IRQ_SAS_A | IRQ_SAS_B); 583 tmp &= ~(MVS_IRQ_SAS_A | MVS_IRQ_SAS_B);
584 mw32(MVS_GBL_INT_STAT, tmp); 584 mw32(MVS_GBL_INT_STAT, tmp);
585 writel(tmp, regs + 0x0C); 585 writel(tmp, regs + 0x0C);
586 writel(tmp, regs + 0x10); 586 writel(tmp, regs + 0x10);
@@ -596,7 +596,7 @@ static u32 mvs_94xx_isr_status(struct mvs_info *mvi, int irq)
596 if (!(mvi->flags & MVF_FLAG_SOC)) { 596 if (!(mvi->flags & MVF_FLAG_SOC)) {
597 stat = mr32(MVS_GBL_INT_STAT); 597 stat = mr32(MVS_GBL_INT_STAT);
598 598
599 if (!(stat & (IRQ_SAS_A | IRQ_SAS_B))) 599 if (!(stat & (MVS_IRQ_SAS_A | MVS_IRQ_SAS_B)))
600 return 0; 600 return 0;
601 } 601 }
602 return stat; 602 return stat;
@@ -606,8 +606,8 @@ static irqreturn_t mvs_94xx_isr(struct mvs_info *mvi, int irq, u32 stat)
606{ 606{
607 void __iomem *regs = mvi->regs; 607 void __iomem *regs = mvi->regs;
608 608
609 if (((stat & IRQ_SAS_A) && mvi->id == 0) || 609 if (((stat & MVS_IRQ_SAS_A) && mvi->id == 0) ||
610 ((stat & IRQ_SAS_B) && mvi->id == 1)) { 610 ((stat & MVS_IRQ_SAS_B) && mvi->id == 1)) {
611 mw32_f(MVS_INT_STAT, CINT_DONE); 611 mw32_f(MVS_INT_STAT, CINT_DONE);
612 612
613 spin_lock(&mvi->lock); 613 spin_lock(&mvi->lock);
diff --git a/drivers/scsi/mvsas/mv_94xx.h b/drivers/scsi/mvsas/mv_94xx.h
index 487aa6f97412..14e197497b46 100644
--- a/drivers/scsi/mvsas/mv_94xx.h
+++ b/drivers/scsi/mvsas/mv_94xx.h
@@ -150,35 +150,35 @@ enum chip_register_bits {
150 150
151enum pci_interrupt_cause { 151enum pci_interrupt_cause {
152 /* MAIN_IRQ_CAUSE (R10200) Bits*/ 152 /* MAIN_IRQ_CAUSE (R10200) Bits*/
153 IRQ_COM_IN_I2O_IOP0 = (1 << 0), 153 MVS_IRQ_COM_IN_I2O_IOP0 = (1 << 0),
154 IRQ_COM_IN_I2O_IOP1 = (1 << 1), 154 MVS_IRQ_COM_IN_I2O_IOP1 = (1 << 1),
155 IRQ_COM_IN_I2O_IOP2 = (1 << 2), 155 MVS_IRQ_COM_IN_I2O_IOP2 = (1 << 2),
156 IRQ_COM_IN_I2O_IOP3 = (1 << 3), 156 MVS_IRQ_COM_IN_I2O_IOP3 = (1 << 3),
157 IRQ_COM_OUT_I2O_HOS0 = (1 << 4), 157 MVS_IRQ_COM_OUT_I2O_HOS0 = (1 << 4),
158 IRQ_COM_OUT_I2O_HOS1 = (1 << 5), 158 MVS_IRQ_COM_OUT_I2O_HOS1 = (1 << 5),
159 IRQ_COM_OUT_I2O_HOS2 = (1 << 6), 159 MVS_IRQ_COM_OUT_I2O_HOS2 = (1 << 6),
160 IRQ_COM_OUT_I2O_HOS3 = (1 << 7), 160 MVS_IRQ_COM_OUT_I2O_HOS3 = (1 << 7),
161 IRQ_PCIF_TO_CPU_DRBL0 = (1 << 8), 161 MVS_IRQ_PCIF_TO_CPU_DRBL0 = (1 << 8),
162 IRQ_PCIF_TO_CPU_DRBL1 = (1 << 9), 162 MVS_IRQ_PCIF_TO_CPU_DRBL1 = (1 << 9),
163 IRQ_PCIF_TO_CPU_DRBL2 = (1 << 10), 163 MVS_IRQ_PCIF_TO_CPU_DRBL2 = (1 << 10),
164 IRQ_PCIF_TO_CPU_DRBL3 = (1 << 11), 164 MVS_IRQ_PCIF_TO_CPU_DRBL3 = (1 << 11),
165 IRQ_PCIF_DRBL0 = (1 << 12), 165 MVS_IRQ_PCIF_DRBL0 = (1 << 12),
166 IRQ_PCIF_DRBL1 = (1 << 13), 166 MVS_IRQ_PCIF_DRBL1 = (1 << 13),
167 IRQ_PCIF_DRBL2 = (1 << 14), 167 MVS_IRQ_PCIF_DRBL2 = (1 << 14),
168 IRQ_PCIF_DRBL3 = (1 << 15), 168 MVS_IRQ_PCIF_DRBL3 = (1 << 15),
169 IRQ_XOR_A = (1 << 16), 169 MVS_IRQ_XOR_A = (1 << 16),
170 IRQ_XOR_B = (1 << 17), 170 MVS_IRQ_XOR_B = (1 << 17),
171 IRQ_SAS_A = (1 << 18), 171 MVS_IRQ_SAS_A = (1 << 18),
172 IRQ_SAS_B = (1 << 19), 172 MVS_IRQ_SAS_B = (1 << 19),
173 IRQ_CPU_CNTRL = (1 << 20), 173 MVS_IRQ_CPU_CNTRL = (1 << 20),
174 IRQ_GPIO = (1 << 21), 174 MVS_IRQ_GPIO = (1 << 21),
175 IRQ_UART = (1 << 22), 175 MVS_IRQ_UART = (1 << 22),
176 IRQ_SPI = (1 << 23), 176 MVS_IRQ_SPI = (1 << 23),
177 IRQ_I2C = (1 << 24), 177 MVS_IRQ_I2C = (1 << 24),
178 IRQ_SGPIO = (1 << 25), 178 MVS_IRQ_SGPIO = (1 << 25),
179 IRQ_COM_ERR = (1 << 29), 179 MVS_IRQ_COM_ERR = (1 << 29),
180 IRQ_I2O_ERR = (1 << 30), 180 MVS_IRQ_I2O_ERR = (1 << 30),
181 IRQ_PCIE_ERR = (1 << 31), 181 MVS_IRQ_PCIE_ERR = (1 << 31),
182}; 182};
183 183
184union reg_phy_cfg { 184union reg_phy_cfg {
diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c
index f6759dc0153b..c41ff148a2b4 100644
--- a/drivers/spi/spi-pxa2xx-dma.c
+++ b/drivers/spi/spi-pxa2xx-dma.c
@@ -368,7 +368,7 @@ int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
368 * otherwise we use the default. Also we use the default FIFO 368 * otherwise we use the default. Also we use the default FIFO
369 * thresholds for now. 369 * thresholds for now.
370 */ 370 */
371 *burst_code = chip_info ? chip_info->dma_burst_size : 16; 371 *burst_code = chip_info ? chip_info->dma_burst_size : 1;
372 *threshold = SSCR1_RxTresh(RX_THRESH_DFLT) 372 *threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
373 | SSCR1_TxTresh(TX_THRESH_DFLT); 373 | SSCR1_TxTresh(TX_THRESH_DFLT);
374 374
diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
index 2c617834dc46..c341ac11c5a3 100644
--- a/drivers/staging/android/timed_output.c
+++ b/drivers/staging/android/timed_output.c
@@ -97,7 +97,6 @@ void timed_output_dev_unregister(struct timed_output_dev *tdev)
97{ 97{
98 tdev->enable(tdev, 0); 98 tdev->enable(tdev, 0);
99 device_destroy(timed_output_class, MKDEV(0, tdev->index)); 99 device_destroy(timed_output_class, MKDEV(0, tdev->index));
100 dev_set_drvdata(tdev->dev, NULL);
101} 100}
102EXPORT_SYMBOL_GPL(timed_output_dev_unregister); 101EXPORT_SYMBOL_GPL(timed_output_dev_unregister);
103 102
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 3a07f0b9afd5..8d992a87d3c4 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -653,6 +653,7 @@ config COMEDI_ADDI_APCI_1516
653 653
654config COMEDI_ADDI_APCI_1564 654config COMEDI_ADDI_APCI_1564
655 tristate "ADDI-DATA APCI_1564 support" 655 tristate "ADDI-DATA APCI_1564 support"
656 select COMEDI_ADDI_WATCHDOG
656 ---help--- 657 ---help---
657 Enable support for ADDI-DATA APCI_1564 cards 658 Enable support for ADDI-DATA APCI_1564 cards
658 659
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index b36feb080cba..fa38be0982f9 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -36,10 +36,11 @@ config IIO_SIMPLE_DUMMY_EVENTS
36 Add some dummy events to the simple dummy driver. 36 Add some dummy events to the simple dummy driver.
37 37
38config IIO_SIMPLE_DUMMY_BUFFER 38config IIO_SIMPLE_DUMMY_BUFFER
39 boolean "Buffered capture support" 39 boolean "Buffered capture support"
40 select IIO_KFIFO_BUF 40 select IIO_BUFFER
41 help 41 select IIO_KFIFO_BUF
42 Add buffered data capture to the simple dummy driver. 42 help
43 Add buffered data capture to the simple dummy driver.
43 44
44endif # IIO_SIMPLE_DUMMY 45endif # IIO_SIMPLE_DUMMY
45 46
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index d8619993c6ff..468327f4a753 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -846,6 +846,14 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val)
846 LRADC_CTRL1); 846 LRADC_CTRL1);
847 mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); 847 mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);
848 848
849 /* Enable / disable the divider per requirement */
850 if (test_bit(chan, &lradc->is_divided))
851 mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
852 LRADC_CTRL2);
853 else
854 mxs_lradc_reg_clear(lradc,
855 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2);
856
849 /* Clean the slot's previous content, then set new one. */ 857 /* Clean the slot's previous content, then set new one. */
850 mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), 858 mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0),
851 LRADC_CTRL4); 859 LRADC_CTRL4);
@@ -961,15 +969,11 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev,
961 if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer && 969 if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer &&
962 val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) { 970 val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) {
963 /* divider by two disabled */ 971 /* divider by two disabled */
964 writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
965 lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR);
966 clear_bit(chan->channel, &lradc->is_divided); 972 clear_bit(chan->channel, &lradc->is_divided);
967 ret = 0; 973 ret = 0;
968 } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer && 974 } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer &&
969 val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) { 975 val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) {
970 /* divider by two enabled */ 976 /* divider by two enabled */
971 writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
972 lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET);
973 set_bit(chan->channel, &lradc->is_divided); 977 set_bit(chan->channel, &lradc->is_divided);
974 ret = 0; 978 ret = 0;
975 } 979 }
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index 9e0f2a9c73ae..ab338e3ddd05 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -667,9 +667,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
667 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = 667 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
668 chip->tsl2x7x_settings.prox_pulse_count; 668 chip->tsl2x7x_settings.prox_pulse_count;
669 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = 669 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
670 chip->tsl2x7x_settings.prox_thres_low; 670 (chip->tsl2x7x_settings.prox_thres_low) & 0xFF;
671 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
672 (chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF;
671 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = 673 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
672 chip->tsl2x7x_settings.prox_thres_high; 674 (chip->tsl2x7x_settings.prox_thres_high) & 0xFF;
675 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
676 (chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF;
673 677
674 /* and make sure we're not already on */ 678 /* and make sure we're not already on */
675 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { 679 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c
index b5678328fc40..4ca61afdf622 100644
--- a/drivers/staging/imx-drm/parallel-display.c
+++ b/drivers/staging/imx-drm/parallel-display.c
@@ -173,6 +173,13 @@ static int imx_pd_register(struct drm_device *drm,
173 if (ret) 173 if (ret)
174 return ret; 174 return ret;
175 175
176 /* set the connector's dpms to OFF so that
177 * drm_helper_connector_dpms() won't return
178 * immediately since the current state is ON
179 * at this point.
180 */
181 imxpd->connector.dpms = DRM_MODE_DPMS_OFF;
182
176 drm_encoder_helper_add(&imxpd->encoder, &imx_pd_encoder_helper_funcs); 183 drm_encoder_helper_add(&imxpd->encoder, &imx_pd_encoder_helper_funcs);
177 drm_encoder_init(drm, &imxpd->encoder, &imx_pd_encoder_funcs, 184 drm_encoder_init(drm, &imxpd->encoder, &imx_pd_encoder_funcs,
178 DRM_MODE_ENCODER_NONE); 185 DRM_MODE_ENCODER_NONE);
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index f95569dedc88..f44f1ba762c3 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1214,15 +1214,16 @@ static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c)
1214{ 1214{
1215 struct n_tty_data *ldata = tty->disc_data; 1215 struct n_tty_data *ldata = tty->disc_data;
1216 1216
1217 if (I_IGNPAR(tty)) 1217 if (I_INPCK(tty)) {
1218 return; 1218 if (I_IGNPAR(tty))
1219 if (I_PARMRK(tty)) { 1219 return;
1220 put_tty_queue('\377', ldata); 1220 if (I_PARMRK(tty)) {
1221 put_tty_queue('\0', ldata); 1221 put_tty_queue('\377', ldata);
1222 put_tty_queue(c, ldata); 1222 put_tty_queue('\0', ldata);
1223 } else if (I_INPCK(tty)) 1223 put_tty_queue(c, ldata);
1224 put_tty_queue('\0', ldata); 1224 } else
1225 else 1225 put_tty_queue('\0', ldata);
1226 } else
1226 put_tty_queue(c, ldata); 1227 put_tty_queue(c, ldata);
1227 if (waitqueue_active(&tty->read_wait)) 1228 if (waitqueue_active(&tty->read_wait))
1228 wake_up_interruptible(&tty->read_wait); 1229 wake_up_interruptible(&tty->read_wait);
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 27f7ad6b74c1..7a91c6d1eb7d 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -2357,7 +2357,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2357 port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 2357 port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2358 if (termios->c_iflag & INPCK) 2358 if (termios->c_iflag & INPCK)
2359 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE; 2359 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2360 if (termios->c_iflag & (BRKINT | PARMRK)) 2360 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
2361 port->read_status_mask |= UART_LSR_BI; 2361 port->read_status_mask |= UART_LSR_BI;
2362 2362
2363 /* 2363 /*
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index cfef801a49d4..4858b8a99d3b 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -144,8 +144,11 @@ static int __init early_serial8250_setup(struct earlycon_device *device,
144 if (!(device->port.membase || device->port.iobase)) 144 if (!(device->port.membase || device->port.iobase))
145 return 0; 145 return 0;
146 146
147 if (!device->baud) 147 if (!device->baud) {
148 device->baud = probe_baud(&device->port); 148 device->baud = probe_baud(&device->port);
149 snprintf(device->options, sizeof(device->options), "%u",
150 device->baud);
151 }
149 152
150 init_port(device); 153 init_port(device);
151 154
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 501667e3e3f5..323376668b72 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -185,6 +185,12 @@ static void altera_uart_set_termios(struct uart_port *port,
185 uart_update_timeout(port, termios->c_cflag, baud); 185 uart_update_timeout(port, termios->c_cflag, baud);
186 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); 186 altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG);
187 spin_unlock_irqrestore(&port->lock, flags); 187 spin_unlock_irqrestore(&port->lock, flags);
188
189 /*
190 * FIXME: port->read_status_mask and port->ignore_status_mask
191 * need to be initialized based on termios settings for
192 * INPCK, IGNBRK, IGNPAR, PARMRK, BRKINT
193 */
188} 194}
189 195
190static void altera_uart_rx_chars(struct altera_uart *pp) 196static void altera_uart_rx_chars(struct altera_uart *pp)
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 01c9e72433e1..971af1e22d0f 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -420,7 +420,7 @@ pl010_set_termios(struct uart_port *port, struct ktermios *termios,
420 uap->port.read_status_mask = UART01x_RSR_OE; 420 uap->port.read_status_mask = UART01x_RSR_OE;
421 if (termios->c_iflag & INPCK) 421 if (termios->c_iflag & INPCK)
422 uap->port.read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE; 422 uap->port.read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE;
423 if (termios->c_iflag & (BRKINT | PARMRK)) 423 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
424 uap->port.read_status_mask |= UART01x_RSR_BE; 424 uap->port.read_status_mask |= UART01x_RSR_BE;
425 425
426 /* 426 /*
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 908a6e3142a2..0e26dcbd5ea4 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1744,7 +1744,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
1744 port->read_status_mask = UART011_DR_OE | 255; 1744 port->read_status_mask = UART011_DR_OE | 255;
1745 if (termios->c_iflag & INPCK) 1745 if (termios->c_iflag & INPCK)
1746 port->read_status_mask |= UART011_DR_FE | UART011_DR_PE; 1746 port->read_status_mask |= UART011_DR_FE | UART011_DR_PE;
1747 if (termios->c_iflag & (BRKINT | PARMRK)) 1747 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1748 port->read_status_mask |= UART011_DR_BE; 1748 port->read_status_mask |= UART011_DR_BE;
1749 1749
1750 /* 1750 /*
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 3fceae099c44..c4f750314100 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1932,7 +1932,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
1932 port->read_status_mask = ATMEL_US_OVRE; 1932 port->read_status_mask = ATMEL_US_OVRE;
1933 if (termios->c_iflag & INPCK) 1933 if (termios->c_iflag & INPCK)
1934 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); 1934 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE);
1935 if (termios->c_iflag & (BRKINT | PARMRK)) 1935 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1936 port->read_status_mask |= ATMEL_US_RXBRK; 1936 port->read_status_mask |= ATMEL_US_RXBRK;
1937 1937
1938 if (atmel_use_pdc_rx(port)) 1938 if (atmel_use_pdc_rx(port))
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index a47421e4627c..231519022b73 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -567,7 +567,7 @@ static void bcm_uart_set_termios(struct uart_port *port,
567 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK; 567 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK;
568 port->read_status_mask |= UART_FIFO_PARERR_MASK; 568 port->read_status_mask |= UART_FIFO_PARERR_MASK;
569 } 569 }
570 if (new->c_iflag & (BRKINT)) 570 if (new->c_iflag & (IGNBRK | BRKINT))
571 port->read_status_mask |= UART_FIFO_BRKDET_MASK; 571 port->read_status_mask |= UART_FIFO_BRKDET_MASK;
572 572
573 port->ignore_status_mask = 0; 573 port->ignore_status_mask = 0;
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 869ceba2ec57..ac86a20992e9 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -833,7 +833,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
833 port->read_status_mask = OE; 833 port->read_status_mask = OE;
834 if (termios->c_iflag & INPCK) 834 if (termios->c_iflag & INPCK)
835 port->read_status_mask |= (FE | PE); 835 port->read_status_mask |= (FE | PE);
836 if (termios->c_iflag & (BRKINT | PARMRK)) 836 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
837 port->read_status_mask |= BI; 837 port->read_status_mask |= BI;
838 838
839 /* 839 /*
diff --git a/drivers/tty/serial/dz.c b/drivers/tty/serial/dz.c
index 2f2b2e538a54..cdbbc788230a 100644
--- a/drivers/tty/serial/dz.c
+++ b/drivers/tty/serial/dz.c
@@ -625,7 +625,7 @@ static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
625 dport->port.read_status_mask = DZ_OERR; 625 dport->port.read_status_mask = DZ_OERR;
626 if (termios->c_iflag & INPCK) 626 if (termios->c_iflag & INPCK)
627 dport->port.read_status_mask |= DZ_FERR | DZ_PERR; 627 dport->port.read_status_mask |= DZ_FERR | DZ_PERR;
628 if (termios->c_iflag & (BRKINT | PARMRK)) 628 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
629 dport->port.read_status_mask |= DZ_BREAK; 629 dport->port.read_status_mask |= DZ_BREAK;
630 630
631 /* characters to ignore */ 631 /* characters to ignore */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 5131b5ee6164..a514ee6f5406 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -25,7 +25,7 @@
25#include <asm/serial.h> 25#include <asm/serial.h>
26 26
27static struct console early_con = { 27static struct console early_con = {
28 .name = "earlycon", 28 .name = "uart", /* 8250 console switch requires this name */
29 .flags = CON_PRINTBUFFER | CON_BOOT, 29 .flags = CON_PRINTBUFFER | CON_BOOT,
30 .index = -1, 30 .index = -1,
31}; 31};
diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index b373f6416e8c..3b0ee9afd76f 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -407,7 +407,7 @@ static void efm32_uart_set_termios(struct uart_port *port,
407 if (new->c_iflag & INPCK) 407 if (new->c_iflag & INPCK)
408 port->read_status_mask |= 408 port->read_status_mask |=
409 UARTn_RXDATAX_FERR | UARTn_RXDATAX_PERR; 409 UARTn_RXDATAX_FERR | UARTn_RXDATAX_PERR;
410 if (new->c_iflag & (BRKINT | PARMRK)) 410 if (new->c_iflag & (IGNBRK | BRKINT | PARMRK))
411 port->read_status_mask |= SW_UARTn_RXDATAX_BERR; 411 port->read_status_mask |= SW_UARTn_RXDATAX_BERR;
412 412
413 port->ignore_status_mask = 0; 413 port->ignore_status_mask = 0;
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index c5eb897de9de..49385c86cfba 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -902,7 +902,7 @@ lpuart_set_termios(struct uart_port *port, struct ktermios *termios,
902 sport->port.read_status_mask = 0; 902 sport->port.read_status_mask = 0;
903 if (termios->c_iflag & INPCK) 903 if (termios->c_iflag & INPCK)
904 sport->port.read_status_mask |= (UARTSR1_FE | UARTSR1_PE); 904 sport->port.read_status_mask |= (UARTSR1_FE | UARTSR1_PE);
905 if (termios->c_iflag & (BRKINT | PARMRK)) 905 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
906 sport->port.read_status_mask |= UARTSR1_FE; 906 sport->port.read_status_mask |= UARTSR1_FE;
907 907
908 /* characters to ignore */ 908 /* characters to ignore */
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 1d9420548e16..1efd4c36ba0c 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -850,7 +850,7 @@ ip22zilog_convert_to_zs(struct uart_ip22zilog_port *up, unsigned int cflag,
850 up->port.read_status_mask = Rx_OVR; 850 up->port.read_status_mask = Rx_OVR;
851 if (iflag & INPCK) 851 if (iflag & INPCK)
852 up->port.read_status_mask |= CRC_ERR | PAR_ERR; 852 up->port.read_status_mask |= CRC_ERR | PAR_ERR;
853 if (iflag & (BRKINT | PARMRK)) 853 if (iflag & (IGNBRK | BRKINT | PARMRK))
854 up->port.read_status_mask |= BRK_ABRT; 854 up->port.read_status_mask |= BRK_ABRT;
855 855
856 up->port.ignore_status_mask = 0; 856 up->port.ignore_status_mask = 0;
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index 9cd9b4eba9fc..68f2c53e0b54 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -737,7 +737,7 @@ static void m32r_sio_set_termios(struct uart_port *port,
737 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 737 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
738 if (termios->c_iflag & INPCK) 738 if (termios->c_iflag & INPCK)
739 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; 739 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
740 if (termios->c_iflag & (BRKINT | PARMRK)) 740 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
741 up->port.read_status_mask |= UART_LSR_BI; 741 up->port.read_status_mask |= UART_LSR_BI;
742 742
743 /* 743 /*
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 2a99d0c61b9e..ba285cd45b59 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -835,7 +835,7 @@ static void max310x_set_termios(struct uart_port *port,
835 if (termios->c_iflag & INPCK) 835 if (termios->c_iflag & INPCK)
836 port->read_status_mask |= MAX310X_LSR_RXPAR_BIT | 836 port->read_status_mask |= MAX310X_LSR_RXPAR_BIT |
837 MAX310X_LSR_FRERR_BIT; 837 MAX310X_LSR_FRERR_BIT;
838 if (termios->c_iflag & (BRKINT | PARMRK)) 838 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
839 port->read_status_mask |= MAX310X_LSR_RXBRK_BIT; 839 port->read_status_mask |= MAX310X_LSR_RXBRK_BIT;
840 840
841 /* Set status ignore mask */ 841 /* Set status ignore mask */
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 0edfaf8cd269..a6f085717f94 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -248,6 +248,12 @@ static void mcf_set_termios(struct uart_port *port, struct ktermios *termios,
248 mr1 |= MCFUART_MR1_PARITYNONE; 248 mr1 |= MCFUART_MR1_PARITYNONE;
249 } 249 }
250 250
251 /*
252 * FIXME: port->read_status_mask and port->ignore_status_mask
253 * need to be initialized based on termios settings for
254 * INPCK, IGNBRK, IGNPAR, PARMRK, BRKINT
255 */
256
251 if (termios->c_cflag & CSTOPB) 257 if (termios->c_cflag & CSTOPB)
252 mr2 |= MCFUART_MR2_STOP2; 258 mr2 |= MCFUART_MR2_STOP2;
253 else 259 else
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c
index 52c930fac210..445799dc9846 100644
--- a/drivers/tty/serial/mfd.c
+++ b/drivers/tty/serial/mfd.c
@@ -977,7 +977,7 @@ serial_hsu_set_termios(struct uart_port *port, struct ktermios *termios,
977 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 977 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
978 if (termios->c_iflag & INPCK) 978 if (termios->c_iflag & INPCK)
979 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; 979 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
980 if (termios->c_iflag & (BRKINT | PARMRK)) 980 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
981 up->port.read_status_mask |= UART_LSR_BI; 981 up->port.read_status_mask |= UART_LSR_BI;
982 982
983 /* Characters to ignore */ 983 /* Characters to ignore */
diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index e30a3ca3cea3..759c6a6fa74a 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -1458,7 +1458,7 @@ static void mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1458 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE 1458 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE
1459 | SDMA_DESC_CMDSTAT_FR; 1459 | SDMA_DESC_CMDSTAT_FR;
1460 1460
1461 if (termios->c_iflag & (BRKINT | PARMRK)) 1461 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
1462 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR; 1462 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR;
1463 1463
1464 /* Characters/events to ignore */ 1464 /* Characters/events to ignore */
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 778e376f197e..c41aca4dfc43 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -582,7 +582,7 @@ static void msm_set_termios(struct uart_port *port, struct ktermios *termios,
582 port->read_status_mask = 0; 582 port->read_status_mask = 0;
583 if (termios->c_iflag & INPCK) 583 if (termios->c_iflag & INPCK)
584 port->read_status_mask |= UART_SR_PAR_FRAME_ERR; 584 port->read_status_mask |= UART_SR_PAR_FRAME_ERR;
585 if (termios->c_iflag & (BRKINT | PARMRK)) 585 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
586 port->read_status_mask |= UART_SR_RX_BREAK; 586 port->read_status_mask |= UART_SR_RX_BREAK;
587 587
588 uart_update_timeout(port, termios->c_cflag, baud); 588 uart_update_timeout(port, termios->c_cflag, baud);
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 4b5b3c2fe328..86de4477d98a 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -604,7 +604,7 @@ static void mxs_auart_settermios(struct uart_port *u,
604 604
605 if (termios->c_iflag & INPCK) 605 if (termios->c_iflag & INPCK)
606 u->read_status_mask |= AUART_STAT_PERR; 606 u->read_status_mask |= AUART_STAT_PERR;
607 if (termios->c_iflag & (BRKINT | PARMRK)) 607 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
608 u->read_status_mask |= AUART_STAT_BERR; 608 u->read_status_mask |= AUART_STAT_BERR;
609 609
610 /* 610 /*
diff --git a/drivers/tty/serial/netx-serial.c b/drivers/tty/serial/netx-serial.c
index 0a4dd70d29eb..7a6745601d4e 100644
--- a/drivers/tty/serial/netx-serial.c
+++ b/drivers/tty/serial/netx-serial.c
@@ -419,7 +419,7 @@ netx_set_termios(struct uart_port *port, struct ktermios *termios,
419 } 419 }
420 420
421 port->read_status_mask = 0; 421 port->read_status_mask = 0;
422 if (termios->c_iflag & (BRKINT | PARMRK)) 422 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
423 port->read_status_mask |= SR_BE; 423 port->read_status_mask |= SR_BE;
424 if (termios->c_iflag & INPCK) 424 if (termios->c_iflag & INPCK)
425 port->read_status_mask |= SR_PE | SR_FE; 425 port->read_status_mask |= SR_PE | SR_FE;
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index e9d420ff3931..8193635103ee 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1092,7 +1092,7 @@ static void pmz_convert_to_zs(struct uart_pmac_port *uap, unsigned int cflag,
1092 uap->port.read_status_mask = Rx_OVR; 1092 uap->port.read_status_mask = Rx_OVR;
1093 if (iflag & INPCK) 1093 if (iflag & INPCK)
1094 uap->port.read_status_mask |= CRC_ERR | PAR_ERR; 1094 uap->port.read_status_mask |= CRC_ERR | PAR_ERR;
1095 if (iflag & (BRKINT | PARMRK)) 1095 if (iflag & (IGNBRK | BRKINT | PARMRK))
1096 uap->port.read_status_mask |= BRK_ABRT; 1096 uap->port.read_status_mask |= BRK_ABRT;
1097 1097
1098 uap->port.ignore_status_mask = 0; 1098 uap->port.ignore_status_mask = 0;
diff --git a/drivers/tty/serial/pnx8xxx_uart.c b/drivers/tty/serial/pnx8xxx_uart.c
index de6c05c63683..2ba24a45c97f 100644
--- a/drivers/tty/serial/pnx8xxx_uart.c
+++ b/drivers/tty/serial/pnx8xxx_uart.c
@@ -477,7 +477,7 @@ pnx8xxx_set_termios(struct uart_port *port, struct ktermios *termios,
477 sport->port.read_status_mask |= 477 sport->port.read_status_mask |=
478 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) | 478 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) |
479 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR); 479 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR);
480 if (termios->c_iflag & (BRKINT | PARMRK)) 480 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
481 sport->port.read_status_mask |= 481 sport->port.read_status_mask |=
482 ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK); 482 ISTAT_TO_SM(PNX8XXX_UART_INT_BREAK);
483 483
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 9e7ee39f8b2a..c638c53cd2b6 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -492,7 +492,7 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios,
492 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 492 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
493 if (termios->c_iflag & INPCK) 493 if (termios->c_iflag & INPCK)
494 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; 494 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
495 if (termios->c_iflag & (BRKINT | PARMRK)) 495 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
496 up->port.read_status_mask |= UART_LSR_BI; 496 up->port.read_status_mask |= UART_LSR_BI;
497 497
498 /* 498 /*
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 329337711bb0..c1d3ebdf3b97 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -66,7 +66,7 @@ static void dbg(const char *fmt, ...)
66 char buff[256]; 66 char buff[256];
67 67
68 va_start(va, fmt); 68 va_start(va, fmt);
69 vscnprintf(buff, sizeof(buf), fmt, va); 69 vscnprintf(buff, sizeof(buff), fmt, va);
70 va_end(va); 70 va_end(va);
71 71
72 printascii(buff); 72 printascii(buff);
diff --git a/drivers/tty/serial/sb1250-duart.c b/drivers/tty/serial/sb1250-duart.c
index a7cdec2962dd..771f361c47ea 100644
--- a/drivers/tty/serial/sb1250-duart.c
+++ b/drivers/tty/serial/sb1250-duart.c
@@ -596,7 +596,7 @@ static void sbd_set_termios(struct uart_port *uport, struct ktermios *termios,
596 if (termios->c_iflag & INPCK) 596 if (termios->c_iflag & INPCK)
597 uport->read_status_mask |= M_DUART_FRM_ERR | 597 uport->read_status_mask |= M_DUART_FRM_ERR |
598 M_DUART_PARITY_ERR; 598 M_DUART_PARITY_ERR;
599 if (termios->c_iflag & (BRKINT | PARMRK)) 599 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
600 uport->read_status_mask |= M_DUART_RCVD_BRK; 600 uport->read_status_mask |= M_DUART_RCVD_BRK;
601 601
602 uport->ignore_status_mask = 0; 602 uport->ignore_status_mask = 0;
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index 5443b46345ed..e84b6a3bdd18 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -665,7 +665,7 @@ static void sccnxp_set_termios(struct uart_port *port,
665 port->read_status_mask = SR_OVR; 665 port->read_status_mask = SR_OVR;
666 if (termios->c_iflag & INPCK) 666 if (termios->c_iflag & INPCK)
667 port->read_status_mask |= SR_PE | SR_FE; 667 port->read_status_mask |= SR_PE | SR_FE;
668 if (termios->c_iflag & (BRKINT | PARMRK)) 668 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
669 port->read_status_mask |= SR_BRK; 669 port->read_status_mask |= SR_BRK;
670 670
671 /* Set status ignore mask */ 671 /* Set status ignore mask */
diff --git a/drivers/tty/serial/serial_ks8695.c b/drivers/tty/serial/serial_ks8695.c
index e1caa99e3d3b..5c79bdab985d 100644
--- a/drivers/tty/serial/serial_ks8695.c
+++ b/drivers/tty/serial/serial_ks8695.c
@@ -437,7 +437,7 @@ static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *term
437 port->read_status_mask = URLS_URROE; 437 port->read_status_mask = URLS_URROE;
438 if (termios->c_iflag & INPCK) 438 if (termios->c_iflag & INPCK)
439 port->read_status_mask |= (URLS_URFE | URLS_URPE); 439 port->read_status_mask |= (URLS_URFE | URLS_URPE);
440 if (termios->c_iflag & (BRKINT | PARMRK)) 440 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
441 port->read_status_mask |= URLS_URBI; 441 port->read_status_mask |= URLS_URBI;
442 442
443 /* 443 /*
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index 60f49b9d7e39..ea8546092c7e 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -697,7 +697,7 @@ serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,
697 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS; 697 TXX9_SIDISR_TDIS | TXX9_SIDISR_RDIS;
698 if (termios->c_iflag & INPCK) 698 if (termios->c_iflag & INPCK)
699 up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER; 699 up->port.read_status_mask |= TXX9_SIDISR_UFER | TXX9_SIDISR_UPER;
700 if (termios->c_iflag & (BRKINT | PARMRK)) 700 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
701 up->port.read_status_mask |= TXX9_SIDISR_UBRK; 701 up->port.read_status_mask |= TXX9_SIDISR_UBRK;
702 702
703 /* 703 /*
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
index 1f2be48c92ce..9b4d71cff00d 100644
--- a/drivers/tty/serial/sirfsoc_uart.c
+++ b/drivers/tty/serial/sirfsoc_uart.c
@@ -896,7 +896,7 @@ static void sirfsoc_uart_set_termios(struct uart_port *port,
896 if (termios->c_iflag & INPCK) 896 if (termios->c_iflag & INPCK)
897 port->read_status_mask |= uint_en->sirfsoc_frm_err_en; 897 port->read_status_mask |= uint_en->sirfsoc_frm_err_en;
898 } 898 }
899 if (termios->c_iflag & (BRKINT | PARMRK)) 899 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
900 port->read_status_mask |= uint_en->sirfsoc_rxd_brk_en; 900 port->read_status_mask |= uint_en->sirfsoc_rxd_brk_en;
901 if (sirfport->uart_reg->uart_type == SIRF_REAL_UART) { 901 if (sirfport->uart_reg->uart_type == SIRF_REAL_UART) {
902 if (termios->c_iflag & IGNPAR) 902 if (termios->c_iflag & IGNPAR)
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index c7f61ac27132..f48b1cc07eea 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -547,7 +547,7 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
547 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; 547 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE;
548 if (termios->c_iflag & INPCK) 548 if (termios->c_iflag & INPCK)
549 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; 549 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE;
550 if (termios->c_iflag & (BRKINT | PARMRK)) 550 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
551 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; 551 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE;
552 552
553 /* 553 /*
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 5faa8e905e98..80a58eca785b 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -719,7 +719,7 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
719 if (iflag & INPCK) 719 if (iflag & INPCK)
720 up->port.read_status_mask |= (SAB82532_ISR0_PERR | 720 up->port.read_status_mask |= (SAB82532_ISR0_PERR |
721 SAB82532_ISR0_FERR); 721 SAB82532_ISR0_FERR);
722 if (iflag & (BRKINT | PARMRK)) 722 if (iflag & (IGNBRK | BRKINT | PARMRK))
723 up->port.read_status_mask |= (SAB82532_ISR1_BRK << 8); 723 up->port.read_status_mask |= (SAB82532_ISR1_BRK << 8);
724 724
725 /* 725 /*
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index 9a0f24f83720..5326ae195e5f 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -834,7 +834,7 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,
834 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 834 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
835 if (iflag & INPCK) 835 if (iflag & INPCK)
836 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; 836 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
837 if (iflag & (BRKINT | PARMRK)) 837 if (iflag & (IGNBRK | BRKINT | PARMRK))
838 up->port.read_status_mask |= UART_LSR_BI; 838 up->port.read_status_mask |= UART_LSR_BI;
839 839
840 /* 840 /*
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index a2c40ed287d2..a85db8b87156 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -915,7 +915,7 @@ sunzilog_convert_to_zs(struct uart_sunzilog_port *up, unsigned int cflag,
915 up->port.read_status_mask = Rx_OVR; 915 up->port.read_status_mask = Rx_OVR;
916 if (iflag & INPCK) 916 if (iflag & INPCK)
917 up->port.read_status_mask |= CRC_ERR | PAR_ERR; 917 up->port.read_status_mask |= CRC_ERR | PAR_ERR;
918 if (iflag & (BRKINT | PARMRK)) 918 if (iflag & (IGNBRK | BRKINT | PARMRK))
919 up->port.read_status_mask |= BRK_ABRT; 919 up->port.read_status_mask |= BRK_ABRT;
920 920
921 up->port.ignore_status_mask = 0; 921 up->port.ignore_status_mask = 0;
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index d569ca58bab6..1c52074c38df 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -936,7 +936,7 @@ static void qe_uart_set_termios(struct uart_port *port,
936 port->read_status_mask = BD_SC_EMPTY | BD_SC_OV; 936 port->read_status_mask = BD_SC_EMPTY | BD_SC_OV;
937 if (termios->c_iflag & INPCK) 937 if (termios->c_iflag & INPCK)
938 port->read_status_mask |= BD_SC_FR | BD_SC_PR; 938 port->read_status_mask |= BD_SC_FR | BD_SC_PR;
939 if (termios->c_iflag & (BRKINT | PARMRK)) 939 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
940 port->read_status_mask |= BD_SC_BR; 940 port->read_status_mask |= BD_SC_BR;
941 941
942 /* 942 /*
diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
index a63c14bc9a24..db0c8a4ab03e 100644
--- a/drivers/tty/serial/vr41xx_siu.c
+++ b/drivers/tty/serial/vr41xx_siu.c
@@ -559,7 +559,7 @@ static void siu_set_termios(struct uart_port *port, struct ktermios *new,
559 port->read_status_mask = UART_LSR_THRE | UART_LSR_OE | UART_LSR_DR; 559 port->read_status_mask = UART_LSR_THRE | UART_LSR_OE | UART_LSR_DR;
560 if (c_iflag & INPCK) 560 if (c_iflag & INPCK)
561 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE; 561 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
562 if (c_iflag & (BRKINT | PARMRK)) 562 if (c_iflag & (IGNBRK | BRKINT | PARMRK))
563 port->read_status_mask |= UART_LSR_BI; 563 port->read_status_mask |= UART_LSR_BI;
564 564
565 port->ignore_status_mask = 0; 565 port->ignore_status_mask = 0;
diff --git a/drivers/tty/serial/zs.c b/drivers/tty/serial/zs.c
index 6a169877109b..2b65bb7ffb8a 100644
--- a/drivers/tty/serial/zs.c
+++ b/drivers/tty/serial/zs.c
@@ -923,7 +923,7 @@ static void zs_set_termios(struct uart_port *uport, struct ktermios *termios,
923 uport->read_status_mask = Rx_OVR; 923 uport->read_status_mask = Rx_OVR;
924 if (termios->c_iflag & INPCK) 924 if (termios->c_iflag & INPCK)
925 uport->read_status_mask |= FRM_ERR | PAR_ERR; 925 uport->read_status_mask |= FRM_ERR | PAR_ERR;
926 if (termios->c_iflag & (BRKINT | PARMRK)) 926 if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
927 uport->read_status_mask |= Rx_BRK; 927 uport->read_status_mask |= Rx_BRK;
928 928
929 uport->ignore_status_mask = 0; 929 uport->ignore_status_mask = 0;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 5e0f6ff2e2f5..b33b00b386de 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3226,8 +3226,7 @@ int do_unbind_con_driver(const struct consw *csw, int first, int last, int deflt
3226 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3226 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3227 con_back = &registered_con_driver[i]; 3227 con_back = &registered_con_driver[i];
3228 3228
3229 if (con_back->con && 3229 if (con_back->con && con_back->con != csw) {
3230 !(con_back->flag & CON_DRIVER_FLAG_MODULE)) {
3231 defcsw = con_back->con; 3230 defcsw = con_back->con;
3232 retval = 0; 3231 retval = 0;
3233 break; 3232 break;
@@ -3332,6 +3331,7 @@ static int vt_unbind(struct con_driver *con)
3332{ 3331{
3333 const struct consw *csw = NULL; 3332 const struct consw *csw = NULL;
3334 int i, more = 1, first = -1, last = -1, deflt = 0; 3333 int i, more = 1, first = -1, last = -1, deflt = 0;
3334 int ret;
3335 3335
3336 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) || 3336 if (!con->con || !(con->flag & CON_DRIVER_FLAG_MODULE) ||
3337 con_is_graphics(con->con, con->first, con->last)) 3337 con_is_graphics(con->con, con->first, con->last))
@@ -3357,8 +3357,10 @@ static int vt_unbind(struct con_driver *con)
3357 3357
3358 if (first != -1) { 3358 if (first != -1) {
3359 console_lock(); 3359 console_lock();
3360 do_unbind_con_driver(csw, first, last, deflt); 3360 ret = do_unbind_con_driver(csw, first, last, deflt);
3361 console_unlock(); 3361 console_unlock();
3362 if (ret != 0)
3363 return ret;
3362 } 3364 }
3363 3365
3364 first = -1; 3366 first = -1;
@@ -3645,17 +3647,20 @@ err:
3645 */ 3647 */
3646int do_unregister_con_driver(const struct consw *csw) 3648int do_unregister_con_driver(const struct consw *csw)
3647{ 3649{
3648 int i, retval = -ENODEV; 3650 int i;
3649 3651
3650 /* cannot unregister a bound driver */ 3652 /* cannot unregister a bound driver */
3651 if (con_is_bound(csw)) 3653 if (con_is_bound(csw))
3652 goto err; 3654 return -EBUSY;
3655
3656 if (csw == conswitchp)
3657 return -EINVAL;
3653 3658
3654 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3659 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3655 struct con_driver *con_driver = &registered_con_driver[i]; 3660 struct con_driver *con_driver = &registered_con_driver[i];
3656 3661
3657 if (con_driver->con == csw && 3662 if (con_driver->con == csw &&
3658 con_driver->flag & CON_DRIVER_FLAG_MODULE) { 3663 con_driver->flag & CON_DRIVER_FLAG_INIT) {
3659 vtconsole_deinit_device(con_driver); 3664 vtconsole_deinit_device(con_driver);
3660 device_destroy(vtconsole_class, 3665 device_destroy(vtconsole_class,
3661 MKDEV(0, con_driver->node)); 3666 MKDEV(0, con_driver->node));
@@ -3666,12 +3671,11 @@ int do_unregister_con_driver(const struct consw *csw)
3666 con_driver->flag = 0; 3671 con_driver->flag = 0;
3667 con_driver->first = 0; 3672 con_driver->first = 0;
3668 con_driver->last = 0; 3673 con_driver->last = 0;
3669 retval = 0; 3674 return 0;
3670 break;
3671 } 3675 }
3672 } 3676 }
3673err: 3677
3674 return retval; 3678 return -ENODEV;
3675} 3679}
3676EXPORT_SYMBOL_GPL(do_unregister_con_driver); 3680EXPORT_SYMBOL_GPL(do_unregister_con_driver);
3677 3681
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index e371f5af11f5..a673e5b6a2e0 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -655,7 +655,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
655 655
656 if (mem->addr & ~PAGE_MASK) 656 if (mem->addr & ~PAGE_MASK)
657 return -ENODEV; 657 return -ENODEV;
658 if (vma->vm_end - vma->vm_start > PAGE_ALIGN(mem->size)) 658 if (vma->vm_end - vma->vm_start > mem->size)
659 return -EINVAL; 659 return -EINVAL;
660 660
661 vma->vm_ops = &uio_physical_vm_ops; 661 vma->vm_ops = &uio_physical_vm_ops;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 879b66e13370..21b99b4b4082 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1526,18 +1526,6 @@ static int hub_configure(struct usb_hub *hub,
1526 dev_dbg(hub_dev, "%umA bus power budget for each child\n", 1526 dev_dbg(hub_dev, "%umA bus power budget for each child\n",
1527 hub->mA_per_port); 1527 hub->mA_per_port);
1528 1528
1529 /* Update the HCD's internal representation of this hub before khubd
1530 * starts getting port status changes for devices under the hub.
1531 */
1532 if (hcd->driver->update_hub_device) {
1533 ret = hcd->driver->update_hub_device(hcd, hdev,
1534 &hub->tt, GFP_KERNEL);
1535 if (ret < 0) {
1536 message = "can't update HCD hub info";
1537 goto fail;
1538 }
1539 }
1540
1541 ret = hub_hub_status(hub, &hubstatus, &hubchange); 1529 ret = hub_hub_status(hub, &hubstatus, &hubchange);
1542 if (ret < 0) { 1530 if (ret < 0) {
1543 message = "can't get hub status"; 1531 message = "can't get hub status";
@@ -1589,10 +1577,28 @@ static int hub_configure(struct usb_hub *hub,
1589 } 1577 }
1590 } 1578 }
1591 hdev->maxchild = i; 1579 hdev->maxchild = i;
1580 for (i = 0; i < hdev->maxchild; i++) {
1581 struct usb_port *port_dev = hub->ports[i];
1582
1583 pm_runtime_put(&port_dev->dev);
1584 }
1585
1592 mutex_unlock(&usb_port_peer_mutex); 1586 mutex_unlock(&usb_port_peer_mutex);
1593 if (ret < 0) 1587 if (ret < 0)
1594 goto fail; 1588 goto fail;
1595 1589
1590 /* Update the HCD's internal representation of this hub before khubd
1591 * starts getting port status changes for devices under the hub.
1592 */
1593 if (hcd->driver->update_hub_device) {
1594 ret = hcd->driver->update_hub_device(hcd, hdev,
1595 &hub->tt, GFP_KERNEL);
1596 if (ret < 0) {
1597 message = "can't update HCD hub info";
1598 goto fail;
1599 }
1600 }
1601
1596 usb_hub_adjust_deviceremovable(hdev, hub->descriptor); 1602 usb_hub_adjust_deviceremovable(hdev, hub->descriptor);
1597 1603
1598 hub_activate(hub, HUB_INIT); 1604 hub_activate(hub, HUB_INIT);
@@ -3458,7 +3464,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
3458 struct usb_device *udev = port_dev->child; 3464 struct usb_device *udev = port_dev->child;
3459 3465
3460 if (udev && udev->can_submit) { 3466 if (udev && udev->can_submit) {
3461 dev_warn(&port_dev->dev, "not suspended yet\n"); 3467 dev_warn(&port_dev->dev, "device %s not suspended yet\n",
3468 dev_name(&udev->dev));
3462 if (PMSG_IS_AUTO(msg)) 3469 if (PMSG_IS_AUTO(msg))
3463 return -EBUSY; 3470 return -EBUSY;
3464 } 3471 }
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 0a7cdc0ef0a9..326308e53961 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -84,6 +84,7 @@ struct usb_hub {
84 * @dev: generic device interface 84 * @dev: generic device interface
85 * @port_owner: port's owner 85 * @port_owner: port's owner
86 * @peer: related usb2 and usb3 ports (share the same connector) 86 * @peer: related usb2 and usb3 ports (share the same connector)
87 * @req: default pm qos request for hubs without port power control
87 * @connect_type: port's connect type 88 * @connect_type: port's connect type
88 * @location: opaque representation of platform connector location 89 * @location: opaque representation of platform connector location
89 * @status_lock: synchronize port_event() vs usb_port_{suspend|resume} 90 * @status_lock: synchronize port_event() vs usb_port_{suspend|resume}
@@ -95,6 +96,7 @@ struct usb_port {
95 struct device dev; 96 struct device dev;
96 struct usb_dev_state *port_owner; 97 struct usb_dev_state *port_owner;
97 struct usb_port *peer; 98 struct usb_port *peer;
99 struct dev_pm_qos_request *req;
98 enum usb_port_connect_type connect_type; 100 enum usb_port_connect_type connect_type;
99 usb_port_location_t location; 101 usb_port_location_t location;
100 struct mutex status_lock; 102 struct mutex status_lock;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 62036faf56c0..fe1b6d0967e3 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -21,6 +21,8 @@
21 21
22#include "hub.h" 22#include "hub.h"
23 23
24static int usb_port_block_power_off;
25
24static const struct attribute_group *port_dev_group[]; 26static const struct attribute_group *port_dev_group[];
25 27
26static ssize_t connect_type_show(struct device *dev, 28static ssize_t connect_type_show(struct device *dev,
@@ -66,6 +68,7 @@ static void usb_port_device_release(struct device *dev)
66{ 68{
67 struct usb_port *port_dev = to_usb_port(dev); 69 struct usb_port *port_dev = to_usb_port(dev);
68 70
71 kfree(port_dev->req);
69 kfree(port_dev); 72 kfree(port_dev);
70} 73}
71 74
@@ -142,6 +145,9 @@ static int usb_port_runtime_suspend(struct device *dev)
142 == PM_QOS_FLAGS_ALL) 145 == PM_QOS_FLAGS_ALL)
143 return -EAGAIN; 146 return -EAGAIN;
144 147
148 if (usb_port_block_power_off)
149 return -EBUSY;
150
145 usb_autopm_get_interface(intf); 151 usb_autopm_get_interface(intf);
146 retval = usb_hub_set_port_power(hdev, hub, port1, false); 152 retval = usb_hub_set_port_power(hdev, hub, port1, false);
147 usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION); 153 usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_CONNECTION);
@@ -190,11 +196,19 @@ static int link_peers(struct usb_port *left, struct usb_port *right)
190 if (left->peer || right->peer) { 196 if (left->peer || right->peer) {
191 struct usb_port *lpeer = left->peer; 197 struct usb_port *lpeer = left->peer;
192 struct usb_port *rpeer = right->peer; 198 struct usb_port *rpeer = right->peer;
193 199 char *method;
194 WARN(1, "failed to peer %s and %s (%s -> %p) (%s -> %p)\n", 200
195 dev_name(&left->dev), dev_name(&right->dev), 201 if (left->location && left->location == right->location)
196 dev_name(&left->dev), lpeer, 202 method = "location";
197 dev_name(&right->dev), rpeer); 203 else
204 method = "default";
205
206 pr_warn("usb: failed to peer %s and %s by %s (%s:%s) (%s:%s)\n",
207 dev_name(&left->dev), dev_name(&right->dev), method,
208 dev_name(&left->dev),
209 lpeer ? dev_name(&lpeer->dev) : "none",
210 dev_name(&right->dev),
211 rpeer ? dev_name(&rpeer->dev) : "none");
198 return -EBUSY; 212 return -EBUSY;
199 } 213 }
200 214
@@ -251,6 +265,7 @@ static void link_peers_report(struct usb_port *left, struct usb_port *right)
251 dev_warn(&left->dev, "failed to peer to %s (%d)\n", 265 dev_warn(&left->dev, "failed to peer to %s (%d)\n",
252 dev_name(&right->dev), rc); 266 dev_name(&right->dev), rc);
253 pr_warn_once("usb: port power management may be unreliable\n"); 267 pr_warn_once("usb: port power management may be unreliable\n");
268 usb_port_block_power_off = 1;
254 } 269 }
255} 270}
256 271
@@ -386,9 +401,13 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
386 int retval; 401 int retval;
387 402
388 port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL); 403 port_dev = kzalloc(sizeof(*port_dev), GFP_KERNEL);
389 if (!port_dev) { 404 if (!port_dev)
390 retval = -ENOMEM; 405 return -ENOMEM;
391 goto exit; 406
407 port_dev->req = kzalloc(sizeof(*(port_dev->req)), GFP_KERNEL);
408 if (!port_dev->req) {
409 kfree(port_dev);
410 return -ENOMEM;
392 } 411 }
393 412
394 hub->ports[port1 - 1] = port_dev; 413 hub->ports[port1 - 1] = port_dev;
@@ -404,31 +423,53 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
404 port1); 423 port1);
405 mutex_init(&port_dev->status_lock); 424 mutex_init(&port_dev->status_lock);
406 retval = device_register(&port_dev->dev); 425 retval = device_register(&port_dev->dev);
407 if (retval) 426 if (retval) {
408 goto error_register; 427 put_device(&port_dev->dev);
428 return retval;
429 }
430
431 /* Set default policy of port-poweroff disabled. */
432 retval = dev_pm_qos_add_request(&port_dev->dev, port_dev->req,
433 DEV_PM_QOS_FLAGS, PM_QOS_FLAG_NO_POWER_OFF);
434 if (retval < 0) {
435 device_unregister(&port_dev->dev);
436 return retval;
437 }
409 438
410 find_and_link_peer(hub, port1); 439 find_and_link_peer(hub, port1);
411 440
441 /*
442 * Enable runtime pm and hold a refernce that hub_configure()
443 * will drop once the PM_QOS_NO_POWER_OFF flag state has been set
444 * and the hub has been fully registered (hdev->maxchild set).
445 */
412 pm_runtime_set_active(&port_dev->dev); 446 pm_runtime_set_active(&port_dev->dev);
447 pm_runtime_get_noresume(&port_dev->dev);
448 pm_runtime_enable(&port_dev->dev);
449 device_enable_async_suspend(&port_dev->dev);
413 450
414 /* 451 /*
415 * Do not enable port runtime pm if the hub does not support 452 * Keep hidden the ability to enable port-poweroff if the hub
416 * power switching. Also, userspace must have final say of 453 * does not support power switching.
417 * whether a port is permitted to power-off. Do not enable
418 * runtime pm if we fail to expose pm_qos_no_power_off.
419 */ 454 */
420 if (hub_is_port_power_switchable(hub) 455 if (!hub_is_port_power_switchable(hub))
421 && dev_pm_qos_expose_flags(&port_dev->dev, 456 return 0;
422 PM_QOS_FLAG_NO_POWER_OFF) == 0)
423 pm_runtime_enable(&port_dev->dev);
424 457
425 device_enable_async_suspend(&port_dev->dev); 458 /* Attempt to let userspace take over the policy. */
426 return 0; 459 retval = dev_pm_qos_expose_flags(&port_dev->dev,
460 PM_QOS_FLAG_NO_POWER_OFF);
461 if (retval < 0) {
462 dev_warn(&port_dev->dev, "failed to expose pm_qos_no_poweroff\n");
463 return 0;
464 }
427 465
428error_register: 466 /* Userspace owns the policy, drop the kernel 'no_poweroff' request. */
429 put_device(&port_dev->dev); 467 retval = dev_pm_qos_remove_request(port_dev->req);
430exit: 468 if (retval >= 0) {
431 return retval; 469 kfree(port_dev->req);
470 port_dev->req = NULL;
471 }
472 return 0;
432} 473}
433 474
434void usb_hub_remove_port_device(struct usb_hub *hub, int port1) 475void usb_hub_remove_port_device(struct usb_hub *hub, int port1)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 4a6d3dd68572..2f3acebb577a 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -656,6 +656,14 @@ static const struct dmi_system_id ehci_dmi_nohandoff_table[] = {
656 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"), 656 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
657 }, 657 },
658 }, 658 },
659 {
660 /* HASEE E200 */
661 .matches = {
662 DMI_MATCH(DMI_BOARD_VENDOR, "HASEE"),
663 DMI_MATCH(DMI_BOARD_NAME, "E210"),
664 DMI_MATCH(DMI_BIOS_VERSION, "6.00"),
665 },
666 },
659 { } 667 { }
660}; 668};
661 669
@@ -665,9 +673,14 @@ static void ehci_bios_handoff(struct pci_dev *pdev,
665{ 673{
666 int try_handoff = 1, tried_handoff = 0; 674 int try_handoff = 1, tried_handoff = 0;
667 675
668 /* The Pegatron Lucid tablet sporadically waits for 98 seconds trying 676 /*
669 * the handoff on its unused controller. Skip it. */ 677 * The Pegatron Lucid tablet sporadically waits for 98 seconds trying
670 if (pdev->vendor == 0x8086 && pdev->device == 0x283a) { 678 * the handoff on its unused controller. Skip it.
679 *
680 * The HASEE E200 hangs when the semaphore is set (bugzilla #77021).
681 */
682 if (pdev->vendor == 0x8086 && (pdev->device == 0x283a ||
683 pdev->device == 0x27cc)) {
671 if (dmi_check_system(ehci_dmi_nohandoff_table)) 684 if (dmi_check_system(ehci_dmi_nohandoff_table))
672 try_handoff = 0; 685 try_handoff = 0;
673 } 686 }
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 6231ce6aa0c3..2b998c60faf2 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -287,7 +287,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
287 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) { 287 if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue) {
288 struct xhci_command *command; 288 struct xhci_command *command;
289 command = xhci_alloc_command(xhci, false, false, 289 command = xhci_alloc_command(xhci, false, false,
290 GFP_NOIO); 290 GFP_NOWAIT);
291 if (!command) { 291 if (!command) {
292 spin_unlock_irqrestore(&xhci->lock, flags); 292 spin_unlock_irqrestore(&xhci->lock, flags);
293 xhci_free_command(xhci, cmd); 293 xhci_free_command(xhci, cmd);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 51a6da256772..829f446064ea 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -7,7 +7,7 @@
7#include <linux/moduleparam.h> 7#include <linux/moduleparam.h>
8#include <linux/scatterlist.h> 8#include <linux/scatterlist.h>
9#include <linux/mutex.h> 9#include <linux/mutex.h>
10 10#include <linux/timer.h>
11#include <linux/usb.h> 11#include <linux/usb.h>
12 12
13#define SIMPLE_IO_TIMEOUT 10000 /* in milliseconds */ 13#define SIMPLE_IO_TIMEOUT 10000 /* in milliseconds */
@@ -484,6 +484,14 @@ alloc_sglist(int nents, int max, int vary)
484 return sg; 484 return sg;
485} 485}
486 486
487static void sg_timeout(unsigned long _req)
488{
489 struct usb_sg_request *req = (struct usb_sg_request *) _req;
490
491 req->status = -ETIMEDOUT;
492 usb_sg_cancel(req);
493}
494
487static int perform_sglist( 495static int perform_sglist(
488 struct usbtest_dev *tdev, 496 struct usbtest_dev *tdev,
489 unsigned iterations, 497 unsigned iterations,
@@ -495,6 +503,9 @@ static int perform_sglist(
495{ 503{
496 struct usb_device *udev = testdev_to_usbdev(tdev); 504 struct usb_device *udev = testdev_to_usbdev(tdev);
497 int retval = 0; 505 int retval = 0;
506 struct timer_list sg_timer;
507
508 setup_timer_on_stack(&sg_timer, sg_timeout, (unsigned long) req);
498 509
499 while (retval == 0 && iterations-- > 0) { 510 while (retval == 0 && iterations-- > 0) {
500 retval = usb_sg_init(req, udev, pipe, 511 retval = usb_sg_init(req, udev, pipe,
@@ -505,7 +516,10 @@ static int perform_sglist(
505 516
506 if (retval) 517 if (retval)
507 break; 518 break;
519 mod_timer(&sg_timer, jiffies +
520 msecs_to_jiffies(SIMPLE_IO_TIMEOUT));
508 usb_sg_wait(req); 521 usb_sg_wait(req);
522 del_timer_sync(&sg_timer);
509 retval = req->status; 523 retval = req->status;
510 524
511 /* FIXME check resulting data pattern */ 525 /* FIXME check resulting data pattern */
diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c
index b63860f7beab..40bec8d64b0a 100644
--- a/drivers/video/console/dummycon.c
+++ b/drivers/video/console/dummycon.c
@@ -77,3 +77,4 @@ const struct consw dummy_con = {
77 .con_set_palette = DUMMY, 77 .con_set_palette = DUMMY,
78 .con_scrolldelta = DUMMY, 78 .con_scrolldelta = DUMMY,
79}; 79};
80EXPORT_SYMBOL_GPL(dummy_con);
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index f267284b423b..6e6aa704fe84 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -1441,5 +1441,6 @@ const struct consw vga_con = {
1441 .con_build_attr = vgacon_build_attr, 1441 .con_build_attr = vgacon_build_attr,
1442 .con_invert_region = vgacon_invert_region, 1442 .con_invert_region = vgacon_invert_region,
1443}; 1443};
1444EXPORT_SYMBOL(vga_con);
1444 1445
1445MODULE_LICENSE("GPL"); 1446MODULE_LICENSE("GPL");
diff --git a/drivers/video/fbdev/offb.c b/drivers/video/fbdev/offb.c
index 7d44d669d5b6..43a0a52fc527 100644
--- a/drivers/video/fbdev/offb.c
+++ b/drivers/video/fbdev/offb.c
@@ -91,15 +91,6 @@ extern boot_infos_t *boot_infos;
91#define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN 0x6cd4 91#define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN 0x6cd4
92#define AVIVO_DC_LUTB_WHITE_OFFSET_RED 0x6cd8 92#define AVIVO_DC_LUTB_WHITE_OFFSET_RED 0x6cd8
93 93
94#define FB_RIGHT_POS(p, bpp) (fb_be_math(p) ? 0 : (32 - (bpp)))
95
96static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
97{
98 u32 bpp = info->var.bits_per_pixel;
99
100 return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
101}
102
103 /* 94 /*
104 * Set a single color register. The values supplied are already 95 * Set a single color register. The values supplied are already
105 * rounded down to the hardware's capabilities (according to the 96 * rounded down to the hardware's capabilities (according to the
@@ -129,7 +120,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
129 mask <<= info->var.transp.offset; 120 mask <<= info->var.transp.offset;
130 value |= mask; 121 value |= mask;
131 } 122 }
132 pal[regno] = offb_cmap_byteswap(info, value); 123 pal[regno] = value;
133 return 0; 124 return 0;
134 } 125 }
135 126
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
index 67b067a3e2ab..a5df5e89d456 100644
--- a/drivers/w1/masters/mxc_w1.c
+++ b/drivers/w1/masters/mxc_w1.c
@@ -66,7 +66,7 @@ static u8 mxc_w1_ds2_reset_bus(void *data)
66 66
67 udelay(100); 67 udelay(100);
68 } 68 }
69 return !!(reg_val & MXC_W1_CONTROL_PST); 69 return !(reg_val & MXC_W1_CONTROL_PST);
70} 70}
71 71
72/* 72/*
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index c845527b503a..76dd54122f76 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1280,14 +1280,17 @@ config WATCHDOG_RTAS
1280 1280
1281# S390 Architecture 1281# S390 Architecture
1282 1282
1283config ZVM_WATCHDOG 1283config DIAG288_WATCHDOG
1284 tristate "z/VM Watchdog Timer" 1284 tristate "System z diag288 Watchdog"
1285 depends on S390 1285 depends on S390
1286 select WATCHDOG_CORE
1286 help 1287 help
1287 IBM s/390 and zSeries machines running under z/VM 5.1 or later 1288 IBM s/390 and zSeries machines running under z/VM 5.1 or later
1288 provide a virtual watchdog timer to their guest that cause a 1289 provide a virtual watchdog timer to their guest that cause a
1289 user define Control Program command to be executed after a 1290 user define Control Program command to be executed after a
1290 timeout. 1291 timeout.
1292 LPAR provides a very similar interface. This driver handles
1293 both.
1291 1294
1292 To compile this driver as a module, choose M here. The module 1295 To compile this driver as a module, choose M here. The module
1293 will be called vmwatchdog. 1296 will be called vmwatchdog.
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 7b8a91ed20e7..468c3204c3b1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -153,6 +153,7 @@ obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
153obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o 153obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
154 154
155# S390 Architecture 155# S390 Architecture
156obj-$(CONFIG_DIAG288_WATCHDOG) += diag288_wdt.o
156 157
157# SUPERH (sh + sh64) Architecture 158# SUPERH (sh + sh64) Architecture
158obj-$(CONFIG_SH_WDT) += shwdt.o 159obj-$(CONFIG_SH_WDT) += shwdt.o
diff --git a/drivers/watchdog/diag288_wdt.c b/drivers/watchdog/diag288_wdt.c
new file mode 100644
index 000000000000..429494b6c822
--- /dev/null
+++ b/drivers/watchdog/diag288_wdt.c
@@ -0,0 +1,316 @@
1/*
2 * Watchdog driver for z/VM and LPAR using the diag 288 interface.
3 *
4 * Under z/VM, expiration of the watchdog will send a "system restart" command
5 * to CP.
6 *
7 * The command can be altered using the module parameter "cmd". This is
8 * not recommended because it's only supported on z/VM but not whith LPAR.
9 *
10 * On LPAR, the watchdog will always trigger a system restart. the module
11 * paramter cmd is meaningless here.
12 *
13 *
14 * Copyright IBM Corp. 2004, 2013
15 * Author(s): Arnd Bergmann (arndb@de.ibm.com)
16 * Philipp Hachtmann (phacht@de.ibm.com)
17 *
18 */
19
20#define KMSG_COMPONENT "diag288_wdt"
21#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
22
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/moduleparam.h>
27#include <linux/slab.h>
28#include <linux/miscdevice.h>
29#include <linux/watchdog.h>
30#include <linux/suspend.h>
31#include <asm/ebcdic.h>
32#include <linux/io.h>
33#include <linux/uaccess.h>
34
35#define MAX_CMDLEN 240
36#define DEFAULT_CMD "SYSTEM RESTART"
37
38#define MIN_INTERVAL 15 /* Minimal time supported by diag88 */
39#define MAX_INTERVAL 3600 /* One hour should be enough - pure estimation */
40
41#define WDT_DEFAULT_TIMEOUT 30
42
43/* Function codes - init, change, cancel */
44#define WDT_FUNC_INIT 0
45#define WDT_FUNC_CHANGE 1
46#define WDT_FUNC_CANCEL 2
47#define WDT_FUNC_CONCEAL 0x80000000
48
49/* Action codes for LPAR watchdog */
50#define LPARWDT_RESTART 0
51
52static char wdt_cmd[MAX_CMDLEN] = DEFAULT_CMD;
53static bool conceal_on;
54static bool nowayout_info = WATCHDOG_NOWAYOUT;
55
56MODULE_LICENSE("GPL");
57MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
58MODULE_AUTHOR("Philipp Hachtmann <phacht@de.ibm.com>");
59
60MODULE_DESCRIPTION("System z diag288 Watchdog Timer");
61
62module_param_string(cmd, wdt_cmd, MAX_CMDLEN, 0644);
63MODULE_PARM_DESC(cmd, "CP command that is run when the watchdog triggers (z/VM only)");
64
65module_param_named(conceal, conceal_on, bool, 0644);
66MODULE_PARM_DESC(conceal, "Enable the CONCEAL CP option while the watchdog is active (z/VM only)");
67
68module_param_named(nowayout, nowayout_info, bool, 0444);
69MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = CONFIG_WATCHDOG_NOWAYOUT)");
70
71MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
72MODULE_ALIAS("vmwatchdog");
73
74static int __diag288(unsigned int func, unsigned int timeout,
75 unsigned long action, unsigned int len)
76{
77 register unsigned long __func asm("2") = func;
78 register unsigned long __timeout asm("3") = timeout;
79 register unsigned long __action asm("4") = action;
80 register unsigned long __len asm("5") = len;
81 int err;
82
83 err = -EINVAL;
84 asm volatile(
85 " diag %1, %3, 0x288\n"
86 "0: la %0, 0\n"
87 "1:\n"
88 EX_TABLE(0b, 1b)
89 : "+d" (err) : "d"(__func), "d"(__timeout),
90 "d"(__action), "d"(__len) : "1", "cc");
91 return err;
92}
93
94static int __diag288_vm(unsigned int func, unsigned int timeout,
95 char *cmd, size_t len)
96{
97 return __diag288(func, timeout, virt_to_phys(cmd), len);
98}
99
100static int __diag288_lpar(unsigned int func, unsigned int timeout,
101 unsigned long action)
102{
103 return __diag288(func, timeout, action, 0);
104}
105
106static int wdt_start(struct watchdog_device *dev)
107{
108 char *ebc_cmd;
109 size_t len;
110 int ret;
111 unsigned int func;
112
113 ret = -ENODEV;
114
115 if (MACHINE_IS_VM) {
116 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
117 if (!ebc_cmd)
118 return -ENOMEM;
119 len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN);
120 ASCEBC(ebc_cmd, MAX_CMDLEN);
121 EBC_TOUPPER(ebc_cmd, MAX_CMDLEN);
122
123 func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL)
124 : WDT_FUNC_INIT;
125 ret = __diag288_vm(func, dev->timeout, ebc_cmd, len);
126 WARN_ON(ret != 0);
127 kfree(ebc_cmd);
128 }
129
130 if (MACHINE_IS_LPAR) {
131 ret = __diag288_lpar(WDT_FUNC_INIT,
132 dev->timeout, LPARWDT_RESTART);
133 }
134
135 if (ret) {
136 pr_err("The watchdog cannot be activated\n");
137 return ret;
138 }
139 pr_info("The watchdog was activated\n");
140 return 0;
141}
142
143static int wdt_stop(struct watchdog_device *dev)
144{
145 int ret;
146
147 ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0);
148 pr_info("The watchdog was deactivated\n");
149 return ret;
150}
151
152static int wdt_ping(struct watchdog_device *dev)
153{
154 char *ebc_cmd;
155 size_t len;
156 int ret;
157 unsigned int func;
158
159 ret = -ENODEV;
160
161 if (MACHINE_IS_VM) {
162 ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL);
163 if (!ebc_cmd)
164 return -ENOMEM;
165 len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN);
166 ASCEBC(ebc_cmd, MAX_CMDLEN);
167 EBC_TOUPPER(ebc_cmd, MAX_CMDLEN);
168
169 /*
170 * It seems to be ok to z/VM to use the init function to
171 * retrigger the watchdog. On LPAR WDT_FUNC_CHANGE must
172 * be used when the watchdog is running.
173 */
174 func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL)
175 : WDT_FUNC_INIT;
176
177 ret = __diag288_vm(func, dev->timeout, ebc_cmd, len);
178 WARN_ON(ret != 0);
179 kfree(ebc_cmd);
180 }
181
182 if (MACHINE_IS_LPAR)
183 ret = __diag288_lpar(WDT_FUNC_CHANGE, dev->timeout, 0);
184
185 if (ret)
186 pr_err("The watchdog timer cannot be started or reset\n");
187 return ret;
188}
189
190static int wdt_set_timeout(struct watchdog_device * dev, unsigned int new_to)
191{
192 dev->timeout = new_to;
193 return wdt_ping(dev);
194}
195
196static struct watchdog_ops wdt_ops = {
197 .owner = THIS_MODULE,
198 .start = wdt_start,
199 .stop = wdt_stop,
200 .ping = wdt_ping,
201 .set_timeout = wdt_set_timeout,
202};
203
204static struct watchdog_info wdt_info = {
205 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
206 .firmware_version = 0,
207 .identity = "z Watchdog",
208};
209
210static struct watchdog_device wdt_dev = {
211 .parent = NULL,
212 .info = &wdt_info,
213 .ops = &wdt_ops,
214 .bootstatus = 0,
215 .timeout = WDT_DEFAULT_TIMEOUT,
216 .min_timeout = MIN_INTERVAL,
217 .max_timeout = MAX_INTERVAL,
218};
219
220/*
221 * It makes no sense to go into suspend while the watchdog is running.
222 * Depending on the memory size, the watchdog might trigger, while we
223 * are still saving the memory.
224 * We reuse the open flag to ensure that suspend and watchdog open are
225 * exclusive operations
226 */
227static int wdt_suspend(void)
228{
229 if (test_and_set_bit(WDOG_DEV_OPEN, &wdt_dev.status)) {
230 pr_err("Linux cannot be suspended while the watchdog is in use\n");
231 return notifier_from_errno(-EBUSY);
232 }
233 if (test_bit(WDOG_ACTIVE, &wdt_dev.status)) {
234 clear_bit(WDOG_DEV_OPEN, &wdt_dev.status);
235 pr_err("Linux cannot be suspended while the watchdog is in use\n");
236 return notifier_from_errno(-EBUSY);
237 }
238 return NOTIFY_DONE;
239}
240
241static int wdt_resume(void)
242{
243 clear_bit(WDOG_DEV_OPEN, &wdt_dev.status);
244 return NOTIFY_DONE;
245}
246
247static int wdt_power_event(struct notifier_block *this, unsigned long event,
248 void *ptr)
249{
250 switch (event) {
251 case PM_POST_HIBERNATION:
252 case PM_POST_SUSPEND:
253 return wdt_resume();
254 case PM_HIBERNATION_PREPARE:
255 case PM_SUSPEND_PREPARE:
256 return wdt_suspend();
257 default:
258 return NOTIFY_DONE;
259 }
260}
261
262static struct notifier_block wdt_power_notifier = {
263 .notifier_call = wdt_power_event,
264};
265
266static int __init diag288_init(void)
267{
268 int ret;
269 char ebc_begin[] = {
270 194, 197, 199, 201, 213
271 };
272
273 watchdog_set_nowayout(&wdt_dev, nowayout_info);
274
275 if (MACHINE_IS_VM) {
276 pr_info("The watchdog device driver detected a z/VM environment\n");
277 if (__diag288_vm(WDT_FUNC_INIT, 15,
278 ebc_begin, sizeof(ebc_begin)) != 0) {
279 pr_err("The watchdog cannot be initialized\n");
280 return -EINVAL;
281 }
282 } else if (MACHINE_IS_LPAR) {
283 pr_info("The watchdog device driver detected an LPAR environment\n");
284 if (__diag288_lpar(WDT_FUNC_INIT, 30, LPARWDT_RESTART)) {
285 pr_err("The watchdog cannot be initialized\n");
286 return -EINVAL;
287 }
288 } else {
289 pr_err("Linux runs in an environment that does not support the diag288 watchdog\n");
290 return -ENODEV;
291 }
292
293 if (__diag288_lpar(WDT_FUNC_CANCEL, 0, 0)) {
294 pr_err("The watchdog cannot be deactivated\n");
295 return -EINVAL;
296 }
297
298 ret = register_pm_notifier(&wdt_power_notifier);
299 if (ret)
300 return ret;
301
302 ret = watchdog_register_device(&wdt_dev);
303 if (ret)
304 unregister_pm_notifier(&wdt_power_notifier);
305
306 return ret;
307}
308
309static void __exit diag288_exit(void)
310{
311 watchdog_unregister_device(&wdt_dev);
312 unregister_pm_notifier(&wdt_power_notifier);
313}
314
315module_init(diag288_init);
316module_exit(diag288_exit);
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 6d325bda76da..5d4de88fe5b8 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -1168,7 +1168,8 @@ int gnttab_resume(void)
1168 1168
1169int gnttab_suspend(void) 1169int gnttab_suspend(void)
1170{ 1170{
1171 gnttab_interface->unmap_frames(); 1171 if (!xen_feature(XENFEAT_auto_translated_physmap))
1172 gnttab_interface->unmap_frames();
1172 return 0; 1173 return 0;
1173} 1174}
1174 1175
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b7e2c1c1ef36..be91397f4e92 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1259,11 +1259,19 @@ struct btrfs_block_group_cache {
1259 spinlock_t lock; 1259 spinlock_t lock;
1260 u64 pinned; 1260 u64 pinned;
1261 u64 reserved; 1261 u64 reserved;
1262 u64 delalloc_bytes;
1262 u64 bytes_super; 1263 u64 bytes_super;
1263 u64 flags; 1264 u64 flags;
1264 u64 sectorsize; 1265 u64 sectorsize;
1265 u64 cache_generation; 1266 u64 cache_generation;
1266 1267
1268 /*
1269 * It is just used for the delayed data space allocation because
1270 * only the data space allocation and the relative metadata update
1271 * can be done cross the transaction.
1272 */
1273 struct rw_semaphore data_rwsem;
1274
1267 /* for raid56, this is a full stripe, without parity */ 1275 /* for raid56, this is a full stripe, without parity */
1268 unsigned long full_stripe_len; 1276 unsigned long full_stripe_len;
1269 1277
@@ -3316,7 +3324,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
3316 struct btrfs_key *ins); 3324 struct btrfs_key *ins);
3317int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes, 3325int btrfs_reserve_extent(struct btrfs_root *root, u64 num_bytes,
3318 u64 min_alloc_size, u64 empty_size, u64 hint_byte, 3326 u64 min_alloc_size, u64 empty_size, u64 hint_byte,
3319 struct btrfs_key *ins, int is_data); 3327 struct btrfs_key *ins, int is_data, int delalloc);
3320int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 3328int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3321 struct extent_buffer *buf, int full_backref, int no_quota); 3329 struct extent_buffer *buf, int full_backref, int no_quota);
3322int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, 3330int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -3330,7 +3338,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
3330 u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid, 3338 u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
3331 u64 owner, u64 offset, int no_quota); 3339 u64 owner, u64 offset, int no_quota);
3332 3340
3333int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); 3341int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len,
3342 int delalloc);
3334int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, 3343int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root,
3335 u64 start, u64 len); 3344 u64 start, u64 len);
3336void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, 3345void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index fafb3e53ecde..99c253918208 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -105,7 +105,8 @@ static int find_next_key(struct btrfs_path *path, int level,
105static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 105static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
106 int dump_block_groups); 106 int dump_block_groups);
107static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, 107static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
108 u64 num_bytes, int reserve); 108 u64 num_bytes, int reserve,
109 int delalloc);
109static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, 110static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv,
110 u64 num_bytes); 111 u64 num_bytes);
111int btrfs_pin_extent(struct btrfs_root *root, 112int btrfs_pin_extent(struct btrfs_root *root,
@@ -3260,7 +3261,8 @@ again:
3260 3261
3261 spin_lock(&block_group->lock); 3262 spin_lock(&block_group->lock);
3262 if (block_group->cached != BTRFS_CACHE_FINISHED || 3263 if (block_group->cached != BTRFS_CACHE_FINISHED ||
3263 !btrfs_test_opt(root, SPACE_CACHE)) { 3264 !btrfs_test_opt(root, SPACE_CACHE) ||
3265 block_group->delalloc_bytes) {
3264 /* 3266 /*
3265 * don't bother trying to write stuff out _if_ 3267 * don't bother trying to write stuff out _if_
3266 * a) we're not cached, 3268 * a) we're not cached,
@@ -5613,6 +5615,7 @@ int btrfs_exclude_logged_extents(struct btrfs_root *log,
5613 * @cache: The cache we are manipulating 5615 * @cache: The cache we are manipulating
5614 * @num_bytes: The number of bytes in question 5616 * @num_bytes: The number of bytes in question
5615 * @reserve: One of the reservation enums 5617 * @reserve: One of the reservation enums
5618 * @delalloc: The blocks are allocated for the delalloc write
5616 * 5619 *
5617 * This is called by the allocator when it reserves space, or by somebody who is 5620 * This is called by the allocator when it reserves space, or by somebody who is
5618 * freeing space that was never actually used on disk. For example if you 5621 * freeing space that was never actually used on disk. For example if you
@@ -5631,7 +5634,7 @@ int btrfs_exclude_logged_extents(struct btrfs_root *log,
5631 * succeeds. 5634 * succeeds.
5632 */ 5635 */
5633static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache, 5636static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
5634 u64 num_bytes, int reserve) 5637 u64 num_bytes, int reserve, int delalloc)
5635{ 5638{
5636 struct btrfs_space_info *space_info = cache->space_info; 5639 struct btrfs_space_info *space_info = cache->space_info;
5637 int ret = 0; 5640 int ret = 0;
@@ -5650,12 +5653,18 @@ static int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
5650 num_bytes, 0); 5653 num_bytes, 0);
5651 space_info->bytes_may_use -= num_bytes; 5654 space_info->bytes_may_use -= num_bytes;
5652 } 5655 }
5656
5657 if (delalloc)
5658 cache->delalloc_bytes += num_bytes;
5653 } 5659 }
5654 } else { 5660 } else {
5655 if (cache->ro) 5661 if (cache->ro)
5656 space_info->bytes_readonly += num_bytes; 5662 space_info->bytes_readonly += num_bytes;
5657 cache->reserved -= num_bytes; 5663 cache->reserved -= num_bytes;
5658 space_info->bytes_reserved -= num_bytes; 5664 space_info->bytes_reserved -= num_bytes;
5665
5666 if (delalloc)
5667 cache->delalloc_bytes -= num_bytes;
5659 } 5668 }
5660 spin_unlock(&cache->lock); 5669 spin_unlock(&cache->lock);
5661 spin_unlock(&space_info->lock); 5670 spin_unlock(&space_info->lock);
@@ -6206,7 +6215,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
6206 WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags)); 6215 WARN_ON(test_bit(EXTENT_BUFFER_DIRTY, &buf->bflags));
6207 6216
6208 btrfs_add_free_space(cache, buf->start, buf->len); 6217 btrfs_add_free_space(cache, buf->start, buf->len);
6209 btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE); 6218 btrfs_update_reserved_bytes(cache, buf->len, RESERVE_FREE, 0);
6210 trace_btrfs_reserved_extent_free(root, buf->start, buf->len); 6219 trace_btrfs_reserved_extent_free(root, buf->start, buf->len);
6211 pin = 0; 6220 pin = 0;
6212 } 6221 }
@@ -6365,6 +6374,70 @@ enum btrfs_loop_type {
6365 LOOP_NO_EMPTY_SIZE = 3, 6374 LOOP_NO_EMPTY_SIZE = 3,
6366}; 6375};
6367 6376
6377static inline void
6378btrfs_lock_block_group(struct btrfs_block_group_cache *cache,
6379 int delalloc)
6380{
6381 if (delalloc)
6382 down_read(&cache->data_rwsem);
6383}
6384
6385static inline void
6386btrfs_grab_block_group(struct btrfs_block_group_cache *cache,
6387 int delalloc)
6388{
6389 btrfs_get_block_group(cache);
6390 if (delalloc)
6391 down_read(&cache->data_rwsem);
6392}
6393
6394static struct btrfs_block_group_cache *
6395btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
6396 struct btrfs_free_cluster *cluster,
6397 int delalloc)
6398{
6399 struct btrfs_block_group_cache *used_bg;
6400 bool locked = false;
6401again:
6402 spin_lock(&cluster->refill_lock);
6403 if (locked) {
6404 if (used_bg == cluster->block_group)
6405 return used_bg;
6406
6407 up_read(&used_bg->data_rwsem);
6408 btrfs_put_block_group(used_bg);
6409 }
6410
6411 used_bg = cluster->block_group;
6412 if (!used_bg)
6413 return NULL;
6414
6415 if (used_bg == block_group)
6416 return used_bg;
6417
6418 btrfs_get_block_group(used_bg);
6419
6420 if (!delalloc)
6421 return used_bg;
6422
6423 if (down_read_trylock(&used_bg->data_rwsem))
6424 return used_bg;
6425
6426 spin_unlock(&cluster->refill_lock);
6427 down_read(&used_bg->data_rwsem);
6428 locked = true;
6429 goto again;
6430}
6431
6432static inline void
6433btrfs_release_block_group(struct btrfs_block_group_cache *cache,
6434 int delalloc)
6435{
6436 if (delalloc)
6437 up_read(&cache->data_rwsem);
6438 btrfs_put_block_group(cache);
6439}
6440
6368/* 6441/*
6369 * walks the btree of allocated extents and find a hole of a given size. 6442 * walks the btree of allocated extents and find a hole of a given size.
6370 * The key ins is changed to record the hole: 6443 * The key ins is changed to record the hole:
@@ -6379,7 +6452,7 @@ enum btrfs_loop_type {
6379static noinline int find_free_extent(struct btrfs_root *orig_root, 6452static noinline int find_free_extent(struct btrfs_root *orig_root,
6380 u64 num_bytes, u64 empty_size, 6453 u64 num_bytes, u64 empty_size,
6381 u64 hint_byte, struct btrfs_key *ins, 6454 u64 hint_byte, struct btrfs_key *ins,
6382 u64 flags) 6455 u64 flags, int delalloc)
6383{ 6456{
6384 int ret = 0; 6457 int ret = 0;
6385 struct btrfs_root *root = orig_root->fs_info->extent_root; 6458 struct btrfs_root *root = orig_root->fs_info->extent_root;
@@ -6467,6 +6540,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
6467 up_read(&space_info->groups_sem); 6540 up_read(&space_info->groups_sem);
6468 } else { 6541 } else {
6469 index = get_block_group_index(block_group); 6542 index = get_block_group_index(block_group);
6543 btrfs_lock_block_group(block_group, delalloc);
6470 goto have_block_group; 6544 goto have_block_group;
6471 } 6545 }
6472 } else if (block_group) { 6546 } else if (block_group) {
@@ -6481,7 +6555,7 @@ search:
6481 u64 offset; 6555 u64 offset;
6482 int cached; 6556 int cached;
6483 6557
6484 btrfs_get_block_group(block_group); 6558 btrfs_grab_block_group(block_group, delalloc);
6485 search_start = block_group->key.objectid; 6559 search_start = block_group->key.objectid;
6486 6560
6487 /* 6561 /*
@@ -6529,16 +6603,16 @@ have_block_group:
6529 * the refill lock keeps out other 6603 * the refill lock keeps out other
6530 * people trying to start a new cluster 6604 * people trying to start a new cluster
6531 */ 6605 */
6532 spin_lock(&last_ptr->refill_lock); 6606 used_block_group = btrfs_lock_cluster(block_group,
6533 used_block_group = last_ptr->block_group; 6607 last_ptr,
6534 if (used_block_group != block_group && 6608 delalloc);
6535 (!used_block_group || 6609 if (!used_block_group)
6536 used_block_group->ro ||
6537 !block_group_bits(used_block_group, flags)))
6538 goto refill_cluster; 6610 goto refill_cluster;
6539 6611
6540 if (used_block_group != block_group) 6612 if (used_block_group != block_group &&
6541 btrfs_get_block_group(used_block_group); 6613 (used_block_group->ro ||
6614 !block_group_bits(used_block_group, flags)))
6615 goto release_cluster;
6542 6616
6543 offset = btrfs_alloc_from_cluster(used_block_group, 6617 offset = btrfs_alloc_from_cluster(used_block_group,
6544 last_ptr, 6618 last_ptr,
@@ -6552,16 +6626,15 @@ have_block_group:
6552 used_block_group, 6626 used_block_group,
6553 search_start, num_bytes); 6627 search_start, num_bytes);
6554 if (used_block_group != block_group) { 6628 if (used_block_group != block_group) {
6555 btrfs_put_block_group(block_group); 6629 btrfs_release_block_group(block_group,
6630 delalloc);
6556 block_group = used_block_group; 6631 block_group = used_block_group;
6557 } 6632 }
6558 goto checks; 6633 goto checks;
6559 } 6634 }
6560 6635
6561 WARN_ON(last_ptr->block_group != used_block_group); 6636 WARN_ON(last_ptr->block_group != used_block_group);
6562 if (used_block_group != block_group) 6637release_cluster:
6563 btrfs_put_block_group(used_block_group);
6564refill_cluster:
6565 /* If we are on LOOP_NO_EMPTY_SIZE, we can't 6638 /* If we are on LOOP_NO_EMPTY_SIZE, we can't
6566 * set up a new clusters, so lets just skip it 6639 * set up a new clusters, so lets just skip it
6567 * and let the allocator find whatever block 6640 * and let the allocator find whatever block
@@ -6578,8 +6651,10 @@ refill_cluster:
6578 * succeeding in the unclustered 6651 * succeeding in the unclustered
6579 * allocation. */ 6652 * allocation. */
6580 if (loop >= LOOP_NO_EMPTY_SIZE && 6653 if (loop >= LOOP_NO_EMPTY_SIZE &&
6581 last_ptr->block_group != block_group) { 6654 used_block_group != block_group) {
6582 spin_unlock(&last_ptr->refill_lock); 6655 spin_unlock(&last_ptr->refill_lock);
6656 btrfs_release_block_group(used_block_group,
6657 delalloc);
6583 goto unclustered_alloc; 6658 goto unclustered_alloc;
6584 } 6659 }
6585 6660
@@ -6589,6 +6664,10 @@ refill_cluster:
6589 */ 6664 */
6590 btrfs_return_cluster_to_free_space(NULL, last_ptr); 6665 btrfs_return_cluster_to_free_space(NULL, last_ptr);
6591 6666
6667 if (used_block_group != block_group)
6668 btrfs_release_block_group(used_block_group,
6669 delalloc);
6670refill_cluster:
6592 if (loop >= LOOP_NO_EMPTY_SIZE) { 6671 if (loop >= LOOP_NO_EMPTY_SIZE) {
6593 spin_unlock(&last_ptr->refill_lock); 6672 spin_unlock(&last_ptr->refill_lock);
6594 goto unclustered_alloc; 6673 goto unclustered_alloc;
@@ -6696,7 +6775,7 @@ checks:
6696 BUG_ON(offset > search_start); 6775 BUG_ON(offset > search_start);
6697 6776
6698 ret = btrfs_update_reserved_bytes(block_group, num_bytes, 6777 ret = btrfs_update_reserved_bytes(block_group, num_bytes,
6699 alloc_type); 6778 alloc_type, delalloc);
6700 if (ret == -EAGAIN) { 6779 if (ret == -EAGAIN) {
6701 btrfs_add_free_space(block_group, offset, num_bytes); 6780 btrfs_add_free_space(block_group, offset, num_bytes);
6702 goto loop; 6781 goto loop;
@@ -6708,13 +6787,13 @@ checks:
6708 6787
6709 trace_btrfs_reserve_extent(orig_root, block_group, 6788 trace_btrfs_reserve_extent(orig_root, block_group,
6710 search_start, num_bytes); 6789 search_start, num_bytes);
6711 btrfs_put_block_group(block_group); 6790 btrfs_release_block_group(block_group, delalloc);
6712 break; 6791 break;
6713loop: 6792loop:
6714 failed_cluster_refill = false; 6793 failed_cluster_refill = false;
6715 failed_alloc = false; 6794 failed_alloc = false;
6716 BUG_ON(index != get_block_group_index(block_group)); 6795 BUG_ON(index != get_block_group_index(block_group));
6717 btrfs_put_block_group(block_group); 6796 btrfs_release_block_group(block_group, delalloc);
6718 } 6797 }
6719 up_read(&space_info->groups_sem); 6798 up_read(&space_info->groups_sem);
6720 6799
@@ -6827,7 +6906,7 @@ again:
6827int btrfs_reserve_extent(struct btrfs_root *root, 6906int btrfs_reserve_extent(struct btrfs_root *root,
6828 u64 num_bytes, u64 min_alloc_size, 6907 u64 num_bytes, u64 min_alloc_size,
6829 u64 empty_size, u64 hint_byte, 6908 u64 empty_size, u64 hint_byte,
6830 struct btrfs_key *ins, int is_data) 6909 struct btrfs_key *ins, int is_data, int delalloc)
6831{ 6910{
6832 bool final_tried = false; 6911 bool final_tried = false;
6833 u64 flags; 6912 u64 flags;
@@ -6837,7 +6916,7 @@ int btrfs_reserve_extent(struct btrfs_root *root,
6837again: 6916again:
6838 WARN_ON(num_bytes < root->sectorsize); 6917 WARN_ON(num_bytes < root->sectorsize);
6839 ret = find_free_extent(root, num_bytes, empty_size, hint_byte, ins, 6918 ret = find_free_extent(root, num_bytes, empty_size, hint_byte, ins,
6840 flags); 6919 flags, delalloc);
6841 6920
6842 if (ret == -ENOSPC) { 6921 if (ret == -ENOSPC) {
6843 if (!final_tried && ins->offset) { 6922 if (!final_tried && ins->offset) {
@@ -6862,7 +6941,8 @@ again:
6862} 6941}
6863 6942
6864static int __btrfs_free_reserved_extent(struct btrfs_root *root, 6943static int __btrfs_free_reserved_extent(struct btrfs_root *root,
6865 u64 start, u64 len, int pin) 6944 u64 start, u64 len,
6945 int pin, int delalloc)
6866{ 6946{
6867 struct btrfs_block_group_cache *cache; 6947 struct btrfs_block_group_cache *cache;
6868 int ret = 0; 6948 int ret = 0;
@@ -6881,7 +6961,7 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
6881 pin_down_extent(root, cache, start, len, 1); 6961 pin_down_extent(root, cache, start, len, 1);
6882 else { 6962 else {
6883 btrfs_add_free_space(cache, start, len); 6963 btrfs_add_free_space(cache, start, len);
6884 btrfs_update_reserved_bytes(cache, len, RESERVE_FREE); 6964 btrfs_update_reserved_bytes(cache, len, RESERVE_FREE, delalloc);
6885 } 6965 }
6886 btrfs_put_block_group(cache); 6966 btrfs_put_block_group(cache);
6887 6967
@@ -6891,15 +6971,15 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
6891} 6971}
6892 6972
6893int btrfs_free_reserved_extent(struct btrfs_root *root, 6973int btrfs_free_reserved_extent(struct btrfs_root *root,
6894 u64 start, u64 len) 6974 u64 start, u64 len, int delalloc)
6895{ 6975{
6896 return __btrfs_free_reserved_extent(root, start, len, 0); 6976 return __btrfs_free_reserved_extent(root, start, len, 0, delalloc);
6897} 6977}
6898 6978
6899int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root, 6979int btrfs_free_and_pin_reserved_extent(struct btrfs_root *root,
6900 u64 start, u64 len) 6980 u64 start, u64 len)
6901{ 6981{
6902 return __btrfs_free_reserved_extent(root, start, len, 1); 6982 return __btrfs_free_reserved_extent(root, start, len, 1, 0);
6903} 6983}
6904 6984
6905static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, 6985static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
@@ -7114,7 +7194,7 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans,
7114 return -EINVAL; 7194 return -EINVAL;
7115 7195
7116 ret = btrfs_update_reserved_bytes(block_group, ins->offset, 7196 ret = btrfs_update_reserved_bytes(block_group, ins->offset,
7117 RESERVE_ALLOC_NO_ACCOUNT); 7197 RESERVE_ALLOC_NO_ACCOUNT, 0);
7118 BUG_ON(ret); /* logic error */ 7198 BUG_ON(ret); /* logic error */
7119 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, 7199 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid,
7120 0, owner, offset, ins, 1); 7200 0, owner, offset, ins, 1);
@@ -7256,7 +7336,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
7256 return ERR_CAST(block_rsv); 7336 return ERR_CAST(block_rsv);
7257 7337
7258 ret = btrfs_reserve_extent(root, blocksize, blocksize, 7338 ret = btrfs_reserve_extent(root, blocksize, blocksize,
7259 empty_size, hint, &ins, 0); 7339 empty_size, hint, &ins, 0, 0);
7260 if (ret) { 7340 if (ret) {
7261 unuse_block_rsv(root->fs_info, block_rsv, blocksize); 7341 unuse_block_rsv(root->fs_info, block_rsv, blocksize);
7262 return ERR_PTR(ret); 7342 return ERR_PTR(ret);
@@ -8659,6 +8739,7 @@ btrfs_create_block_group_cache(struct btrfs_root *root, u64 start, u64 size)
8659 start); 8739 start);
8660 atomic_set(&cache->count, 1); 8740 atomic_set(&cache->count, 1);
8661 spin_lock_init(&cache->lock); 8741 spin_lock_init(&cache->lock);
8742 init_rwsem(&cache->data_rwsem);
8662 INIT_LIST_HEAD(&cache->list); 8743 INIT_LIST_HEAD(&cache->list);
8663 INIT_LIST_HEAD(&cache->cluster_list); 8744 INIT_LIST_HEAD(&cache->cluster_list);
8664 INIT_LIST_HEAD(&cache->new_bg_list); 8745 INIT_LIST_HEAD(&cache->new_bg_list);
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 15ce5f2a2b62..ccc264e7bde1 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -158,7 +158,6 @@ struct extent_buffer {
158 * to unlock 158 * to unlock
159 */ 159 */
160 wait_queue_head_t read_lock_wq; 160 wait_queue_head_t read_lock_wq;
161 wait_queue_head_t lock_wq;
162 struct page *pages[INLINE_EXTENT_BUFFER_PAGES]; 161 struct page *pages[INLINE_EXTENT_BUFFER_PAGES];
163#ifdef CONFIG_BTRFS_DEBUG 162#ifdef CONFIG_BTRFS_DEBUG
164 struct list_head leak_list; 163 struct list_head leak_list;
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 1874aee69c86..225302b39afb 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -75,6 +75,8 @@ void free_extent_map(struct extent_map *em)
75 if (atomic_dec_and_test(&em->refs)) { 75 if (atomic_dec_and_test(&em->refs)) {
76 WARN_ON(extent_map_in_tree(em)); 76 WARN_ON(extent_map_in_tree(em));
77 WARN_ON(!list_empty(&em->list)); 77 WARN_ON(!list_empty(&em->list));
78 if (test_bit(EXTENT_FLAG_FS_MAPPING, &em->flags))
79 kfree(em->bdev);
78 kmem_cache_free(extent_map_cache, em); 80 kmem_cache_free(extent_map_cache, em);
79 } 81 }
80} 82}
diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
index e7fd8a56a140..b2991fd8583e 100644
--- a/fs/btrfs/extent_map.h
+++ b/fs/btrfs/extent_map.h
@@ -15,6 +15,7 @@
15#define EXTENT_FLAG_PREALLOC 3 /* pre-allocated extent */ 15#define EXTENT_FLAG_PREALLOC 3 /* pre-allocated extent */
16#define EXTENT_FLAG_LOGGING 4 /* Logging this extent */ 16#define EXTENT_FLAG_LOGGING 4 /* Logging this extent */
17#define EXTENT_FLAG_FILLING 5 /* Filling in a preallocated extent */ 17#define EXTENT_FLAG_FILLING 5 /* Filling in a preallocated extent */
18#define EXTENT_FLAG_FS_MAPPING 6 /* filesystem extent mapping type */
18 19
19struct extent_map { 20struct extent_map {
20 struct rb_node rb_node; 21 struct rb_node rb_node;
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 372b05ff1943..2b0a627cb5f9 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -274,18 +274,32 @@ struct io_ctl {
274}; 274};
275 275
276static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode, 276static int io_ctl_init(struct io_ctl *io_ctl, struct inode *inode,
277 struct btrfs_root *root) 277 struct btrfs_root *root, int write)
278{ 278{
279 int num_pages;
280 int check_crcs = 0;
281
282 num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
283 PAGE_CACHE_SHIFT;
284
285 if (btrfs_ino(inode) != BTRFS_FREE_INO_OBJECTID)
286 check_crcs = 1;
287
288 /* Make sure we can fit our crcs into the first page */
289 if (write && check_crcs &&
290 (num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE)
291 return -ENOSPC;
292
279 memset(io_ctl, 0, sizeof(struct io_ctl)); 293 memset(io_ctl, 0, sizeof(struct io_ctl));
280 io_ctl->num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> 294
281 PAGE_CACHE_SHIFT; 295 io_ctl->pages = kzalloc(sizeof(struct page *) * num_pages, GFP_NOFS);
282 io_ctl->pages = kzalloc(sizeof(struct page *) * io_ctl->num_pages,
283 GFP_NOFS);
284 if (!io_ctl->pages) 296 if (!io_ctl->pages)
285 return -ENOMEM; 297 return -ENOMEM;
298
299 io_ctl->num_pages = num_pages;
286 io_ctl->root = root; 300 io_ctl->root = root;
287 if (btrfs_ino(inode) != BTRFS_FREE_INO_OBJECTID) 301 io_ctl->check_crcs = check_crcs;
288 io_ctl->check_crcs = 1; 302
289 return 0; 303 return 0;
290} 304}
291 305
@@ -666,6 +680,13 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
666 generation = btrfs_free_space_generation(leaf, header); 680 generation = btrfs_free_space_generation(leaf, header);
667 btrfs_release_path(path); 681 btrfs_release_path(path);
668 682
683 if (!BTRFS_I(inode)->generation) {
684 btrfs_info(root->fs_info,
685 "The free space cache file (%llu) is invalid. skip it\n",
686 offset);
687 return 0;
688 }
689
669 if (BTRFS_I(inode)->generation != generation) { 690 if (BTRFS_I(inode)->generation != generation) {
670 btrfs_err(root->fs_info, 691 btrfs_err(root->fs_info,
671 "free space inode generation (%llu) " 692 "free space inode generation (%llu) "
@@ -677,7 +698,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
677 if (!num_entries) 698 if (!num_entries)
678 return 0; 699 return 0;
679 700
680 ret = io_ctl_init(&io_ctl, inode, root); 701 ret = io_ctl_init(&io_ctl, inode, root, 0);
681 if (ret) 702 if (ret)
682 return ret; 703 return ret;
683 704
@@ -957,19 +978,18 @@ fail:
957} 978}
958 979
959static noinline_for_stack int 980static noinline_for_stack int
960add_ioctl_entries(struct btrfs_root *root, 981write_pinned_extent_entries(struct btrfs_root *root,
961 struct inode *inode, 982 struct btrfs_block_group_cache *block_group,
962 struct btrfs_block_group_cache *block_group, 983 struct io_ctl *io_ctl,
963 struct io_ctl *io_ctl, 984 int *entries)
964 struct extent_state **cached_state,
965 struct list_head *bitmap_list,
966 int *entries)
967{ 985{
968 u64 start, extent_start, extent_end, len; 986 u64 start, extent_start, extent_end, len;
969 struct list_head *pos, *n;
970 struct extent_io_tree *unpin = NULL; 987 struct extent_io_tree *unpin = NULL;
971 int ret; 988 int ret;
972 989
990 if (!block_group)
991 return 0;
992
973 /* 993 /*
974 * We want to add any pinned extents to our free space cache 994 * We want to add any pinned extents to our free space cache
975 * so we don't leak the space 995 * so we don't leak the space
@@ -979,23 +999,19 @@ add_ioctl_entries(struct btrfs_root *root,
979 */ 999 */
980 unpin = root->fs_info->pinned_extents; 1000 unpin = root->fs_info->pinned_extents;
981 1001
982 if (block_group) 1002 start = block_group->key.objectid;
983 start = block_group->key.objectid;
984 1003
985 while (block_group && (start < block_group->key.objectid + 1004 while (start < block_group->key.objectid + block_group->key.offset) {
986 block_group->key.offset)) {
987 ret = find_first_extent_bit(unpin, start, 1005 ret = find_first_extent_bit(unpin, start,
988 &extent_start, &extent_end, 1006 &extent_start, &extent_end,
989 EXTENT_DIRTY, NULL); 1007 EXTENT_DIRTY, NULL);
990 if (ret) { 1008 if (ret)
991 ret = 0; 1009 return 0;
992 break;
993 }
994 1010
995 /* This pinned extent is out of our range */ 1011 /* This pinned extent is out of our range */
996 if (extent_start >= block_group->key.objectid + 1012 if (extent_start >= block_group->key.objectid +
997 block_group->key.offset) 1013 block_group->key.offset)
998 break; 1014 return 0;
999 1015
1000 extent_start = max(extent_start, start); 1016 extent_start = max(extent_start, start);
1001 extent_end = min(block_group->key.objectid + 1017 extent_end = min(block_group->key.objectid +
@@ -1005,11 +1021,20 @@ add_ioctl_entries(struct btrfs_root *root,
1005 *entries += 1; 1021 *entries += 1;
1006 ret = io_ctl_add_entry(io_ctl, extent_start, len, NULL); 1022 ret = io_ctl_add_entry(io_ctl, extent_start, len, NULL);
1007 if (ret) 1023 if (ret)
1008 goto out_nospc; 1024 return -ENOSPC;
1009 1025
1010 start = extent_end; 1026 start = extent_end;
1011 } 1027 }
1012 1028
1029 return 0;
1030}
1031
1032static noinline_for_stack int
1033write_bitmap_entries(struct io_ctl *io_ctl, struct list_head *bitmap_list)
1034{
1035 struct list_head *pos, *n;
1036 int ret;
1037
1013 /* Write out the bitmaps */ 1038 /* Write out the bitmaps */
1014 list_for_each_safe(pos, n, bitmap_list) { 1039 list_for_each_safe(pos, n, bitmap_list) {
1015 struct btrfs_free_space *entry = 1040 struct btrfs_free_space *entry =
@@ -1017,36 +1042,24 @@ add_ioctl_entries(struct btrfs_root *root,
1017 1042
1018 ret = io_ctl_add_bitmap(io_ctl, entry->bitmap); 1043 ret = io_ctl_add_bitmap(io_ctl, entry->bitmap);
1019 if (ret) 1044 if (ret)
1020 goto out_nospc; 1045 return -ENOSPC;
1021 list_del_init(&entry->list); 1046 list_del_init(&entry->list);
1022 } 1047 }
1023 1048
1024 /* Zero out the rest of the pages just to make sure */ 1049 return 0;
1025 io_ctl_zero_remaining_pages(io_ctl); 1050}
1026
1027 ret = btrfs_dirty_pages(root, inode, io_ctl->pages, io_ctl->num_pages,
1028 0, i_size_read(inode), cached_state);
1029 io_ctl_drop_pages(io_ctl);
1030 unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
1031 i_size_read(inode) - 1, cached_state, GFP_NOFS);
1032 1051
1033 if (ret) 1052static int flush_dirty_cache(struct inode *inode)
1034 goto fail; 1053{
1054 int ret;
1035 1055
1036 ret = btrfs_wait_ordered_range(inode, 0, (u64)-1); 1056 ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
1037 if (ret) { 1057 if (ret)
1038 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1, 1058 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1039 EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL, 1059 EXTENT_DIRTY | EXTENT_DELALLOC, 0, 0, NULL,
1040 GFP_NOFS); 1060 GFP_NOFS);
1041 goto fail;
1042 }
1043 return 0;
1044 1061
1045fail: 1062 return ret;
1046 return -1;
1047
1048out_nospc:
1049 return -ENOSPC;
1050} 1063}
1051 1064
1052static void noinline_for_stack 1065static void noinline_for_stack
@@ -1056,6 +1069,7 @@ cleanup_write_cache_enospc(struct inode *inode,
1056 struct list_head *bitmap_list) 1069 struct list_head *bitmap_list)
1057{ 1070{
1058 struct list_head *pos, *n; 1071 struct list_head *pos, *n;
1072
1059 list_for_each_safe(pos, n, bitmap_list) { 1073 list_for_each_safe(pos, n, bitmap_list) {
1060 struct btrfs_free_space *entry = 1074 struct btrfs_free_space *entry =
1061 list_entry(pos, struct btrfs_free_space, list); 1075 list_entry(pos, struct btrfs_free_space, list);
@@ -1088,64 +1102,104 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
1088{ 1102{
1089 struct extent_state *cached_state = NULL; 1103 struct extent_state *cached_state = NULL;
1090 struct io_ctl io_ctl; 1104 struct io_ctl io_ctl;
1091 struct list_head bitmap_list; 1105 LIST_HEAD(bitmap_list);
1092 int entries = 0; 1106 int entries = 0;
1093 int bitmaps = 0; 1107 int bitmaps = 0;
1094 int ret; 1108 int ret;
1095 int err = -1;
1096
1097 INIT_LIST_HEAD(&bitmap_list);
1098 1109
1099 if (!i_size_read(inode)) 1110 if (!i_size_read(inode))
1100 return -1; 1111 return -1;
1101 1112
1102 ret = io_ctl_init(&io_ctl, inode, root); 1113 ret = io_ctl_init(&io_ctl, inode, root, 1);
1103 if (ret) 1114 if (ret)
1104 return -1; 1115 return -1;
1105 1116
1117 if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA)) {
1118 down_write(&block_group->data_rwsem);
1119 spin_lock(&block_group->lock);
1120 if (block_group->delalloc_bytes) {
1121 block_group->disk_cache_state = BTRFS_DC_WRITTEN;
1122 spin_unlock(&block_group->lock);
1123 up_write(&block_group->data_rwsem);
1124 BTRFS_I(inode)->generation = 0;
1125 ret = 0;
1126 goto out;
1127 }
1128 spin_unlock(&block_group->lock);
1129 }
1130
1106 /* Lock all pages first so we can lock the extent safely. */ 1131 /* Lock all pages first so we can lock the extent safely. */
1107 io_ctl_prepare_pages(&io_ctl, inode, 0); 1132 io_ctl_prepare_pages(&io_ctl, inode, 0);
1108 1133
1109 lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1, 1134 lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
1110 0, &cached_state); 1135 0, &cached_state);
1111 1136
1112
1113 /* Make sure we can fit our crcs into the first page */
1114 if (io_ctl.check_crcs &&
1115 (io_ctl.num_pages * sizeof(u32)) >= PAGE_CACHE_SIZE)
1116 goto out_nospc;
1117
1118 io_ctl_set_generation(&io_ctl, trans->transid); 1137 io_ctl_set_generation(&io_ctl, trans->transid);
1119 1138
1139 /* Write out the extent entries in the free space cache */
1120 ret = write_cache_extent_entries(&io_ctl, ctl, 1140 ret = write_cache_extent_entries(&io_ctl, ctl,
1121 block_group, &entries, &bitmaps, 1141 block_group, &entries, &bitmaps,
1122 &bitmap_list); 1142 &bitmap_list);
1123 if (ret) 1143 if (ret)
1124 goto out_nospc; 1144 goto out_nospc;
1125 1145
1126 ret = add_ioctl_entries(root, inode, block_group, &io_ctl, 1146 /*
1127 &cached_state, &bitmap_list, &entries); 1147 * Some spaces that are freed in the current transaction are pinned,
1148 * they will be added into free space cache after the transaction is
1149 * committed, we shouldn't lose them.
1150 */
1151 ret = write_pinned_extent_entries(root, block_group, &io_ctl, &entries);
1152 if (ret)
1153 goto out_nospc;
1128 1154
1129 if (ret == -ENOSPC) 1155 /* At last, we write out all the bitmaps. */
1156 ret = write_bitmap_entries(&io_ctl, &bitmap_list);
1157 if (ret)
1130 goto out_nospc; 1158 goto out_nospc;
1131 else if (ret) 1159
1160 /* Zero out the rest of the pages just to make sure */
1161 io_ctl_zero_remaining_pages(&io_ctl);
1162
1163 /* Everything is written out, now we dirty the pages in the file. */
1164 ret = btrfs_dirty_pages(root, inode, io_ctl.pages, io_ctl.num_pages,
1165 0, i_size_read(inode), &cached_state);
1166 if (ret)
1167 goto out_nospc;
1168
1169 if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
1170 up_write(&block_group->data_rwsem);
1171 /*
1172 * Release the pages and unlock the extent, we will flush
1173 * them out later
1174 */
1175 io_ctl_drop_pages(&io_ctl);
1176
1177 unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
1178 i_size_read(inode) - 1, &cached_state, GFP_NOFS);
1179
1180 /* Flush the dirty pages in the cache file. */
1181 ret = flush_dirty_cache(inode);
1182 if (ret)
1132 goto out; 1183 goto out;
1133 1184
1134 err = update_cache_item(trans, root, inode, path, offset, 1185 /* Update the cache item to tell everyone this cache file is valid. */
1186 ret = update_cache_item(trans, root, inode, path, offset,
1135 entries, bitmaps); 1187 entries, bitmaps);
1136
1137out: 1188out:
1138 io_ctl_free(&io_ctl); 1189 io_ctl_free(&io_ctl);
1139 if (err) { 1190 if (ret) {
1140 invalidate_inode_pages2(inode->i_mapping); 1191 invalidate_inode_pages2(inode->i_mapping);
1141 BTRFS_I(inode)->generation = 0; 1192 BTRFS_I(inode)->generation = 0;
1142 } 1193 }
1143 btrfs_update_inode(trans, root, inode); 1194 btrfs_update_inode(trans, root, inode);
1144 return err; 1195 return ret;
1145 1196
1146out_nospc: 1197out_nospc:
1147
1148 cleanup_write_cache_enospc(inode, &io_ctl, &cached_state, &bitmap_list); 1198 cleanup_write_cache_enospc(inode, &io_ctl, &cached_state, &bitmap_list);
1199
1200 if (block_group && (block_group->flags & BTRFS_BLOCK_GROUP_DATA))
1201 up_write(&block_group->data_rwsem);
1202
1149 goto out; 1203 goto out;
1150} 1204}
1151 1205
@@ -1165,6 +1219,12 @@ int btrfs_write_out_cache(struct btrfs_root *root,
1165 spin_unlock(&block_group->lock); 1219 spin_unlock(&block_group->lock);
1166 return 0; 1220 return 0;
1167 } 1221 }
1222
1223 if (block_group->delalloc_bytes) {
1224 block_group->disk_cache_state = BTRFS_DC_WRITTEN;
1225 spin_unlock(&block_group->lock);
1226 return 0;
1227 }
1168 spin_unlock(&block_group->lock); 1228 spin_unlock(&block_group->lock);
1169 1229
1170 inode = lookup_free_space_inode(root, block_group, path); 1230 inode = lookup_free_space_inode(root, block_group, path);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8925f66a1411..3668048e16f8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -693,7 +693,7 @@ retry:
693 ret = btrfs_reserve_extent(root, 693 ret = btrfs_reserve_extent(root,
694 async_extent->compressed_size, 694 async_extent->compressed_size,
695 async_extent->compressed_size, 695 async_extent->compressed_size,
696 0, alloc_hint, &ins, 1); 696 0, alloc_hint, &ins, 1, 1);
697 if (ret) { 697 if (ret) {
698 int i; 698 int i;
699 699
@@ -794,7 +794,7 @@ retry:
794out: 794out:
795 return ret; 795 return ret;
796out_free_reserve: 796out_free_reserve:
797 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 797 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
798out_free: 798out_free:
799 extent_clear_unlock_delalloc(inode, async_extent->start, 799 extent_clear_unlock_delalloc(inode, async_extent->start,
800 async_extent->start + 800 async_extent->start +
@@ -917,7 +917,7 @@ static noinline int cow_file_range(struct inode *inode,
917 cur_alloc_size = disk_num_bytes; 917 cur_alloc_size = disk_num_bytes;
918 ret = btrfs_reserve_extent(root, cur_alloc_size, 918 ret = btrfs_reserve_extent(root, cur_alloc_size,
919 root->sectorsize, 0, alloc_hint, 919 root->sectorsize, 0, alloc_hint,
920 &ins, 1); 920 &ins, 1, 1);
921 if (ret < 0) 921 if (ret < 0)
922 goto out_unlock; 922 goto out_unlock;
923 923
@@ -995,7 +995,7 @@ out:
995 return ret; 995 return ret;
996 996
997out_reserve: 997out_reserve:
998 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 998 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
999out_unlock: 999out_unlock:
1000 extent_clear_unlock_delalloc(inode, start, end, locked_page, 1000 extent_clear_unlock_delalloc(inode, start, end, locked_page,
1001 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING | 1001 EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
@@ -2599,6 +2599,21 @@ out_kfree:
2599 return NULL; 2599 return NULL;
2600} 2600}
2601 2601
2602static void btrfs_release_delalloc_bytes(struct btrfs_root *root,
2603 u64 start, u64 len)
2604{
2605 struct btrfs_block_group_cache *cache;
2606
2607 cache = btrfs_lookup_block_group(root->fs_info, start);
2608 ASSERT(cache);
2609
2610 spin_lock(&cache->lock);
2611 cache->delalloc_bytes -= len;
2612 spin_unlock(&cache->lock);
2613
2614 btrfs_put_block_group(cache);
2615}
2616
2602/* as ordered data IO finishes, this gets called so we can finish 2617/* as ordered data IO finishes, this gets called so we can finish
2603 * an ordered extent if the range of bytes in the file it covers are 2618 * an ordered extent if the range of bytes in the file it covers are
2604 * fully written. 2619 * fully written.
@@ -2698,6 +2713,10 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
2698 logical_len, logical_len, 2713 logical_len, logical_len,
2699 compress_type, 0, 0, 2714 compress_type, 0, 0,
2700 BTRFS_FILE_EXTENT_REG); 2715 BTRFS_FILE_EXTENT_REG);
2716 if (!ret)
2717 btrfs_release_delalloc_bytes(root,
2718 ordered_extent->start,
2719 ordered_extent->disk_len);
2701 } 2720 }
2702 unpin_extent_cache(&BTRFS_I(inode)->extent_tree, 2721 unpin_extent_cache(&BTRFS_I(inode)->extent_tree,
2703 ordered_extent->file_offset, ordered_extent->len, 2722 ordered_extent->file_offset, ordered_extent->len,
@@ -2750,7 +2769,7 @@ out:
2750 !test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) && 2769 !test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&
2751 !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) 2770 !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags))
2752 btrfs_free_reserved_extent(root, ordered_extent->start, 2771 btrfs_free_reserved_extent(root, ordered_extent->start,
2753 ordered_extent->disk_len); 2772 ordered_extent->disk_len, 1);
2754 } 2773 }
2755 2774
2756 2775
@@ -6535,21 +6554,21 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode,
6535 6554
6536 alloc_hint = get_extent_allocation_hint(inode, start, len); 6555 alloc_hint = get_extent_allocation_hint(inode, start, len);
6537 ret = btrfs_reserve_extent(root, len, root->sectorsize, 0, 6556 ret = btrfs_reserve_extent(root, len, root->sectorsize, 0,
6538 alloc_hint, &ins, 1); 6557 alloc_hint, &ins, 1, 1);
6539 if (ret) 6558 if (ret)
6540 return ERR_PTR(ret); 6559 return ERR_PTR(ret);
6541 6560
6542 em = create_pinned_em(inode, start, ins.offset, start, ins.objectid, 6561 em = create_pinned_em(inode, start, ins.offset, start, ins.objectid,
6543 ins.offset, ins.offset, ins.offset, 0); 6562 ins.offset, ins.offset, ins.offset, 0);
6544 if (IS_ERR(em)) { 6563 if (IS_ERR(em)) {
6545 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 6564 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
6546 return em; 6565 return em;
6547 } 6566 }
6548 6567
6549 ret = btrfs_add_ordered_extent_dio(inode, start, ins.objectid, 6568 ret = btrfs_add_ordered_extent_dio(inode, start, ins.objectid,
6550 ins.offset, ins.offset, 0); 6569 ins.offset, ins.offset, 0);
6551 if (ret) { 6570 if (ret) {
6552 btrfs_free_reserved_extent(root, ins.objectid, ins.offset); 6571 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
6553 free_extent_map(em); 6572 free_extent_map(em);
6554 return ERR_PTR(ret); 6573 return ERR_PTR(ret);
6555 } 6574 }
@@ -7437,7 +7456,7 @@ free_ordered:
7437 if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) && 7456 if (!test_bit(BTRFS_ORDERED_PREALLOC, &ordered->flags) &&
7438 !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) 7457 !test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags))
7439 btrfs_free_reserved_extent(root, ordered->start, 7458 btrfs_free_reserved_extent(root, ordered->start,
7440 ordered->disk_len); 7459 ordered->disk_len, 1);
7441 btrfs_put_ordered_extent(ordered); 7460 btrfs_put_ordered_extent(ordered);
7442 btrfs_put_ordered_extent(ordered); 7461 btrfs_put_ordered_extent(ordered);
7443 } 7462 }
@@ -8808,7 +8827,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
8808 cur_bytes = min(num_bytes, 256ULL * 1024 * 1024); 8827 cur_bytes = min(num_bytes, 256ULL * 1024 * 1024);
8809 cur_bytes = max(cur_bytes, min_size); 8828 cur_bytes = max(cur_bytes, min_size);
8810 ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0, 8829 ret = btrfs_reserve_extent(root, cur_bytes, min_size, 0,
8811 *alloc_hint, &ins, 1); 8830 *alloc_hint, &ins, 1, 0);
8812 if (ret) { 8831 if (ret) {
8813 if (own_trans) 8832 if (own_trans)
8814 btrfs_end_transaction(trans, root); 8833 btrfs_end_transaction(trans, root);
@@ -8822,7 +8841,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
8822 BTRFS_FILE_EXTENT_PREALLOC); 8841 BTRFS_FILE_EXTENT_PREALLOC);
8823 if (ret) { 8842 if (ret) {
8824 btrfs_free_reserved_extent(root, ins.objectid, 8843 btrfs_free_reserved_extent(root, ins.objectid,
8825 ins.offset); 8844 ins.offset, 0);
8826 btrfs_abort_transaction(trans, root, ret); 8845 btrfs_abort_transaction(trans, root, ret);
8827 if (own_trans) 8846 if (own_trans)
8828 btrfs_end_transaction(trans, root); 8847 btrfs_end_transaction(trans, root);
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 01277b8f2373..5665d2149249 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -33,14 +33,14 @@ static void btrfs_assert_tree_read_locked(struct extent_buffer *eb);
33 */ 33 */
34void btrfs_set_lock_blocking_rw(struct extent_buffer *eb, int rw) 34void btrfs_set_lock_blocking_rw(struct extent_buffer *eb, int rw)
35{ 35{
36 if (eb->lock_nested) { 36 /*
37 read_lock(&eb->lock); 37 * no lock is required. The lock owner may change if
38 if (eb->lock_nested && current->pid == eb->lock_owner) { 38 * we have a read lock, but it won't change to or away
39 read_unlock(&eb->lock); 39 * from us. If we have the write lock, we are the owner
40 return; 40 * and it'll never change.
41 } 41 */
42 read_unlock(&eb->lock); 42 if (eb->lock_nested && current->pid == eb->lock_owner)
43 } 43 return;
44 if (rw == BTRFS_WRITE_LOCK) { 44 if (rw == BTRFS_WRITE_LOCK) {
45 if (atomic_read(&eb->blocking_writers) == 0) { 45 if (atomic_read(&eb->blocking_writers) == 0) {
46 WARN_ON(atomic_read(&eb->spinning_writers) != 1); 46 WARN_ON(atomic_read(&eb->spinning_writers) != 1);
@@ -65,14 +65,15 @@ void btrfs_set_lock_blocking_rw(struct extent_buffer *eb, int rw)
65 */ 65 */
66void btrfs_clear_lock_blocking_rw(struct extent_buffer *eb, int rw) 66void btrfs_clear_lock_blocking_rw(struct extent_buffer *eb, int rw)
67{ 67{
68 if (eb->lock_nested) { 68 /*
69 read_lock(&eb->lock); 69 * no lock is required. The lock owner may change if
70 if (eb->lock_nested && current->pid == eb->lock_owner) { 70 * we have a read lock, but it won't change to or away
71 read_unlock(&eb->lock); 71 * from us. If we have the write lock, we are the owner
72 return; 72 * and it'll never change.
73 } 73 */
74 read_unlock(&eb->lock); 74 if (eb->lock_nested && current->pid == eb->lock_owner)
75 } 75 return;
76
76 if (rw == BTRFS_WRITE_LOCK_BLOCKING) { 77 if (rw == BTRFS_WRITE_LOCK_BLOCKING) {
77 BUG_ON(atomic_read(&eb->blocking_writers) != 1); 78 BUG_ON(atomic_read(&eb->blocking_writers) != 1);
78 write_lock(&eb->lock); 79 write_lock(&eb->lock);
@@ -99,6 +100,9 @@ void btrfs_clear_lock_blocking_rw(struct extent_buffer *eb, int rw)
99void btrfs_tree_read_lock(struct extent_buffer *eb) 100void btrfs_tree_read_lock(struct extent_buffer *eb)
100{ 101{
101again: 102again:
103 BUG_ON(!atomic_read(&eb->blocking_writers) &&
104 current->pid == eb->lock_owner);
105
102 read_lock(&eb->lock); 106 read_lock(&eb->lock);
103 if (atomic_read(&eb->blocking_writers) && 107 if (atomic_read(&eb->blocking_writers) &&
104 current->pid == eb->lock_owner) { 108 current->pid == eb->lock_owner) {
@@ -132,7 +136,9 @@ int btrfs_try_tree_read_lock(struct extent_buffer *eb)
132 if (atomic_read(&eb->blocking_writers)) 136 if (atomic_read(&eb->blocking_writers))
133 return 0; 137 return 0;
134 138
135 read_lock(&eb->lock); 139 if (!read_trylock(&eb->lock))
140 return 0;
141
136 if (atomic_read(&eb->blocking_writers)) { 142 if (atomic_read(&eb->blocking_writers)) {
137 read_unlock(&eb->lock); 143 read_unlock(&eb->lock);
138 return 0; 144 return 0;
@@ -151,7 +157,10 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
151 if (atomic_read(&eb->blocking_writers) || 157 if (atomic_read(&eb->blocking_writers) ||
152 atomic_read(&eb->blocking_readers)) 158 atomic_read(&eb->blocking_readers))
153 return 0; 159 return 0;
154 write_lock(&eb->lock); 160
161 if (!write_trylock(&eb->lock))
162 return 0;
163
155 if (atomic_read(&eb->blocking_writers) || 164 if (atomic_read(&eb->blocking_writers) ||
156 atomic_read(&eb->blocking_readers)) { 165 atomic_read(&eb->blocking_readers)) {
157 write_unlock(&eb->lock); 166 write_unlock(&eb->lock);
@@ -168,14 +177,15 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
168 */ 177 */
169void btrfs_tree_read_unlock(struct extent_buffer *eb) 178void btrfs_tree_read_unlock(struct extent_buffer *eb)
170{ 179{
171 if (eb->lock_nested) { 180 /*
172 read_lock(&eb->lock); 181 * if we're nested, we have the write lock. No new locking
173 if (eb->lock_nested && current->pid == eb->lock_owner) { 182 * is needed as long as we are the lock owner.
174 eb->lock_nested = 0; 183 * The write unlock will do a barrier for us, and the lock_nested
175 read_unlock(&eb->lock); 184 * field only matters to the lock owner.
176 return; 185 */
177 } 186 if (eb->lock_nested && current->pid == eb->lock_owner) {
178 read_unlock(&eb->lock); 187 eb->lock_nested = 0;
188 return;
179 } 189 }
180 btrfs_assert_tree_read_locked(eb); 190 btrfs_assert_tree_read_locked(eb);
181 WARN_ON(atomic_read(&eb->spinning_readers) == 0); 191 WARN_ON(atomic_read(&eb->spinning_readers) == 0);
@@ -189,14 +199,15 @@ void btrfs_tree_read_unlock(struct extent_buffer *eb)
189 */ 199 */
190void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb) 200void btrfs_tree_read_unlock_blocking(struct extent_buffer *eb)
191{ 201{
192 if (eb->lock_nested) { 202 /*
193 read_lock(&eb->lock); 203 * if we're nested, we have the write lock. No new locking
194 if (eb->lock_nested && current->pid == eb->lock_owner) { 204 * is needed as long as we are the lock owner.
195 eb->lock_nested = 0; 205 * The write unlock will do a barrier for us, and the lock_nested
196 read_unlock(&eb->lock); 206 * field only matters to the lock owner.
197 return; 207 */
198 } 208 if (eb->lock_nested && current->pid == eb->lock_owner) {
199 read_unlock(&eb->lock); 209 eb->lock_nested = 0;
210 return;
200 } 211 }
201 btrfs_assert_tree_read_locked(eb); 212 btrfs_assert_tree_read_locked(eb);
202 WARN_ON(atomic_read(&eb->blocking_readers) == 0); 213 WARN_ON(atomic_read(&eb->blocking_readers) == 0);
@@ -244,6 +255,7 @@ void btrfs_tree_unlock(struct extent_buffer *eb)
244 BUG_ON(blockers > 1); 255 BUG_ON(blockers > 1);
245 256
246 btrfs_assert_tree_locked(eb); 257 btrfs_assert_tree_locked(eb);
258 eb->lock_owner = 0;
247 atomic_dec(&eb->write_locks); 259 atomic_dec(&eb->write_locks);
248 260
249 if (blockers) { 261 if (blockers) {
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index ac80188eec88..b6d198f5181e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2725,11 +2725,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
2725 dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent); 2725 dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);
2726 length = btrfs_dev_extent_length(l, dev_extent); 2726 length = btrfs_dev_extent_length(l, dev_extent);
2727 2727
2728 if (found_key.offset + length <= start) { 2728 if (found_key.offset + length <= start)
2729 key.offset = found_key.offset + length; 2729 goto skip;
2730 btrfs_release_path(path);
2731 continue;
2732 }
2733 2730
2734 chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent); 2731 chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent);
2735 chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent); 2732 chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent);
@@ -2740,10 +2737,12 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
2740 * the chunk from going away while we scrub it 2737 * the chunk from going away while we scrub it
2741 */ 2738 */
2742 cache = btrfs_lookup_block_group(fs_info, chunk_offset); 2739 cache = btrfs_lookup_block_group(fs_info, chunk_offset);
2743 if (!cache) { 2740
2744 ret = -ENOENT; 2741 /* some chunks are removed but not committed to disk yet,
2745 break; 2742 * continue scrubbing */
2746 } 2743 if (!cache)
2744 goto skip;
2745
2747 dev_replace->cursor_right = found_key.offset + length; 2746 dev_replace->cursor_right = found_key.offset + length;
2748 dev_replace->cursor_left = found_key.offset; 2747 dev_replace->cursor_left = found_key.offset;
2749 dev_replace->item_needs_writeback = 1; 2748 dev_replace->item_needs_writeback = 1;
@@ -2802,7 +2801,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
2802 2801
2803 dev_replace->cursor_left = dev_replace->cursor_right; 2802 dev_replace->cursor_left = dev_replace->cursor_right;
2804 dev_replace->item_needs_writeback = 1; 2803 dev_replace->item_needs_writeback = 1;
2805 2804skip:
2806 key.offset = found_key.offset + length; 2805 key.offset = found_key.offset + length;
2807 btrfs_release_path(path); 2806 btrfs_release_path(path);
2808 } 2807 }
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ffeed6d6326f..c83b24251e53 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2543,9 +2543,6 @@ static int btrfs_relocate_chunk(struct btrfs_root *root,
2543 remove_extent_mapping(em_tree, em); 2543 remove_extent_mapping(em_tree, em);
2544 write_unlock(&em_tree->lock); 2544 write_unlock(&em_tree->lock);
2545 2545
2546 kfree(map);
2547 em->bdev = NULL;
2548
2549 /* once for the tree */ 2546 /* once for the tree */
2550 free_extent_map(em); 2547 free_extent_map(em);
2551 /* once for us */ 2548 /* once for us */
@@ -4301,9 +4298,11 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
4301 4298
4302 em = alloc_extent_map(); 4299 em = alloc_extent_map();
4303 if (!em) { 4300 if (!em) {
4301 kfree(map);
4304 ret = -ENOMEM; 4302 ret = -ENOMEM;
4305 goto error; 4303 goto error;
4306 } 4304 }
4305 set_bit(EXTENT_FLAG_FS_MAPPING, &em->flags);
4307 em->bdev = (struct block_device *)map; 4306 em->bdev = (struct block_device *)map;
4308 em->start = start; 4307 em->start = start;
4309 em->len = num_bytes; 4308 em->len = num_bytes;
@@ -4346,7 +4345,6 @@ error_del_extent:
4346 /* One for the tree reference */ 4345 /* One for the tree reference */
4347 free_extent_map(em); 4346 free_extent_map(em);
4348error: 4347error:
4349 kfree(map);
4350 kfree(devices_info); 4348 kfree(devices_info);
4351 return ret; 4349 return ret;
4352} 4350}
@@ -4558,7 +4556,6 @@ void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree)
4558 write_unlock(&tree->map_tree.lock); 4556 write_unlock(&tree->map_tree.lock);
4559 if (!em) 4557 if (!em)
4560 break; 4558 break;
4561 kfree(em->bdev);
4562 /* once for us */ 4559 /* once for us */
4563 free_extent_map(em); 4560 free_extent_map(em);
4564 /* once for the tree */ 4561 /* once for the tree */
@@ -5362,6 +5359,15 @@ int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
5362 return 0; 5359 return 0;
5363} 5360}
5364 5361
5362static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio, int err)
5363{
5364 if (likely(bbio->flags & BTRFS_BIO_ORIG_BIO_SUBMITTED))
5365 bio_endio_nodec(bio, err);
5366 else
5367 bio_endio(bio, err);
5368 kfree(bbio);
5369}
5370
5365static void btrfs_end_bio(struct bio *bio, int err) 5371static void btrfs_end_bio(struct bio *bio, int err)
5366{ 5372{
5367 struct btrfs_bio *bbio = bio->bi_private; 5373 struct btrfs_bio *bbio = bio->bi_private;
@@ -5402,12 +5408,6 @@ static void btrfs_end_bio(struct bio *bio, int err)
5402 bio = bbio->orig_bio; 5408 bio = bbio->orig_bio;
5403 } 5409 }
5404 5410
5405 /*
5406 * We have original bio now. So increment bi_remaining to
5407 * account for it in endio
5408 */
5409 atomic_inc(&bio->bi_remaining);
5410
5411 bio->bi_private = bbio->private; 5411 bio->bi_private = bbio->private;
5412 bio->bi_end_io = bbio->end_io; 5412 bio->bi_end_io = bbio->end_io;
5413 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 5413 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num;
@@ -5424,9 +5424,8 @@ static void btrfs_end_bio(struct bio *bio, int err)
5424 set_bit(BIO_UPTODATE, &bio->bi_flags); 5424 set_bit(BIO_UPTODATE, &bio->bi_flags);
5425 err = 0; 5425 err = 0;
5426 } 5426 }
5427 kfree(bbio);
5428 5427
5429 bio_endio(bio, err); 5428 btrfs_end_bbio(bbio, bio, err);
5430 } else if (!is_orig_bio) { 5429 } else if (!is_orig_bio) {
5431 bio_put(bio); 5430 bio_put(bio);
5432 } 5431 }
@@ -5589,12 +5588,15 @@ static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical)
5589{ 5588{
5590 atomic_inc(&bbio->error); 5589 atomic_inc(&bbio->error);
5591 if (atomic_dec_and_test(&bbio->stripes_pending)) { 5590 if (atomic_dec_and_test(&bbio->stripes_pending)) {
5591 /* Shoud be the original bio. */
5592 WARN_ON(bio != bbio->orig_bio);
5593
5592 bio->bi_private = bbio->private; 5594 bio->bi_private = bbio->private;
5593 bio->bi_end_io = bbio->end_io; 5595 bio->bi_end_io = bbio->end_io;
5594 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; 5596 btrfs_io_bio(bio)->mirror_num = bbio->mirror_num;
5595 bio->bi_iter.bi_sector = logical >> 9; 5597 bio->bi_iter.bi_sector = logical >> 9;
5596 kfree(bbio); 5598
5597 bio_endio(bio, -EIO); 5599 btrfs_end_bbio(bbio, bio, -EIO);
5598 } 5600 }
5599} 5601}
5600 5602
@@ -5681,6 +5683,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio,
5681 BUG_ON(!bio); /* -ENOMEM */ 5683 BUG_ON(!bio); /* -ENOMEM */
5682 } else { 5684 } else {
5683 bio = first_bio; 5685 bio = first_bio;
5686 bbio->flags |= BTRFS_BIO_ORIG_BIO_SUBMITTED;
5684 } 5687 }
5685 5688
5686 submit_stripe_bio(root, bbio, bio, 5689 submit_stripe_bio(root, bbio, bio,
@@ -5822,6 +5825,7 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
5822 return -ENOMEM; 5825 return -ENOMEM;
5823 } 5826 }
5824 5827
5828 set_bit(EXTENT_FLAG_FS_MAPPING, &em->flags);
5825 em->bdev = (struct block_device *)map; 5829 em->bdev = (struct block_device *)map;
5826 em->start = logical; 5830 em->start = logical;
5827 em->len = length; 5831 em->len = length;
@@ -5846,7 +5850,6 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
5846 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, 5850 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid,
5847 uuid, NULL); 5851 uuid, NULL);
5848 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { 5852 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) {
5849 kfree(map);
5850 free_extent_map(em); 5853 free_extent_map(em);
5851 return -EIO; 5854 return -EIO;
5852 } 5855 }
@@ -5854,7 +5857,6 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
5854 map->stripes[i].dev = 5857 map->stripes[i].dev =
5855 add_missing_dev(root, devid, uuid); 5858 add_missing_dev(root, devid, uuid);
5856 if (!map->stripes[i].dev) { 5859 if (!map->stripes[i].dev) {
5857 kfree(map);
5858 free_extent_map(em); 5860 free_extent_map(em);
5859 return -EIO; 5861 return -EIO;
5860 } 5862 }
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 1a15bbeb65e2..2aaa00c47816 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -190,11 +190,14 @@ struct btrfs_bio_stripe {
190struct btrfs_bio; 190struct btrfs_bio;
191typedef void (btrfs_bio_end_io_t) (struct btrfs_bio *bio, int err); 191typedef void (btrfs_bio_end_io_t) (struct btrfs_bio *bio, int err);
192 192
193#define BTRFS_BIO_ORIG_BIO_SUBMITTED 0x1
194
193struct btrfs_bio { 195struct btrfs_bio {
194 atomic_t stripes_pending; 196 atomic_t stripes_pending;
195 struct btrfs_fs_info *fs_info; 197 struct btrfs_fs_info *fs_info;
196 bio_end_io_t *end_io; 198 bio_end_io_t *end_io;
197 struct bio *orig_bio; 199 struct bio *orig_bio;
200 unsigned long flags;
198 void *private; 201 void *private;
199 atomic_t error; 202 atomic_t error;
200 int max_errors; 203 int max_errors;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index b73e0621ce9e..b10b48c2a7af 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -910,7 +910,7 @@ static const struct file_operations eventpoll_fops = {
910void eventpoll_release_file(struct file *file) 910void eventpoll_release_file(struct file *file)
911{ 911{
912 struct eventpoll *ep; 912 struct eventpoll *ep;
913 struct epitem *epi; 913 struct epitem *epi, *next;
914 914
915 /* 915 /*
916 * We don't want to get "file->f_lock" because it is not 916 * We don't want to get "file->f_lock" because it is not
@@ -926,7 +926,7 @@ void eventpoll_release_file(struct file *file)
926 * Besides, ep_remove() acquires the lock, so we can't hold it here. 926 * Besides, ep_remove() acquires the lock, so we can't hold it here.
927 */ 927 */
928 mutex_lock(&epmutex); 928 mutex_lock(&epmutex);
929 list_for_each_entry_rcu(epi, &file->f_ep_links, fllink) { 929 list_for_each_entry_safe(epi, next, &file->f_ep_links, fllink) {
930 ep = epi->ep; 930 ep = epi->ep;
931 mutex_lock_nested(&ep->mtx, 0); 931 mutex_lock_nested(&ep->mtx, 0);
932 ep_remove(ep, epi); 932 ep_remove(ep, epi);
diff --git a/fs/locks.c b/fs/locks.c
index da57c9b7e844..717fbc404e6b 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -431,7 +431,7 @@ static int lease_init(struct file *filp, long type, struct file_lock *fl)
431 if (assign_type(fl, type) != 0) 431 if (assign_type(fl, type) != 0)
432 return -EINVAL; 432 return -EINVAL;
433 433
434 fl->fl_owner = (fl_owner_t)filp; 434 fl->fl_owner = (fl_owner_t)current->files;
435 fl->fl_pid = current->tgid; 435 fl->fl_pid = current->tgid;
436 436
437 fl->fl_file = filp; 437 fl->fl_file = filp;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c0d45cec9958..2204e1fe5725 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -41,6 +41,7 @@
41#include <linux/ratelimit.h> 41#include <linux/ratelimit.h>
42#include <linux/sunrpc/svcauth_gss.h> 42#include <linux/sunrpc/svcauth_gss.h>
43#include <linux/sunrpc/addr.h> 43#include <linux/sunrpc/addr.h>
44#include <linux/hash.h>
44#include "xdr4.h" 45#include "xdr4.h"
45#include "xdr4cb.h" 46#include "xdr4cb.h"
46#include "vfs.h" 47#include "vfs.h"
@@ -364,6 +365,79 @@ static struct nfs4_ol_stateid * nfs4_alloc_stateid(struct nfs4_client *clp)
364 return openlockstateid(nfs4_alloc_stid(clp, stateid_slab)); 365 return openlockstateid(nfs4_alloc_stid(clp, stateid_slab));
365} 366}
366 367
368/*
369 * When we recall a delegation, we should be careful not to hand it
370 * out again straight away.
371 * To ensure this we keep a pair of bloom filters ('new' and 'old')
372 * in which the filehandles of recalled delegations are "stored".
373 * If a filehandle appear in either filter, a delegation is blocked.
374 * When a delegation is recalled, the filehandle is stored in the "new"
375 * filter.
376 * Every 30 seconds we swap the filters and clear the "new" one,
377 * unless both are empty of course.
378 *
379 * Each filter is 256 bits. We hash the filehandle to 32bit and use the
380 * low 3 bytes as hash-table indices.
381 *
382 * 'state_lock', which is always held when block_delegations() is called,
383 * is used to manage concurrent access. Testing does not need the lock
384 * except when swapping the two filters.
385 */
386static struct bloom_pair {
387 int entries, old_entries;
388 time_t swap_time;
389 int new; /* index into 'set' */
390 DECLARE_BITMAP(set[2], 256);
391} blocked_delegations;
392
393static int delegation_blocked(struct knfsd_fh *fh)
394{
395 u32 hash;
396 struct bloom_pair *bd = &blocked_delegations;
397
398 if (bd->entries == 0)
399 return 0;
400 if (seconds_since_boot() - bd->swap_time > 30) {
401 spin_lock(&state_lock);
402 if (seconds_since_boot() - bd->swap_time > 30) {
403 bd->entries -= bd->old_entries;
404 bd->old_entries = bd->entries;
405 memset(bd->set[bd->new], 0,
406 sizeof(bd->set[0]));
407 bd->new = 1-bd->new;
408 bd->swap_time = seconds_since_boot();
409 }
410 spin_unlock(&state_lock);
411 }
412 hash = arch_fast_hash(&fh->fh_base, fh->fh_size, 0);
413 if (test_bit(hash&255, bd->set[0]) &&
414 test_bit((hash>>8)&255, bd->set[0]) &&
415 test_bit((hash>>16)&255, bd->set[0]))
416 return 1;
417
418 if (test_bit(hash&255, bd->set[1]) &&
419 test_bit((hash>>8)&255, bd->set[1]) &&
420 test_bit((hash>>16)&255, bd->set[1]))
421 return 1;
422
423 return 0;
424}
425
426static void block_delegations(struct knfsd_fh *fh)
427{
428 u32 hash;
429 struct bloom_pair *bd = &blocked_delegations;
430
431 hash = arch_fast_hash(&fh->fh_base, fh->fh_size, 0);
432
433 __set_bit(hash&255, bd->set[bd->new]);
434 __set_bit((hash>>8)&255, bd->set[bd->new]);
435 __set_bit((hash>>16)&255, bd->set[bd->new]);
436 if (bd->entries == 0)
437 bd->swap_time = seconds_since_boot();
438 bd->entries += 1;
439}
440
367static struct nfs4_delegation * 441static struct nfs4_delegation *
368alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct svc_fh *current_fh) 442alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct svc_fh *current_fh)
369{ 443{
@@ -372,6 +446,8 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct sv
372 dprintk("NFSD alloc_init_deleg\n"); 446 dprintk("NFSD alloc_init_deleg\n");
373 if (num_delegations > max_delegations) 447 if (num_delegations > max_delegations)
374 return NULL; 448 return NULL;
449 if (delegation_blocked(&current_fh->fh_handle))
450 return NULL;
375 dp = delegstateid(nfs4_alloc_stid(clp, deleg_slab)); 451 dp = delegstateid(nfs4_alloc_stid(clp, deleg_slab));
376 if (dp == NULL) 452 if (dp == NULL)
377 return dp; 453 return dp;
@@ -2770,6 +2846,8 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
2770 /* Only place dl_time is set; protected by i_lock: */ 2846 /* Only place dl_time is set; protected by i_lock: */
2771 dp->dl_time = get_seconds(); 2847 dp->dl_time = get_seconds();
2772 2848
2849 block_delegations(&dp->dl_fh);
2850
2773 nfsd4_cb_recall(dp); 2851 nfsd4_cb_recall(dp);
2774} 2852}
2775 2853
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2d305a121f37..83baf2bfe9e9 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2687,6 +2687,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen,
2687 nfserr = nfserr_toosmall; 2687 nfserr = nfserr_toosmall;
2688 goto fail; 2688 goto fail;
2689 case nfserr_noent: 2689 case nfserr_noent:
2690 xdr_truncate_encode(xdr, start_offset);
2690 goto skip_entry; 2691 goto skip_entry;
2691 default: 2692 default:
2692 /* 2693 /*
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 6eb1d3cb5104..9b9b6f29bbf3 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -53,7 +53,7 @@ struct acpi_power_register {
53 u8 bit_offset; 53 u8 bit_offset;
54 u8 access_size; 54 u8 access_size;
55 u64 address; 55 u64 address;
56} __attribute__ ((packed)); 56} __packed;
57 57
58struct acpi_processor_cx { 58struct acpi_processor_cx {
59 u8 valid; 59 u8 valid;
@@ -83,7 +83,7 @@ struct acpi_psd_package {
83 u64 domain; 83 u64 domain;
84 u64 coord_type; 84 u64 coord_type;
85 u64 num_processors; 85 u64 num_processors;
86} __attribute__ ((packed)); 86} __packed;
87 87
88struct acpi_pct_register { 88struct acpi_pct_register {
89 u8 descriptor; 89 u8 descriptor;
@@ -93,7 +93,7 @@ struct acpi_pct_register {
93 u8 bit_offset; 93 u8 bit_offset;
94 u8 reserved; 94 u8 reserved;
95 u64 address; 95 u64 address;
96} __attribute__ ((packed)); 96} __packed;
97 97
98struct acpi_processor_px { 98struct acpi_processor_px {
99 u64 core_frequency; /* megahertz */ 99 u64 core_frequency; /* megahertz */
@@ -124,7 +124,7 @@ struct acpi_tsd_package {
124 u64 domain; 124 u64 domain;
125 u64 coord_type; 125 u64 coord_type;
126 u64 num_processors; 126 u64 num_processors;
127} __attribute__ ((packed)); 127} __packed;
128 128
129struct acpi_ptc_register { 129struct acpi_ptc_register {
130 u8 descriptor; 130 u8 descriptor;
@@ -134,7 +134,7 @@ struct acpi_ptc_register {
134 u8 bit_offset; 134 u8 bit_offset;
135 u8 reserved; 135 u8 reserved;
136 u64 address; 136 u64 address;
137} __attribute__ ((packed)); 137} __packed;
138 138
139struct acpi_processor_tx_tss { 139struct acpi_processor_tx_tss {
140 u64 freqpercentage; /* */ 140 u64 freqpercentage; /* */
diff --git a/include/drm/i915_powerwell.h b/include/drm/i915_powerwell.h
index cfdc884405b7..2baba9996094 100644
--- a/include/drm/i915_powerwell.h
+++ b/include/drm/i915_powerwell.h
@@ -30,7 +30,7 @@
30#define _I915_POWERWELL_H_ 30#define _I915_POWERWELL_H_
31 31
32/* For use by hda_i915 driver */ 32/* For use by hda_i915 driver */
33extern void i915_request_power_well(void); 33extern int i915_request_power_well(void);
34extern void i915_release_power_well(void); 34extern int i915_release_power_well(void);
35 35
36#endif /* _I915_POWERWELL_H_ */ 36#endif /* _I915_POWERWELL_H_ */
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index a002cf191427..eb726b9c5762 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -42,7 +42,7 @@ struct blk_mq_hw_ctx {
42 unsigned int nr_ctx; 42 unsigned int nr_ctx;
43 struct blk_mq_ctx **ctxs; 43 struct blk_mq_ctx **ctxs;
44 44
45 unsigned int wait_index; 45 atomic_t wait_index;
46 46
47 struct blk_mq_tags *tags; 47 struct blk_mq_tags *tags;
48 48
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 31e11051f1ba..713f8b62b435 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -920,7 +920,7 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
920 sector_t offset) 920 sector_t offset)
921{ 921{
922 if (!q->limits.chunk_sectors) 922 if (!q->limits.chunk_sectors)
923 return q->limits.max_hw_sectors; 923 return q->limits.max_sectors;
924 924
925 return q->limits.chunk_sectors - 925 return q->limits.chunk_sectors -
926 (offset & (q->limits.chunk_sectors - 1)); 926 (offset & (q->limits.chunk_sectors - 1));
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 4ff262e2bf37..e2a6bd7fb133 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -133,7 +133,6 @@ extern struct request *elv_latter_request(struct request_queue *, struct request
133extern int elv_register_queue(struct request_queue *q); 133extern int elv_register_queue(struct request_queue *q);
134extern void elv_unregister_queue(struct request_queue *q); 134extern void elv_unregister_queue(struct request_queue *q);
135extern int elv_may_queue(struct request_queue *, int); 135extern int elv_may_queue(struct request_queue *, int);
136extern void elv_abort_queue(struct request_queue *);
137extern void elv_completed_request(struct request_queue *, struct request *); 136extern void elv_completed_request(struct request_queue *, struct request *);
138extern int elv_set_request(struct request_queue *q, struct request *rq, 137extern int elv_set_request(struct request_queue *q, struct request *rq,
139 struct bio *bio, gfp_t gfp_mask); 138 struct bio *bio, gfp_t gfp_mask);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 338e6f758c6d..e11d60cc867b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1921,6 +1921,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
1921 1921
1922static inline int break_deleg(struct inode *inode, unsigned int mode) 1922static inline int break_deleg(struct inode *inode, unsigned int mode)
1923{ 1923{
1924 /*
1925 * Since this check is lockless, we must ensure that any refcounts
1926 * taken are done before checking inode->i_flock. Otherwise, we could
1927 * end up racing with tasks trying to set a new lease on this file.
1928 */
1929 smp_mb();
1924 if (inode->i_flock) 1930 if (inode->i_flock)
1925 return __break_lease(inode, mode, FL_DELEG); 1931 return __break_lease(inode, mode, FL_DELEG);
1926 return 0; 1932 return 0;
diff --git a/include/linux/profile.h b/include/linux/profile.h
index aaad3861beb8..b537a25ffa17 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -44,6 +44,7 @@ extern int prof_on __read_mostly;
44int profile_init(void); 44int profile_init(void);
45int profile_setup(char *str); 45int profile_setup(char *str);
46void profile_tick(int type); 46void profile_tick(int type);
47int setup_profiling_timer(unsigned int multiplier);
47 48
48/* 49/*
49 * Add multiple profiler hits to a given address: 50 * Add multiple profiler hits to a given address:
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index a2d9d81038d1..14ec18d5e18b 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -395,6 +395,11 @@ static inline void regulator_bulk_free(int num_consumers,
395{ 395{
396} 396}
397 397
398static inline int regulator_can_change_voltage(struct regulator *regulator)
399{
400 return 0;
401}
402
398static inline int regulator_set_voltage(struct regulator *regulator, 403static inline int regulator_set_voltage(struct regulator *regulator,
399 int min_uV, int max_uV) 404 int min_uV, int max_uV)
400{ 405{
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index f76994b9396c..519064e0c943 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -327,6 +327,7 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
327extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); 327extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
328extern int hibernate(void); 328extern int hibernate(void);
329extern bool system_entering_hibernation(void); 329extern bool system_entering_hibernation(void);
330extern bool hibernation_available(void);
330asmlinkage int swsusp_save(void); 331asmlinkage int swsusp_save(void);
331extern struct pbe *restore_pblist; 332extern struct pbe *restore_pblist;
332#else /* CONFIG_HIBERNATION */ 333#else /* CONFIG_HIBERNATION */
@@ -339,6 +340,7 @@ static inline void swsusp_unset_page_free(struct page *p) {}
339static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {} 340static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
340static inline int hibernate(void) { return -ENOSYS; } 341static inline int hibernate(void) { return -ENOSYS; }
341static inline bool system_entering_hibernation(void) { return false; } 342static inline bool system_entering_hibernation(void) { return false; }
343static inline bool hibernation_available(void) { return false; }
342#endif /* CONFIG_HIBERNATION */ 344#endif /* CONFIG_HIBERNATION */
343 345
344/* Hibernation and suspend events */ 346/* Hibernation and suspend events */
diff --git a/include/sound/core.h b/include/sound/core.h
index eedda2cdfe57..1df3f2fe5350 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -116,6 +116,8 @@ struct snd_card {
116 int user_ctl_count; /* count of all user controls */ 116 int user_ctl_count; /* count of all user controls */
117 struct list_head controls; /* all controls for this card */ 117 struct list_head controls; /* all controls for this card */
118 struct list_head ctl_files; /* active control files */ 118 struct list_head ctl_files; /* active control files */
119 struct mutex user_ctl_lock; /* protects user controls against
120 concurrent access */
119 121
120 struct snd_info_entry *proc_root; /* root for soundcard specific files */ 122 struct snd_info_entry *proc_root; /* root for soundcard specific files */
121 struct snd_info_entry *proc_id; /* the card id */ 123 struct snd_info_entry *proc_id; /* the card id */
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 5312fae47218..9269de254874 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -705,6 +705,7 @@ enum perf_event_type {
705 * u32 min; 705 * u32 min;
706 * u64 ino; 706 * u64 ino;
707 * u64 ino_generation; 707 * u64 ino_generation;
708 * u32 prot, flags;
708 * char filename[]; 709 * char filename[];
709 * struct sample_id sample_id; 710 * struct sample_id sample_id;
710 * }; 711 * };
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 019d45008448..5664985c46a0 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -19,6 +19,7 @@
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/hardirq.h> 20#include <linux/hardirq.h>
21#include <linux/export.h> 21#include <linux/export.h>
22#include <linux/kprobes.h>
22 23
23#define CREATE_TRACE_POINTS 24#define CREATE_TRACE_POINTS
24#include <trace/events/context_tracking.h> 25#include <trace/events/context_tracking.h>
@@ -104,6 +105,7 @@ void context_tracking_user_enter(void)
104 } 105 }
105 local_irq_restore(flags); 106 local_irq_restore(flags);
106} 107}
108NOKPROBE_SYMBOL(context_tracking_user_enter);
107 109
108#ifdef CONFIG_PREEMPT 110#ifdef CONFIG_PREEMPT
109/** 111/**
@@ -181,6 +183,7 @@ void context_tracking_user_exit(void)
181 } 183 }
182 local_irq_restore(flags); 184 local_irq_restore(flags);
183} 185}
186NOKPROBE_SYMBOL(context_tracking_user_exit);
184 187
185/** 188/**
186 * __context_tracking_task_switch - context switch the syscall callbacks 189 * __context_tracking_task_switch - context switch the syscall callbacks
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5fa58e4cffac..a33d9a2bcbd7 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -40,6 +40,7 @@
40#include <linux/mm_types.h> 40#include <linux/mm_types.h>
41#include <linux/cgroup.h> 41#include <linux/cgroup.h>
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/mman.h>
43 44
44#include "internal.h" 45#include "internal.h"
45 46
@@ -5128,6 +5129,7 @@ struct perf_mmap_event {
5128 int maj, min; 5129 int maj, min;
5129 u64 ino; 5130 u64 ino;
5130 u64 ino_generation; 5131 u64 ino_generation;
5132 u32 prot, flags;
5131 5133
5132 struct { 5134 struct {
5133 struct perf_event_header header; 5135 struct perf_event_header header;
@@ -5169,6 +5171,8 @@ static void perf_event_mmap_output(struct perf_event *event,
5169 mmap_event->event_id.header.size += sizeof(mmap_event->min); 5171 mmap_event->event_id.header.size += sizeof(mmap_event->min);
5170 mmap_event->event_id.header.size += sizeof(mmap_event->ino); 5172 mmap_event->event_id.header.size += sizeof(mmap_event->ino);
5171 mmap_event->event_id.header.size += sizeof(mmap_event->ino_generation); 5173 mmap_event->event_id.header.size += sizeof(mmap_event->ino_generation);
5174 mmap_event->event_id.header.size += sizeof(mmap_event->prot);
5175 mmap_event->event_id.header.size += sizeof(mmap_event->flags);
5172 } 5176 }
5173 5177
5174 perf_event_header__init_id(&mmap_event->event_id.header, &sample, event); 5178 perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);
@@ -5187,6 +5191,8 @@ static void perf_event_mmap_output(struct perf_event *event,
5187 perf_output_put(&handle, mmap_event->min); 5191 perf_output_put(&handle, mmap_event->min);
5188 perf_output_put(&handle, mmap_event->ino); 5192 perf_output_put(&handle, mmap_event->ino);
5189 perf_output_put(&handle, mmap_event->ino_generation); 5193 perf_output_put(&handle, mmap_event->ino_generation);
5194 perf_output_put(&handle, mmap_event->prot);
5195 perf_output_put(&handle, mmap_event->flags);
5190 } 5196 }
5191 5197
5192 __output_copy(&handle, mmap_event->file_name, 5198 __output_copy(&handle, mmap_event->file_name,
@@ -5205,6 +5211,7 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5205 struct file *file = vma->vm_file; 5211 struct file *file = vma->vm_file;
5206 int maj = 0, min = 0; 5212 int maj = 0, min = 0;
5207 u64 ino = 0, gen = 0; 5213 u64 ino = 0, gen = 0;
5214 u32 prot = 0, flags = 0;
5208 unsigned int size; 5215 unsigned int size;
5209 char tmp[16]; 5216 char tmp[16];
5210 char *buf = NULL; 5217 char *buf = NULL;
@@ -5235,6 +5242,28 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
5235 gen = inode->i_generation; 5242 gen = inode->i_generation;
5236 maj = MAJOR(dev); 5243 maj = MAJOR(dev);
5237 min = MINOR(dev); 5244 min = MINOR(dev);
5245
5246 if (vma->vm_flags & VM_READ)
5247 prot |= PROT_READ;
5248 if (vma->vm_flags & VM_WRITE)
5249 prot |= PROT_WRITE;
5250 if (vma->vm_flags & VM_EXEC)
5251 prot |= PROT_EXEC;
5252
5253 if (vma->vm_flags & VM_MAYSHARE)
5254 flags = MAP_SHARED;
5255 else
5256 flags = MAP_PRIVATE;
5257
5258 if (vma->vm_flags & VM_DENYWRITE)
5259 flags |= MAP_DENYWRITE;
5260 if (vma->vm_flags & VM_MAYEXEC)
5261 flags |= MAP_EXECUTABLE;
5262 if (vma->vm_flags & VM_LOCKED)
5263 flags |= MAP_LOCKED;
5264 if (vma->vm_flags & VM_HUGETLB)
5265 flags |= MAP_HUGETLB;
5266
5238 goto got_name; 5267 goto got_name;
5239 } else { 5268 } else {
5240 name = (char *)arch_vma_name(vma); 5269 name = (char *)arch_vma_name(vma);
@@ -5275,6 +5304,8 @@ got_name:
5275 mmap_event->min = min; 5304 mmap_event->min = min;
5276 mmap_event->ino = ino; 5305 mmap_event->ino = ino;
5277 mmap_event->ino_generation = gen; 5306 mmap_event->ino_generation = gen;
5307 mmap_event->prot = prot;
5308 mmap_event->flags = flags;
5278 5309
5279 if (!(vma->vm_flags & VM_EXEC)) 5310 if (!(vma->vm_flags & VM_EXEC))
5280 mmap_event->event_id.header.misc |= PERF_RECORD_MISC_MMAP_DATA; 5311 mmap_event->event_id.header.misc |= PERF_RECORD_MISC_MMAP_DATA;
@@ -5315,6 +5346,8 @@ void perf_event_mmap(struct vm_area_struct *vma)
5315 /* .min (attr_mmap2 only) */ 5346 /* .min (attr_mmap2 only) */
5316 /* .ino (attr_mmap2 only) */ 5347 /* .ino (attr_mmap2 only) */
5317 /* .ino_generation (attr_mmap2 only) */ 5348 /* .ino_generation (attr_mmap2 only) */
5349 /* .prot (attr_mmap2 only) */
5350 /* .flags (attr_mmap2 only) */
5318 }; 5351 };
5319 5352
5320 perf_event_mmap_event(&mmap_event); 5353 perf_event_mmap_event(&mmap_event);
@@ -6897,10 +6930,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
6897 if (ret) 6930 if (ret)
6898 return -EFAULT; 6931 return -EFAULT;
6899 6932
6900 /* disabled for now */
6901 if (attr->mmap2)
6902 return -EINVAL;
6903
6904 if (attr->__reserved_1) 6933 if (attr->__reserved_1)
6905 return -EINVAL; 6934 return -EINVAL;
6906 6935
diff --git a/kernel/locking/rtmutex-debug.h b/kernel/locking/rtmutex-debug.h
index 14193d596d78..ab29b6a22669 100644
--- a/kernel/locking/rtmutex-debug.h
+++ b/kernel/locking/rtmutex-debug.h
@@ -31,3 +31,8 @@ static inline int debug_rt_mutex_detect_deadlock(struct rt_mutex_waiter *waiter,
31{ 31{
32 return (waiter != NULL); 32 return (waiter != NULL);
33} 33}
34
35static inline void rt_mutex_print_deadlock(struct rt_mutex_waiter *w)
36{
37 debug_rt_mutex_print_deadlock(w);
38}
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index a620d4d08ca6..fc605941b9b8 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -83,6 +83,47 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
83 owner = *p; 83 owner = *p;
84 } while (cmpxchg(p, owner, owner | RT_MUTEX_HAS_WAITERS) != owner); 84 } while (cmpxchg(p, owner, owner | RT_MUTEX_HAS_WAITERS) != owner);
85} 85}
86
87/*
88 * Safe fastpath aware unlock:
89 * 1) Clear the waiters bit
90 * 2) Drop lock->wait_lock
91 * 3) Try to unlock the lock with cmpxchg
92 */
93static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock)
94 __releases(lock->wait_lock)
95{
96 struct task_struct *owner = rt_mutex_owner(lock);
97
98 clear_rt_mutex_waiters(lock);
99 raw_spin_unlock(&lock->wait_lock);
100 /*
101 * If a new waiter comes in between the unlock and the cmpxchg
102 * we have two situations:
103 *
104 * unlock(wait_lock);
105 * lock(wait_lock);
106 * cmpxchg(p, owner, 0) == owner
107 * mark_rt_mutex_waiters(lock);
108 * acquire(lock);
109 * or:
110 *
111 * unlock(wait_lock);
112 * lock(wait_lock);
113 * mark_rt_mutex_waiters(lock);
114 *
115 * cmpxchg(p, owner, 0) != owner
116 * enqueue_waiter();
117 * unlock(wait_lock);
118 * lock(wait_lock);
119 * wake waiter();
120 * unlock(wait_lock);
121 * lock(wait_lock);
122 * acquire(lock);
123 */
124 return rt_mutex_cmpxchg(lock, owner, NULL);
125}
126
86#else 127#else
87# define rt_mutex_cmpxchg(l,c,n) (0) 128# define rt_mutex_cmpxchg(l,c,n) (0)
88static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) 129static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
@@ -90,6 +131,17 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock)
90 lock->owner = (struct task_struct *) 131 lock->owner = (struct task_struct *)
91 ((unsigned long)lock->owner | RT_MUTEX_HAS_WAITERS); 132 ((unsigned long)lock->owner | RT_MUTEX_HAS_WAITERS);
92} 133}
134
135/*
136 * Simple slow path only version: lock->owner is protected by lock->wait_lock.
137 */
138static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock)
139 __releases(lock->wait_lock)
140{
141 lock->owner = NULL;
142 raw_spin_unlock(&lock->wait_lock);
143 return true;
144}
93#endif 145#endif
94 146
95static inline int 147static inline int
@@ -260,27 +312,36 @@ static void rt_mutex_adjust_prio(struct task_struct *task)
260 */ 312 */
261int max_lock_depth = 1024; 313int max_lock_depth = 1024;
262 314
315static inline struct rt_mutex *task_blocked_on_lock(struct task_struct *p)
316{
317 return p->pi_blocked_on ? p->pi_blocked_on->lock : NULL;
318}
319
263/* 320/*
264 * Adjust the priority chain. Also used for deadlock detection. 321 * Adjust the priority chain. Also used for deadlock detection.
265 * Decreases task's usage by one - may thus free the task. 322 * Decreases task's usage by one - may thus free the task.
266 * 323 *
267 * @task: the task owning the mutex (owner) for which a chain walk is probably 324 * @task: the task owning the mutex (owner) for which a chain walk is
268 * needed 325 * probably needed
269 * @deadlock_detect: do we have to carry out deadlock detection? 326 * @deadlock_detect: do we have to carry out deadlock detection?
270 * @orig_lock: the mutex (can be NULL if we are walking the chain to recheck 327 * @orig_lock: the mutex (can be NULL if we are walking the chain to recheck
271 * things for a task that has just got its priority adjusted, and 328 * things for a task that has just got its priority adjusted, and
272 * is waiting on a mutex) 329 * is waiting on a mutex)
330 * @next_lock: the mutex on which the owner of @orig_lock was blocked before
331 * we dropped its pi_lock. Is never dereferenced, only used for
332 * comparison to detect lock chain changes.
273 * @orig_waiter: rt_mutex_waiter struct for the task that has just donated 333 * @orig_waiter: rt_mutex_waiter struct for the task that has just donated
274 * its priority to the mutex owner (can be NULL in the case 334 * its priority to the mutex owner (can be NULL in the case
275 * depicted above or if the top waiter is gone away and we are 335 * depicted above or if the top waiter is gone away and we are
276 * actually deboosting the owner) 336 * actually deboosting the owner)
277 * @top_task: the current top waiter 337 * @top_task: the current top waiter
278 * 338 *
279 * Returns 0 or -EDEADLK. 339 * Returns 0 or -EDEADLK.
280 */ 340 */
281static int rt_mutex_adjust_prio_chain(struct task_struct *task, 341static int rt_mutex_adjust_prio_chain(struct task_struct *task,
282 int deadlock_detect, 342 int deadlock_detect,
283 struct rt_mutex *orig_lock, 343 struct rt_mutex *orig_lock,
344 struct rt_mutex *next_lock,
284 struct rt_mutex_waiter *orig_waiter, 345 struct rt_mutex_waiter *orig_waiter,
285 struct task_struct *top_task) 346 struct task_struct *top_task)
286{ 347{
@@ -314,7 +375,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
314 } 375 }
315 put_task_struct(task); 376 put_task_struct(task);
316 377
317 return deadlock_detect ? -EDEADLK : 0; 378 return -EDEADLK;
318 } 379 }
319 retry: 380 retry:
320 /* 381 /*
@@ -339,6 +400,18 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
339 goto out_unlock_pi; 400 goto out_unlock_pi;
340 401
341 /* 402 /*
403 * We dropped all locks after taking a refcount on @task, so
404 * the task might have moved on in the lock chain or even left
405 * the chain completely and blocks now on an unrelated lock or
406 * on @orig_lock.
407 *
408 * We stored the lock on which @task was blocked in @next_lock,
409 * so we can detect the chain change.
410 */
411 if (next_lock != waiter->lock)
412 goto out_unlock_pi;
413
414 /*
342 * Drop out, when the task has no waiters. Note, 415 * Drop out, when the task has no waiters. Note,
343 * top_waiter can be NULL, when we are in the deboosting 416 * top_waiter can be NULL, when we are in the deboosting
344 * mode! 417 * mode!
@@ -377,7 +450,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
377 if (lock == orig_lock || rt_mutex_owner(lock) == top_task) { 450 if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
378 debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock); 451 debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
379 raw_spin_unlock(&lock->wait_lock); 452 raw_spin_unlock(&lock->wait_lock);
380 ret = deadlock_detect ? -EDEADLK : 0; 453 ret = -EDEADLK;
381 goto out_unlock_pi; 454 goto out_unlock_pi;
382 } 455 }
383 456
@@ -422,11 +495,26 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
422 __rt_mutex_adjust_prio(task); 495 __rt_mutex_adjust_prio(task);
423 } 496 }
424 497
498 /*
499 * Check whether the task which owns the current lock is pi
500 * blocked itself. If yes we store a pointer to the lock for
501 * the lock chain change detection above. After we dropped
502 * task->pi_lock next_lock cannot be dereferenced anymore.
503 */
504 next_lock = task_blocked_on_lock(task);
505
425 raw_spin_unlock_irqrestore(&task->pi_lock, flags); 506 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
426 507
427 top_waiter = rt_mutex_top_waiter(lock); 508 top_waiter = rt_mutex_top_waiter(lock);
428 raw_spin_unlock(&lock->wait_lock); 509 raw_spin_unlock(&lock->wait_lock);
429 510
511 /*
512 * We reached the end of the lock chain. Stop right here. No
513 * point to go back just to figure that out.
514 */
515 if (!next_lock)
516 goto out_put_task;
517
430 if (!detect_deadlock && waiter != top_waiter) 518 if (!detect_deadlock && waiter != top_waiter)
431 goto out_put_task; 519 goto out_put_task;
432 520
@@ -536,8 +624,9 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
536{ 624{
537 struct task_struct *owner = rt_mutex_owner(lock); 625 struct task_struct *owner = rt_mutex_owner(lock);
538 struct rt_mutex_waiter *top_waiter = waiter; 626 struct rt_mutex_waiter *top_waiter = waiter;
539 unsigned long flags; 627 struct rt_mutex *next_lock;
540 int chain_walk = 0, res; 628 int chain_walk = 0, res;
629 unsigned long flags;
541 630
542 /* 631 /*
543 * Early deadlock detection. We really don't want the task to 632 * Early deadlock detection. We really don't want the task to
@@ -548,7 +637,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
548 * which is wrong, as the other waiter is not in a deadlock 637 * which is wrong, as the other waiter is not in a deadlock
549 * situation. 638 * situation.
550 */ 639 */
551 if (detect_deadlock && owner == task) 640 if (owner == task)
552 return -EDEADLK; 641 return -EDEADLK;
553 642
554 raw_spin_lock_irqsave(&task->pi_lock, flags); 643 raw_spin_lock_irqsave(&task->pi_lock, flags);
@@ -569,20 +658,28 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
569 if (!owner) 658 if (!owner)
570 return 0; 659 return 0;
571 660
661 raw_spin_lock_irqsave(&owner->pi_lock, flags);
572 if (waiter == rt_mutex_top_waiter(lock)) { 662 if (waiter == rt_mutex_top_waiter(lock)) {
573 raw_spin_lock_irqsave(&owner->pi_lock, flags);
574 rt_mutex_dequeue_pi(owner, top_waiter); 663 rt_mutex_dequeue_pi(owner, top_waiter);
575 rt_mutex_enqueue_pi(owner, waiter); 664 rt_mutex_enqueue_pi(owner, waiter);
576 665
577 __rt_mutex_adjust_prio(owner); 666 __rt_mutex_adjust_prio(owner);
578 if (owner->pi_blocked_on) 667 if (owner->pi_blocked_on)
579 chain_walk = 1; 668 chain_walk = 1;
580 raw_spin_unlock_irqrestore(&owner->pi_lock, flags); 669 } else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock)) {
581 }
582 else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock))
583 chain_walk = 1; 670 chain_walk = 1;
671 }
584 672
585 if (!chain_walk) 673 /* Store the lock on which owner is blocked or NULL */
674 next_lock = task_blocked_on_lock(owner);
675
676 raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
677 /*
678 * Even if full deadlock detection is on, if the owner is not
679 * blocked itself, we can avoid finding this out in the chain
680 * walk.
681 */
682 if (!chain_walk || !next_lock)
586 return 0; 683 return 0;
587 684
588 /* 685 /*
@@ -594,8 +691,8 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
594 691
595 raw_spin_unlock(&lock->wait_lock); 692 raw_spin_unlock(&lock->wait_lock);
596 693
597 res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter, 694 res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock,
598 task); 695 next_lock, waiter, task);
599 696
600 raw_spin_lock(&lock->wait_lock); 697 raw_spin_lock(&lock->wait_lock);
601 698
@@ -605,7 +702,8 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
605/* 702/*
606 * Wake up the next waiter on the lock. 703 * Wake up the next waiter on the lock.
607 * 704 *
608 * Remove the top waiter from the current tasks waiter list and wake it up. 705 * Remove the top waiter from the current tasks pi waiter list and
706 * wake it up.
609 * 707 *
610 * Called with lock->wait_lock held. 708 * Called with lock->wait_lock held.
611 */ 709 */
@@ -626,10 +724,23 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
626 */ 724 */
627 rt_mutex_dequeue_pi(current, waiter); 725 rt_mutex_dequeue_pi(current, waiter);
628 726
629 rt_mutex_set_owner(lock, NULL); 727 /*
728 * As we are waking up the top waiter, and the waiter stays
729 * queued on the lock until it gets the lock, this lock
730 * obviously has waiters. Just set the bit here and this has
731 * the added benefit of forcing all new tasks into the
732 * slow path making sure no task of lower priority than
733 * the top waiter can steal this lock.
734 */
735 lock->owner = (void *) RT_MUTEX_HAS_WAITERS;
630 736
631 raw_spin_unlock_irqrestore(&current->pi_lock, flags); 737 raw_spin_unlock_irqrestore(&current->pi_lock, flags);
632 738
739 /*
740 * It's safe to dereference waiter as it cannot go away as
741 * long as we hold lock->wait_lock. The waiter task needs to
742 * acquire it in order to dequeue the waiter.
743 */
633 wake_up_process(waiter->task); 744 wake_up_process(waiter->task);
634} 745}
635 746
@@ -644,8 +755,8 @@ static void remove_waiter(struct rt_mutex *lock,
644{ 755{
645 int first = (waiter == rt_mutex_top_waiter(lock)); 756 int first = (waiter == rt_mutex_top_waiter(lock));
646 struct task_struct *owner = rt_mutex_owner(lock); 757 struct task_struct *owner = rt_mutex_owner(lock);
758 struct rt_mutex *next_lock = NULL;
647 unsigned long flags; 759 unsigned long flags;
648 int chain_walk = 0;
649 760
650 raw_spin_lock_irqsave(&current->pi_lock, flags); 761 raw_spin_lock_irqsave(&current->pi_lock, flags);
651 rt_mutex_dequeue(lock, waiter); 762 rt_mutex_dequeue(lock, waiter);
@@ -669,13 +780,13 @@ static void remove_waiter(struct rt_mutex *lock,
669 } 780 }
670 __rt_mutex_adjust_prio(owner); 781 __rt_mutex_adjust_prio(owner);
671 782
672 if (owner->pi_blocked_on) 783 /* Store the lock on which owner is blocked or NULL */
673 chain_walk = 1; 784 next_lock = task_blocked_on_lock(owner);
674 785
675 raw_spin_unlock_irqrestore(&owner->pi_lock, flags); 786 raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
676 } 787 }
677 788
678 if (!chain_walk) 789 if (!next_lock)
679 return; 790 return;
680 791
681 /* gets dropped in rt_mutex_adjust_prio_chain()! */ 792 /* gets dropped in rt_mutex_adjust_prio_chain()! */
@@ -683,7 +794,7 @@ static void remove_waiter(struct rt_mutex *lock,
683 794
684 raw_spin_unlock(&lock->wait_lock); 795 raw_spin_unlock(&lock->wait_lock);
685 796
686 rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current); 797 rt_mutex_adjust_prio_chain(owner, 0, lock, next_lock, NULL, current);
687 798
688 raw_spin_lock(&lock->wait_lock); 799 raw_spin_lock(&lock->wait_lock);
689} 800}
@@ -696,6 +807,7 @@ static void remove_waiter(struct rt_mutex *lock,
696void rt_mutex_adjust_pi(struct task_struct *task) 807void rt_mutex_adjust_pi(struct task_struct *task)
697{ 808{
698 struct rt_mutex_waiter *waiter; 809 struct rt_mutex_waiter *waiter;
810 struct rt_mutex *next_lock;
699 unsigned long flags; 811 unsigned long flags;
700 812
701 raw_spin_lock_irqsave(&task->pi_lock, flags); 813 raw_spin_lock_irqsave(&task->pi_lock, flags);
@@ -706,12 +818,13 @@ void rt_mutex_adjust_pi(struct task_struct *task)
706 raw_spin_unlock_irqrestore(&task->pi_lock, flags); 818 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
707 return; 819 return;
708 } 820 }
709 821 next_lock = waiter->lock;
710 raw_spin_unlock_irqrestore(&task->pi_lock, flags); 822 raw_spin_unlock_irqrestore(&task->pi_lock, flags);
711 823
712 /* gets dropped in rt_mutex_adjust_prio_chain()! */ 824 /* gets dropped in rt_mutex_adjust_prio_chain()! */
713 get_task_struct(task); 825 get_task_struct(task);
714 rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task); 826
827 rt_mutex_adjust_prio_chain(task, 0, NULL, next_lock, NULL, task);
715} 828}
716 829
717/** 830/**
@@ -763,6 +876,26 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state,
763 return ret; 876 return ret;
764} 877}
765 878
879static void rt_mutex_handle_deadlock(int res, int detect_deadlock,
880 struct rt_mutex_waiter *w)
881{
882 /*
883 * If the result is not -EDEADLOCK or the caller requested
884 * deadlock detection, nothing to do here.
885 */
886 if (res != -EDEADLOCK || detect_deadlock)
887 return;
888
889 /*
890 * Yell lowdly and stop the task right here.
891 */
892 rt_mutex_print_deadlock(w);
893 while (1) {
894 set_current_state(TASK_INTERRUPTIBLE);
895 schedule();
896 }
897}
898
766/* 899/*
767 * Slow path lock function: 900 * Slow path lock function:
768 */ 901 */
@@ -802,8 +935,10 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
802 935
803 set_current_state(TASK_RUNNING); 936 set_current_state(TASK_RUNNING);
804 937
805 if (unlikely(ret)) 938 if (unlikely(ret)) {
806 remove_waiter(lock, &waiter); 939 remove_waiter(lock, &waiter);
940 rt_mutex_handle_deadlock(ret, detect_deadlock, &waiter);
941 }
807 942
808 /* 943 /*
809 * try_to_take_rt_mutex() sets the waiter bit 944 * try_to_take_rt_mutex() sets the waiter bit
@@ -859,12 +994,49 @@ rt_mutex_slowunlock(struct rt_mutex *lock)
859 994
860 rt_mutex_deadlock_account_unlock(current); 995 rt_mutex_deadlock_account_unlock(current);
861 996
862 if (!rt_mutex_has_waiters(lock)) { 997 /*
863 lock->owner = NULL; 998 * We must be careful here if the fast path is enabled. If we
864 raw_spin_unlock(&lock->wait_lock); 999 * have no waiters queued we cannot set owner to NULL here
865 return; 1000 * because of:
1001 *
1002 * foo->lock->owner = NULL;
1003 * rtmutex_lock(foo->lock); <- fast path
1004 * free = atomic_dec_and_test(foo->refcnt);
1005 * rtmutex_unlock(foo->lock); <- fast path
1006 * if (free)
1007 * kfree(foo);
1008 * raw_spin_unlock(foo->lock->wait_lock);
1009 *
1010 * So for the fastpath enabled kernel:
1011 *
1012 * Nothing can set the waiters bit as long as we hold
1013 * lock->wait_lock. So we do the following sequence:
1014 *
1015 * owner = rt_mutex_owner(lock);
1016 * clear_rt_mutex_waiters(lock);
1017 * raw_spin_unlock(&lock->wait_lock);
1018 * if (cmpxchg(&lock->owner, owner, 0) == owner)
1019 * return;
1020 * goto retry;
1021 *
1022 * The fastpath disabled variant is simple as all access to
1023 * lock->owner is serialized by lock->wait_lock:
1024 *
1025 * lock->owner = NULL;
1026 * raw_spin_unlock(&lock->wait_lock);
1027 */
1028 while (!rt_mutex_has_waiters(lock)) {
1029 /* Drops lock->wait_lock ! */
1030 if (unlock_rt_mutex_safe(lock) == true)
1031 return;
1032 /* Relock the rtmutex and try again */
1033 raw_spin_lock(&lock->wait_lock);
866 } 1034 }
867 1035
1036 /*
1037 * The wakeup next waiter path does not suffer from the above
1038 * race. See the comments there.
1039 */
868 wakeup_next_waiter(lock); 1040 wakeup_next_waiter(lock);
869 1041
870 raw_spin_unlock(&lock->wait_lock); 1042 raw_spin_unlock(&lock->wait_lock);
@@ -1112,7 +1284,8 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1112 return 1; 1284 return 1;
1113 } 1285 }
1114 1286
1115 ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock); 1287 /* We enforce deadlock detection for futexes */
1288 ret = task_blocks_on_rt_mutex(lock, waiter, task, 1);
1116 1289
1117 if (ret && !rt_mutex_owner(lock)) { 1290 if (ret && !rt_mutex_owner(lock)) {
1118 /* 1291 /*
diff --git a/kernel/locking/rtmutex.h b/kernel/locking/rtmutex.h
index a1a1dd06421d..f6a1f3c133b1 100644
--- a/kernel/locking/rtmutex.h
+++ b/kernel/locking/rtmutex.h
@@ -24,3 +24,8 @@
24#define debug_rt_mutex_print_deadlock(w) do { } while (0) 24#define debug_rt_mutex_print_deadlock(w) do { } while (0)
25#define debug_rt_mutex_detect_deadlock(w,d) (d) 25#define debug_rt_mutex_detect_deadlock(w,d) (d)
26#define debug_rt_mutex_reset_waiter(w) do { } while (0) 26#define debug_rt_mutex_reset_waiter(w) do { } while (0)
27
28static inline void rt_mutex_print_deadlock(struct rt_mutex_waiter *w)
29{
30 WARN(1, "rtmutex deadlock detected\n");
31}
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 49e0a20fd010..fcc2611d3f14 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -35,6 +35,7 @@
35 35
36static int nocompress; 36static int nocompress;
37static int noresume; 37static int noresume;
38static int nohibernate;
38static int resume_wait; 39static int resume_wait;
39static unsigned int resume_delay; 40static unsigned int resume_delay;
40static char resume_file[256] = CONFIG_PM_STD_PARTITION; 41static char resume_file[256] = CONFIG_PM_STD_PARTITION;
@@ -62,6 +63,11 @@ bool freezer_test_done;
62 63
63static const struct platform_hibernation_ops *hibernation_ops; 64static const struct platform_hibernation_ops *hibernation_ops;
64 65
66bool hibernation_available(void)
67{
68 return (nohibernate == 0);
69}
70
65/** 71/**
66 * hibernation_set_ops - Set the global hibernate operations. 72 * hibernation_set_ops - Set the global hibernate operations.
67 * @ops: Hibernation operations to use in subsequent hibernation transitions. 73 * @ops: Hibernation operations to use in subsequent hibernation transitions.
@@ -642,6 +648,11 @@ int hibernate(void)
642{ 648{
643 int error; 649 int error;
644 650
651 if (!hibernation_available()) {
652 pr_debug("PM: Hibernation not available.\n");
653 return -EPERM;
654 }
655
645 lock_system_sleep(); 656 lock_system_sleep();
646 /* The snapshot device should not be opened while we're running */ 657 /* The snapshot device should not be opened while we're running */
647 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 658 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
@@ -734,7 +745,7 @@ static int software_resume(void)
734 /* 745 /*
735 * If the user said "noresume".. bail out early. 746 * If the user said "noresume".. bail out early.
736 */ 747 */
737 if (noresume) 748 if (noresume || !hibernation_available())
738 return 0; 749 return 0;
739 750
740 /* 751 /*
@@ -900,6 +911,9 @@ static ssize_t disk_show(struct kobject *kobj, struct kobj_attribute *attr,
900 int i; 911 int i;
901 char *start = buf; 912 char *start = buf;
902 913
914 if (!hibernation_available())
915 return sprintf(buf, "[disabled]\n");
916
903 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) { 917 for (i = HIBERNATION_FIRST; i <= HIBERNATION_MAX; i++) {
904 if (!hibernation_modes[i]) 918 if (!hibernation_modes[i])
905 continue; 919 continue;
@@ -934,6 +948,9 @@ static ssize_t disk_store(struct kobject *kobj, struct kobj_attribute *attr,
934 char *p; 948 char *p;
935 int mode = HIBERNATION_INVALID; 949 int mode = HIBERNATION_INVALID;
936 950
951 if (!hibernation_available())
952 return -EPERM;
953
937 p = memchr(buf, '\n', n); 954 p = memchr(buf, '\n', n);
938 len = p ? p - buf : n; 955 len = p ? p - buf : n;
939 956
@@ -1101,6 +1118,10 @@ static int __init hibernate_setup(char *str)
1101 noresume = 1; 1118 noresume = 1;
1102 else if (!strncmp(str, "nocompress", 10)) 1119 else if (!strncmp(str, "nocompress", 10))
1103 nocompress = 1; 1120 nocompress = 1;
1121 else if (!strncmp(str, "no", 2)) {
1122 noresume = 1;
1123 nohibernate = 1;
1124 }
1104 return 1; 1125 return 1;
1105} 1126}
1106 1127
@@ -1125,9 +1146,23 @@ static int __init resumedelay_setup(char *str)
1125 return 1; 1146 return 1;
1126} 1147}
1127 1148
1149static int __init nohibernate_setup(char *str)
1150{
1151 noresume = 1;
1152 nohibernate = 1;
1153 return 1;
1154}
1155
1156static int __init kaslr_nohibernate_setup(char *str)
1157{
1158 return nohibernate_setup(str);
1159}
1160
1128__setup("noresume", noresume_setup); 1161__setup("noresume", noresume_setup);
1129__setup("resume_offset=", resume_offset_setup); 1162__setup("resume_offset=", resume_offset_setup);
1130__setup("resume=", resume_setup); 1163__setup("resume=", resume_setup);
1131__setup("hibernate=", hibernate_setup); 1164__setup("hibernate=", hibernate_setup);
1132__setup("resumewait", resumewait_setup); 1165__setup("resumewait", resumewait_setup);
1133__setup("resumedelay=", resumedelay_setup); 1166__setup("resumedelay=", resumedelay_setup);
1167__setup("nohibernate", nohibernate_setup);
1168__setup("kaslr", kaslr_nohibernate_setup);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 573410d6647e..8e90f330f139 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -300,13 +300,11 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
300 s += sprintf(s,"%s ", pm_states[i].label); 300 s += sprintf(s,"%s ", pm_states[i].label);
301 301
302#endif 302#endif
303#ifdef CONFIG_HIBERNATION 303 if (hibernation_available())
304 s += sprintf(s, "%s\n", "disk"); 304 s += sprintf(s, "disk ");
305#else
306 if (s != buf) 305 if (s != buf)
307 /* convert the last space to a newline */ 306 /* convert the last space to a newline */
308 *(s-1) = '\n'; 307 *(s-1) = '\n';
309#endif
310 return (s - buf); 308 return (s - buf);
311} 309}
312 310
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 98d357584cd6..526e8911460a 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -49,6 +49,9 @@ static int snapshot_open(struct inode *inode, struct file *filp)
49 struct snapshot_data *data; 49 struct snapshot_data *data;
50 int error; 50 int error;
51 51
52 if (!hibernation_available())
53 return -EPERM;
54
52 lock_system_sleep(); 55 lock_system_sleep();
53 56
54 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) { 57 if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ba9ed453c4ed..7de6555cfea0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -152,10 +152,6 @@ static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
152#ifdef CONFIG_SPARC 152#ifdef CONFIG_SPARC
153#endif 153#endif
154 154
155#ifdef CONFIG_SPARC64
156extern int sysctl_tsb_ratio;
157#endif
158
159#ifdef __hppa__ 155#ifdef __hppa__
160extern int pwrsw_enabled; 156extern int pwrsw_enabled;
161#endif 157#endif
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index b5f08f727868..35d5a5877d04 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -289,14 +289,16 @@ EOF
289 289
290fi 290fi
291 291
292# Build header package 292# Build kernel header package
293(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") 293(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles"
294(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") 294(cd $srctree; find arch/$SRCARCH/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles"
295(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") 295(cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles"
296(cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles"
297(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles"
296destdir=$kernel_headers_dir/usr/src/linux-headers-$version 298destdir=$kernel_headers_dir/usr/src/linux-headers-$version
297mkdir -p "$destdir" 299mkdir -p "$destdir"
298(cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -) 300(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -)
299(cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) 301(cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -)
300(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be 302(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be
301ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" 303ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
302rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" 304rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 995c1eafaff6..e046bff33589 100644
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -125,12 +125,11 @@ esac
125# Create the tarball 125# Create the tarball
126# 126#
127( 127(
128 cd "${tmpdir}"
129 opts= 128 opts=
130 if tar --owner=root --group=root --help >/dev/null 2>&1; then 129 if tar --owner=root --group=root --help >/dev/null 2>&1; then
131 opts="--owner=root --group=root" 130 opts="--owner=root --group=root"
132 fi 131 fi
133 tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}" 132 tar cf - -C "$tmpdir" boot/ lib/ $opts | ${compress} > "${tarball}${file_ext}"
134) 133)
135 134
136echo "Tarball successfully created in ${tarball}${file_ext}" 135echo "Tarball successfully created in ${tarball}${file_ext}"
diff --git a/sound/core/control.c b/sound/core/control.c
index f038f5afafe2..f0b0e14497a5 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -288,6 +288,10 @@ static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
288{ 288{
289 struct snd_kcontrol *kctl; 289 struct snd_kcontrol *kctl;
290 290
291 /* Make sure that the ids assigned to the control do not wrap around */
292 if (card->last_numid >= UINT_MAX - count)
293 card->last_numid = 0;
294
291 list_for_each_entry(kctl, &card->controls, list) { 295 list_for_each_entry(kctl, &card->controls, list) {
292 if (kctl->id.numid < card->last_numid + 1 + count && 296 if (kctl->id.numid < card->last_numid + 1 + count &&
293 kctl->id.numid + kctl->count > card->last_numid + 1) { 297 kctl->id.numid + kctl->count > card->last_numid + 1) {
@@ -330,6 +334,7 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
330{ 334{
331 struct snd_ctl_elem_id id; 335 struct snd_ctl_elem_id id;
332 unsigned int idx; 336 unsigned int idx;
337 unsigned int count;
333 int err = -EINVAL; 338 int err = -EINVAL;
334 339
335 if (! kcontrol) 340 if (! kcontrol)
@@ -337,6 +342,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
337 if (snd_BUG_ON(!card || !kcontrol->info)) 342 if (snd_BUG_ON(!card || !kcontrol->info))
338 goto error; 343 goto error;
339 id = kcontrol->id; 344 id = kcontrol->id;
345 if (id.index > UINT_MAX - kcontrol->count)
346 goto error;
347
340 down_write(&card->controls_rwsem); 348 down_write(&card->controls_rwsem);
341 if (snd_ctl_find_id(card, &id)) { 349 if (snd_ctl_find_id(card, &id)) {
342 up_write(&card->controls_rwsem); 350 up_write(&card->controls_rwsem);
@@ -358,8 +366,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
358 card->controls_count += kcontrol->count; 366 card->controls_count += kcontrol->count;
359 kcontrol->id.numid = card->last_numid + 1; 367 kcontrol->id.numid = card->last_numid + 1;
360 card->last_numid += kcontrol->count; 368 card->last_numid += kcontrol->count;
369 count = kcontrol->count;
361 up_write(&card->controls_rwsem); 370 up_write(&card->controls_rwsem);
362 for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++) 371 for (idx = 0; idx < count; idx++, id.index++, id.numid++)
363 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); 372 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
364 return 0; 373 return 0;
365 374
@@ -388,6 +397,7 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
388 bool add_on_replace) 397 bool add_on_replace)
389{ 398{
390 struct snd_ctl_elem_id id; 399 struct snd_ctl_elem_id id;
400 unsigned int count;
391 unsigned int idx; 401 unsigned int idx;
392 struct snd_kcontrol *old; 402 struct snd_kcontrol *old;
393 int ret; 403 int ret;
@@ -423,8 +433,9 @@ add:
423 card->controls_count += kcontrol->count; 433 card->controls_count += kcontrol->count;
424 kcontrol->id.numid = card->last_numid + 1; 434 kcontrol->id.numid = card->last_numid + 1;
425 card->last_numid += kcontrol->count; 435 card->last_numid += kcontrol->count;
436 count = kcontrol->count;
426 up_write(&card->controls_rwsem); 437 up_write(&card->controls_rwsem);
427 for (idx = 0; idx < kcontrol->count; idx++, id.index++, id.numid++) 438 for (idx = 0; idx < count; idx++, id.index++, id.numid++)
428 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); 439 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id);
429 return 0; 440 return 0;
430 441
@@ -897,9 +908,9 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
897 result = kctl->put(kctl, control); 908 result = kctl->put(kctl, control);
898 } 909 }
899 if (result > 0) { 910 if (result > 0) {
911 struct snd_ctl_elem_id id = control->id;
900 up_read(&card->controls_rwsem); 912 up_read(&card->controls_rwsem);
901 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, 913 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id);
902 &control->id);
903 return 0; 914 return 0;
904 } 915 }
905 } 916 }
@@ -991,6 +1002,7 @@ static int snd_ctl_elem_unlock(struct snd_ctl_file *file,
991 1002
992struct user_element { 1003struct user_element {
993 struct snd_ctl_elem_info info; 1004 struct snd_ctl_elem_info info;
1005 struct snd_card *card;
994 void *elem_data; /* element data */ 1006 void *elem_data; /* element data */
995 unsigned long elem_data_size; /* size of element data in bytes */ 1007 unsigned long elem_data_size; /* size of element data in bytes */
996 void *tlv_data; /* TLV data */ 1008 void *tlv_data; /* TLV data */
@@ -1034,7 +1046,9 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol,
1034{ 1046{
1035 struct user_element *ue = kcontrol->private_data; 1047 struct user_element *ue = kcontrol->private_data;
1036 1048
1049 mutex_lock(&ue->card->user_ctl_lock);
1037 memcpy(&ucontrol->value, ue->elem_data, ue->elem_data_size); 1050 memcpy(&ucontrol->value, ue->elem_data, ue->elem_data_size);
1051 mutex_unlock(&ue->card->user_ctl_lock);
1038 return 0; 1052 return 0;
1039} 1053}
1040 1054
@@ -1043,10 +1057,12 @@ static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol,
1043{ 1057{
1044 int change; 1058 int change;
1045 struct user_element *ue = kcontrol->private_data; 1059 struct user_element *ue = kcontrol->private_data;
1046 1060
1061 mutex_lock(&ue->card->user_ctl_lock);
1047 change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0; 1062 change = memcmp(&ucontrol->value, ue->elem_data, ue->elem_data_size) != 0;
1048 if (change) 1063 if (change)
1049 memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size); 1064 memcpy(ue->elem_data, &ucontrol->value, ue->elem_data_size);
1065 mutex_unlock(&ue->card->user_ctl_lock);
1050 return change; 1066 return change;
1051} 1067}
1052 1068
@@ -1066,19 +1082,32 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
1066 new_data = memdup_user(tlv, size); 1082 new_data = memdup_user(tlv, size);
1067 if (IS_ERR(new_data)) 1083 if (IS_ERR(new_data))
1068 return PTR_ERR(new_data); 1084 return PTR_ERR(new_data);
1085 mutex_lock(&ue->card->user_ctl_lock);
1069 change = ue->tlv_data_size != size; 1086 change = ue->tlv_data_size != size;
1070 if (!change) 1087 if (!change)
1071 change = memcmp(ue->tlv_data, new_data, size); 1088 change = memcmp(ue->tlv_data, new_data, size);
1072 kfree(ue->tlv_data); 1089 kfree(ue->tlv_data);
1073 ue->tlv_data = new_data; 1090 ue->tlv_data = new_data;
1074 ue->tlv_data_size = size; 1091 ue->tlv_data_size = size;
1092 mutex_unlock(&ue->card->user_ctl_lock);
1075 } else { 1093 } else {
1076 if (! ue->tlv_data_size || ! ue->tlv_data) 1094 int ret = 0;
1077 return -ENXIO; 1095
1078 if (size < ue->tlv_data_size) 1096 mutex_lock(&ue->card->user_ctl_lock);
1079 return -ENOSPC; 1097 if (!ue->tlv_data_size || !ue->tlv_data) {
1098 ret = -ENXIO;
1099 goto err_unlock;
1100 }
1101 if (size < ue->tlv_data_size) {
1102 ret = -ENOSPC;
1103 goto err_unlock;
1104 }
1080 if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size)) 1105 if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size))
1081 return -EFAULT; 1106 ret = -EFAULT;
1107err_unlock:
1108 mutex_unlock(&ue->card->user_ctl_lock);
1109 if (ret)
1110 return ret;
1082 } 1111 }
1083 return change; 1112 return change;
1084} 1113}
@@ -1136,8 +1165,6 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
1136 struct user_element *ue; 1165 struct user_element *ue;
1137 int idx, err; 1166 int idx, err;
1138 1167
1139 if (!replace && card->user_ctl_count >= MAX_USER_CONTROLS)
1140 return -ENOMEM;
1141 if (info->count < 1) 1168 if (info->count < 1)
1142 return -EINVAL; 1169 return -EINVAL;
1143 access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : 1170 access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
@@ -1146,21 +1173,16 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
1146 SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE)); 1173 SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE));
1147 info->id.numid = 0; 1174 info->id.numid = 0;
1148 memset(&kctl, 0, sizeof(kctl)); 1175 memset(&kctl, 0, sizeof(kctl));
1149 down_write(&card->controls_rwsem); 1176
1150 _kctl = snd_ctl_find_id(card, &info->id); 1177 if (replace) {
1151 err = 0; 1178 err = snd_ctl_remove_user_ctl(file, &info->id);
1152 if (_kctl) { 1179 if (err)
1153 if (replace) 1180 return err;
1154 err = snd_ctl_remove(card, _kctl);
1155 else
1156 err = -EBUSY;
1157 } else {
1158 if (replace)
1159 err = -ENOENT;
1160 } 1181 }
1161 up_write(&card->controls_rwsem); 1182
1162 if (err < 0) 1183 if (card->user_ctl_count >= MAX_USER_CONTROLS)
1163 return err; 1184 return -ENOMEM;
1185
1164 memcpy(&kctl.id, &info->id, sizeof(info->id)); 1186 memcpy(&kctl.id, &info->id, sizeof(info->id));
1165 kctl.count = info->owner ? info->owner : 1; 1187 kctl.count = info->owner ? info->owner : 1;
1166 access |= SNDRV_CTL_ELEM_ACCESS_USER; 1188 access |= SNDRV_CTL_ELEM_ACCESS_USER;
@@ -1210,6 +1232,7 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
1210 ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL); 1232 ue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);
1211 if (ue == NULL) 1233 if (ue == NULL)
1212 return -ENOMEM; 1234 return -ENOMEM;
1235 ue->card = card;
1213 ue->info = *info; 1236 ue->info = *info;
1214 ue->info.access = 0; 1237 ue->info.access = 0;
1215 ue->elem_data = (char *)ue + sizeof(*ue); 1238 ue->elem_data = (char *)ue + sizeof(*ue);
@@ -1321,8 +1344,9 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,
1321 } 1344 }
1322 err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv); 1345 err = kctl->tlv.c(kctl, op_flag, tlv.length, _tlv->tlv);
1323 if (err > 0) { 1346 if (err > 0) {
1347 struct snd_ctl_elem_id id = kctl->id;
1324 up_read(&card->controls_rwsem); 1348 up_read(&card->controls_rwsem);
1325 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &kctl->id); 1349 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id);
1326 return 0; 1350 return 0;
1327 } 1351 }
1328 } else { 1352 } else {
diff --git a/sound/core/init.c b/sound/core/init.c
index 5ee83845c5de..7bdfd19e24a8 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -232,6 +232,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
232 INIT_LIST_HEAD(&card->devices); 232 INIT_LIST_HEAD(&card->devices);
233 init_rwsem(&card->controls_rwsem); 233 init_rwsem(&card->controls_rwsem);
234 rwlock_init(&card->ctl_files_rwlock); 234 rwlock_init(&card->ctl_files_rwlock);
235 mutex_init(&card->user_ctl_lock);
235 INIT_LIST_HEAD(&card->controls); 236 INIT_LIST_HEAD(&card->controls);
236 INIT_LIST_HEAD(&card->ctl_files); 237 INIT_LIST_HEAD(&card->ctl_files);
237 spin_lock_init(&card->files_lock); 238 spin_lock_init(&card->files_lock);
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 9d07e4edacdb..e9e8a4a4a9a1 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -22,20 +22,20 @@
22#include <drm/i915_powerwell.h> 22#include <drm/i915_powerwell.h>
23#include "hda_i915.h" 23#include "hda_i915.h"
24 24
25static void (*get_power)(void); 25static int (*get_power)(void);
26static void (*put_power)(void); 26static int (*put_power)(void);
27 27
28void hda_display_power(bool enable) 28int hda_display_power(bool enable)
29{ 29{
30 if (!get_power || !put_power) 30 if (!get_power || !put_power)
31 return; 31 return -ENODEV;
32 32
33 pr_debug("HDA display power %s \n", 33 pr_debug("HDA display power %s \n",
34 enable ? "Enable" : "Disable"); 34 enable ? "Enable" : "Disable");
35 if (enable) 35 if (enable)
36 get_power(); 36 return get_power();
37 else 37 else
38 put_power(); 38 return put_power();
39} 39}
40 40
41int hda_i915_init(void) 41int hda_i915_init(void)
diff --git a/sound/pci/hda/hda_i915.h b/sound/pci/hda/hda_i915.h
index 5a63da2c53e5..bfd835f8f1aa 100644
--- a/sound/pci/hda/hda_i915.h
+++ b/sound/pci/hda/hda_i915.h
@@ -17,11 +17,11 @@
17#define __SOUND_HDA_I915_H 17#define __SOUND_HDA_I915_H
18 18
19#ifdef CONFIG_SND_HDA_I915 19#ifdef CONFIG_SND_HDA_I915
20void hda_display_power(bool enable); 20int hda_display_power(bool enable);
21int hda_i915_init(void); 21int hda_i915_init(void);
22int hda_i915_exit(void); 22int hda_i915_exit(void);
23#else 23#else
24static inline void hda_display_power(bool enable) {} 24static inline int hda_display_power(bool enable) { return 0; }
25static inline int hda_i915_init(void) 25static inline int hda_i915_init(void)
26{ 26{
27 return -ENODEV; 27 return -ENODEV;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index bb65a124e006..23fd6b9aecca 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1656,8 +1656,13 @@ static int azx_probe_continue(struct azx *chip)
1656 "Error request power-well from i915\n"); 1656 "Error request power-well from i915\n");
1657 goto out_free; 1657 goto out_free;
1658 } 1658 }
1659 err = hda_display_power(true);
1660 if (err < 0) {
1661 dev_err(chip->card->dev,
1662 "Cannot turn on display power on i915\n");
1663 goto out_free;
1664 }
1659#endif 1665#endif
1660 hda_display_power(true);
1661 } 1666 }
1662 1667
1663 err = azx_first_init(chip); 1668 err = azx_first_init(chip);
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index cbfa1e18f651..0b9571c858f8 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -225,11 +225,11 @@ config SND_SOC_ADAU1373
225config SND_SOC_ADAU1701 225config SND_SOC_ADAU1701
226 tristate "Analog Devices ADAU1701 CODEC" 226 tristate "Analog Devices ADAU1701 CODEC"
227 depends on I2C 227 depends on I2C
228 select SND_SOC_SIGMADSP 228 select SND_SOC_SIGMADSP_I2C
229 229
230config SND_SOC_ADAU17X1 230config SND_SOC_ADAU17X1
231 tristate 231 tristate
232 select SND_SOC_SIGMADSP 232 select SND_SOC_SIGMADSP_REGMAP
233 233
234config SND_SOC_ADAU1761 234config SND_SOC_ADAU1761
235 tristate 235 tristate
@@ -476,6 +476,14 @@ config SND_SOC_SIGMADSP
476 tristate 476 tristate
477 select CRC32 477 select CRC32
478 478
479config SND_SOC_SIGMADSP_I2C
480 tristate
481 select SND_SOC_SIGMADSP
482
483config SND_SOC_SIGMADSP_REGMAP
484 tristate
485 select SND_SOC_SIGMADSP
486
479config SND_SOC_SIRF_AUDIO_CODEC 487config SND_SOC_SIRF_AUDIO_CODEC
480 tristate "SiRF SoC internal audio codec" 488 tristate "SiRF SoC internal audio codec"
481 select REGMAP_MMIO 489 select REGMAP_MMIO
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index be3377b8d73f..1bd6e1cf6f82 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -77,6 +77,8 @@ snd-soc-sgtl5000-objs := sgtl5000.o
77snd-soc-alc5623-objs := alc5623.o 77snd-soc-alc5623-objs := alc5623.o
78snd-soc-alc5632-objs := alc5632.o 78snd-soc-alc5632-objs := alc5632.o
79snd-soc-sigmadsp-objs := sigmadsp.o 79snd-soc-sigmadsp-objs := sigmadsp.o
80snd-soc-sigmadsp-i2c-objs := sigmadsp-i2c.o
81snd-soc-sigmadsp-regmap-objs := sigmadsp-regmap.o
80snd-soc-si476x-objs := si476x.o 82snd-soc-si476x-objs := si476x.o
81snd-soc-sirf-audio-codec-objs := sirf-audio-codec.o 83snd-soc-sirf-audio-codec-objs := sirf-audio-codec.o
82snd-soc-sn95031-objs := sn95031.o 84snd-soc-sn95031-objs := sn95031.o
@@ -240,6 +242,8 @@ obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o
240obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o 242obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o
241obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o 243obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
242obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o 244obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o
245obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o
246obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP) += snd-soc-sigmadsp-regmap.o
243obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o 247obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o
244obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o 248obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o
245obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o 249obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o
diff --git a/sound/soc/codecs/sigmadsp-i2c.c b/sound/soc/codecs/sigmadsp-i2c.c
new file mode 100644
index 000000000000..246081aae8ca
--- /dev/null
+++ b/sound/soc/codecs/sigmadsp-i2c.c
@@ -0,0 +1,35 @@
1/*
2 * Load Analog Devices SigmaStudio firmware files
3 *
4 * Copyright 2009-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/i2c.h>
10#include <linux/export.h>
11#include <linux/module.h>
12
13#include "sigmadsp.h"
14
15static int sigma_action_write_i2c(void *control_data,
16 const struct sigma_action *sa, size_t len)
17{
18 return i2c_master_send(control_data, (const unsigned char *)&sa->addr,
19 len);
20}
21
22int process_sigma_firmware(struct i2c_client *client, const char *name)
23{
24 struct sigma_firmware ssfw;
25
26 ssfw.control_data = client;
27 ssfw.write = sigma_action_write_i2c;
28
29 return _process_sigma_firmware(&client->dev, &ssfw, name);
30}
31EXPORT_SYMBOL(process_sigma_firmware);
32
33MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
34MODULE_DESCRIPTION("SigmaDSP I2C firmware loader");
35MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/sigmadsp-regmap.c b/sound/soc/codecs/sigmadsp-regmap.c
new file mode 100644
index 000000000000..f78ed8d2cfb2
--- /dev/null
+++ b/sound/soc/codecs/sigmadsp-regmap.c
@@ -0,0 +1,36 @@
1/*
2 * Load Analog Devices SigmaStudio firmware files
3 *
4 * Copyright 2009-2011 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <linux/regmap.h>
10#include <linux/export.h>
11#include <linux/module.h>
12
13#include "sigmadsp.h"
14
15static int sigma_action_write_regmap(void *control_data,
16 const struct sigma_action *sa, size_t len)
17{
18 return regmap_raw_write(control_data, be16_to_cpu(sa->addr),
19 sa->payload, len - 2);
20}
21
22int process_sigma_firmware_regmap(struct device *dev, struct regmap *regmap,
23 const char *name)
24{
25 struct sigma_firmware ssfw;
26
27 ssfw.control_data = regmap;
28 ssfw.write = sigma_action_write_regmap;
29
30 return _process_sigma_firmware(dev, &ssfw, name);
31}
32EXPORT_SYMBOL(process_sigma_firmware_regmap);
33
34MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
35MODULE_DESCRIPTION("SigmaDSP regmap firmware loader");
36MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/sigmadsp.c b/sound/soc/codecs/sigmadsp.c
index 4068f2491232..f2de7e049bc6 100644
--- a/sound/soc/codecs/sigmadsp.c
+++ b/sound/soc/codecs/sigmadsp.c
@@ -34,23 +34,6 @@ enum {
34 SIGMA_ACTION_END, 34 SIGMA_ACTION_END,
35}; 35};
36 36
37struct sigma_action {
38 u8 instr;
39 u8 len_hi;
40 __le16 len;
41 __be16 addr;
42 unsigned char payload[];
43} __packed;
44
45struct sigma_firmware {
46 const struct firmware *fw;
47 size_t pos;
48
49 void *control_data;
50 int (*write)(void *control_data, const struct sigma_action *sa,
51 size_t len);
52};
53
54static inline u32 sigma_action_len(struct sigma_action *sa) 37static inline u32 sigma_action_len(struct sigma_action *sa)
55{ 38{
56 return (sa->len_hi << 16) | le16_to_cpu(sa->len); 39 return (sa->len_hi << 16) | le16_to_cpu(sa->len);
@@ -138,7 +121,7 @@ process_sigma_actions(struct sigma_firmware *ssfw)
138 return 0; 121 return 0;
139} 122}
140 123
141static int _process_sigma_firmware(struct device *dev, 124int _process_sigma_firmware(struct device *dev,
142 struct sigma_firmware *ssfw, const char *name) 125 struct sigma_firmware *ssfw, const char *name)
143{ 126{
144 int ret; 127 int ret;
@@ -197,50 +180,6 @@ static int _process_sigma_firmware(struct device *dev,
197 180
198 return ret; 181 return ret;
199} 182}
200 183EXPORT_SYMBOL_GPL(_process_sigma_firmware);
201#if IS_ENABLED(CONFIG_I2C)
202
203static int sigma_action_write_i2c(void *control_data,
204 const struct sigma_action *sa, size_t len)
205{
206 return i2c_master_send(control_data, (const unsigned char *)&sa->addr,
207 len);
208}
209
210int process_sigma_firmware(struct i2c_client *client, const char *name)
211{
212 struct sigma_firmware ssfw;
213
214 ssfw.control_data = client;
215 ssfw.write = sigma_action_write_i2c;
216
217 return _process_sigma_firmware(&client->dev, &ssfw, name);
218}
219EXPORT_SYMBOL(process_sigma_firmware);
220
221#endif
222
223#if IS_ENABLED(CONFIG_REGMAP)
224
225static int sigma_action_write_regmap(void *control_data,
226 const struct sigma_action *sa, size_t len)
227{
228 return regmap_raw_write(control_data, be16_to_cpu(sa->addr),
229 sa->payload, len - 2);
230}
231
232int process_sigma_firmware_regmap(struct device *dev, struct regmap *regmap,
233 const char *name)
234{
235 struct sigma_firmware ssfw;
236
237 ssfw.control_data = regmap;
238 ssfw.write = sigma_action_write_regmap;
239
240 return _process_sigma_firmware(dev, &ssfw, name);
241}
242EXPORT_SYMBOL(process_sigma_firmware_regmap);
243
244#endif
245 184
246MODULE_LICENSE("GPL"); 185MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/sigmadsp.h b/sound/soc/codecs/sigmadsp.h
index e439cbd7af7d..c47cd23e9827 100644
--- a/sound/soc/codecs/sigmadsp.h
+++ b/sound/soc/codecs/sigmadsp.h
@@ -12,6 +12,26 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/regmap.h> 13#include <linux/regmap.h>
14 14
15struct sigma_action {
16 u8 instr;
17 u8 len_hi;
18 __le16 len;
19 __be16 addr;
20 unsigned char payload[];
21} __packed;
22
23struct sigma_firmware {
24 const struct firmware *fw;
25 size_t pos;
26
27 void *control_data;
28 int (*write)(void *control_data, const struct sigma_action *sa,
29 size_t len);
30};
31
32int _process_sigma_firmware(struct device *dev,
33 struct sigma_firmware *ssfw, const char *name);
34
15struct i2c_client; 35struct i2c_client;
16 36
17extern int process_sigma_firmware(struct i2c_client *client, const char *name); 37extern int process_sigma_firmware(struct i2c_client *client, const char *name);
diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c
index 6bb0ea59284f..a609aafc994d 100644
--- a/sound/soc/fsl/fsl_dma.c
+++ b/sound/soc/fsl/fsl_dma.c
@@ -923,8 +923,8 @@ static int fsl_soc_dma_probe(struct platform_device *pdev)
923 dma->dai.pcm_free = fsl_dma_free_dma_buffers; 923 dma->dai.pcm_free = fsl_dma_free_dma_buffers;
924 924
925 /* Store the SSI-specific information that we need */ 925 /* Store the SSI-specific information that we need */
926 dma->ssi_stx_phys = res.start + offsetof(struct ccsr_ssi, stx0); 926 dma->ssi_stx_phys = res.start + CCSR_SSI_STX0;
927 dma->ssi_srx_phys = res.start + offsetof(struct ccsr_ssi, srx0); 927 dma->ssi_srx_phys = res.start + CCSR_SSI_SRX0;
928 928
929 iprop = of_get_property(ssi_np, "fsl,fifo-depth", NULL); 929 iprop = of_get_property(ssi_np, "fsl,fifo-depth", NULL);
930 if (iprop) 930 if (iprop)
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index b912d45a2a4c..d7a60614dd21 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -762,7 +762,7 @@ static int fsl_spdif_vbit_get(struct snd_kcontrol *kcontrol,
762 struct regmap *regmap = spdif_priv->regmap; 762 struct regmap *regmap = spdif_priv->regmap;
763 u32 val; 763 u32 val;
764 764
765 val = regmap_read(regmap, REG_SPDIF_SIS, &val); 765 regmap_read(regmap, REG_SPDIF_SIS, &val);
766 ucontrol->value.integer.value[0] = (val & INT_VAL_NOGOOD) != 0; 766 ucontrol->value.integer.value[0] = (val & INT_VAL_NOGOOD) != 0;
767 regmap_write(regmap, REG_SPDIF_SIC, INT_VAL_NOGOOD); 767 regmap_write(regmap, REG_SPDIF_SIC, INT_VAL_NOGOOD);
768 768
@@ -1076,7 +1076,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
1076 goto out; 1076 goto out;
1077 } else if (arate / rate[index] == 1) { 1077 } else if (arate / rate[index] == 1) {
1078 /* A little bigger than expect */ 1078 /* A little bigger than expect */
1079 sub = (arate - rate[index]) * 100000; 1079 sub = (u64)(arate - rate[index]) * 100000;
1080 do_div(sub, rate[index]); 1080 do_div(sub, rate[index]);
1081 if (sub >= savesub) 1081 if (sub >= savesub)
1082 continue; 1082 continue;
@@ -1086,7 +1086,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
1086 spdif_priv->txrate[index] = arate; 1086 spdif_priv->txrate[index] = arate;
1087 } else if (rate[index] / arate == 1) { 1087 } else if (rate[index] / arate == 1) {
1088 /* A little smaller than expect */ 1088 /* A little smaller than expect */
1089 sub = (rate[index] - arate) * 100000; 1089 sub = (u64)(rate[index] - arate) * 100000;
1090 do_div(sub, rate[index]); 1090 do_div(sub, rate[index]);
1091 if (sub >= savesub) 1091 if (sub >= savesub)
1092 continue; 1092 continue;
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index 6acb225ec6fd..2434b6d61675 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -11,6 +11,7 @@ config SND_PXA2XX_SOC
11config SND_MMP_SOC 11config SND_MMP_SOC
12 bool "Soc Audio for Marvell MMP chips" 12 bool "Soc Audio for Marvell MMP chips"
13 depends on ARCH_MMP 13 depends on ARCH_MMP
14 select MMP_SRAM
14 select SND_SOC_GENERIC_DMAENGINE_PCM 15 select SND_SOC_GENERIC_DMAENGINE_PCM
15 select SND_ARM 16 select SND_ARM
16 help 17 help
@@ -40,7 +41,7 @@ config SND_MMP_SOC_SSPA
40 41
41config SND_PXA2XX_SOC_CORGI 42config SND_PXA2XX_SOC_CORGI
42 tristate "SoC Audio support for Sharp Zaurus SL-C7x0" 43 tristate "SoC Audio support for Sharp Zaurus SL-C7x0"
43 depends on SND_PXA2XX_SOC && PXA_SHARP_C7xx 44 depends on SND_PXA2XX_SOC && PXA_SHARP_C7xx && I2C
44 select SND_PXA2XX_SOC_I2S 45 select SND_PXA2XX_SOC_I2S
45 select SND_SOC_WM8731 46 select SND_SOC_WM8731
46 help 47 help
@@ -49,7 +50,7 @@ config SND_PXA2XX_SOC_CORGI
49 50
50config SND_PXA2XX_SOC_SPITZ 51config SND_PXA2XX_SOC_SPITZ
51 tristate "SoC Audio support for Sharp Zaurus SL-Cxx00" 52 tristate "SoC Audio support for Sharp Zaurus SL-Cxx00"
52 depends on SND_PXA2XX_SOC && PXA_SHARP_Cxx00 53 depends on SND_PXA2XX_SOC && PXA_SHARP_Cxx00 && I2C
53 select SND_PXA2XX_SOC_I2S 54 select SND_PXA2XX_SOC_I2S
54 select SND_SOC_WM8750 55 select SND_SOC_WM8750
55 help 56 help
@@ -58,7 +59,7 @@ config SND_PXA2XX_SOC_SPITZ
58 59
59config SND_PXA2XX_SOC_Z2 60config SND_PXA2XX_SOC_Z2
60 tristate "SoC Audio support for Zipit Z2" 61 tristate "SoC Audio support for Zipit Z2"
61 depends on SND_PXA2XX_SOC && MACH_ZIPIT2 62 depends on SND_PXA2XX_SOC && MACH_ZIPIT2 && I2C
62 select SND_PXA2XX_SOC_I2S 63 select SND_PXA2XX_SOC_I2S
63 select SND_SOC_WM8750 64 select SND_SOC_WM8750
64 help 65 help
@@ -66,7 +67,7 @@ config SND_PXA2XX_SOC_Z2
66 67
67config SND_PXA2XX_SOC_POODLE 68config SND_PXA2XX_SOC_POODLE
68 tristate "SoC Audio support for Poodle" 69 tristate "SoC Audio support for Poodle"
69 depends on SND_PXA2XX_SOC && MACH_POODLE 70 depends on SND_PXA2XX_SOC && MACH_POODLE && I2C
70 select SND_PXA2XX_SOC_I2S 71 select SND_PXA2XX_SOC_I2S
71 select SND_SOC_WM8731 72 select SND_SOC_WM8731
72 help 73 help
@@ -181,7 +182,7 @@ config SND_PXA2XX_SOC_HX4700
181 182
182config SND_PXA2XX_SOC_MAGICIAN 183config SND_PXA2XX_SOC_MAGICIAN
183 tristate "SoC Audio support for HTC Magician" 184 tristate "SoC Audio support for HTC Magician"
184 depends on SND_PXA2XX_SOC && MACH_MAGICIAN 185 depends on SND_PXA2XX_SOC && MACH_MAGICIAN && I2C
185 select SND_PXA2XX_SOC_I2S 186 select SND_PXA2XX_SOC_I2S
186 select SND_PXA_SOC_SSP 187 select SND_PXA_SOC_SSP
187 select SND_SOC_UDA1380 188 select SND_SOC_UDA1380
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 91880156e1ae..4e86265f625c 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -315,7 +315,7 @@ static void rsnd_dma_of_name(struct rsnd_dma *dma,
315 dst_mod = mod[index]; 315 dst_mod = mod[index];
316 } else { 316 } else {
317 src_mod = mod[index]; 317 src_mod = mod[index];
318 dst_mod = mod[index + 1]; 318 dst_mod = mod[index - 1];
319 } 319 }
320 320
321 index = 0; 321 index = 0;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a74b9bf23d9f..cdc837ed144d 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2755,7 +2755,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
2755 unsigned int mask = (1 << fls(max)) - 1; 2755 unsigned int mask = (1 << fls(max)) - 1;
2756 unsigned int invert = mc->invert; 2756 unsigned int invert = mc->invert;
2757 unsigned int val; 2757 unsigned int val;
2758 int connect, change; 2758 int connect, change, reg_change = 0;
2759 struct snd_soc_dapm_update update; 2759 struct snd_soc_dapm_update update;
2760 int ret = 0; 2760 int ret = 0;
2761 2761
@@ -2773,20 +2773,23 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
2773 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); 2773 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
2774 2774
2775 change = dapm_kcontrol_set_value(kcontrol, val); 2775 change = dapm_kcontrol_set_value(kcontrol, val);
2776 if (change) {
2777 if (reg != SND_SOC_NOPM) {
2778 mask = mask << shift;
2779 val = val << shift;
2780
2781 if (snd_soc_test_bits(codec, reg, mask, val)) {
2782 update.kcontrol = kcontrol;
2783 update.reg = reg;
2784 update.mask = mask;
2785 update.val = val;
2786 card->update = &update;
2787 }
2788 2776
2777 if (reg != SND_SOC_NOPM) {
2778 mask = mask << shift;
2779 val = val << shift;
2780
2781 reg_change = snd_soc_test_bits(codec, reg, mask, val);
2782 }
2783
2784 if (change || reg_change) {
2785 if (reg_change) {
2786 update.kcontrol = kcontrol;
2787 update.reg = reg;
2788 update.mask = mask;
2789 update.val = val;
2790 card->update = &update;
2789 } 2791 }
2792 change |= reg_change;
2790 2793
2791 ret = soc_dapm_mixer_update_power(card, kcontrol, connect); 2794 ret = soc_dapm_mixer_update_power(card, kcontrol, connect);
2792 2795
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index b83184f2d484..93825a17dcce 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -765,6 +765,9 @@ static void free_arg(struct print_arg *arg)
765 case PRINT_BSTRING: 765 case PRINT_BSTRING:
766 free(arg->string.string); 766 free(arg->string.string);
767 break; 767 break;
768 case PRINT_BITMASK:
769 free(arg->bitmask.bitmask);
770 break;
768 case PRINT_DYNAMIC_ARRAY: 771 case PRINT_DYNAMIC_ARRAY:
769 free(arg->dynarray.index); 772 free(arg->dynarray.index);
770 break; 773 break;
@@ -2268,6 +2271,7 @@ static int arg_num_eval(struct print_arg *arg, long long *val)
2268 case PRINT_FIELD ... PRINT_SYMBOL: 2271 case PRINT_FIELD ... PRINT_SYMBOL:
2269 case PRINT_STRING: 2272 case PRINT_STRING:
2270 case PRINT_BSTRING: 2273 case PRINT_BSTRING:
2274 case PRINT_BITMASK:
2271 default: 2275 default:
2272 do_warning("invalid eval type %d", arg->type); 2276 do_warning("invalid eval type %d", arg->type);
2273 ret = 0; 2277 ret = 0;
@@ -2296,6 +2300,7 @@ static char *arg_eval (struct print_arg *arg)
2296 case PRINT_FIELD ... PRINT_SYMBOL: 2300 case PRINT_FIELD ... PRINT_SYMBOL:
2297 case PRINT_STRING: 2301 case PRINT_STRING:
2298 case PRINT_BSTRING: 2302 case PRINT_BSTRING:
2303 case PRINT_BITMASK:
2299 default: 2304 default:
2300 do_warning("invalid eval type %d", arg->type); 2305 do_warning("invalid eval type %d", arg->type);
2301 break; 2306 break;
@@ -2683,6 +2688,35 @@ process_str(struct event_format *event __maybe_unused, struct print_arg *arg,
2683 return EVENT_ERROR; 2688 return EVENT_ERROR;
2684} 2689}
2685 2690
2691static enum event_type
2692process_bitmask(struct event_format *event __maybe_unused, struct print_arg *arg,
2693 char **tok)
2694{
2695 enum event_type type;
2696 char *token;
2697
2698 if (read_expect_type(EVENT_ITEM, &token) < 0)
2699 goto out_free;
2700
2701 arg->type = PRINT_BITMASK;
2702 arg->bitmask.bitmask = token;
2703 arg->bitmask.offset = -1;
2704
2705 if (read_expected(EVENT_DELIM, ")") < 0)
2706 goto out_err;
2707
2708 type = read_token(&token);
2709 *tok = token;
2710
2711 return type;
2712
2713 out_free:
2714 free_token(token);
2715 out_err:
2716 *tok = NULL;
2717 return EVENT_ERROR;
2718}
2719
2686static struct pevent_function_handler * 2720static struct pevent_function_handler *
2687find_func_handler(struct pevent *pevent, char *func_name) 2721find_func_handler(struct pevent *pevent, char *func_name)
2688{ 2722{
@@ -2797,6 +2831,10 @@ process_function(struct event_format *event, struct print_arg *arg,
2797 free_token(token); 2831 free_token(token);
2798 return process_str(event, arg, tok); 2832 return process_str(event, arg, tok);
2799 } 2833 }
2834 if (strcmp(token, "__get_bitmask") == 0) {
2835 free_token(token);
2836 return process_bitmask(event, arg, tok);
2837 }
2800 if (strcmp(token, "__get_dynamic_array") == 0) { 2838 if (strcmp(token, "__get_dynamic_array") == 0) {
2801 free_token(token); 2839 free_token(token);
2802 return process_dynamic_array(event, arg, tok); 2840 return process_dynamic_array(event, arg, tok);
@@ -3324,6 +3362,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
3324 return eval_type(val, arg, 0); 3362 return eval_type(val, arg, 0);
3325 case PRINT_STRING: 3363 case PRINT_STRING:
3326 case PRINT_BSTRING: 3364 case PRINT_BSTRING:
3365 case PRINT_BITMASK:
3327 return 0; 3366 return 0;
3328 case PRINT_FUNC: { 3367 case PRINT_FUNC: {
3329 struct trace_seq s; 3368 struct trace_seq s;
@@ -3556,6 +3595,60 @@ static void print_str_to_seq(struct trace_seq *s, const char *format,
3556 trace_seq_printf(s, format, str); 3595 trace_seq_printf(s, format, str);
3557} 3596}
3558 3597
3598static void print_bitmask_to_seq(struct pevent *pevent,
3599 struct trace_seq *s, const char *format,
3600 int len_arg, const void *data, int size)
3601{
3602 int nr_bits = size * 8;
3603 int str_size = (nr_bits + 3) / 4;
3604 int len = 0;
3605 char buf[3];
3606 char *str;
3607 int index;
3608 int i;
3609
3610 /*
3611 * The kernel likes to put in commas every 32 bits, we
3612 * can do the same.
3613 */
3614 str_size += (nr_bits - 1) / 32;
3615
3616 str = malloc(str_size + 1);
3617 if (!str) {
3618 do_warning("%s: not enough memory!", __func__);
3619 return;
3620 }
3621 str[str_size] = 0;
3622
3623 /* Start out with -2 for the two chars per byte */
3624 for (i = str_size - 2; i >= 0; i -= 2) {
3625 /*
3626 * data points to a bit mask of size bytes.
3627 * In the kernel, this is an array of long words, thus
3628 * endianess is very important.
3629 */
3630 if (pevent->file_bigendian)
3631 index = size - (len + 1);
3632 else
3633 index = len;
3634
3635 snprintf(buf, 3, "%02x", *((unsigned char *)data + index));
3636 memcpy(str + i, buf, 2);
3637 len++;
3638 if (!(len & 3) && i > 0) {
3639 i--;
3640 str[i] = ',';
3641 }
3642 }
3643
3644 if (len_arg >= 0)
3645 trace_seq_printf(s, format, len_arg, str);
3646 else
3647 trace_seq_printf(s, format, str);
3648
3649 free(str);
3650}
3651
3559static void print_str_arg(struct trace_seq *s, void *data, int size, 3652static void print_str_arg(struct trace_seq *s, void *data, int size,
3560 struct event_format *event, const char *format, 3653 struct event_format *event, const char *format,
3561 int len_arg, struct print_arg *arg) 3654 int len_arg, struct print_arg *arg)
@@ -3691,6 +3784,23 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
3691 case PRINT_BSTRING: 3784 case PRINT_BSTRING:
3692 print_str_to_seq(s, format, len_arg, arg->string.string); 3785 print_str_to_seq(s, format, len_arg, arg->string.string);
3693 break; 3786 break;
3787 case PRINT_BITMASK: {
3788 int bitmask_offset;
3789 int bitmask_size;
3790
3791 if (arg->bitmask.offset == -1) {
3792 struct format_field *f;
3793
3794 f = pevent_find_any_field(event, arg->bitmask.bitmask);
3795 arg->bitmask.offset = f->offset;
3796 }
3797 bitmask_offset = data2host4(pevent, data + arg->bitmask.offset);
3798 bitmask_size = bitmask_offset >> 16;
3799 bitmask_offset &= 0xffff;
3800 print_bitmask_to_seq(pevent, s, format, len_arg,
3801 data + bitmask_offset, bitmask_size);
3802 break;
3803 }
3694 case PRINT_OP: 3804 case PRINT_OP:
3695 /* 3805 /*
3696 * The only op for string should be ? : 3806 * The only op for string should be ? :
@@ -4822,6 +4932,9 @@ static void print_args(struct print_arg *args)
4822 case PRINT_BSTRING: 4932 case PRINT_BSTRING:
4823 printf("__get_str(%s)", args->string.string); 4933 printf("__get_str(%s)", args->string.string);
4824 break; 4934 break;
4935 case PRINT_BITMASK:
4936 printf("__get_bitmask(%s)", args->bitmask.bitmask);
4937 break;
4825 case PRINT_TYPE: 4938 case PRINT_TYPE:
4826 printf("(%s)", args->typecast.type); 4939 printf("(%s)", args->typecast.type);
4827 print_args(args->typecast.item); 4940 print_args(args->typecast.item);
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index feab94281634..7a3873ff9a4f 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -107,8 +107,8 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s,
107typedef int (*pevent_plugin_load_func)(struct pevent *pevent); 107typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
108typedef int (*pevent_plugin_unload_func)(struct pevent *pevent); 108typedef int (*pevent_plugin_unload_func)(struct pevent *pevent);
109 109
110struct plugin_option { 110struct pevent_plugin_option {
111 struct plugin_option *next; 111 struct pevent_plugin_option *next;
112 void *handle; 112 void *handle;
113 char *file; 113 char *file;
114 char *name; 114 char *name;
@@ -135,7 +135,7 @@ struct plugin_option {
135 * PEVENT_PLUGIN_OPTIONS: (optional) 135 * PEVENT_PLUGIN_OPTIONS: (optional)
136 * Plugin options that can be set before loading 136 * Plugin options that can be set before loading
137 * 137 *
138 * struct plugin_option PEVENT_PLUGIN_OPTIONS[] = { 138 * struct pevent_plugin_option PEVENT_PLUGIN_OPTIONS[] = {
139 * { 139 * {
140 * .name = "option-name", 140 * .name = "option-name",
141 * .plugin_alias = "overide-file-name", (optional) 141 * .plugin_alias = "overide-file-name", (optional)
@@ -208,6 +208,11 @@ struct print_arg_string {
208 int offset; 208 int offset;
209}; 209};
210 210
211struct print_arg_bitmask {
212 char *bitmask;
213 int offset;
214};
215
211struct print_arg_field { 216struct print_arg_field {
212 char *name; 217 char *name;
213 struct format_field *field; 218 struct format_field *field;
@@ -274,6 +279,7 @@ enum print_arg_type {
274 PRINT_DYNAMIC_ARRAY, 279 PRINT_DYNAMIC_ARRAY,
275 PRINT_OP, 280 PRINT_OP,
276 PRINT_FUNC, 281 PRINT_FUNC,
282 PRINT_BITMASK,
277}; 283};
278 284
279struct print_arg { 285struct print_arg {
@@ -288,6 +294,7 @@ struct print_arg {
288 struct print_arg_hex hex; 294 struct print_arg_hex hex;
289 struct print_arg_func func; 295 struct print_arg_func func;
290 struct print_arg_string string; 296 struct print_arg_string string;
297 struct print_arg_bitmask bitmask;
291 struct print_arg_op op; 298 struct print_arg_op op;
292 struct print_arg_dynarray dynarray; 299 struct print_arg_dynarray dynarray;
293 }; 300 };
@@ -354,6 +361,8 @@ enum pevent_func_arg_type {
354 361
355enum pevent_flag { 362enum pevent_flag {
356 PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */ 363 PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */
364 PEVENT_DISABLE_SYS_PLUGINS = 1 << 1,
365 PEVENT_DISABLE_PLUGINS = 1 << 2,
357}; 366};
358 367
359#define PEVENT_ERRORS \ 368#define PEVENT_ERRORS \
@@ -410,9 +419,19 @@ enum pevent_errno {
410 419
411struct plugin_list; 420struct plugin_list;
412 421
422#define INVALID_PLUGIN_LIST_OPTION ((char **)((unsigned long)-1))
423
413struct plugin_list *traceevent_load_plugins(struct pevent *pevent); 424struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
414void traceevent_unload_plugins(struct plugin_list *plugin_list, 425void traceevent_unload_plugins(struct plugin_list *plugin_list,
415 struct pevent *pevent); 426 struct pevent *pevent);
427char **traceevent_plugin_list_options(void);
428void traceevent_plugin_free_options_list(char **list);
429int traceevent_plugin_add_options(const char *name,
430 struct pevent_plugin_option *options);
431void traceevent_plugin_remove_options(struct pevent_plugin_option *options);
432void traceevent_print_plugins(struct trace_seq *s,
433 const char *prefix, const char *suffix,
434 const struct plugin_list *list);
416 435
417struct cmdline; 436struct cmdline;
418struct cmdline_list; 437struct cmdline_list;
diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c
index 0c8bf6780e4d..136162c03af1 100644
--- a/tools/lib/traceevent/event-plugin.c
+++ b/tools/lib/traceevent/event-plugin.c
@@ -18,6 +18,7 @@
18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 */ 19 */
20 20
21#include <stdio.h>
21#include <string.h> 22#include <string.h>
22#include <dlfcn.h> 23#include <dlfcn.h>
23#include <stdlib.h> 24#include <stdlib.h>
@@ -30,12 +31,207 @@
30 31
31#define LOCAL_PLUGIN_DIR ".traceevent/plugins" 32#define LOCAL_PLUGIN_DIR ".traceevent/plugins"
32 33
34static struct registered_plugin_options {
35 struct registered_plugin_options *next;
36 struct pevent_plugin_option *options;
37} *registered_options;
38
39static struct trace_plugin_options {
40 struct trace_plugin_options *next;
41 char *plugin;
42 char *option;
43 char *value;
44} *trace_plugin_options;
45
33struct plugin_list { 46struct plugin_list {
34 struct plugin_list *next; 47 struct plugin_list *next;
35 char *name; 48 char *name;
36 void *handle; 49 void *handle;
37}; 50};
38 51
52/**
53 * traceevent_plugin_list_options - get list of plugin options
54 *
55 * Returns an array of char strings that list the currently registered
56 * plugin options in the format of <plugin>:<option>. This list can be
57 * used by toggling the option.
58 *
59 * Returns NULL if there's no options registered. On error it returns
60 * INVALID_PLUGIN_LIST_OPTION
61 *
62 * Must be freed with traceevent_plugin_free_options_list().
63 */
64char **traceevent_plugin_list_options(void)
65{
66 struct registered_plugin_options *reg;
67 struct pevent_plugin_option *op;
68 char **list = NULL;
69 char *name;
70 int count = 0;
71
72 for (reg = registered_options; reg; reg = reg->next) {
73 for (op = reg->options; op->name; op++) {
74 char *alias = op->plugin_alias ? op->plugin_alias : op->file;
75 char **temp = list;
76
77 name = malloc(strlen(op->name) + strlen(alias) + 2);
78 if (!name)
79 goto err;
80
81 sprintf(name, "%s:%s", alias, op->name);
82 list = realloc(list, count + 2);
83 if (!list) {
84 list = temp;
85 free(name);
86 goto err;
87 }
88 list[count++] = name;
89 list[count] = NULL;
90 }
91 }
92 return list;
93
94 err:
95 while (--count >= 0)
96 free(list[count]);
97 free(list);
98
99 return INVALID_PLUGIN_LIST_OPTION;
100}
101
102void traceevent_plugin_free_options_list(char **list)
103{
104 int i;
105
106 if (!list)
107 return;
108
109 if (list == INVALID_PLUGIN_LIST_OPTION)
110 return;
111
112 for (i = 0; list[i]; i++)
113 free(list[i]);
114
115 free(list);
116}
117
118static int
119update_option(const char *file, struct pevent_plugin_option *option)
120{
121 struct trace_plugin_options *op;
122 char *plugin;
123
124 if (option->plugin_alias) {
125 plugin = strdup(option->plugin_alias);
126 if (!plugin)
127 return -1;
128 } else {
129 char *p;
130 plugin = strdup(file);
131 if (!plugin)
132 return -1;
133 p = strstr(plugin, ".");
134 if (p)
135 *p = '\0';
136 }
137
138 /* first look for named options */
139 for (op = trace_plugin_options; op; op = op->next) {
140 if (!op->plugin)
141 continue;
142 if (strcmp(op->plugin, plugin) != 0)
143 continue;
144 if (strcmp(op->option, option->name) != 0)
145 continue;
146
147 option->value = op->value;
148 option->set ^= 1;
149 goto out;
150 }
151
152 /* first look for unnamed options */
153 for (op = trace_plugin_options; op; op = op->next) {
154 if (op->plugin)
155 continue;
156 if (strcmp(op->option, option->name) != 0)
157 continue;
158
159 option->value = op->value;
160 option->set ^= 1;
161 break;
162 }
163
164 out:
165 free(plugin);
166 return 0;
167}
168
169/**
170 * traceevent_plugin_add_options - Add a set of options by a plugin
171 * @name: The name of the plugin adding the options
172 * @options: The set of options being loaded
173 *
174 * Sets the options with the values that have been added by user.
175 */
176int traceevent_plugin_add_options(const char *name,
177 struct pevent_plugin_option *options)
178{
179 struct registered_plugin_options *reg;
180
181 reg = malloc(sizeof(*reg));
182 if (!reg)
183 return -1;
184 reg->next = registered_options;
185 reg->options = options;
186 registered_options = reg;
187
188 while (options->name) {
189 update_option(name, options);
190 options++;
191 }
192 return 0;
193}
194
195/**
196 * traceevent_plugin_remove_options - remove plugin options that were registered
197 * @options: Options to removed that were registered with traceevent_plugin_add_options
198 */
199void traceevent_plugin_remove_options(struct pevent_plugin_option *options)
200{
201 struct registered_plugin_options **last;
202 struct registered_plugin_options *reg;
203
204 for (last = &registered_options; *last; last = &(*last)->next) {
205 if ((*last)->options == options) {
206 reg = *last;
207 *last = reg->next;
208 free(reg);
209 return;
210 }
211 }
212}
213
214/**
215 * traceevent_print_plugins - print out the list of plugins loaded
216 * @s: the trace_seq descripter to write to
217 * @prefix: The prefix string to add before listing the option name
218 * @suffix: The suffix string ot append after the option name
219 * @list: The list of plugins (usually returned by traceevent_load_plugins()
220 *
221 * Writes to the trace_seq @s the list of plugins (files) that is
222 * returned by traceevent_load_plugins(). Use @prefix and @suffix for formating:
223 * @prefix = " ", @suffix = "\n".
224 */
225void traceevent_print_plugins(struct trace_seq *s,
226 const char *prefix, const char *suffix,
227 const struct plugin_list *list)
228{
229 while (list) {
230 trace_seq_printf(s, "%s%s%s", prefix, list->name, suffix);
231 list = list->next;
232 }
233}
234
39static void 235static void
40load_plugin(struct pevent *pevent, const char *path, 236load_plugin(struct pevent *pevent, const char *path,
41 const char *file, void *data) 237 const char *file, void *data)
@@ -148,12 +344,17 @@ load_plugins(struct pevent *pevent, const char *suffix,
148 char *path; 344 char *path;
149 char *envdir; 345 char *envdir;
150 346
347 if (pevent->flags & PEVENT_DISABLE_PLUGINS)
348 return;
349
151 /* 350 /*
152 * If a system plugin directory was defined, 351 * If a system plugin directory was defined,
153 * check that first. 352 * check that first.
154 */ 353 */
155#ifdef PLUGIN_DIR 354#ifdef PLUGIN_DIR
156 load_plugins_dir(pevent, suffix, PLUGIN_DIR, load_plugin, data); 355 if (!(pevent->flags & PEVENT_DISABLE_SYS_PLUGINS))
356 load_plugins_dir(pevent, suffix, PLUGIN_DIR,
357 load_plugin, data);
157#endif 358#endif
158 359
159 /* 360 /*
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index 80ba4ff1fe84..a00ec190821a 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -33,6 +33,29 @@ static int cpus = -1;
33 33
34#define STK_BLK 10 34#define STK_BLK 10
35 35
36struct pevent_plugin_option plugin_options[] =
37{
38 {
39 .name = "parent",
40 .plugin_alias = "ftrace",
41 .description =
42 "Print parent of functions for function events",
43 },
44 {
45 .name = "indent",
46 .plugin_alias = "ftrace",
47 .description =
48 "Try to show function call indents, based on parents",
49 .set = 1,
50 },
51 {
52 .name = NULL,
53 }
54};
55
56static struct pevent_plugin_option *ftrace_parent = &plugin_options[0];
57static struct pevent_plugin_option *ftrace_indent = &plugin_options[1];
58
36static void add_child(struct func_stack *stack, const char *child, int pos) 59static void add_child(struct func_stack *stack, const char *child, int pos)
37{ 60{
38 int i; 61 int i;
@@ -119,7 +142,8 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record,
119 142
120 parent = pevent_find_function(pevent, pfunction); 143 parent = pevent_find_function(pevent, pfunction);
121 144
122 index = add_and_get_index(parent, func, record->cpu); 145 if (parent && ftrace_indent->set)
146 index = add_and_get_index(parent, func, record->cpu);
123 147
124 trace_seq_printf(s, "%*s", index*3, ""); 148 trace_seq_printf(s, "%*s", index*3, "");
125 149
@@ -128,11 +152,13 @@ static int function_handler(struct trace_seq *s, struct pevent_record *record,
128 else 152 else
129 trace_seq_printf(s, "0x%llx", function); 153 trace_seq_printf(s, "0x%llx", function);
130 154
131 trace_seq_printf(s, " <-- "); 155 if (ftrace_parent->set) {
132 if (parent) 156 trace_seq_printf(s, " <-- ");
133 trace_seq_printf(s, "%s", parent); 157 if (parent)
134 else 158 trace_seq_printf(s, "%s", parent);
135 trace_seq_printf(s, "0x%llx", pfunction); 159 else
160 trace_seq_printf(s, "0x%llx", pfunction);
161 }
136 162
137 return 0; 163 return 0;
138} 164}
@@ -141,6 +167,9 @@ int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
141{ 167{
142 pevent_register_event_handler(pevent, -1, "ftrace", "function", 168 pevent_register_event_handler(pevent, -1, "ftrace", "function",
143 function_handler, NULL); 169 function_handler, NULL);
170
171 traceevent_plugin_add_options("ftrace", plugin_options);
172
144 return 0; 173 return 0;
145} 174}
146 175
@@ -157,6 +186,8 @@ void PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
157 free(fstack[i].stack); 186 free(fstack[i].stack);
158 } 187 }
159 188
189 traceevent_plugin_remove_options(plugin_options);
190
160 free(fstack); 191 free(fstack);
161 fstack = NULL; 192 fstack = NULL;
162 cpus = -1; 193 cpus = -1;
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index cefdf430d1b4..d2b59af62bc0 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -117,6 +117,22 @@ OPTIONS
117 By default, every sort keys not specified in -F will be appended 117 By default, every sort keys not specified in -F will be appended
118 automatically. 118 automatically.
119 119
120 If --mem-mode option is used, following sort keys are also available
121 (incompatible with --branch-stack):
122 symbol_daddr, dso_daddr, locked, tlb, mem, snoop, dcacheline.
123
124 - symbol_daddr: name of data symbol being executed on at the time of sample
125 - dso_daddr: name of library or module containing the data being executed
126 on at the time of sample
127 - locked: whether the bus was locked at the time of sample
128 - tlb: type of tlb access for the data at the time of sample
129 - mem: type of memory access for the data at the time of sample
130 - snoop: type of snoop (if any) for the data at the time of sample
131 - dcacheline: the cacheline the data address is on at the time of sample
132
133 And default sort keys are changed to local_weight, mem, sym, dso,
134 symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
135
120-p:: 136-p::
121--parent=<regex>:: 137--parent=<regex>::
122 A regex filter to identify parent. The parent is a caller of this 138 A regex filter to identify parent. The parent is a caller of this
@@ -260,6 +276,13 @@ OPTIONS
260 Demangle symbol names to human readable form. It's enabled by default, 276 Demangle symbol names to human readable form. It's enabled by default,
261 disable with --no-demangle. 277 disable with --no-demangle.
262 278
279--mem-mode::
280 Use the data addresses of samples in addition to instruction addresses
281 to build the histograms. To generate meaningful output, the perf.data
282 file must have been obtained using perf record -d -W and using a
283 special event -e cpu/mem-loads/ or -e cpu/mem-stores/. See
284 'perf mem' for simpler access.
285
263--percent-limit:: 286--percent-limit::
264 Do not show entries which have an overhead under that percent. 287 Do not show entries which have an overhead under that percent.
265 (Default: 0). 288 (Default: 0).
diff --git a/tools/perf/Documentation/perf-timechart.txt b/tools/perf/Documentation/perf-timechart.txt
index bc5990c33dc0..5e0f986dff38 100644
--- a/tools/perf/Documentation/perf-timechart.txt
+++ b/tools/perf/Documentation/perf-timechart.txt
@@ -43,27 +43,6 @@ TIMECHART OPTIONS
43 43
44--symfs=<directory>:: 44--symfs=<directory>::
45 Look for files with symbols relative to this directory. 45 Look for files with symbols relative to this directory.
46
47EXAMPLES
48--------
49
50$ perf timechart record git pull
51
52 [ perf record: Woken up 13 times to write data ]
53 [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ]
54
55$ perf timechart
56
57 Written 10.2 seconds of trace to output.svg.
58
59Record system-wide timechart:
60
61 $ perf timechart record
62
63 then generate timechart and highlight 'gcc' tasks:
64
65 $ perf timechart --highlight gcc
66
67-n:: 46-n::
68--proc-num:: 47--proc-num::
69 Print task info for at least given number of tasks. 48 Print task info for at least given number of tasks.
@@ -88,6 +67,26 @@ RECORD OPTIONS
88--callchain:: 67--callchain::
89 Do call-graph (stack chain/backtrace) recording 68 Do call-graph (stack chain/backtrace) recording
90 69
70EXAMPLES
71--------
72
73$ perf timechart record git pull
74
75 [ perf record: Woken up 13 times to write data ]
76 [ perf record: Captured and wrote 4.253 MB perf.data (~185801 samples) ]
77
78$ perf timechart
79
80 Written 10.2 seconds of trace to output.svg.
81
82Record system-wide timechart:
83
84 $ perf timechart record
85
86 then generate timechart and highlight 'gcc' tasks:
87
88 $ perf timechart --highlight gcc
89
91SEE ALSO 90SEE ALSO
92-------- 91--------
93linkperf:perf-record[1] 92linkperf:perf-record[1]
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ae20edfcc3f7..9670a16fa577 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -819,15 +819,15 @@ TAG_FOLDERS= . ../lib/traceevent ../lib/api ../lib/symbol
819TAG_FILES= ../../include/uapi/linux/perf_event.h 819TAG_FILES= ../../include/uapi/linux/perf_event.h
820 820
821TAGS: 821TAGS:
822 $(RM) TAGS 822 $(QUIET_GEN)$(RM) TAGS; \
823 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs etags -a $(TAG_FILES) 823 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs etags -a $(TAG_FILES)
824 824
825tags: 825tags:
826 $(RM) tags 826 $(QUIET_GEN)$(RM) tags; \
827 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs ctags -a $(TAG_FILES) 827 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs ctags -a $(TAG_FILES)
828 828
829cscope: 829cscope:
830 $(RM) cscope* 830 $(QUIET_GEN)$(RM) cscope*; \
831 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs cscope -b $(TAG_FILES) 831 $(FIND) $(TAG_FOLDERS) -name '*.[hcS]' -print | xargs cscope -b $(TAG_FILES)
832 832
833### Detect prefix changes 833### Detect prefix changes
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 6a3af0013d68..16c7c11ad06e 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -72,7 +72,7 @@ static int perf_event__repipe_attr(struct perf_tool *tool,
72 if (ret) 72 if (ret)
73 return ret; 73 return ret;
74 74
75 if (&inject->output.is_pipe) 75 if (!inject->output.is_pipe)
76 return 0; 76 return 0;
77 77
78 return perf_event__repipe_synth(tool, event); 78 return perf_event__repipe_synth(tool, event);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index cdcd4eb3a57d..c63fa2925075 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -288,6 +288,13 @@ static void cleanup_params(void)
288 memset(&params, 0, sizeof(params)); 288 memset(&params, 0, sizeof(params));
289} 289}
290 290
291static void pr_err_with_code(const char *msg, int err)
292{
293 pr_err("%s", msg);
294 pr_debug(" Reason: %s (Code: %d)", strerror(-err), err);
295 pr_err("\n");
296}
297
291static int 298static int
292__cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused) 299__cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
293{ 300{
@@ -379,7 +386,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
379 } 386 }
380 ret = parse_probe_event_argv(argc, argv); 387 ret = parse_probe_event_argv(argc, argv);
381 if (ret < 0) { 388 if (ret < 0) {
382 pr_err(" Error: Parse Error. (%d)\n", ret); 389 pr_err_with_code(" Error: Command Parse Error.", ret);
383 return ret; 390 return ret;
384 } 391 }
385 } 392 }
@@ -419,8 +426,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
419 } 426 }
420 ret = show_perf_probe_events(); 427 ret = show_perf_probe_events();
421 if (ret < 0) 428 if (ret < 0)
422 pr_err(" Error: Failed to show event list. (%d)\n", 429 pr_err_with_code(" Error: Failed to show event list.", ret);
423 ret);
424 return ret; 430 return ret;
425 } 431 }
426 if (params.show_funcs) { 432 if (params.show_funcs) {
@@ -445,8 +451,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
445 strfilter__delete(params.filter); 451 strfilter__delete(params.filter);
446 params.filter = NULL; 452 params.filter = NULL;
447 if (ret < 0) 453 if (ret < 0)
448 pr_err(" Error: Failed to show functions." 454 pr_err_with_code(" Error: Failed to show functions.", ret);
449 " (%d)\n", ret);
450 return ret; 455 return ret;
451 } 456 }
452 457
@@ -464,7 +469,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
464 469
465 ret = show_line_range(&params.line_range, params.target); 470 ret = show_line_range(&params.line_range, params.target);
466 if (ret < 0) 471 if (ret < 0)
467 pr_err(" Error: Failed to show lines. (%d)\n", ret); 472 pr_err_with_code(" Error: Failed to show lines.", ret);
468 return ret; 473 return ret;
469 } 474 }
470 if (params.show_vars) { 475 if (params.show_vars) {
@@ -485,7 +490,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
485 strfilter__delete(params.filter); 490 strfilter__delete(params.filter);
486 params.filter = NULL; 491 params.filter = NULL;
487 if (ret < 0) 492 if (ret < 0)
488 pr_err(" Error: Failed to show vars. (%d)\n", ret); 493 pr_err_with_code(" Error: Failed to show vars.", ret);
489 return ret; 494 return ret;
490 } 495 }
491#endif 496#endif
@@ -493,7 +498,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
493 if (params.dellist) { 498 if (params.dellist) {
494 ret = del_perf_probe_events(params.dellist); 499 ret = del_perf_probe_events(params.dellist);
495 if (ret < 0) { 500 if (ret < 0) {
496 pr_err(" Error: Failed to delete events. (%d)\n", ret); 501 pr_err_with_code(" Error: Failed to delete events.", ret);
497 return ret; 502 return ret;
498 } 503 }
499 } 504 }
@@ -504,7 +509,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
504 params.target, 509 params.target,
505 params.force_add); 510 params.force_add);
506 if (ret < 0) { 511 if (ret < 0) {
507 pr_err(" Error: Failed to add events. (%d)\n", ret); 512 pr_err_with_code(" Error: Failed to add events.", ret);
508 return ret; 513 return ret;
509 } 514 }
510 } 515 }
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 4f100b54ba8b..f30ac5e5d271 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -299,7 +299,11 @@ else
299 NO_LIBUNWIND := 1 299 NO_LIBUNWIND := 1
300 NO_LIBDW_DWARF_UNWIND := 1 300 NO_LIBDW_DWARF_UNWIND := 1
301 else 301 else
302 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); 302 ifneq ($(filter s% -static%,$(LDFLAGS),),)
303 msg := $(error No static glibc found, please install glibc-static);
304 else
305 msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
306 endif
303 endif 307 endif
304 else 308 else
305 ifndef NO_LIBDW_DWARF_UNWIND 309 ifndef NO_LIBDW_DWARF_UNWIND
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 78f7b920e548..95c58fc15284 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -458,6 +458,7 @@ int main(int argc, const char **argv)
458 458
459 /* The page_size is placed in util object. */ 459 /* The page_size is placed in util object. */
460 page_size = sysconf(_SC_PAGE_SIZE); 460 page_size = sysconf(_SC_PAGE_SIZE);
461 cacheline_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
461 462
462 cmd = perf_extract_argv0_path(argv[0]); 463 cmd = perf_extract_argv0_path(argv[0]);
463 if (!cmd) 464 if (!cmd)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 802e3cd50f6f..6f8b01bc6033 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Builtin regression testing command: ever growing number of sanity tests 4 * Builtin regression testing command: ever growing number of sanity tests
5 */ 5 */
6#include <unistd.h>
7#include <string.h>
6#include "builtin.h" 8#include "builtin.h"
7#include "intlist.h" 9#include "intlist.h"
8#include "tests.h" 10#include "tests.h"
@@ -50,10 +52,18 @@ static struct test {
50 .func = test__pmu, 52 .func = test__pmu,
51 }, 53 },
52 { 54 {
53 .desc = "Test dso data interface", 55 .desc = "Test dso data read",
54 .func = test__dso_data, 56 .func = test__dso_data,
55 }, 57 },
56 { 58 {
59 .desc = "Test dso data cache",
60 .func = test__dso_data_cache,
61 },
62 {
63 .desc = "Test dso data reopen",
64 .func = test__dso_data_reopen,
65 },
66 {
57 .desc = "roundtrip evsel->name check", 67 .desc = "roundtrip evsel->name check",
58 .func = test__perf_evsel__roundtrip_name_test, 68 .func = test__perf_evsel__roundtrip_name_test,
59 }, 69 },
@@ -172,6 +182,34 @@ static bool perf_test__matches(int curr, int argc, const char *argv[])
172 return false; 182 return false;
173} 183}
174 184
185static int run_test(struct test *test)
186{
187 int status, err = -1, child = fork();
188
189 if (child < 0) {
190 pr_err("failed to fork test: %s\n", strerror(errno));
191 return -1;
192 }
193
194 if (!child) {
195 pr_debug("test child forked, pid %d\n", getpid());
196 err = test->func();
197 exit(err);
198 }
199
200 wait(&status);
201
202 if (WIFEXITED(status)) {
203 err = WEXITSTATUS(status);
204 pr_debug("test child finished with %d\n", err);
205 } else if (WIFSIGNALED(status)) {
206 err = -1;
207 pr_debug("test child interrupted\n");
208 }
209
210 return err;
211}
212
175static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) 213static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
176{ 214{
177 int i = 0; 215 int i = 0;
@@ -200,7 +238,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
200 } 238 }
201 239
202 pr_debug("\n--- start ---\n"); 240 pr_debug("\n--- start ---\n");
203 err = tests[curr].func(); 241 err = run_test(&tests[curr]);
204 pr_debug("---- end ----\n%s:", tests[curr].desc); 242 pr_debug("---- end ----\n%s:", tests[curr].desc);
205 243
206 switch (err) { 244 switch (err) {
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 3e6cb171e3d3..630808cd7cc2 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -1,22 +1,27 @@
1#include "util.h"
2
3#include <stdlib.h> 1#include <stdlib.h>
4#include <linux/types.h> 2#include <linux/types.h>
5#include <sys/stat.h> 3#include <sys/stat.h>
6#include <fcntl.h> 4#include <fcntl.h>
7#include <string.h> 5#include <string.h>
8 6#include <sys/time.h>
7#include <sys/resource.h>
8#include <api/fs/fs.h>
9#include "util.h"
9#include "machine.h" 10#include "machine.h"
10#include "symbol.h" 11#include "symbol.h"
11#include "tests.h" 12#include "tests.h"
12 13
13static char *test_file(int size) 14static char *test_file(int size)
14{ 15{
15 static char buf_templ[] = "/tmp/test-XXXXXX"; 16#define TEMPL "/tmp/perf-test-XXXXXX"
17 static char buf_templ[sizeof(TEMPL)];
16 char *templ = buf_templ; 18 char *templ = buf_templ;
17 int fd, i; 19 int fd, i;
18 unsigned char *buf; 20 unsigned char *buf;
19 21
22 strcpy(buf_templ, TEMPL);
23#undef TEMPL
24
20 fd = mkstemp(templ); 25 fd = mkstemp(templ);
21 if (fd < 0) { 26 if (fd < 0) {
22 perror("mkstemp failed"); 27 perror("mkstemp failed");
@@ -150,3 +155,204 @@ int test__dso_data(void)
150 unlink(file); 155 unlink(file);
151 return 0; 156 return 0;
152} 157}
158
159static long open_files_cnt(void)
160{
161 char path[PATH_MAX];
162 struct dirent *dent;
163 DIR *dir;
164 long nr = 0;
165
166 scnprintf(path, PATH_MAX, "%s/self/fd", procfs__mountpoint());
167 pr_debug("fd path: %s\n", path);
168
169 dir = opendir(path);
170 TEST_ASSERT_VAL("failed to open fd directory", dir);
171
172 while ((dent = readdir(dir)) != NULL) {
173 if (!strcmp(dent->d_name, ".") ||
174 !strcmp(dent->d_name, ".."))
175 continue;
176
177 nr++;
178 }
179
180 closedir(dir);
181 return nr - 1;
182}
183
184static struct dso **dsos;
185
186static int dsos__create(int cnt, int size)
187{
188 int i;
189
190 dsos = malloc(sizeof(dsos) * cnt);
191 TEST_ASSERT_VAL("failed to alloc dsos array", dsos);
192
193 for (i = 0; i < cnt; i++) {
194 char *file;
195
196 file = test_file(size);
197 TEST_ASSERT_VAL("failed to get dso file", file);
198
199 dsos[i] = dso__new(file);
200 TEST_ASSERT_VAL("failed to get dso", dsos[i]);
201 }
202
203 return 0;
204}
205
206static void dsos__delete(int cnt)
207{
208 int i;
209
210 for (i = 0; i < cnt; i++) {
211 struct dso *dso = dsos[i];
212
213 unlink(dso->name);
214 dso__delete(dso);
215 }
216
217 free(dsos);
218}
219
220static int set_fd_limit(int n)
221{
222 struct rlimit rlim;
223
224 if (getrlimit(RLIMIT_NOFILE, &rlim))
225 return -1;
226
227 pr_debug("file limit %ld, new %d\n", (long) rlim.rlim_cur, n);
228
229 rlim.rlim_cur = n;
230 return setrlimit(RLIMIT_NOFILE, &rlim);
231}
232
233int test__dso_data_cache(void)
234{
235 struct machine machine;
236 long nr_end, nr = open_files_cnt();
237 int dso_cnt, limit, i, fd;
238
239 memset(&machine, 0, sizeof(machine));
240
241 /* set as system limit */
242 limit = nr * 4;
243 TEST_ASSERT_VAL("failed to set file limit", !set_fd_limit(limit));
244
245 /* and this is now our dso open FDs limit + 1 extra */
246 dso_cnt = limit / 2 + 1;
247 TEST_ASSERT_VAL("failed to create dsos\n",
248 !dsos__create(dso_cnt, TEST_FILE_SIZE));
249
250 for (i = 0; i < (dso_cnt - 1); i++) {
251 struct dso *dso = dsos[i];
252
253 /*
254 * Open dsos via dso__data_fd or dso__data_read_offset.
255 * Both opens the data file and keep it open.
256 */
257 if (i % 2) {
258 fd = dso__data_fd(dso, &machine);
259 TEST_ASSERT_VAL("failed to get fd", fd > 0);
260 } else {
261 #define BUFSIZE 10
262 u8 buf[BUFSIZE];
263 ssize_t n;
264
265 n = dso__data_read_offset(dso, &machine, 0, buf, BUFSIZE);
266 TEST_ASSERT_VAL("failed to read dso", n == BUFSIZE);
267 }
268 }
269
270 /* open +1 dso over the allowed limit */
271 fd = dso__data_fd(dsos[i], &machine);
272 TEST_ASSERT_VAL("failed to get fd", fd > 0);
273
274 /* should force the first one to be closed */
275 TEST_ASSERT_VAL("failed to close dsos[0]", dsos[0]->data.fd == -1);
276
277 /* cleanup everything */
278 dsos__delete(dso_cnt);
279
280 /* Make sure we did not leak any file descriptor. */
281 nr_end = open_files_cnt();
282 pr_debug("nr start %ld, nr stop %ld\n", nr, nr_end);
283 TEST_ASSERT_VAL("failed leadking files", nr == nr_end);
284 return 0;
285}
286
287int test__dso_data_reopen(void)
288{
289 struct machine machine;
290 long nr_end, nr = open_files_cnt();
291 int fd, fd_extra;
292
293#define dso_0 (dsos[0])
294#define dso_1 (dsos[1])
295#define dso_2 (dsos[2])
296
297 memset(&machine, 0, sizeof(machine));
298
299 /*
300 * Test scenario:
301 * - create 3 dso objects
302 * - set process file descriptor limit to current
303 * files count + 3
304 * - test that the first dso gets closed when we
305 * reach the files count limit
306 */
307
308 /* Make sure we are able to open 3 fds anyway */
309 TEST_ASSERT_VAL("failed to set file limit",
310 !set_fd_limit((nr + 3)));
311
312 TEST_ASSERT_VAL("failed to create dsos\n", !dsos__create(3, TEST_FILE_SIZE));
313
314 /* open dso_0 */
315 fd = dso__data_fd(dso_0, &machine);
316 TEST_ASSERT_VAL("failed to get fd", fd > 0);
317
318 /* open dso_1 */
319 fd = dso__data_fd(dso_1, &machine);
320 TEST_ASSERT_VAL("failed to get fd", fd > 0);
321
322 /*
323 * open extra file descriptor and we just
324 * reached the files count limit
325 */
326 fd_extra = open("/dev/null", O_RDONLY);
327 TEST_ASSERT_VAL("failed to open extra fd", fd_extra > 0);
328
329 /* open dso_2 */
330 fd = dso__data_fd(dso_2, &machine);
331 TEST_ASSERT_VAL("failed to get fd", fd > 0);
332
333 /*
334 * dso_0 should get closed, because we reached
335 * the file descriptor limit
336 */
337 TEST_ASSERT_VAL("failed to close dso_0", dso_0->data.fd == -1);
338
339 /* open dso_0 */
340 fd = dso__data_fd(dso_0, &machine);
341 TEST_ASSERT_VAL("failed to get fd", fd > 0);
342
343 /*
344 * dso_1 should get closed, because we reached
345 * the file descriptor limit
346 */
347 TEST_ASSERT_VAL("failed to close dso_1", dso_1->data.fd == -1);
348
349 /* cleanup everything */
350 close(fd_extra);
351 dsos__delete(3);
352
353 /* Make sure we did not leak any file descriptor. */
354 nr_end = open_files_cnt();
355 pr_debug("nr start %ld, nr stop %ld\n", nr, nr_end);
356 TEST_ASSERT_VAL("failed leadking files", nr == nr_end);
357 return 0;
358}
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 108f0cd49f4e..96adb730b744 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -15,7 +15,7 @@ static int mmap_handler(struct perf_tool *tool __maybe_unused,
15 struct perf_sample *sample __maybe_unused, 15 struct perf_sample *sample __maybe_unused,
16 struct machine *machine) 16 struct machine *machine)
17{ 17{
18 return machine__process_mmap_event(machine, event, NULL); 18 return machine__process_mmap2_event(machine, event, NULL);
19} 19}
20 20
21static int init_live_machine(struct machine *machine) 21static int init_live_machine(struct machine *machine)
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 2f92d6e7ee00..69a71ff84e01 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -205,8 +205,7 @@ $(run):
205 ( eval $$cmd ) >> $@ 2>&1; \ 205 ( eval $$cmd ) >> $@ 2>&1; \
206 echo " test: $(call test,$@)" >> $@ 2>&1; \ 206 echo " test: $(call test,$@)" >> $@ 2>&1; \
207 $(call test,$@) && \ 207 $(call test,$@) && \
208 rm -f $@ \ 208 rm -rf $@ $$TMP_DEST || (cat $@ ; false)
209 rm -rf $$TMP_DEST
210 209
211$(run_O): 210$(run_O):
212 $(call clean) 211 $(call clean)
@@ -217,9 +216,7 @@ $(run_O):
217 ( eval $$cmd ) >> $@ 2>&1 && \ 216 ( eval $$cmd ) >> $@ 2>&1 && \
218 echo " test: $(call test_O,$@)" >> $@ 2>&1; \ 217 echo " test: $(call test_O,$@)" >> $@ 2>&1; \
219 $(call test_O,$@) && \ 218 $(call test_O,$@) && \
220 rm -f $@ && \ 219 rm -rf $@ $$TMP_O $$TMP_DEST || (cat $@ ; false)
221 rm -rf $$TMP_O \
222 rm -rf $$TMP_DEST
223 220
224tarpkg: 221tarpkg:
225 @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \ 222 @cmd="$(PERF)/tests/perf-targz-src-pkg $(PERF)"; \
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 022bb68fd9c7..ed64790a395f 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -28,6 +28,8 @@ int test__syscall_open_tp_fields(void);
28int test__pmu(void); 28int test__pmu(void);
29int test__attr(void); 29int test__attr(void);
30int test__dso_data(void); 30int test__dso_data(void);
31int test__dso_data_cache(void);
32int test__dso_data_reopen(void);
31int test__parse_events(void); 33int test__parse_events(void);
32int test__hists_link(void); 34int test__hists_link(void);
33int test__python_use(void); 35int test__python_use(void);
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 64453d63b971..819f10414f08 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1,3 +1,6 @@
1#include <asm/bug.h>
2#include <sys/time.h>
3#include <sys/resource.h>
1#include "symbol.h" 4#include "symbol.h"
2#include "dso.h" 5#include "dso.h"
3#include "machine.h" 6#include "machine.h"
@@ -136,7 +139,48 @@ int dso__read_binary_type_filename(const struct dso *dso,
136 return ret; 139 return ret;
137} 140}
138 141
139static int open_dso(struct dso *dso, struct machine *machine) 142/*
143 * Global list of open DSOs and the counter.
144 */
145static LIST_HEAD(dso__data_open);
146static long dso__data_open_cnt;
147
148static void dso__list_add(struct dso *dso)
149{
150 list_add_tail(&dso->data.open_entry, &dso__data_open);
151 dso__data_open_cnt++;
152}
153
154static void dso__list_del(struct dso *dso)
155{
156 list_del(&dso->data.open_entry);
157 WARN_ONCE(dso__data_open_cnt <= 0,
158 "DSO data fd counter out of bounds.");
159 dso__data_open_cnt--;
160}
161
162static void close_first_dso(void);
163
164static int do_open(char *name)
165{
166 int fd;
167
168 do {
169 fd = open(name, O_RDONLY);
170 if (fd >= 0)
171 return fd;
172
173 pr_debug("dso open failed, mmap: %s\n", strerror(errno));
174 if (!dso__data_open_cnt || errno != EMFILE)
175 break;
176
177 close_first_dso();
178 } while (1);
179
180 return -1;
181}
182
183static int __open_dso(struct dso *dso, struct machine *machine)
140{ 184{
141 int fd; 185 int fd;
142 char *root_dir = (char *)""; 186 char *root_dir = (char *)"";
@@ -154,11 +198,130 @@ static int open_dso(struct dso *dso, struct machine *machine)
154 return -EINVAL; 198 return -EINVAL;
155 } 199 }
156 200
157 fd = open(name, O_RDONLY); 201 fd = do_open(name);
158 free(name); 202 free(name);
159 return fd; 203 return fd;
160} 204}
161 205
206static void check_data_close(void);
207
208/**
209 * dso_close - Open DSO data file
210 * @dso: dso object
211 *
212 * Open @dso's data file descriptor and updates
213 * list/count of open DSO objects.
214 */
215static int open_dso(struct dso *dso, struct machine *machine)
216{
217 int fd = __open_dso(dso, machine);
218
219 if (fd > 0) {
220 dso__list_add(dso);
221 /*
222 * Check if we crossed the allowed number
223 * of opened DSOs and close one if needed.
224 */
225 check_data_close();
226 }
227
228 return fd;
229}
230
231static void close_data_fd(struct dso *dso)
232{
233 if (dso->data.fd >= 0) {
234 close(dso->data.fd);
235 dso->data.fd = -1;
236 dso->data.file_size = 0;
237 dso__list_del(dso);
238 }
239}
240
241/**
242 * dso_close - Close DSO data file
243 * @dso: dso object
244 *
245 * Close @dso's data file descriptor and updates
246 * list/count of open DSO objects.
247 */
248static void close_dso(struct dso *dso)
249{
250 close_data_fd(dso);
251}
252
253static void close_first_dso(void)
254{
255 struct dso *dso;
256
257 dso = list_first_entry(&dso__data_open, struct dso, data.open_entry);
258 close_dso(dso);
259}
260
261static rlim_t get_fd_limit(void)
262{
263 struct rlimit l;
264 rlim_t limit = 0;
265
266 /* Allow half of the current open fd limit. */
267 if (getrlimit(RLIMIT_NOFILE, &l) == 0) {
268 if (l.rlim_cur == RLIM_INFINITY)
269 limit = l.rlim_cur;
270 else
271 limit = l.rlim_cur / 2;
272 } else {
273 pr_err("failed to get fd limit\n");
274 limit = 1;
275 }
276
277 return limit;
278}
279
280static bool may_cache_fd(void)
281{
282 static rlim_t limit;
283
284 if (!limit)
285 limit = get_fd_limit();
286
287 if (limit == RLIM_INFINITY)
288 return true;
289
290 return limit > (rlim_t) dso__data_open_cnt;
291}
292
293/*
294 * Check and close LRU dso if we crossed allowed limit
295 * for opened dso file descriptors. The limit is half
296 * of the RLIMIT_NOFILE files opened.
297*/
298static void check_data_close(void)
299{
300 bool cache_fd = may_cache_fd();
301
302 if (!cache_fd)
303 close_first_dso();
304}
305
306/**
307 * dso__data_close - Close DSO data file
308 * @dso: dso object
309 *
310 * External interface to close @dso's data file descriptor.
311 */
312void dso__data_close(struct dso *dso)
313{
314 close_dso(dso);
315}
316
317/**
318 * dso__data_fd - Get dso's data file descriptor
319 * @dso: dso object
320 * @machine: machine object
321 *
322 * External interface to find dso's file, open it and
323 * returns file descriptor.
324 */
162int dso__data_fd(struct dso *dso, struct machine *machine) 325int dso__data_fd(struct dso *dso, struct machine *machine)
163{ 326{
164 enum dso_binary_type binary_type_data[] = { 327 enum dso_binary_type binary_type_data[] = {
@@ -168,8 +331,13 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
168 }; 331 };
169 int i = 0; 332 int i = 0;
170 333
171 if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) 334 if (dso->data.fd >= 0)
172 return open_dso(dso, machine); 335 return dso->data.fd;
336
337 if (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND) {
338 dso->data.fd = open_dso(dso, machine);
339 return dso->data.fd;
340 }
173 341
174 do { 342 do {
175 int fd; 343 int fd;
@@ -178,7 +346,7 @@ int dso__data_fd(struct dso *dso, struct machine *machine)
178 346
179 fd = open_dso(dso, machine); 347 fd = open_dso(dso, machine);
180 if (fd >= 0) 348 if (fd >= 0)
181 return fd; 349 return dso->data.fd = fd;
182 350
183 } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND); 351 } while (dso->binary_type != DSO_BINARY_TYPE__NOT_FOUND);
184 352
@@ -260,16 +428,10 @@ dso_cache__memcpy(struct dso_cache *cache, u64 offset,
260} 428}
261 429
262static ssize_t 430static ssize_t
263dso_cache__read(struct dso *dso, struct machine *machine, 431dso_cache__read(struct dso *dso, u64 offset, u8 *data, ssize_t size)
264 u64 offset, u8 *data, ssize_t size)
265{ 432{
266 struct dso_cache *cache; 433 struct dso_cache *cache;
267 ssize_t ret; 434 ssize_t ret;
268 int fd;
269
270 fd = dso__data_fd(dso, machine);
271 if (fd < 0)
272 return -1;
273 435
274 do { 436 do {
275 u64 cache_offset; 437 u64 cache_offset;
@@ -283,16 +445,16 @@ dso_cache__read(struct dso *dso, struct machine *machine,
283 cache_offset = offset & DSO__DATA_CACHE_MASK; 445 cache_offset = offset & DSO__DATA_CACHE_MASK;
284 ret = -EINVAL; 446 ret = -EINVAL;
285 447
286 if (-1 == lseek(fd, cache_offset, SEEK_SET)) 448 if (-1 == lseek(dso->data.fd, cache_offset, SEEK_SET))
287 break; 449 break;
288 450
289 ret = read(fd, cache->data, DSO__DATA_CACHE_SIZE); 451 ret = read(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE);
290 if (ret <= 0) 452 if (ret <= 0)
291 break; 453 break;
292 454
293 cache->offset = cache_offset; 455 cache->offset = cache_offset;
294 cache->size = ret; 456 cache->size = ret;
295 dso_cache__insert(&dso->cache, cache); 457 dso_cache__insert(&dso->data.cache, cache);
296 458
297 ret = dso_cache__memcpy(cache, offset, data, size); 459 ret = dso_cache__memcpy(cache, offset, data, size);
298 460
@@ -301,24 +463,27 @@ dso_cache__read(struct dso *dso, struct machine *machine,
301 if (ret <= 0) 463 if (ret <= 0)
302 free(cache); 464 free(cache);
303 465
304 close(fd);
305 return ret; 466 return ret;
306} 467}
307 468
308static ssize_t dso_cache_read(struct dso *dso, struct machine *machine, 469static ssize_t dso_cache_read(struct dso *dso, u64 offset,
309 u64 offset, u8 *data, ssize_t size) 470 u8 *data, ssize_t size)
310{ 471{
311 struct dso_cache *cache; 472 struct dso_cache *cache;
312 473
313 cache = dso_cache__find(&dso->cache, offset); 474 cache = dso_cache__find(&dso->data.cache, offset);
314 if (cache) 475 if (cache)
315 return dso_cache__memcpy(cache, offset, data, size); 476 return dso_cache__memcpy(cache, offset, data, size);
316 else 477 else
317 return dso_cache__read(dso, machine, offset, data, size); 478 return dso_cache__read(dso, offset, data, size);
318} 479}
319 480
320ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, 481/*
321 u64 offset, u8 *data, ssize_t size) 482 * Reads and caches dso data DSO__DATA_CACHE_SIZE size chunks
483 * in the rb_tree. Any read to already cached data is served
484 * by cached data.
485 */
486static ssize_t cached_read(struct dso *dso, u64 offset, u8 *data, ssize_t size)
322{ 487{
323 ssize_t r = 0; 488 ssize_t r = 0;
324 u8 *p = data; 489 u8 *p = data;
@@ -326,7 +491,7 @@ ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
326 do { 491 do {
327 ssize_t ret; 492 ssize_t ret;
328 493
329 ret = dso_cache_read(dso, machine, offset, p, size); 494 ret = dso_cache_read(dso, offset, p, size);
330 if (ret < 0) 495 if (ret < 0)
331 return ret; 496 return ret;
332 497
@@ -346,6 +511,67 @@ ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
346 return r; 511 return r;
347} 512}
348 513
514static int data_file_size(struct dso *dso)
515{
516 struct stat st;
517
518 if (!dso->data.file_size) {
519 if (fstat(dso->data.fd, &st)) {
520 pr_err("dso mmap failed, fstat: %s\n", strerror(errno));
521 return -1;
522 }
523 dso->data.file_size = st.st_size;
524 }
525
526 return 0;
527}
528
529static ssize_t data_read_offset(struct dso *dso, u64 offset,
530 u8 *data, ssize_t size)
531{
532 if (data_file_size(dso))
533 return -1;
534
535 /* Check the offset sanity. */
536 if (offset > dso->data.file_size)
537 return -1;
538
539 if (offset + size < offset)
540 return -1;
541
542 return cached_read(dso, offset, data, size);
543}
544
545/**
546 * dso__data_read_offset - Read data from dso file offset
547 * @dso: dso object
548 * @machine: machine object
549 * @offset: file offset
550 * @data: buffer to store data
551 * @size: size of the @data buffer
552 *
553 * External interface to read data from dso file offset. Open
554 * dso data file and use cached_read to get the data.
555 */
556ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
557 u64 offset, u8 *data, ssize_t size)
558{
559 if (dso__data_fd(dso, machine) < 0)
560 return -1;
561
562 return data_read_offset(dso, offset, data, size);
563}
564
565/**
566 * dso__data_read_addr - Read data from dso address
567 * @dso: dso object
568 * @machine: machine object
569 * @add: virtual memory address
570 * @data: buffer to store data
571 * @size: size of the @data buffer
572 *
573 * External interface to read data from dso address.
574 */
349ssize_t dso__data_read_addr(struct dso *dso, struct map *map, 575ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
350 struct machine *machine, u64 addr, 576 struct machine *machine, u64 addr,
351 u8 *data, ssize_t size) 577 u8 *data, ssize_t size)
@@ -473,7 +699,8 @@ struct dso *dso__new(const char *name)
473 dso__set_short_name(dso, dso->name, false); 699 dso__set_short_name(dso, dso->name, false);
474 for (i = 0; i < MAP__NR_TYPES; ++i) 700 for (i = 0; i < MAP__NR_TYPES; ++i)
475 dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; 701 dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
476 dso->cache = RB_ROOT; 702 dso->data.cache = RB_ROOT;
703 dso->data.fd = -1;
477 dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND; 704 dso->symtab_type = DSO_BINARY_TYPE__NOT_FOUND;
478 dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND; 705 dso->binary_type = DSO_BINARY_TYPE__NOT_FOUND;
479 dso->loaded = 0; 706 dso->loaded = 0;
@@ -485,6 +712,7 @@ struct dso *dso__new(const char *name)
485 dso->kernel = DSO_TYPE_USER; 712 dso->kernel = DSO_TYPE_USER;
486 dso->needs_swap = DSO_SWAP__UNSET; 713 dso->needs_swap = DSO_SWAP__UNSET;
487 INIT_LIST_HEAD(&dso->node); 714 INIT_LIST_HEAD(&dso->node);
715 INIT_LIST_HEAD(&dso->data.open_entry);
488 } 716 }
489 717
490 return dso; 718 return dso;
@@ -506,7 +734,8 @@ void dso__delete(struct dso *dso)
506 dso->long_name_allocated = false; 734 dso->long_name_allocated = false;
507 } 735 }
508 736
509 dso_cache__free(&dso->cache); 737 dso__data_close(dso);
738 dso_cache__free(&dso->data.cache);
510 dso__free_a2l(dso); 739 dso__free_a2l(dso);
511 zfree(&dso->symsrc_filename); 740 zfree(&dso->symsrc_filename);
512 free(dso); 741 free(dso);
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 38efe95a7fdd..ad553ba257bf 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -76,7 +76,6 @@ struct dso {
76 struct list_head node; 76 struct list_head node;
77 struct rb_root symbols[MAP__NR_TYPES]; 77 struct rb_root symbols[MAP__NR_TYPES];
78 struct rb_root symbol_names[MAP__NR_TYPES]; 78 struct rb_root symbol_names[MAP__NR_TYPES];
79 struct rb_root cache;
80 void *a2l; 79 void *a2l;
81 char *symsrc_filename; 80 char *symsrc_filename;
82 unsigned int a2l_fails; 81 unsigned int a2l_fails;
@@ -99,6 +98,15 @@ struct dso {
99 const char *long_name; 98 const char *long_name;
100 u16 long_name_len; 99 u16 long_name_len;
101 u16 short_name_len; 100 u16 short_name_len;
101
102 /* dso data file */
103 struct {
104 struct rb_root cache;
105 int fd;
106 size_t file_size;
107 struct list_head open_entry;
108 } data;
109
102 char name[0]; 110 char name[0];
103}; 111};
104 112
@@ -141,7 +149,47 @@ char dso__symtab_origin(const struct dso *dso);
141int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type, 149int dso__read_binary_type_filename(const struct dso *dso, enum dso_binary_type type,
142 char *root_dir, char *filename, size_t size); 150 char *root_dir, char *filename, size_t size);
143 151
152/*
153 * The dso__data_* external interface provides following functions:
154 * dso__data_fd
155 * dso__data_close
156 * dso__data_read_offset
157 * dso__data_read_addr
158 *
159 * Please refer to the dso.c object code for each function and
160 * arguments documentation. Following text tries to explain the
161 * dso file descriptor caching.
162 *
163 * The dso__data* interface allows caching of opened file descriptors
164 * to speed up the dso data accesses. The idea is to leave the file
165 * descriptor opened ideally for the whole life of the dso object.
166 *
167 * The current usage of the dso__data_* interface is as follows:
168 *
169 * Get DSO's fd:
170 * int fd = dso__data_fd(dso, machine);
171 * USE 'fd' SOMEHOW
172 *
173 * Read DSO's data:
174 * n = dso__data_read_offset(dso_0, &machine, 0, buf, BUFSIZE);
175 * n = dso__data_read_addr(dso_0, &machine, 0, buf, BUFSIZE);
176 *
177 * Eventually close DSO's fd:
178 * dso__data_close(dso);
179 *
180 * It is not necessary to close the DSO object data file. Each time new
181 * DSO data file is opened, the limit (RLIMIT_NOFILE/2) is checked. Once
182 * it is crossed, the oldest opened DSO object is closed.
183 *
184 * The dso__delete function calls close_dso function to ensure the
185 * data file descriptor gets closed/unmapped before the dso object
186 * is freed.
187 *
188 * TODO
189*/
144int dso__data_fd(struct dso *dso, struct machine *machine); 190int dso__data_fd(struct dso *dso, struct machine *machine);
191void dso__data_close(struct dso *dso);
192
145ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, 193ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine,
146 u64 offset, u8 *data, ssize_t size); 194 u64 offset, u8 *data, ssize_t size);
147ssize_t dso__data_read_addr(struct dso *dso, struct map *map, 195ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 65795b835b39..d0281bdfa582 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1,4 +1,5 @@
1#include <linux/types.h> 1#include <linux/types.h>
2#include <sys/mman.h>
2#include "event.h" 3#include "event.h"
3#include "debug.h" 4#include "debug.h"
4#include "hist.h" 5#include "hist.h"
@@ -178,13 +179,14 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
178 return -1; 179 return -1;
179 } 180 }
180 181
181 event->header.type = PERF_RECORD_MMAP; 182 event->header.type = PERF_RECORD_MMAP2;
182 183
183 while (1) { 184 while (1) {
184 char bf[BUFSIZ]; 185 char bf[BUFSIZ];
185 char prot[5]; 186 char prot[5];
186 char execname[PATH_MAX]; 187 char execname[PATH_MAX];
187 char anonstr[] = "//anon"; 188 char anonstr[] = "//anon";
189 unsigned int ino;
188 size_t size; 190 size_t size;
189 ssize_t n; 191 ssize_t n;
190 192
@@ -195,15 +197,20 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
195 strcpy(execname, ""); 197 strcpy(execname, "");
196 198
197 /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */ 199 /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
198 n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n", 200 n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n",
199 &event->mmap.start, &event->mmap.len, prot, 201 &event->mmap2.start, &event->mmap2.len, prot,
200 &event->mmap.pgoff, 202 &event->mmap2.pgoff, &event->mmap2.maj,
201 execname); 203 &event->mmap2.min,
204 &ino, execname);
205
202 /* 206 /*
203 * Anon maps don't have the execname. 207 * Anon maps don't have the execname.
204 */ 208 */
205 if (n < 4) 209 if (n < 7)
206 continue; 210 continue;
211
212 event->mmap2.ino = (u64)ino;
213
207 /* 214 /*
208 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c 215 * Just like the kernel, see __perf_event_mmap in kernel/perf_event.c
209 */ 216 */
@@ -212,6 +219,21 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
212 else 219 else
213 event->header.misc = PERF_RECORD_MISC_GUEST_USER; 220 event->header.misc = PERF_RECORD_MISC_GUEST_USER;
214 221
222 /* map protection and flags bits */
223 event->mmap2.prot = 0;
224 event->mmap2.flags = 0;
225 if (prot[0] == 'r')
226 event->mmap2.prot |= PROT_READ;
227 if (prot[1] == 'w')
228 event->mmap2.prot |= PROT_WRITE;
229 if (prot[2] == 'x')
230 event->mmap2.prot |= PROT_EXEC;
231
232 if (prot[3] == 's')
233 event->mmap2.flags |= MAP_SHARED;
234 else
235 event->mmap2.flags |= MAP_PRIVATE;
236
215 if (prot[2] != 'x') { 237 if (prot[2] != 'x') {
216 if (!mmap_data || prot[0] != 'r') 238 if (!mmap_data || prot[0] != 'r')
217 continue; 239 continue;
@@ -223,15 +245,15 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
223 strcpy(execname, anonstr); 245 strcpy(execname, anonstr);
224 246
225 size = strlen(execname) + 1; 247 size = strlen(execname) + 1;
226 memcpy(event->mmap.filename, execname, size); 248 memcpy(event->mmap2.filename, execname, size);
227 size = PERF_ALIGN(size, sizeof(u64)); 249 size = PERF_ALIGN(size, sizeof(u64));
228 event->mmap.len -= event->mmap.start; 250 event->mmap2.len -= event->mmap.start;
229 event->mmap.header.size = (sizeof(event->mmap) - 251 event->mmap2.header.size = (sizeof(event->mmap2) -
230 (sizeof(event->mmap.filename) - size)); 252 (sizeof(event->mmap2.filename) - size));
231 memset(event->mmap.filename + size, 0, machine->id_hdr_size); 253 memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
232 event->mmap.header.size += machine->id_hdr_size; 254 event->mmap2.header.size += machine->id_hdr_size;
233 event->mmap.pid = tgid; 255 event->mmap2.pid = tgid;
234 event->mmap.tid = pid; 256 event->mmap2.tid = pid;
235 257
236 if (process(tool, event, &synth_sample, machine) != 0) { 258 if (process(tool, event, &synth_sample, machine) != 0) {
237 rc = -1; 259 rc = -1;
@@ -612,12 +634,15 @@ size_t perf_event__fprintf_mmap(union perf_event *event, FILE *fp)
612size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp) 634size_t perf_event__fprintf_mmap2(union perf_event *event, FILE *fp)
613{ 635{
614 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64 636 return fprintf(fp, " %d/%d: [%#" PRIx64 "(%#" PRIx64 ") @ %#" PRIx64
615 " %02x:%02x %"PRIu64" %"PRIu64"]: %c %s\n", 637 " %02x:%02x %"PRIu64" %"PRIu64"]: %c%c%c%c %s\n",
616 event->mmap2.pid, event->mmap2.tid, event->mmap2.start, 638 event->mmap2.pid, event->mmap2.tid, event->mmap2.start,
617 event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj, 639 event->mmap2.len, event->mmap2.pgoff, event->mmap2.maj,
618 event->mmap2.min, event->mmap2.ino, 640 event->mmap2.min, event->mmap2.ino,
619 event->mmap2.ino_generation, 641 event->mmap2.ino_generation,
620 (event->header.misc & PERF_RECORD_MISC_MMAP_DATA) ? 'r' : 'x', 642 (event->mmap2.prot & PROT_READ) ? 'r' : '-',
643 (event->mmap2.prot & PROT_WRITE) ? 'w' : '-',
644 (event->mmap2.prot & PROT_EXEC) ? 'x' : '-',
645 (event->mmap2.flags & MAP_SHARED) ? 's' : 'p',
621 event->mmap2.filename); 646 event->mmap2.filename);
622} 647}
623 648
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
index d970232cb270..e5dd40addb30 100644
--- a/tools/perf/util/event.h
+++ b/tools/perf/util/event.h
@@ -7,6 +7,7 @@
7#include "../perf.h" 7#include "../perf.h"
8#include "map.h" 8#include "map.h"
9#include "build-id.h" 9#include "build-id.h"
10#include "perf_regs.h"
10 11
11struct mmap_event { 12struct mmap_event {
12 struct perf_event_header header; 13 struct perf_event_header header;
@@ -27,6 +28,8 @@ struct mmap2_event {
27 u32 min; 28 u32 min;
28 u64 ino; 29 u64 ino;
29 u64 ino_generation; 30 u64 ino_generation;
31 u32 prot;
32 u32 flags;
30 char filename[PATH_MAX]; 33 char filename[PATH_MAX];
31}; 34};
32 35
@@ -87,6 +90,10 @@ struct regs_dump {
87 u64 abi; 90 u64 abi;
88 u64 mask; 91 u64 mask;
89 u64 *regs; 92 u64 *regs;
93
94 /* Cached values/mask filled by first register access. */
95 u64 cache_regs[PERF_REGS_MAX];
96 u64 cache_mask;
90}; 97};
91 98
92struct stack_dump { 99struct stack_dump {
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 5c28d82b76c4..8606175fe1e8 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -589,10 +589,10 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
589 } 589 }
590 590
591 /* 591 /*
592 * We default some events to a 1 default interval. But keep 592 * We default some events to have a default interval. But keep
593 * it a weak assumption overridable by the user. 593 * it a weak assumption overridable by the user.
594 */ 594 */
595 if (!attr->sample_period || (opts->user_freq != UINT_MAX && 595 if (!attr->sample_period || (opts->user_freq != UINT_MAX ||
596 opts->user_interval != ULLONG_MAX)) { 596 opts->user_interval != ULLONG_MAX)) {
597 if (opts->freq) { 597 if (opts->freq) {
598 perf_evsel__set_sample_bit(evsel, PERIOD); 598 perf_evsel__set_sample_bit(evsel, PERIOD);
@@ -659,6 +659,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
659 perf_evsel__set_sample_bit(evsel, WEIGHT); 659 perf_evsel__set_sample_bit(evsel, WEIGHT);
660 660
661 attr->mmap = track; 661 attr->mmap = track;
662 attr->mmap2 = track && !perf_missing_features.mmap2;
662 attr->comm = track; 663 attr->comm = track;
663 664
664 if (opts->sample_transaction) 665 if (opts->sample_transaction)
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 5a0a4b2cadc4..30df6187ee02 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -128,6 +128,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
128 + unresolved_col_width + 2; 128 + unresolved_col_width + 2;
129 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, 129 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
130 symlen); 130 symlen);
131 hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
132 symlen + 1);
131 } else { 133 } else {
132 symlen = unresolved_col_width + 4 + 2; 134 symlen = unresolved_col_width + 4 + 2;
133 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, 135 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
@@ -439,9 +441,10 @@ struct hist_entry *__hists__add_entry(struct hists *hists,
439 .map = al->map, 441 .map = al->map,
440 .sym = al->sym, 442 .sym = al->sym,
441 }, 443 },
442 .cpu = al->cpu, 444 .cpu = al->cpu,
443 .ip = al->addr, 445 .cpumode = al->cpumode,
444 .level = al->level, 446 .ip = al->addr,
447 .level = al->level,
445 .stat = { 448 .stat = {
446 .nr_events = 1, 449 .nr_events = 1,
447 .period = period, 450 .period = period,
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index d2bf03575d5f..742f49a85725 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -72,6 +72,7 @@ enum hist_column {
72 HISTC_MEM_TLB, 72 HISTC_MEM_TLB,
73 HISTC_MEM_LVL, 73 HISTC_MEM_LVL,
74 HISTC_MEM_SNOOP, 74 HISTC_MEM_SNOOP,
75 HISTC_MEM_DCACHELINE,
75 HISTC_TRANSACTION, 76 HISTC_TRANSACTION,
76 HISTC_NR_COLS, /* Last entry */ 77 HISTC_NR_COLS, /* Last entry */
77}; 78};
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7409ac8de51c..0e5fea95d596 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1060,6 +1060,8 @@ int machine__process_mmap2_event(struct machine *machine,
1060 event->mmap2.pid, event->mmap2.maj, 1060 event->mmap2.pid, event->mmap2.maj,
1061 event->mmap2.min, event->mmap2.ino, 1061 event->mmap2.min, event->mmap2.ino,
1062 event->mmap2.ino_generation, 1062 event->mmap2.ino_generation,
1063 event->mmap2.prot,
1064 event->mmap2.flags,
1063 event->mmap2.filename, type); 1065 event->mmap2.filename, type);
1064 1066
1065 if (map == NULL) 1067 if (map == NULL)
@@ -1105,7 +1107,7 @@ int machine__process_mmap_event(struct machine *machine, union perf_event *event
1105 1107
1106 map = map__new(&machine->user_dsos, event->mmap.start, 1108 map = map__new(&machine->user_dsos, event->mmap.start,
1107 event->mmap.len, event->mmap.pgoff, 1109 event->mmap.len, event->mmap.pgoff,
1108 event->mmap.pid, 0, 0, 0, 0, 1110 event->mmap.pid, 0, 0, 0, 0, 0, 0,
1109 event->mmap.filename, 1111 event->mmap.filename,
1110 type); 1112 type);
1111 1113
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 8ccbb32eda25..25c571f4cba6 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -138,7 +138,7 @@ void map__init(struct map *map, enum map_type type,
138 138
139struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, 139struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
140 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 140 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
141 u64 ino_gen, char *filename, 141 u64 ino_gen, u32 prot, u32 flags, char *filename,
142 enum map_type type) 142 enum map_type type)
143{ 143{
144 struct map *map = malloc(sizeof(*map)); 144 struct map *map = malloc(sizeof(*map));
@@ -157,6 +157,8 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
157 map->min = d_min; 157 map->min = d_min;
158 map->ino = ino; 158 map->ino = ino;
159 map->ino_generation = ino_gen; 159 map->ino_generation = ino_gen;
160 map->prot = prot;
161 map->flags = flags;
160 162
161 if ((anon || no_dso) && type == MAP__FUNCTION) { 163 if ((anon || no_dso) && type == MAP__FUNCTION) {
162 snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid); 164 snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid);
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index ae2d45110588..7758c72522ef 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -35,6 +35,8 @@ struct map {
35 bool referenced; 35 bool referenced;
36 bool erange_warned; 36 bool erange_warned;
37 u32 priv; 37 u32 priv;
38 u32 prot;
39 u32 flags;
38 u64 pgoff; 40 u64 pgoff;
39 u64 reloc; 41 u64 reloc;
40 u32 maj, min; /* only valid for MMAP2 record */ 42 u32 maj, min; /* only valid for MMAP2 record */
@@ -118,7 +120,7 @@ void map__init(struct map *map, enum map_type type,
118 u64 start, u64 end, u64 pgoff, struct dso *dso); 120 u64 start, u64 end, u64 pgoff, struct dso *dso);
119struct map *map__new(struct list_head *dsos__list, u64 start, u64 len, 121struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
120 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino, 122 u64 pgoff, u32 pid, u32 d_maj, u32 d_min, u64 ino,
121 u64 ino_gen, 123 u64 ino_gen, u32 prot, u32 flags,
122 char *filename, enum map_type type); 124 char *filename, enum map_type type);
123struct map *map__new2(u64 start, struct dso *dso, enum map_type type); 125struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
124void map__delete(struct map *map); 126void map__delete(struct map *map);
diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
index a3539ef30b15..43168fb0d9a2 100644
--- a/tools/perf/util/perf_regs.c
+++ b/tools/perf/util/perf_regs.c
@@ -1,11 +1,15 @@
1#include <errno.h> 1#include <errno.h>
2#include "perf_regs.h" 2#include "perf_regs.h"
3#include "event.h"
3 4
4int perf_reg_value(u64 *valp, struct regs_dump *regs, int id) 5int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
5{ 6{
6 int i, idx = 0; 7 int i, idx = 0;
7 u64 mask = regs->mask; 8 u64 mask = regs->mask;
8 9
10 if (regs->cache_mask & (1 << id))
11 goto out;
12
9 if (!(mask & (1 << id))) 13 if (!(mask & (1 << id)))
10 return -EINVAL; 14 return -EINVAL;
11 15
@@ -14,6 +18,10 @@ int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
14 idx++; 18 idx++;
15 } 19 }
16 20
17 *valp = regs->regs[idx]; 21 regs->cache_mask |= (1 << id);
22 regs->cache_regs[id] = regs->regs[idx];
23
24out:
25 *valp = regs->cache_regs[id];
18 return 0; 26 return 0;
19} 27}
diff --git a/tools/perf/util/perf_regs.h b/tools/perf/util/perf_regs.h
index 79c78f74e0cf..980dbf76bc98 100644
--- a/tools/perf/util/perf_regs.h
+++ b/tools/perf/util/perf_regs.h
@@ -2,7 +2,8 @@
2#define __PERF_REGS_H 2#define __PERF_REGS_H
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include "event.h" 5
6struct regs_dump;
6 7
7#ifdef HAVE_PERF_REGS_SUPPORT 8#ifdef HAVE_PERF_REGS_SUPPORT
8#include <perf_regs.h> 9#include <perf_regs.h>
@@ -11,6 +12,7 @@ int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
11 12
12#else 13#else
13#define PERF_REGS_MASK 0 14#define PERF_REGS_MASK 0
15#define PERF_REGS_MAX 0
14 16
15static inline const char *perf_reg_name(int id __maybe_unused) 17static inline const char *perf_reg_name(int id __maybe_unused)
16{ 18{
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 0d1542f33d87..9a0a1839a377 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -628,11 +628,11 @@ static int __show_line_range(struct line_range *lr, const char *module)
628 628
629 ret = debuginfo__find_line_range(dinfo, lr); 629 ret = debuginfo__find_line_range(dinfo, lr);
630 debuginfo__delete(dinfo); 630 debuginfo__delete(dinfo);
631 if (ret == 0) { 631 if (ret == 0 || ret == -ENOENT) {
632 pr_warning("Specified source line is not found.\n"); 632 pr_warning("Specified source line is not found.\n");
633 return -ENOENT; 633 return -ENOENT;
634 } else if (ret < 0) { 634 } else if (ret < 0) {
635 pr_warning("Debuginfo analysis failed. (%d)\n", ret); 635 pr_warning("Debuginfo analysis failed.\n");
636 return ret; 636 return ret;
637 } 637 }
638 638
@@ -641,7 +641,7 @@ static int __show_line_range(struct line_range *lr, const char *module)
641 ret = get_real_path(tmp, lr->comp_dir, &lr->path); 641 ret = get_real_path(tmp, lr->comp_dir, &lr->path);
642 free(tmp); /* Free old path */ 642 free(tmp); /* Free old path */
643 if (ret < 0) { 643 if (ret < 0) {
644 pr_warning("Failed to find source file. (%d)\n", ret); 644 pr_warning("Failed to find source file path.\n");
645 return ret; 645 return ret;
646 } 646 }
647 647
@@ -721,9 +721,14 @@ static int show_available_vars_at(struct debuginfo *dinfo,
721 ret = debuginfo__find_available_vars_at(dinfo, pev, &vls, 721 ret = debuginfo__find_available_vars_at(dinfo, pev, &vls,
722 max_vls, externs); 722 max_vls, externs);
723 if (ret <= 0) { 723 if (ret <= 0) {
724 pr_err("Failed to find variables at %s (%d)\n", buf, ret); 724 if (ret == 0 || ret == -ENOENT) {
725 pr_err("Failed to find the address of %s\n", buf);
726 ret = -ENOENT;
727 } else
728 pr_warning("Debuginfo analysis failed.\n");
725 goto end; 729 goto end;
726 } 730 }
731
727 /* Some variables are found */ 732 /* Some variables are found */
728 fprintf(stdout, "Available variables at %s\n", buf); 733 fprintf(stdout, "Available variables at %s\n", buf);
729 for (i = 0; i < ret; i++) { 734 for (i = 0; i < ret; i++) {
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 9d8eb26f0533..98e304766416 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -573,14 +573,13 @@ static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf)
573 if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) { 573 if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) {
574 /* Search again in global variables */ 574 /* Search again in global variables */
575 if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die)) 575 if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, 0, &vr_die))
576 pr_warning("Failed to find '%s' in this function.\n",
577 pf->pvar->var);
576 ret = -ENOENT; 578 ret = -ENOENT;
577 } 579 }
578 if (ret >= 0) 580 if (ret >= 0)
579 ret = convert_variable(&vr_die, pf); 581 ret = convert_variable(&vr_die, pf);
580 582
581 if (ret < 0)
582 pr_warning("Failed to find '%s' in this function.\n",
583 pf->pvar->var);
584 return ret; 583 return ret;
585} 584}
586 585
@@ -1281,7 +1280,11 @@ out:
1281 return ret; 1280 return ret;
1282} 1281}
1283 1282
1284/* Find available variables at given probe point */ 1283/*
1284 * Find available variables at given probe point
1285 * Return the number of found probe points. Return 0 if there is no
1286 * matched probe point. Return <0 if an error occurs.
1287 */
1285int debuginfo__find_available_vars_at(struct debuginfo *dbg, 1288int debuginfo__find_available_vars_at(struct debuginfo *dbg,
1286 struct perf_probe_event *pev, 1289 struct perf_probe_event *pev,
1287 struct variable_list **vls, 1290 struct variable_list **vls,
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index e108207c5de0..af7da565a750 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -215,6 +215,7 @@ static void define_event_symbols(struct event_format *event,
215 case PRINT_BSTRING: 215 case PRINT_BSTRING:
216 case PRINT_DYNAMIC_ARRAY: 216 case PRINT_DYNAMIC_ARRAY:
217 case PRINT_STRING: 217 case PRINT_STRING:
218 case PRINT_BITMASK:
218 break; 219 break;
219 case PRINT_TYPE: 220 case PRINT_TYPE:
220 define_event_symbols(event, ev_name, args->typecast.item); 221 define_event_symbols(event, ev_name, args->typecast.item);
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index cd9774df3750..1c419321f707 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -197,6 +197,7 @@ static void define_event_symbols(struct event_format *event,
197 case PRINT_BSTRING: 197 case PRINT_BSTRING:
198 case PRINT_DYNAMIC_ARRAY: 198 case PRINT_DYNAMIC_ARRAY:
199 case PRINT_FUNC: 199 case PRINT_FUNC:
200 case PRINT_BITMASK:
200 /* we should warn... */ 201 /* we should warn... */
201 return; 202 return;
202 } 203 }
@@ -622,6 +623,7 @@ static int python_generate_script(struct pevent *pevent, const char *outfile)
622 fprintf(ofp, "%s=", f->name); 623 fprintf(ofp, "%s=", f->name);
623 if (f->flags & FIELD_IS_STRING || 624 if (f->flags & FIELD_IS_STRING ||
624 f->flags & FIELD_IS_FLAG || 625 f->flags & FIELD_IS_FLAG ||
626 f->flags & FIELD_IS_ARRAY ||
625 f->flags & FIELD_IS_SYMBOLIC) 627 f->flags & FIELD_IS_SYMBOLIC)
626 fprintf(ofp, "%%s"); 628 fprintf(ofp, "%%s");
627 else if (f->flags & FIELD_IS_SIGNED) 629 else if (f->flags & FIELD_IS_SIGNED)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 45512baaab67..1ec57dd82284 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,3 +1,4 @@
1#include <sys/mman.h>
1#include "sort.h" 2#include "sort.h"
2#include "hist.h" 3#include "hist.h"
3#include "comm.h" 4#include "comm.h"
@@ -784,6 +785,104 @@ static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
784 return repsep_snprintf(bf, size, "%-*s", width, out); 785 return repsep_snprintf(bf, size, "%-*s", width, out);
785} 786}
786 787
788static inline u64 cl_address(u64 address)
789{
790 /* return the cacheline of the address */
791 return (address & ~(cacheline_size - 1));
792}
793
794static int64_t
795sort__dcacheline_cmp(struct hist_entry *left, struct hist_entry *right)
796{
797 u64 l, r;
798 struct map *l_map, *r_map;
799
800 if (!left->mem_info) return -1;
801 if (!right->mem_info) return 1;
802
803 /* group event types together */
804 if (left->cpumode > right->cpumode) return -1;
805 if (left->cpumode < right->cpumode) return 1;
806
807 l_map = left->mem_info->daddr.map;
808 r_map = right->mem_info->daddr.map;
809
810 /* if both are NULL, jump to sort on al_addr instead */
811 if (!l_map && !r_map)
812 goto addr;
813
814 if (!l_map) return -1;
815 if (!r_map) return 1;
816
817 if (l_map->maj > r_map->maj) return -1;
818 if (l_map->maj < r_map->maj) return 1;
819
820 if (l_map->min > r_map->min) return -1;
821 if (l_map->min < r_map->min) return 1;
822
823 if (l_map->ino > r_map->ino) return -1;
824 if (l_map->ino < r_map->ino) return 1;
825
826 if (l_map->ino_generation > r_map->ino_generation) return -1;
827 if (l_map->ino_generation < r_map->ino_generation) return 1;
828
829 /*
830 * Addresses with no major/minor numbers are assumed to be
831 * anonymous in userspace. Sort those on pid then address.
832 *
833 * The kernel and non-zero major/minor mapped areas are
834 * assumed to be unity mapped. Sort those on address.
835 */
836
837 if ((left->cpumode != PERF_RECORD_MISC_KERNEL) &&
838 (!(l_map->flags & MAP_SHARED)) &&
839 !l_map->maj && !l_map->min && !l_map->ino &&
840 !l_map->ino_generation) {
841 /* userspace anonymous */
842
843 if (left->thread->pid_ > right->thread->pid_) return -1;
844 if (left->thread->pid_ < right->thread->pid_) return 1;
845 }
846
847addr:
848 /* al_addr does all the right addr - start + offset calculations */
849 l = cl_address(left->mem_info->daddr.al_addr);
850 r = cl_address(right->mem_info->daddr.al_addr);
851
852 if (l > r) return -1;
853 if (l < r) return 1;
854
855 return 0;
856}
857
858static int hist_entry__dcacheline_snprintf(struct hist_entry *he, char *bf,
859 size_t size, unsigned int width)
860{
861
862 uint64_t addr = 0;
863 struct map *map = NULL;
864 struct symbol *sym = NULL;
865 char level = he->level;
866
867 if (he->mem_info) {
868 addr = cl_address(he->mem_info->daddr.al_addr);
869 map = he->mem_info->daddr.map;
870 sym = he->mem_info->daddr.sym;
871
872 /* print [s] for shared data mmaps */
873 if ((he->cpumode != PERF_RECORD_MISC_KERNEL) &&
874 map && (map->type == MAP__VARIABLE) &&
875 (map->flags & MAP_SHARED) &&
876 (map->maj || map->min || map->ino ||
877 map->ino_generation))
878 level = 's';
879 else if (!map)
880 level = 'X';
881 }
882 return _hist_entry__sym_snprintf(map, sym, addr, level, bf, size,
883 width);
884}
885
787struct sort_entry sort_mispredict = { 886struct sort_entry sort_mispredict = {
788 .se_header = "Branch Mispredicted", 887 .se_header = "Branch Mispredicted",
789 .se_cmp = sort__mispredict_cmp, 888 .se_cmp = sort__mispredict_cmp,
@@ -876,6 +975,13 @@ struct sort_entry sort_mem_snoop = {
876 .se_width_idx = HISTC_MEM_SNOOP, 975 .se_width_idx = HISTC_MEM_SNOOP,
877}; 976};
878 977
978struct sort_entry sort_mem_dcacheline = {
979 .se_header = "Data Cacheline",
980 .se_cmp = sort__dcacheline_cmp,
981 .se_snprintf = hist_entry__dcacheline_snprintf,
982 .se_width_idx = HISTC_MEM_DCACHELINE,
983};
984
879static int64_t 985static int64_t
880sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) 986sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
881{ 987{
@@ -1043,6 +1149,7 @@ static struct sort_dimension memory_sort_dimensions[] = {
1043 DIM(SORT_MEM_TLB, "tlb", sort_mem_tlb), 1149 DIM(SORT_MEM_TLB, "tlb", sort_mem_tlb),
1044 DIM(SORT_MEM_LVL, "mem", sort_mem_lvl), 1150 DIM(SORT_MEM_LVL, "mem", sort_mem_lvl),
1045 DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop), 1151 DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop),
1152 DIM(SORT_MEM_DCACHELINE, "dcacheline", sort_mem_dcacheline),
1046}; 1153};
1047 1154
1048#undef DIM 1155#undef DIM
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 5bf0098d6b06..041f0c9cea2b 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -89,6 +89,7 @@ struct hist_entry {
89 u64 ip; 89 u64 ip;
90 u64 transaction; 90 u64 transaction;
91 s32 cpu; 91 s32 cpu;
92 u8 cpumode;
92 93
93 struct hist_entry_diff diff; 94 struct hist_entry_diff diff;
94 95
@@ -185,6 +186,7 @@ enum sort_type {
185 SORT_MEM_TLB, 186 SORT_MEM_TLB,
186 SORT_MEM_LVL, 187 SORT_MEM_LVL,
187 SORT_MEM_SNOOP, 188 SORT_MEM_SNOOP,
189 SORT_MEM_DCACHELINE,
188}; 190};
189 191
190/* 192/*
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index bd5768d74f01..25578b98f5c5 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -250,7 +250,6 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
250 250
251 /* Check the .eh_frame section for unwinding info */ 251 /* Check the .eh_frame section for unwinding info */
252 offset = elf_section_offset(fd, ".eh_frame_hdr"); 252 offset = elf_section_offset(fd, ".eh_frame_hdr");
253 close(fd);
254 253
255 if (offset) 254 if (offset)
256 ret = unwind_spec_ehframe(dso, machine, offset, 255 ret = unwind_spec_ehframe(dso, machine, offset,
@@ -271,7 +270,6 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
271 270
272 /* Check the .debug_frame section for unwinding info */ 271 /* Check the .debug_frame section for unwinding info */
273 *offset = elf_section_offset(fd, ".debug_frame"); 272 *offset = elf_section_offset(fd, ".debug_frame");
274 close(fd);
275 273
276 if (*offset) 274 if (*offset)
277 return 0; 275 return 0;
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7fff6be07f07..95aefa78bb07 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -17,6 +17,7 @@
17 * XXX We need to find a better place for these things... 17 * XXX We need to find a better place for these things...
18 */ 18 */
19unsigned int page_size; 19unsigned int page_size;
20int cacheline_size;
20 21
21bool test_attr__enabled; 22bool test_attr__enabled;
22 23
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index b03da44e94e4..66864364ccb4 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -304,6 +304,7 @@ char *rtrim(char *s);
304void dump_stack(void); 304void dump_stack(void);
305 305
306extern unsigned int page_size; 306extern unsigned int page_size;
307extern int cacheline_size;
307 308
308void get_term_dimensions(struct winsize *ws); 309void get_term_dimensions(struct winsize *ws);
309 310