aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--Documentation/arm/Atmel/README124
-rw-r--r--Documentation/devicetree/bindings/arm/atmel-at91.txt17
-rw-r--r--Documentation/devicetree/bindings/input/gpio-keys.txt10
-rw-r--r--Documentation/devicetree/bindings/input/stmpe-keypad.txt2
-rw-r--r--MAINTAINERS14
-rw-r--r--Makefile3
-rw-r--r--arch/arm/Kconfig.debug91
-rw-r--r--arch/arm/boot/dts/armada-370-db.dts24
-rw-r--r--arch/arm/boot/dts/at91rm9200.dtsi12
-rw-r--r--arch/arm/boot/dts/at91rm9200ek.dts4
-rw-r--r--arch/arm/boot/dts/at91sam9260.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9261.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9263.dtsi12
-rw-r--r--arch/arm/boot/dts/at91sam9g20.dtsi9
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi7
-rw-r--r--arch/arm/boot/dts/at91sam9n12.dtsi12
-rw-r--r--arch/arm/boot/dts/at91sam9rl.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi5
-rw-r--r--arch/arm/boot/dts/at91sam9xe.dtsi60
-rw-r--r--arch/arm/boot/dts/ethernut5.dts2
-rw-r--r--arch/arm/boot/dts/sama5d3.dtsi34
-rw-r--r--arch/arm/boot/dts/sama5d3xcm.dtsi1
-rw-r--r--arch/arm/boot/dts/sama5d3xmb.dtsi40
-rw-r--r--arch/arm/boot/dts/sama5d4.dtsi10
-rw-r--r--arch/arm/configs/multi_v7_defconfig1
-rw-r--r--arch/arm/include/debug/at91.S (renamed from arch/arm/mach-at91/include/mach/debug-macro.S)19
-rw-r--r--arch/arm/include/debug/sirf.S30
-rw-r--r--arch/arm/include/uapi/asm/unistd.h1
-rw-r--r--arch/arm/kernel/calls.S1
-rw-r--r--arch/arm/kernel/perf_regs.c8
-rw-r--r--arch/arm/kernel/setup.c9
-rw-r--r--arch/arm/kernel/smp.c12
-rw-r--r--arch/arm/mach-at91/Kconfig9
-rw-r--r--arch/arm/mach-at91/Makefile6
-rw-r--r--arch/arm/mach-at91/at91rm9200.c15
-rw-r--r--arch/arm/mach-at91/at91sam9260.c29
-rw-r--r--arch/arm/mach-at91/at91sam9261.c11
-rw-r--r--arch/arm/mach-at91/at91sam9263.c10
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c11
-rw-r--r--arch/arm/mach-at91/at91sam9n12.c12
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c22
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c16
-rw-r--r--arch/arm/mach-at91/board-dt-rm9200.c13
-rw-r--r--arch/arm/mach-at91/board-dt-sam9.c27
-rw-r--r--arch/arm/mach-at91/board-dt-sama5.c1
-rw-r--r--arch/arm/mach-at91/generic.h21
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pio.h80
-rw-r--r--arch/arm/mach-at91/include/mach/at91_rtt.h35
-rw-r--r--arch/arm/mach-at91/include/mach/memory.h26
-rw-r--r--arch/arm/mach-at91/pm.c109
-rw-r--r--arch/arm/mach-at91/sama5d3.c12
-rw-r--r--arch/arm/mach-at91/sama5d4.c1
-rw-r--r--arch/arm/mach-at91/setup.c38
-rw-r--r--arch/arm/mach-at91/sysirq_mask.c75
-rw-r--r--arch/arm/mach-bcm/platsmp-brcmstb.c85
-rw-r--r--arch/arm/mach-hisi/Kconfig8
-rw-r--r--arch/arm/mach-hisi/core.h5
-rw-r--r--arch/arm/mach-hisi/headsmp.S2
-rw-r--r--arch/arm/mach-hisi/hisilicon.c10
-rw-r--r--arch/arm/mach-hisi/hotplug.c31
-rw-r--r--arch/arm/mach-hisi/platsmp.c56
-rw-r--r--arch/arm/mach-mvebu/mvebu-soc-id.h18
-rw-r--r--arch/arm/mach-prima2/Kconfig22
-rw-r--r--arch/arm/mach-prima2/Makefile1
-rw-r--r--arch/arm/mach-prima2/common.c22
-rw-r--r--arch/arm/mach-prima2/lluart.c35
-rw-r--r--arch/arm/mach-prima2/platsmp.c52
-rw-r--r--arch/arm/mach-prima2/rstc.c41
-rw-r--r--arch/arm/mach-prima2/rtciobrg.c1
-rw-r--r--arch/arm/mach-shmobile/Kconfig5
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c10
-rw-r--r--arch/arm/mach-shmobile/setup-rcar-gen2.c4
-rw-r--r--arch/arm/mach-shmobile/smp-r8a7779.c2
-rw-r--r--arch/arm/mm/dump.c9
-rw-r--r--arch/arm/mm/init.c4
-rw-r--r--arch/arm/mm/mmu.c4
-rw-r--r--arch/arm64/configs/defconfig9
-rw-r--r--arch/arm64/include/asm/arch_timer.h1
-rw-r--r--arch/arm64/include/asm/cpu.h5
-rw-r--r--arch/arm64/include/asm/dma-mapping.h11
-rw-r--r--arch/arm64/include/asm/pgtable.h5
-rw-r--r--arch/arm64/include/asm/processor.h4
-rw-r--r--arch/arm64/include/asm/unistd.h2
-rw-r--r--arch/arm64/kernel/cpuinfo.c10
-rw-r--r--arch/arm64/kernel/efi.c2
-rw-r--r--arch/arm64/kernel/module.c1
-rw-r--r--arch/arm64/kernel/perf_regs.c8
-rw-r--r--arch/arm64/kernel/setup.c1
-rw-r--r--arch/arm64/kernel/smp_spin_table.c1
-rw-r--r--arch/arm64/kernel/suspend.c14
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c1
-rw-r--r--arch/ia64/include/asm/unistd.h2
-rw-r--r--arch/ia64/include/uapi/asm/unistd.h1
-rw-r--r--arch/ia64/kernel/acpi.c9
-rw-r--r--arch/ia64/kernel/entry.S1
-rw-r--r--arch/nios2/kernel/cpuinfo.c1
-rw-r--r--arch/nios2/kernel/entry.S20
-rw-r--r--arch/parisc/include/asm/ldcw.h13
-rw-r--r--arch/powerpc/include/asm/kexec.h10
-rw-r--r--arch/powerpc/include/asm/systbl.h1
-rw-r--r--arch/powerpc/include/asm/unistd.h2
-rw-r--r--arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c2
-rw-r--r--arch/powerpc/kernel/smp.c9
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c8
-rw-r--r--arch/um/Kconfig.common1
-rw-r--r--arch/x86/boot/Makefile1
-rw-r--r--arch/x86/crypto/Makefile2
-rw-r--r--arch/x86/crypto/aes_ctrby8_avx-x86_64.S46
-rw-r--r--arch/x86/include/asm/vgtod.h6
-rw-r--r--arch/x86/kernel/acpi/boot.c9
-rw-r--r--arch/x86/kernel/cpu/Makefile1
-rw-r--r--arch/x86/kernel/cpu/mkcapflags.sh2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c17
-rw-r--r--arch/x86/kernel/perf_regs.c90
-rw-r--r--arch/x86/kvm/mmu.c2
-rw-r--r--arch/x86/kvm/vmx.c88
-rw-r--r--arch/x86/lib/insn.c2
-rw-r--r--arch/x86/mm/init.c37
-rw-r--r--arch/x86/um/sys_call_table_32.c2
-rw-r--r--arch/x86/um/sys_call_table_64.c2
-rw-r--r--arch/x86/vdso/vma.c45
-rw-r--r--crypto/af_alg.c3
-rw-r--r--drivers/Makefile6
-rw-r--r--drivers/acpi/acpi_processor.c25
-rw-r--r--drivers/acpi/device_pm.c2
-rw-r--r--drivers/acpi/processor_core.c56
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/scan.c13
-rw-r--r--drivers/acpi/video.c27
-rw-r--r--drivers/base/power/domain.c3
-rw-r--r--drivers/base/power/opp.c39
-rw-r--r--drivers/char/agp/ali-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c2
-rw-r--r--drivers/char/agp/backend.c2
-rw-r--r--drivers/char/agp/intel-agp.c2
-rw-r--r--drivers/char/agp/intel-gtt.c2
-rw-r--r--drivers/char/agp/nvidia-agp.c2
-rw-r--r--drivers/char/agp/via-agp.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c46
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c4
-rw-r--r--drivers/clk/at91/pmc.c9
-rw-r--r--drivers/clocksource/arm_arch_timer.c2
-rw-r--r--drivers/cpufreq/cpufreq-dt.c11
-rw-r--r--drivers/cpufreq/cpufreq.c6
-rw-r--r--drivers/cpuidle/governors/ladder.c7
-rw-r--r--drivers/cpuidle/governors/menu.c25
-rw-r--r--drivers/gpu/drm/Makefile2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_chardev.c320
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c28
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c6
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_pasid.c2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_priv.h18
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_process.c9
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_topology.c10
-rw-r--r--drivers/gpu/drm/amd/include/kgd_kfd_interface.h17
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c2
-rw-r--r--drivers/gpu/drm/drm_irq.c60
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c6
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h7
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c36
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c48
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c3
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c24
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h3
-rw-r--r--drivers/gpu/drm/i915/intel_display.c8
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c28
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c3
-rw-r--r--drivers/gpu/drm/i915/intel_runtime_pm.c27
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_gpu.c6
-rw-r--r--drivers/gpu/drm/msm/hdmi/hdmi_connector.c53
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c11
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c12
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c12
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp_kms.c9
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp_kms.h2
-rw-r--r--drivers/gpu/drm/msm/msm_atomic.c69
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c1
-rw-r--r--drivers/gpu/drm/msm/msm_drv.h4
-rw-r--r--drivers/gpu/drm/msm/msm_fbdev.c3
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/core/event.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/core/notify.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/nve0.c33
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c6
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c65
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c38
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_ttm.c3
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c8
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c4
-rw-r--r--drivers/gpu/drm/radeon/cikd.h2
-rw-r--r--drivers/gpu/drm/radeon/dce3_1_afmt.c2
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c26
-rw-r--r--drivers/gpu/drm/radeon/radeon_kfd.c76
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c2
-rw-r--r--drivers/gpu/drm/tegra/dc.c48
-rw-r--r--drivers/gpu/drm/tegra/drm.c16
-rw-r--r--drivers/gpu/drm/tegra/gem.c52
-rw-r--r--drivers/hid/Kconfig3
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/hid-input.c3
-rw-r--r--drivers/hid/hid-kye.c4
-rw-r--r--drivers/hid/hid-logitech-dj.c16
-rw-r--r--drivers/hid/hid-logitech-hidpp.c41
-rw-r--r--drivers/hid/hid-roccat-pyra.c8
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c5
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/input/evdev.c60
-rw-r--r--drivers/input/input.c22
-rw-r--r--drivers/input/keyboard/Kconfig1
-rw-r--r--drivers/input/keyboard/gpio_keys.c114
-rw-r--r--drivers/input/keyboard/hil_kbd.c6
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c141
-rw-r--r--drivers/input/mouse/alps.c84
-rw-r--r--drivers/input/mouse/trackpoint.c4
-rw-r--r--drivers/input/mouse/trackpoint.h5
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c99
-rw-r--r--drivers/input/touchscreen/edt-ft5x06.c4
-rw-r--r--drivers/iommu/intel-iommu.c12
-rw-r--r--drivers/iommu/ipmmu-vmsa.c6
-rw-r--r--drivers/iommu/rockchip-iommu.c1
-rw-r--r--drivers/md/dm-thin.c29
-rw-r--r--drivers/md/dm.c2
-rw-r--r--drivers/mfd/stmpe.c4
-rw-r--r--drivers/mfd/stmpe.h3
-rw-r--r--drivers/mmc/core/mmc.c2
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/caif/caif_virtio.c2
-rw-r--r--drivers/net/ethernet/8390/ne2k-pci.c6
-rw-r--r--drivers/net/ethernet/Kconfig12
-rw-r--r--drivers/net/ethernet/Makefile1
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c4
-rw-r--r--drivers/net/ethernet/altera/altera_tse_main.c15
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c8
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c34
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_debugfs.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/adapter.h4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c142
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c54
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c18
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c8
-rw-r--r--drivers/net/ethernet/intel/e100.c2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_debugfs.c4
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_82575.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c9
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c6
-rw-r--r--drivers/net/ethernet/myricom/myri10ge/myri10ge.c4
-rw-r--r--drivers/net/ethernet/qlogic/qla3xxx.c8
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c9
-rw-r--r--drivers/net/ethernet/realtek/8139too.c4
-rw-r--r--drivers/net/ethernet/s6gmac.c1058
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c14
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/ethernet/sun/sunvnet.c1
-rw-r--r--drivers/net/ethernet/ti/cpsw.c19
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet.h2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c6
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c1
-rw-r--r--drivers/net/hyperv/hyperv_net.h1
-rw-r--r--drivers/net/hyperv/netvsc.c15
-rw-r--r--drivers/net/phy/micrel.c18
-rw-r--r--drivers/net/usb/qmi_wwan.c10
-rw-r--r--drivers/net/usb/r8152.c17
-rw-r--r--drivers/net/virtio_net.c2
-rw-r--r--drivers/net/vxlan.c34
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c4
-rw-r--r--drivers/net/wireless/ipw2x00/Kconfig3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c15
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c4
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c17
-rw-r--r--drivers/net/xen-netback/xenbus.c1
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c57
-rw-r--r--drivers/pinctrl/pinctrl-st.c5
-rw-r--r--drivers/powercap/intel_rapl.c1
-rw-r--r--drivers/regulator/s2mps11.c19
-rw-r--r--drivers/rtc/Kconfig28
-rw-r--r--drivers/scsi/fnic/fnic.h2
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c15
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c4
-rw-r--r--drivers/scsi/scsi_error.c4
-rw-r--r--drivers/scsi/sd.c5
-rw-r--r--drivers/spi/spi-img-spfi.c8
-rw-r--r--drivers/spi/spi-sh-msiof.c5
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c2
-rw-r--r--drivers/thermal/cpu_cooling.c360
-rw-r--r--drivers/thermal/db8500_cpufreq_cooling.c20
-rw-r--r--drivers/thermal/imx_thermal.c15
-rw-r--r--drivers/thermal/int340x_thermal/Makefile1
-rw-r--r--drivers/thermal/int340x_thermal/acpi_thermal_rel.c8
-rw-r--r--drivers/thermal/int340x_thermal/int3400_thermal.c1
-rw-r--r--drivers/thermal/int340x_thermal/int3402_thermal.c1
-rw-r--r--drivers/thermal/int340x_thermal/int3403_thermal.c4
-rw-r--r--drivers/thermal/int340x_thermal/processor_thermal_device.c309
-rw-r--r--drivers/thermal/intel_powerclamp.c1
-rw-r--r--drivers/thermal/rockchip_thermal.c1
-rw-r--r--drivers/thermal/samsung/Kconfig2
-rw-r--r--drivers/thermal/samsung/exynos_thermal_common.c12
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c5
-rw-r--r--drivers/thermal/thermal_core.c6
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c17
-rw-r--r--drivers/vfio/pci/vfio_pci.c4
-rw-r--r--drivers/vhost/net.c2
-rw-r--r--drivers/vhost/vhost.c10
-rw-r--r--drivers/video/fbdev/core/fb_defio.c5
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi_pll.c2
-rw-r--r--drivers/video/fbdev/omap2/dss/pll.c3
-rw-r--r--drivers/video/fbdev/omap2/dss/sdi.c2
-rw-r--r--drivers/video/logo/logo.c17
-rw-r--r--drivers/virtio/virtio_pci_common.c10
-rw-r--r--drivers/virtio/virtio_pci_common.h1
-rw-r--r--drivers/virtio/virtio_pci_legacy.c12
-rw-r--r--fs/btrfs/backref.c13
-rw-r--r--fs/btrfs/delayed-inode.c8
-rw-r--r--fs/btrfs/extent-tree.c12
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/scrub.c2
-rw-r--r--fs/ceph/addr.c2
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/netmisc.c12
-rw-r--r--fs/cifs/readdir.c10
-rw-r--r--fs/cifs/smb2misc.c12
-rw-r--r--fs/cifs/smb2ops.c3
-rw-r--r--fs/cifs/smb2pdu.h2
-rw-r--r--fs/cifs/smb2transport.c2
-rw-r--r--fs/ext4/extents.c4
-rw-r--r--fs/ext4/file.c220
-rw-r--r--fs/ext4/resize.c24
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/fcntl.c5
-rw-r--r--fs/isofs/rock.c3
-rw-r--r--fs/nfsd/nfs4state.c2
-rw-r--r--fs/notify/fanotify/fanotify_user.c10
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c5
-rw-r--r--fs/ocfs2/namei.c43
-rw-r--r--fs/udf/dir.c31
-rw-r--r--fs/udf/inode.c14
-rw-r--r--fs/udf/namei.c17
-rw-r--r--fs/udf/symlink.c57
-rw-r--r--fs/udf/udfdecl.h3
-rw-r--r--fs/udf/unicode.c28
-rw-r--r--include/acpi/processor.h8
-rw-r--r--include/drm/drmP.h4
-rw-r--r--include/drm/drm_gem.h7
-rw-r--r--include/dt-bindings/thermal/thermal.h2
-rw-r--r--include/linux/acpi.h4
-rw-r--r--include/linux/audit.h4
-rw-r--r--include/linux/ceph/osd_client.h4
-rw-r--r--include/linux/cpu_cooling.h6
-rw-r--r--include/linux/cpuidle.h3
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/kdb.h62
-rw-r--r--include/linux/mfd/stmpe.h22
-rw-r--r--include/linux/mm.h2
-rw-r--r--include/linux/netdevice.h20
-rw-r--r--include/linux/netlink.h4
-rw-r--r--include/linux/pagemap.h13
-rw-r--r--include/linux/perf_event.h12
-rw-r--r--include/linux/perf_regs.h16
-rw-r--r--include/linux/pm_domain.h8
-rw-r--r--include/linux/rmap.h10
-rw-r--r--include/linux/thermal.h2
-rw-r--r--include/linux/writeback.h1
-rw-r--r--include/net/genetlink.h9
-rw-r--r--include/net/mac80211.h7
-rw-r--r--include/net/neighbour.h1
-rw-r--r--include/net/vxlan.h28
-rw-r--r--include/sound/pcm.h10
-rw-r--r--include/uapi/asm-generic/fcntl.h2
-rw-r--r--include/uapi/linux/in6.h3
-rw-r--r--include/uapi/linux/kfd_ioctl.h37
-rw-r--r--include/uapi/linux/libc-compat.h3
-rw-r--r--include/uapi/linux/virtio_ring.h7
-rw-r--r--kernel/audit.c10
-rw-r--r--kernel/auditfilter.c23
-rw-r--r--kernel/auditsc.c49
-rw-r--r--kernel/debug/debug_core.c52
-rw-r--r--kernel/debug/kdb/kdb_bp.c37
-rw-r--r--kernel/debug/kdb/kdb_debugger.c4
-rw-r--r--kernel/debug/kdb/kdb_main.c267
-rw-r--r--kernel/debug/kdb/kdb_private.h3
-rw-r--r--kernel/events/core.c19
-rw-r--r--kernel/exit.c12
-rw-r--r--kernel/locking/mutex-debug.c2
-rw-r--r--kernel/sched/core.c13
-rw-r--r--kernel/sched/deadline.c25
-rw-r--r--kernel/sched/fair.c6
-rw-r--r--kernel/trace/trace_kdb.c4
-rw-r--r--lib/Kconfig.kgdb25
-rw-r--r--lib/assoc_array.c1
-rw-r--r--mm/Kconfig.debug9
-rw-r--r--mm/filemap.c29
-rw-r--r--mm/memcontrol.c17
-rw-r--r--mm/memory.c35
-rw-r--r--mm/mmap.c13
-rw-r--r--mm/page-writeback.c43
-rw-r--r--mm/rmap.c42
-rw-r--r--mm/vmscan.c24
-rw-r--r--net/batman-adv/fragmentation.c4
-rw-r--r--net/batman-adv/gateway_client.c2
-rw-r--r--net/batman-adv/multicast.c11
-rw-r--r--net/batman-adv/network-coding.c2
-rw-r--r--net/batman-adv/originator.c7
-rw-r--r--net/batman-adv/routing.c6
-rw-r--r--net/bluetooth/6lowpan.c1
-rw-r--r--net/bluetooth/bnep/core.c3
-rw-r--r--net/bluetooth/cmtp/core.c3
-rw-r--r--net/bluetooth/hci_event.c16
-rw-r--r--net/bluetooth/hidp/core.c3
-rw-r--r--net/ceph/auth_x.c2
-rw-r--r--net/ceph/mon_client.c2
-rw-r--r--net/core/dev.c175
-rw-r--r--net/core/skbuff.c1
-rw-r--r--net/ipv4/geneve.c6
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv6/tcp_ipv6.c45
-rw-r--r--net/mac80211/key.c12
-rw-r--r--net/mpls/mpls_gso.c5
-rw-r--r--net/netfilter/nfnetlink.c2
-rw-r--r--net/netlink/af_netlink.c38
-rw-r--r--net/netlink/af_netlink.h8
-rw-r--r--net/netlink/genetlink.c56
-rw-r--r--net/openvswitch/actions.c3
-rw-r--r--net/openvswitch/datapath.c3
-rw-r--r--net/openvswitch/flow.c5
-rw-r--r--net/openvswitch/flow_netlink.c13
-rw-r--r--net/openvswitch/vport-geneve.c3
-rw-r--r--net/openvswitch/vport-gre.c18
-rw-r--r--net/openvswitch/vport-vxlan.c2
-rw-r--r--net/openvswitch/vport.c7
-rw-r--r--net/packet/af_packet.c11
-rw-r--r--net/sunrpc/xdr.c6
-rw-r--r--net/wireless/Kconfig2
-rw-r--r--scripts/Makefile.clean16
-rw-r--r--security/keys/gc.c4
-rw-r--r--sound/firewire/fireworks/fireworks_transaction.c2
-rw-r--r--sound/pci/hda/hda_controller.c24
-rw-r--r--sound/pci/hda/hda_intel.c5
-rw-r--r--sound/pci/hda/hda_priv.h1
-rw-r--r--sound/pci/hda/patch_hdmi.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c4
-rw-r--r--sound/soc/codecs/rt5677.c9
-rw-r--r--sound/soc/dwc/designware_i2s.c49
-rw-r--r--sound/soc/intel/Kconfig4
-rw-r--r--sound/soc/intel/bytcr_dpcm_rt5640.c2
-rw-r--r--sound/soc/intel/sst-firmware.c6
-rw-r--r--sound/soc/intel/sst/sst_acpi.c2
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c4
-rw-r--r--sound/soc/rockchip/rockchip_i2s.h2
-rw-r--r--sound/soc/soc-core.c14
-rw-r--r--sound/usb/caiaq/audio.c2
-rw-r--r--tools/lib/lockdep/preload.c4
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-diff.c46
-rw-r--r--tools/perf/builtin-list.c13
-rw-r--r--tools/perf/builtin-report.c24
-rw-r--r--tools/perf/builtin-top.c4
-rw-r--r--tools/perf/tests/hists_cumulate.c66
-rw-r--r--tools/perf/tests/hists_filter.c2
-rw-r--r--tools/perf/tests/hists_output.c10
-rw-r--r--tools/perf/ui/browsers/hists.c2
-rw-r--r--tools/perf/ui/hist.c3
-rw-r--r--tools/perf/ui/tui/setup.c26
-rw-r--r--tools/perf/util/callchain.c30
-rw-r--r--tools/perf/util/callchain.h2
-rw-r--r--tools/perf/util/hist.c18
-rw-r--r--tools/perf/util/hist.h2
-rw-r--r--tools/perf/util/probe-event.c6
-rw-r--r--tools/perf/util/probe-finder.c18
-rw-r--r--tools/power/cpupower/utils/cpupower.c2
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.c2
-rw-r--r--tools/testing/selftests/exec/execveat.c4
-rw-r--r--virt/kvm/kvm_main.c26
489 files changed, 5343 insertions, 4247 deletions
diff --git a/.mailmap b/.mailmap
index ada8ad696b2e..d357e1bd2a43 100644
--- a/.mailmap
+++ b/.mailmap
@@ -51,6 +51,7 @@ Greg Kroah-Hartman <gregkh@suse.de>
51Greg Kroah-Hartman <greg@kroah.com> 51Greg Kroah-Hartman <greg@kroah.com>
52Henk Vergonet <Henk.Vergonet@gmail.com> 52Henk Vergonet <Henk.Vergonet@gmail.com>
53Henrik Kretzschmar <henne@nachtwindheim.de> 53Henrik Kretzschmar <henne@nachtwindheim.de>
54Henrik Rydberg <rydberg@bitmath.org>
54Herbert Xu <herbert@gondor.apana.org.au> 55Herbert Xu <herbert@gondor.apana.org.au>
55Jacob Shin <Jacob.Shin@amd.com> 56Jacob Shin <Jacob.Shin@amd.com>
56James Bottomley <jejb@mulgrave.(none)> 57James Bottomley <jejb@mulgrave.(none)>
diff --git a/Documentation/arm/Atmel/README b/Documentation/arm/Atmel/README
new file mode 100644
index 000000000000..c53a19b4aab2
--- /dev/null
+++ b/Documentation/arm/Atmel/README
@@ -0,0 +1,124 @@
1ARM Atmel SoCs (aka AT91)
2=========================
3
4
5Introduction
6------------
7This document gives useful information about the ARM Atmel SoCs that are
8currently supported in Linux Mainline (you know, the one on kernel.org).
9
10It is important to note that the Atmel | SMART ARM-based MPU product line is
11historically named "AT91" or "at91" throughout the Linux kernel development
12process even if this product prefix has completely disappeared from the
13official Atmel product name. Anyway, files, directories, git trees,
14git branches/tags and email subject always contain this "at91" sub-string.
15
16
17AT91 SoCs
18---------
19Documentation and detailled datasheet for each product are available on
20the Atmel website: http://www.atmel.com.
21
22 Flavors:
23 * ARM 920 based SoC
24 - at91rm9200
25 + Datasheet
26 http://www.atmel.com/Images/doc1768.pdf
27
28 * ARM 926 based SoCs
29 - at91sam9260
30 + Datasheet
31 http://www.atmel.com/Images/doc6221.pdf
32
33 - at91sam9xe
34 + Datasheet
35 http://www.atmel.com/Images/Atmel-6254-32-bit-ARM926EJ-S-Embedded-Microprocessor-SAM9XE_Datasheet.pdf
36
37 - at91sam9261
38 + Datasheet
39 http://www.atmel.com/Images/doc6062.pdf
40
41 - at91sam9263
42 + Datasheet
43 http://www.atmel.com/Images/Atmel_6249_32-bit-ARM926EJ-S-Microcontroller_SAM9263_Datasheet.pdf
44
45 - at91sam9rl
46 + Datasheet
47 http://www.atmel.com/Images/doc6289.pdf
48
49 - at91sam9g20
50 + Datasheet
51 http://www.atmel.com/Images/doc6384.pdf
52
53 - at91sam9g45 family
54 - at91sam9g45
55 - at91sam9g46
56 - at91sam9m10
57 - at91sam9m11 (device superset)
58 + Datasheet
59 http://www.atmel.com/Images/Atmel-6437-32-bit-ARM926-Embedded-Microprocessor-SAM9M11_Datasheet.pdf
60
61 - at91sam9x5 family (aka "The 5 series")
62 - at91sam9g15
63 - at91sam9g25
64 - at91sam9g35
65 - at91sam9x25
66 - at91sam9x35
67 + Datasheet (can be considered as covering the whole family)
68 http://www.atmel.com/Images/Atmel_11055_32-bit-ARM926EJ-S-Microcontroller_SAM9X35_Datasheet.pdf
69
70 - at91sam9n12
71 + Datasheet
72 http://www.atmel.com/Images/Atmel_11063_32-bit-ARM926EJ-S-Microcontroller_SAM9N12CN11CN12_Datasheet.pdf
73
74 * ARM Cortex-A5 based SoCs
75 - sama5d3 family
76 - sama5d31
77 - sama5d33
78 - sama5d34
79 - sama5d35
80 - sama5d36 (device superset)
81 + Datasheet
82 http://www.atmel.com/Images/Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet.pdf
83
84 * ARM Cortex-A5 + NEON based SoCs
85 - sama5d4 family
86 - sama5d41
87 - sama5d42
88 - sama5d43
89 - sama5d44 (device superset)
90 + Datasheet
91 http://www.atmel.com/Images/Atmel-11238-32-bit-Cortex-A5-Microcontroller-SAMA5D4_Datasheet.pdf
92
93
94Linux kernel information
95------------------------
96Linux kernel mach directory: arch/arm/mach-at91
97MAINTAINERS entry is: "ARM/ATMEL AT91RM9200 AND AT91SAM ARM ARCHITECTURES"
98
99
100Device Tree for AT91 SoCs and boards
101------------------------------------
102All AT91 SoCs are converted to Device Tree. Since Linux 3.19, these products
103must use this method to boot the Linux kernel.
104
105Work In Progress statement:
106Device Tree files and Device Tree bindings that apply to AT91 SoCs and boards are
107considered as "Unstable". To be completely clear, any at91 binding can change at
108any time. So, be sure to use a Device Tree Binary and a Kernel Image generated from
109the same source tree.
110Please refer to the Documentation/devicetree/bindings/ABI.txt file for a
111definition of a "Stable" binding/ABI.
112This statement will be removed by AT91 MAINTAINERS when appropriate.
113
114Naming conventions and best practice:
115- SoCs Device Tree Source Include files are named after the official name of
116 the product (at91sam9g20.dtsi or sama5d33.dtsi for instance).
117- Device Tree Source Include files (.dtsi) are used to collect common nodes that can be
118 shared across SoCs or boards (sama5d3.dtsi or at91sam9x5cm.dtsi for instance).
119 When collecting nodes for a particular peripheral or topic, the identifier have to
120 be placed at the end of the file name, separated with a "_" (at91sam9x5_can.dtsi
121 or sama5d3_gmac.dtsi for example).
122- board Device Tree Source files (.dts) are prefixed by the string "at91-" so
123 that they can be identified easily. Note that some files are historical exceptions
124 to this rule (sama5d3[13456]ek.dts, usb_a9g20.dts or animeo_ip.dts for example).
diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index 562cda9d86d9..ad319f84f560 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -24,6 +24,7 @@ compatible: must be one of:
24 o "atmel,at91sam9g45" 24 o "atmel,at91sam9g45"
25 o "atmel,at91sam9n12" 25 o "atmel,at91sam9n12"
26 o "atmel,at91sam9rl" 26 o "atmel,at91sam9rl"
27 o "atmel,at91sam9xe"
27 * "atmel,sama5" for SoCs using a Cortex-A5, shall be extended with the specific 28 * "atmel,sama5" for SoCs using a Cortex-A5, shall be extended with the specific
28 SoC family: 29 SoC family:
29 o "atmel,sama5d3" shall be extended with the specific SoC compatible: 30 o "atmel,sama5d3" shall be extended with the specific SoC compatible:
@@ -136,3 +137,19 @@ Example:
136 compatible = "atmel,at91sam9260-rstc"; 137 compatible = "atmel,at91sam9260-rstc";
137 reg = <0xfffffd00 0x10>; 138 reg = <0xfffffd00 0x10>;
138 }; 139 };
140
141Special Function Registers (SFR)
142
143Special Function Registers (SFR) manage specific aspects of the integrated
144memory, bridge implementations, processor and other functionality not controlled
145elsewhere.
146
147required properties:
148- compatible: Should be "atmel,<chip>-sfr", "syscon".
149 <chip> can be "sama5d3" or "sama5d4".
150- reg: Should contain registers location and length
151
152 sfr@f0038000 {
153 compatible = "atmel,sama5d3-sfr", "syscon";
154 reg = <0xf0038000 0x60>;
155 };
diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
index a4a38fcf2ed6..44b705767aca 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
@@ -10,12 +10,13 @@ Optional properties:
10Each button (key) is represented as a sub-node of "gpio-keys": 10Each button (key) is represented as a sub-node of "gpio-keys":
11Subnode properties: 11Subnode properties:
12 12
13 - gpios: OF device-tree gpio specification.
14 - interrupts: the interrupt line for that input.
13 - label: Descriptive name of the key. 15 - label: Descriptive name of the key.
14 - linux,code: Keycode to emit. 16 - linux,code: Keycode to emit.
15 17
16Required mutual exclusive subnode-properties: 18Note that either "interrupts" or "gpios" properties can be omitted, but not
17 - gpios: OF device-tree gpio specification. 19both at the same time. Specifying both properties is allowed.
18 - interrupts: the interrupt line for that input
19 20
20Optional subnode-properties: 21Optional subnode-properties:
21 - linux,input-type: Specify event type this button/key generates. 22 - linux,input-type: Specify event type this button/key generates.
@@ -23,6 +24,9 @@ Optional subnode-properties:
23 - debounce-interval: Debouncing interval time in milliseconds. 24 - debounce-interval: Debouncing interval time in milliseconds.
24 If not specified defaults to 5. 25 If not specified defaults to 5.
25 - gpio-key,wakeup: Boolean, button can wake-up the system. 26 - gpio-key,wakeup: Boolean, button can wake-up the system.
27 - linux,can-disable: Boolean, indicates that button is connected
28 to dedicated (not shared) interrupt which can be disabled to
29 suppress events from the button.
26 30
27Example nodes: 31Example nodes:
28 32
diff --git a/Documentation/devicetree/bindings/input/stmpe-keypad.txt b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
index 1b97222e8a0b..12bb771d66d4 100644
--- a/Documentation/devicetree/bindings/input/stmpe-keypad.txt
+++ b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
@@ -8,6 +8,8 @@ Optional properties:
8 - debounce-interval : Debouncing interval time in milliseconds 8 - debounce-interval : Debouncing interval time in milliseconds
9 - st,scan-count : Scanning cycles elapsed before key data is updated 9 - st,scan-count : Scanning cycles elapsed before key data is updated
10 - st,no-autorepeat : If specified device will not autorepeat 10 - st,no-autorepeat : If specified device will not autorepeat
11 - keypad,num-rows : See ./matrix-keymap.txt
12 - keypad,num-columns : See ./matrix-keymap.txt
11 13
12Example: 14Example:
13 15
diff --git a/MAINTAINERS b/MAINTAINERS
index ddb9ac8d32b3..8c25979a3c43 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -724,15 +724,15 @@ F: include/uapi/linux/apm_bios.h
724F: drivers/char/apm-emulation.c 724F: drivers/char/apm-emulation.c
725 725
726APPLE BCM5974 MULTITOUCH DRIVER 726APPLE BCM5974 MULTITOUCH DRIVER
727M: Henrik Rydberg <rydberg@euromail.se> 727M: Henrik Rydberg <rydberg@bitmath.org>
728L: linux-input@vger.kernel.org 728L: linux-input@vger.kernel.org
729S: Maintained 729S: Odd fixes
730F: drivers/input/mouse/bcm5974.c 730F: drivers/input/mouse/bcm5974.c
731 731
732APPLE SMC DRIVER 732APPLE SMC DRIVER
733M: Henrik Rydberg <rydberg@euromail.se> 733M: Henrik Rydberg <rydberg@bitmath.org>
734L: lm-sensors@lm-sensors.org 734L: lm-sensors@lm-sensors.org
735S: Maintained 735S: Odd fixes
736F: drivers/hwmon/applesmc.c 736F: drivers/hwmon/applesmc.c
737 737
738APPLETALK NETWORK LAYER 738APPLETALK NETWORK LAYER
@@ -877,6 +877,7 @@ F: arch/arm/boot/dts/at91*.dts
877F: arch/arm/boot/dts/at91*.dtsi 877F: arch/arm/boot/dts/at91*.dtsi
878F: arch/arm/boot/dts/sama*.dts 878F: arch/arm/boot/dts/sama*.dts
879F: arch/arm/boot/dts/sama*.dtsi 879F: arch/arm/boot/dts/sama*.dtsi
880F: arch/arm/include/debug/at91.S
880 881
881ARM/ATMEL AT91 Clock Support 882ARM/ATMEL AT91 Clock Support
882M: Boris Brezillon <boris.brezillon@free-electrons.com> 883M: Boris Brezillon <boris.brezillon@free-electrons.com>
@@ -2259,6 +2260,7 @@ F: drivers/gpio/gpio-bt8xx.c
2259BTRFS FILE SYSTEM 2260BTRFS FILE SYSTEM
2260M: Chris Mason <clm@fb.com> 2261M: Chris Mason <clm@fb.com>
2261M: Josef Bacik <jbacik@fb.com> 2262M: Josef Bacik <jbacik@fb.com>
2263M: David Sterba <dsterba@suse.cz>
2262L: linux-btrfs@vger.kernel.org 2264L: linux-btrfs@vger.kernel.org
2263W: http://btrfs.wiki.kernel.org/ 2265W: http://btrfs.wiki.kernel.org/
2264Q: http://patchwork.kernel.org/project/linux-btrfs/list/ 2266Q: http://patchwork.kernel.org/project/linux-btrfs/list/
@@ -4940,10 +4942,10 @@ F: include/uapi/linux/input.h
4940F: include/linux/input/ 4942F: include/linux/input/
4941 4943
4942INPUT MULTITOUCH (MT) PROTOCOL 4944INPUT MULTITOUCH (MT) PROTOCOL
4943M: Henrik Rydberg <rydberg@euromail.se> 4945M: Henrik Rydberg <rydberg@bitmath.org>
4944L: linux-input@vger.kernel.org 4946L: linux-input@vger.kernel.org
4945T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git 4947T: git git://git.kernel.org/pub/scm/linux/kernel/git/rydberg/input-mt.git
4946S: Maintained 4948S: Odd fixes
4947F: Documentation/input/multi-touch-protocol.txt 4949F: Documentation/input/multi-touch-protocol.txt
4948F: drivers/input/input-mt.c 4950F: drivers/input/input-mt.c
4949K: \b(ABS|SYN)_MT_ 4951K: \b(ABS|SYN)_MT_
diff --git a/Makefile b/Makefile
index b1c3254441f3..e41a3356abee 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 19 2PATCHLEVEL = 19
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc4
5NAME = Diseased Newt 5NAME = Diseased Newt
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -391,6 +391,7 @@ USERINCLUDE := \
391# Needed to be compatible with the O= option 391# Needed to be compatible with the O= option
392LINUXINCLUDE := \ 392LINUXINCLUDE := \
393 -I$(srctree)/arch/$(hdr-arch)/include \ 393 -I$(srctree)/arch/$(hdr-arch)/include \
394 -Iarch/$(hdr-arch)/include/generated/uapi \
394 -Iarch/$(hdr-arch)/include/generated \ 395 -Iarch/$(hdr-arch)/include/generated \
395 $(if $(KBUILD_SRC), -I$(srctree)/include) \ 396 $(if $(KBUILD_SRC), -I$(srctree)/include) \
396 -Iinclude \ 397 -Iinclude \
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 5ddd4906f7a7..dc2b768edb8a 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -115,15 +115,18 @@ choice
115 0x80024000 | 0xf0024000 | UART9 115 0x80024000 | 0xf0024000 | UART9
116 116
117 config AT91_DEBUG_LL_DBGU0 117 config AT91_DEBUG_LL_DBGU0
118 bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl" 118 bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10, 9rl, 9x5, 9n12"
119 select DEBUG_AT91_UART
119 depends on HAVE_AT91_DBGU0 120 depends on HAVE_AT91_DBGU0
120 121
121 config AT91_DEBUG_LL_DBGU1 122 config AT91_DEBUG_LL_DBGU1
122 bool "Kernel low-level debugging on 9263 and 9g45" 123 bool "Kernel low-level debugging on 9263, 9g45 and sama5d3"
124 select DEBUG_AT91_UART
123 depends on HAVE_AT91_DBGU1 125 depends on HAVE_AT91_DBGU1
124 126
125 config AT91_DEBUG_LL_DBGU2 127 config AT91_DEBUG_LL_DBGU2
126 bool "Kernel low-level debugging on sama5d4" 128 bool "Kernel low-level debugging on sama5d4"
129 select DEBUG_AT91_UART
127 depends on HAVE_AT91_DBGU2 130 depends on HAVE_AT91_DBGU2
128 131
129 config DEBUG_BCM2835 132 config DEBUG_BCM2835
@@ -272,6 +275,14 @@ choice
272 Say Y here if you want the debug print routines to direct 275 Say Y here if you want the debug print routines to direct
273 their output to the UART on Highbank based devices. 276 their output to the UART on Highbank based devices.
274 277
278 config DEBUG_HIP01_UART
279 bool "Hisilicon Hip01 Debug UART"
280 depends on ARCH_HIP01
281 select DEBUG_UART_8250
282 help
283 Say Y here if you want kernel low-level debugging support
284 on HIP01 UART.
285
275 config DEBUG_HIP04_UART 286 config DEBUG_HIP04_UART
276 bool "Hisilicon HiP04 Debug UART" 287 bool "Hisilicon HiP04 Debug UART"
277 depends on ARCH_HIP04 288 depends on ARCH_HIP04
@@ -455,13 +466,13 @@ choice
455 Please adjust DEBUG_UART_PHYS and DEBUG_UART_BASE configuration 466 Please adjust DEBUG_UART_PHYS and DEBUG_UART_BASE configuration
456 options based on your needs. 467 options based on your needs.
457 468
458 config DEBUG_MVEBU_UART 469 config DEBUG_MVEBU_UART0
459 bool "Kernel low-level debugging messages via MVEBU UART (old bootloaders)" 470 bool "Kernel low-level debugging messages via MVEBU UART0 (old bootloaders)"
460 depends on ARCH_MVEBU 471 depends on ARCH_MVEBU
461 select DEBUG_UART_8250 472 select DEBUG_UART_8250
462 help 473 help
463 Say Y here if you want kernel low-level debugging support 474 Say Y here if you want kernel low-level debugging support
464 on MVEBU based platforms. 475 on MVEBU based platforms on UART0.
465 476
466 This option should be used with the old bootloaders 477 This option should be used with the old bootloaders
467 that left the internal registers mapped at 478 that left the internal registers mapped at
@@ -474,13 +485,28 @@ choice
474 when u-boot hands over to the kernel, the system 485 when u-boot hands over to the kernel, the system
475 silently crashes, with no serial output at all. 486 silently crashes, with no serial output at all.
476 487
477 config DEBUG_MVEBU_UART_ALTERNATE 488 config DEBUG_MVEBU_UART0_ALTERNATE
478 bool "Kernel low-level debugging messages via MVEBU UART (new bootloaders)" 489 bool "Kernel low-level debugging messages via MVEBU UART0 (new bootloaders)"
479 depends on ARCH_MVEBU 490 depends on ARCH_MVEBU
480 select DEBUG_UART_8250 491 select DEBUG_UART_8250
481 help 492 help
482 Say Y here if you want kernel low-level debugging support 493 Say Y here if you want kernel low-level debugging support
483 on MVEBU based platforms. 494 on MVEBU based platforms on UART0.
495
496 This option should be used with the new bootloaders
497 that remap the internal registers at 0xf1000000.
498
499 If the wrong DEBUG_MVEBU_UART* option is selected,
500 when u-boot hands over to the kernel, the system
501 silently crashes, with no serial output at all.
502
503 config DEBUG_MVEBU_UART1_ALTERNATE
504 bool "Kernel low-level debugging messages via MVEBU UART1 (new bootloaders)"
505 depends on ARCH_MVEBU
506 select DEBUG_UART_8250
507 help
508 Say Y here if you want kernel low-level debugging support
509 on MVEBU based platforms on UART1.
484 510
485 This option should be used with the new bootloaders 511 This option should be used with the new bootloaders
486 that remap the internal registers at 0xf1000000. 512 that remap the internal registers at 0xf1000000.
@@ -916,16 +942,28 @@ choice
916 config DEBUG_SIRFPRIMA2_UART1 942 config DEBUG_SIRFPRIMA2_UART1
917 bool "Kernel low-level debugging messages via SiRFprimaII UART1" 943 bool "Kernel low-level debugging messages via SiRFprimaII UART1"
918 depends on ARCH_PRIMA2 944 depends on ARCH_PRIMA2
945 select DEBUG_SIRFSOC_UART
919 help 946 help
920 Say Y here if you want the debug print routines to direct 947 Say Y here if you want the debug print routines to direct
921 their output to the uart1 port on SiRFprimaII devices. 948 their output to the uart1 port on SiRFprimaII devices.
922 949
923 config DEBUG_SIRFMARCO_UART1 950 config DEBUG_SIRFATLAS7_UART0
924 bool "Kernel low-level debugging messages via SiRFmarco UART1" 951 bool "Kernel low-level debugging messages via SiRFatlas7 UART0"
925 depends on ARCH_MARCO 952 depends on ARCH_ATLAS7
953 select DEBUG_SIRFSOC_UART
926 help 954 help
927 Say Y here if you want the debug print routines to direct 955 Say Y here if you want the debug print routines to direct
928 their output to the uart1 port on SiRFmarco devices. 956 their output to the uart0 port on SiRFATLAS7 devices.The uart0
957 is used on SiRFATLAS7 as a extra debug port.sometimes an extra
958 debug port can be very useful.
959
960 config DEBUG_SIRFATLAS7_UART1
961 bool "Kernel low-level debugging messages via SiRFatlas7 UART1"
962 depends on ARCH_ATLAS7
963 select DEBUG_SIRFSOC_UART
964 help
965 Say Y here if you want the debug print routines to direct
966 their output to the uart1 port on SiRFATLAS7 devices.
929 967
930 config STIH41X_DEBUG_ASC2 968 config STIH41X_DEBUG_ASC2
931 bool "Use StiH415/416 ASC2 UART for low-level debug" 969 bool "Use StiH415/416 ASC2 UART for low-level debug"
@@ -1161,10 +1199,16 @@ config DEBUG_STI_UART
1161 bool 1199 bool
1162 depends on ARCH_STI 1200 depends on ARCH_STI
1163 1201
1202config DEBUG_SIRFSOC_UART
1203 bool
1204 depends on ARCH_SIRF
1205
1164config DEBUG_LL_INCLUDE 1206config DEBUG_LL_INCLUDE
1165 string 1207 string
1166 default "debug/sa1100.S" if DEBUG_SA1100 1208 default "debug/sa1100.S" if DEBUG_SA1100
1167 default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250 1209 default "debug/8250.S" if DEBUG_LL_UART_8250 || DEBUG_UART_8250
1210 default "debug/at91.S" if AT91_DEBUG_LL_DBGU0 || AT91_DEBUG_LL_DBGU1 || \
1211 AT91_DEBUG_LL_DBGU2
1168 default "debug/asm9260.S" if DEBUG_ASM9260_UART 1212 default "debug/asm9260.S" if DEBUG_ASM9260_UART
1169 default "debug/clps711x.S" if DEBUG_CLPS711X_UART1 || DEBUG_CLPS711X_UART2 1213 default "debug/clps711x.S" if DEBUG_CLPS711X_UART1 || DEBUG_CLPS711X_UART2
1170 default "debug/meson.S" if DEBUG_MESON_UARTAO 1214 default "debug/meson.S" if DEBUG_MESON_UARTAO
@@ -1195,7 +1239,7 @@ config DEBUG_LL_INCLUDE
1195 default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA4 1239 default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA4
1196 default "debug/s3c24xx.S" if DEBUG_S3C24XX_UART 1240 default "debug/s3c24xx.S" if DEBUG_S3C24XX_UART
1197 default "debug/s5pv210.S" if DEBUG_S5PV210_UART 1241 default "debug/s5pv210.S" if DEBUG_S5PV210_UART
1198 default "debug/sirf.S" if DEBUG_SIRFPRIMA2_UART1 || DEBUG_SIRFMARCO_UART1 1242 default "debug/sirf.S" if DEBUG_SIRFSOC_UART
1199 default "debug/sti.S" if DEBUG_STI_UART 1243 default "debug/sti.S" if DEBUG_STI_UART
1200 default "debug/tegra.S" if DEBUG_TEGRA_UART 1244 default "debug/tegra.S" if DEBUG_TEGRA_UART
1201 default "debug/ux500.S" if DEBUG_UX500_UART 1245 default "debug/ux500.S" if DEBUG_UX500_UART
@@ -1251,7 +1295,10 @@ config DEBUG_UART_PHYS
1251 default 0x11009000 if DEBUG_MT8135_UART3 1295 default 0x11009000 if DEBUG_MT8135_UART3
1252 default 0x16000000 if ARCH_INTEGRATOR 1296 default 0x16000000 if ARCH_INTEGRATOR
1253 default 0x18000300 if DEBUG_BCM_5301X 1297 default 0x18000300 if DEBUG_BCM_5301X
1298 default 0x18010000 if DEBUG_SIRFATLAS7_UART0
1299 default 0x18020000 if DEBUG_SIRFATLAS7_UART1
1254 default 0x1c090000 if DEBUG_VEXPRESS_UART0_RS1 1300 default 0x1c090000 if DEBUG_VEXPRESS_UART0_RS1
1301 default 0x20001000 if DEBUG_HIP01_UART
1255 default 0x20060000 if DEBUG_RK29_UART0 1302 default 0x20060000 if DEBUG_RK29_UART0
1256 default 0x20064000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2 1303 default 0x20064000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2
1257 default 0x20068000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3 1304 default 0x20068000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3
@@ -1277,12 +1324,13 @@ config DEBUG_UART_PHYS
1277 default 0x808c0000 if ARCH_EP93XX 1324 default 0x808c0000 if ARCH_EP93XX
1278 default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART 1325 default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART
1279 default 0xa9a00000 if DEBUG_MSM_UART 1326 default 0xa9a00000 if DEBUG_MSM_UART
1327 default 0xb0060000 if DEBUG_SIRFPRIMA2_UART1
1280 default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX 1328 default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX
1281 default 0xc0013000 if DEBUG_U300_UART 1329 default 0xc0013000 if DEBUG_U300_UART
1282 default 0xc8000000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN 1330 default 0xc8000000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
1283 default 0xc8000003 if ARCH_IXP4XX && CPU_BIG_ENDIAN 1331 default 0xc8000003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
1284 default 0xd0000000 if ARCH_SPEAR3XX || ARCH_SPEAR6XX 1332 default 0xd0000000 if ARCH_SPEAR3XX || ARCH_SPEAR6XX
1285 default 0xd0012000 if DEBUG_MVEBU_UART 1333 default 0xd0012000 if DEBUG_MVEBU_UART0
1286 default 0xc81004c0 if DEBUG_MESON_UARTAO 1334 default 0xc81004c0 if DEBUG_MESON_UARTAO
1287 default 0xd4017000 if DEBUG_MMP_UART2 1335 default 0xd4017000 if DEBUG_MMP_UART2
1288 default 0xd4018000 if DEBUG_MMP_UART3 1336 default 0xd4018000 if DEBUG_MMP_UART3
@@ -1296,7 +1344,8 @@ config DEBUG_UART_PHYS
1296 default 0xe8008000 if DEBUG_R7S72100_SCIF2 1344 default 0xe8008000 if DEBUG_R7S72100_SCIF2
1297 default 0xf0000be0 if ARCH_EBSA110 1345 default 0xf0000be0 if ARCH_EBSA110
1298 default 0xf040ab00 if DEBUG_BRCMSTB_UART 1346 default 0xf040ab00 if DEBUG_BRCMSTB_UART
1299 default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE 1347 default 0xf1012000 if DEBUG_MVEBU_UART0_ALTERNATE
1348 default 0xf1012100 if DEBUG_MVEBU_UART1_ALTERNATE
1300 default 0xf1012000 if ARCH_DOVE || ARCH_MV78XX0 || \ 1349 default 0xf1012000 if ARCH_DOVE || ARCH_MV78XX0 || \
1301 ARCH_ORION5X 1350 ARCH_ORION5X
1302 default 0xf7fc9000 if DEBUG_BERLIN_UART 1351 default 0xf7fc9000 if DEBUG_BERLIN_UART
@@ -1320,7 +1369,8 @@ config DEBUG_UART_PHYS
1320 DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \ 1369 DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \
1321 DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \ 1370 DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \
1322 DEBUG_RMOBILE_SCIFA4 || DEBUG_S3C24XX_UART || \ 1371 DEBUG_RMOBILE_SCIFA4 || DEBUG_S3C24XX_UART || \
1323 DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART 1372 DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART || \
1373 DEBUG_SIRFSOC_UART
1324 1374
1325config DEBUG_UART_VIRT 1375config DEBUG_UART_VIRT
1326 hex "Virtual base address of debug UART" 1376 hex "Virtual base address of debug UART"
@@ -1377,8 +1427,12 @@ config DEBUG_UART_VIRT
1377 default 0xfeb30c00 if DEBUG_KEYSTONE_UART0 1427 default 0xfeb30c00 if DEBUG_KEYSTONE_UART0
1378 default 0xfeb31000 if DEBUG_KEYSTONE_UART1 1428 default 0xfeb31000 if DEBUG_KEYSTONE_UART1
1379 default 0xfec02000 if DEBUG_SOCFPGA_UART 1429 default 0xfec02000 if DEBUG_SOCFPGA_UART
1380 default 0xfec12000 if DEBUG_MVEBU_UART || DEBUG_MVEBU_UART_ALTERNATE 1430 default 0xfec12000 if DEBUG_MVEBU_UART0 || DEBUG_MVEBU_UART0_ALTERNATE
1431 default 0xfec12100 if DEBUG_MVEBU_UART1_ALTERNATE
1432 default 0xfec10000 if DEBUG_SIRFATLAS7_UART0
1381 default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0 1433 default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0
1434 default 0xfec20000 if DEBUG_SIRFATLAS7_UART1
1435 default 0xfec60000 if DEBUG_SIRFPRIMA2_UART1
1382 default 0xfec90000 if DEBUG_RK32_UART2 1436 default 0xfec90000 if DEBUG_RK32_UART2
1383 default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1 1437 default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1
1384 default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2 1438 default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2
@@ -1394,11 +1448,12 @@ config DEBUG_UART_VIRT
1394 default 0xfef36000 if DEBUG_HIGHBANK_UART 1448 default 0xfef36000 if DEBUG_HIGHBANK_UART
1395 default 0xfefff700 if ARCH_IOP33X 1449 default 0xfefff700 if ARCH_IOP33X
1396 default 0xff003000 if DEBUG_U300_UART 1450 default 0xff003000 if DEBUG_U300_UART
1451 default 0xffd01000 if DEBUG_HIP01_UART
1397 default DEBUG_UART_PHYS if !MMU 1452 default DEBUG_UART_PHYS if !MMU
1398 depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \ 1453 depends on DEBUG_LL_UART_8250 || DEBUG_LL_UART_PL01X || \
1399 DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \ 1454 DEBUG_UART_8250 || DEBUG_UART_PL01X || DEBUG_MESON_UARTAO || \
1400 DEBUG_MSM_UART || DEBUG_QCOM_UARTDM || DEBUG_S3C24XX_UART || \ 1455 DEBUG_MSM_UART || DEBUG_QCOM_UARTDM || DEBUG_S3C24XX_UART || \
1401 DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART 1456 DEBUG_UART_BCM63XX || DEBUG_ASM9260_UART || DEBUG_SIRFSOC_UART
1402 1457
1403config DEBUG_UART_8250_SHIFT 1458config DEBUG_UART_8250_SHIFT
1404 int "Register offset shift for the 8250 debug UART" 1459 int "Register offset shift for the 8250 debug UART"
diff --git a/arch/arm/boot/dts/armada-370-db.dts b/arch/arm/boot/dts/armada-370-db.dts
index 1466580be295..70b1943a86b1 100644
--- a/arch/arm/boot/dts/armada-370-db.dts
+++ b/arch/arm/boot/dts/armada-370-db.dts
@@ -203,27 +203,3 @@
203 compatible = "linux,spdif-dir"; 203 compatible = "linux,spdif-dir";
204 }; 204 };
205}; 205};
206
207&pinctrl {
208 /*
209 * These pins might be muxed as I2S by
210 * the bootloader, but it conflicts
211 * with the real I2S pins that are
212 * muxed using i2s_pins. We must mux
213 * those pins to a function other than
214 * I2S.
215 */
216 pinctrl-0 = <&hog_pins1 &hog_pins2>;
217 pinctrl-names = "default";
218
219 hog_pins1: hog-pins1 {
220 marvell,pins = "mpp6", "mpp8", "mpp10",
221 "mpp12", "mpp13";
222 marvell,function = "gpio";
223 };
224
225 hog_pins2: hog-pins2 {
226 marvell,pins = "mpp5", "mpp7", "mpp9";
227 marvell,function = "gpo";
228 };
229};
diff --git a/arch/arm/boot/dts/at91rm9200.dtsi b/arch/arm/boot/dts/at91rm9200.dtsi
index 6c97d4af61ee..21c2b504f977 100644
--- a/arch/arm/boot/dts/at91rm9200.dtsi
+++ b/arch/arm/boot/dts/at91rm9200.dtsi
@@ -66,6 +66,11 @@
66 }; 66 };
67 }; 67 };
68 68
69 sram: sram@00200000 {
70 compatible = "mmio-sram";
71 reg = <0x00200000 0x4000>;
72 };
73
69 ahb { 74 ahb {
70 compatible = "simple-bus"; 75 compatible = "simple-bus";
71 #address-cells = <1>; 76 #address-cells = <1>;
@@ -356,6 +361,13 @@
356 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>; 361 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
357 }; 362 };
358 363
364 rtc: rtc@fffffe00 {
365 compatible = "atmel,at91rm9200-rtc";
366 reg = <0xfffffe00 0x40>;
367 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
368 status = "disabled";
369 };
370
359 tcb0: timer@fffa0000 { 371 tcb0: timer@fffa0000 {
360 compatible = "atmel,at91rm9200-tcb"; 372 compatible = "atmel,at91rm9200-tcb";
361 reg = <0xfffa0000 0x100>; 373 reg = <0xfffa0000 0x100>;
diff --git a/arch/arm/boot/dts/at91rm9200ek.dts b/arch/arm/boot/dts/at91rm9200ek.dts
index 43eb779dd6f6..2a5d21247d7e 100644
--- a/arch/arm/boot/dts/at91rm9200ek.dts
+++ b/arch/arm/boot/dts/at91rm9200ek.dts
@@ -77,6 +77,10 @@
77 dbgu: serial@fffff200 { 77 dbgu: serial@fffff200 {
78 status = "okay"; 78 status = "okay";
79 }; 79 };
80
81 rtc: rtc@fffffe00 {
82 status = "okay";
83 };
80 }; 84 };
81 85
82 usb0: ohci@00300000 { 86 usb0: ohci@00300000 {
diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index dd1313cbc314..fff0ee69aab4 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -69,6 +69,11 @@
69 }; 69 };
70 }; 70 };
71 71
72 sram0: sram@002ff000 {
73 compatible = "mmio-sram";
74 reg = <0x002ff000 0x2000>;
75 };
76
72 ahb { 77 ahb {
73 compatible = "simple-bus"; 78 compatible = "simple-bus";
74 #address-cells = <1>; 79 #address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9261.dtsi b/arch/arm/boot/dts/at91sam9261.dtsi
index cdb9ed612109..e247b0b5fdab 100644
--- a/arch/arm/boot/dts/at91sam9261.dtsi
+++ b/arch/arm/boot/dts/at91sam9261.dtsi
@@ -60,6 +60,11 @@
60 }; 60 };
61 }; 61 };
62 62
63 sram: sram@00300000 {
64 compatible = "mmio-sram";
65 reg = <0x00300000 0x28000>;
66 };
67
63 ahb { 68 ahb {
64 compatible = "simple-bus"; 69 compatible = "simple-bus";
65 #address-cells = <1>; 70 #address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 1467750e3377..8a210d5033b1 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -62,6 +62,16 @@
62 }; 62 };
63 }; 63 };
64 64
65 sram0: sram@00300000 {
66 compatible = "mmio-sram";
67 reg = <0x00300000 0x14000>;
68 };
69
70 sram1: sram@00500000 {
71 compatible = "mmio-sram";
72 reg = <0x00300000 0x4000>;
73 };
74
65 ahb { 75 ahb {
66 compatible = "simple-bus"; 76 compatible = "simple-bus";
67 #address-cells = <1>; 77 #address-cells = <1>;
@@ -294,7 +304,7 @@
294 reg = <17>; 304 reg = <17>;
295 }; 305 };
296 306
297 ac91_clk: ac97_clk { 307 ac97_clk: ac97_clk {
298 #clock-cells = <0>; 308 #clock-cells = <0>;
299 reg = <18>; 309 reg = <18>;
300 }; 310 };
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index a50ee587a7af..f59301618163 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -16,6 +16,15 @@
16 reg = <0x20000000 0x08000000>; 16 reg = <0x20000000 0x08000000>;
17 }; 17 };
18 18
19 sram0: sram@002ff000 {
20 status = "disabled";
21 };
22
23 sram1: sram@002fc000 {
24 compatible = "mmio-sram";
25 reg = <0x002fc000 0x8000>;
26 };
27
19 ahb { 28 ahb {
20 apb { 29 apb {
21 i2c0: i2c@fffac000 { 30 i2c0: i2c@fffac000 {
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 2a8da8a884b4..ee80aa9c0759 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -74,6 +74,11 @@
74 }; 74 };
75 }; 75 };
76 76
77 sram: sram@00300000 {
78 compatible = "mmio-sram";
79 reg = <0x00300000 0x10000>;
80 };
81
77 ahb { 82 ahb {
78 compatible = "simple-bus"; 83 compatible = "simple-bus";
79 #address-cells = <1>; 84 #address-cells = <1>;
@@ -1287,7 +1292,6 @@
1287 compatible = "atmel,at91rm9200-ohci", "usb-ohci"; 1292 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
1288 reg = <0x00700000 0x100000>; 1293 reg = <0x00700000 0x100000>;
1289 interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; 1294 interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>;
1290 //TODO
1291 clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, <&uhpck>; 1295 clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, <&uhpck>;
1292 clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck"; 1296 clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck";
1293 status = "disabled"; 1297 status = "disabled";
@@ -1297,7 +1301,6 @@
1297 compatible = "atmel,at91sam9g45-ehci", "usb-ehci"; 1301 compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
1298 reg = <0x00800000 0x100000>; 1302 reg = <0x00800000 0x100000>;
1299 interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; 1303 interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>;
1300 //TODO
1301 clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, <&uhpck>; 1304 clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, <&uhpck>;
1302 clock-names = "usb_clk", "ehci_clk", "hclk", "uhpck"; 1305 clock-names = "usb_clk", "ehci_clk", "hclk", "uhpck";
1303 status = "disabled"; 1306 status = "disabled";
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index 68eb9aded164..c2666a7cb5b1 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -64,6 +64,11 @@
64 }; 64 };
65 }; 65 };
66 66
67 sram: sram@00300000 {
68 compatible = "mmio-sram";
69 reg = <0x00300000 0x8000>;
70 };
71
67 ahb { 72 ahb {
68 compatible = "simple-bus"; 73 compatible = "simple-bus";
69 #address-cells = <1>; 74 #address-cells = <1>;
@@ -893,6 +898,13 @@
893 status = "disabled"; 898 status = "disabled";
894 }; 899 };
895 900
901 rtc@fffffeb0 {
902 compatible = "atmel,at91rm9200-rtc";
903 reg = <0xfffffeb0 0x40>;
904 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
905 status = "disabled";
906 };
907
896 pwm0: pwm@f8034000 { 908 pwm0: pwm@f8034000 {
897 compatible = "atmel,at91sam9rl-pwm"; 909 compatible = "atmel,at91sam9rl-pwm";
898 reg = <0xf8034000 0x300>; 910 reg = <0xf8034000 0x300>;
diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi b/arch/arm/boot/dts/at91sam9rl.dtsi
index 72424371413e..40f645b8fe25 100644
--- a/arch/arm/boot/dts/at91sam9rl.dtsi
+++ b/arch/arm/boot/dts/at91sam9rl.dtsi
@@ -70,6 +70,11 @@
70 }; 70 };
71 }; 71 };
72 72
73 sram: sram@00300000 {
74 compatible = "mmio-sram";
75 reg = <0x00300000 0x10000>;
76 };
77
73 ahb { 78 ahb {
74 compatible = "simple-bus"; 79 compatible = "simple-bus";
75 #address-cells = <1>; 80 #address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index bbb3ba65165f..818dabdd8c0e 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -72,6 +72,11 @@
72 }; 72 };
73 }; 73 };
74 74
75 sram: sram@00300000 {
76 compatible = "mmio-sram";
77 reg = <0x00300000 0x8000>;
78 };
79
75 ahb { 80 ahb {
76 compatible = "simple-bus"; 81 compatible = "simple-bus";
77 #address-cells = <1>; 82 #address-cells = <1>;
diff --git a/arch/arm/boot/dts/at91sam9xe.dtsi b/arch/arm/boot/dts/at91sam9xe.dtsi
new file mode 100644
index 000000000000..0278f63b2daf
--- /dev/null
+++ b/arch/arm/boot/dts/at91sam9xe.dtsi
@@ -0,0 +1,60 @@
1/*
2 * at91sam9xe.dtsi - Device Tree Include file for AT91SAM9XE family SoC
3 *
4 * Copyright (C) 2015 Atmel,
5 * 2015 Alexandre Belloni <alexandre.Belloni@free-electrons.com>
6 *
7 * This file is dual-licensed: you can use it either under the terms
8 * of the GPL or the X11 license, at your option. Note that this dual
9 * licensing only applies to this file, and not this project as a
10 * whole.
11 *
12 * a) This file is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
16 *
17 * This file is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * Or, alternatively,
23 *
24 * b) Permission is hereby granted, free of charge, to any person
25 * obtaining a copy of this software and associated documentation
26 * files (the "Software"), to deal in the Software without
27 * restriction, including without limitation the rights to use,
28 * copy, modify, merge, publish, distribute, sublicense, and/or
29 * sell copies of the Software, and to permit persons to whom the
30 * Software is furnished to do so, subject to the following
31 * conditions:
32 *
33 * The above copyright notice and this permission notice shall be
34 * included in all copies or substantial portions of the Software.
35 *
36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
38 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
40 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 * OTHER DEALINGS IN THE SOFTWARE.
44 */
45
46#include "at91sam9260.dtsi"
47
48/ {
49 model = "Atmel AT91SAM9XE family SoC";
50 compatible = "atmel,at91sam9xe", "atmel,at91sam9260";
51
52 sram0: sram@002ff000 {
53 status = "disabled";
54 };
55
56 sram1: sram@00300000 {
57 compatible = "mmio-sram";
58 reg = <0x00300000 0x4000>;
59 };
60};
diff --git a/arch/arm/boot/dts/ethernut5.dts b/arch/arm/boot/dts/ethernut5.dts
index 8f941c2db7c6..243044343ee8 100644
--- a/arch/arm/boot/dts/ethernut5.dts
+++ b/arch/arm/boot/dts/ethernut5.dts
@@ -6,7 +6,7 @@
6 * Licensed under GPLv2. 6 * Licensed under GPLv2.
7 */ 7 */
8/dts-v1/; 8/dts-v1/;
9#include "at91sam9260.dtsi" 9#include "at91sam9xe.dtsi"
10 10
11/ { 11/ {
12 model = "Ethernut 5"; 12 model = "Ethernut 5";
diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi
index 5f4144d1e3a1..261311bdf65b 100644
--- a/arch/arm/boot/dts/sama5d3.dtsi
+++ b/arch/arm/boot/dts/sama5d3.dtsi
@@ -78,6 +78,11 @@
78 }; 78 };
79 }; 79 };
80 80
81 sram: sram@00300000 {
82 compatible = "mmio-sram";
83 reg = <0x00300000 0x20000>;
84 };
85
81 ahb { 86 ahb {
82 compatible = "simple-bus"; 87 compatible = "simple-bus";
83 #address-cells = <1>; 88 #address-cells = <1>;
@@ -214,7 +219,20 @@
214 compatible = "atmel,at91sam9g45-isi"; 219 compatible = "atmel,at91sam9g45-isi";
215 reg = <0xf0034000 0x4000>; 220 reg = <0xf0034000 0x4000>;
216 interrupts = <37 IRQ_TYPE_LEVEL_HIGH 5>; 221 interrupts = <37 IRQ_TYPE_LEVEL_HIGH 5>;
222 pinctrl-names = "default";
223 pinctrl-0 = <&pinctrl_isi_data_0_7>;
224 clocks = <&isi_clk>;
225 clock-names = "isi_clk";
217 status = "disabled"; 226 status = "disabled";
227 port {
228 #address-cells = <1>;
229 #size-cells = <0>;
230 };
231 };
232
233 sfr: sfr@f0038000 {
234 compatible = "atmel,sama5d3-sfr", "syscon";
235 reg = <0xf0038000 0x60>;
218 }; 236 };
219 237
220 mmc1: mmc@f8000000 { 238 mmc1: mmc@f8000000 {
@@ -545,7 +563,7 @@
545 }; 563 };
546 564
547 isi { 565 isi {
548 pinctrl_isi: isi-0 { 566 pinctrl_isi_data_0_7: isi-0-data-0-7 {
549 atmel,pins = 567 atmel,pins =
550 <AT91_PIOA 16 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA16 periph C ISI_D0, conflicts with LCDDAT16 */ 568 <AT91_PIOA 16 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA16 periph C ISI_D0, conflicts with LCDDAT16 */
551 AT91_PIOA 17 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA17 periph C ISI_D1, conflicts with LCDDAT17 */ 569 AT91_PIOA 17 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA17 periph C ISI_D1, conflicts with LCDDAT17 */
@@ -557,13 +575,19 @@
557 AT91_PIOA 23 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA23 periph C ISI_D7, conflicts with LCDDAT23, PWML1 */ 575 AT91_PIOA 23 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA23 periph C ISI_D7, conflicts with LCDDAT23, PWML1 */
558 AT91_PIOC 30 AT91_PERIPH_C AT91_PINCTRL_NONE /* PC30 periph C ISI_PCK, conflicts with UTXD0 */ 576 AT91_PIOC 30 AT91_PERIPH_C AT91_PINCTRL_NONE /* PC30 periph C ISI_PCK, conflicts with UTXD0 */
559 AT91_PIOA 31 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA31 periph C ISI_HSYNC, conflicts with TWCK0, UTXD1 */ 577 AT91_PIOA 31 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA31 periph C ISI_HSYNC, conflicts with TWCK0, UTXD1 */
560 AT91_PIOA 30 AT91_PERIPH_C AT91_PINCTRL_NONE /* PA30 periph C ISI_VSYNC, conflicts with TWD0, URXD1 */ 578 AT91_PIOA 30 AT91_PERIPH_C AT91_PINCTRL_NONE>; /* PA30 periph C ISI_VSYNC, conflicts with TWD0, URXD1 */
561 AT91_PIOC 29 AT91_PERIPH_C AT91_PINCTRL_NONE /* PC29 periph C ISI_PD8, conflicts with URXD0, PWMFI2 */ 579 };
580
581 pinctrl_isi_data_8_9: isi-0-data-8-9 {
582 atmel,pins =
583 <AT91_PIOC 29 AT91_PERIPH_C AT91_PINCTRL_NONE /* PC29 periph C ISI_PD8, conflicts with URXD0, PWMFI2 */
562 AT91_PIOC 28 AT91_PERIPH_C AT91_PINCTRL_NONE>; /* PC28 periph C ISI_PD9, conflicts with SPI1_NPCS3, PWMFI0 */ 584 AT91_PIOC 28 AT91_PERIPH_C AT91_PINCTRL_NONE>; /* PC28 periph C ISI_PD9, conflicts with SPI1_NPCS3, PWMFI0 */
563 }; 585 };
564 pinctrl_isi_pck_as_mck: isi_pck_as_mck-0 { 586
587 pinctrl_isi_data_10_11: isi-0-data-10-11 {
565 atmel,pins = 588 atmel,pins =
566 <AT91_PIOD 31 AT91_PERIPH_B AT91_PINCTRL_NONE>; /* PD31 periph B ISI_MCK */ 589 <AT91_PIOC 27 AT91_PERIPH_C AT91_PINCTRL_NONE /* PC27 periph C ISI_PD10, conflicts with SPI1_NPCS2, TWCK1 */
590 AT91_PIOC 26 AT91_PERIPH_C AT91_PINCTRL_NONE>; /* PC26 periph C ISI_PD11, conflicts with SPI1_NPCS1, TWD1 */
567 }; 591 };
568 }; 592 };
569 593
diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi b/arch/arm/boot/dts/sama5d3xcm.dtsi
index cfcd200b0c17..7d6babdab039 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -122,6 +122,7 @@
122 d2 { 122 d2 {
123 label = "d2"; 123 label = "d2";
124 gpios = <&pioE 25 GPIO_ACTIVE_LOW>; /* PE25, conflicts with A25, RXD2 */ 124 gpios = <&pioE 25 GPIO_ACTIVE_LOW>; /* PE25, conflicts with A25, RXD2 */
125 linux,default-trigger = "heartbeat";
125 }; 126 };
126 }; 127 };
127}; 128};
diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi
index 49c10d33df30..9fdb8a07b145 100644
--- a/arch/arm/boot/dts/sama5d3xmb.dtsi
+++ b/arch/arm/boot/dts/sama5d3xmb.dtsi
@@ -52,6 +52,29 @@
52 }; 52 };
53 }; 53 };
54 54
55 i2c1: i2c@f0018000 {
56 ov2640: camera@0x30 {
57 compatible = "ovti,ov2640";
58 reg = <0x30>;
59 pinctrl-names = "default";
60 pinctrl-0 = <&pinctrl_pck1_as_isi_mck &pinctrl_sensor_power &pinctrl_sensor_reset>;
61 resetb-gpios = <&pioE 24 GPIO_ACTIVE_LOW>;
62 pwdn-gpios = <&pioE 29 GPIO_ACTIVE_HIGH>;
63 /* use pck1 for the master clock of ov2640 */
64 clocks = <&pck1>;
65 clock-names = "xvclk";
66 assigned-clocks = <&pck1>;
67 assigned-clock-rates = <25000000>;
68
69 port {
70 ov2640_0: endpoint {
71 remote-endpoint = <&isi_0>;
72 bus-width = <8>;
73 };
74 };
75 };
76 };
77
55 usart1: serial@f0020000 { 78 usart1: serial@f0020000 {
56 dmas = <0>, <0>; /* Do not use DMA for usart1 */ 79 dmas = <0>, <0>; /* Do not use DMA for usart1 */
57 pinctrl-names = "default"; 80 pinctrl-names = "default";
@@ -60,8 +83,12 @@
60 }; 83 };
61 84
62 isi: isi@f0034000 { 85 isi: isi@f0034000 {
63 pinctrl-names = "default"; 86 port {
64 pinctrl-0 = <&pinctrl_isi &pinctrl_isi_pck_as_mck &pinctrl_isi_power &pinctrl_isi_reset>; 87 isi_0: endpoint {
88 remote-endpoint = <&ov2640_0>;
89 bus-width = <8>;
90 };
91 };
65 }; 92 };
66 93
67 mmc1: mmc@f8000000 { 94 mmc1: mmc@f8000000 {
@@ -117,12 +144,17 @@
117 <AT91_PIOD 30 AT91_PERIPH_B AT91_PINCTRL_NONE>; /* PD30 periph B */ 144 <AT91_PIOD 30 AT91_PERIPH_B AT91_PINCTRL_NONE>; /* PD30 periph B */
118 }; 145 };
119 146
120 pinctrl_isi_reset: isi_reset-0 { 147 pinctrl_pck1_as_isi_mck: pck1_as_isi_mck-0 {
148 atmel,pins =
149 <AT91_PIOD 31 AT91_PERIPH_B AT91_PINCTRL_NONE>; /* PD31 periph B ISI_MCK */
150 };
151
152 pinctrl_sensor_reset: sensor_reset-0 {
121 atmel,pins = 153 atmel,pins =
122 <AT91_PIOE 24 AT91_PERIPH_GPIO AT91_PINCTRL_NONE>; /* PE24 gpio */ 154 <AT91_PIOE 24 AT91_PERIPH_GPIO AT91_PINCTRL_NONE>; /* PE24 gpio */
123 }; 155 };
124 156
125 pinctrl_isi_power: isi_power-0 { 157 pinctrl_sensor_power: sensor_power-0 {
126 atmel,pins = 158 atmel,pins =
127 <AT91_PIOE 29 AT91_PERIPH_GPIO AT91_PINCTRL_NONE>; /* PE29 gpio */ 159 <AT91_PIOE 29 AT91_PERIPH_GPIO AT91_PINCTRL_NONE>; /* PE29 gpio */
128 }; 160 };
diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
index 1b0f30c2c4a5..1b4fe4e19721 100644
--- a/arch/arm/boot/dts/sama5d4.dtsi
+++ b/arch/arm/boot/dts/sama5d4.dtsi
@@ -103,6 +103,11 @@
103 }; 103 };
104 }; 104 };
105 105
106 ns_sram: sram@00210000 {
107 compatible = "mmio-sram";
108 reg = <0x00210000 0x10000>;
109 };
110
106 ahb { 111 ahb {
107 compatible = "simple-bus"; 112 compatible = "simple-bus";
108 #address-cells = <1>; 113 #address-cells = <1>;
@@ -870,6 +875,11 @@
870 status = "disabled"; 875 status = "disabled";
871 }; 876 };
872 877
878 sfr: sfr@f8028000 {
879 compatible = "atmel,sama5d4-sfr", "syscon";
880 reg = <0xf8028000 0x60>;
881 };
882
873 mmc1: mmc@fc000000 { 883 mmc1: mmc@fc000000 {
874 compatible = "atmel,hsmci"; 884 compatible = "atmel,hsmci";
875 reg = <0xfc000000 0x600>; 885 reg = <0xfc000000 0x600>;
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 2328fe752e9c..bc393b7e5ece 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -338,6 +338,7 @@ CONFIG_USB=y
338CONFIG_USB_XHCI_HCD=y 338CONFIG_USB_XHCI_HCD=y
339CONFIG_USB_XHCI_MVEBU=y 339CONFIG_USB_XHCI_MVEBU=y
340CONFIG_USB_EHCI_HCD=y 340CONFIG_USB_EHCI_HCD=y
341CONFIG_USB_EHCI_EXYNOS=y
341CONFIG_USB_EHCI_TEGRA=y 342CONFIG_USB_EHCI_TEGRA=y
342CONFIG_USB_EHCI_HCD_STI=y 343CONFIG_USB_EHCI_HCD_STI=y
343CONFIG_USB_EHCI_HCD_PLATFORM=y 344CONFIG_USB_EHCI_HCD_PLATFORM=y
diff --git a/arch/arm/mach-at91/include/mach/debug-macro.S b/arch/arm/include/debug/at91.S
index 2103a90f2261..80a6501b4d50 100644
--- a/arch/arm/mach-at91/include/mach/debug-macro.S
+++ b/arch/arm/include/debug/at91.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/debug-macro.S
3 *
4 * Copyright (C) 2003-2005 SAN People 2 * Copyright (C) 2003-2005 SAN People
5 * 3 *
6 * Debugging macro include header 4 * Debugging macro include header
@@ -11,18 +9,23 @@
11 * 9 *
12*/ 10*/
13 11
14#include <mach/hardware.h>
15#include <mach/at91_dbgu.h>
16
17#if defined(CONFIG_AT91_DEBUG_LL_DBGU0) 12#if defined(CONFIG_AT91_DEBUG_LL_DBGU0)
18#define AT91_DBGU AT91_BASE_DBGU0 13#define AT91_DBGU 0xfffff200 /* AT91_BASE_DBGU0 */
19#elif defined(CONFIG_AT91_DEBUG_LL_DBGU1) 14#elif defined(CONFIG_AT91_DEBUG_LL_DBGU1)
20#define AT91_DBGU AT91_BASE_DBGU1 15#define AT91_DBGU 0xffffee00 /* AT91_BASE_DBGU1 */
21#else 16#else
22/* On sama5d4, use USART3 as low level serial console */ 17/* On sama5d4, use USART3 as low level serial console */
23#define AT91_DBGU SAMA5D4_BASE_USART3 18#define AT91_DBGU 0xfc00c000 /* SAMA5D4_BASE_USART3 */
24#endif 19#endif
25 20
21/* Keep in sync with mach-at91/include/mach/hardware.h */
22#define AT91_IO_P2V(x) ((x) - 0x01000000)
23
24#define AT91_DBGU_SR (0x14) /* Status Register */
25#define AT91_DBGU_THR (0x1c) /* Transmitter Holding Register */
26#define AT91_DBGU_TXRDY (1 << 1) /* Transmitter Ready */
27#define AT91_DBGU_TXEMPTY (1 << 9) /* Transmitter Empty */
28
26 .macro addruart, rp, rv, tmp 29 .macro addruart, rp, rv, tmp
27 ldr \rp, =AT91_DBGU @ System peripherals (phys address) 30 ldr \rp, =AT91_DBGU @ System peripherals (phys address)
28 ldr \rv, =AT91_IO_P2V(AT91_DBGU) @ System peripherals (virt address) 31 ldr \rv, =AT91_IO_P2V(AT91_DBGU) @ System peripherals (virt address)
diff --git a/arch/arm/include/debug/sirf.S b/arch/arm/include/debug/sirf.S
index dbf250cf18e6..630f231f2f37 100644
--- a/arch/arm/include/debug/sirf.S
+++ b/arch/arm/include/debug/sirf.S
@@ -6,37 +6,33 @@
6 * Licensed under GPLv2 or later. 6 * Licensed under GPLv2 or later.
7 */ 7 */
8 8
9#if defined(CONFIG_DEBUG_SIRFPRIMA2_UART1) 9#define SIRF_LLUART_TXFIFO_STATUS 0x0114
10#define SIRFSOC_UART1_PA_BASE 0xb0060000 10#define SIRF_LLUART_TXFIFO_DATA 0x0118
11#elif defined(CONFIG_DEBUG_SIRFMARCO_UART1)
12#define SIRFSOC_UART1_PA_BASE 0xcc060000
13#else
14#define SIRFSOC_UART1_PA_BASE 0
15#endif
16 11
17#define SIRFSOC_UART1_VA_BASE 0xFEC60000 12#define SIRF_LLUART_TXFIFO_FULL (1 << 5)
18 13
19#define SIRFSOC_UART_TXFIFO_STATUS 0x0114 14#ifdef CONFIG_DEBUG_SIRFATLAS7_UART0
20#define SIRFSOC_UART_TXFIFO_DATA 0x0118 15#define SIRF_LLUART_TXFIFO_EMPTY (1 << 8)
16#else
17#define SIRF_LLUART_TXFIFO_EMPTY (1 << 6)
18#endif
21 19
22#define SIRFSOC_UART1_TXFIFO_FULL (1 << 5)
23#define SIRFSOC_UART1_TXFIFO_EMPTY (1 << 6)
24 20
25 .macro addruart, rp, rv, tmp 21 .macro addruart, rp, rv, tmp
26 ldr \rp, =SIRFSOC_UART1_PA_BASE @ physical 22 ldr \rp, =CONFIG_DEBUG_UART_PHYS @ physical
27 ldr \rv, =SIRFSOC_UART1_VA_BASE @ virtual 23 ldr \rv, =CONFIG_DEBUG_UART_VIRT @ virtual
28 .endm 24 .endm
29 25
30 .macro senduart,rd,rx 26 .macro senduart,rd,rx
31 str \rd, [\rx, #SIRFSOC_UART_TXFIFO_DATA] 27 str \rd, [\rx, #SIRF_LLUART_TXFIFO_DATA]
32 .endm 28 .endm
33 29
34 .macro busyuart,rd,rx 30 .macro busyuart,rd,rx
35 .endm 31 .endm
36 32
37 .macro waituart,rd,rx 33 .macro waituart,rd,rx
381001: ldr \rd, [\rx, #SIRFSOC_UART_TXFIFO_STATUS] 341001: ldr \rd, [\rx, #SIRF_LLUART_TXFIFO_STATUS]
39 tst \rd, #SIRFSOC_UART1_TXFIFO_EMPTY 35 tst \rd, #SIRF_LLUART_TXFIFO_EMPTY
40 beq 1001b 36 beq 1001b
41 .endm 37 .endm
42 38
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index 705bb7620673..0c3f5a0dafd3 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -413,6 +413,7 @@
413#define __NR_getrandom (__NR_SYSCALL_BASE+384) 413#define __NR_getrandom (__NR_SYSCALL_BASE+384)
414#define __NR_memfd_create (__NR_SYSCALL_BASE+385) 414#define __NR_memfd_create (__NR_SYSCALL_BASE+385)
415#define __NR_bpf (__NR_SYSCALL_BASE+386) 415#define __NR_bpf (__NR_SYSCALL_BASE+386)
416#define __NR_execveat (__NR_SYSCALL_BASE+387)
416 417
417/* 418/*
418 * The following SWIs are ARM private. 419 * The following SWIs are ARM private.
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index e51833f8cc38..05745eb838c5 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -396,6 +396,7 @@
396 CALL(sys_getrandom) 396 CALL(sys_getrandom)
397/* 385 */ CALL(sys_memfd_create) 397/* 385 */ CALL(sys_memfd_create)
398 CALL(sys_bpf) 398 CALL(sys_bpf)
399 CALL(sys_execveat)
399#ifndef syscalls_counted 400#ifndef syscalls_counted
400.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 401.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
401#define syscalls_counted 402#define syscalls_counted
diff --git a/arch/arm/kernel/perf_regs.c b/arch/arm/kernel/perf_regs.c
index 6e4379c67cbc..592dda3f21ff 100644
--- a/arch/arm/kernel/perf_regs.c
+++ b/arch/arm/kernel/perf_regs.c
@@ -28,3 +28,11 @@ u64 perf_reg_abi(struct task_struct *task)
28{ 28{
29 return PERF_SAMPLE_REGS_ABI_32; 29 return PERF_SAMPLE_REGS_ABI_32;
30} 30}
31
32void perf_get_regs_user(struct perf_regs *regs_user,
33 struct pt_regs *regs,
34 struct pt_regs *regs_user_copy)
35{
36 regs_user->regs = task_pt_regs(current);
37 regs_user->abi = perf_reg_abi(current);
38}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index f9c863911038..715ae19bc7c8 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1046,6 +1046,15 @@ static int c_show(struct seq_file *m, void *v)
1046 seq_printf(m, "model name\t: %s rev %d (%s)\n", 1046 seq_printf(m, "model name\t: %s rev %d (%s)\n",
1047 cpu_name, cpuid & 15, elf_platform); 1047 cpu_name, cpuid & 15, elf_platform);
1048 1048
1049#if defined(CONFIG_SMP)
1050 seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
1051 per_cpu(cpu_data, i).loops_per_jiffy / (500000UL/HZ),
1052 (per_cpu(cpu_data, i).loops_per_jiffy / (5000UL/HZ)) % 100);
1053#else
1054 seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
1055 loops_per_jiffy / (500000/HZ),
1056 (loops_per_jiffy / (5000/HZ)) % 100);
1057#endif
1049 /* dump out the processor features */ 1058 /* dump out the processor features */
1050 seq_puts(m, "Features\t: "); 1059 seq_puts(m, "Features\t: ");
1051 1060
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 5e6052e18850..86ef244c5a24 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -387,6 +387,18 @@ asmlinkage void secondary_start_kernel(void)
387 387
388void __init smp_cpus_done(unsigned int max_cpus) 388void __init smp_cpus_done(unsigned int max_cpus)
389{ 389{
390 int cpu;
391 unsigned long bogosum = 0;
392
393 for_each_online_cpu(cpu)
394 bogosum += per_cpu(cpu_data, cpu).loops_per_jiffy;
395
396 printk(KERN_INFO "SMP: Total of %d processors activated "
397 "(%lu.%02lu BogoMIPS).\n",
398 num_online_cpus(),
399 bogosum / (500000/HZ),
400 (bogosum / (5000/HZ)) % 100);
401
390 hyp_mode_check(); 402 hyp_mode_check();
391} 403}
392 404
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 2395c68b3e32..b7dcef50db23 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -174,18 +174,11 @@ config SOC_AT91SAM9N12
174# ---------------------------------------------------------- 174# ----------------------------------------------------------
175endif # SOC_SAM_V4_V5 175endif # SOC_SAM_V4_V5
176 176
177config MACH_AT91RM9200_DT
178 def_bool SOC_AT91RM9200
179
180config MACH_AT91SAM9_DT
181 def_bool SOC_AT91SAM9
182
183# ----------------------------------------------------------
184
185comment "AT91 Feature Selections" 177comment "AT91 Feature Selections"
186 178
187config AT91_SLOW_CLOCK 179config AT91_SLOW_CLOCK
188 bool "Suspend-to-RAM disables main oscillator" 180 bool "Suspend-to-RAM disables main oscillator"
181 select SRAM
189 depends on SUSPEND 182 depends on SUSPEND
190 help 183 help
191 Select this if you want Suspend-to-RAM to save the most power 184 Select this if you want Suspend-to-RAM to save the most power
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 7b6424d40764..8ef7d9a2e855 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := setup.o sysirq_mask.o 5obj-y := setup.o
6 6
7obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o 7obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o
8 8
@@ -19,8 +19,8 @@ obj-$(CONFIG_SOC_SAMA5D3) += sama5d3.o
19obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o 19obj-$(CONFIG_SOC_SAMA5D4) += sama5d4.o
20 20
21# AT91SAM board with device-tree 21# AT91SAM board with device-tree
22obj-$(CONFIG_MACH_AT91RM9200_DT) += board-dt-rm9200.o 22obj-$(CONFIG_SOC_AT91RM9200) += board-dt-rm9200.o
23obj-$(CONFIG_MACH_AT91SAM9_DT) += board-dt-sam9.o 23obj-$(CONFIG_SOC_AT91SAM9) += board-dt-sam9.o
24 24
25# SAMA5 board with device-tree 25# SAMA5 board with device-tree
26obj-$(CONFIG_SOC_SAMA5) += board-dt-sama5.o 26obj-$(CONFIG_SOC_SAMA5) += board-dt-sama5.o
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index b52916947535..3be1963f5c56 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -21,14 +21,6 @@
21#include "soc.h" 21#include "soc.h"
22#include "generic.h" 22#include "generic.h"
23 23
24static void at91rm9200_idle(void)
25{
26 /*
27 * Disable the processor clock. The processor will be automatically
28 * re-enabled by an interrupt or by a reset.
29 */
30 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
31}
32 24
33static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd) 25static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
34{ 26{
@@ -42,11 +34,6 @@ static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
42/* -------------------------------------------------------------------- 34/* --------------------------------------------------------------------
43 * AT91RM9200 processor initialization 35 * AT91RM9200 processor initialization
44 * -------------------------------------------------------------------- */ 36 * -------------------------------------------------------------------- */
45static void __init at91rm9200_map_io(void)
46{
47 /* Map peripherals */
48 at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE);
49}
50 37
51static void __init at91rm9200_initialize(void) 38static void __init at91rm9200_initialize(void)
52{ 39{
@@ -54,8 +41,6 @@ static void __init at91rm9200_initialize(void)
54 arm_pm_restart = at91rm9200_restart; 41 arm_pm_restart = at91rm9200_restart;
55} 42}
56 43
57
58AT91_SOC_START(at91rm9200) 44AT91_SOC_START(at91rm9200)
59 .map_io = at91rm9200_map_io,
60 .init = at91rm9200_initialize, 45 .init = at91rm9200_initialize,
61AT91_SOC_END 46AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 78137c24d90b..ab9841c8b0d5 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -22,40 +22,11 @@
22 * AT91SAM9260 processor initialization 22 * AT91SAM9260 processor initialization
23 * -------------------------------------------------------------------- */ 23 * -------------------------------------------------------------------- */
24 24
25static void __init at91sam9xe_map_io(void)
26{
27 unsigned long sram_size;
28
29 switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {
30 case AT91_CIDR_SRAMSIZ_32K:
31 sram_size = 2 * SZ_16K;
32 break;
33 case AT91_CIDR_SRAMSIZ_16K:
34 default:
35 sram_size = SZ_16K;
36 }
37
38 at91_init_sram(0, AT91SAM9XE_SRAM_BASE, sram_size);
39}
40
41static void __init at91sam9260_map_io(void)
42{
43 if (cpu_is_at91sam9xe())
44 at91sam9xe_map_io();
45 else if (cpu_is_at91sam9g20())
46 at91_init_sram(0, AT91SAM9G20_SRAM_BASE, AT91SAM9G20_SRAM_SIZE);
47 else
48 at91_init_sram(0, AT91SAM9260_SRAM_BASE, AT91SAM9260_SRAM_SIZE);
49}
50
51static void __init at91sam9260_initialize(void) 25static void __init at91sam9260_initialize(void)
52{ 26{
53 arm_pm_idle = at91sam9_idle; 27 arm_pm_idle = at91sam9_idle;
54
55 at91_sysirq_mask_rtt(AT91SAM9260_BASE_RTT);
56} 28}
57 29
58AT91_SOC_START(at91sam9260) 30AT91_SOC_START(at91sam9260)
59 .map_io = at91sam9260_map_io,
60 .init = at91sam9260_initialize, 31 .init = at91sam9260_initialize,
61AT91_SOC_END 32AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index d29953ecb0c4..2029096b93fa 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -21,22 +21,11 @@
21 * AT91SAM9261 processor initialization 21 * AT91SAM9261 processor initialization
22 * -------------------------------------------------------------------- */ 22 * -------------------------------------------------------------------- */
23 23
24static void __init at91sam9261_map_io(void)
25{
26 if (cpu_is_at91sam9g10())
27 at91_init_sram(0, AT91SAM9G10_SRAM_BASE, AT91SAM9G10_SRAM_SIZE);
28 else
29 at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE);
30}
31
32static void __init at91sam9261_initialize(void) 24static void __init at91sam9261_initialize(void)
33{ 25{
34 arm_pm_idle = at91sam9_idle; 26 arm_pm_idle = at91sam9_idle;
35
36 at91_sysirq_mask_rtt(AT91SAM9261_BASE_RTT);
37} 27}
38 28
39AT91_SOC_START(at91sam9261) 29AT91_SOC_START(at91sam9261)
40 .map_io = at91sam9261_map_io,
41 .init = at91sam9261_initialize, 30 .init = at91sam9261_initialize,
42AT91_SOC_END 31AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index e7ad14864083..1fe672a05513 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -20,21 +20,11 @@
20 * AT91SAM9263 processor initialization 20 * AT91SAM9263 processor initialization
21 * -------------------------------------------------------------------- */ 21 * -------------------------------------------------------------------- */
22 22
23static void __init at91sam9263_map_io(void)
24{
25 at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE);
26 at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE);
27}
28
29static void __init at91sam9263_initialize(void) 23static void __init at91sam9263_initialize(void)
30{ 24{
31 arm_pm_idle = at91sam9_idle; 25 arm_pm_idle = at91sam9_idle;
32
33 at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT0);
34 at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT1);
35} 26}
36 27
37AT91_SOC_START(at91sam9263) 28AT91_SOC_START(at91sam9263)
38 .map_io = at91sam9263_map_io,
39 .init = at91sam9263_initialize, 29 .init = at91sam9263_initialize,
40AT91_SOC_END 30AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index b6117bea9a6f..d0493df40a13 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -11,7 +11,6 @@
11 */ 11 */
12 12
13#include <asm/system_misc.h> 13#include <asm/system_misc.h>
14#include <asm/irq.h>
15#include <mach/hardware.h> 14#include <mach/hardware.h>
16 15
17#include "soc.h" 16#include "soc.h"
@@ -20,21 +19,11 @@
20/* -------------------------------------------------------------------- 19/* --------------------------------------------------------------------
21 * AT91SAM9G45 processor initialization 20 * AT91SAM9G45 processor initialization
22 * -------------------------------------------------------------------- */ 21 * -------------------------------------------------------------------- */
23
24static void __init at91sam9g45_map_io(void)
25{
26 at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE);
27}
28
29static void __init at91sam9g45_initialize(void) 22static void __init at91sam9g45_initialize(void)
30{ 23{
31 arm_pm_idle = at91sam9_idle; 24 arm_pm_idle = at91sam9_idle;
32
33 at91_sysirq_mask_rtc(AT91SAM9G45_BASE_RTC);
34 at91_sysirq_mask_rtt(AT91SAM9G45_BASE_RTT);
35} 25}
36 26
37AT91_SOC_START(at91sam9g45) 27AT91_SOC_START(at91sam9g45)
38 .map_io = at91sam9g45_map_io,
39 .init = at91sam9g45_initialize, 28 .init = at91sam9g45_initialize,
40AT91_SOC_END 29AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index dee569b1987e..b5ea69a3eaf6 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -16,17 +16,5 @@
16 * AT91SAM9N12 processor initialization 16 * AT91SAM9N12 processor initialization
17 * -------------------------------------------------------------------- */ 17 * -------------------------------------------------------------------- */
18 18
19static void __init at91sam9n12_map_io(void)
20{
21 at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
22}
23
24static void __init at91sam9n12_initialize(void)
25{
26 at91_sysirq_mask_rtc(AT91SAM9N12_BASE_RTC);
27}
28
29AT91_SOC_START(at91sam9n12) 19AT91_SOC_START(at91sam9n12)
30 .map_io = at91sam9n12_map_io,
31 .init = at91sam9n12_initialize,
32AT91_SOC_END 20AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index f25b9aec9c50..33acae30bb0b 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <asm/system_misc.h> 12#include <asm/system_misc.h>
13#include <asm/irq.h>
14#include <mach/cpu.h> 13#include <mach/cpu.h>
15#include <mach/at91_dbgu.h> 14#include <mach/at91_dbgu.h>
16#include <mach/hardware.h> 15#include <mach/hardware.h>
@@ -22,32 +21,11 @@
22 * AT91SAM9RL processor initialization 21 * AT91SAM9RL processor initialization
23 * -------------------------------------------------------------------- */ 22 * -------------------------------------------------------------------- */
24 23
25static void __init at91sam9rl_map_io(void)
26{
27 unsigned long sram_size;
28
29 switch (at91_soc_initdata.cidr & AT91_CIDR_SRAMSIZ) {
30 case AT91_CIDR_SRAMSIZ_32K:
31 sram_size = 2 * SZ_16K;
32 break;
33 case AT91_CIDR_SRAMSIZ_16K:
34 default:
35 sram_size = SZ_16K;
36 }
37
38 /* Map SRAM */
39 at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size);
40}
41
42static void __init at91sam9rl_initialize(void) 24static void __init at91sam9rl_initialize(void)
43{ 25{
44 arm_pm_idle = at91sam9_idle; 26 arm_pm_idle = at91sam9_idle;
45
46 at91_sysirq_mask_rtc(AT91SAM9RL_BASE_RTC);
47 at91_sysirq_mask_rtt(AT91SAM9RL_BASE_RTT);
48} 27}
49 28
50AT91_SOC_START(at91sam9rl) 29AT91_SOC_START(at91sam9rl)
51 .map_io = at91sam9rl_map_io,
52 .init = at91sam9rl_initialize, 30 .init = at91sam9rl_initialize,
53AT91_SOC_END 31AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index f0d5a69a7237..7b60a529db01 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -16,21 +16,5 @@
16 * AT91SAM9x5 processor initialization 16 * AT91SAM9x5 processor initialization
17 * -------------------------------------------------------------------- */ 17 * -------------------------------------------------------------------- */
18 18
19static void __init at91sam9x5_map_io(void)
20{
21 at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
22}
23
24static void __init at91sam9x5_initialize(void)
25{
26 at91_sysirq_mask_rtc(AT91SAM9X5_BASE_RTC);
27}
28
29/* --------------------------------------------------------------------
30 * Interrupt initialization
31 * -------------------------------------------------------------------- */
32
33AT91_SOC_START(at91sam9x5) 19AT91_SOC_START(at91sam9x5)
34 .map_io = at91sam9x5_map_io,
35 .init = at91sam9x5_initialize,
36AT91_SOC_END 20AT91_SOC_END
diff --git a/arch/arm/mach-at91/board-dt-rm9200.c b/arch/arm/mach-at91/board-dt-rm9200.c
index 76dfe8f9af50..5f82a65153e1 100644
--- a/arch/arm/mach-at91/board-dt-rm9200.c
+++ b/arch/arm/mach-at91/board-dt-rm9200.c
@@ -14,6 +14,7 @@
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_irq.h> 16#include <linux/of_irq.h>
17#include <linux/of_platform.h>
17#include <linux/clk-provider.h> 18#include <linux/clk-provider.h>
18 19
19#include <asm/setup.h> 20#include <asm/setup.h>
@@ -30,6 +31,15 @@ static void __init at91rm9200_dt_timer_init(void)
30 at91rm9200_timer_init(); 31 at91rm9200_timer_init();
31} 32}
32 33
34static void __init rm9200_dt_device_init(void)
35{
36 at91_rm9200_pm_init();
37
38 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
39}
40
41
42
33static const char *at91rm9200_dt_board_compat[] __initdata = { 43static const char *at91rm9200_dt_board_compat[] __initdata = {
34 "atmel,at91rm9200", 44 "atmel,at91rm9200",
35 NULL 45 NULL
@@ -38,6 +48,7 @@ static const char *at91rm9200_dt_board_compat[] __initdata = {
38DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200 (Device Tree)") 48DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200 (Device Tree)")
39 .init_time = at91rm9200_dt_timer_init, 49 .init_time = at91rm9200_dt_timer_init,
40 .map_io = at91_map_io, 50 .map_io = at91_map_io,
41 .init_early = at91rm9200_dt_initialize, 51 .init_early = at91_dt_initialize,
52 .init_machine = rm9200_dt_device_init,
42 .dt_compat = at91rm9200_dt_board_compat, 53 .dt_compat = at91rm9200_dt_board_compat,
43MACHINE_END 54MACHINE_END
diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c
index f99246aa9b38..0fe1ced608c5 100644
--- a/arch/arm/mach-at91/board-dt-sam9.c
+++ b/arch/arm/mach-at91/board-dt-sam9.c
@@ -13,6 +13,7 @@
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <linux/of.h> 14#include <linux/of.h>
15#include <linux/of_irq.h> 15#include <linux/of_irq.h>
16#include <linux/of_platform.h>
16#include <linux/clk-provider.h> 17#include <linux/clk-provider.h>
17 18
18#include <asm/setup.h> 19#include <asm/setup.h>
@@ -23,6 +24,12 @@
23 24
24#include "generic.h" 25#include "generic.h"
25 26
27static void __init sam9_dt_device_init(void)
28{
29 at91_sam9260_pm_init();
30 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
31}
32
26static const char *at91_dt_board_compat[] __initdata = { 33static const char *at91_dt_board_compat[] __initdata = {
27 "atmel,at91sam9", 34 "atmel,at91sam9",
28 NULL 35 NULL
@@ -32,5 +39,25 @@ DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
32 /* Maintainer: Atmel */ 39 /* Maintainer: Atmel */
33 .map_io = at91_map_io, 40 .map_io = at91_map_io,
34 .init_early = at91_dt_initialize, 41 .init_early = at91_dt_initialize,
42 .init_machine = sam9_dt_device_init,
35 .dt_compat = at91_dt_board_compat, 43 .dt_compat = at91_dt_board_compat,
36MACHINE_END 44MACHINE_END
45
46static void __init sam9g45_dt_device_init(void)
47{
48 at91_sam9g45_pm_init();
49 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
50}
51
52static const char *at91_9g45_board_compat[] __initconst = {
53 "atmel,at91sam9g45",
54 NULL
55};
56
57DT_MACHINE_START(at91sam9g45_dt, "Atmel AT91SAM9G45")
58 /* Maintainer: Atmel */
59 .map_io = at91_map_io,
60 .init_early = at91_dt_initialize,
61 .init_machine = sam9g45_dt_device_init,
62 .dt_compat = at91_9g45_board_compat,
63MACHINE_END
diff --git a/arch/arm/mach-at91/board-dt-sama5.c b/arch/arm/mach-at91/board-dt-sama5.c
index 8fb9ef5333f1..44d372a22a29 100644
--- a/arch/arm/mach-at91/board-dt-sama5.c
+++ b/arch/arm/mach-at91/board-dt-sama5.c
@@ -28,6 +28,7 @@
28 28
29static void __init sama5_dt_device_init(void) 29static void __init sama5_dt_device_init(void)
30{ 30{
31 at91_sam9260_pm_init();
31 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 32 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
32} 33}
33 34
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index d53324210adf..44fc725edcf1 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -17,24 +17,29 @@
17 /* Map io */ 17 /* Map io */
18extern void __init at91_map_io(void); 18extern void __init at91_map_io(void);
19extern void __init at91_alt_map_io(void); 19extern void __init at91_alt_map_io(void);
20extern void __init at91_init_sram(int bank, unsigned long base,
21 unsigned int length);
22 20
23 /* Processors */ 21 /* Processors */
24extern void __init at91rm9200_set_type(int type);
25extern void __init at91rm9200_dt_initialize(void);
26extern void __init at91_dt_initialize(void); 22extern void __init at91_dt_initialize(void);
27 23
28 /* Interrupts */
29extern void __init at91_sysirq_mask_rtc(u32 rtc_base);
30extern void __init at91_sysirq_mask_rtt(u32 rtt_base);
31
32 /* Timer */ 24 /* Timer */
33extern void at91rm9200_timer_init(void); 25extern void at91rm9200_timer_init(void);
34 26
35/* idle */ 27/* idle */
28extern void at91rm9200_idle(void);
36extern void at91sam9_idle(void); 29extern void at91sam9_idle(void);
37 30
38/* Matrix */ 31/* Matrix */
39extern void at91_ioremap_matrix(u32 base_addr); 32extern void at91_ioremap_matrix(u32 base_addr);
33
34
35#ifdef CONFIG_PM
36extern void __init at91_rm9200_pm_init(void);
37extern void __init at91_sam9260_pm_init(void);
38extern void __init at91_sam9g45_pm_init(void);
39#else
40void __init at91_rm9200_pm_init(void) { }
41void __init at91_sam9260_pm_init(void) { }
42void __init at91_sam9g45_pm_init(void) { }
43#endif
44
40#endif /* _AT91_GENERIC_H */ 45#endif /* _AT91_GENERIC_H */
diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h
deleted file mode 100644
index 7b7366253ceb..000000000000
--- a/arch/arm/mach-at91/include/mach/at91_pio.h
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_pio.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Parallel I/O Controller (PIO) - System peripherals registers.
8 * Based on AT91RM9200 datasheet revision E.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91_PIO_H
17#define AT91_PIO_H
18
19#define PIO_PER 0x00 /* Enable Register */
20#define PIO_PDR 0x04 /* Disable Register */
21#define PIO_PSR 0x08 /* Status Register */
22#define PIO_OER 0x10 /* Output Enable Register */
23#define PIO_ODR 0x14 /* Output Disable Register */
24#define PIO_OSR 0x18 /* Output Status Register */
25#define PIO_IFER 0x20 /* Glitch Input Filter Enable */
26#define PIO_IFDR 0x24 /* Glitch Input Filter Disable */
27#define PIO_IFSR 0x28 /* Glitch Input Filter Status */
28#define PIO_SODR 0x30 /* Set Output Data Register */
29#define PIO_CODR 0x34 /* Clear Output Data Register */
30#define PIO_ODSR 0x38 /* Output Data Status Register */
31#define PIO_PDSR 0x3c /* Pin Data Status Register */
32#define PIO_IER 0x40 /* Interrupt Enable Register */
33#define PIO_IDR 0x44 /* Interrupt Disable Register */
34#define PIO_IMR 0x48 /* Interrupt Mask Register */
35#define PIO_ISR 0x4c /* Interrupt Status Register */
36#define PIO_MDER 0x50 /* Multi-driver Enable Register */
37#define PIO_MDDR 0x54 /* Multi-driver Disable Register */
38#define PIO_MDSR 0x58 /* Multi-driver Status Register */
39#define PIO_PUDR 0x60 /* Pull-up Disable Register */
40#define PIO_PUER 0x64 /* Pull-up Enable Register */
41#define PIO_PUSR 0x68 /* Pull-up Status Register */
42#define PIO_ASR 0x70 /* Peripheral A Select Register */
43#define PIO_ABCDSR1 0x70 /* Peripheral ABCD Select Register 1 [some sam9 only] */
44#define PIO_BSR 0x74 /* Peripheral B Select Register */
45#define PIO_ABCDSR2 0x74 /* Peripheral ABCD Select Register 2 [some sam9 only] */
46#define PIO_ABSR 0x78 /* AB Status Register */
47#define PIO_IFSCDR 0x80 /* Input Filter Slow Clock Disable Register */
48#define PIO_IFSCER 0x84 /* Input Filter Slow Clock Enable Register */
49#define PIO_IFSCSR 0x88 /* Input Filter Slow Clock Status Register */
50#define PIO_SCDR 0x8c /* Slow Clock Divider Debouncing Register */
51#define PIO_SCDR_DIV (0x3fff << 0) /* Slow Clock Divider Mask */
52#define PIO_PPDDR 0x90 /* Pad Pull-down Disable Register */
53#define PIO_PPDER 0x94 /* Pad Pull-down Enable Register */
54#define PIO_PPDSR 0x98 /* Pad Pull-down Status Register */
55#define PIO_OWER 0xa0 /* Output Write Enable Register */
56#define PIO_OWDR 0xa4 /* Output Write Disable Register */
57#define PIO_OWSR 0xa8 /* Output Write Status Register */
58#define PIO_AIMER 0xb0 /* Additional Interrupt Modes Enable Register */
59#define PIO_AIMDR 0xb4 /* Additional Interrupt Modes Disable Register */
60#define PIO_AIMMR 0xb8 /* Additional Interrupt Modes Mask Register */
61#define PIO_ESR 0xc0 /* Edge Select Register */
62#define PIO_LSR 0xc4 /* Level Select Register */
63#define PIO_ELSR 0xc8 /* Edge/Level Status Register */
64#define PIO_FELLSR 0xd0 /* Falling Edge/Low Level Select Register */
65#define PIO_REHLSR 0xd4 /* Rising Edge/ High Level Select Register */
66#define PIO_FRLHSR 0xd8 /* Fall/Rise - Low/High Status Register */
67#define PIO_SCHMITT 0x100 /* Schmitt Trigger Register */
68
69#define ABCDSR_PERIPH_A 0x0
70#define ABCDSR_PERIPH_B 0x1
71#define ABCDSR_PERIPH_C 0x2
72#define ABCDSR_PERIPH_D 0x3
73
74#define SAMA5D3_PIO_DRIVER1 0x118 /*PIO Driver 1 register offset*/
75#define SAMA5D3_PIO_DRIVER2 0x11C /*PIO Driver 2 register offset*/
76
77#define AT91SAM9X5_PIO_DRIVER1 0x114 /*PIO Driver 1 register offset*/
78#define AT91SAM9X5_PIO_DRIVER2 0x118 /*PIO Driver 2 register offset*/
79
80#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_rtt.h b/arch/arm/mach-at91/include/mach/at91_rtt.h
deleted file mode 100644
index 7ec75de8bbb6..000000000000
--- a/arch/arm/mach-at91/include/mach/at91_rtt.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_rtt.h
3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
7 * Real-time Timer (RTT) - System peripherals regsters.
8 * Based on AT91SAM9261 datasheet revision D.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91_RTT_H
17#define AT91_RTT_H
18
19#define AT91_RTT_MR 0x00 /* Real-time Mode Register */
20#define AT91_RTT_RTPRES (0xffff << 0) /* Real-time Timer Prescaler Value */
21#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */
22#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */
23#define AT91_RTT_RTTRST (1 << 18) /* Real Time Timer Restart */
24
25#define AT91_RTT_AR 0x04 /* Real-time Alarm Register */
26#define AT91_RTT_ALMV (0xffffffff) /* Alarm Value */
27
28#define AT91_RTT_VR 0x08 /* Real-time Value Register */
29#define AT91_RTT_CRTV (0xffffffff) /* Current Real-time Value */
30
31#define AT91_RTT_SR 0x0c /* Real-time Status Register */
32#define AT91_RTT_ALMS (1 << 0) /* Real-time Alarm Status */
33#define AT91_RTT_RTTINC (1 << 1) /* Real-time Timer Increment */
34
35#endif
diff --git a/arch/arm/mach-at91/include/mach/memory.h b/arch/arm/mach-at91/include/mach/memory.h
deleted file mode 100644
index 401c207f2f39..000000000000
--- a/arch/arm/mach-at91/include/mach/memory.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/memory.h
3 *
4 * Copyright (C) 2004 SAN People
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __ASM_ARCH_MEMORY_H
22#define __ASM_ARCH_MEMORY_H
23
24#include <mach/hardware.h>
25
26#endif
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 9b15169a1c62..81f2f12d3cc1 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -14,9 +14,12 @@
14#include <linux/suspend.h> 14#include <linux/suspend.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
17#include <linux/genalloc.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/sysfs.h> 19#include <linux/sysfs.h>
19#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/of.h>
22#include <linux/of_platform.h>
20#include <linux/platform_device.h> 23#include <linux/platform_device.h>
21#include <linux/io.h> 24#include <linux/io.h>
22#include <linux/clk/at91_pmc.h> 25#include <linux/clk/at91_pmc.h>
@@ -32,6 +35,11 @@
32#include "generic.h" 35#include "generic.h"
33#include "pm.h" 36#include "pm.h"
34 37
38static struct {
39 unsigned long uhp_udp_mask;
40 int memctrl;
41} at91_pm_data;
42
35static void (*at91_pm_standby)(void); 43static void (*at91_pm_standby)(void);
36 44
37static int at91_pm_valid_state(suspend_state_t state) 45static int at91_pm_valid_state(suspend_state_t state)
@@ -71,17 +79,9 @@ static int at91_pm_verify_clocks(void)
71 scsr = at91_pmc_read(AT91_PMC_SCSR); 79 scsr = at91_pmc_read(AT91_PMC_SCSR);
72 80
73 /* USB must not be using PLLB */ 81 /* USB must not be using PLLB */
74 if (cpu_is_at91rm9200()) { 82 if ((scsr & at91_pm_data.uhp_udp_mask) != 0) {
75 if ((scsr & (AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP)) != 0) { 83 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
76 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); 84 return 0;
77 return 0;
78 }
79 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()
80 || cpu_is_at91sam9g20() || cpu_is_at91sam9g10()) {
81 if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
82 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
83 return 0;
84 }
85 } 85 }
86 86
87 /* PCK0..PCK3 must be disabled, or configured to use clk32k */ 87 /* PCK0..PCK3 must be disabled, or configured to use clk32k */
@@ -149,18 +149,13 @@ static int at91_pm_enter(suspend_state_t state)
149 * turning off the main oscillator; reverse on wakeup. 149 * turning off the main oscillator; reverse on wakeup.
150 */ 150 */
151 if (slow_clock) { 151 if (slow_clock) {
152 int memctrl = AT91_MEMCTRL_SDRAMC;
153
154 if (cpu_is_at91rm9200())
155 memctrl = AT91_MEMCTRL_MC;
156 else if (cpu_is_at91sam9g45())
157 memctrl = AT91_MEMCTRL_DDRSDR;
158#ifdef CONFIG_AT91_SLOW_CLOCK 152#ifdef CONFIG_AT91_SLOW_CLOCK
159 /* copy slow_clock handler to SRAM, and call it */ 153 /* copy slow_clock handler to SRAM, and call it */
160 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz); 154 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
161#endif 155#endif
162 slow_clock(at91_pmc_base, at91_ramc_base[0], 156 slow_clock(at91_pmc_base, at91_ramc_base[0],
163 at91_ramc_base[1], memctrl); 157 at91_ramc_base[1],
158 at91_pm_data.memctrl);
164 break; 159 break;
165 } else { 160 } else {
166 pr_info("AT91: PM - no slow clock mode enabled ...\n"); 161 pr_info("AT91: PM - no slow clock mode enabled ...\n");
@@ -229,23 +224,85 @@ void at91_pm_set_standby(void (*at91_standby)(void))
229 } 224 }
230} 225}
231 226
232static int __init at91_pm_init(void) 227#ifdef CONFIG_AT91_SLOW_CLOCK
228static void __init at91_pm_sram_init(void)
229{
230 struct gen_pool *sram_pool;
231 phys_addr_t sram_pbase;
232 unsigned long sram_base;
233 struct device_node *node;
234 struct platform_device *pdev;
235
236 node = of_find_compatible_node(NULL, NULL, "mmio-sram");
237 if (!node) {
238 pr_warn("%s: failed to find sram node!\n", __func__);
239 return;
240 }
241
242 pdev = of_find_device_by_node(node);
243 if (!pdev) {
244 pr_warn("%s: failed to find sram device!\n", __func__);
245 goto put_node;
246 }
247
248 sram_pool = dev_get_gen_pool(&pdev->dev);
249 if (!sram_pool) {
250 pr_warn("%s: sram pool unavailable!\n", __func__);
251 goto put_node;
252 }
253
254 sram_base = gen_pool_alloc(sram_pool, at91_slow_clock_sz);
255 if (!sram_base) {
256 pr_warn("%s: unable to alloc ocram!\n", __func__);
257 goto put_node;
258 }
259
260 sram_pbase = gen_pool_virt_to_phys(sram_pool, sram_base);
261 slow_clock = __arm_ioremap_exec(sram_pbase, at91_slow_clock_sz, false);
262
263put_node:
264 of_node_put(node);
265}
266#endif
267
268
269static void __init at91_pm_init(void)
233{ 270{
234#ifdef CONFIG_AT91_SLOW_CLOCK 271#ifdef CONFIG_AT91_SLOW_CLOCK
235 slow_clock = (void *) (AT91_IO_VIRT_BASE - at91_slow_clock_sz); 272 at91_pm_sram_init();
236#endif 273#endif
237 274
238 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); 275 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
239 276
240 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
241 if (cpu_is_at91rm9200())
242 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
243
244 if (at91_cpuidle_device.dev.platform_data) 277 if (at91_cpuidle_device.dev.platform_data)
245 platform_device_register(&at91_cpuidle_device); 278 platform_device_register(&at91_cpuidle_device);
246 279
247 suspend_set_ops(&at91_pm_ops); 280 suspend_set_ops(&at91_pm_ops);
281}
248 282
249 return 0; 283void __init at91_rm9200_pm_init(void)
284{
285 /*
286 * AT91RM9200 SDRAM low-power mode cannot be used with self-refresh.
287 */
288 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
289
290 at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP;
291 at91_pm_data.memctrl = AT91_MEMCTRL_MC;
292
293 at91_pm_init();
294}
295
296void __init at91_sam9260_pm_init(void)
297{
298 at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC;
299 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP;
300 return at91_pm_init();
301}
302
303void __init at91_sam9g45_pm_init(void)
304{
305 at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP;
306 at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR;
307 return at91_pm_init();
250} 308}
251arch_initcall(at91_pm_init);
diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
index 3d775d08de08..b7c64ca7107f 100644
--- a/arch/arm/mach-at91/sama5d3.c
+++ b/arch/arm/mach-at91/sama5d3.c
@@ -25,17 +25,5 @@
25 * AT91SAM9x5 processor initialization 25 * AT91SAM9x5 processor initialization
26 * -------------------------------------------------------------------- */ 26 * -------------------------------------------------------------------- */
27 27
28static void __init sama5d3_map_io(void)
29{
30 at91_init_sram(0, SAMA5D3_SRAM_BASE, SAMA5D3_SRAM_SIZE);
31}
32
33static void __init sama5d3_initialize(void)
34{
35 at91_sysirq_mask_rtc(SAMA5D3_BASE_RTC);
36}
37
38AT91_SOC_START(sama5d3) 28AT91_SOC_START(sama5d3)
39 .map_io = sama5d3_map_io,
40 .init = sama5d3_initialize,
41AT91_SOC_END 29AT91_SOC_END
diff --git a/arch/arm/mach-at91/sama5d4.c b/arch/arm/mach-at91/sama5d4.c
index 7638509639f4..fa127fb79221 100644
--- a/arch/arm/mach-at91/sama5d4.c
+++ b/arch/arm/mach-at91/sama5d4.c
@@ -56,7 +56,6 @@ static struct map_desc at91_io_desc[] __initdata = {
56static void __init sama5d4_map_io(void) 56static void __init sama5d4_map_io(void)
57{ 57{
58 iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc)); 58 iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc));
59 at91_init_sram(0, SAMA5D4_NS_SRAM_BASE, SAMA5D4_NS_SRAM_SIZE);
60} 59}
61 60
62AT91_SOC_START(sama5d4) 61AT91_SOC_START(sama5d4)
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index ce25e85720fb..4c184285d38f 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -31,40 +31,9 @@ struct at91_init_soc __initdata at91_boot_soc;
31struct at91_socinfo at91_soc_initdata; 31struct at91_socinfo at91_soc_initdata;
32EXPORT_SYMBOL(at91_soc_initdata); 32EXPORT_SYMBOL(at91_soc_initdata);
33 33
34void __init at91rm9200_set_type(int type)
35{
36 if (type == ARCH_REVISON_9200_PQFP)
37 at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP;
38 else
39 at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
40
41 pr_info("filled in soc subtype: %s\n",
42 at91_get_soc_subtype(&at91_soc_initdata));
43}
44
45void __iomem *at91_ramc_base[2]; 34void __iomem *at91_ramc_base[2];
46EXPORT_SYMBOL_GPL(at91_ramc_base); 35EXPORT_SYMBOL_GPL(at91_ramc_base);
47 36
48static struct map_desc sram_desc[2] __initdata;
49
50void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
51{
52 struct map_desc *desc = &sram_desc[bank];
53
54 desc->virtual = (unsigned long)AT91_IO_VIRT_BASE - length;
55 if (bank > 0)
56 desc->virtual -= sram_desc[bank - 1].length;
57
58 desc->pfn = __phys_to_pfn(base);
59 desc->length = length;
60 desc->type = MT_MEMORY_RWX_NONCACHED;
61
62 pr_info("sram at 0x%lx of 0x%x mapped at 0x%lx\n",
63 base, length, desc->virtual);
64
65 iotable_init(desc, 1);
66}
67
68static struct map_desc at91_io_desc __initdata __maybe_unused = { 37static struct map_desc at91_io_desc __initdata __maybe_unused = {
69 .virtual = (unsigned long)AT91_VA_BASE_SYS, 38 .virtual = (unsigned long)AT91_VA_BASE_SYS,
70 .pfn = __phys_to_pfn(AT91_BASE_SYS), 39 .pfn = __phys_to_pfn(AT91_BASE_SYS),
@@ -429,13 +398,6 @@ static void at91_dt_ramc(void)
429 at91_pm_set_standby(standby); 398 at91_pm_set_standby(standby);
430} 399}
431 400
432void __init at91rm9200_dt_initialize(void)
433{
434 at91_dt_ramc();
435
436 at91_boot_soc.init();
437}
438
439void __init at91_dt_initialize(void) 401void __init at91_dt_initialize(void)
440{ 402{
441 at91_dt_ramc(); 403 at91_dt_ramc();
diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c
deleted file mode 100644
index f8bc3511a8c8..000000000000
--- a/arch/arm/mach-at91/sysirq_mask.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * sysirq_mask.c - System-interrupt masking
3 *
4 * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
5 *
6 * Functions to disable system interrupts from backup-powered peripherals.
7 *
8 * The RTC and RTT-peripherals are generally powered by backup power (VDDBU)
9 * and are not reset on wake-up, user, watchdog or software reset. This means
10 * that their interrupts may be enabled during early boot (e.g. after a user
11 * reset).
12 *
13 * As the RTC and RTT share the system-interrupt line with the PIT, an
14 * interrupt occurring before a handler has been installed would lead to the
15 * system interrupt being disabled and prevent the system from booting.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 */
22
23#include <linux/io.h>
24#include <mach/at91_rtt.h>
25
26#include "generic.h"
27
28#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
29#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
30#define AT91_RTC_IRQ_MASK 0x1f /* Available IRQs mask */
31
32void __init at91_sysirq_mask_rtc(u32 rtc_base)
33{
34 void __iomem *base;
35
36 base = ioremap(rtc_base, 64);
37 if (!base)
38 return;
39
40 /*
41 * sam9x5 SoCs have the following errata:
42 * "RTC: Interrupt Mask Register cannot be used
43 * Interrupt Mask Register read always returns 0."
44 *
45 * Hence we're not relying on IMR values to disable
46 * interrupts.
47 */
48 writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR);
49 (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */
50
51 iounmap(base);
52}
53
54void __init at91_sysirq_mask_rtt(u32 rtt_base)
55{
56 void __iomem *base;
57 void __iomem *reg;
58 u32 mode;
59
60 base = ioremap(rtt_base, 16);
61 if (!base)
62 return;
63
64 reg = base + AT91_RTT_MR;
65
66 mode = readl_relaxed(reg);
67 if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
68 pr_info("AT91: Disabling rtt irq\n");
69 mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
70 writel_relaxed(mode, reg);
71 (void)readl_relaxed(reg); /* flush */
72 }
73
74 iounmap(base);
75}
diff --git a/arch/arm/mach-bcm/platsmp-brcmstb.c b/arch/arm/mach-bcm/platsmp-brcmstb.c
index 31c87a284a34..e209e6fc7caf 100644
--- a/arch/arm/mach-bcm/platsmp-brcmstb.c
+++ b/arch/arm/mach-bcm/platsmp-brcmstb.c
@@ -17,6 +17,7 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/jiffies.h>
20#include <linux/of_address.h> 21#include <linux/of_address.h>
21#include <linux/of_platform.h> 22#include <linux/of_platform.h>
22#include <linux/printk.h> 23#include <linux/printk.h>
@@ -94,10 +95,35 @@ static u32 pwr_ctrl_rd(u32 cpu)
94 return readl_relaxed(base); 95 return readl_relaxed(base);
95} 96}
96 97
97static void pwr_ctrl_wr(u32 cpu, u32 val) 98static void pwr_ctrl_set(unsigned int cpu, u32 val, u32 mask)
98{ 99{
99 void __iomem *base = pwr_ctrl_get_base(cpu); 100 void __iomem *base = pwr_ctrl_get_base(cpu);
100 writel(val, base); 101 writel((readl(base) & mask) | val, base);
102}
103
104static void pwr_ctrl_clr(unsigned int cpu, u32 val, u32 mask)
105{
106 void __iomem *base = pwr_ctrl_get_base(cpu);
107 writel((readl(base) & mask) & ~val, base);
108}
109
110#define POLL_TMOUT_MS 500
111static int pwr_ctrl_wait_tmout(unsigned int cpu, u32 set, u32 mask)
112{
113 const unsigned long timeo = jiffies + msecs_to_jiffies(POLL_TMOUT_MS);
114 u32 tmp;
115
116 do {
117 tmp = pwr_ctrl_rd(cpu) & mask;
118 if (!set == !tmp)
119 return 0;
120 } while (time_before(jiffies, timeo));
121
122 tmp = pwr_ctrl_rd(cpu) & mask;
123 if (!set == !tmp)
124 return 0;
125
126 return -ETIMEDOUT;
101} 127}
102 128
103static void cpu_rst_cfg_set(u32 cpu, int set) 129static void cpu_rst_cfg_set(u32 cpu, int set)
@@ -139,15 +165,22 @@ static void brcmstb_cpu_power_on(u32 cpu)
139 * The secondary cores power was cut, so we must go through 165 * The secondary cores power was cut, so we must go through
140 * power-on initialization. 166 * power-on initialization.
141 */ 167 */
142 u32 tmp; 168 pwr_ctrl_set(cpu, ZONE_MAN_ISO_CNTL_MASK, 0xffffff00);
169 pwr_ctrl_set(cpu, ZONE_MANUAL_CONTROL_MASK, -1);
170 pwr_ctrl_set(cpu, ZONE_RESERVED_1_MASK, -1);
143 171
144 /* Request zone power up */ 172 pwr_ctrl_set(cpu, ZONE_MAN_MEM_PWR_MASK, -1);
145 pwr_ctrl_wr(cpu, ZONE_PWR_UP_REQ_MASK);
146 173
147 /* Wait for the power up FSM to complete */ 174 if (pwr_ctrl_wait_tmout(cpu, 1, ZONE_MEM_PWR_STATE_MASK))
148 do { 175 panic("ZONE_MEM_PWR_STATE_MASK set timeout");
149 tmp = pwr_ctrl_rd(cpu); 176
150 } while (!(tmp & ZONE_PWR_ON_STATE_MASK)); 177 pwr_ctrl_set(cpu, ZONE_MAN_CLKEN_MASK, -1);
178
179 if (pwr_ctrl_wait_tmout(cpu, 1, ZONE_DPG_PWR_STATE_MASK))
180 panic("ZONE_DPG_PWR_STATE_MASK set timeout");
181
182 pwr_ctrl_clr(cpu, ZONE_MAN_ISO_CNTL_MASK, -1);
183 pwr_ctrl_set(cpu, ZONE_MAN_RESET_CNTL_MASK, -1);
151} 184}
152 185
153static int brcmstb_cpu_get_power_state(u32 cpu) 186static int brcmstb_cpu_get_power_state(u32 cpu)
@@ -174,25 +207,33 @@ static void brcmstb_cpu_die(u32 cpu)
174 207
175static int brcmstb_cpu_kill(u32 cpu) 208static int brcmstb_cpu_kill(u32 cpu)
176{ 209{
177 u32 tmp; 210 /*
211 * Ordinarily, the hardware forbids power-down of CPU0 (which is good
212 * because it is the boot CPU), but this is not true when using BPCM
213 * manual mode. Consequently, we must avoid turning off CPU0 here to
214 * ensure that TI2C master reset will work.
215 */
216 if (cpu == 0) {
217 pr_warn("SMP: refusing to power off CPU0\n");
218 return 1;
219 }
178 220
179 while (per_cpu_sw_state_rd(cpu)) 221 while (per_cpu_sw_state_rd(cpu))
180 ; 222 ;
181 223
182 /* Program zone reset */ 224 pwr_ctrl_set(cpu, ZONE_MANUAL_CONTROL_MASK, -1);
183 pwr_ctrl_wr(cpu, ZONE_RESET_STATE_MASK | ZONE_BLK_RST_ASSERT_MASK | 225 pwr_ctrl_clr(cpu, ZONE_MAN_RESET_CNTL_MASK, -1);
184 ZONE_PWR_DN_REQ_MASK); 226 pwr_ctrl_clr(cpu, ZONE_MAN_CLKEN_MASK, -1);
227 pwr_ctrl_set(cpu, ZONE_MAN_ISO_CNTL_MASK, -1);
228 pwr_ctrl_clr(cpu, ZONE_MAN_MEM_PWR_MASK, -1);
185 229
186 /* Verify zone reset */ 230 if (pwr_ctrl_wait_tmout(cpu, 0, ZONE_MEM_PWR_STATE_MASK))
187 tmp = pwr_ctrl_rd(cpu); 231 panic("ZONE_MEM_PWR_STATE_MASK clear timeout");
188 if (!(tmp & ZONE_RESET_STATE_MASK))
189 pr_err("%s: Zone reset bit for CPU %d not asserted!\n",
190 __func__, cpu);
191 232
192 /* Wait for power down */ 233 pwr_ctrl_clr(cpu, ZONE_RESERVED_1_MASK, -1);
193 do { 234
194 tmp = pwr_ctrl_rd(cpu); 235 if (pwr_ctrl_wait_tmout(cpu, 0, ZONE_DPG_PWR_STATE_MASK))
195 } while (!(tmp & ZONE_PWR_OFF_STATE_MASK)); 236 panic("ZONE_DPG_PWR_STATE_MASK clear timeout");
196 237
197 /* Flush pipeline before resetting CPU */ 238 /* Flush pipeline before resetting CPU */
198 mb(); 239 mb();
diff --git a/arch/arm/mach-hisi/Kconfig b/arch/arm/mach-hisi/Kconfig
index cd19433f76d3..83061ad0e282 100644
--- a/arch/arm/mach-hisi/Kconfig
+++ b/arch/arm/mach-hisi/Kconfig
@@ -22,6 +22,14 @@ config ARCH_HI3xxx
22 help 22 help
23 Support for Hisilicon Hi36xx SoC family 23 Support for Hisilicon Hi36xx SoC family
24 24
25config ARCH_HIP01
26 bool "Hisilicon HIP01 family" if ARCH_MULTI_V7
27 select HAVE_ARM_SCU if SMP
28 select HAVE_ARM_TWD if SMP
29 select ARM_GLOBAL_TIMER
30 help
31 Support for Hisilicon HIP01 SoC family
32
25config ARCH_HIP04 33config ARCH_HIP04
26 bool "Hisilicon HiP04 Cortex A15 family" if ARCH_MULTI_V7 34 bool "Hisilicon HiP04 Cortex A15 family" if ARCH_MULTI_V7
27 select ARM_ERRATA_798181 if SMP 35 select ARM_ERRATA_798181 if SMP
diff --git a/arch/arm/mach-hisi/core.h b/arch/arm/mach-hisi/core.h
index 88b1f487d065..92a682d8e939 100644
--- a/arch/arm/mach-hisi/core.h
+++ b/arch/arm/mach-hisi/core.h
@@ -12,9 +12,12 @@ extern void hi3xxx_cpu_die(unsigned int cpu);
12extern int hi3xxx_cpu_kill(unsigned int cpu); 12extern int hi3xxx_cpu_kill(unsigned int cpu);
13extern void hi3xxx_set_cpu(int cpu, bool enable); 13extern void hi3xxx_set_cpu(int cpu, bool enable);
14 14
15extern void hix5hd2_secondary_startup(void); 15extern void hisi_secondary_startup(void);
16extern struct smp_operations hix5hd2_smp_ops; 16extern struct smp_operations hix5hd2_smp_ops;
17extern void hix5hd2_set_cpu(int cpu, bool enable); 17extern void hix5hd2_set_cpu(int cpu, bool enable);
18extern void hix5hd2_cpu_die(unsigned int cpu); 18extern void hix5hd2_cpu_die(unsigned int cpu);
19 19
20extern struct smp_operations hip01_smp_ops;
21extern void hip01_set_cpu(int cpu, bool enable);
22extern void hip01_cpu_die(unsigned int cpu);
20#endif 23#endif
diff --git a/arch/arm/mach-hisi/headsmp.S b/arch/arm/mach-hisi/headsmp.S
index 278889c00b77..81e35b159e75 100644
--- a/arch/arm/mach-hisi/headsmp.S
+++ b/arch/arm/mach-hisi/headsmp.S
@@ -11,6 +11,6 @@
11 11
12 __CPUINIT 12 __CPUINIT
13 13
14ENTRY(hix5hd2_secondary_startup) 14ENTRY(hisi_secondary_startup)
15 bl v7_invalidate_l1 15 bl v7_invalidate_l1
16 b secondary_startup 16 b secondary_startup
diff --git a/arch/arm/mach-hisi/hisilicon.c b/arch/arm/mach-hisi/hisilicon.c
index 7744c351bbfd..76b907078b58 100644
--- a/arch/arm/mach-hisi/hisilicon.c
+++ b/arch/arm/mach-hisi/hisilicon.c
@@ -72,3 +72,13 @@ static const char *hip04_compat[] __initconst = {
72DT_MACHINE_START(HIP04, "Hisilicon HiP04 (Flattened Device Tree)") 72DT_MACHINE_START(HIP04, "Hisilicon HiP04 (Flattened Device Tree)")
73 .dt_compat = hip04_compat, 73 .dt_compat = hip04_compat,
74MACHINE_END 74MACHINE_END
75
76static const char *hip01_compat[] __initconst = {
77 "hisilicon,hip01",
78 "hisilicon,hip01-ca9x2",
79 NULL,
80};
81
82DT_MACHINE_START(HIP01, "Hisilicon HIP01 (Flattened Device Tree)")
83 .dt_compat = hip01_compat,
84MACHINE_END
diff --git a/arch/arm/mach-hisi/hotplug.c b/arch/arm/mach-hisi/hotplug.c
index 84e6919f68c7..a129aae72602 100644
--- a/arch/arm/mach-hisi/hotplug.c
+++ b/arch/arm/mach-hisi/hotplug.c
@@ -65,6 +65,9 @@
65#define PMC0_CPU1_PMC_ENABLE (1 << 7) 65#define PMC0_CPU1_PMC_ENABLE (1 << 7)
66#define PMC0_CPU1_POWERDOWN (1 << 3) 66#define PMC0_CPU1_POWERDOWN (1 << 3)
67 67
68#define HIP01_PERI9 0x50
69#define PERI9_CPU1_RESET (1 << 1)
70
68enum { 71enum {
69 HI3620_CTRL, 72 HI3620_CTRL,
70 ERROR_CTRL, 73 ERROR_CTRL,
@@ -209,6 +212,34 @@ void hix5hd2_set_cpu(int cpu, bool enable)
209 } 212 }
210} 213}
211 214
215void hip01_set_cpu(int cpu, bool enable)
216{
217 unsigned int temp;
218 struct device_node *np;
219
220 if (!ctrl_base) {
221 np = of_find_compatible_node(NULL, NULL, "hisilicon,hip01-sysctrl");
222 if (np)
223 ctrl_base = of_iomap(np, 0);
224 else
225 BUG();
226 }
227
228 if (enable) {
229 /* reset on CPU1 */
230 temp = readl_relaxed(ctrl_base + HIP01_PERI9);
231 temp |= PERI9_CPU1_RESET;
232 writel_relaxed(temp, ctrl_base + HIP01_PERI9);
233
234 udelay(50);
235
236 /* unreset on CPU1 */
237 temp = readl_relaxed(ctrl_base + HIP01_PERI9);
238 temp &= ~PERI9_CPU1_RESET;
239 writel_relaxed(temp, ctrl_base + HIP01_PERI9);
240 }
241}
242
212static inline void cpu_enter_lowpower(void) 243static inline void cpu_enter_lowpower(void)
213{ 244{
214 unsigned int v; 245 unsigned int v;
diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c
index 575dd8285f1f..8880c8e8b296 100644
--- a/arch/arm/mach-hisi/platsmp.c
+++ b/arch/arm/mach-hisi/platsmp.c
@@ -10,10 +10,12 @@
10#include <linux/smp.h> 10#include <linux/smp.h>
11#include <linux/io.h> 11#include <linux/io.h>
12#include <linux/of_address.h> 12#include <linux/of_address.h>
13#include <linux/delay.h>
13 14
14#include <asm/cacheflush.h> 15#include <asm/cacheflush.h>
15#include <asm/smp_plat.h> 16#include <asm/smp_plat.h>
16#include <asm/smp_scu.h> 17#include <asm/smp_scu.h>
18#include <asm/mach/map.h>
17 19
18#include "core.h" 20#include "core.h"
19 21
@@ -96,7 +98,7 @@ struct smp_operations hi3xxx_smp_ops __initdata = {
96#endif 98#endif
97}; 99};
98 100
99static void __init hix5hd2_smp_prepare_cpus(unsigned int max_cpus) 101static void __init hisi_common_smp_prepare_cpus(unsigned int max_cpus)
100{ 102{
101 hisi_enable_scu_a9(); 103 hisi_enable_scu_a9();
102} 104}
@@ -116,7 +118,7 @@ static int hix5hd2_boot_secondary(unsigned int cpu, struct task_struct *idle)
116{ 118{
117 phys_addr_t jumpaddr; 119 phys_addr_t jumpaddr;
118 120
119 jumpaddr = virt_to_phys(hix5hd2_secondary_startup); 121 jumpaddr = virt_to_phys(hisi_secondary_startup);
120 hix5hd2_set_scu_boot_addr(HIX5HD2_BOOT_ADDRESS, jumpaddr); 122 hix5hd2_set_scu_boot_addr(HIX5HD2_BOOT_ADDRESS, jumpaddr);
121 hix5hd2_set_cpu(cpu, true); 123 hix5hd2_set_cpu(cpu, true);
122 arch_send_wakeup_ipi_mask(cpumask_of(cpu)); 124 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
@@ -125,12 +127,60 @@ static int hix5hd2_boot_secondary(unsigned int cpu, struct task_struct *idle)
125 127
126 128
127struct smp_operations hix5hd2_smp_ops __initdata = { 129struct smp_operations hix5hd2_smp_ops __initdata = {
128 .smp_prepare_cpus = hix5hd2_smp_prepare_cpus, 130 .smp_prepare_cpus = hisi_common_smp_prepare_cpus,
129 .smp_boot_secondary = hix5hd2_boot_secondary, 131 .smp_boot_secondary = hix5hd2_boot_secondary,
130#ifdef CONFIG_HOTPLUG_CPU 132#ifdef CONFIG_HOTPLUG_CPU
131 .cpu_die = hix5hd2_cpu_die, 133 .cpu_die = hix5hd2_cpu_die,
132#endif 134#endif
133}; 135};
134 136
137
138#define SC_SCTL_REMAP_CLR 0x00000100
139#define HIP01_BOOT_ADDRESS 0x80000000
140#define REG_SC_CTRL 0x000
141
142void hip01_set_boot_addr(phys_addr_t start_addr, phys_addr_t jump_addr)
143{
144 void __iomem *virt;
145
146 virt = phys_to_virt(start_addr);
147
148 writel_relaxed(0xe51ff004, virt);
149 writel_relaxed(jump_addr, virt + 4);
150}
151
152static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)
153{
154 phys_addr_t jumpaddr;
155 unsigned int remap_reg_value = 0;
156 struct device_node *node;
157
158
159 jumpaddr = virt_to_phys(hisi_secondary_startup);
160 hip01_set_boot_addr(HIP01_BOOT_ADDRESS, jumpaddr);
161
162 node = of_find_compatible_node(NULL, NULL, "hisilicon,hip01-sysctrl");
163 if (WARN_ON(!node))
164 return -1;
165 ctrl_base = of_iomap(node, 0);
166
167 /* set the secondary core boot from DDR */
168 remap_reg_value = readl_relaxed(ctrl_base + REG_SC_CTRL);
169 barrier();
170 remap_reg_value |= SC_SCTL_REMAP_CLR;
171 barrier();
172 writel_relaxed(remap_reg_value, ctrl_base + REG_SC_CTRL);
173
174 hip01_set_cpu(cpu, true);
175
176 return 0;
177}
178
179struct smp_operations hip01_smp_ops __initdata = {
180 .smp_prepare_cpus = hisi_common_smp_prepare_cpus,
181 .smp_boot_secondary = hip01_boot_secondary,
182};
183
135CPU_METHOD_OF_DECLARE(hi3xxx_smp, "hisilicon,hi3620-smp", &hi3xxx_smp_ops); 184CPU_METHOD_OF_DECLARE(hi3xxx_smp, "hisilicon,hi3620-smp", &hi3xxx_smp_ops);
136CPU_METHOD_OF_DECLARE(hix5hd2_smp, "hisilicon,hix5hd2-smp", &hix5hd2_smp_ops); 185CPU_METHOD_OF_DECLARE(hix5hd2_smp, "hisilicon,hix5hd2-smp", &hix5hd2_smp_ops);
186CPU_METHOD_OF_DECLARE(hip01_smp, "hisilicon,hip01-smp", &hip01_smp_ops);
diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.h b/arch/arm/mach-mvebu/mvebu-soc-id.h
index c16bb68ca81f..e124a0b82a3e 100644
--- a/arch/arm/mach-mvebu/mvebu-soc-id.h
+++ b/arch/arm/mach-mvebu/mvebu-soc-id.h
@@ -20,10 +20,28 @@
20#define MV78XX0_A0_REV 0x1 20#define MV78XX0_A0_REV 0x1
21#define MV78XX0_B0_REV 0x2 21#define MV78XX0_B0_REV 0x2
22 22
23/* Amada 370 ID */
24#define ARMADA_370_DEV_ID 0x6710
25
26/* Amada 370 Revision */
27#define ARMADA_370_A1_REV 0x1
28
29/* Armada 375 ID */
30#define ARMADA_375_DEV_ID 0x6720
31
23/* Armada 375 */ 32/* Armada 375 */
24#define ARMADA_375_Z1_REV 0x0 33#define ARMADA_375_Z1_REV 0x0
25#define ARMADA_375_A0_REV 0x3 34#define ARMADA_375_A0_REV 0x3
26 35
36/* Armada 38x ID */
37#define ARMADA_380_DEV_ID 0x6810
38#define ARMADA_385_DEV_ID 0x6820
39#define ARMADA_388_DEV_ID 0x6828
40
41/* Armada 38x Revision */
42#define ARMADA_38x_Z1_REV 0x0
43#define ARMADA_38x_A0_REV 0x4
44
27#ifdef CONFIG_ARCH_MVEBU 45#ifdef CONFIG_ARCH_MVEBU
28int mvebu_get_soc_id(u32 *dev, u32 *rev); 46int mvebu_get_soc_id(u32 *dev, u32 *rev);
29#else 47#else
diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig
index 042f693ef423..a219dc310d5d 100644
--- a/arch/arm/mach-prima2/Kconfig
+++ b/arch/arm/mach-prima2/Kconfig
@@ -11,7 +11,7 @@ menuconfig ARCH_SIRF
11 11
12if ARCH_SIRF 12if ARCH_SIRF
13 13
14comment "CSR SiRF atlas6/primaII/Marco/Polo Specific Features" 14comment "CSR SiRF atlas6/primaII/Atlas7 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"
@@ -20,6 +20,17 @@ config ARCH_ATLAS6
20 help 20 help
21 Support for CSR SiRFSoC ARM Cortex A9 Platform 21 Support for CSR SiRFSoC ARM Cortex A9 Platform
22 22
23config ARCH_ATLAS7
24 bool "CSR SiRFSoC ATLAS7 ARM Cortex A7 Platform"
25 default y
26 select ARM_GIC
27 select CPU_V7
28 select HAVE_ARM_SCU if SMP
29 select HAVE_SMP
30 select SMP_ON_UP if SMP
31 help
32 Support for CSR SiRFSoC ARM Cortex A7 Platform
33
23config ARCH_PRIMA2 34config ARCH_PRIMA2
24 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform" 35 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
25 default y 36 default y
@@ -28,15 +39,6 @@ config ARCH_PRIMA2
28 help 39 help
29 Support for CSR SiRFSoC ARM Cortex A9 Platform 40 Support for CSR SiRFSoC ARM Cortex A9 Platform
30 41
31config ARCH_MARCO
32 bool "CSR SiRFSoC MARCO ARM Cortex A9 Platform"
33 default y
34 select ARM_GIC
35 select HAVE_ARM_SCU if SMP
36 select SMP_ON_UP if SMP
37 help
38 Support for CSR SiRFSoC ARM Cortex A9 Platform
39
40config SIRF_IRQ 42config SIRF_IRQ
41 bool 43 bool
42 44
diff --git a/arch/arm/mach-prima2/Makefile b/arch/arm/mach-prima2/Makefile
index 8846e7d87ea5..d7d02b043449 100644
--- a/arch/arm/mach-prima2/Makefile
+++ b/arch/arm/mach-prima2/Makefile
@@ -1,7 +1,6 @@
1obj-y += rstc.o 1obj-y += rstc.o
2obj-y += common.o 2obj-y += common.o
3obj-y += rtciobrg.o 3obj-y += rtciobrg.o
4obj-$(CONFIG_DEBUG_LL) += lluart.o
5obj-$(CONFIG_SUSPEND) += pm.o sleep.o 4obj-$(CONFIG_SUSPEND) += pm.o sleep.o
6obj-$(CONFIG_SMP) += platsmp.o headsmp.o 5obj-$(CONFIG_SMP) += platsmp.o headsmp.o
7obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 6obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
diff --git a/arch/arm/mach-prima2/common.c b/arch/arm/mach-prima2/common.c
index a860ea27e8ae..0c819bb88418 100644
--- a/arch/arm/mach-prima2/common.c
+++ b/arch/arm/mach-prima2/common.c
@@ -20,12 +20,6 @@ static void __init sirfsoc_init_late(void)
20 sirfsoc_pm_init(); 20 sirfsoc_pm_init();
21} 21}
22 22
23static __init void sirfsoc_map_io(void)
24{
25 sirfsoc_map_lluart();
26 sirfsoc_map_scu();
27}
28
29#ifdef CONFIG_ARCH_ATLAS6 23#ifdef CONFIG_ARCH_ATLAS6
30static const char *atlas6_dt_match[] __initconst = { 24static const char *atlas6_dt_match[] __initconst = {
31 "sirf,atlas6", 25 "sirf,atlas6",
@@ -36,7 +30,6 @@ DT_MACHINE_START(ATLAS6_DT, "Generic ATLAS6 (Flattened Device Tree)")
36 /* Maintainer: Barry Song <baohua.song@csr.com> */ 30 /* Maintainer: Barry Song <baohua.song@csr.com> */
37 .l2c_aux_val = 0, 31 .l2c_aux_val = 0,
38 .l2c_aux_mask = ~0, 32 .l2c_aux_mask = ~0,
39 .map_io = sirfsoc_map_io,
40 .init_late = sirfsoc_init_late, 33 .init_late = sirfsoc_init_late,
41 .dt_compat = atlas6_dt_match, 34 .dt_compat = atlas6_dt_match,
42MACHINE_END 35MACHINE_END
@@ -52,26 +45,21 @@ DT_MACHINE_START(PRIMA2_DT, "Generic PRIMA2 (Flattened Device Tree)")
52 /* Maintainer: Barry Song <baohua.song@csr.com> */ 45 /* Maintainer: Barry Song <baohua.song@csr.com> */
53 .l2c_aux_val = 0, 46 .l2c_aux_val = 0,
54 .l2c_aux_mask = ~0, 47 .l2c_aux_mask = ~0,
55 .map_io = sirfsoc_map_io,
56 .dma_zone_size = SZ_256M, 48 .dma_zone_size = SZ_256M,
57 .init_late = sirfsoc_init_late, 49 .init_late = sirfsoc_init_late,
58 .dt_compat = prima2_dt_match, 50 .dt_compat = prima2_dt_match,
59MACHINE_END 51MACHINE_END
60#endif 52#endif
61 53
62#ifdef CONFIG_ARCH_MARCO 54#ifdef CONFIG_ARCH_ATLAS7
63static const char *marco_dt_match[] __initconst = { 55static const char *atlas7_dt_match[] __initdata = {
64 "sirf,marco", 56 "sirf,atlas7",
65 NULL 57 NULL
66}; 58};
67 59
68DT_MACHINE_START(MARCO_DT, "Generic MARCO (Flattened Device Tree)") 60DT_MACHINE_START(ATLAS7_DT, "Generic ATLAS7 (Flattened Device Tree)")
69 /* Maintainer: Barry Song <baohua.song@csr.com> */ 61 /* Maintainer: Barry Song <baohua.song@csr.com> */
70 .l2c_aux_val = 0,
71 .l2c_aux_mask = ~0,
72 .smp = smp_ops(sirfsoc_smp_ops), 62 .smp = smp_ops(sirfsoc_smp_ops),
73 .map_io = sirfsoc_map_io, 63 .dt_compat = atlas7_dt_match,
74 .init_late = sirfsoc_init_late,
75 .dt_compat = marco_dt_match,
76MACHINE_END 64MACHINE_END
77#endif 65#endif
diff --git a/arch/arm/mach-prima2/lluart.c b/arch/arm/mach-prima2/lluart.c
deleted file mode 100644
index 99c0c927ca4a..000000000000
--- a/arch/arm/mach-prima2/lluart.c
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Static memory mapping for DEBUG_LL
3 *
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
5 *
6 * Licensed under GPLv2 or later.
7 */
8
9#include <linux/kernel.h>
10#include <asm/page.h>
11#include <asm/mach/map.h>
12#include "common.h"
13
14#if defined(CONFIG_DEBUG_SIRFPRIMA2_UART1)
15#define SIRFSOC_UART1_PA_BASE 0xb0060000
16#elif defined(CONFIG_DEBUG_SIRFMARCO_UART1)
17#define SIRFSOC_UART1_PA_BASE 0xcc060000
18#else
19#define SIRFSOC_UART1_PA_BASE 0
20#endif
21
22#define SIRFSOC_UART1_VA_BASE SIRFSOC_VA(0x060000)
23#define SIRFSOC_UART1_SIZE SZ_4K
24
25void __init sirfsoc_map_lluart(void)
26{
27 struct map_desc sirfsoc_lluart_map = {
28 .virtual = SIRFSOC_UART1_VA_BASE,
29 .pfn = __phys_to_pfn(SIRFSOC_UART1_PA_BASE),
30 .length = SIRFSOC_UART1_SIZE,
31 .type = MT_DEVICE,
32 };
33
34 iotable_init(&sirfsoc_lluart_map, 1);
35}
diff --git a/arch/arm/mach-prima2/platsmp.c b/arch/arm/mach-prima2/platsmp.c
index 335c12e92262..fc2b03c81e5f 100644
--- a/arch/arm/mach-prima2/platsmp.c
+++ b/arch/arm/mach-prima2/platsmp.c
@@ -20,30 +20,10 @@
20 20
21#include "common.h" 21#include "common.h"
22 22
23static void __iomem *scu_base; 23static void __iomem *clk_base;
24static void __iomem *rsc_base;
25 24
26static DEFINE_SPINLOCK(boot_lock); 25static DEFINE_SPINLOCK(boot_lock);
27 26
28static struct map_desc scu_io_desc __initdata = {
29 .length = SZ_4K,
30 .type = MT_DEVICE,
31};
32
33void __init sirfsoc_map_scu(void)
34{
35 unsigned long base;
36
37 /* Get SCU base */
38 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));
39
40 scu_io_desc.virtual = SIRFSOC_VA(base);
41 scu_io_desc.pfn = __phys_to_pfn(base);
42 iotable_init(&scu_io_desc, 1);
43
44 scu_base = (void __iomem *)SIRFSOC_VA(base);
45}
46
47static void sirfsoc_secondary_init(unsigned int cpu) 27static void sirfsoc_secondary_init(unsigned int cpu)
48{ 28{
49 /* 29 /*
@@ -60,8 +40,8 @@ static void sirfsoc_secondary_init(unsigned int cpu)
60 spin_unlock(&boot_lock); 40 spin_unlock(&boot_lock);
61} 41}
62 42
63static struct of_device_id rsc_ids[] = { 43static struct of_device_id clk_ids[] = {
64 { .compatible = "sirf,marco-rsc" }, 44 { .compatible = "sirf,atlas7-clkc" },
65 {}, 45 {},
66}; 46};
67 47
@@ -70,27 +50,27 @@ static int sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle)
70 unsigned long timeout; 50 unsigned long timeout;
71 struct device_node *np; 51 struct device_node *np;
72 52
73 np = of_find_matching_node(NULL, rsc_ids); 53 np = of_find_matching_node(NULL, clk_ids);
74 if (!np) 54 if (!np)
75 return -ENODEV; 55 return -ENODEV;
76 56
77 rsc_base = of_iomap(np, 0); 57 clk_base = of_iomap(np, 0);
78 if (!rsc_base) 58 if (!clk_base)
79 return -ENOMEM; 59 return -ENOMEM;
80 60
81 /* 61 /*
82 * write the address of secondary startup into the sram register 62 * write the address of secondary startup into the clkc register
83 * at offset 0x2C, then write the magic number 0x3CAF5D62 to the 63 * at offset 0x2bC, then write the magic number 0x3CAF5D62 to the
84 * RSC register at offset 0x28, which is what boot rom code is 64 * clkc register at offset 0x2b8, which is what boot rom code is
85 * waiting for. This would wake up the secondary core from WFE 65 * waiting for. This would wake up the secondary core from WFE
86 */ 66 */
87#define SIRFSOC_CPU1_JUMPADDR_OFFSET 0x2C 67#define SIRFSOC_CPU1_JUMPADDR_OFFSET 0x2bc
88 __raw_writel(virt_to_phys(sirfsoc_secondary_startup), 68 __raw_writel(virt_to_phys(sirfsoc_secondary_startup),
89 rsc_base + SIRFSOC_CPU1_JUMPADDR_OFFSET); 69 clk_base + SIRFSOC_CPU1_JUMPADDR_OFFSET);
90 70
91#define SIRFSOC_CPU1_WAKEMAGIC_OFFSET 0x28 71#define SIRFSOC_CPU1_WAKEMAGIC_OFFSET 0x2b8
92 __raw_writel(0x3CAF5D62, 72 __raw_writel(0x3CAF5D62,
93 rsc_base + SIRFSOC_CPU1_WAKEMAGIC_OFFSET); 73 clk_base + SIRFSOC_CPU1_WAKEMAGIC_OFFSET);
94 74
95 /* make sure write buffer is drained */ 75 /* make sure write buffer is drained */
96 mb(); 76 mb();
@@ -132,13 +112,7 @@ static int sirfsoc_boot_secondary(unsigned int cpu, struct task_struct *idle)
132 return pen_release != -1 ? -ENOSYS : 0; 112 return pen_release != -1 ? -ENOSYS : 0;
133} 113}
134 114
135static void __init sirfsoc_smp_prepare_cpus(unsigned int max_cpus)
136{
137 scu_enable(scu_base);
138}
139
140struct smp_operations sirfsoc_smp_ops __initdata = { 115struct smp_operations sirfsoc_smp_ops __initdata = {
141 .smp_prepare_cpus = sirfsoc_smp_prepare_cpus,
142 .smp_secondary_init = sirfsoc_secondary_init, 116 .smp_secondary_init = sirfsoc_secondary_init,
143 .smp_boot_secondary = sirfsoc_boot_secondary, 117 .smp_boot_secondary = sirfsoc_boot_secondary,
144#ifdef CONFIG_HOTPLUG_CPU 118#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/arm/mach-prima2/rstc.c b/arch/arm/mach-prima2/rstc.c
index e1f1f86f6a95..7c251eb11d01 100644
--- a/arch/arm/mach-prima2/rstc.c
+++ b/arch/arm/mach-prima2/rstc.c
@@ -34,36 +34,20 @@ static int sirfsoc_reset_module(struct reset_controller_dev *rcdev,
34 34
35 mutex_lock(&rstc_lock); 35 mutex_lock(&rstc_lock);
36 36
37 if (of_device_is_compatible(rcdev->of_node, "sirf,prima2-rstc")) { 37 /*
38 /* 38 * Writing 1 to this bit resets corresponding block.
39 * Writing 1 to this bit resets corresponding block. 39 * Writing 0 to this bit de-asserts reset signal of the
40 * Writing 0 to this bit de-asserts reset signal of the 40 * corresponding block. datasheet doesn't require explicit
41 * corresponding block. datasheet doesn't require explicit 41 * delay between the set and clear of reset bit. it could
42 * delay between the set and clear of reset bit. it could 42 * be shorter if tests pass.
43 * be shorter if tests pass. 43 */
44 */ 44 writel(readl(sirfsoc_rstc_base +
45 writel(readl(sirfsoc_rstc_base +
46 (reset_bit / 32) * 4) | (1 << reset_bit), 45 (reset_bit / 32) * 4) | (1 << reset_bit),
47 sirfsoc_rstc_base + (reset_bit / 32) * 4); 46 sirfsoc_rstc_base + (reset_bit / 32) * 4);
48 msleep(20); 47 msleep(20);
49 writel(readl(sirfsoc_rstc_base + 48 writel(readl(sirfsoc_rstc_base +
50 (reset_bit / 32) * 4) & ~(1 << reset_bit), 49 (reset_bit / 32) * 4) & ~(1 << reset_bit),
51 sirfsoc_rstc_base + (reset_bit / 32) * 4); 50 sirfsoc_rstc_base + (reset_bit / 32) * 4);
52 } else {
53 /*
54 * For MARCO and POLO
55 * Writing 1 to SET register resets corresponding block.
56 * Writing 1 to CLEAR register de-asserts reset signal of the
57 * corresponding block.
58 * datasheet doesn't require explicit delay between the set and
59 * clear of reset bit. it could be shorter if tests pass.
60 */
61 writel(1 << reset_bit,
62 sirfsoc_rstc_base + (reset_bit / 32) * 8);
63 msleep(20);
64 writel(1 << reset_bit,
65 sirfsoc_rstc_base + (reset_bit / 32) * 8 + 4);
66 }
67 51
68 mutex_unlock(&rstc_lock); 52 mutex_unlock(&rstc_lock);
69 53
@@ -106,7 +90,6 @@ static int sirfsoc_rstc_probe(struct platform_device *pdev)
106 90
107static const struct of_device_id rstc_ids[] = { 91static const struct of_device_id rstc_ids[] = {
108 { .compatible = "sirf,prima2-rstc" }, 92 { .compatible = "sirf,prima2-rstc" },
109 { .compatible = "sirf,marco-rstc" },
110 {}, 93 {},
111}; 94};
112 95
diff --git a/arch/arm/mach-prima2/rtciobrg.c b/arch/arm/mach-prima2/rtciobrg.c
index 70a0b475062b..8f66d8f7ca75 100644
--- a/arch/arm/mach-prima2/rtciobrg.c
+++ b/arch/arm/mach-prima2/rtciobrg.c
@@ -104,7 +104,6 @@ EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel);
104 104
105static const struct of_device_id rtciobrg_ids[] = { 105static const struct of_device_id rtciobrg_ids[] = {
106 { .compatible = "sirf,prima2-rtciobg" }, 106 { .compatible = "sirf,prima2-rtciobg" },
107 { .compatible = "sirf,marco-rtciobg" },
108 {} 107 {}
109}; 108};
110 109
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 1b4fafe524ff..d107b9386bda 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -51,6 +51,11 @@ config ARCH_R7S72100
51 bool "RZ/A1H (R7S72100)" 51 bool "RZ/A1H (R7S72100)"
52 select SYS_SUPPORTS_SH_MTU2 52 select SYS_SUPPORTS_SH_MTU2
53 53
54config ARCH_R8A73A4
55 bool "R-Mobile APE6 (R8A73A40)"
56 select ARCH_RMOBILE
57 select RENESAS_IRQC
58
54config ARCH_R8A7740 59config ARCH_R8A7740
55 bool "R-Mobile A1 (R8A77400)" 60 bool "R-Mobile A1 (R8A77400)"
56 select ARCH_RMOBILE 61 select ARCH_RMOBILE
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 6b4c1f313cc9..3855fb024fdb 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -553,6 +553,7 @@ enum { MSTP001,
553 MSTP314, MSTP313, MSTP312, MSTP311, 553 MSTP314, MSTP313, MSTP312, MSTP311,
554 MSTP304, MSTP303, MSTP302, MSTP301, MSTP300, 554 MSTP304, MSTP303, MSTP302, MSTP301, MSTP300,
555 MSTP411, MSTP410, MSTP403, 555 MSTP411, MSTP410, MSTP403,
556 MSTP508,
556 MSTP_NR }; 557 MSTP_NR };
557 558
558#define MSTP(_parent, _reg, _bit, _flags) \ 559#define MSTP(_parent, _reg, _bit, _flags) \
@@ -597,6 +598,7 @@ static struct clk mstp_clks[MSTP_NR] = {
597 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */ 598 [MSTP411] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 11, 0), /* IIC3 */
598 [MSTP410] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 10, 0), /* IIC4 */ 599 [MSTP410] = MSTP(&div4_clks[DIV4_HP], SMSTPCR4, 10, 0), /* IIC4 */
599 [MSTP403] = MSTP(&r_clk, SMSTPCR4, 3, 0), /* KEYSC */ 600 [MSTP403] = MSTP(&r_clk, SMSTPCR4, 3, 0), /* KEYSC */
601 [MSTP508] = MSTP(&div4_clks[DIV4_HP], SMSTPCR5, 8, 0), /* INTCA0 */
600}; 602};
601 603
602/* The lookups structure below includes duplicate entries for some clocks 604/* The lookups structure below includes duplicate entries for some clocks
@@ -677,6 +679,14 @@ static struct clk_lookup lookups[] = {
677 CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */ 679 CLKDEV_DEV_ID("i2c-sh_mobile.4", &mstp_clks[MSTP410]), /* I2C4 */
678 CLKDEV_DEV_ID("e6828000.i2c", &mstp_clks[MSTP410]), /* I2C4 */ 680 CLKDEV_DEV_ID("e6828000.i2c", &mstp_clks[MSTP410]), /* I2C4 */
679 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */ 681 CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */
682 CLKDEV_DEV_ID("renesas_intc_irqpin.0", &mstp_clks[MSTP508]), /* INTCA0 */
683 CLKDEV_DEV_ID("e6900000.irqpin", &mstp_clks[MSTP508]), /* INTCA0 */
684 CLKDEV_DEV_ID("renesas_intc_irqpin.1", &mstp_clks[MSTP508]), /* INTCA0 */
685 CLKDEV_DEV_ID("e6900004.irqpin", &mstp_clks[MSTP508]), /* INTCA0 */
686 CLKDEV_DEV_ID("renesas_intc_irqpin.2", &mstp_clks[MSTP508]), /* INTCA0 */
687 CLKDEV_DEV_ID("e6900008.irqpin", &mstp_clks[MSTP508]), /* INTCA0 */
688 CLKDEV_DEV_ID("renesas_intc_irqpin.3", &mstp_clks[MSTP508]), /* INTCA0 */
689 CLKDEV_DEV_ID("e690000c.irqpin", &mstp_clks[MSTP508]), /* INTCA0 */
680 690
681 /* ICK */ 691 /* ICK */
682 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]), 692 CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]),
diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c
index 3dd6edd9bd1d..c35b91d92190 100644
--- a/arch/arm/mach-shmobile/setup-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c
@@ -52,15 +52,13 @@ void __init rcar_gen2_timer_init(void)
52{ 52{
53#if defined(CONFIG_ARM_ARCH_TIMER) || defined(CONFIG_COMMON_CLK) 53#if defined(CONFIG_ARM_ARCH_TIMER) || defined(CONFIG_COMMON_CLK)
54 u32 mode = rcar_gen2_read_mode_pins(); 54 u32 mode = rcar_gen2_read_mode_pins();
55 bool is_e2 = (bool)of_find_compatible_node(NULL, NULL,
56 "renesas,r8a7794");
57#endif 55#endif
58#ifdef CONFIG_ARM_ARCH_TIMER 56#ifdef CONFIG_ARM_ARCH_TIMER
59 void __iomem *base; 57 void __iomem *base;
60 int extal_mhz = 0; 58 int extal_mhz = 0;
61 u32 freq; 59 u32 freq;
62 60
63 if (is_e2) { 61 if (of_machine_is_compatible("renesas,r8a7794")) {
64 freq = 260000000 / 8; /* ZS / 8 */ 62 freq = 260000000 / 8; /* ZS / 8 */
65 /* CNTVOFF has to be initialized either from non-secure 63 /* CNTVOFF has to be initialized either from non-secure
66 * Hypervisor mode or secure Monitor mode with SCR.NS==1. 64 * Hypervisor mode or secure Monitor mode with SCR.NS==1.
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c
index 3f761f839043..9fc280e24ef4 100644
--- a/arch/arm/mach-shmobile/smp-r8a7779.c
+++ b/arch/arm/mach-shmobile/smp-r8a7779.c
@@ -56,7 +56,7 @@ static struct rcar_sysc_ch *r8a7779_ch_cpu[4] = {
56 [3] = &r8a7779_ch_cpu3, 56 [3] = &r8a7779_ch_cpu3,
57}; 57};
58 58
59#ifdef CONFIG_HAVE_ARM_TWD 59#if defined(CONFIG_HAVE_ARM_TWD) && !defined(CONFIG_ARCH_MULTIPLATFORM)
60static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, R8A7779_SCU_BASE + 0x600, 29); 60static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, R8A7779_SCU_BASE + 0x600, 29);
61void __init r8a7779_register_twd(void) 61void __init r8a7779_register_twd(void)
62{ 62{
diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 59424937e52b..9fe8e241335c 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -220,9 +220,6 @@ static void note_page(struct pg_state *st, unsigned long addr, unsigned level, u
220 static const char units[] = "KMGTPE"; 220 static const char units[] = "KMGTPE";
221 u64 prot = val & pg_level[level].mask; 221 u64 prot = val & pg_level[level].mask;
222 222
223 if (addr < USER_PGTABLES_CEILING)
224 return;
225
226 if (!st->level) { 223 if (!st->level) {
227 st->level = level; 224 st->level = level;
228 st->current_prot = prot; 225 st->current_prot = prot;
@@ -308,15 +305,13 @@ static void walk_pgd(struct seq_file *m)
308 pgd_t *pgd = swapper_pg_dir; 305 pgd_t *pgd = swapper_pg_dir;
309 struct pg_state st; 306 struct pg_state st;
310 unsigned long addr; 307 unsigned long addr;
311 unsigned i, pgdoff = USER_PGTABLES_CEILING / PGDIR_SIZE; 308 unsigned i;
312 309
313 memset(&st, 0, sizeof(st)); 310 memset(&st, 0, sizeof(st));
314 st.seq = m; 311 st.seq = m;
315 st.marker = address_markers; 312 st.marker = address_markers;
316 313
317 pgd += pgdoff; 314 for (i = 0; i < PTRS_PER_PGD; i++, pgd++) {
318
319 for (i = pgdoff; i < PTRS_PER_PGD; i++, pgd++) {
320 addr = i * PGDIR_SIZE; 315 addr = i * PGDIR_SIZE;
321 if (!pgd_none(*pgd)) { 316 if (!pgd_none(*pgd)) {
322 walk_pud(&st, pgd, addr); 317 walk_pud(&st, pgd, addr);
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 98ad9c79ea0e..2495c8cb47ba 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -658,8 +658,8 @@ static struct section_perm ro_perms[] = {
658 .start = (unsigned long)_stext, 658 .start = (unsigned long)_stext,
659 .end = (unsigned long)__init_begin, 659 .end = (unsigned long)__init_begin,
660#ifdef CONFIG_ARM_LPAE 660#ifdef CONFIG_ARM_LPAE
661 .mask = ~PMD_SECT_RDONLY, 661 .mask = ~L_PMD_SECT_RDONLY,
662 .prot = PMD_SECT_RDONLY, 662 .prot = L_PMD_SECT_RDONLY,
663#else 663#else
664 .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE), 664 .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
665 .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE, 665 .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index cda7c40999b6..4e6ef896c619 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1329,8 +1329,8 @@ static void __init kmap_init(void)
1329static void __init map_lowmem(void) 1329static void __init map_lowmem(void)
1330{ 1330{
1331 struct memblock_region *reg; 1331 struct memblock_region *reg;
1332 unsigned long kernel_x_start = round_down(__pa(_stext), SECTION_SIZE); 1332 phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
1333 unsigned long kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE); 1333 phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
1334 1334
1335 /* Map all the lowmem memory banks. */ 1335 /* Map all the lowmem memory banks. */
1336 for_each_memblock(memory, reg) { 1336 for_each_memblock(memory, reg) {
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index dd301be89ecc..5376d908eabe 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1,6 +1,7 @@
1# CONFIG_LOCALVERSION_AUTO is not set 1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_POSIX_MQUEUE=y 3CONFIG_POSIX_MQUEUE=y
4CONFIG_FHANDLE=y
4CONFIG_AUDIT=y 5CONFIG_AUDIT=y
5CONFIG_NO_HZ_IDLE=y 6CONFIG_NO_HZ_IDLE=y
6CONFIG_HIGH_RES_TIMERS=y 7CONFIG_HIGH_RES_TIMERS=y
@@ -13,14 +14,12 @@ CONFIG_TASK_IO_ACCOUNTING=y
13CONFIG_IKCONFIG=y 14CONFIG_IKCONFIG=y
14CONFIG_IKCONFIG_PROC=y 15CONFIG_IKCONFIG_PROC=y
15CONFIG_LOG_BUF_SHIFT=14 16CONFIG_LOG_BUF_SHIFT=14
16CONFIG_RESOURCE_COUNTERS=y
17CONFIG_MEMCG=y 17CONFIG_MEMCG=y
18CONFIG_MEMCG_SWAP=y 18CONFIG_MEMCG_SWAP=y
19CONFIG_MEMCG_KMEM=y 19CONFIG_MEMCG_KMEM=y
20CONFIG_CGROUP_HUGETLB=y 20CONFIG_CGROUP_HUGETLB=y
21# CONFIG_UTS_NS is not set 21# CONFIG_UTS_NS is not set
22# CONFIG_IPC_NS is not set 22# CONFIG_IPC_NS is not set
23# CONFIG_PID_NS is not set
24# CONFIG_NET_NS is not set 23# CONFIG_NET_NS is not set
25CONFIG_SCHED_AUTOGROUP=y 24CONFIG_SCHED_AUTOGROUP=y
26CONFIG_BLK_DEV_INITRD=y 25CONFIG_BLK_DEV_INITRD=y
@@ -92,7 +91,6 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
92CONFIG_SERIAL_OF_PLATFORM=y 91CONFIG_SERIAL_OF_PLATFORM=y
93CONFIG_VIRTIO_CONSOLE=y 92CONFIG_VIRTIO_CONSOLE=y
94# CONFIG_HW_RANDOM is not set 93# CONFIG_HW_RANDOM is not set
95# CONFIG_HMC_DRV is not set
96CONFIG_SPI=y 94CONFIG_SPI=y
97CONFIG_SPI_PL022=y 95CONFIG_SPI_PL022=y
98CONFIG_GPIO_PL061=y 96CONFIG_GPIO_PL061=y
@@ -133,6 +131,8 @@ CONFIG_EXT3_FS=y
133CONFIG_EXT4_FS=y 131CONFIG_EXT4_FS=y
134CONFIG_FANOTIFY=y 132CONFIG_FANOTIFY=y
135CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y 133CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
134CONFIG_QUOTA=y
135CONFIG_AUTOFS4_FS=y
136CONFIG_FUSE_FS=y 136CONFIG_FUSE_FS=y
137CONFIG_CUSE=y 137CONFIG_CUSE=y
138CONFIG_VFAT_FS=y 138CONFIG_VFAT_FS=y
@@ -152,14 +152,15 @@ CONFIG_MAGIC_SYSRQ=y
152CONFIG_DEBUG_KERNEL=y 152CONFIG_DEBUG_KERNEL=y
153CONFIG_LOCKUP_DETECTOR=y 153CONFIG_LOCKUP_DETECTOR=y
154# CONFIG_SCHED_DEBUG is not set 154# CONFIG_SCHED_DEBUG is not set
155# CONFIG_DEBUG_PREEMPT is not set
155# CONFIG_FTRACE is not set 156# CONFIG_FTRACE is not set
157CONFIG_KEYS=y
156CONFIG_SECURITY=y 158CONFIG_SECURITY=y
157CONFIG_CRYPTO_ANSI_CPRNG=y 159CONFIG_CRYPTO_ANSI_CPRNG=y
158CONFIG_ARM64_CRYPTO=y 160CONFIG_ARM64_CRYPTO=y
159CONFIG_CRYPTO_SHA1_ARM64_CE=y 161CONFIG_CRYPTO_SHA1_ARM64_CE=y
160CONFIG_CRYPTO_SHA2_ARM64_CE=y 162CONFIG_CRYPTO_SHA2_ARM64_CE=y
161CONFIG_CRYPTO_GHASH_ARM64_CE=y 163CONFIG_CRYPTO_GHASH_ARM64_CE=y
162CONFIG_CRYPTO_AES_ARM64_CE=y
163CONFIG_CRYPTO_AES_ARM64_CE_CCM=y 164CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
164CONFIG_CRYPTO_AES_ARM64_CE_BLK=y 165CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
165CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y 166CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index b1fa4e614718..fbe0ca31a99c 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -21,6 +21,7 @@
21 21
22#include <asm/barrier.h> 22#include <asm/barrier.h>
23 23
24#include <linux/bug.h>
24#include <linux/init.h> 25#include <linux/init.h>
25#include <linux/types.h> 26#include <linux/types.h>
26 27
diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h
index ace70682499b..8e797b2fcc01 100644
--- a/arch/arm64/include/asm/cpu.h
+++ b/arch/arm64/include/asm/cpu.h
@@ -39,6 +39,7 @@ struct cpuinfo_arm64 {
39 u64 reg_id_aa64pfr0; 39 u64 reg_id_aa64pfr0;
40 u64 reg_id_aa64pfr1; 40 u64 reg_id_aa64pfr1;
41 41
42 u32 reg_id_dfr0;
42 u32 reg_id_isar0; 43 u32 reg_id_isar0;
43 u32 reg_id_isar1; 44 u32 reg_id_isar1;
44 u32 reg_id_isar2; 45 u32 reg_id_isar2;
@@ -51,6 +52,10 @@ struct cpuinfo_arm64 {
51 u32 reg_id_mmfr3; 52 u32 reg_id_mmfr3;
52 u32 reg_id_pfr0; 53 u32 reg_id_pfr0;
53 u32 reg_id_pfr1; 54 u32 reg_id_pfr1;
55
56 u32 reg_mvfr0;
57 u32 reg_mvfr1;
58 u32 reg_mvfr2;
54}; 59};
55 60
56DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data); 61DECLARE_PER_CPU(struct cpuinfo_arm64, cpu_data);
diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h
index d34189bceff7..9ce3e680ae1c 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -52,13 +52,14 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops)
52 dev->archdata.dma_ops = ops; 52 dev->archdata.dma_ops = ops;
53} 53}
54 54
55static inline int set_arch_dma_coherent_ops(struct device *dev) 55static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
56 struct iommu_ops *iommu, bool coherent)
56{ 57{
57 dev->archdata.dma_coherent = true; 58 dev->archdata.dma_coherent = coherent;
58 set_dma_ops(dev, &coherent_swiotlb_dma_ops); 59 if (coherent)
59 return 0; 60 set_dma_ops(dev, &coherent_swiotlb_dma_ops);
60} 61}
61#define set_arch_dma_coherent_ops set_arch_dma_coherent_ops 62#define arch_setup_dma_ops arch_setup_dma_ops
62 63
63/* do not use this function in a driver */ 64/* do not use this function in a driver */
64static inline bool is_device_dma_coherent(struct device *dev) 65static inline bool is_device_dma_coherent(struct device *dev)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index df22314f57cf..210d632aa5ad 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -298,7 +298,6 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address,
298#define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))) 298#define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)))
299#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) 299#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot)
300 300
301#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK))
302#define pud_write(pud) pte_write(pud_pte(pud)) 301#define pud_write(pud) pte_write(pud_pte(pud))
303#define pud_pfn(pud) (((pud_val(pud) & PUD_MASK) & PHYS_MASK) >> PAGE_SHIFT) 302#define pud_pfn(pud) (((pud_val(pud) & PUD_MASK) & PHYS_MASK) >> PAGE_SHIFT)
304 303
@@ -401,7 +400,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
401 return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr); 400 return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(addr);
402} 401}
403 402
404#define pud_page(pud) pmd_page(pud_pmd(pud)) 403#define pud_page(pud) pfn_to_page(__phys_to_pfn(pud_val(pud) & PHYS_MASK))
405 404
406#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */ 405#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 2 */
407 406
@@ -437,6 +436,8 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr)
437 return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(addr); 436 return (pud_t *)pgd_page_vaddr(*pgd) + pud_index(addr);
438} 437}
439 438
439#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(pgd_val(pgd) & PHYS_MASK))
440
440#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */ 441#endif /* CONFIG_ARM64_PGTABLE_LEVELS > 3 */
441 442
442#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd)) 443#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 286b1bec547c..f9be30ea1cbd 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -31,6 +31,7 @@
31 31
32#include <asm/fpsimd.h> 32#include <asm/fpsimd.h>
33#include <asm/hw_breakpoint.h> 33#include <asm/hw_breakpoint.h>
34#include <asm/pgtable-hwdef.h>
34#include <asm/ptrace.h> 35#include <asm/ptrace.h>
35#include <asm/types.h> 36#include <asm/types.h>
36 37
@@ -123,9 +124,6 @@ struct task_struct;
123/* Free all resources held by a thread. */ 124/* Free all resources held by a thread. */
124extern void release_thread(struct task_struct *); 125extern void release_thread(struct task_struct *);
125 126
126/* Prepare to copy thread state - unlazy all lazy status */
127#define prepare_to_copy(tsk) do { } while (0)
128
129unsigned long get_wchan(struct task_struct *p); 127unsigned long get_wchan(struct task_struct *p);
130 128
131#define cpu_relax() barrier() 129#define cpu_relax() barrier()
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 49c9aefd24a5..b780c6c76eec 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -44,7 +44,7 @@
44#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2) 44#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2)
45#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5) 45#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5)
46 46
47#define __NR_compat_syscalls 386 47#define __NR_compat_syscalls 387
48#endif 48#endif
49 49
50#define __ARCH_WANT_SYS_CLONE 50#define __ARCH_WANT_SYS_CLONE
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
index 57b641747534..07d435cf2eea 100644
--- a/arch/arm64/kernel/cpuinfo.c
+++ b/arch/arm64/kernel/cpuinfo.c
@@ -147,6 +147,7 @@ static void cpuinfo_sanity_check(struct cpuinfo_arm64 *cur)
147 * If we have AArch32, we care about 32-bit features for compat. These 147 * If we have AArch32, we care about 32-bit features for compat. These
148 * registers should be RES0 otherwise. 148 * registers should be RES0 otherwise.
149 */ 149 */
150 diff |= CHECK(id_dfr0, boot, cur, cpu);
150 diff |= CHECK(id_isar0, boot, cur, cpu); 151 diff |= CHECK(id_isar0, boot, cur, cpu);
151 diff |= CHECK(id_isar1, boot, cur, cpu); 152 diff |= CHECK(id_isar1, boot, cur, cpu);
152 diff |= CHECK(id_isar2, boot, cur, cpu); 153 diff |= CHECK(id_isar2, boot, cur, cpu);
@@ -165,6 +166,10 @@ static void cpuinfo_sanity_check(struct cpuinfo_arm64 *cur)
165 diff |= CHECK(id_pfr0, boot, cur, cpu); 166 diff |= CHECK(id_pfr0, boot, cur, cpu);
166 diff |= CHECK(id_pfr1, boot, cur, cpu); 167 diff |= CHECK(id_pfr1, boot, cur, cpu);
167 168
169 diff |= CHECK(mvfr0, boot, cur, cpu);
170 diff |= CHECK(mvfr1, boot, cur, cpu);
171 diff |= CHECK(mvfr2, boot, cur, cpu);
172
168 /* 173 /*
169 * Mismatched CPU features are a recipe for disaster. Don't even 174 * Mismatched CPU features are a recipe for disaster. Don't even
170 * pretend to support them. 175 * pretend to support them.
@@ -189,6 +194,7 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
189 info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1); 194 info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1);
190 info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1); 195 info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1);
191 196
197 info->reg_id_dfr0 = read_cpuid(ID_DFR0_EL1);
192 info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); 198 info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1);
193 info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); 199 info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1);
194 info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); 200 info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1);
@@ -202,6 +208,10 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
202 info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); 208 info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1);
203 info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); 209 info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1);
204 210
211 info->reg_mvfr0 = read_cpuid(MVFR0_EL1);
212 info->reg_mvfr1 = read_cpuid(MVFR1_EL1);
213 info->reg_mvfr2 = read_cpuid(MVFR2_EL1);
214
205 cpuinfo_detect_icache_policy(info); 215 cpuinfo_detect_icache_policy(info);
206 216
207 check_local_cpu_errata(); 217 check_local_cpu_errata();
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 6fac253bc783..2bb4347d0edf 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -326,6 +326,7 @@ void __init efi_idmap_init(void)
326 326
327 /* boot time idmap_pg_dir is incomplete, so fill in missing parts */ 327 /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
328 efi_setup_idmap(); 328 efi_setup_idmap();
329 early_memunmap(memmap.map, memmap.map_end - memmap.map);
329} 330}
330 331
331static int __init remap_region(efi_memory_desc_t *md, void **new) 332static int __init remap_region(efi_memory_desc_t *md, void **new)
@@ -380,7 +381,6 @@ static int __init arm64_enter_virtual_mode(void)
380 } 381 }
381 382
382 mapsize = memmap.map_end - memmap.map; 383 mapsize = memmap.map_end - memmap.map;
383 early_memunmap(memmap.map, mapsize);
384 384
385 if (efi_runtime_disabled()) { 385 if (efi_runtime_disabled()) {
386 pr_info("EFI runtime services will be disabled.\n"); 386 pr_info("EFI runtime services will be disabled.\n");
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index fd027b101de5..9b6f71db2709 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -25,6 +25,7 @@
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/moduleloader.h> 26#include <linux/moduleloader.h>
27#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
28#include <asm/alternative.h>
28#include <asm/insn.h> 29#include <asm/insn.h>
29#include <asm/sections.h> 30#include <asm/sections.h>
30 31
diff --git a/arch/arm64/kernel/perf_regs.c b/arch/arm64/kernel/perf_regs.c
index 6762ad705587..3f62b35fb6f1 100644
--- a/arch/arm64/kernel/perf_regs.c
+++ b/arch/arm64/kernel/perf_regs.c
@@ -50,3 +50,11 @@ u64 perf_reg_abi(struct task_struct *task)
50 else 50 else
51 return PERF_SAMPLE_REGS_ABI_64; 51 return PERF_SAMPLE_REGS_ABI_64;
52} 52}
53
54void perf_get_regs_user(struct perf_regs *regs_user,
55 struct pt_regs *regs,
56 struct pt_regs *regs_user_copy)
57{
58 regs_user->regs = task_pt_regs(current);
59 regs_user->abi = perf_reg_abi(current);
60}
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index b80991166754..20fe2932ad0c 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -402,6 +402,7 @@ void __init setup_arch(char **cmdline_p)
402 request_standard_resources(); 402 request_standard_resources();
403 403
404 efi_idmap_init(); 404 efi_idmap_init();
405 early_ioremap_reset();
405 406
406 unflatten_device_tree(); 407 unflatten_device_tree();
407 408
diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c
index 4f93c67e63de..14944e5b28da 100644
--- a/arch/arm64/kernel/smp_spin_table.c
+++ b/arch/arm64/kernel/smp_spin_table.c
@@ -25,6 +25,7 @@
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/cpu_ops.h> 26#include <asm/cpu_ops.h>
27#include <asm/cputype.h> 27#include <asm/cputype.h>
28#include <asm/io.h>
28#include <asm/smp_plat.h> 29#include <asm/smp_plat.h>
29 30
30extern void secondary_holding_pen(void); 31extern void secondary_holding_pen(void);
diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index 3771b72b6569..2d6b6065fe7f 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -5,6 +5,7 @@
5#include <asm/debug-monitors.h> 5#include <asm/debug-monitors.h>
6#include <asm/pgtable.h> 6#include <asm/pgtable.h>
7#include <asm/memory.h> 7#include <asm/memory.h>
8#include <asm/mmu_context.h>
8#include <asm/smp_plat.h> 9#include <asm/smp_plat.h>
9#include <asm/suspend.h> 10#include <asm/suspend.h>
10#include <asm/tlbflush.h> 11#include <asm/tlbflush.h>
@@ -98,7 +99,18 @@ int __cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
98 */ 99 */
99 ret = __cpu_suspend_enter(arg, fn); 100 ret = __cpu_suspend_enter(arg, fn);
100 if (ret == 0) { 101 if (ret == 0) {
101 cpu_switch_mm(mm->pgd, mm); 102 /*
103 * We are resuming from reset with TTBR0_EL1 set to the
104 * idmap to enable the MMU; restore the active_mm mappings in
105 * TTBR0_EL1 unless the active_mm == &init_mm, in which case
106 * the thread entered __cpu_suspend with TTBR0_EL1 set to
107 * reserved TTBR0 page tables and should be restored as such.
108 */
109 if (mm == &init_mm)
110 cpu_set_reserved_ttbr0();
111 else
112 cpu_switch_mm(mm->pgd, mm);
113
102 flush_tlb_all(); 114 flush_tlb_all();
103 115
104 /* 116 /*
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index 6f4bac969bf7..23eada79439c 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/device.h> 9#include <linux/device.h>
10#include <linux/delay.h>
10#include <linux/platform_device.h> 11#include <linux/platform_device.h>
11#include <linux/mtd/mtd.h> 12#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h> 13#include <linux/mtd/partitions.h>
diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h
index f3b51b57740a..95c39b95e97e 100644
--- a/arch/ia64/include/asm/unistd.h
+++ b/arch/ia64/include/asm/unistd.h
@@ -11,7 +11,7 @@
11 11
12 12
13 13
14#define NR_syscalls 318 /* length of syscall table */ 14#define NR_syscalls 319 /* length of syscall table */
15 15
16/* 16/*
17 * The following defines stop scripts/checksyscalls.sh from complaining about 17 * The following defines stop scripts/checksyscalls.sh from complaining about
diff --git a/arch/ia64/include/uapi/asm/unistd.h b/arch/ia64/include/uapi/asm/unistd.h
index 4c2240c1b0cb..461079560c78 100644
--- a/arch/ia64/include/uapi/asm/unistd.h
+++ b/arch/ia64/include/uapi/asm/unistd.h
@@ -331,5 +331,6 @@
331#define __NR_getrandom 1339 331#define __NR_getrandom 1339
332#define __NR_memfd_create 1340 332#define __NR_memfd_create 1340
333#define __NR_bpf 1341 333#define __NR_bpf 1341
334#define __NR_execveat 1342
334 335
335#endif /* _UAPI_ASM_IA64_UNISTD_H */ 336#endif /* _UAPI_ASM_IA64_UNISTD_H */
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 615ef81def49..e795cb848154 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -893,13 +893,13 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
893} 893}
894 894
895/* wrapper to silence section mismatch warning */ 895/* wrapper to silence section mismatch warning */
896int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) 896int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
897{ 897{
898 return _acpi_map_lsapic(handle, physid, pcpu); 898 return _acpi_map_lsapic(handle, physid, pcpu);
899} 899}
900EXPORT_SYMBOL(acpi_map_lsapic); 900EXPORT_SYMBOL(acpi_map_cpu);
901 901
902int acpi_unmap_lsapic(int cpu) 902int acpi_unmap_cpu(int cpu)
903{ 903{
904 ia64_cpu_to_sapicid[cpu] = -1; 904 ia64_cpu_to_sapicid[cpu] = -1;
905 set_cpu_present(cpu, false); 905 set_cpu_present(cpu, false);
@@ -910,8 +910,7 @@ int acpi_unmap_lsapic(int cpu)
910 910
911 return (0); 911 return (0);
912} 912}
913 913EXPORT_SYMBOL(acpi_unmap_cpu);
914EXPORT_SYMBOL(acpi_unmap_lsapic);
915#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 914#endif /* CONFIG_ACPI_HOTPLUG_CPU */
916 915
917#ifdef CONFIG_ACPI_NUMA 916#ifdef CONFIG_ACPI_NUMA
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index f5e96dffc63c..fcf8b8cbca0b 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1779,6 +1779,7 @@ sys_call_table:
1779 data8 sys_getrandom 1779 data8 sys_getrandom
1780 data8 sys_memfd_create // 1340 1780 data8 sys_memfd_create // 1340
1781 data8 sys_bpf 1781 data8 sys_bpf
1782 data8 sys_execveat
1782 1783
1783 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls 1784 .org sys_call_table + 8*NR_syscalls // guard against failures to increase NR_syscalls
1784#endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */ 1785#endif /* __IA64_ASM_PARAVIRTUALIZED_NATIVE */
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c
index 51d5bb90d3e5..a223691dff4f 100644
--- a/arch/nios2/kernel/cpuinfo.c
+++ b/arch/nios2/kernel/cpuinfo.c
@@ -72,6 +72,7 @@ void __init setup_cpuinfo(void)
72 cpuinfo.has_div = fcpu_has(cpu, "altr,has-div"); 72 cpuinfo.has_div = fcpu_has(cpu, "altr,has-div");
73 cpuinfo.has_mul = fcpu_has(cpu, "altr,has-mul"); 73 cpuinfo.has_mul = fcpu_has(cpu, "altr,has-mul");
74 cpuinfo.has_mulx = fcpu_has(cpu, "altr,has-mulx"); 74 cpuinfo.has_mulx = fcpu_has(cpu, "altr,has-mulx");
75 cpuinfo.mmu = fcpu_has(cpu, "altr,has-mmu");
75 76
76 if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) 77 if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div)
77 err_cpu("DIV"); 78 err_cpu("DIV");
diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
index 83bca17d1008..0bdfd13ff98b 100644
--- a/arch/nios2/kernel/entry.S
+++ b/arch/nios2/kernel/entry.S
@@ -365,30 +365,14 @@ ENTRY(ret_from_interrupt)
365 GET_THREAD_INFO r1 365 GET_THREAD_INFO r1
366 ldw r4, TI_PREEMPT_COUNT(r1) 366 ldw r4, TI_PREEMPT_COUNT(r1)
367 bne r4, r0, restore_all 367 bne r4, r0, restore_all
368
369need_resched:
370 ldw r4, TI_FLAGS(r1) /* ? Need resched set */ 368 ldw r4, TI_FLAGS(r1) /* ? Need resched set */
371 BTBZ r10, r4, TIF_NEED_RESCHED, restore_all 369 BTBZ r10, r4, TIF_NEED_RESCHED, restore_all
372 ldw r4, PT_ESTATUS(sp) /* ? Interrupts off */ 370 ldw r4, PT_ESTATUS(sp) /* ? Interrupts off */
373 andi r10, r4, ESTATUS_EPIE 371 andi r10, r4, ESTATUS_EPIE
374 beq r10, r0, restore_all 372 beq r10, r0, restore_all
375 movia r4, PREEMPT_ACTIVE 373 call preempt_schedule_irq
376 stw r4, TI_PREEMPT_COUNT(r1)
377 rdctl r10, status /* enable intrs again */
378 ori r10, r10 ,STATUS_PIE
379 wrctl status, r10
380 PUSH r1
381 call schedule
382 POP r1
383 mov r4, r0
384 stw r4, TI_PREEMPT_COUNT(r1)
385 rdctl r10, status /* disable intrs */
386 andi r10, r10, %lo(~STATUS_PIE)
387 wrctl status, r10
388 br need_resched
389#else
390 br restore_all
391#endif 374#endif
375 br restore_all
392 376
393/*********************************************************************** 377/***********************************************************************
394 * A few syscall wrappers 378 * A few syscall wrappers
diff --git a/arch/parisc/include/asm/ldcw.h b/arch/parisc/include/asm/ldcw.h
index d2d11b7055ba..8121aa6db2ff 100644
--- a/arch/parisc/include/asm/ldcw.h
+++ b/arch/parisc/include/asm/ldcw.h
@@ -33,11 +33,18 @@
33 33
34#endif /*!CONFIG_PA20*/ 34#endif /*!CONFIG_PA20*/
35 35
36/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */ 36/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*.
37 We don't explicitly expose that "*a" may be written as reload
38 fails to find a register in class R1_REGS when "a" needs to be
39 reloaded when generating 64-bit PIC code. Instead, we clobber
40 memory to indicate to the compiler that the assembly code reads
41 or writes to items other than those listed in the input and output
42 operands. This may pessimize the code somewhat but __ldcw is
43 usually used within code blocks surrounded by memory barriors. */
37#define __ldcw(a) ({ \ 44#define __ldcw(a) ({ \
38 unsigned __ret; \ 45 unsigned __ret; \
39 __asm__ __volatile__(__LDCW " 0(%2),%0" \ 46 __asm__ __volatile__(__LDCW " 0(%1),%0" \
40 : "=r" (__ret), "+m" (*(a)) : "r" (a)); \ 47 : "=r" (__ret) : "r" (a) : "memory"); \
41 __ret; \ 48 __ret; \
42}) 49})
43 50
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 19c36cba37c4..a46f5f45570c 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -86,6 +86,11 @@ extern int overlaps_crashkernel(unsigned long start, unsigned long size);
86extern void reserve_crashkernel(void); 86extern void reserve_crashkernel(void);
87extern void machine_kexec_mask_interrupts(void); 87extern void machine_kexec_mask_interrupts(void);
88 88
89static inline bool kdump_in_progress(void)
90{
91 return crashing_cpu >= 0;
92}
93
89#else /* !CONFIG_KEXEC */ 94#else /* !CONFIG_KEXEC */
90static inline void crash_kexec_secondary(struct pt_regs *regs) { } 95static inline void crash_kexec_secondary(struct pt_regs *regs) { }
91 96
@@ -106,6 +111,11 @@ static inline int crash_shutdown_unregister(crash_shutdown_t handler)
106 return 0; 111 return 0;
107} 112}
108 113
114static inline bool kdump_in_progress(void)
115{
116 return false;
117}
118
109#endif /* CONFIG_KEXEC */ 119#endif /* CONFIG_KEXEC */
110#endif /* ! __ASSEMBLY__ */ 120#endif /* ! __ASSEMBLY__ */
111#endif /* __KERNEL__ */ 121#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index ce9577d693be..91062eef582f 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -366,3 +366,4 @@ SYSCALL_SPU(seccomp)
366SYSCALL_SPU(getrandom) 366SYSCALL_SPU(getrandom)
367SYSCALL_SPU(memfd_create) 367SYSCALL_SPU(memfd_create)
368SYSCALL_SPU(bpf) 368SYSCALL_SPU(bpf)
369COMPAT_SYS(execveat)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index e0da021caa00..36b79c31eedd 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
12#include <uapi/asm/unistd.h> 12#include <uapi/asm/unistd.h>
13 13
14 14
15#define __NR_syscalls 362 15#define __NR_syscalls 363
16 16
17#define __NR__exit __NR_exit 17#define __NR__exit __NR_exit
18#define NR_syscalls __NR_syscalls 18#define NR_syscalls __NR_syscalls
diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h
index f55351f2e66e..ef5b5b1f3123 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -384,5 +384,6 @@
384#define __NR_getrandom 359 384#define __NR_getrandom 359
385#define __NR_memfd_create 360 385#define __NR_memfd_create 360
386#define __NR_bpf 361 386#define __NR_bpf 361
387#define __NR_execveat 362
387 388
388#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 389#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 879b3aacac32..f96d1ec24189 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -330,7 +330,7 @@ void default_machine_kexec(struct kimage *image)
330 * using debugger IPI. 330 * using debugger IPI.
331 */ 331 */
332 332
333 if (crashing_cpu == -1) 333 if (!kdump_in_progress())
334 kexec_prepare_cpus(); 334 kexec_prepare_cpus();
335 335
336 pr_debug("kexec: Starting switchover sequence.\n"); 336 pr_debug("kexec: Starting switchover sequence.\n");
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 8ec017cb4446..8b2d2dc8ef10 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -700,6 +700,7 @@ void start_secondary(void *unused)
700 smp_store_cpu_info(cpu); 700 smp_store_cpu_info(cpu);
701 set_dec(tb_ticks_per_jiffy); 701 set_dec(tb_ticks_per_jiffy);
702 preempt_disable(); 702 preempt_disable();
703 cpu_callin_map[cpu] = 1;
703 704
704 if (smp_ops->setup_cpu) 705 if (smp_ops->setup_cpu)
705 smp_ops->setup_cpu(cpu); 706 smp_ops->setup_cpu(cpu);
@@ -738,14 +739,6 @@ void start_secondary(void *unused)
738 notify_cpu_starting(cpu); 739 notify_cpu_starting(cpu);
739 set_cpu_online(cpu, true); 740 set_cpu_online(cpu, true);
740 741
741 /*
742 * CPU must be marked active and online before we signal back to the
743 * master, because the scheduler needs to see the cpu_online and
744 * cpu_active bits set.
745 */
746 smp_wmb();
747 cpu_callin_map[cpu] = 1;
748
749 local_irq_enable(); 742 local_irq_enable();
750 743
751 cpu_startup_entry(CPUHP_ONLINE); 744 cpu_startup_entry(CPUHP_ONLINE);
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 469751d92004..b5682fd6c984 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -43,6 +43,7 @@
43#include <asm/trace.h> 43#include <asm/trace.h>
44#include <asm/firmware.h> 44#include <asm/firmware.h>
45#include <asm/plpar_wrappers.h> 45#include <asm/plpar_wrappers.h>
46#include <asm/kexec.h>
46#include <asm/fadump.h> 47#include <asm/fadump.h>
47 48
48#include "pseries.h" 49#include "pseries.h"
@@ -267,8 +268,13 @@ static void pSeries_lpar_hptab_clear(void)
267 * out to the user, but at least this will stop us from 268 * out to the user, but at least this will stop us from
268 * continuing on further and creating an even more 269 * continuing on further and creating an even more
269 * difficult to debug situation. 270 * difficult to debug situation.
271 *
272 * There is a known problem when kdump'ing, if cpus are offline
273 * the above call will fail. Rather than panicking again, keep
274 * going and hope the kdump kernel is also little endian, which
275 * it usually is.
270 */ 276 */
271 if (rc) 277 if (rc && !kdump_in_progress())
272 panic("Could not enable big endian exceptions"); 278 panic("Could not enable big endian exceptions");
273 } 279 }
274#endif 280#endif
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 87bc86821bc9..d195a87ca542 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -3,6 +3,7 @@ config UML
3 default y 3 default y
4 select HAVE_ARCH_AUDITSYSCALL 4 select HAVE_ARCH_AUDITSYSCALL
5 select HAVE_UID16 5 select HAVE_UID16
6 select HAVE_FUTEX_CMPXCHG if FUTEX
6 select GENERIC_IRQ_SHOW 7 select GENERIC_IRQ_SHOW
7 select GENERIC_CPU_DEVICES 8 select GENERIC_CPU_DEVICES
8 select GENERIC_IO 9 select GENERIC_IO
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 5b016e2498f3..3db07f30636f 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -51,6 +51,7 @@ targets += cpustr.h
51$(obj)/cpustr.h: $(obj)/mkcpustr FORCE 51$(obj)/cpustr.h: $(obj)/mkcpustr FORCE
52 $(call if_changed,cpustr) 52 $(call if_changed,cpustr)
53endif 53endif
54clean-files += cpustr.h
54 55
55# --------------------------------------------------------------------------- 56# ---------------------------------------------------------------------------
56 57
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index fd0f848938cc..5a4a089e8b1f 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o
26 26
27obj-$(CONFIG_CRYPTO_CRC32C_INTEL) += crc32c-intel.o 27obj-$(CONFIG_CRYPTO_CRC32C_INTEL) += crc32c-intel.o
28obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o 28obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o
29obj-$(CONFIG_CRYPTO_SHA1_MB) += sha-mb/
30obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o 29obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o
31obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o 30obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o
32obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o 31obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o
@@ -46,6 +45,7 @@ endif
46ifeq ($(avx2_supported),yes) 45ifeq ($(avx2_supported),yes)
47 obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64) += camellia-aesni-avx2.o 46 obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64) += camellia-aesni-avx2.o
48 obj-$(CONFIG_CRYPTO_SERPENT_AVX2_X86_64) += serpent-avx2.o 47 obj-$(CONFIG_CRYPTO_SERPENT_AVX2_X86_64) += serpent-avx2.o
48 obj-$(CONFIG_CRYPTO_SHA1_MB) += sha-mb/
49endif 49endif
50 50
51aes-i586-y := aes-i586-asm_32.o aes_glue.o 51aes-i586-y := aes-i586-asm_32.o aes_glue.o
diff --git a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
index 2df2a0298f5a..a916c4a61165 100644
--- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
+++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S
@@ -208,7 +208,7 @@ ddq_add_8:
208 208
209 .if (klen == KEY_128) 209 .if (klen == KEY_128)
210 .if (load_keys) 210 .if (load_keys)
211 vmovdqa 3*16(p_keys), xkeyA 211 vmovdqa 3*16(p_keys), xkey4
212 .endif 212 .endif
213 .else 213 .else
214 vmovdqa 3*16(p_keys), xkeyA 214 vmovdqa 3*16(p_keys), xkeyA
@@ -224,7 +224,7 @@ ddq_add_8:
224 add $(16*by), p_in 224 add $(16*by), p_in
225 225
226 .if (klen == KEY_128) 226 .if (klen == KEY_128)
227 vmovdqa 4*16(p_keys), xkey4 227 vmovdqa 4*16(p_keys), xkeyB
228 .else 228 .else
229 .if (load_keys) 229 .if (load_keys)
230 vmovdqa 4*16(p_keys), xkey4 230 vmovdqa 4*16(p_keys), xkey4
@@ -234,7 +234,12 @@ ddq_add_8:
234 .set i, 0 234 .set i, 0
235 .rept by 235 .rept by
236 club XDATA, i 236 club XDATA, i
237 vaesenc xkeyA, var_xdata, var_xdata /* key 3 */ 237 /* key 3 */
238 .if (klen == KEY_128)
239 vaesenc xkey4, var_xdata, var_xdata
240 .else
241 vaesenc xkeyA, var_xdata, var_xdata
242 .endif
238 .set i, (i +1) 243 .set i, (i +1)
239 .endr 244 .endr
240 245
@@ -243,13 +248,18 @@ ddq_add_8:
243 .set i, 0 248 .set i, 0
244 .rept by 249 .rept by
245 club XDATA, i 250 club XDATA, i
246 vaesenc xkey4, var_xdata, var_xdata /* key 4 */ 251 /* key 4 */
252 .if (klen == KEY_128)
253 vaesenc xkeyB, var_xdata, var_xdata
254 .else
255 vaesenc xkey4, var_xdata, var_xdata
256 .endif
247 .set i, (i +1) 257 .set i, (i +1)
248 .endr 258 .endr
249 259
250 .if (klen == KEY_128) 260 .if (klen == KEY_128)
251 .if (load_keys) 261 .if (load_keys)
252 vmovdqa 6*16(p_keys), xkeyB 262 vmovdqa 6*16(p_keys), xkey8
253 .endif 263 .endif
254 .else 264 .else
255 vmovdqa 6*16(p_keys), xkeyB 265 vmovdqa 6*16(p_keys), xkeyB
@@ -267,12 +277,17 @@ ddq_add_8:
267 .set i, 0 277 .set i, 0
268 .rept by 278 .rept by
269 club XDATA, i 279 club XDATA, i
270 vaesenc xkeyB, var_xdata, var_xdata /* key 6 */ 280 /* key 6 */
281 .if (klen == KEY_128)
282 vaesenc xkey8, var_xdata, var_xdata
283 .else
284 vaesenc xkeyB, var_xdata, var_xdata
285 .endif
271 .set i, (i +1) 286 .set i, (i +1)
272 .endr 287 .endr
273 288
274 .if (klen == KEY_128) 289 .if (klen == KEY_128)
275 vmovdqa 8*16(p_keys), xkey8 290 vmovdqa 8*16(p_keys), xkeyB
276 .else 291 .else
277 .if (load_keys) 292 .if (load_keys)
278 vmovdqa 8*16(p_keys), xkey8 293 vmovdqa 8*16(p_keys), xkey8
@@ -288,7 +303,7 @@ ddq_add_8:
288 303
289 .if (klen == KEY_128) 304 .if (klen == KEY_128)
290 .if (load_keys) 305 .if (load_keys)
291 vmovdqa 9*16(p_keys), xkeyA 306 vmovdqa 9*16(p_keys), xkey12
292 .endif 307 .endif
293 .else 308 .else
294 vmovdqa 9*16(p_keys), xkeyA 309 vmovdqa 9*16(p_keys), xkeyA
@@ -297,7 +312,12 @@ ddq_add_8:
297 .set i, 0 312 .set i, 0
298 .rept by 313 .rept by
299 club XDATA, i 314 club XDATA, i
300 vaesenc xkey8, var_xdata, var_xdata /* key 8 */ 315 /* key 8 */
316 .if (klen == KEY_128)
317 vaesenc xkeyB, var_xdata, var_xdata
318 .else
319 vaesenc xkey8, var_xdata, var_xdata
320 .endif
301 .set i, (i +1) 321 .set i, (i +1)
302 .endr 322 .endr
303 323
@@ -306,7 +326,12 @@ ddq_add_8:
306 .set i, 0 326 .set i, 0
307 .rept by 327 .rept by
308 club XDATA, i 328 club XDATA, i
309 vaesenc xkeyA, var_xdata, var_xdata /* key 9 */ 329 /* key 9 */
330 .if (klen == KEY_128)
331 vaesenc xkey12, var_xdata, var_xdata
332 .else
333 vaesenc xkeyA, var_xdata, var_xdata
334 .endif
310 .set i, (i +1) 335 .set i, (i +1)
311 .endr 336 .endr
312 337
@@ -412,7 +437,6 @@ ddq_add_8:
412/* main body of aes ctr load */ 437/* main body of aes ctr load */
413 438
414.macro do_aes_ctrmain key_len 439.macro do_aes_ctrmain key_len
415
416 cmp $16, num_bytes 440 cmp $16, num_bytes
417 jb .Ldo_return2\key_len 441 jb .Ldo_return2\key_len
418 442
diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h
index e7e9682a33e9..f556c4843aa1 100644
--- a/arch/x86/include/asm/vgtod.h
+++ b/arch/x86/include/asm/vgtod.h
@@ -80,9 +80,11 @@ static inline unsigned int __getcpu(void)
80 80
81 /* 81 /*
82 * Load per CPU data from GDT. LSL is faster than RDTSCP and 82 * Load per CPU data from GDT. LSL is faster than RDTSCP and
83 * works on all CPUs. 83 * works on all CPUs. This is volatile so that it orders
84 * correctly wrt barrier() and to keep gcc from cleverly
85 * hoisting it out of the calling function.
84 */ 86 */
85 asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG)); 87 asm volatile ("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
86 88
87 return p; 89 return p;
88} 90}
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4433a4be8171..d1626364a28a 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -750,13 +750,13 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
750} 750}
751 751
752/* wrapper to silence section mismatch warning */ 752/* wrapper to silence section mismatch warning */
753int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) 753int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu)
754{ 754{
755 return _acpi_map_lsapic(handle, physid, pcpu); 755 return _acpi_map_lsapic(handle, physid, pcpu);
756} 756}
757EXPORT_SYMBOL(acpi_map_lsapic); 757EXPORT_SYMBOL(acpi_map_cpu);
758 758
759int acpi_unmap_lsapic(int cpu) 759int acpi_unmap_cpu(int cpu)
760{ 760{
761#ifdef CONFIG_ACPI_NUMA 761#ifdef CONFIG_ACPI_NUMA
762 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); 762 set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
@@ -768,8 +768,7 @@ int acpi_unmap_lsapic(int cpu)
768 768
769 return (0); 769 return (0);
770} 770}
771 771EXPORT_SYMBOL(acpi_unmap_cpu);
772EXPORT_SYMBOL(acpi_unmap_lsapic);
773#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 772#endif /* CONFIG_ACPI_HOTPLUG_CPU */
774 773
775int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) 774int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index e27b49d7c922..80091ae54c2b 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -66,3 +66,4 @@ targets += capflags.c
66$(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE 66$(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE
67 $(call if_changed,mkcapflags) 67 $(call if_changed,mkcapflags)
68endif 68endif
69clean-files += capflags.c
diff --git a/arch/x86/kernel/cpu/mkcapflags.sh b/arch/x86/kernel/cpu/mkcapflags.sh
index e2b22df964cd..36d99a337b49 100644
--- a/arch/x86/kernel/cpu/mkcapflags.sh
+++ b/arch/x86/kernel/cpu/mkcapflags.sh
@@ -28,7 +28,7 @@ function dump_array()
28 # If the /* comment */ starts with a quote string, grab that. 28 # If the /* comment */ starts with a quote string, grab that.
29 VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')" 29 VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')"
30 [ -z "$VALUE" ] && VALUE="\"$NAME\"" 30 [ -z "$VALUE" ] && VALUE="\"$NAME\""
31 [ "$VALUE" == '""' ] && continue 31 [ "$VALUE" = '""' ] && continue
32 32
33 # Name is uppercase, VALUE is all lowercase 33 # Name is uppercase, VALUE is all lowercase
34 VALUE="$(echo "$VALUE" | tr A-Z a-z)" 34 VALUE="$(echo "$VALUE" | tr A-Z a-z)"
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
index 18eb78bbdd10..863d9b02563e 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
@@ -17,7 +17,7 @@
17#define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff) 17#define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff)
18#define UNCORE_PCI_DEV_IDX(data) (data & 0xff) 18#define UNCORE_PCI_DEV_IDX(data) (data & 0xff)
19#define UNCORE_EXTRA_PCI_DEV 0xff 19#define UNCORE_EXTRA_PCI_DEV 0xff
20#define UNCORE_EXTRA_PCI_DEV_MAX 2 20#define UNCORE_EXTRA_PCI_DEV_MAX 3
21 21
22/* support up to 8 sockets */ 22/* support up to 8 sockets */
23#define UNCORE_SOCKET_MAX 8 23#define UNCORE_SOCKET_MAX 8
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
index 745b158e9a65..21af6149edf2 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -891,6 +891,7 @@ void snbep_uncore_cpu_init(void)
891enum { 891enum {
892 SNBEP_PCI_QPI_PORT0_FILTER, 892 SNBEP_PCI_QPI_PORT0_FILTER,
893 SNBEP_PCI_QPI_PORT1_FILTER, 893 SNBEP_PCI_QPI_PORT1_FILTER,
894 HSWEP_PCI_PCU_3,
894}; 895};
895 896
896static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event) 897static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event)
@@ -2026,6 +2027,17 @@ void hswep_uncore_cpu_init(void)
2026{ 2027{
2027 if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) 2028 if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores)
2028 hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; 2029 hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores;
2030
2031 /* Detect 6-8 core systems with only two SBOXes */
2032 if (uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3]) {
2033 u32 capid4;
2034
2035 pci_read_config_dword(uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3],
2036 0x94, &capid4);
2037 if (((capid4 >> 6) & 0x3) == 0)
2038 hswep_uncore_sbox.num_boxes = 2;
2039 }
2040
2029 uncore_msr_uncores = hswep_msr_uncores; 2041 uncore_msr_uncores = hswep_msr_uncores;
2030} 2042}
2031 2043
@@ -2287,6 +2299,11 @@ static DEFINE_PCI_DEVICE_TABLE(hswep_uncore_pci_ids) = {
2287 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 2299 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
2288 SNBEP_PCI_QPI_PORT1_FILTER), 2300 SNBEP_PCI_QPI_PORT1_FILTER),
2289 }, 2301 },
2302 { /* PCU.3 (for Capability registers) */
2303 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2fc0),
2304 .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV,
2305 HSWEP_PCI_PCU_3),
2306 },
2290 { /* end: all zeroes */ } 2307 { /* end: all zeroes */ }
2291}; 2308};
2292 2309
diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c
index e309cc5c276e..781861cc5ee8 100644
--- a/arch/x86/kernel/perf_regs.c
+++ b/arch/x86/kernel/perf_regs.c
@@ -78,6 +78,14 @@ u64 perf_reg_abi(struct task_struct *task)
78{ 78{
79 return PERF_SAMPLE_REGS_ABI_32; 79 return PERF_SAMPLE_REGS_ABI_32;
80} 80}
81
82void perf_get_regs_user(struct perf_regs *regs_user,
83 struct pt_regs *regs,
84 struct pt_regs *regs_user_copy)
85{
86 regs_user->regs = task_pt_regs(current);
87 regs_user->abi = perf_reg_abi(current);
88}
81#else /* CONFIG_X86_64 */ 89#else /* CONFIG_X86_64 */
82#define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ 90#define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \
83 (1ULL << PERF_REG_X86_ES) | \ 91 (1ULL << PERF_REG_X86_ES) | \
@@ -102,4 +110,86 @@ u64 perf_reg_abi(struct task_struct *task)
102 else 110 else
103 return PERF_SAMPLE_REGS_ABI_64; 111 return PERF_SAMPLE_REGS_ABI_64;
104} 112}
113
114void perf_get_regs_user(struct perf_regs *regs_user,
115 struct pt_regs *regs,
116 struct pt_regs *regs_user_copy)
117{
118 struct pt_regs *user_regs = task_pt_regs(current);
119
120 /*
121 * If we're in an NMI that interrupted task_pt_regs setup, then
122 * we can't sample user regs at all. This check isn't really
123 * sufficient, though, as we could be in an NMI inside an interrupt
124 * that happened during task_pt_regs setup.
125 */
126 if (regs->sp > (unsigned long)&user_regs->r11 &&
127 regs->sp <= (unsigned long)(user_regs + 1)) {
128 regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;
129 regs_user->regs = NULL;
130 return;
131 }
132
133 /*
134 * RIP, flags, and the argument registers are usually saved.
135 * orig_ax is probably okay, too.
136 */
137 regs_user_copy->ip = user_regs->ip;
138 regs_user_copy->cx = user_regs->cx;
139 regs_user_copy->dx = user_regs->dx;
140 regs_user_copy->si = user_regs->si;
141 regs_user_copy->di = user_regs->di;
142 regs_user_copy->r8 = user_regs->r8;
143 regs_user_copy->r9 = user_regs->r9;
144 regs_user_copy->r10 = user_regs->r10;
145 regs_user_copy->r11 = user_regs->r11;
146 regs_user_copy->orig_ax = user_regs->orig_ax;
147 regs_user_copy->flags = user_regs->flags;
148
149 /*
150 * Don't even try to report the "rest" regs.
151 */
152 regs_user_copy->bx = -1;
153 regs_user_copy->bp = -1;
154 regs_user_copy->r12 = -1;
155 regs_user_copy->r13 = -1;
156 regs_user_copy->r14 = -1;
157 regs_user_copy->r15 = -1;
158
159 /*
160 * For this to be at all useful, we need a reasonable guess for
161 * sp and the ABI. Be careful: we're in NMI context, and we're
162 * considering current to be the current task, so we should
163 * be careful not to look at any other percpu variables that might
164 * change during context switches.
165 */
166 if (IS_ENABLED(CONFIG_IA32_EMULATION) &&
167 task_thread_info(current)->status & TS_COMPAT) {
168 /* Easy case: we're in a compat syscall. */
169 regs_user->abi = PERF_SAMPLE_REGS_ABI_32;
170 regs_user_copy->sp = user_regs->sp;
171 regs_user_copy->cs = user_regs->cs;
172 regs_user_copy->ss = user_regs->ss;
173 } else if (user_regs->orig_ax != -1) {
174 /*
175 * We're probably in a 64-bit syscall.
176 * Warning: this code is severely racy. At least it's better
177 * than just blindly copying user_regs.
178 */
179 regs_user->abi = PERF_SAMPLE_REGS_ABI_64;
180 regs_user_copy->sp = this_cpu_read(old_rsp);
181 regs_user_copy->cs = __USER_CS;
182 regs_user_copy->ss = __USER_DS;
183 regs_user_copy->cx = -1; /* usually contains garbage */
184 } else {
185 /* We're probably in an interrupt or exception. */
186 regs_user->abi = user_64bit_mode(user_regs) ?
187 PERF_SAMPLE_REGS_ABI_64 : PERF_SAMPLE_REGS_ABI_32;
188 regs_user_copy->sp = user_regs->sp;
189 regs_user_copy->cs = user_regs->cs;
190 regs_user_copy->ss = user_regs->ss;
191 }
192
193 regs_user->regs = regs_user_copy;
194}
105#endif /* CONFIG_X86_32 */ 195#endif /* CONFIG_X86_32 */
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 10fbed126b11..f83fc6c5e0ba 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4448,7 +4448,7 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm)
4448 * zap all shadow pages. 4448 * zap all shadow pages.
4449 */ 4449 */
4450 if (unlikely(kvm_current_mmio_generation(kvm) == 0)) { 4450 if (unlikely(kvm_current_mmio_generation(kvm) == 0)) {
4451 printk_ratelimited(KERN_INFO "kvm: zapping shadow pages for mmio generation wraparound\n"); 4451 printk_ratelimited(KERN_DEBUG "kvm: zapping shadow pages for mmio generation wraparound\n");
4452 kvm_mmu_invalidate_zap_all_pages(kvm); 4452 kvm_mmu_invalidate_zap_all_pages(kvm);
4453 } 4453 }
4454} 4454}
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index feb852b04598..d4c58d884838 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5840,53 +5840,10 @@ static __init int hardware_setup(void)
5840 memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE); 5840 memset(vmx_msr_bitmap_legacy, 0xff, PAGE_SIZE);
5841 memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE); 5841 memset(vmx_msr_bitmap_longmode, 0xff, PAGE_SIZE);
5842 5842
5843 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
5844 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
5845 vmx_disable_intercept_for_msr(MSR_KERNEL_GS_BASE, true);
5846 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_CS, false);
5847 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_ESP, false);
5848 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false);
5849 vmx_disable_intercept_for_msr(MSR_IA32_BNDCFGS, true);
5850
5851 memcpy(vmx_msr_bitmap_legacy_x2apic,
5852 vmx_msr_bitmap_legacy, PAGE_SIZE);
5853 memcpy(vmx_msr_bitmap_longmode_x2apic,
5854 vmx_msr_bitmap_longmode, PAGE_SIZE);
5855
5856 if (enable_apicv) {
5857 for (msr = 0x800; msr <= 0x8ff; msr++)
5858 vmx_disable_intercept_msr_read_x2apic(msr);
5859
5860 /* According SDM, in x2apic mode, the whole id reg is used.
5861 * But in KVM, it only use the highest eight bits. Need to
5862 * intercept it */
5863 vmx_enable_intercept_msr_read_x2apic(0x802);
5864 /* TMCCT */
5865 vmx_enable_intercept_msr_read_x2apic(0x839);
5866 /* TPR */
5867 vmx_disable_intercept_msr_write_x2apic(0x808);
5868 /* EOI */
5869 vmx_disable_intercept_msr_write_x2apic(0x80b);
5870 /* SELF-IPI */
5871 vmx_disable_intercept_msr_write_x2apic(0x83f);
5872 }
5873
5874 if (enable_ept) {
5875 kvm_mmu_set_mask_ptes(0ull,
5876 (enable_ept_ad_bits) ? VMX_EPT_ACCESS_BIT : 0ull,
5877 (enable_ept_ad_bits) ? VMX_EPT_DIRTY_BIT : 0ull,
5878 0ull, VMX_EPT_EXECUTABLE_MASK);
5879 ept_set_mmio_spte_mask();
5880 kvm_enable_tdp();
5881 } else
5882 kvm_disable_tdp();
5883
5884 update_ple_window_actual_max();
5885
5886 if (setup_vmcs_config(&vmcs_config) < 0) { 5843 if (setup_vmcs_config(&vmcs_config) < 0) {
5887 r = -EIO; 5844 r = -EIO;
5888 goto out7; 5845 goto out7;
5889 } 5846 }
5890 5847
5891 if (boot_cpu_has(X86_FEATURE_NX)) 5848 if (boot_cpu_has(X86_FEATURE_NX))
5892 kvm_enable_efer_bits(EFER_NX); 5849 kvm_enable_efer_bits(EFER_NX);
@@ -5945,6 +5902,49 @@ static __init int hardware_setup(void)
5945 if (nested) 5902 if (nested)
5946 nested_vmx_setup_ctls_msrs(); 5903 nested_vmx_setup_ctls_msrs();
5947 5904
5905 vmx_disable_intercept_for_msr(MSR_FS_BASE, false);
5906 vmx_disable_intercept_for_msr(MSR_GS_BASE, false);
5907 vmx_disable_intercept_for_msr(MSR_KERNEL_GS_BASE, true);
5908 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_CS, false);
5909 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_ESP, false);
5910 vmx_disable_intercept_for_msr(MSR_IA32_SYSENTER_EIP, false);
5911 vmx_disable_intercept_for_msr(MSR_IA32_BNDCFGS, true);
5912
5913 memcpy(vmx_msr_bitmap_legacy_x2apic,
5914 vmx_msr_bitmap_legacy, PAGE_SIZE);
5915 memcpy(vmx_msr_bitmap_longmode_x2apic,
5916 vmx_msr_bitmap_longmode, PAGE_SIZE);
5917
5918 if (enable_apicv) {
5919 for (msr = 0x800; msr <= 0x8ff; msr++)
5920 vmx_disable_intercept_msr_read_x2apic(msr);
5921
5922 /* According SDM, in x2apic mode, the whole id reg is used.
5923 * But in KVM, it only use the highest eight bits. Need to
5924 * intercept it */
5925 vmx_enable_intercept_msr_read_x2apic(0x802);
5926 /* TMCCT */
5927 vmx_enable_intercept_msr_read_x2apic(0x839);
5928 /* TPR */
5929 vmx_disable_intercept_msr_write_x2apic(0x808);
5930 /* EOI */
5931 vmx_disable_intercept_msr_write_x2apic(0x80b);
5932 /* SELF-IPI */
5933 vmx_disable_intercept_msr_write_x2apic(0x83f);
5934 }
5935
5936 if (enable_ept) {
5937 kvm_mmu_set_mask_ptes(0ull,
5938 (enable_ept_ad_bits) ? VMX_EPT_ACCESS_BIT : 0ull,
5939 (enable_ept_ad_bits) ? VMX_EPT_DIRTY_BIT : 0ull,
5940 0ull, VMX_EPT_EXECUTABLE_MASK);
5941 ept_set_mmio_spte_mask();
5942 kvm_enable_tdp();
5943 } else
5944 kvm_disable_tdp();
5945
5946 update_ple_window_actual_max();
5947
5948 return alloc_kvm_area(); 5948 return alloc_kvm_area();
5949 5949
5950out7: 5950out7:
diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
index 2480978b31cc..1313ae6b478b 100644
--- a/arch/x86/lib/insn.c
+++ b/arch/x86/lib/insn.c
@@ -28,7 +28,7 @@
28 28
29/* Verify next sizeof(t) bytes can be on the same instruction */ 29/* Verify next sizeof(t) bytes can be on the same instruction */
30#define validate_next(t, insn, n) \ 30#define validate_next(t, insn, n) \
31 ((insn)->next_byte + sizeof(t) + n < (insn)->end_kaddr) 31 ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr)
32 32
33#define __get_next(t, insn) \ 33#define __get_next(t, insn) \
34 ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) 34 ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; })
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index a97ee0801475..08a7d313538a 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -438,20 +438,20 @@ static unsigned long __init init_range_memory_mapping(
438static unsigned long __init get_new_step_size(unsigned long step_size) 438static unsigned long __init get_new_step_size(unsigned long step_size)
439{ 439{
440 /* 440 /*
441 * Explain why we shift by 5 and why we don't have to worry about 441 * Initial mapped size is PMD_SIZE (2M).
442 * 'step_size << 5' overflowing:
443 *
444 * initial mapped size is PMD_SIZE (2M).
445 * We can not set step_size to be PUD_SIZE (1G) yet. 442 * We can not set step_size to be PUD_SIZE (1G) yet.
446 * In worse case, when we cross the 1G boundary, and 443 * In worse case, when we cross the 1G boundary, and
447 * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k) 444 * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k)
448 * to map 1G range with PTE. Use 5 as shift for now. 445 * to map 1G range with PTE. Hence we use one less than the
446 * difference of page table level shifts.
449 * 447 *
450 * Don't need to worry about overflow, on 32bit, when step_size 448 * Don't need to worry about overflow in the top-down case, on 32bit,
451 * is 0, round_down() returns 0 for start, and that turns it 449 * when step_size is 0, round_down() returns 0 for start, and that
452 * into 0x100000000ULL. 450 * turns it into 0x100000000ULL.
451 * In the bottom-up case, round_up(x, 0) returns 0 though too, which
452 * needs to be taken into consideration by the code below.
453 */ 453 */
454 return step_size << 5; 454 return step_size << (PMD_SHIFT - PAGE_SHIFT - 1);
455} 455}
456 456
457/** 457/**
@@ -471,7 +471,6 @@ static void __init memory_map_top_down(unsigned long map_start,
471 unsigned long step_size; 471 unsigned long step_size;
472 unsigned long addr; 472 unsigned long addr;
473 unsigned long mapped_ram_size = 0; 473 unsigned long mapped_ram_size = 0;
474 unsigned long new_mapped_ram_size;
475 474
476 /* xen has big range in reserved near end of ram, skip it at first.*/ 475 /* xen has big range in reserved near end of ram, skip it at first.*/
477 addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE); 476 addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE);
@@ -496,14 +495,12 @@ static void __init memory_map_top_down(unsigned long map_start,
496 start = map_start; 495 start = map_start;
497 } else 496 } else
498 start = map_start; 497 start = map_start;
499 new_mapped_ram_size = init_range_memory_mapping(start, 498 mapped_ram_size += init_range_memory_mapping(start,
500 last_start); 499 last_start);
501 last_start = start; 500 last_start = start;
502 min_pfn_mapped = last_start >> PAGE_SHIFT; 501 min_pfn_mapped = last_start >> PAGE_SHIFT;
503 /* only increase step_size after big range get mapped */ 502 if (mapped_ram_size >= step_size)
504 if (new_mapped_ram_size > mapped_ram_size)
505 step_size = get_new_step_size(step_size); 503 step_size = get_new_step_size(step_size);
506 mapped_ram_size += new_mapped_ram_size;
507 } 504 }
508 505
509 if (real_end < map_end) 506 if (real_end < map_end)
@@ -524,7 +521,7 @@ static void __init memory_map_top_down(unsigned long map_start,
524static void __init memory_map_bottom_up(unsigned long map_start, 521static void __init memory_map_bottom_up(unsigned long map_start,
525 unsigned long map_end) 522 unsigned long map_end)
526{ 523{
527 unsigned long next, new_mapped_ram_size, start; 524 unsigned long next, start;
528 unsigned long mapped_ram_size = 0; 525 unsigned long mapped_ram_size = 0;
529 /* step_size need to be small so pgt_buf from BRK could cover it */ 526 /* step_size need to be small so pgt_buf from BRK could cover it */
530 unsigned long step_size = PMD_SIZE; 527 unsigned long step_size = PMD_SIZE;
@@ -539,19 +536,19 @@ static void __init memory_map_bottom_up(unsigned long map_start,
539 * for page table. 536 * for page table.
540 */ 537 */
541 while (start < map_end) { 538 while (start < map_end) {
542 if (map_end - start > step_size) { 539 if (step_size && map_end - start > step_size) {
543 next = round_up(start + 1, step_size); 540 next = round_up(start + 1, step_size);
544 if (next > map_end) 541 if (next > map_end)
545 next = map_end; 542 next = map_end;
546 } else 543 } else {
547 next = map_end; 544 next = map_end;
545 }
548 546
549 new_mapped_ram_size = init_range_memory_mapping(start, next); 547 mapped_ram_size += init_range_memory_mapping(start, next);
550 start = next; 548 start = next;
551 549
552 if (new_mapped_ram_size > mapped_ram_size) 550 if (mapped_ram_size >= step_size)
553 step_size = get_new_step_size(step_size); 551 step_size = get_new_step_size(step_size);
554 mapped_ram_size += new_mapped_ram_size;
555 } 552 }
556} 553}
557 554
diff --git a/arch/x86/um/sys_call_table_32.c b/arch/x86/um/sys_call_table_32.c
index 531d4269e2e3..bd16d6c370ec 100644
--- a/arch/x86/um/sys_call_table_32.c
+++ b/arch/x86/um/sys_call_table_32.c
@@ -34,7 +34,7 @@ typedef asmlinkage void (*sys_call_ptr_t)(void);
34 34
35extern asmlinkage void sys_ni_syscall(void); 35extern asmlinkage void sys_ni_syscall(void);
36 36
37const sys_call_ptr_t sys_call_table[] __cacheline_aligned = { 37const sys_call_ptr_t sys_call_table[] ____cacheline_aligned = {
38 /* 38 /*
39 * Smells like a compiler bug -- it doesn't work 39 * Smells like a compiler bug -- it doesn't work
40 * when the & below is removed. 40 * when the & below is removed.
diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c
index 20c3649d0691..5cdfa9db2217 100644
--- a/arch/x86/um/sys_call_table_64.c
+++ b/arch/x86/um/sys_call_table_64.c
@@ -47,7 +47,7 @@ typedef void (*sys_call_ptr_t)(void);
47 47
48extern void sys_ni_syscall(void); 48extern void sys_ni_syscall(void);
49 49
50const sys_call_ptr_t sys_call_table[] __cacheline_aligned = { 50const sys_call_ptr_t sys_call_table[] ____cacheline_aligned = {
51 /* 51 /*
52 * Smells like a compiler bug -- it doesn't work 52 * Smells like a compiler bug -- it doesn't work
53 * when the & below is removed. 53 * when the & below is removed.
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index 009495b9ab4b..1c9f750c3859 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -41,12 +41,17 @@ void __init init_vdso_image(const struct vdso_image *image)
41 41
42struct linux_binprm; 42struct linux_binprm;
43 43
44/* Put the vdso above the (randomized) stack with another randomized offset. 44/*
45 This way there is no hole in the middle of address space. 45 * Put the vdso above the (randomized) stack with another randomized
46 To save memory make sure it is still in the same PTE as the stack top. 46 * offset. This way there is no hole in the middle of address space.
47 This doesn't give that many random bits. 47 * To save memory make sure it is still in the same PTE as the stack
48 48 * top. This doesn't give that many random bits.
49 Only used for the 64-bit and x32 vdsos. */ 49 *
50 * Note that this algorithm is imperfect: the distribution of the vdso
51 * start address within a PMD is biased toward the end.
52 *
53 * Only used for the 64-bit and x32 vdsos.
54 */
50static unsigned long vdso_addr(unsigned long start, unsigned len) 55static unsigned long vdso_addr(unsigned long start, unsigned len)
51{ 56{
52#ifdef CONFIG_X86_32 57#ifdef CONFIG_X86_32
@@ -54,22 +59,30 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
54#else 59#else
55 unsigned long addr, end; 60 unsigned long addr, end;
56 unsigned offset; 61 unsigned offset;
57 end = (start + PMD_SIZE - 1) & PMD_MASK; 62
63 /*
64 * Round up the start address. It can start out unaligned as a result
65 * of stack start randomization.
66 */
67 start = PAGE_ALIGN(start);
68
69 /* Round the lowest possible end address up to a PMD boundary. */
70 end = (start + len + PMD_SIZE - 1) & PMD_MASK;
58 if (end >= TASK_SIZE_MAX) 71 if (end >= TASK_SIZE_MAX)
59 end = TASK_SIZE_MAX; 72 end = TASK_SIZE_MAX;
60 end -= len; 73 end -= len;
61 /* This loses some more bits than a modulo, but is cheaper */ 74
62 offset = get_random_int() & (PTRS_PER_PTE - 1); 75 if (end > start) {
63 addr = start + (offset << PAGE_SHIFT); 76 offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1);
64 if (addr >= end) 77 addr = start + (offset << PAGE_SHIFT);
65 addr = end; 78 } else {
79 addr = start;
80 }
66 81
67 /* 82 /*
68 * page-align it here so that get_unmapped_area doesn't 83 * Forcibly align the final address in case we have a hardware
69 * align it wrongfully again to the next page. addr can come in 4K 84 * issue that requires alignment for performance reasons.
70 * unaligned here as a result of stack start randomization.
71 */ 85 */
72 addr = PAGE_ALIGN(addr);
73 addr = align_vdso_addr(addr); 86 addr = align_vdso_addr(addr);
74 87
75 return addr; 88 return addr;
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 1fa7bc31be63..4665b79c729a 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -455,6 +455,9 @@ void af_alg_complete(struct crypto_async_request *req, int err)
455{ 455{
456 struct af_alg_completion *completion = req->data; 456 struct af_alg_completion *completion = req->data;
457 457
458 if (err == -EINPROGRESS)
459 return;
460
458 completion->err = err; 461 completion->err = err;
459 complete(&completion->completion); 462 complete(&completion->completion);
460} 463}
diff --git a/drivers/Makefile b/drivers/Makefile
index 67d2334dc41e..527a6da8d539 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -50,7 +50,10 @@ obj-$(CONFIG_RESET_CONTROLLER) += reset/
50obj-y += tty/ 50obj-y += tty/
51obj-y += char/ 51obj-y += char/
52 52
53# gpu/ comes after char for AGP vs DRM startup 53# iommu/ comes before gpu as gpu are using iommu controllers
54obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
55
56# gpu/ comes after char for AGP vs DRM startup and after iommu
54obj-y += gpu/ 57obj-y += gpu/
55 58
56obj-$(CONFIG_CONNECTOR) += connector/ 59obj-$(CONFIG_CONNECTOR) += connector/
@@ -141,7 +144,6 @@ obj-y += clk/
141 144
142obj-$(CONFIG_MAILBOX) += mailbox/ 145obj-$(CONFIG_MAILBOX) += mailbox/
143obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ 146obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
144obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
145obj-$(CONFIG_REMOTEPROC) += remoteproc/ 147obj-$(CONFIG_REMOTEPROC) += remoteproc/
146obj-$(CONFIG_RPMSG) += rpmsg/ 148obj-$(CONFIG_RPMSG) += rpmsg/
147 149
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 1fdf5e07a1c7..1020b1b53a17 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
170 acpi_status status; 170 acpi_status status;
171 int ret; 171 int ret;
172 172
173 if (pr->apic_id == -1) 173 if (pr->phys_id == -1)
174 return -ENODEV; 174 return -ENODEV;
175 175
176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); 176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
@@ -180,13 +180,13 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
180 cpu_maps_update_begin(); 180 cpu_maps_update_begin();
181 cpu_hotplug_begin(); 181 cpu_hotplug_begin();
182 182
183 ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id); 183 ret = acpi_map_cpu(pr->handle, pr->phys_id, &pr->id);
184 if (ret) 184 if (ret)
185 goto out; 185 goto out;
186 186
187 ret = arch_register_cpu(pr->id); 187 ret = arch_register_cpu(pr->id);
188 if (ret) { 188 if (ret) {
189 acpi_unmap_lsapic(pr->id); 189 acpi_unmap_cpu(pr->id);
190 goto out; 190 goto out;
191 } 191 }
192 192
@@ -215,7 +215,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
215 union acpi_object object = { 0 }; 215 union acpi_object object = { 0 };
216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
217 struct acpi_processor *pr = acpi_driver_data(device); 217 struct acpi_processor *pr = acpi_driver_data(device);
218 int apic_id, cpu_index, device_declaration = 0; 218 int phys_id, cpu_index, device_declaration = 0;
219 acpi_status status = AE_OK; 219 acpi_status status = AE_OK;
220 static int cpu0_initialized; 220 static int cpu0_initialized;
221 unsigned long long value; 221 unsigned long long value;
@@ -262,15 +262,18 @@ static int acpi_processor_get_info(struct acpi_device *device)
262 pr->acpi_id = value; 262 pr->acpi_id = value;
263 } 263 }
264 264
265 apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); 265 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
266 if (apic_id < 0) 266 if (phys_id < 0)
267 acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n"); 267 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
268 pr->apic_id = apic_id; 268 pr->phys_id = phys_id;
269 269
270 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); 270 cpu_index = acpi_map_cpuid(pr->phys_id, pr->acpi_id);
271 if (!cpu0_initialized && !acpi_has_cpu_in_madt()) { 271 if (!cpu0_initialized && !acpi_has_cpu_in_madt()) {
272 cpu0_initialized = 1; 272 cpu0_initialized = 1;
273 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 273 /*
274 * Handle UP system running SMP kernel, with no CPU
275 * entry in MADT
276 */
274 if ((cpu_index == -1) && (num_online_cpus() == 1)) 277 if ((cpu_index == -1) && (num_online_cpus() == 1))
275 cpu_index = 0; 278 cpu_index = 0;
276 } 279 }
@@ -458,7 +461,7 @@ static void acpi_processor_remove(struct acpi_device *device)
458 461
459 /* Remove the CPU. */ 462 /* Remove the CPU. */
460 arch_unregister_cpu(pr->id); 463 arch_unregister_cpu(pr->id);
461 acpi_unmap_lsapic(pr->id); 464 acpi_unmap_cpu(pr->id);
462 465
463 cpu_hotplug_done(); 466 cpu_hotplug_done();
464 cpu_maps_update_done(); 467 cpu_maps_update_done();
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index c2daa85fc9f7..c0d44d394ca3 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -257,7 +257,7 @@ int acpi_bus_init_power(struct acpi_device *device)
257 257
258 device->power.state = ACPI_STATE_UNKNOWN; 258 device->power.state = ACPI_STATE_UNKNOWN;
259 if (!acpi_device_is_present(device)) 259 if (!acpi_device_is_present(device))
260 return 0; 260 return -ENXIO;
261 261
262 result = acpi_device_get_power(device, &state); 262 result = acpi_device_get_power(device, &state);
263 if (result) 263 if (result)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 342942f90a10..02e48394276c 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -69,7 +69,7 @@ static int map_madt_entry(int type, u32 acpi_id)
69 unsigned long madt_end, entry; 69 unsigned long madt_end, entry;
70 static struct acpi_table_madt *madt; 70 static struct acpi_table_madt *madt;
71 static int read_madt; 71 static int read_madt;
72 int apic_id = -1; 72 int phys_id = -1; /* CPU hardware ID */
73 73
74 if (!read_madt) { 74 if (!read_madt) {
75 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, 75 if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0,
@@ -79,7 +79,7 @@ static int map_madt_entry(int type, u32 acpi_id)
79 } 79 }
80 80
81 if (!madt) 81 if (!madt)
82 return apic_id; 82 return phys_id;
83 83
84 entry = (unsigned long)madt; 84 entry = (unsigned long)madt;
85 madt_end = entry + madt->header.length; 85 madt_end = entry + madt->header.length;
@@ -91,18 +91,18 @@ static int map_madt_entry(int type, u32 acpi_id)
91 struct acpi_subtable_header *header = 91 struct acpi_subtable_header *header =
92 (struct acpi_subtable_header *)entry; 92 (struct acpi_subtable_header *)entry;
93 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { 93 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
94 if (!map_lapic_id(header, acpi_id, &apic_id)) 94 if (!map_lapic_id(header, acpi_id, &phys_id))
95 break; 95 break;
96 } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { 96 } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
97 if (!map_x2apic_id(header, type, acpi_id, &apic_id)) 97 if (!map_x2apic_id(header, type, acpi_id, &phys_id))
98 break; 98 break;
99 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 99 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
100 if (!map_lsapic_id(header, type, acpi_id, &apic_id)) 100 if (!map_lsapic_id(header, type, acpi_id, &phys_id))
101 break; 101 break;
102 } 102 }
103 entry += header->length; 103 entry += header->length;
104 } 104 }
105 return apic_id; 105 return phys_id;
106} 106}
107 107
108static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 108static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
@@ -110,7 +110,7 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
110 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 110 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
111 union acpi_object *obj; 111 union acpi_object *obj;
112 struct acpi_subtable_header *header; 112 struct acpi_subtable_header *header;
113 int apic_id = -1; 113 int phys_id = -1;
114 114
115 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 115 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
116 goto exit; 116 goto exit;
@@ -126,38 +126,38 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
126 126
127 header = (struct acpi_subtable_header *)obj->buffer.pointer; 127 header = (struct acpi_subtable_header *)obj->buffer.pointer;
128 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) 128 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC)
129 map_lapic_id(header, acpi_id, &apic_id); 129 map_lapic_id(header, acpi_id, &phys_id);
130 else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) 130 else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC)
131 map_lsapic_id(header, type, acpi_id, &apic_id); 131 map_lsapic_id(header, type, acpi_id, &phys_id);
132 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) 132 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
133 map_x2apic_id(header, type, acpi_id, &apic_id); 133 map_x2apic_id(header, type, acpi_id, &phys_id);
134 134
135exit: 135exit:
136 kfree(buffer.pointer); 136 kfree(buffer.pointer);
137 return apic_id; 137 return phys_id;
138} 138}
139 139
140int acpi_get_apicid(acpi_handle handle, int type, u32 acpi_id) 140int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
141{ 141{
142 int apic_id; 142 int phys_id;
143 143
144 apic_id = map_mat_entry(handle, type, acpi_id); 144 phys_id = map_mat_entry(handle, type, acpi_id);
145 if (apic_id == -1) 145 if (phys_id == -1)
146 apic_id = map_madt_entry(type, acpi_id); 146 phys_id = map_madt_entry(type, acpi_id);
147 147
148 return apic_id; 148 return phys_id;
149} 149}
150 150
151int acpi_map_cpuid(int apic_id, u32 acpi_id) 151int acpi_map_cpuid(int phys_id, u32 acpi_id)
152{ 152{
153#ifdef CONFIG_SMP 153#ifdef CONFIG_SMP
154 int i; 154 int i;
155#endif 155#endif
156 156
157 if (apic_id == -1) { 157 if (phys_id == -1) {
158 /* 158 /*
159 * On UP processor, there is no _MAT or MADT table. 159 * On UP processor, there is no _MAT or MADT table.
160 * So above apic_id is always set to -1. 160 * So above phys_id is always set to -1.
161 * 161 *
162 * BIOS may define multiple CPU handles even for UP processor. 162 * BIOS may define multiple CPU handles even for UP processor.
163 * For example, 163 * For example,
@@ -170,7 +170,7 @@ int acpi_map_cpuid(int apic_id, u32 acpi_id)
170 * Processor (CPU3, 0x03, 0x00000410, 0x06) {} 170 * Processor (CPU3, 0x03, 0x00000410, 0x06) {}
171 * } 171 * }
172 * 172 *
173 * Ignores apic_id and always returns 0 for the processor 173 * Ignores phys_id and always returns 0 for the processor
174 * handle with acpi id 0 if nr_cpu_ids is 1. 174 * handle with acpi id 0 if nr_cpu_ids is 1.
175 * This should be the case if SMP tables are not found. 175 * This should be the case if SMP tables are not found.
176 * Return -1 for other CPU's handle. 176 * Return -1 for other CPU's handle.
@@ -178,28 +178,28 @@ int acpi_map_cpuid(int apic_id, u32 acpi_id)
178 if (nr_cpu_ids <= 1 && acpi_id == 0) 178 if (nr_cpu_ids <= 1 && acpi_id == 0)
179 return acpi_id; 179 return acpi_id;
180 else 180 else
181 return apic_id; 181 return phys_id;
182 } 182 }
183 183
184#ifdef CONFIG_SMP 184#ifdef CONFIG_SMP
185 for_each_possible_cpu(i) { 185 for_each_possible_cpu(i) {
186 if (cpu_physical_id(i) == apic_id) 186 if (cpu_physical_id(i) == phys_id)
187 return i; 187 return i;
188 } 188 }
189#else 189#else
190 /* In UP kernel, only processor 0 is valid */ 190 /* In UP kernel, only processor 0 is valid */
191 if (apic_id == 0) 191 if (phys_id == 0)
192 return apic_id; 192 return phys_id;
193#endif 193#endif
194 return -1; 194 return -1;
195} 195}
196 196
197int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 197int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
198{ 198{
199 int apic_id; 199 int phys_id;
200 200
201 apic_id = acpi_get_apicid(handle, type, acpi_id); 201 phys_id = acpi_get_phys_id(handle, type, acpi_id);
202 202
203 return acpi_map_cpuid(apic_id, acpi_id); 203 return acpi_map_cpuid(phys_id, acpi_id);
204} 204}
205EXPORT_SYMBOL_GPL(acpi_get_cpuid); 205EXPORT_SYMBOL_GPL(acpi_get_cpuid);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 499536504698..87b704e41877 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -985,8 +985,6 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
985 state->flags = 0; 985 state->flags = 0;
986 switch (cx->type) { 986 switch (cx->type) {
987 case ACPI_STATE_C1: 987 case ACPI_STATE_C1:
988 if (cx->entry_method != ACPI_CSTATE_FFH)
989 state->flags |= CPUIDLE_FLAG_TIME_INVALID;
990 988
991 state->enter = acpi_idle_enter_c1; 989 state->enter = acpi_idle_enter_c1;
992 state->enter_dead = acpi_idle_play_dead; 990 state->enter_dead = acpi_idle_play_dead;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 16914cc30882..dc4d8960684a 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1001,7 +1001,7 @@ static void acpi_free_power_resources_lists(struct acpi_device *device)
1001 if (device->wakeup.flags.valid) 1001 if (device->wakeup.flags.valid)
1002 acpi_power_resources_list_free(&device->wakeup.resources); 1002 acpi_power_resources_list_free(&device->wakeup.resources);
1003 1003
1004 if (!device->flags.power_manageable) 1004 if (!device->power.flags.power_resources)
1005 return; 1005 return;
1006 1006
1007 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) { 1007 for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3_HOT; i++) {
@@ -1744,10 +1744,8 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
1744 device->power.flags.power_resources) 1744 device->power.flags.power_resources)
1745 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1; 1745 device->power.states[ACPI_STATE_D3_COLD].flags.os_accessible = 1;
1746 1746
1747 if (acpi_bus_init_power(device)) { 1747 if (acpi_bus_init_power(device))
1748 acpi_free_power_resources_lists(device);
1749 device->flags.power_manageable = 0; 1748 device->flags.power_manageable = 0;
1750 }
1751} 1749}
1752 1750
1753static void acpi_bus_get_flags(struct acpi_device *device) 1751static void acpi_bus_get_flags(struct acpi_device *device)
@@ -2371,13 +2369,18 @@ static void acpi_bus_attach(struct acpi_device *device)
2371 /* Skip devices that are not present. */ 2369 /* Skip devices that are not present. */
2372 if (!acpi_device_is_present(device)) { 2370 if (!acpi_device_is_present(device)) {
2373 device->flags.visited = false; 2371 device->flags.visited = false;
2372 device->flags.power_manageable = 0;
2374 return; 2373 return;
2375 } 2374 }
2376 if (device->handler) 2375 if (device->handler)
2377 goto ok; 2376 goto ok;
2378 2377
2379 if (!device->flags.initialized) { 2378 if (!device->flags.initialized) {
2380 acpi_bus_update_power(device, NULL); 2379 device->flags.power_manageable =
2380 device->power.states[ACPI_STATE_D0].flags.valid;
2381 if (acpi_bus_init_power(device))
2382 device->flags.power_manageable = 0;
2383
2381 device->flags.initialized = true; 2384 device->flags.initialized = true;
2382 } 2385 }
2383 device->flags.visited = false; 2386 device->flags.visited = false;
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 1eaadff2e198..032db459370f 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -505,6 +505,33 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
505 DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"), 505 DMI_MATCH(DMI_PRODUCT_NAME, "HP ENVY 15 Notebook PC"),
506 }, 506 },
507 }, 507 },
508
509 {
510 .callback = video_disable_native_backlight,
511 .ident = "SAMSUNG 870Z5E/880Z5E/680Z5E",
512 .matches = {
513 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
514 DMI_MATCH(DMI_PRODUCT_NAME, "870Z5E/880Z5E/680Z5E"),
515 },
516 },
517 {
518 .callback = video_disable_native_backlight,
519 .ident = "SAMSUNG 370R4E/370R4V/370R5E/3570RE/370R5V",
520 .matches = {
521 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
522 DMI_MATCH(DMI_PRODUCT_NAME, "370R4E/370R4V/370R5E/3570RE/370R5V"),
523 },
524 },
525
526 {
527 /* https://bugzilla.redhat.com/show_bug.cgi?id=1163574 */
528 .callback = video_disable_native_backlight,
529 .ident = "Dell XPS15 L521X",
530 .matches = {
531 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
532 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
533 },
534 },
508 {} 535 {}
509}; 536};
510 537
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 6a103a35ea9b..0d8780c04a5e 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2088,7 +2088,7 @@ EXPORT_SYMBOL_GPL(of_genpd_del_provider);
2088 * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR() 2088 * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR()
2089 * on failure. 2089 * on failure.
2090 */ 2090 */
2091static struct generic_pm_domain *of_genpd_get_from_provider( 2091struct generic_pm_domain *of_genpd_get_from_provider(
2092 struct of_phandle_args *genpdspec) 2092 struct of_phandle_args *genpdspec)
2093{ 2093{
2094 struct generic_pm_domain *genpd = ERR_PTR(-ENOENT); 2094 struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
@@ -2108,6 +2108,7 @@ static struct generic_pm_domain *of_genpd_get_from_provider(
2108 2108
2109 return genpd; 2109 return genpd;
2110} 2110}
2111EXPORT_SYMBOL_GPL(of_genpd_get_from_provider);
2111 2112
2112/** 2113/**
2113 * genpd_dev_pm_detach - Detach a device from its PM domain. 2114 * genpd_dev_pm_detach - Detach a device from its PM domain.
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index d24dd614a0bd..106c69359306 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -108,6 +108,14 @@ static LIST_HEAD(dev_opp_list);
108/* Lock to allow exclusive modification to the device and opp lists */ 108/* Lock to allow exclusive modification to the device and opp lists */
109static DEFINE_MUTEX(dev_opp_list_lock); 109static DEFINE_MUTEX(dev_opp_list_lock);
110 110
111#define opp_rcu_lockdep_assert() \
112do { \
113 rcu_lockdep_assert(rcu_read_lock_held() || \
114 lockdep_is_held(&dev_opp_list_lock), \
115 "Missing rcu_read_lock() or " \
116 "dev_opp_list_lock protection"); \
117} while (0)
118
111/** 119/**
112 * find_device_opp() - find device_opp struct using device pointer 120 * find_device_opp() - find device_opp struct using device pointer
113 * @dev: device pointer used to lookup device OPPs 121 * @dev: device pointer used to lookup device OPPs
@@ -208,9 +216,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
208 * This function returns the number of available opps if there are any, 216 * This function returns the number of available opps if there are any,
209 * else returns 0 if none or the corresponding error value. 217 * else returns 0 if none or the corresponding error value.
210 * 218 *
211 * Locking: This function must be called under rcu_read_lock(). This function 219 * Locking: This function takes rcu_read_lock().
212 * internally references two RCU protected structures: device_opp and opp which
213 * are safe as long as we are under a common RCU locked section.
214 */ 220 */
215int dev_pm_opp_get_opp_count(struct device *dev) 221int dev_pm_opp_get_opp_count(struct device *dev)
216{ 222{
@@ -218,11 +224,14 @@ int dev_pm_opp_get_opp_count(struct device *dev)
218 struct dev_pm_opp *temp_opp; 224 struct dev_pm_opp *temp_opp;
219 int count = 0; 225 int count = 0;
220 226
227 rcu_read_lock();
228
221 dev_opp = find_device_opp(dev); 229 dev_opp = find_device_opp(dev);
222 if (IS_ERR(dev_opp)) { 230 if (IS_ERR(dev_opp)) {
223 int r = PTR_ERR(dev_opp); 231 count = PTR_ERR(dev_opp);
224 dev_err(dev, "%s: device OPP not found (%d)\n", __func__, r); 232 dev_err(dev, "%s: device OPP not found (%d)\n",
225 return r; 233 __func__, count);
234 goto out_unlock;
226 } 235 }
227 236
228 list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) { 237 list_for_each_entry_rcu(temp_opp, &dev_opp->opp_list, node) {
@@ -230,6 +239,8 @@ int dev_pm_opp_get_opp_count(struct device *dev)
230 count++; 239 count++;
231 } 240 }
232 241
242out_unlock:
243 rcu_read_unlock();
233 return count; 244 return count;
234} 245}
235EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count); 246EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count);
@@ -267,6 +278,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
267 struct device_opp *dev_opp; 278 struct device_opp *dev_opp;
268 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); 279 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
269 280
281 opp_rcu_lockdep_assert();
282
270 dev_opp = find_device_opp(dev); 283 dev_opp = find_device_opp(dev);
271 if (IS_ERR(dev_opp)) { 284 if (IS_ERR(dev_opp)) {
272 int r = PTR_ERR(dev_opp); 285 int r = PTR_ERR(dev_opp);
@@ -313,6 +326,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
313 struct device_opp *dev_opp; 326 struct device_opp *dev_opp;
314 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); 327 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
315 328
329 opp_rcu_lockdep_assert();
330
316 if (!dev || !freq) { 331 if (!dev || !freq) {
317 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); 332 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
318 return ERR_PTR(-EINVAL); 333 return ERR_PTR(-EINVAL);
@@ -361,6 +376,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
361 struct device_opp *dev_opp; 376 struct device_opp *dev_opp;
362 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); 377 struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
363 378
379 opp_rcu_lockdep_assert();
380
364 if (!dev || !freq) { 381 if (!dev || !freq) {
365 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); 382 dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
366 return ERR_PTR(-EINVAL); 383 return ERR_PTR(-EINVAL);
@@ -783,9 +800,15 @@ void of_free_opp_table(struct device *dev)
783 800
784 /* Check for existing list for 'dev' */ 801 /* Check for existing list for 'dev' */
785 dev_opp = find_device_opp(dev); 802 dev_opp = find_device_opp(dev);
786 if (WARN(IS_ERR(dev_opp), "%s: dev_opp: %ld\n", dev_name(dev), 803 if (IS_ERR(dev_opp)) {
787 PTR_ERR(dev_opp))) 804 int error = PTR_ERR(dev_opp);
805 if (error != -ENODEV)
806 WARN(1, "%s: dev_opp: %d\n",
807 IS_ERR_OR_NULL(dev) ?
808 "Invalid device" : dev_name(dev),
809 error);
788 return; 810 return;
811 }
789 812
790 /* Hold our list modification lock here */ 813 /* Hold our list modification lock here */
791 mutex_lock(&dev_opp_list_lock); 814 mutex_lock(&dev_opp_list_lock);
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index 19db03667650..dcbbb4ea3cc1 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -417,6 +417,6 @@ static void __exit agp_ali_cleanup(void)
417module_init(agp_ali_init); 417module_init(agp_ali_init);
418module_exit(agp_ali_cleanup); 418module_exit(agp_ali_cleanup);
419 419
420MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 420MODULE_AUTHOR("Dave Jones");
421MODULE_LICENSE("GPL and additional rights"); 421MODULE_LICENSE("GPL and additional rights");
422 422
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 3b47ed0310e1..0ef350010766 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -813,6 +813,6 @@ static void __exit agp_amd64_cleanup(void)
813module_init(agp_amd64_mod_init); 813module_init(agp_amd64_mod_init);
814module_exit(agp_amd64_cleanup); 814module_exit(agp_amd64_cleanup);
815 815
816MODULE_AUTHOR("Dave Jones <davej@redhat.com>, Andi Kleen"); 816MODULE_AUTHOR("Dave Jones, Andi Kleen");
817module_param(agp_try_unsupported, bool, 0); 817module_param(agp_try_unsupported, bool, 0);
818MODULE_LICENSE("GPL"); 818MODULE_LICENSE("GPL");
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 18a7a6baa304..75a9786a77e6 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -579,6 +579,6 @@ static void __exit agp_ati_cleanup(void)
579module_init(agp_ati_init); 579module_init(agp_ati_init);
580module_exit(agp_ati_cleanup); 580module_exit(agp_ati_cleanup);
581 581
582MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 582MODULE_AUTHOR("Dave Jones");
583MODULE_LICENSE("GPL and additional rights"); 583MODULE_LICENSE("GPL and additional rights");
584 584
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 317c28ce8328..38ffb281df97 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -356,7 +356,7 @@ static __init int agp_setup(char *s)
356__setup("agp=", agp_setup); 356__setup("agp=", agp_setup);
357#endif 357#endif
358 358
359MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 359MODULE_AUTHOR("Dave Jones, Jeff Hartmann");
360MODULE_DESCRIPTION("AGP GART driver"); 360MODULE_DESCRIPTION("AGP GART driver");
361MODULE_LICENSE("GPL and additional rights"); 361MODULE_LICENSE("GPL and additional rights");
362MODULE_ALIAS_MISCDEV(AGPGART_MINOR); 362MODULE_ALIAS_MISCDEV(AGPGART_MINOR);
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index f9b9ca5d31b7..0a21daed5b62 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -920,5 +920,5 @@ static void __exit agp_intel_cleanup(void)
920module_init(agp_intel_init); 920module_init(agp_intel_init);
921module_exit(agp_intel_cleanup); 921module_exit(agp_intel_cleanup);
922 922
923MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 923MODULE_AUTHOR("Dave Jones, Various @Intel");
924MODULE_LICENSE("GPL and additional rights"); 924MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index f3334829e55a..92aa43fa8d70 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1438,5 +1438,5 @@ void intel_gmch_remove(void)
1438} 1438}
1439EXPORT_SYMBOL(intel_gmch_remove); 1439EXPORT_SYMBOL(intel_gmch_remove);
1440 1440
1441MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 1441MODULE_AUTHOR("Dave Jones, Various @Intel");
1442MODULE_LICENSE("GPL and additional rights"); 1442MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index a1861b75eb31..6c8d39cb566e 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Nvidia AGPGART routines. 2 * Nvidia AGPGART routines.
3 * Based upon a 2.4 agpgart diff by the folks from NVIDIA, and hacked up 3 * Based upon a 2.4 agpgart diff by the folks from NVIDIA, and hacked up
4 * to work in 2.5 by Dave Jones <davej@redhat.com> 4 * to work in 2.5 by Dave Jones.
5 */ 5 */
6 6
7#include <linux/module.h> 7#include <linux/module.h>
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 228f20cddc05..a4961d35e940 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -595,4 +595,4 @@ module_init(agp_via_init);
595module_exit(agp_via_cleanup); 595module_exit(agp_via_cleanup);
596 596
597MODULE_LICENSE("GPL"); 597MODULE_LICENSE("GPL");
598MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); 598MODULE_AUTHOR("Dave Jones");
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 5fa83f751378..6b65fa4e0c55 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -199,18 +199,6 @@ struct bmc_device {
199 int guid_set; 199 int guid_set;
200 char name[16]; 200 char name[16];
201 struct kref usecount; 201 struct kref usecount;
202
203 /* bmc device attributes */
204 struct device_attribute device_id_attr;
205 struct device_attribute provides_dev_sdrs_attr;
206 struct device_attribute revision_attr;
207 struct device_attribute firmware_rev_attr;
208 struct device_attribute version_attr;
209 struct device_attribute add_dev_support_attr;
210 struct device_attribute manufacturer_id_attr;
211 struct device_attribute product_id_attr;
212 struct device_attribute guid_attr;
213 struct device_attribute aux_firmware_rev_attr;
214}; 202};
215#define to_bmc_device(x) container_of((x), struct bmc_device, pdev.dev) 203#define to_bmc_device(x) container_of((x), struct bmc_device, pdev.dev)
216 204
@@ -2252,7 +2240,7 @@ static ssize_t device_id_show(struct device *dev,
2252 2240
2253 return snprintf(buf, 10, "%u\n", bmc->id.device_id); 2241 return snprintf(buf, 10, "%u\n", bmc->id.device_id);
2254} 2242}
2255DEVICE_ATTR(device_id, S_IRUGO, device_id_show, NULL); 2243static DEVICE_ATTR(device_id, S_IRUGO, device_id_show, NULL);
2256 2244
2257static ssize_t provides_device_sdrs_show(struct device *dev, 2245static ssize_t provides_device_sdrs_show(struct device *dev,
2258 struct device_attribute *attr, 2246 struct device_attribute *attr,
@@ -2263,7 +2251,8 @@ static ssize_t provides_device_sdrs_show(struct device *dev,
2263 return snprintf(buf, 10, "%u\n", 2251 return snprintf(buf, 10, "%u\n",
2264 (bmc->id.device_revision & 0x80) >> 7); 2252 (bmc->id.device_revision & 0x80) >> 7);
2265} 2253}
2266DEVICE_ATTR(provides_device_sdrs, S_IRUGO, provides_device_sdrs_show, NULL); 2254static DEVICE_ATTR(provides_device_sdrs, S_IRUGO, provides_device_sdrs_show,
2255 NULL);
2267 2256
2268static ssize_t revision_show(struct device *dev, struct device_attribute *attr, 2257static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
2269 char *buf) 2258 char *buf)
@@ -2273,7 +2262,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
2273 return snprintf(buf, 20, "%u\n", 2262 return snprintf(buf, 20, "%u\n",
2274 bmc->id.device_revision & 0x0F); 2263 bmc->id.device_revision & 0x0F);
2275} 2264}
2276DEVICE_ATTR(revision, S_IRUGO, revision_show, NULL); 2265static DEVICE_ATTR(revision, S_IRUGO, revision_show, NULL);
2277 2266
2278static ssize_t firmware_revision_show(struct device *dev, 2267static ssize_t firmware_revision_show(struct device *dev,
2279 struct device_attribute *attr, 2268 struct device_attribute *attr,
@@ -2284,7 +2273,7 @@ static ssize_t firmware_revision_show(struct device *dev,
2284 return snprintf(buf, 20, "%u.%x\n", bmc->id.firmware_revision_1, 2273 return snprintf(buf, 20, "%u.%x\n", bmc->id.firmware_revision_1,
2285 bmc->id.firmware_revision_2); 2274 bmc->id.firmware_revision_2);
2286} 2275}
2287DEVICE_ATTR(firmware_revision, S_IRUGO, firmware_revision_show, NULL); 2276static DEVICE_ATTR(firmware_revision, S_IRUGO, firmware_revision_show, NULL);
2288 2277
2289static ssize_t ipmi_version_show(struct device *dev, 2278static ssize_t ipmi_version_show(struct device *dev,
2290 struct device_attribute *attr, 2279 struct device_attribute *attr,
@@ -2296,7 +2285,7 @@ static ssize_t ipmi_version_show(struct device *dev,
2296 ipmi_version_major(&bmc->id), 2285 ipmi_version_major(&bmc->id),
2297 ipmi_version_minor(&bmc->id)); 2286 ipmi_version_minor(&bmc->id));
2298} 2287}
2299DEVICE_ATTR(ipmi_version, S_IRUGO, ipmi_version_show, NULL); 2288static DEVICE_ATTR(ipmi_version, S_IRUGO, ipmi_version_show, NULL);
2300 2289
2301static ssize_t add_dev_support_show(struct device *dev, 2290static ssize_t add_dev_support_show(struct device *dev,
2302 struct device_attribute *attr, 2291 struct device_attribute *attr,
@@ -2307,7 +2296,8 @@ static ssize_t add_dev_support_show(struct device *dev,
2307 return snprintf(buf, 10, "0x%02x\n", 2296 return snprintf(buf, 10, "0x%02x\n",
2308 bmc->id.additional_device_support); 2297 bmc->id.additional_device_support);
2309} 2298}
2310DEVICE_ATTR(additional_device_support, S_IRUGO, add_dev_support_show, NULL); 2299static DEVICE_ATTR(additional_device_support, S_IRUGO, add_dev_support_show,
2300 NULL);
2311 2301
2312static ssize_t manufacturer_id_show(struct device *dev, 2302static ssize_t manufacturer_id_show(struct device *dev,
2313 struct device_attribute *attr, 2303 struct device_attribute *attr,
@@ -2317,7 +2307,7 @@ static ssize_t manufacturer_id_show(struct device *dev,
2317 2307
2318 return snprintf(buf, 20, "0x%6.6x\n", bmc->id.manufacturer_id); 2308 return snprintf(buf, 20, "0x%6.6x\n", bmc->id.manufacturer_id);
2319} 2309}
2320DEVICE_ATTR(manufacturer_id, S_IRUGO, manufacturer_id_show, NULL); 2310static DEVICE_ATTR(manufacturer_id, S_IRUGO, manufacturer_id_show, NULL);
2321 2311
2322static ssize_t product_id_show(struct device *dev, 2312static ssize_t product_id_show(struct device *dev,
2323 struct device_attribute *attr, 2313 struct device_attribute *attr,
@@ -2327,7 +2317,7 @@ static ssize_t product_id_show(struct device *dev,
2327 2317
2328 return snprintf(buf, 10, "0x%4.4x\n", bmc->id.product_id); 2318 return snprintf(buf, 10, "0x%4.4x\n", bmc->id.product_id);
2329} 2319}
2330DEVICE_ATTR(product_id, S_IRUGO, product_id_show, NULL); 2320static DEVICE_ATTR(product_id, S_IRUGO, product_id_show, NULL);
2331 2321
2332static ssize_t aux_firmware_rev_show(struct device *dev, 2322static ssize_t aux_firmware_rev_show(struct device *dev,
2333 struct device_attribute *attr, 2323 struct device_attribute *attr,
@@ -2341,7 +2331,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev,
2341 bmc->id.aux_firmware_revision[1], 2331 bmc->id.aux_firmware_revision[1],
2342 bmc->id.aux_firmware_revision[0]); 2332 bmc->id.aux_firmware_revision[0]);
2343} 2333}
2344DEVICE_ATTR(aux_firmware_revision, S_IRUGO, aux_firmware_rev_show, NULL); 2334static DEVICE_ATTR(aux_firmware_revision, S_IRUGO, aux_firmware_rev_show, NULL);
2345 2335
2346static ssize_t guid_show(struct device *dev, struct device_attribute *attr, 2336static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
2347 char *buf) 2337 char *buf)
@@ -2352,7 +2342,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
2352 (long long) bmc->guid[0], 2342 (long long) bmc->guid[0],
2353 (long long) bmc->guid[8]); 2343 (long long) bmc->guid[8]);
2354} 2344}
2355DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL); 2345static DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL);
2356 2346
2357static struct attribute *bmc_dev_attrs[] = { 2347static struct attribute *bmc_dev_attrs[] = {
2358 &dev_attr_device_id.attr, 2348 &dev_attr_device_id.attr,
@@ -2392,10 +2382,10 @@ cleanup_bmc_device(struct kref *ref)
2392 2382
2393 if (bmc->id.aux_firmware_revision_set) 2383 if (bmc->id.aux_firmware_revision_set)
2394 device_remove_file(&bmc->pdev.dev, 2384 device_remove_file(&bmc->pdev.dev,
2395 &bmc->aux_firmware_rev_attr); 2385 &dev_attr_aux_firmware_revision);
2396 if (bmc->guid_set) 2386 if (bmc->guid_set)
2397 device_remove_file(&bmc->pdev.dev, 2387 device_remove_file(&bmc->pdev.dev,
2398 &bmc->guid_attr); 2388 &dev_attr_guid);
2399 2389
2400 platform_device_unregister(&bmc->pdev); 2390 platform_device_unregister(&bmc->pdev);
2401} 2391}
@@ -2422,16 +2412,14 @@ static int create_bmc_files(struct bmc_device *bmc)
2422 int err; 2412 int err;
2423 2413
2424 if (bmc->id.aux_firmware_revision_set) { 2414 if (bmc->id.aux_firmware_revision_set) {
2425 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2426 err = device_create_file(&bmc->pdev.dev, 2415 err = device_create_file(&bmc->pdev.dev,
2427 &bmc->aux_firmware_rev_attr); 2416 &dev_attr_aux_firmware_revision);
2428 if (err) 2417 if (err)
2429 goto out; 2418 goto out;
2430 } 2419 }
2431 if (bmc->guid_set) { 2420 if (bmc->guid_set) {
2432 bmc->guid_attr.attr.name = "guid";
2433 err = device_create_file(&bmc->pdev.dev, 2421 err = device_create_file(&bmc->pdev.dev,
2434 &bmc->guid_attr); 2422 &dev_attr_guid);
2435 if (err) 2423 if (err)
2436 goto out_aux_firm; 2424 goto out_aux_firm;
2437 } 2425 }
@@ -2441,7 +2429,7 @@ static int create_bmc_files(struct bmc_device *bmc)
2441out_aux_firm: 2429out_aux_firm:
2442 if (bmc->id.aux_firmware_revision_set) 2430 if (bmc->id.aux_firmware_revision_set)
2443 device_remove_file(&bmc->pdev.dev, 2431 device_remove_file(&bmc->pdev.dev,
2444 &bmc->aux_firmware_rev_attr); 2432 &dev_attr_aux_firmware_revision);
2445out: 2433out:
2446 return err; 2434 return err;
2447} 2435}
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index e178ac27e73c..982b96323f82 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -52,6 +52,7 @@
52#include <linux/dmi.h> 52#include <linux/dmi.h>
53#include <linux/kthread.h> 53#include <linux/kthread.h>
54#include <linux/acpi.h> 54#include <linux/acpi.h>
55#include <linux/ctype.h>
55 56
56#define PFX "ipmi_ssif: " 57#define PFX "ipmi_ssif: "
57#define DEVICE_NAME "ipmi_ssif" 58#define DEVICE_NAME "ipmi_ssif"
@@ -968,7 +969,8 @@ static void sender(void *send_info,
968 969
969 do_gettimeofday(&t); 970 do_gettimeofday(&t);
970 pr_info("**Enqueue %02x %02x: %ld.%6.6ld\n", 971 pr_info("**Enqueue %02x %02x: %ld.%6.6ld\n",
971 msg->data[0], msg->data[1], t.tv_sec, t.tv_usec); 972 msg->data[0], msg->data[1],
973 (long) t.tv_sec, (long) t.tv_usec);
972 } 974 }
973} 975}
974 976
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 386999b4f8eb..f07c8152e5cc 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -27,6 +27,15 @@
27void __iomem *at91_pmc_base; 27void __iomem *at91_pmc_base;
28EXPORT_SYMBOL_GPL(at91_pmc_base); 28EXPORT_SYMBOL_GPL(at91_pmc_base);
29 29
30void at91rm9200_idle(void)
31{
32 /*
33 * Disable the processor clock. The processor will be automatically
34 * re-enabled by an interrupt or by a reset.
35 */
36 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
37}
38
30void at91sam9_idle(void) 39void at91sam9_idle(void)
31{ 40{
32 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); 41 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 6a79fc4f900c..095c1774592c 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -462,7 +462,7 @@ static void __init arch_counter_register(unsigned type)
462 462
463 /* Register the CP15 based counter if we have one */ 463 /* Register the CP15 based counter if we have one */
464 if (type & ARCH_CP15_TIMER) { 464 if (type & ARCH_CP15_TIMER) {
465 if (arch_timer_use_virtual) 465 if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
466 arch_timer_read_counter = arch_counter_get_cntvct; 466 arch_timer_read_counter = arch_counter_get_cntvct;
467 else 467 else
468 arch_timer_read_counter = arch_counter_get_cntpct; 468 arch_timer_read_counter = arch_counter_get_cntpct;
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index f56147a1daed..fde97d6e31d6 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -211,6 +211,17 @@ static int cpufreq_init(struct cpufreq_policy *policy)
211 /* OPPs might be populated at runtime, don't check for error here */ 211 /* OPPs might be populated at runtime, don't check for error here */
212 of_init_opp_table(cpu_dev); 212 of_init_opp_table(cpu_dev);
213 213
214 /*
215 * But we need OPP table to function so if it is not there let's
216 * give platform code chance to provide it for us.
217 */
218 ret = dev_pm_opp_get_opp_count(cpu_dev);
219 if (ret <= 0) {
220 pr_debug("OPP table is not ready, deferring probe\n");
221 ret = -EPROBE_DEFER;
222 goto out_free_opp;
223 }
224
214 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 225 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
215 if (!priv) { 226 if (!priv) {
216 ret = -ENOMEM; 227 ret = -ENOMEM;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a09a29c312a9..46bed4f81cde 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2028,6 +2028,12 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
2028 /* Don't start any governor operations if we are entering suspend */ 2028 /* Don't start any governor operations if we are entering suspend */
2029 if (cpufreq_suspended) 2029 if (cpufreq_suspended)
2030 return 0; 2030 return 0;
2031 /*
2032 * Governor might not be initiated here if ACPI _PPC changed
2033 * notification happened, so check it.
2034 */
2035 if (!policy->governor)
2036 return -EINVAL;
2031 2037
2032 if (policy->governor->max_transition_latency && 2038 if (policy->governor->max_transition_latency &&
2033 policy->cpuinfo.transition_latency > 2039 policy->cpuinfo.transition_latency >
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 37263d9a1051..401c0106ed34 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -79,12 +79,7 @@ static int ladder_select_state(struct cpuidle_driver *drv,
79 79
80 last_state = &ldev->states[last_idx]; 80 last_state = &ldev->states[last_idx];
81 81
82 if (!(drv->states[last_idx].flags & CPUIDLE_FLAG_TIME_INVALID)) { 82 last_residency = cpuidle_get_last_residency(dev) - drv->states[last_idx].exit_latency;
83 last_residency = cpuidle_get_last_residency(dev) - \
84 drv->states[last_idx].exit_latency;
85 }
86 else
87 last_residency = last_state->threshold.promotion_time + 1;
88 83
89 /* consider promotion */ 84 /* consider promotion */
90 if (last_idx < drv->state_count - 1 && 85 if (last_idx < drv->state_count - 1 &&
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 659d7b0c9ebf..40580794e23d 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -396,8 +396,8 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
396 * power state and occurrence of the wakeup event. 396 * power state and occurrence of the wakeup event.
397 * 397 *
398 * If the entered idle state didn't support residency measurements, 398 * If the entered idle state didn't support residency measurements,
399 * we are basically lost in the dark how much time passed. 399 * we use them anyway if they are short, and if long,
400 * As a compromise, assume we slept for the whole expected time. 400 * truncate to the whole expected time.
401 * 401 *
402 * Any measured amount of time will include the exit latency. 402 * Any measured amount of time will include the exit latency.
403 * Since we are interested in when the wakeup begun, not when it 403 * Since we are interested in when the wakeup begun, not when it
@@ -405,22 +405,17 @@ static void menu_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
405 * the measured amount of time is less than the exit latency, 405 * the measured amount of time is less than the exit latency,
406 * assume the state was never reached and the exit latency is 0. 406 * assume the state was never reached and the exit latency is 0.
407 */ 407 */
408 if (unlikely(target->flags & CPUIDLE_FLAG_TIME_INVALID)) {
409 /* Use timer value as is */
410 measured_us = data->next_timer_us;
411 408
412 } else { 409 /* measured value */
413 /* Use measured value */ 410 measured_us = cpuidle_get_last_residency(dev);
414 measured_us = cpuidle_get_last_residency(dev);
415 411
416 /* Deduct exit latency */ 412 /* Deduct exit latency */
417 if (measured_us > target->exit_latency) 413 if (measured_us > target->exit_latency)
418 measured_us -= target->exit_latency; 414 measured_us -= target->exit_latency;
419 415
420 /* Make sure our coefficients do not exceed unity */ 416 /* Make sure our coefficients do not exceed unity */
421 if (measured_us > data->next_timer_us) 417 if (measured_us > data->next_timer_us)
422 measured_us = data->next_timer_us; 418 measured_us = data->next_timer_us;
423 }
424 419
425 /* Update our correction ratio */ 420 /* Update our correction ratio */
426 new_factor = data->correction_factor[data->bucket]; 421 new_factor = data->correction_factor[data->bucket];
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 66e40398b3d3..e620807418ea 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
37obj-$(CONFIG_DRM_TTM) += ttm/ 37obj-$(CONFIG_DRM_TTM) += ttm/
38obj-$(CONFIG_DRM_TDFX) += tdfx/ 38obj-$(CONFIG_DRM_TDFX) += tdfx/
39obj-$(CONFIG_DRM_R128) += r128/ 39obj-$(CONFIG_DRM_R128) += r128/
40obj-$(CONFIG_HSA_AMD) += amd/amdkfd/
40obj-$(CONFIG_DRM_RADEON)+= radeon/ 41obj-$(CONFIG_DRM_RADEON)+= radeon/
41obj-$(CONFIG_DRM_MGA) += mga/ 42obj-$(CONFIG_DRM_MGA) += mga/
42obj-$(CONFIG_DRM_I810) += i810/ 43obj-$(CONFIG_DRM_I810) += i810/
@@ -67,4 +68,3 @@ obj-$(CONFIG_DRM_IMX) += imx/
67obj-y += i2c/ 68obj-y += i2c/
68obj-y += panel/ 69obj-y += panel/
69obj-y += bridge/ 70obj-y += bridge/
70obj-$(CONFIG_HSA_AMD) += amd/amdkfd/
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 4f7b275f2f7b..fcfdf23e1913 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -31,7 +31,6 @@
31#include <uapi/linux/kfd_ioctl.h> 31#include <uapi/linux/kfd_ioctl.h>
32#include <linux/time.h> 32#include <linux/time.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/uaccess.h>
35#include <uapi/asm-generic/mman-common.h> 34#include <uapi/asm-generic/mman-common.h>
36#include <asm/processor.h> 35#include <asm/processor.h>
37#include "kfd_priv.h" 36#include "kfd_priv.h"
@@ -121,27 +120,20 @@ static int kfd_open(struct inode *inode, struct file *filep)
121 if (IS_ERR(process)) 120 if (IS_ERR(process))
122 return PTR_ERR(process); 121 return PTR_ERR(process);
123 122
124 process->is_32bit_user_mode = is_32bit_user_mode;
125
126 dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n", 123 dev_dbg(kfd_device, "process %d opened, compat mode (32 bit) - %d\n",
127 process->pasid, process->is_32bit_user_mode); 124 process->pasid, process->is_32bit_user_mode);
128 125
129 kfd_init_apertures(process);
130
131 return 0; 126 return 0;
132} 127}
133 128
134static long kfd_ioctl_get_version(struct file *filep, struct kfd_process *p, 129static int kfd_ioctl_get_version(struct file *filep, struct kfd_process *p,
135 void __user *arg) 130 void *data)
136{ 131{
137 struct kfd_ioctl_get_version_args args; 132 struct kfd_ioctl_get_version_args *args = data;
138 int err = 0; 133 int err = 0;
139 134
140 args.major_version = KFD_IOCTL_MAJOR_VERSION; 135 args->major_version = KFD_IOCTL_MAJOR_VERSION;
141 args.minor_version = KFD_IOCTL_MINOR_VERSION; 136 args->minor_version = KFD_IOCTL_MINOR_VERSION;
142
143 if (copy_to_user(arg, &args, sizeof(args)))
144 err = -EFAULT;
145 137
146 return err; 138 return err;
147} 139}
@@ -225,10 +217,10 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,
225 return 0; 217 return 0;
226} 218}
227 219
228static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, 220static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
229 void __user *arg) 221 void *data)
230{ 222{
231 struct kfd_ioctl_create_queue_args args; 223 struct kfd_ioctl_create_queue_args *args = data;
232 struct kfd_dev *dev; 224 struct kfd_dev *dev;
233 int err = 0; 225 int err = 0;
234 unsigned int queue_id; 226 unsigned int queue_id;
@@ -237,16 +229,13 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
237 229
238 memset(&q_properties, 0, sizeof(struct queue_properties)); 230 memset(&q_properties, 0, sizeof(struct queue_properties));
239 231
240 if (copy_from_user(&args, arg, sizeof(args)))
241 return -EFAULT;
242
243 pr_debug("kfd: creating queue ioctl\n"); 232 pr_debug("kfd: creating queue ioctl\n");
244 233
245 err = set_queue_properties_from_user(&q_properties, &args); 234 err = set_queue_properties_from_user(&q_properties, args);
246 if (err) 235 if (err)
247 return err; 236 return err;
248 237
249 dev = kfd_device_by_id(args.gpu_id); 238 dev = kfd_device_by_id(args->gpu_id);
250 if (dev == NULL) 239 if (dev == NULL)
251 return -EINVAL; 240 return -EINVAL;
252 241
@@ -254,7 +243,7 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
254 243
255 pdd = kfd_bind_process_to_device(dev, p); 244 pdd = kfd_bind_process_to_device(dev, p);
256 if (IS_ERR(pdd)) { 245 if (IS_ERR(pdd)) {
257 err = PTR_ERR(pdd); 246 err = -ESRCH;
258 goto err_bind_process; 247 goto err_bind_process;
259 } 248 }
260 249
@@ -267,33 +256,26 @@ static long kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p,
267 if (err != 0) 256 if (err != 0)
268 goto err_create_queue; 257 goto err_create_queue;
269 258
270 args.queue_id = queue_id; 259 args->queue_id = queue_id;
271 260
272 /* Return gpu_id as doorbell offset for mmap usage */ 261 /* Return gpu_id as doorbell offset for mmap usage */
273 args.doorbell_offset = args.gpu_id << PAGE_SHIFT; 262 args->doorbell_offset = args->gpu_id << PAGE_SHIFT;
274
275 if (copy_to_user(arg, &args, sizeof(args))) {
276 err = -EFAULT;
277 goto err_copy_args_out;
278 }
279 263
280 mutex_unlock(&p->mutex); 264 mutex_unlock(&p->mutex);
281 265
282 pr_debug("kfd: queue id %d was created successfully\n", args.queue_id); 266 pr_debug("kfd: queue id %d was created successfully\n", args->queue_id);
283 267
284 pr_debug("ring buffer address == 0x%016llX\n", 268 pr_debug("ring buffer address == 0x%016llX\n",
285 args.ring_base_address); 269 args->ring_base_address);
286 270
287 pr_debug("read ptr address == 0x%016llX\n", 271 pr_debug("read ptr address == 0x%016llX\n",
288 args.read_pointer_address); 272 args->read_pointer_address);
289 273
290 pr_debug("write ptr address == 0x%016llX\n", 274 pr_debug("write ptr address == 0x%016llX\n",
291 args.write_pointer_address); 275 args->write_pointer_address);
292 276
293 return 0; 277 return 0;
294 278
295err_copy_args_out:
296 pqm_destroy_queue(&p->pqm, queue_id);
297err_create_queue: 279err_create_queue:
298err_bind_process: 280err_bind_process:
299 mutex_unlock(&p->mutex); 281 mutex_unlock(&p->mutex);
@@ -301,99 +283,90 @@ err_bind_process:
301} 283}
302 284
303static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p, 285static int kfd_ioctl_destroy_queue(struct file *filp, struct kfd_process *p,
304 void __user *arg) 286 void *data)
305{ 287{
306 int retval; 288 int retval;
307 struct kfd_ioctl_destroy_queue_args args; 289 struct kfd_ioctl_destroy_queue_args *args = data;
308
309 if (copy_from_user(&args, arg, sizeof(args)))
310 return -EFAULT;
311 290
312 pr_debug("kfd: destroying queue id %d for PASID %d\n", 291 pr_debug("kfd: destroying queue id %d for PASID %d\n",
313 args.queue_id, 292 args->queue_id,
314 p->pasid); 293 p->pasid);
315 294
316 mutex_lock(&p->mutex); 295 mutex_lock(&p->mutex);
317 296
318 retval = pqm_destroy_queue(&p->pqm, args.queue_id); 297 retval = pqm_destroy_queue(&p->pqm, args->queue_id);
319 298
320 mutex_unlock(&p->mutex); 299 mutex_unlock(&p->mutex);
321 return retval; 300 return retval;
322} 301}
323 302
324static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p, 303static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,
325 void __user *arg) 304 void *data)
326{ 305{
327 int retval; 306 int retval;
328 struct kfd_ioctl_update_queue_args args; 307 struct kfd_ioctl_update_queue_args *args = data;
329 struct queue_properties properties; 308 struct queue_properties properties;
330 309
331 if (copy_from_user(&args, arg, sizeof(args))) 310 if (args->queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) {
332 return -EFAULT;
333
334 if (args.queue_percentage > KFD_MAX_QUEUE_PERCENTAGE) {
335 pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n"); 311 pr_err("kfd: queue percentage must be between 0 to KFD_MAX_QUEUE_PERCENTAGE\n");
336 return -EINVAL; 312 return -EINVAL;
337 } 313 }
338 314
339 if (args.queue_priority > KFD_MAX_QUEUE_PRIORITY) { 315 if (args->queue_priority > KFD_MAX_QUEUE_PRIORITY) {
340 pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n"); 316 pr_err("kfd: queue priority must be between 0 to KFD_MAX_QUEUE_PRIORITY\n");
341 return -EINVAL; 317 return -EINVAL;
342 } 318 }
343 319
344 if ((args.ring_base_address) && 320 if ((args->ring_base_address) &&
345 (!access_ok(VERIFY_WRITE, 321 (!access_ok(VERIFY_WRITE,
346 (const void __user *) args.ring_base_address, 322 (const void __user *) args->ring_base_address,
347 sizeof(uint64_t)))) { 323 sizeof(uint64_t)))) {
348 pr_err("kfd: can't access ring base address\n"); 324 pr_err("kfd: can't access ring base address\n");
349 return -EFAULT; 325 return -EFAULT;
350 } 326 }
351 327
352 if (!is_power_of_2(args.ring_size) && (args.ring_size != 0)) { 328 if (!is_power_of_2(args->ring_size) && (args->ring_size != 0)) {
353 pr_err("kfd: ring size must be a power of 2 or 0\n"); 329 pr_err("kfd: ring size must be a power of 2 or 0\n");
354 return -EINVAL; 330 return -EINVAL;
355 } 331 }
356 332
357 properties.queue_address = args.ring_base_address; 333 properties.queue_address = args->ring_base_address;
358 properties.queue_size = args.ring_size; 334 properties.queue_size = args->ring_size;
359 properties.queue_percent = args.queue_percentage; 335 properties.queue_percent = args->queue_percentage;
360 properties.priority = args.queue_priority; 336 properties.priority = args->queue_priority;
361 337
362 pr_debug("kfd: updating queue id %d for PASID %d\n", 338 pr_debug("kfd: updating queue id %d for PASID %d\n",
363 args.queue_id, p->pasid); 339 args->queue_id, p->pasid);
364 340
365 mutex_lock(&p->mutex); 341 mutex_lock(&p->mutex);
366 342
367 retval = pqm_update_queue(&p->pqm, args.queue_id, &properties); 343 retval = pqm_update_queue(&p->pqm, args->queue_id, &properties);
368 344
369 mutex_unlock(&p->mutex); 345 mutex_unlock(&p->mutex);
370 346
371 return retval; 347 return retval;
372} 348}
373 349
374static long kfd_ioctl_set_memory_policy(struct file *filep, 350static int kfd_ioctl_set_memory_policy(struct file *filep,
375 struct kfd_process *p, void __user *arg) 351 struct kfd_process *p, void *data)
376{ 352{
377 struct kfd_ioctl_set_memory_policy_args args; 353 struct kfd_ioctl_set_memory_policy_args *args = data;
378 struct kfd_dev *dev; 354 struct kfd_dev *dev;
379 int err = 0; 355 int err = 0;
380 struct kfd_process_device *pdd; 356 struct kfd_process_device *pdd;
381 enum cache_policy default_policy, alternate_policy; 357 enum cache_policy default_policy, alternate_policy;
382 358
383 if (copy_from_user(&args, arg, sizeof(args))) 359 if (args->default_policy != KFD_IOC_CACHE_POLICY_COHERENT
384 return -EFAULT; 360 && args->default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) {
385
386 if (args.default_policy != KFD_IOC_CACHE_POLICY_COHERENT
387 && args.default_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) {
388 return -EINVAL; 361 return -EINVAL;
389 } 362 }
390 363
391 if (args.alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT 364 if (args->alternate_policy != KFD_IOC_CACHE_POLICY_COHERENT
392 && args.alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) { 365 && args->alternate_policy != KFD_IOC_CACHE_POLICY_NONCOHERENT) {
393 return -EINVAL; 366 return -EINVAL;
394 } 367 }
395 368
396 dev = kfd_device_by_id(args.gpu_id); 369 dev = kfd_device_by_id(args->gpu_id);
397 if (dev == NULL) 370 if (dev == NULL)
398 return -EINVAL; 371 return -EINVAL;
399 372
@@ -401,23 +374,23 @@ static long kfd_ioctl_set_memory_policy(struct file *filep,
401 374
402 pdd = kfd_bind_process_to_device(dev, p); 375 pdd = kfd_bind_process_to_device(dev, p);
403 if (IS_ERR(pdd)) { 376 if (IS_ERR(pdd)) {
404 err = PTR_ERR(pdd); 377 err = -ESRCH;
405 goto out; 378 goto out;
406 } 379 }
407 380
408 default_policy = (args.default_policy == KFD_IOC_CACHE_POLICY_COHERENT) 381 default_policy = (args->default_policy == KFD_IOC_CACHE_POLICY_COHERENT)
409 ? cache_policy_coherent : cache_policy_noncoherent; 382 ? cache_policy_coherent : cache_policy_noncoherent;
410 383
411 alternate_policy = 384 alternate_policy =
412 (args.alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT) 385 (args->alternate_policy == KFD_IOC_CACHE_POLICY_COHERENT)
413 ? cache_policy_coherent : cache_policy_noncoherent; 386 ? cache_policy_coherent : cache_policy_noncoherent;
414 387
415 if (!dev->dqm->set_cache_memory_policy(dev->dqm, 388 if (!dev->dqm->set_cache_memory_policy(dev->dqm,
416 &pdd->qpd, 389 &pdd->qpd,
417 default_policy, 390 default_policy,
418 alternate_policy, 391 alternate_policy,
419 (void __user *)args.alternate_aperture_base, 392 (void __user *)args->alternate_aperture_base,
420 args.alternate_aperture_size)) 393 args->alternate_aperture_size))
421 err = -EINVAL; 394 err = -EINVAL;
422 395
423out: 396out:
@@ -426,53 +399,44 @@ out:
426 return err; 399 return err;
427} 400}
428 401
429static long kfd_ioctl_get_clock_counters(struct file *filep, 402static int kfd_ioctl_get_clock_counters(struct file *filep,
430 struct kfd_process *p, void __user *arg) 403 struct kfd_process *p, void *data)
431{ 404{
432 struct kfd_ioctl_get_clock_counters_args args; 405 struct kfd_ioctl_get_clock_counters_args *args = data;
433 struct kfd_dev *dev; 406 struct kfd_dev *dev;
434 struct timespec time; 407 struct timespec time;
435 408
436 if (copy_from_user(&args, arg, sizeof(args))) 409 dev = kfd_device_by_id(args->gpu_id);
437 return -EFAULT;
438
439 dev = kfd_device_by_id(args.gpu_id);
440 if (dev == NULL) 410 if (dev == NULL)
441 return -EINVAL; 411 return -EINVAL;
442 412
443 /* Reading GPU clock counter from KGD */ 413 /* Reading GPU clock counter from KGD */
444 args.gpu_clock_counter = kfd2kgd->get_gpu_clock_counter(dev->kgd); 414 args->gpu_clock_counter = kfd2kgd->get_gpu_clock_counter(dev->kgd);
445 415
446 /* No access to rdtsc. Using raw monotonic time */ 416 /* No access to rdtsc. Using raw monotonic time */
447 getrawmonotonic(&time); 417 getrawmonotonic(&time);
448 args.cpu_clock_counter = (uint64_t)timespec_to_ns(&time); 418 args->cpu_clock_counter = (uint64_t)timespec_to_ns(&time);
449 419
450 get_monotonic_boottime(&time); 420 get_monotonic_boottime(&time);
451 args.system_clock_counter = (uint64_t)timespec_to_ns(&time); 421 args->system_clock_counter = (uint64_t)timespec_to_ns(&time);
452 422
453 /* Since the counter is in nano-seconds we use 1GHz frequency */ 423 /* Since the counter is in nano-seconds we use 1GHz frequency */
454 args.system_clock_freq = 1000000000; 424 args->system_clock_freq = 1000000000;
455
456 if (copy_to_user(arg, &args, sizeof(args)))
457 return -EFAULT;
458 425
459 return 0; 426 return 0;
460} 427}
461 428
462 429
463static int kfd_ioctl_get_process_apertures(struct file *filp, 430static int kfd_ioctl_get_process_apertures(struct file *filp,
464 struct kfd_process *p, void __user *arg) 431 struct kfd_process *p, void *data)
465{ 432{
466 struct kfd_ioctl_get_process_apertures_args args; 433 struct kfd_ioctl_get_process_apertures_args *args = data;
467 struct kfd_process_device_apertures *pAperture; 434 struct kfd_process_device_apertures *pAperture;
468 struct kfd_process_device *pdd; 435 struct kfd_process_device *pdd;
469 436
470 dev_dbg(kfd_device, "get apertures for PASID %d", p->pasid); 437 dev_dbg(kfd_device, "get apertures for PASID %d", p->pasid);
471 438
472 if (copy_from_user(&args, arg, sizeof(args))) 439 args->num_of_nodes = 0;
473 return -EFAULT;
474
475 args.num_of_nodes = 0;
476 440
477 mutex_lock(&p->mutex); 441 mutex_lock(&p->mutex);
478 442
@@ -481,7 +445,8 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
481 /* Run over all pdd of the process */ 445 /* Run over all pdd of the process */
482 pdd = kfd_get_first_process_device_data(p); 446 pdd = kfd_get_first_process_device_data(p);
483 do { 447 do {
484 pAperture = &args.process_apertures[args.num_of_nodes]; 448 pAperture =
449 &args->process_apertures[args->num_of_nodes];
485 pAperture->gpu_id = pdd->dev->id; 450 pAperture->gpu_id = pdd->dev->id;
486 pAperture->lds_base = pdd->lds_base; 451 pAperture->lds_base = pdd->lds_base;
487 pAperture->lds_limit = pdd->lds_limit; 452 pAperture->lds_limit = pdd->lds_limit;
@@ -491,7 +456,7 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
491 pAperture->scratch_limit = pdd->scratch_limit; 456 pAperture->scratch_limit = pdd->scratch_limit;
492 457
493 dev_dbg(kfd_device, 458 dev_dbg(kfd_device,
494 "node id %u\n", args.num_of_nodes); 459 "node id %u\n", args->num_of_nodes);
495 dev_dbg(kfd_device, 460 dev_dbg(kfd_device,
496 "gpu id %u\n", pdd->dev->id); 461 "gpu id %u\n", pdd->dev->id);
497 dev_dbg(kfd_device, 462 dev_dbg(kfd_device,
@@ -507,80 +472,131 @@ static int kfd_ioctl_get_process_apertures(struct file *filp,
507 dev_dbg(kfd_device, 472 dev_dbg(kfd_device,
508 "scratch_limit %llX\n", pdd->scratch_limit); 473 "scratch_limit %llX\n", pdd->scratch_limit);
509 474
510 args.num_of_nodes++; 475 args->num_of_nodes++;
511 } while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL && 476 } while ((pdd = kfd_get_next_process_device_data(p, pdd)) != NULL &&
512 (args.num_of_nodes < NUM_OF_SUPPORTED_GPUS)); 477 (args->num_of_nodes < NUM_OF_SUPPORTED_GPUS));
513 } 478 }
514 479
515 mutex_unlock(&p->mutex); 480 mutex_unlock(&p->mutex);
516 481
517 if (copy_to_user(arg, &args, sizeof(args)))
518 return -EFAULT;
519
520 return 0; 482 return 0;
521} 483}
522 484
485#define AMDKFD_IOCTL_DEF(ioctl, _func, _flags) \
486 [_IOC_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags, .cmd_drv = 0, .name = #ioctl}
487
488/** Ioctl table */
489static const struct amdkfd_ioctl_desc amdkfd_ioctls[] = {
490 AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_VERSION,
491 kfd_ioctl_get_version, 0),
492
493 AMDKFD_IOCTL_DEF(AMDKFD_IOC_CREATE_QUEUE,
494 kfd_ioctl_create_queue, 0),
495
496 AMDKFD_IOCTL_DEF(AMDKFD_IOC_DESTROY_QUEUE,
497 kfd_ioctl_destroy_queue, 0),
498
499 AMDKFD_IOCTL_DEF(AMDKFD_IOC_SET_MEMORY_POLICY,
500 kfd_ioctl_set_memory_policy, 0),
501
502 AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_CLOCK_COUNTERS,
503 kfd_ioctl_get_clock_counters, 0),
504
505 AMDKFD_IOCTL_DEF(AMDKFD_IOC_GET_PROCESS_APERTURES,
506 kfd_ioctl_get_process_apertures, 0),
507
508 AMDKFD_IOCTL_DEF(AMDKFD_IOC_UPDATE_QUEUE,
509 kfd_ioctl_update_queue, 0),
510};
511
512#define AMDKFD_CORE_IOCTL_COUNT ARRAY_SIZE(amdkfd_ioctls)
513
523static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) 514static long kfd_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
524{ 515{
525 struct kfd_process *process; 516 struct kfd_process *process;
526 long err = -EINVAL; 517 amdkfd_ioctl_t *func;
518 const struct amdkfd_ioctl_desc *ioctl = NULL;
519 unsigned int nr = _IOC_NR(cmd);
520 char stack_kdata[128];
521 char *kdata = NULL;
522 unsigned int usize, asize;
523 int retcode = -EINVAL;
524
525 if (nr >= AMDKFD_CORE_IOCTL_COUNT)
526 goto err_i1;
527
528 if ((nr >= AMDKFD_COMMAND_START) && (nr < AMDKFD_COMMAND_END)) {
529 u32 amdkfd_size;
530
531 ioctl = &amdkfd_ioctls[nr];
527 532
528 dev_dbg(kfd_device, 533 amdkfd_size = _IOC_SIZE(ioctl->cmd);
529 "ioctl cmd 0x%x (#%d), arg 0x%lx\n", 534 usize = asize = _IOC_SIZE(cmd);
530 cmd, _IOC_NR(cmd), arg); 535 if (amdkfd_size > asize)
536 asize = amdkfd_size;
537
538 cmd = ioctl->cmd;
539 } else
540 goto err_i1;
541
542 dev_dbg(kfd_device, "ioctl cmd 0x%x (#%d), arg 0x%lx\n", cmd, nr, arg);
531 543
532 process = kfd_get_process(current); 544 process = kfd_get_process(current);
533 if (IS_ERR(process)) 545 if (IS_ERR(process)) {
534 return PTR_ERR(process); 546 dev_dbg(kfd_device, "no process\n");
547 goto err_i1;
548 }
535 549
536 switch (cmd) { 550 /* Do not trust userspace, use our own definition */
537 case KFD_IOC_GET_VERSION: 551 func = ioctl->func;
538 err = kfd_ioctl_get_version(filep, process, (void __user *)arg); 552
539 break; 553 if (unlikely(!func)) {
540 case KFD_IOC_CREATE_QUEUE: 554 dev_dbg(kfd_device, "no function\n");
541 err = kfd_ioctl_create_queue(filep, process, 555 retcode = -EINVAL;
542 (void __user *)arg); 556 goto err_i1;
543 break;
544
545 case KFD_IOC_DESTROY_QUEUE:
546 err = kfd_ioctl_destroy_queue(filep, process,
547 (void __user *)arg);
548 break;
549
550 case KFD_IOC_SET_MEMORY_POLICY:
551 err = kfd_ioctl_set_memory_policy(filep, process,
552 (void __user *)arg);
553 break;
554
555 case KFD_IOC_GET_CLOCK_COUNTERS:
556 err = kfd_ioctl_get_clock_counters(filep, process,
557 (void __user *)arg);
558 break;
559
560 case KFD_IOC_GET_PROCESS_APERTURES:
561 err = kfd_ioctl_get_process_apertures(filep, process,
562 (void __user *)arg);
563 break;
564
565 case KFD_IOC_UPDATE_QUEUE:
566 err = kfd_ioctl_update_queue(filep, process,
567 (void __user *)arg);
568 break;
569
570 default:
571 dev_err(kfd_device,
572 "unknown ioctl cmd 0x%x, arg 0x%lx)\n",
573 cmd, arg);
574 err = -EINVAL;
575 break;
576 } 557 }
577 558
578 if (err < 0) 559 if (cmd & (IOC_IN | IOC_OUT)) {
579 dev_err(kfd_device, 560 if (asize <= sizeof(stack_kdata)) {
580 "ioctl error %ld for ioctl cmd 0x%x (#%d)\n", 561 kdata = stack_kdata;
581 err, cmd, _IOC_NR(cmd)); 562 } else {
563 kdata = kmalloc(asize, GFP_KERNEL);
564 if (!kdata) {
565 retcode = -ENOMEM;
566 goto err_i1;
567 }
568 }
569 if (asize > usize)
570 memset(kdata + usize, 0, asize - usize);
571 }
582 572
583 return err; 573 if (cmd & IOC_IN) {
574 if (copy_from_user(kdata, (void __user *)arg, usize) != 0) {
575 retcode = -EFAULT;
576 goto err_i1;
577 }
578 } else if (cmd & IOC_OUT) {
579 memset(kdata, 0, usize);
580 }
581
582 retcode = func(filep, process, kdata);
583
584 if (cmd & IOC_OUT)
585 if (copy_to_user((void __user *)arg, kdata, usize) != 0)
586 retcode = -EFAULT;
587
588err_i1:
589 if (!ioctl)
590 dev_dbg(kfd_device, "invalid ioctl: pid=%d, cmd=0x%02x, nr=0x%02x\n",
591 task_pid_nr(current), cmd, nr);
592
593 if (kdata != stack_kdata)
594 kfree(kdata);
595
596 if (retcode)
597 dev_dbg(kfd_device, "ret = %d\n", retcode);
598
599 return retcode;
584} 600}
585 601
586static int kfd_mmap(struct file *filp, struct vm_area_struct *vma) 602static int kfd_mmap(struct file *filp, struct vm_area_struct *vma)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index 924e90c072e5..9c8961d22360 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -161,6 +161,9 @@ static void deallocate_vmid(struct device_queue_manager *dqm,
161{ 161{
162 int bit = qpd->vmid - KFD_VMID_START_OFFSET; 162 int bit = qpd->vmid - KFD_VMID_START_OFFSET;
163 163
164 /* Release the vmid mapping */
165 set_pasid_vmid_mapping(dqm, 0, qpd->vmid);
166
164 set_bit(bit, (unsigned long *)&dqm->vmid_bitmap); 167 set_bit(bit, (unsigned long *)&dqm->vmid_bitmap);
165 qpd->vmid = 0; 168 qpd->vmid = 0;
166 q->properties.vmid = 0; 169 q->properties.vmid = 0;
@@ -272,6 +275,18 @@ static int create_compute_queue_nocpsch(struct device_queue_manager *dqm,
272 return retval; 275 return retval;
273 } 276 }
274 277
278 pr_debug("kfd: loading mqd to hqd on pipe (%d) queue (%d)\n",
279 q->pipe,
280 q->queue);
281
282 retval = mqd->load_mqd(mqd, q->mqd, q->pipe,
283 q->queue, q->properties.write_ptr);
284 if (retval != 0) {
285 deallocate_hqd(dqm, q);
286 mqd->uninit_mqd(mqd, q->mqd, q->mqd_mem_obj);
287 return retval;
288 }
289
275 return 0; 290 return 0;
276} 291}
277 292
@@ -320,6 +335,7 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
320{ 335{
321 int retval; 336 int retval;
322 struct mqd_manager *mqd; 337 struct mqd_manager *mqd;
338 bool prev_active = false;
323 339
324 BUG_ON(!dqm || !q || !q->mqd); 340 BUG_ON(!dqm || !q || !q->mqd);
325 341
@@ -330,10 +346,18 @@ static int update_queue(struct device_queue_manager *dqm, struct queue *q)
330 return -ENOMEM; 346 return -ENOMEM;
331 } 347 }
332 348
333 retval = mqd->update_mqd(mqd, q->mqd, &q->properties);
334 if (q->properties.is_active == true) 349 if (q->properties.is_active == true)
350 prev_active = true;
351
352 /*
353 *
354 * check active state vs. the previous state
355 * and modify counter accordingly
356 */
357 retval = mqd->update_mqd(mqd, q->mqd, &q->properties);
358 if ((q->properties.is_active == true) && (prev_active == false))
335 dqm->queue_count++; 359 dqm->queue_count++;
336 else 360 else if ((q->properties.is_active == false) && (prev_active == true))
337 dqm->queue_count--; 361 dqm->queue_count--;
338 362
339 if (sched_policy != KFD_SCHED_POLICY_NO_HWS) 363 if (sched_policy != KFD_SCHED_POLICY_NO_HWS)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
index 66df4da01c29..e64aa99e5e41 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c
@@ -299,13 +299,13 @@ int kfd_init_apertures(struct kfd_process *process)
299 struct kfd_dev *dev; 299 struct kfd_dev *dev;
300 struct kfd_process_device *pdd; 300 struct kfd_process_device *pdd;
301 301
302 mutex_lock(&process->mutex);
303
304 /*Iterating over all devices*/ 302 /*Iterating over all devices*/
305 while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL && 303 while ((dev = kfd_topology_enum_kfd_devices(id)) != NULL &&
306 id < NUM_OF_SUPPORTED_GPUS) { 304 id < NUM_OF_SUPPORTED_GPUS) {
307 305
308 pdd = kfd_get_process_device_data(dev, process, 1); 306 pdd = kfd_get_process_device_data(dev, process, 1);
307 if (!pdd)
308 return -1;
309 309
310 /* 310 /*
311 * For 64 bit process aperture will be statically reserved in 311 * For 64 bit process aperture will be statically reserved in
@@ -348,8 +348,6 @@ int kfd_init_apertures(struct kfd_process *process)
348 id++; 348 id++;
349 } 349 }
350 350
351 mutex_unlock(&process->mutex);
352
353 return 0; 351 return 0;
354} 352}
355 353
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
index adc31474e786..4c3828cf45bf 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c
@@ -184,7 +184,7 @@ static bool is_occupied(struct mqd_manager *mm, void *mqd,
184 uint32_t queue_id) 184 uint32_t queue_id)
185{ 185{
186 186
187 return kfd2kgd->hqd_is_occupies(mm->dev->kgd, queue_address, 187 return kfd2kgd->hqd_is_occupied(mm->dev->kgd, queue_address,
188 pipe_id, queue_id); 188 pipe_id, queue_id);
189 189
190} 190}
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
index 71699ad97d74..4c25ef504f79 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_pasid.c
@@ -32,7 +32,7 @@ int kfd_pasid_init(void)
32{ 32{
33 pasid_limit = max_num_of_processes; 33 pasid_limit = max_num_of_processes;
34 34
35 pasid_bitmap = kzalloc(BITS_TO_LONGS(pasid_limit), GFP_KERNEL); 35 pasid_bitmap = kcalloc(BITS_TO_LONGS(pasid_limit), sizeof(long), GFP_KERNEL);
36 if (!pasid_bitmap) 36 if (!pasid_bitmap)
37 return -ENOMEM; 37 return -ENOMEM;
38 38
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index f9fb81e3bb09..a5edb29507e3 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -463,6 +463,24 @@ struct kfd_process {
463 bool is_32bit_user_mode; 463 bool is_32bit_user_mode;
464}; 464};
465 465
466/**
467 * Ioctl function type.
468 *
469 * \param filep pointer to file structure.
470 * \param p amdkfd process pointer.
471 * \param data pointer to arg that was copied from user.
472 */
473typedef int amdkfd_ioctl_t(struct file *filep, struct kfd_process *p,
474 void *data);
475
476struct amdkfd_ioctl_desc {
477 unsigned int cmd;
478 int flags;
479 amdkfd_ioctl_t *func;
480 unsigned int cmd_drv;
481 const char *name;
482};
483
466void kfd_process_create_wq(void); 484void kfd_process_create_wq(void);
467void kfd_process_destroy_wq(void); 485void kfd_process_destroy_wq(void);
468struct kfd_process *kfd_create_process(const struct task_struct *); 486struct kfd_process *kfd_create_process(const struct task_struct *);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index b85eb0b830b4..3c76ef05cbcf 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -26,6 +26,8 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/amd-iommu.h> 27#include <linux/amd-iommu.h>
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/compat.h>
30
29struct mm_struct; 31struct mm_struct;
30 32
31#include "kfd_priv.h" 33#include "kfd_priv.h"
@@ -285,8 +287,15 @@ static struct kfd_process *create_process(const struct task_struct *thread)
285 if (err != 0) 287 if (err != 0)
286 goto err_process_pqm_init; 288 goto err_process_pqm_init;
287 289
290 /* init process apertures*/
291 process->is_32bit_user_mode = is_compat_task();
292 if (kfd_init_apertures(process) != 0)
293 goto err_init_apretures;
294
288 return process; 295 return process;
289 296
297err_init_apretures:
298 pqm_uninit(&process->pqm);
290err_process_pqm_init: 299err_process_pqm_init:
291 hash_del_rcu(&process->kfd_processes); 300 hash_del_rcu(&process->kfd_processes);
292 synchronize_rcu(); 301 synchronize_rcu();
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 5733e2859e8a..cca1708fd811 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -700,8 +700,6 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
700 dev->node_props.simd_per_cu); 700 dev->node_props.simd_per_cu);
701 sysfs_show_32bit_prop(buffer, "max_slots_scratch_cu", 701 sysfs_show_32bit_prop(buffer, "max_slots_scratch_cu",
702 dev->node_props.max_slots_scratch_cu); 702 dev->node_props.max_slots_scratch_cu);
703 sysfs_show_32bit_prop(buffer, "engine_id",
704 dev->node_props.engine_id);
705 sysfs_show_32bit_prop(buffer, "vendor_id", 703 sysfs_show_32bit_prop(buffer, "vendor_id",
706 dev->node_props.vendor_id); 704 dev->node_props.vendor_id);
707 sysfs_show_32bit_prop(buffer, "device_id", 705 sysfs_show_32bit_prop(buffer, "device_id",
@@ -715,6 +713,12 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
715 dev->gpu->kgd)); 713 dev->gpu->kgd));
716 sysfs_show_64bit_prop(buffer, "local_mem_size", 714 sysfs_show_64bit_prop(buffer, "local_mem_size",
717 kfd2kgd->get_vmem_size(dev->gpu->kgd)); 715 kfd2kgd->get_vmem_size(dev->gpu->kgd));
716
717 sysfs_show_32bit_prop(buffer, "fw_version",
718 kfd2kgd->get_fw_version(
719 dev->gpu->kgd,
720 KGD_ENGINE_MEC1));
721
718 } 722 }
719 723
720 ret = sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute", 724 ret = sysfs_show_32bit_prop(buffer, "max_engine_clk_ccompute",
@@ -917,7 +921,7 @@ static int kfd_build_sysfs_node_tree(void)
917 uint32_t i = 0; 921 uint32_t i = 0;
918 922
919 list_for_each_entry(dev, &topology_device_list, list) { 923 list_for_each_entry(dev, &topology_device_list, list) {
920 ret = kfd_build_sysfs_node_entry(dev, 0); 924 ret = kfd_build_sysfs_node_entry(dev, i);
921 if (ret < 0) 925 if (ret < 0)
922 return ret; 926 return ret;
923 i++; 927 i++;
diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
index 9c729dd8dd50..96a512208fad 100644
--- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
+++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h
@@ -45,6 +45,17 @@ enum kgd_memory_pool {
45 KGD_POOL_FRAMEBUFFER = 3, 45 KGD_POOL_FRAMEBUFFER = 3,
46}; 46};
47 47
48enum kgd_engine_type {
49 KGD_ENGINE_PFP = 1,
50 KGD_ENGINE_ME,
51 KGD_ENGINE_CE,
52 KGD_ENGINE_MEC1,
53 KGD_ENGINE_MEC2,
54 KGD_ENGINE_RLC,
55 KGD_ENGINE_SDMA,
56 KGD_ENGINE_MAX
57};
58
48struct kgd2kfd_shared_resources { 59struct kgd2kfd_shared_resources {
49 /* Bit n == 1 means VMID n is available for KFD. */ 60 /* Bit n == 1 means VMID n is available for KFD. */
50 unsigned int compute_vmid_bitmap; 61 unsigned int compute_vmid_bitmap;
@@ -137,6 +148,8 @@ struct kgd2kfd_calls {
137 * 148 *
138 * @hqd_destroy: Destructs and preempts the queue assigned to that hqd slot. 149 * @hqd_destroy: Destructs and preempts the queue assigned to that hqd slot.
139 * 150 *
151 * @get_fw_version: Returns FW versions from the header
152 *
140 * This structure contains function pointers to services that the kgd driver 153 * This structure contains function pointers to services that the kgd driver
141 * provides to amdkfd driver. 154 * provides to amdkfd driver.
142 * 155 *
@@ -170,12 +183,14 @@ struct kfd2kgd_calls {
170 int (*hqd_load)(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, 183 int (*hqd_load)(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
171 uint32_t queue_id, uint32_t __user *wptr); 184 uint32_t queue_id, uint32_t __user *wptr);
172 185
173 bool (*hqd_is_occupies)(struct kgd_dev *kgd, uint64_t queue_address, 186 bool (*hqd_is_occupied)(struct kgd_dev *kgd, uint64_t queue_address,
174 uint32_t pipe_id, uint32_t queue_id); 187 uint32_t pipe_id, uint32_t queue_id);
175 188
176 int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type, 189 int (*hqd_destroy)(struct kgd_dev *kgd, uint32_t reset_type,
177 unsigned int timeout, uint32_t pipe_id, 190 unsigned int timeout, uint32_t pipe_id,
178 uint32_t queue_id); 191 uint32_t queue_id);
192 uint16_t (*get_fw_version)(struct kgd_dev *kgd,
193 enum kgd_engine_type type);
179}; 194};
180 195
181bool kgd2kfd_init(unsigned interface_version, 196bool kgd2kfd_init(unsigned interface_version,
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 4a78a773151c..bbdbe4721573 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -61,7 +61,7 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
61 struct drm_crtc_state *crtc_state; 61 struct drm_crtc_state *crtc_state;
62 62
63 if (plane->state->crtc) { 63 if (plane->state->crtc) {
64 crtc_state = state->crtc_states[drm_crtc_index(plane->crtc)]; 64 crtc_state = state->crtc_states[drm_crtc_index(plane->state->crtc)];
65 65
66 if (WARN_ON(!crtc_state)) 66 if (WARN_ON(!crtc_state))
67 return; 67 return;
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index f5a5f18efa5b..4d79dad9d44f 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -830,6 +830,8 @@ drm_get_last_vbltimestamp(struct drm_device *dev, int crtc,
830 * vblank events since the system was booted, including lost events due to 830 * vblank events since the system was booted, including lost events due to
831 * modesetting activity. 831 * modesetting activity.
832 * 832 *
833 * This is the legacy version of drm_crtc_vblank_count().
834 *
833 * Returns: 835 * Returns:
834 * The software vblank counter. 836 * The software vblank counter.
835 */ 837 */
@@ -844,6 +846,25 @@ u32 drm_vblank_count(struct drm_device *dev, int crtc)
844EXPORT_SYMBOL(drm_vblank_count); 846EXPORT_SYMBOL(drm_vblank_count);
845 847
846/** 848/**
849 * drm_crtc_vblank_count - retrieve "cooked" vblank counter value
850 * @crtc: which counter to retrieve
851 *
852 * Fetches the "cooked" vblank count value that represents the number of
853 * vblank events since the system was booted, including lost events due to
854 * modesetting activity.
855 *
856 * This is the native KMS version of drm_vblank_count().
857 *
858 * Returns:
859 * The software vblank counter.
860 */
861u32 drm_crtc_vblank_count(struct drm_crtc *crtc)
862{
863 return drm_vblank_count(crtc->dev, drm_crtc_index(crtc));
864}
865EXPORT_SYMBOL(drm_crtc_vblank_count);
866
867/**
847 * drm_vblank_count_and_time - retrieve "cooked" vblank counter value 868 * drm_vblank_count_and_time - retrieve "cooked" vblank counter value
848 * and the system timestamp corresponding to that vblank counter value. 869 * and the system timestamp corresponding to that vblank counter value.
849 * 870 *
@@ -904,6 +925,8 @@ static void send_vblank_event(struct drm_device *dev,
904 * 925 *
905 * Updates sequence # and timestamp on event, and sends it to userspace. 926 * Updates sequence # and timestamp on event, and sends it to userspace.
906 * Caller must hold event lock. 927 * Caller must hold event lock.
928 *
929 * This is the legacy version of drm_crtc_send_vblank_event().
907 */ 930 */
908void drm_send_vblank_event(struct drm_device *dev, int crtc, 931void drm_send_vblank_event(struct drm_device *dev, int crtc,
909 struct drm_pending_vblank_event *e) 932 struct drm_pending_vblank_event *e)
@@ -923,6 +946,23 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc,
923EXPORT_SYMBOL(drm_send_vblank_event); 946EXPORT_SYMBOL(drm_send_vblank_event);
924 947
925/** 948/**
949 * drm_crtc_send_vblank_event - helper to send vblank event after pageflip
950 * @crtc: the source CRTC of the vblank event
951 * @e: the event to send
952 *
953 * Updates sequence # and timestamp on event, and sends it to userspace.
954 * Caller must hold event lock.
955 *
956 * This is the native KMS version of drm_send_vblank_event().
957 */
958void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
959 struct drm_pending_vblank_event *e)
960{
961 drm_send_vblank_event(crtc->dev, drm_crtc_index(crtc), e);
962}
963EXPORT_SYMBOL(drm_crtc_send_vblank_event);
964
965/**
926 * drm_vblank_enable - enable the vblank interrupt on a CRTC 966 * drm_vblank_enable - enable the vblank interrupt on a CRTC
927 * @dev: DRM device 967 * @dev: DRM device
928 * @crtc: CRTC in question 968 * @crtc: CRTC in question
@@ -1594,6 +1634,8 @@ static void drm_handle_vblank_events(struct drm_device *dev, int crtc)
1594 * 1634 *
1595 * Drivers should call this routine in their vblank interrupt handlers to 1635 * Drivers should call this routine in their vblank interrupt handlers to
1596 * update the vblank counter and send any signals that may be pending. 1636 * update the vblank counter and send any signals that may be pending.
1637 *
1638 * This is the legacy version of drm_crtc_handle_vblank().
1597 */ 1639 */
1598bool drm_handle_vblank(struct drm_device *dev, int crtc) 1640bool drm_handle_vblank(struct drm_device *dev, int crtc)
1599{ 1641{
@@ -1670,3 +1712,21 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc)
1670 return true; 1712 return true;
1671} 1713}
1672EXPORT_SYMBOL(drm_handle_vblank); 1714EXPORT_SYMBOL(drm_handle_vblank);
1715
1716/**
1717 * drm_crtc_handle_vblank - handle a vblank event
1718 * @crtc: where this event occurred
1719 *
1720 * Drivers should call this routine in their vblank interrupt handlers to
1721 * update the vblank counter and send any signals that may be pending.
1722 *
1723 * This is the native KMS version of drm_handle_vblank().
1724 *
1725 * Returns:
1726 * True if the event was successfully handled, false on failure.
1727 */
1728bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
1729{
1730 return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
1731}
1732EXPORT_SYMBOL(drm_crtc_handle_vblank);
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f990ab4c3efb..574057cd1d09 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -811,6 +811,8 @@ int i915_reset(struct drm_device *dev)
811 if (!i915.reset) 811 if (!i915.reset)
812 return 0; 812 return 0;
813 813
814 intel_reset_gt_powersave(dev);
815
814 mutex_lock(&dev->struct_mutex); 816 mutex_lock(&dev->struct_mutex);
815 817
816 i915_gem_reset(dev); 818 i915_gem_reset(dev);
@@ -880,7 +882,7 @@ int i915_reset(struct drm_device *dev)
880 * of re-init after reset. 882 * of re-init after reset.
881 */ 883 */
882 if (INTEL_INFO(dev)->gen > 5) 884 if (INTEL_INFO(dev)->gen > 5)
883 intel_reset_gt_powersave(dev); 885 intel_enable_gt_powersave(dev);
884 } else { 886 } else {
885 mutex_unlock(&dev->struct_mutex); 887 mutex_unlock(&dev->struct_mutex);
886 } 888 }
@@ -1584,7 +1586,7 @@ static struct drm_driver driver = {
1584 .gem_prime_import = i915_gem_prime_import, 1586 .gem_prime_import = i915_gem_prime_import,
1585 1587
1586 .dumb_create = i915_gem_dumb_create, 1588 .dumb_create = i915_gem_dumb_create,
1587 .dumb_map_offset = i915_gem_dumb_map_offset, 1589 .dumb_map_offset = i915_gem_mmap_gtt,
1588 .dumb_destroy = drm_gem_dumb_destroy, 1590 .dumb_destroy = drm_gem_dumb_destroy,
1589 .ioctls = i915_ioctls, 1591 .ioctls = i915_ioctls,
1590 .fops = &i915_driver_fops, 1592 .fops = &i915_driver_fops,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 63bcda5541ec..e9f891c432f8 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1756,8 +1756,6 @@ struct drm_i915_private {
1756 */ 1756 */
1757 struct workqueue_struct *dp_wq; 1757 struct workqueue_struct *dp_wq;
1758 1758
1759 uint32_t bios_vgacntr;
1760
1761 /* Abstract the submission mechanism (legacy ringbuffer or execlists) away */ 1759 /* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
1762 struct { 1760 struct {
1763 int (*do_execbuf)(struct drm_device *dev, struct drm_file *file, 1761 int (*do_execbuf)(struct drm_device *dev, struct drm_file *file,
@@ -2501,9 +2499,8 @@ void i915_vma_move_to_active(struct i915_vma *vma,
2501int i915_gem_dumb_create(struct drm_file *file_priv, 2499int i915_gem_dumb_create(struct drm_file *file_priv,
2502 struct drm_device *dev, 2500 struct drm_device *dev,
2503 struct drm_mode_create_dumb *args); 2501 struct drm_mode_create_dumb *args);
2504int i915_gem_dumb_map_offset(struct drm_file *file_priv, 2502int i915_gem_mmap_gtt(struct drm_file *file_priv, struct drm_device *dev,
2505 struct drm_device *dev, uint32_t handle, 2503 uint32_t handle, uint64_t *offset);
2506 uint64_t *offset);
2507/** 2504/**
2508 * Returns true if seq1 is later than seq2. 2505 * Returns true if seq1 is later than seq2.
2509 */ 2506 */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 4a9faea626db..c11603b4cf1d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -401,7 +401,6 @@ static int
401i915_gem_create(struct drm_file *file, 401i915_gem_create(struct drm_file *file,
402 struct drm_device *dev, 402 struct drm_device *dev,
403 uint64_t size, 403 uint64_t size,
404 bool dumb,
405 uint32_t *handle_p) 404 uint32_t *handle_p)
406{ 405{
407 struct drm_i915_gem_object *obj; 406 struct drm_i915_gem_object *obj;
@@ -417,7 +416,6 @@ i915_gem_create(struct drm_file *file,
417 if (obj == NULL) 416 if (obj == NULL)
418 return -ENOMEM; 417 return -ENOMEM;
419 418
420 obj->base.dumb = dumb;
421 ret = drm_gem_handle_create(file, &obj->base, &handle); 419 ret = drm_gem_handle_create(file, &obj->base, &handle);
422 /* drop reference from allocate - handle holds it now */ 420 /* drop reference from allocate - handle holds it now */
423 drm_gem_object_unreference_unlocked(&obj->base); 421 drm_gem_object_unreference_unlocked(&obj->base);
@@ -437,7 +435,7 @@ i915_gem_dumb_create(struct drm_file *file,
437 args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64); 435 args->pitch = ALIGN(args->width * DIV_ROUND_UP(args->bpp, 8), 64);
438 args->size = args->pitch * args->height; 436 args->size = args->pitch * args->height;
439 return i915_gem_create(file, dev, 437 return i915_gem_create(file, dev,
440 args->size, true, &args->handle); 438 args->size, &args->handle);
441} 439}
442 440
443/** 441/**
@@ -450,7 +448,7 @@ i915_gem_create_ioctl(struct drm_device *dev, void *data,
450 struct drm_i915_gem_create *args = data; 448 struct drm_i915_gem_create *args = data;
451 449
452 return i915_gem_create(file, dev, 450 return i915_gem_create(file, dev,
453 args->size, false, &args->handle); 451 args->size, &args->handle);
454} 452}
455 453
456static inline int 454static inline int
@@ -1050,6 +1048,7 @@ int
1050i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, 1048i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
1051 struct drm_file *file) 1049 struct drm_file *file)
1052{ 1050{
1051 struct drm_i915_private *dev_priv = dev->dev_private;
1053 struct drm_i915_gem_pwrite *args = data; 1052 struct drm_i915_gem_pwrite *args = data;
1054 struct drm_i915_gem_object *obj; 1053 struct drm_i915_gem_object *obj;
1055 int ret; 1054 int ret;
@@ -1069,9 +1068,11 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
1069 return -EFAULT; 1068 return -EFAULT;
1070 } 1069 }
1071 1070
1071 intel_runtime_pm_get(dev_priv);
1072
1072 ret = i915_mutex_lock_interruptible(dev); 1073 ret = i915_mutex_lock_interruptible(dev);
1073 if (ret) 1074 if (ret)
1074 return ret; 1075 goto put_rpm;
1075 1076
1076 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle)); 1077 obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
1077 if (&obj->base == NULL) { 1078 if (&obj->base == NULL) {
@@ -1123,6 +1124,9 @@ out:
1123 drm_gem_object_unreference(&obj->base); 1124 drm_gem_object_unreference(&obj->base);
1124unlock: 1125unlock:
1125 mutex_unlock(&dev->struct_mutex); 1126 mutex_unlock(&dev->struct_mutex);
1127put_rpm:
1128 intel_runtime_pm_put(dev_priv);
1129
1126 return ret; 1130 return ret;
1127} 1131}
1128 1132
@@ -1840,10 +1844,10 @@ static void i915_gem_object_free_mmap_offset(struct drm_i915_gem_object *obj)
1840 drm_gem_free_mmap_offset(&obj->base); 1844 drm_gem_free_mmap_offset(&obj->base);
1841} 1845}
1842 1846
1843static int 1847int
1844i915_gem_mmap_gtt(struct drm_file *file, 1848i915_gem_mmap_gtt(struct drm_file *file,
1845 struct drm_device *dev, 1849 struct drm_device *dev,
1846 uint32_t handle, bool dumb, 1850 uint32_t handle,
1847 uint64_t *offset) 1851 uint64_t *offset)
1848{ 1852{
1849 struct drm_i915_private *dev_priv = dev->dev_private; 1853 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1860,13 +1864,6 @@ i915_gem_mmap_gtt(struct drm_file *file,
1860 goto unlock; 1864 goto unlock;
1861 } 1865 }
1862 1866
1863 /*
1864 * We don't allow dumb mmaps on objects created using another
1865 * interface.
1866 */
1867 WARN_ONCE(dumb && !(obj->base.dumb || obj->base.import_attach),
1868 "Illegal dumb map of accelerated buffer.\n");
1869
1870 if (obj->base.size > dev_priv->gtt.mappable_end) { 1867 if (obj->base.size > dev_priv->gtt.mappable_end) {
1871 ret = -E2BIG; 1868 ret = -E2BIG;
1872 goto out; 1869 goto out;
@@ -1891,15 +1888,6 @@ unlock:
1891 return ret; 1888 return ret;
1892} 1889}
1893 1890
1894int
1895i915_gem_dumb_map_offset(struct drm_file *file,
1896 struct drm_device *dev,
1897 uint32_t handle,
1898 uint64_t *offset)
1899{
1900 return i915_gem_mmap_gtt(file, dev, handle, true, offset);
1901}
1902
1903/** 1891/**
1904 * i915_gem_mmap_gtt_ioctl - prepare an object for GTT mmap'ing 1892 * i915_gem_mmap_gtt_ioctl - prepare an object for GTT mmap'ing
1905 * @dev: DRM device 1893 * @dev: DRM device
@@ -1921,7 +1909,7 @@ i915_gem_mmap_gtt_ioctl(struct drm_device *dev, void *data,
1921{ 1909{
1922 struct drm_i915_gem_mmap_gtt *args = data; 1910 struct drm_i915_gem_mmap_gtt *args = data;
1923 1911
1924 return i915_gem_mmap_gtt(file, dev, args->handle, false, &args->offset); 1912 return i915_gem_mmap_gtt(file, dev, args->handle, &args->offset);
1925} 1913}
1926 1914
1927static inline int 1915static inline int
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index d17ff435f276..d011ec82ef1e 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -473,7 +473,12 @@ mi_set_context(struct intel_engine_cs *ring,
473 u32 hw_flags) 473 u32 hw_flags)
474{ 474{
475 u32 flags = hw_flags | MI_MM_SPACE_GTT; 475 u32 flags = hw_flags | MI_MM_SPACE_GTT;
476 int ret; 476 const int num_rings =
477 /* Use an extended w/a on ivb+ if signalling from other rings */
478 i915_semaphore_is_enabled(ring->dev) ?
479 hweight32(INTEL_INFO(ring->dev)->ring_mask) - 1 :
480 0;
481 int len, i, ret;
477 482
478 /* w/a: If Flush TLB Invalidation Mode is enabled, driver must do a TLB 483 /* w/a: If Flush TLB Invalidation Mode is enabled, driver must do a TLB
479 * invalidation prior to MI_SET_CONTEXT. On GEN6 we don't set the value 484 * invalidation prior to MI_SET_CONTEXT. On GEN6 we don't set the value
@@ -490,15 +495,31 @@ mi_set_context(struct intel_engine_cs *ring,
490 if (!IS_HASWELL(ring->dev) && INTEL_INFO(ring->dev)->gen < 8) 495 if (!IS_HASWELL(ring->dev) && INTEL_INFO(ring->dev)->gen < 8)
491 flags |= (MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN); 496 flags |= (MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN);
492 497
493 ret = intel_ring_begin(ring, 6); 498
499 len = 4;
500 if (INTEL_INFO(ring->dev)->gen >= 7)
501 len += 2 + (num_rings ? 4*num_rings + 2 : 0);
502
503 ret = intel_ring_begin(ring, len);
494 if (ret) 504 if (ret)
495 return ret; 505 return ret;
496 506
497 /* WaProgramMiArbOnOffAroundMiSetContext:ivb,vlv,hsw,bdw,chv */ 507 /* WaProgramMiArbOnOffAroundMiSetContext:ivb,vlv,hsw,bdw,chv */
498 if (INTEL_INFO(ring->dev)->gen >= 7) 508 if (INTEL_INFO(ring->dev)->gen >= 7) {
499 intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_DISABLE); 509 intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_DISABLE);
500 else 510 if (num_rings) {
501 intel_ring_emit(ring, MI_NOOP); 511 struct intel_engine_cs *signaller;
512
513 intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(num_rings));
514 for_each_ring(signaller, to_i915(ring->dev), i) {
515 if (signaller == ring)
516 continue;
517
518 intel_ring_emit(ring, RING_PSMI_CTL(signaller->mmio_base));
519 intel_ring_emit(ring, _MASKED_BIT_ENABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
520 }
521 }
522 }
502 523
503 intel_ring_emit(ring, MI_NOOP); 524 intel_ring_emit(ring, MI_NOOP);
504 intel_ring_emit(ring, MI_SET_CONTEXT); 525 intel_ring_emit(ring, MI_SET_CONTEXT);
@@ -510,10 +531,21 @@ mi_set_context(struct intel_engine_cs *ring,
510 */ 531 */
511 intel_ring_emit(ring, MI_NOOP); 532 intel_ring_emit(ring, MI_NOOP);
512 533
513 if (INTEL_INFO(ring->dev)->gen >= 7) 534 if (INTEL_INFO(ring->dev)->gen >= 7) {
535 if (num_rings) {
536 struct intel_engine_cs *signaller;
537
538 intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(num_rings));
539 for_each_ring(signaller, to_i915(ring->dev), i) {
540 if (signaller == ring)
541 continue;
542
543 intel_ring_emit(ring, RING_PSMI_CTL(signaller->mmio_base));
544 intel_ring_emit(ring, _MASKED_BIT_DISABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
545 }
546 }
514 intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_ENABLE); 547 intel_ring_emit(ring, MI_ARB_ON_OFF | MI_ARB_ENABLE);
515 else 548 }
516 intel_ring_emit(ring, MI_NOOP);
517 549
518 intel_ring_advance(ring); 550 intel_ring_advance(ring);
519 551
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index f06027ba3ee5..11738316394a 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -121,9 +121,6 @@ eb_lookup_vmas(struct eb_vmas *eb,
121 goto err; 121 goto err;
122 } 122 }
123 123
124 WARN_ONCE(obj->base.dumb,
125 "GPU use of dumb buffer is illegal.\n");
126
127 drm_gem_object_reference(&obj->base); 124 drm_gem_object_reference(&obj->base);
128 list_add_tail(&obj->obj_exec_link, &objects); 125 list_add_tail(&obj->obj_exec_link, &objects);
129 } 126 }
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 981834b0f9b6..d0d3dfbe6d2a 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -281,10 +281,14 @@ void gen6_enable_rps_interrupts(struct drm_device *dev)
281 struct drm_i915_private *dev_priv = dev->dev_private; 281 struct drm_i915_private *dev_priv = dev->dev_private;
282 282
283 spin_lock_irq(&dev_priv->irq_lock); 283 spin_lock_irq(&dev_priv->irq_lock);
284
284 WARN_ON(dev_priv->rps.pm_iir); 285 WARN_ON(dev_priv->rps.pm_iir);
285 WARN_ON(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events); 286 WARN_ON(I915_READ(gen6_pm_iir(dev_priv)) & dev_priv->pm_rps_events);
286 dev_priv->rps.interrupts_enabled = true; 287 dev_priv->rps.interrupts_enabled = true;
288 I915_WRITE(gen6_pm_ier(dev_priv), I915_READ(gen6_pm_ier(dev_priv)) |
289 dev_priv->pm_rps_events);
287 gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events); 290 gen6_enable_pm_irq(dev_priv, dev_priv->pm_rps_events);
291
288 spin_unlock_irq(&dev_priv->irq_lock); 292 spin_unlock_irq(&dev_priv->irq_lock);
289} 293}
290 294
@@ -3307,8 +3311,10 @@ static void gen5_gt_irq_postinstall(struct drm_device *dev)
3307 GEN5_IRQ_INIT(GT, dev_priv->gt_irq_mask, gt_irqs); 3311 GEN5_IRQ_INIT(GT, dev_priv->gt_irq_mask, gt_irqs);
3308 3312
3309 if (INTEL_INFO(dev)->gen >= 6) { 3313 if (INTEL_INFO(dev)->gen >= 6) {
3310 pm_irqs |= dev_priv->pm_rps_events; 3314 /*
3311 3315 * RPS interrupts will get enabled/disabled on demand when RPS
3316 * itself is enabled/disabled.
3317 */
3312 if (HAS_VEBOX(dev)) 3318 if (HAS_VEBOX(dev))
3313 pm_irqs |= PM_VEBOX_USER_INTERRUPT; 3319 pm_irqs |= PM_VEBOX_USER_INTERRUPT;
3314 3320
@@ -3520,7 +3526,11 @@ static void gen8_gt_irq_postinstall(struct drm_i915_private *dev_priv)
3520 dev_priv->pm_irq_mask = 0xffffffff; 3526 dev_priv->pm_irq_mask = 0xffffffff;
3521 GEN8_IRQ_INIT_NDX(GT, 0, ~gt_interrupts[0], gt_interrupts[0]); 3527 GEN8_IRQ_INIT_NDX(GT, 0, ~gt_interrupts[0], gt_interrupts[0]);
3522 GEN8_IRQ_INIT_NDX(GT, 1, ~gt_interrupts[1], gt_interrupts[1]); 3528 GEN8_IRQ_INIT_NDX(GT, 1, ~gt_interrupts[1], gt_interrupts[1]);
3523 GEN8_IRQ_INIT_NDX(GT, 2, dev_priv->pm_irq_mask, dev_priv->pm_rps_events); 3529 /*
3530 * RPS interrupts will get enabled/disabled on demand when RPS itself
3531 * is enabled/disabled.
3532 */
3533 GEN8_IRQ_INIT_NDX(GT, 2, dev_priv->pm_irq_mask, 0);
3524 GEN8_IRQ_INIT_NDX(GT, 3, ~gt_interrupts[3], gt_interrupts[3]); 3534 GEN8_IRQ_INIT_NDX(GT, 3, ~gt_interrupts[3], gt_interrupts[3]);
3525} 3535}
3526 3536
@@ -3609,7 +3619,7 @@ static void vlv_display_irq_uninstall(struct drm_i915_private *dev_priv)
3609 3619
3610 vlv_display_irq_reset(dev_priv); 3620 vlv_display_irq_reset(dev_priv);
3611 3621
3612 dev_priv->irq_mask = 0; 3622 dev_priv->irq_mask = ~0;
3613} 3623}
3614 3624
3615static void valleyview_irq_uninstall(struct drm_device *dev) 3625static void valleyview_irq_uninstall(struct drm_device *dev)
@@ -3715,8 +3725,6 @@ static bool i8xx_handle_vblank(struct drm_device *dev,
3715 if ((iir & flip_pending) == 0) 3725 if ((iir & flip_pending) == 0)
3716 goto check_page_flip; 3726 goto check_page_flip;
3717 3727
3718 intel_prepare_page_flip(dev, plane);
3719
3720 /* We detect FlipDone by looking for the change in PendingFlip from '1' 3728 /* We detect FlipDone by looking for the change in PendingFlip from '1'
3721 * to '0' on the following vblank, i.e. IIR has the Pendingflip 3729 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3722 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence 3730 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
@@ -3726,6 +3734,7 @@ static bool i8xx_handle_vblank(struct drm_device *dev,
3726 if (I915_READ16(ISR) & flip_pending) 3734 if (I915_READ16(ISR) & flip_pending)
3727 goto check_page_flip; 3735 goto check_page_flip;
3728 3736
3737 intel_prepare_page_flip(dev, plane);
3729 intel_finish_page_flip(dev, pipe); 3738 intel_finish_page_flip(dev, pipe);
3730 return true; 3739 return true;
3731 3740
@@ -3897,8 +3906,6 @@ static bool i915_handle_vblank(struct drm_device *dev,
3897 if ((iir & flip_pending) == 0) 3906 if ((iir & flip_pending) == 0)
3898 goto check_page_flip; 3907 goto check_page_flip;
3899 3908
3900 intel_prepare_page_flip(dev, plane);
3901
3902 /* We detect FlipDone by looking for the change in PendingFlip from '1' 3909 /* We detect FlipDone by looking for the change in PendingFlip from '1'
3903 * to '0' on the following vblank, i.e. IIR has the Pendingflip 3910 * to '0' on the following vblank, i.e. IIR has the Pendingflip
3904 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence 3911 * asserted following the MI_DISPLAY_FLIP, but ISR is deasserted, hence
@@ -3908,6 +3915,7 @@ static bool i915_handle_vblank(struct drm_device *dev,
3908 if (I915_READ(ISR) & flip_pending) 3915 if (I915_READ(ISR) & flip_pending)
3909 goto check_page_flip; 3916 goto check_page_flip;
3910 3917
3918 intel_prepare_page_flip(dev, plane);
3911 intel_finish_page_flip(dev, pipe); 3919 intel_finish_page_flip(dev, pipe);
3912 return true; 3920 return true;
3913 3921
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index eefdc238f70b..172de3b3433b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -395,6 +395,7 @@
395#define PIPE_CONTROL_STORE_DATA_INDEX (1<<21) 395#define PIPE_CONTROL_STORE_DATA_INDEX (1<<21)
396#define PIPE_CONTROL_CS_STALL (1<<20) 396#define PIPE_CONTROL_CS_STALL (1<<20)
397#define PIPE_CONTROL_TLB_INVALIDATE (1<<18) 397#define PIPE_CONTROL_TLB_INVALIDATE (1<<18)
398#define PIPE_CONTROL_MEDIA_STATE_CLEAR (1<<16)
398#define PIPE_CONTROL_QW_WRITE (1<<14) 399#define PIPE_CONTROL_QW_WRITE (1<<14)
399#define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14) 400#define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)
400#define PIPE_CONTROL_DEPTH_STALL (1<<13) 401#define PIPE_CONTROL_DEPTH_STALL (1<<13)
@@ -1128,6 +1129,7 @@ enum punit_power_well {
1128#define GEN6_VERSYNC (RING_SYNC_1(VEBOX_RING_BASE)) 1129#define GEN6_VERSYNC (RING_SYNC_1(VEBOX_RING_BASE))
1129#define GEN6_VEVSYNC (RING_SYNC_2(VEBOX_RING_BASE)) 1130#define GEN6_VEVSYNC (RING_SYNC_2(VEBOX_RING_BASE))
1130#define GEN6_NOSYNC 0 1131#define GEN6_NOSYNC 0
1132#define RING_PSMI_CTL(base) ((base)+0x50)
1131#define RING_MAX_IDLE(base) ((base)+0x54) 1133#define RING_MAX_IDLE(base) ((base)+0x54)
1132#define RING_HWS_PGA(base) ((base)+0x80) 1134#define RING_HWS_PGA(base) ((base)+0x80)
1133#define RING_HWS_PGA_GEN6(base) ((base)+0x2080) 1135#define RING_HWS_PGA_GEN6(base) ((base)+0x2080)
@@ -1458,6 +1460,7 @@ enum punit_power_well {
1458#define GEN6_BLITTER_FBC_NOTIFY (1<<3) 1460#define GEN6_BLITTER_FBC_NOTIFY (1<<3)
1459 1461
1460#define GEN6_RC_SLEEP_PSMI_CONTROL 0x2050 1462#define GEN6_RC_SLEEP_PSMI_CONTROL 0x2050
1463#define GEN6_PSMI_SLEEP_MSG_DISABLE (1 << 0)
1461#define GEN8_RC_SEMA_IDLE_MSG_DISABLE (1 << 12) 1464#define GEN8_RC_SEMA_IDLE_MSG_DISABLE (1 << 12)
1462#define GEN8_FF_DOP_CLOCK_GATE_DISABLE (1<<10) 1465#define GEN8_FF_DOP_CLOCK_GATE_DISABLE (1<<10)
1463 1466
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index fb3e3d429191..e2af1383b179 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13057,11 +13057,7 @@ static void i915_disable_vga(struct drm_device *dev)
13057 vga_put(dev->pdev, VGA_RSRC_LEGACY_IO); 13057 vga_put(dev->pdev, VGA_RSRC_LEGACY_IO);
13058 udelay(300); 13058 udelay(300);
13059 13059
13060 /* 13060 I915_WRITE(vga_reg, VGA_DISP_DISABLE);
13061 * Fujitsu-Siemens Lifebook S6010 (830) has problems resuming
13062 * from S3 without preserving (some of?) the other bits.
13063 */
13064 I915_WRITE(vga_reg, dev_priv->bios_vgacntr | VGA_DISP_DISABLE);
13065 POSTING_READ(vga_reg); 13061 POSTING_READ(vga_reg);
13066} 13062}
13067 13063
@@ -13146,8 +13142,6 @@ void intel_modeset_init(struct drm_device *dev)
13146 13142
13147 intel_shared_dpll_init(dev); 13143 intel_shared_dpll_init(dev);
13148 13144
13149 /* save the BIOS value before clobbering it */
13150 dev_priv->bios_vgacntr = I915_READ(i915_vgacntrl_reg(dev));
13151 /* Just disable it once at startup */ 13145 /* Just disable it once at startup */
13152 i915_disable_vga(dev); 13146 i915_disable_vga(dev);
13153 intel_setup_outputs(dev); 13147 intel_setup_outputs(dev);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 1f4b56e273c8..964b28e3c630 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -6191,6 +6191,20 @@ void intel_cleanup_gt_powersave(struct drm_device *dev)
6191 valleyview_cleanup_gt_powersave(dev); 6191 valleyview_cleanup_gt_powersave(dev);
6192} 6192}
6193 6193
6194static void gen6_suspend_rps(struct drm_device *dev)
6195{
6196 struct drm_i915_private *dev_priv = dev->dev_private;
6197
6198 flush_delayed_work(&dev_priv->rps.delayed_resume_work);
6199
6200 /*
6201 * TODO: disable RPS interrupts on GEN9+ too once RPS support
6202 * is added for it.
6203 */
6204 if (INTEL_INFO(dev)->gen < 9)
6205 gen6_disable_rps_interrupts(dev);
6206}
6207
6194/** 6208/**
6195 * intel_suspend_gt_powersave - suspend PM work and helper threads 6209 * intel_suspend_gt_powersave - suspend PM work and helper threads
6196 * @dev: drm device 6210 * @dev: drm device
@@ -6206,14 +6220,7 @@ void intel_suspend_gt_powersave(struct drm_device *dev)
6206 if (INTEL_INFO(dev)->gen < 6) 6220 if (INTEL_INFO(dev)->gen < 6)
6207 return; 6221 return;
6208 6222
6209 flush_delayed_work(&dev_priv->rps.delayed_resume_work); 6223 gen6_suspend_rps(dev);
6210
6211 /*
6212 * TODO: disable RPS interrupts on GEN9+ too once RPS support
6213 * is added for it.
6214 */
6215 if (INTEL_INFO(dev)->gen < 9)
6216 gen6_disable_rps_interrupts(dev);
6217 6224
6218 /* Force GPU to min freq during suspend */ 6225 /* Force GPU to min freq during suspend */
6219 gen6_rps_idle(dev_priv); 6226 gen6_rps_idle(dev_priv);
@@ -6316,8 +6323,11 @@ void intel_reset_gt_powersave(struct drm_device *dev)
6316{ 6323{
6317 struct drm_i915_private *dev_priv = dev->dev_private; 6324 struct drm_i915_private *dev_priv = dev->dev_private;
6318 6325
6326 if (INTEL_INFO(dev)->gen < 6)
6327 return;
6328
6329 gen6_suspend_rps(dev);
6319 dev_priv->rps.enabled = false; 6330 dev_priv->rps.enabled = false;
6320 intel_enable_gt_powersave(dev);
6321} 6331}
6322 6332
6323static void ibx_init_clock_gating(struct drm_device *dev) 6333static void ibx_init_clock_gating(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 9f445e9a75d1..c7bc93d28d84 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -362,12 +362,15 @@ gen7_render_ring_flush(struct intel_engine_cs *ring,
362 flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE; 362 flags |= PIPE_CONTROL_VF_CACHE_INVALIDATE;
363 flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE; 363 flags |= PIPE_CONTROL_CONST_CACHE_INVALIDATE;
364 flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE; 364 flags |= PIPE_CONTROL_STATE_CACHE_INVALIDATE;
365 flags |= PIPE_CONTROL_MEDIA_STATE_CLEAR;
365 /* 366 /*
366 * TLB invalidate requires a post-sync write. 367 * TLB invalidate requires a post-sync write.
367 */ 368 */
368 flags |= PIPE_CONTROL_QW_WRITE; 369 flags |= PIPE_CONTROL_QW_WRITE;
369 flags |= PIPE_CONTROL_GLOBAL_GTT_IVB; 370 flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
370 371
372 flags |= PIPE_CONTROL_STALL_AT_SCOREBOARD;
373
371 /* Workaround: we must issue a pipe_control with CS-stall bit 374 /* Workaround: we must issue a pipe_control with CS-stall bit
372 * set before a pipe_control command that has the state cache 375 * set before a pipe_control command that has the state cache
373 * invalidate bit set. */ 376 * invalidate bit set. */
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index f5a78d53e297..ac6da7102fbb 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -615,29 +615,6 @@ static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv,
615 vlv_power_sequencer_reset(dev_priv); 615 vlv_power_sequencer_reset(dev_priv);
616} 616}
617 617
618static void check_power_well_state(struct drm_i915_private *dev_priv,
619 struct i915_power_well *power_well)
620{
621 bool enabled = power_well->ops->is_enabled(dev_priv, power_well);
622
623 if (power_well->always_on || !i915.disable_power_well) {
624 if (!enabled)
625 goto mismatch;
626
627 return;
628 }
629
630 if (enabled != (power_well->count > 0))
631 goto mismatch;
632
633 return;
634
635mismatch:
636 WARN(1, "state mismatch for '%s' (always_on %d hw state %d use-count %d disable_power_well %d\n",
637 power_well->name, power_well->always_on, enabled,
638 power_well->count, i915.disable_power_well);
639}
640
641/** 618/**
642 * intel_display_power_get - grab a power domain reference 619 * intel_display_power_get - grab a power domain reference
643 * @dev_priv: i915 device instance 620 * @dev_priv: i915 device instance
@@ -669,8 +646,6 @@ void intel_display_power_get(struct drm_i915_private *dev_priv,
669 power_well->ops->enable(dev_priv, power_well); 646 power_well->ops->enable(dev_priv, power_well);
670 power_well->hw_enabled = true; 647 power_well->hw_enabled = true;
671 } 648 }
672
673 check_power_well_state(dev_priv, power_well);
674 } 649 }
675 650
676 power_domains->domain_use_count[domain]++; 651 power_domains->domain_use_count[domain]++;
@@ -709,8 +684,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
709 power_well->hw_enabled = false; 684 power_well->hw_enabled = false;
710 power_well->ops->disable(dev_priv, power_well); 685 power_well->ops->disable(dev_priv, power_well);
711 } 686 }
712
713 check_power_well_state(dev_priv, power_well);
714 } 687 }
715 688
716 mutex_unlock(&power_domains->lock); 689 mutex_unlock(&power_domains->lock);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index aa873048308b..94a5bee69fe7 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -386,9 +386,7 @@ void adreno_gpu_cleanup(struct adreno_gpu *gpu)
386 msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id); 386 msm_gem_put_iova(gpu->memptrs_bo, gpu->base.id);
387 drm_gem_object_unreference(gpu->memptrs_bo); 387 drm_gem_object_unreference(gpu->memptrs_bo);
388 } 388 }
389 if (gpu->pm4) 389 release_firmware(gpu->pm4);
390 release_firmware(gpu->pm4); 390 release_firmware(gpu->pfp);
391 if (gpu->pfp)
392 release_firmware(gpu->pfp);
393 msm_gpu_cleanup(&gpu->base); 391 msm_gpu_cleanup(&gpu->base);
394} 392}
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index fbebb0405d76..b4e70e0e3cfa 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -141,6 +141,15 @@ static int hpd_enable(struct hdmi_connector *hdmi_connector)
141 uint32_t hpd_ctrl; 141 uint32_t hpd_ctrl;
142 int i, ret; 142 int i, ret;
143 143
144 for (i = 0; i < config->hpd_reg_cnt; i++) {
145 ret = regulator_enable(hdmi->hpd_regs[i]);
146 if (ret) {
147 dev_err(dev->dev, "failed to enable hpd regulator: %s (%d)\n",
148 config->hpd_reg_names[i], ret);
149 goto fail;
150 }
151 }
152
144 ret = gpio_config(hdmi, true); 153 ret = gpio_config(hdmi, true);
145 if (ret) { 154 if (ret) {
146 dev_err(dev->dev, "failed to configure GPIOs: %d\n", ret); 155 dev_err(dev->dev, "failed to configure GPIOs: %d\n", ret);
@@ -164,15 +173,6 @@ static int hpd_enable(struct hdmi_connector *hdmi_connector)
164 } 173 }
165 } 174 }
166 175
167 for (i = 0; i < config->hpd_reg_cnt; i++) {
168 ret = regulator_enable(hdmi->hpd_regs[i]);
169 if (ret) {
170 dev_err(dev->dev, "failed to enable hpd regulator: %s (%d)\n",
171 config->hpd_reg_names[i], ret);
172 goto fail;
173 }
174 }
175
176 hdmi_set_mode(hdmi, false); 176 hdmi_set_mode(hdmi, false);
177 phy->funcs->reset(phy); 177 phy->funcs->reset(phy);
178 hdmi_set_mode(hdmi, true); 178 hdmi_set_mode(hdmi, true);
@@ -200,7 +200,7 @@ fail:
200 return ret; 200 return ret;
201} 201}
202 202
203static int hdp_disable(struct hdmi_connector *hdmi_connector) 203static void hdp_disable(struct hdmi_connector *hdmi_connector)
204{ 204{
205 struct hdmi *hdmi = hdmi_connector->hdmi; 205 struct hdmi *hdmi = hdmi_connector->hdmi;
206 const struct hdmi_platform_config *config = hdmi->config; 206 const struct hdmi_platform_config *config = hdmi->config;
@@ -212,28 +212,19 @@ static int hdp_disable(struct hdmi_connector *hdmi_connector)
212 212
213 hdmi_set_mode(hdmi, false); 213 hdmi_set_mode(hdmi, false);
214 214
215 for (i = 0; i < config->hpd_reg_cnt; i++) {
216 ret = regulator_disable(hdmi->hpd_regs[i]);
217 if (ret) {
218 dev_err(dev->dev, "failed to disable hpd regulator: %s (%d)\n",
219 config->hpd_reg_names[i], ret);
220 goto fail;
221 }
222 }
223
224 for (i = 0; i < config->hpd_clk_cnt; i++) 215 for (i = 0; i < config->hpd_clk_cnt; i++)
225 clk_disable_unprepare(hdmi->hpd_clks[i]); 216 clk_disable_unprepare(hdmi->hpd_clks[i]);
226 217
227 ret = gpio_config(hdmi, false); 218 ret = gpio_config(hdmi, false);
228 if (ret) { 219 if (ret)
229 dev_err(dev->dev, "failed to unconfigure GPIOs: %d\n", ret); 220 dev_warn(dev->dev, "failed to unconfigure GPIOs: %d\n", ret);
230 goto fail;
231 }
232
233 return 0;
234 221
235fail: 222 for (i = 0; i < config->hpd_reg_cnt; i++) {
236 return ret; 223 ret = regulator_disable(hdmi->hpd_regs[i]);
224 if (ret)
225 dev_warn(dev->dev, "failed to disable hpd regulator: %s (%d)\n",
226 config->hpd_reg_names[i], ret);
227 }
237} 228}
238 229
239static void 230static void
@@ -260,11 +251,11 @@ void hdmi_connector_irq(struct drm_connector *connector)
260 (hpd_int_status & HDMI_HPD_INT_STATUS_INT)) { 251 (hpd_int_status & HDMI_HPD_INT_STATUS_INT)) {
261 bool detected = !!(hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED); 252 bool detected = !!(hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED);
262 253
263 DBG("status=%04x, ctrl=%04x", hpd_int_status, hpd_int_ctrl); 254 /* ack & disable (temporarily) HPD events: */
264
265 /* ack the irq: */
266 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 255 hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL,
267 hpd_int_ctrl | HDMI_HPD_INT_CTRL_INT_ACK); 256 HDMI_HPD_INT_CTRL_INT_ACK);
257
258 DBG("status=%04x, ctrl=%04x", hpd_int_status, hpd_int_ctrl);
268 259
269 /* detect disconnect if we are connected or visa versa: */ 260 /* detect disconnect if we are connected or visa versa: */
270 hpd_int_ctrl = HDMI_HPD_INT_CTRL_INT_EN; 261 hpd_int_ctrl = HDMI_HPD_INT_CTRL_INT_EN;
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index a7672e100d8b..3449213f1e76 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -331,17 +331,8 @@ static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
331 struct drm_crtc_state *state) 331 struct drm_crtc_state *state)
332{ 332{
333 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc); 333 struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
334 struct drm_device *dev = crtc->dev;
335
336 DBG("%s: check", mdp4_crtc->name); 334 DBG("%s: check", mdp4_crtc->name);
337
338 if (mdp4_crtc->event) {
339 dev_err(dev->dev, "already pending flip!\n");
340 return -EBUSY;
341 }
342
343 // TODO anything else to check? 335 // TODO anything else to check?
344
345 return 0; 336 return 0;
346} 337}
347 338
@@ -357,7 +348,7 @@ static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc)
357 struct drm_device *dev = crtc->dev; 348 struct drm_device *dev = crtc->dev;
358 unsigned long flags; 349 unsigned long flags;
359 350
360 DBG("%s: flush", mdp4_crtc->name); 351 DBG("%s: event: %p", mdp4_crtc->name, crtc->state->event);
361 352
362 WARN_ON(mdp4_crtc->event); 353 WARN_ON(mdp4_crtc->event);
363 354
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index 0e9a2e3a82d7..f021f960a8a2 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -303,11 +303,6 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
303 303
304 DBG("%s: check", mdp5_crtc->name); 304 DBG("%s: check", mdp5_crtc->name);
305 305
306 if (mdp5_crtc->event) {
307 dev_err(dev->dev, "already pending flip!\n");
308 return -EBUSY;
309 }
310
311 /* request a free CTL, if none is already allocated for this CRTC */ 306 /* request a free CTL, if none is already allocated for this CRTC */
312 if (state->enable && !mdp5_crtc->ctl) { 307 if (state->enable && !mdp5_crtc->ctl) {
313 mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc); 308 mdp5_crtc->ctl = mdp5_ctlm_request(mdp5_kms->ctlm, crtc);
@@ -364,7 +359,7 @@ static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc)
364 struct drm_device *dev = crtc->dev; 359 struct drm_device *dev = crtc->dev;
365 unsigned long flags; 360 unsigned long flags;
366 361
367 DBG("%s: flush", mdp5_crtc->name); 362 DBG("%s: event: %p", mdp5_crtc->name, crtc->state->event);
368 363
369 WARN_ON(mdp5_crtc->event); 364 WARN_ON(mdp5_crtc->event);
370 365
@@ -460,10 +455,7 @@ void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
460 /* now that we know what irq's we want: */ 455 /* now that we know what irq's we want: */
461 mdp5_crtc->err.irqmask = intf2err(intf); 456 mdp5_crtc->err.irqmask = intf2err(intf);
462 mdp5_crtc->vblank.irqmask = intf2vblank(intf); 457 mdp5_crtc->vblank.irqmask = intf2vblank(intf);
463 458 mdp_irq_update(&mdp5_kms->base);
464 /* when called from modeset_init(), skip the rest until later: */
465 if (!mdp5_kms)
466 return;
467 459
468 spin_lock_irqsave(&mdp5_kms->resource_lock, flags); 460 spin_lock_irqsave(&mdp5_kms->resource_lock, flags);
469 intf_sel = mdp5_read(mdp5_kms, REG_MDP5_DISP_INTF_SEL); 461 intf_sel = mdp5_read(mdp5_kms, REG_MDP5_DISP_INTF_SEL);
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
index a11f1b80c488..9f01a4f21af2 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
@@ -216,17 +216,7 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
216 goto fail; 216 goto fail;
217 } 217 }
218 218
219 /* NOTE: the vsync and error irq's are actually associated with 219 encoder->possible_crtcs = (1 << priv->num_crtcs) - 1;;
220 * the INTF/encoder.. the easiest way to deal with this (ie. what
221 * we do now) is assume a fixed relationship between crtc's and
222 * encoders. I'm not sure if there is ever a need to more freely
223 * assign crtcs to encoders, but if there is then we need to take
224 * care of error and vblank irq's that the crtc has registered,
225 * and also update user-requested vblank_mask.
226 */
227 encoder->possible_crtcs = BIT(0);
228 mdp5_crtc_set_intf(priv->crtcs[0], 3, INTF_HDMI);
229
230 priv->encoders[priv->num_encoders++] = encoder; 220 priv->encoders[priv->num_encoders++] = encoder;
231 221
232 /* Construct bridge/connector for HDMI: */ 222 /* Construct bridge/connector for HDMI: */
diff --git a/drivers/gpu/drm/msm/mdp/mdp_kms.c b/drivers/gpu/drm/msm/mdp/mdp_kms.c
index 03455b64a245..2a731722d840 100644
--- a/drivers/gpu/drm/msm/mdp/mdp_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp_kms.c
@@ -42,7 +42,10 @@ static void update_irq(struct mdp_kms *mdp_kms)
42 mdp_kms->funcs->set_irqmask(mdp_kms, irqmask); 42 mdp_kms->funcs->set_irqmask(mdp_kms, irqmask);
43} 43}
44 44
45static void update_irq_unlocked(struct mdp_kms *mdp_kms) 45/* if an mdp_irq's irqmask has changed, such as when mdp5 crtc<->encoder
46 * link changes, this must be called to figure out the new global irqmask
47 */
48void mdp_irq_update(struct mdp_kms *mdp_kms)
46{ 49{
47 unsigned long flags; 50 unsigned long flags;
48 spin_lock_irqsave(&list_lock, flags); 51 spin_lock_irqsave(&list_lock, flags);
@@ -122,7 +125,7 @@ void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq)
122 spin_unlock_irqrestore(&list_lock, flags); 125 spin_unlock_irqrestore(&list_lock, flags);
123 126
124 if (needs_update) 127 if (needs_update)
125 update_irq_unlocked(mdp_kms); 128 mdp_irq_update(mdp_kms);
126} 129}
127 130
128void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq) 131void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq)
@@ -141,5 +144,5 @@ void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq)
141 spin_unlock_irqrestore(&list_lock, flags); 144 spin_unlock_irqrestore(&list_lock, flags);
142 145
143 if (needs_update) 146 if (needs_update)
144 update_irq_unlocked(mdp_kms); 147 mdp_irq_update(mdp_kms);
145} 148}
diff --git a/drivers/gpu/drm/msm/mdp/mdp_kms.h b/drivers/gpu/drm/msm/mdp/mdp_kms.h
index 99557b5ad4fd..b268ce95d394 100644
--- a/drivers/gpu/drm/msm/mdp/mdp_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp_kms.h
@@ -75,7 +75,7 @@ void mdp_update_vblank_mask(struct mdp_kms *mdp_kms, uint32_t mask, bool enable)
75void mdp_irq_wait(struct mdp_kms *mdp_kms, uint32_t irqmask); 75void mdp_irq_wait(struct mdp_kms *mdp_kms, uint32_t irqmask);
76void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq); 76void mdp_irq_register(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
77void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq); 77void mdp_irq_unregister(struct mdp_kms *mdp_kms, struct mdp_irq *irq);
78 78void mdp_irq_update(struct mdp_kms *mdp_kms);
79 79
80/* 80/*
81 * pixel format helpers: 81 * pixel format helpers:
diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
index f0de412e13dc..191968256c58 100644
--- a/drivers/gpu/drm/msm/msm_atomic.c
+++ b/drivers/gpu/drm/msm/msm_atomic.c
@@ -23,10 +23,41 @@ struct msm_commit {
23 struct drm_atomic_state *state; 23 struct drm_atomic_state *state;
24 uint32_t fence; 24 uint32_t fence;
25 struct msm_fence_cb fence_cb; 25 struct msm_fence_cb fence_cb;
26 uint32_t crtc_mask;
26}; 27};
27 28
28static void fence_cb(struct msm_fence_cb *cb); 29static void fence_cb(struct msm_fence_cb *cb);
29 30
31/* block until specified crtcs are no longer pending update, and
32 * atomically mark them as pending update
33 */
34static int start_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
35{
36 int ret;
37
38 spin_lock(&priv->pending_crtcs_event.lock);
39 ret = wait_event_interruptible_locked(priv->pending_crtcs_event,
40 !(priv->pending_crtcs & crtc_mask));
41 if (ret == 0) {
42 DBG("start: %08x", crtc_mask);
43 priv->pending_crtcs |= crtc_mask;
44 }
45 spin_unlock(&priv->pending_crtcs_event.lock);
46
47 return ret;
48}
49
50/* clear specified crtcs (no longer pending update)
51 */
52static void end_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
53{
54 spin_lock(&priv->pending_crtcs_event.lock);
55 DBG("end: %08x", crtc_mask);
56 priv->pending_crtcs &= ~crtc_mask;
57 wake_up_all_locked(&priv->pending_crtcs_event);
58 spin_unlock(&priv->pending_crtcs_event.lock);
59}
60
30static struct msm_commit *new_commit(struct drm_atomic_state *state) 61static struct msm_commit *new_commit(struct drm_atomic_state *state)
31{ 62{
32 struct msm_commit *c = kzalloc(sizeof(*c), GFP_KERNEL); 63 struct msm_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
@@ -58,12 +89,27 @@ static void complete_commit(struct msm_commit *c)
58 89
59 drm_atomic_helper_commit_post_planes(dev, state); 90 drm_atomic_helper_commit_post_planes(dev, state);
60 91
92 /* NOTE: _wait_for_vblanks() only waits for vblank on
93 * enabled CRTCs. So we end up faulting when disabling
94 * due to (potentially) unref'ing the outgoing fb's
95 * before the vblank when the disable has latched.
96 *
97 * But if it did wait on disabled (or newly disabled)
98 * CRTCs, that would be racy (ie. we could have missed
99 * the irq. We need some way to poll for pipe shut
100 * down. Or just live with occasionally hitting the
101 * timeout in the CRTC disable path (which really should
102 * not be critical path)
103 */
104
61 drm_atomic_helper_wait_for_vblanks(dev, state); 105 drm_atomic_helper_wait_for_vblanks(dev, state);
62 106
63 drm_atomic_helper_cleanup_planes(dev, state); 107 drm_atomic_helper_cleanup_planes(dev, state);
64 108
65 drm_atomic_state_free(state); 109 drm_atomic_state_free(state);
66 110
111 end_atomic(dev->dev_private, c->crtc_mask);
112
67 kfree(c); 113 kfree(c);
68} 114}
69 115
@@ -97,8 +143,9 @@ static void add_fb(struct msm_commit *c, struct drm_framebuffer *fb)
97int msm_atomic_commit(struct drm_device *dev, 143int msm_atomic_commit(struct drm_device *dev,
98 struct drm_atomic_state *state, bool async) 144 struct drm_atomic_state *state, bool async)
99{ 145{
100 struct msm_commit *c;
101 int nplanes = dev->mode_config.num_total_plane; 146 int nplanes = dev->mode_config.num_total_plane;
147 int ncrtcs = dev->mode_config.num_crtc;
148 struct msm_commit *c;
102 int i, ret; 149 int i, ret;
103 150
104 ret = drm_atomic_helper_prepare_planes(dev, state); 151 ret = drm_atomic_helper_prepare_planes(dev, state);
@@ -106,6 +153,18 @@ int msm_atomic_commit(struct drm_device *dev,
106 return ret; 153 return ret;
107 154
108 c = new_commit(state); 155 c = new_commit(state);
156 if (!c)
157 return -ENOMEM;
158
159 /*
160 * Figure out what crtcs we have:
161 */
162 for (i = 0; i < ncrtcs; i++) {
163 struct drm_crtc *crtc = state->crtcs[i];
164 if (!crtc)
165 continue;
166 c->crtc_mask |= (1 << drm_crtc_index(crtc));
167 }
109 168
110 /* 169 /*
111 * Figure out what fence to wait for: 170 * Figure out what fence to wait for:
@@ -122,6 +181,14 @@ int msm_atomic_commit(struct drm_device *dev,
122 } 181 }
123 182
124 /* 183 /*
184 * Wait for pending updates on any of the same crtc's and then
185 * mark our set of crtc's as busy:
186 */
187 ret = start_atomic(dev->dev_private, c->crtc_mask);
188 if (ret)
189 return ret;
190
191 /*
125 * This is the point of no return - everything below never fails except 192 * This is the point of no return - everything below never fails except
126 * when the hw goes bonghits. Which means we can commit the new state on 193 * when the hw goes bonghits. Which means we can commit the new state on
127 * the software side now. 194 * the software side now.
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index c795217e1bfc..9a61546a0b05 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -193,6 +193,7 @@ static int msm_load(struct drm_device *dev, unsigned long flags)
193 193
194 priv->wq = alloc_ordered_workqueue("msm", 0); 194 priv->wq = alloc_ordered_workqueue("msm", 0);
195 init_waitqueue_head(&priv->fence_event); 195 init_waitqueue_head(&priv->fence_event);
196 init_waitqueue_head(&priv->pending_crtcs_event);
196 197
197 INIT_LIST_HEAD(&priv->inactive_list); 198 INIT_LIST_HEAD(&priv->inactive_list);
198 INIT_LIST_HEAD(&priv->fence_cbs); 199 INIT_LIST_HEAD(&priv->fence_cbs);
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 136303818436..b69ef2d5a26c 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -96,6 +96,10 @@ struct msm_drm_private {
96 /* callbacks deferred until bo is inactive: */ 96 /* callbacks deferred until bo is inactive: */
97 struct list_head fence_cbs; 97 struct list_head fence_cbs;
98 98
99 /* crtcs pending async atomic updates: */
100 uint32_t pending_crtcs;
101 wait_queue_head_t pending_crtcs_event;
102
99 /* registered MMUs: */ 103 /* registered MMUs: */
100 unsigned int num_mmus; 104 unsigned int num_mmus;
101 struct msm_mmu *mmus[NUM_DOMAINS]; 105 struct msm_mmu *mmus[NUM_DOMAINS];
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 94d55e526b4e..1f3af13ccede 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -190,8 +190,7 @@ fail_unlock:
190fail: 190fail:
191 191
192 if (ret) { 192 if (ret) {
193 if (fbi) 193 framebuffer_release(fbi);
194 framebuffer_release(fbi);
195 if (fb) { 194 if (fb) {
196 drm_framebuffer_unregister_private(fb); 195 drm_framebuffer_unregister_private(fb);
197 drm_framebuffer_remove(fb); 196 drm_framebuffer_remove(fb);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 4a6f0e49d5b5..49dea4fb55ac 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -535,8 +535,7 @@ void msm_gem_free_object(struct drm_gem_object *obj)
535 drm_free_large(msm_obj->pages); 535 drm_free_large(msm_obj->pages);
536 536
537 } else { 537 } else {
538 if (msm_obj->vaddr) 538 vunmap(msm_obj->vaddr);
539 vunmap(msm_obj->vaddr);
540 put_pages(obj); 539 put_pages(obj);
541 } 540 }
542 541
diff --git a/drivers/gpu/drm/nouveau/core/core/event.c b/drivers/gpu/drm/nouveau/core/core/event.c
index ff2b434b3db4..760947e380c9 100644
--- a/drivers/gpu/drm/nouveau/core/core/event.c
+++ b/drivers/gpu/drm/nouveau/core/core/event.c
@@ -26,7 +26,7 @@
26void 26void
27nvkm_event_put(struct nvkm_event *event, u32 types, int index) 27nvkm_event_put(struct nvkm_event *event, u32 types, int index)
28{ 28{
29 BUG_ON(!spin_is_locked(&event->refs_lock)); 29 assert_spin_locked(&event->refs_lock);
30 while (types) { 30 while (types) {
31 int type = __ffs(types); types &= ~(1 << type); 31 int type = __ffs(types); types &= ~(1 << type);
32 if (--event->refs[index * event->types_nr + type] == 0) { 32 if (--event->refs[index * event->types_nr + type] == 0) {
@@ -39,7 +39,7 @@ nvkm_event_put(struct nvkm_event *event, u32 types, int index)
39void 39void
40nvkm_event_get(struct nvkm_event *event, u32 types, int index) 40nvkm_event_get(struct nvkm_event *event, u32 types, int index)
41{ 41{
42 BUG_ON(!spin_is_locked(&event->refs_lock)); 42 assert_spin_locked(&event->refs_lock);
43 while (types) { 43 while (types) {
44 int type = __ffs(types); types &= ~(1 << type); 44 int type = __ffs(types); types &= ~(1 << type);
45 if (++event->refs[index * event->types_nr + type] == 1) { 45 if (++event->refs[index * event->types_nr + type] == 1) {
diff --git a/drivers/gpu/drm/nouveau/core/core/notify.c b/drivers/gpu/drm/nouveau/core/core/notify.c
index d1bcde55e9d7..839a32577680 100644
--- a/drivers/gpu/drm/nouveau/core/core/notify.c
+++ b/drivers/gpu/drm/nouveau/core/core/notify.c
@@ -98,7 +98,7 @@ nvkm_notify_send(struct nvkm_notify *notify, void *data, u32 size)
98 struct nvkm_event *event = notify->event; 98 struct nvkm_event *event = notify->event;
99 unsigned long flags; 99 unsigned long flags;
100 100
101 BUG_ON(!spin_is_locked(&event->list_lock)); 101 assert_spin_locked(&event->list_lock);
102 BUG_ON(size != notify->size); 102 BUG_ON(size != notify->size);
103 103
104 spin_lock_irqsave(&event->refs_lock, flags); 104 spin_lock_irqsave(&event->refs_lock, flags);
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nve0.c b/drivers/gpu/drm/nouveau/core/engine/device/nve0.c
index 674da1f095b2..732922690653 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/nve0.c
@@ -249,6 +249,39 @@ nve0_identify(struct nouveau_device *device)
249 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; 249 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
250 device->oclass[NVDEV_ENGINE_PERFMON] = &nvf0_perfmon_oclass; 250 device->oclass[NVDEV_ENGINE_PERFMON] = &nvf0_perfmon_oclass;
251 break; 251 break;
252 case 0x106:
253 device->cname = "GK208B";
254 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
255 device->oclass[NVDEV_SUBDEV_GPIO ] = nve0_gpio_oclass;
256 device->oclass[NVDEV_SUBDEV_I2C ] = nve0_i2c_oclass;
257 device->oclass[NVDEV_SUBDEV_FUSE ] = &gf100_fuse_oclass;
258 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nve0_clock_oclass;
259 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
260 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
261 device->oclass[NVDEV_SUBDEV_DEVINIT] = nvc0_devinit_oclass;
262 device->oclass[NVDEV_SUBDEV_MC ] = gk20a_mc_oclass;
263 device->oclass[NVDEV_SUBDEV_BUS ] = nvc0_bus_oclass;
264 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
265 device->oclass[NVDEV_SUBDEV_FB ] = nve0_fb_oclass;
266 device->oclass[NVDEV_SUBDEV_LTC ] = gk104_ltc_oclass;
267 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass;
268 device->oclass[NVDEV_SUBDEV_INSTMEM] = nv50_instmem_oclass;
269 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass;
270 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass;
271 device->oclass[NVDEV_SUBDEV_PWR ] = nv108_pwr_oclass;
272 device->oclass[NVDEV_SUBDEV_VOLT ] = &nv40_volt_oclass;
273 device->oclass[NVDEV_ENGINE_DMAOBJ ] = nvd0_dmaeng_oclass;
274 device->oclass[NVDEV_ENGINE_FIFO ] = nv108_fifo_oclass;
275 device->oclass[NVDEV_ENGINE_SW ] = nvc0_software_oclass;
276 device->oclass[NVDEV_ENGINE_GR ] = nv108_graph_oclass;
277 device->oclass[NVDEV_ENGINE_DISP ] = nvf0_disp_oclass;
278 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass;
279 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass;
280 device->oclass[NVDEV_ENGINE_COPY2 ] = &nve0_copy2_oclass;
281 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass;
282 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass;
283 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
284 break;
252 case 0x108: 285 case 0x108:
253 device->cname = "GK208"; 286 device->cname = "GK208";
254 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 287 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c b/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c
index 5e58bba0dd5c..a7a890fad1e5 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/shadowramin.c
@@ -44,8 +44,10 @@ static void
44pramin_fini(void *data) 44pramin_fini(void *data)
45{ 45{
46 struct priv *priv = data; 46 struct priv *priv = data;
47 nv_wr32(priv->bios, 0x001700, priv->bar0); 47 if (priv) {
48 kfree(priv); 48 nv_wr32(priv->bios, 0x001700, priv->bar0);
49 kfree(priv);
50 }
49} 51}
50 52
51static void * 53static void *
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c
index 00f2ca7e44a5..033a8e999497 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnvaa.c
@@ -24,34 +24,71 @@
24 24
25#include "nv50.h" 25#include "nv50.h"
26 26
27struct nvaa_ram_priv {
28 struct nouveau_ram base;
29 u64 poller_base;
30};
31
27static int 32static int
28nvaa_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 33nvaa_ram_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
29 struct nouveau_oclass *oclass, void *data, u32 datasize, 34 struct nouveau_oclass *oclass, void *data, u32 datasize,
30 struct nouveau_object **pobject) 35 struct nouveau_object **pobject)
31{ 36{
32 const u32 rsvd_head = ( 256 * 1024) >> 12; /* vga memory */ 37 u32 rsvd_head = ( 256 * 1024); /* vga memory */
33 const u32 rsvd_tail = (1024 * 1024) >> 12; /* vbios etc */ 38 u32 rsvd_tail = (1024 * 1024); /* vbios etc */
34 struct nouveau_fb *pfb = nouveau_fb(parent); 39 struct nouveau_fb *pfb = nouveau_fb(parent);
35 struct nouveau_ram *ram; 40 struct nvaa_ram_priv *priv;
36 int ret; 41 int ret;
37 42
38 ret = nouveau_ram_create(parent, engine, oclass, &ram); 43 ret = nouveau_ram_create(parent, engine, oclass, &priv);
39 *pobject = nv_object(ram); 44 *pobject = nv_object(priv);
40 if (ret) 45 if (ret)
41 return ret; 46 return ret;
42 47
43 ram->size = nv_rd32(pfb, 0x10020c); 48 priv->base.type = NV_MEM_TYPE_STOLEN;
44 ram->size = (ram->size & 0xffffff00) | ((ram->size & 0x000000ff) << 32); 49 priv->base.stolen = (u64)nv_rd32(pfb, 0x100e10) << 12;
50 priv->base.size = (u64)nv_rd32(pfb, 0x100e14) << 12;
45 51
46 ret = nouveau_mm_init(&pfb->vram, rsvd_head, (ram->size >> 12) - 52 rsvd_tail += 0x1000;
47 (rsvd_head + rsvd_tail), 1); 53 priv->poller_base = priv->base.size - rsvd_tail;
54
55 ret = nouveau_mm_init(&pfb->vram, rsvd_head >> 12,
56 (priv->base.size - (rsvd_head + rsvd_tail)) >> 12,
57 1);
48 if (ret) 58 if (ret)
49 return ret; 59 return ret;
50 60
51 ram->type = NV_MEM_TYPE_STOLEN; 61 priv->base.get = nv50_ram_get;
52 ram->stolen = (u64)nv_rd32(pfb, 0x100e10) << 12; 62 priv->base.put = nv50_ram_put;
53 ram->get = nv50_ram_get; 63 return 0;
54 ram->put = nv50_ram_put; 64}
65
66static int
67nvaa_ram_init(struct nouveau_object *object)
68{
69 struct nouveau_fb *pfb = nouveau_fb(object);
70 struct nvaa_ram_priv *priv = (void *)object;
71 int ret;
72 u64 dniso, hostnb, flush;
73
74 ret = nouveau_ram_init(&priv->base);
75 if (ret)
76 return ret;
77
78 dniso = ((priv->base.size - (priv->poller_base + 0x00)) >> 5) - 1;
79 hostnb = ((priv->base.size - (priv->poller_base + 0x20)) >> 5) - 1;
80 flush = ((priv->base.size - (priv->poller_base + 0x40)) >> 5) - 1;
81
82 /* Enable NISO poller for various clients and set their associated
83 * read address, only for MCP77/78 and MCP79/7A. (fd#25701)
84 */
85 nv_wr32(pfb, 0x100c18, dniso);
86 nv_mask(pfb, 0x100c14, 0x00000000, 0x00000001);
87 nv_wr32(pfb, 0x100c1c, hostnb);
88 nv_mask(pfb, 0x100c14, 0x00000000, 0x00000002);
89 nv_wr32(pfb, 0x100c24, flush);
90 nv_mask(pfb, 0x100c14, 0x00000000, 0x00010000);
91
55 return 0; 92 return 0;
56} 93}
57 94
@@ -60,7 +97,7 @@ nvaa_ram_oclass = {
60 .ofuncs = &(struct nouveau_ofuncs) { 97 .ofuncs = &(struct nouveau_ofuncs) {
61 .ctor = nvaa_ram_ctor, 98 .ctor = nvaa_ram_ctor,
62 .dtor = _nouveau_ram_dtor, 99 .dtor = _nouveau_ram_dtor,
63 .init = _nouveau_ram_init, 100 .init = nvaa_ram_init,
64 .fini = _nouveau_ram_fini, 101 .fini = _nouveau_ram_fini,
65 }, 102 },
66}; 103};
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c
index a75c35ccf25c..165401c4045c 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c
@@ -24,13 +24,6 @@
24 24
25#include "nv04.h" 25#include "nv04.h"
26 26
27static void
28nv4c_mc_msi_rearm(struct nouveau_mc *pmc)
29{
30 struct nv04_mc_priv *priv = (void *)pmc;
31 nv_wr08(priv, 0x088050, 0xff);
32}
33
34struct nouveau_oclass * 27struct nouveau_oclass *
35nv4c_mc_oclass = &(struct nouveau_mc_oclass) { 28nv4c_mc_oclass = &(struct nouveau_mc_oclass) {
36 .base.handle = NV_SUBDEV(MC, 0x4c), 29 .base.handle = NV_SUBDEV(MC, 0x4c),
@@ -41,5 +34,4 @@ nv4c_mc_oclass = &(struct nouveau_mc_oclass) {
41 .fini = _nouveau_mc_fini, 34 .fini = _nouveau_mc_fini,
42 }, 35 },
43 .intr = nv04_mc_intr, 36 .intr = nv04_mc_intr,
44 .msi_rearm = nv4c_mc_msi_rearm,
45}.base; 37}.base;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 21ec561edc99..bba2960d3dfb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1572,8 +1572,10 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
1572 * so use the DMA API for them. 1572 * so use the DMA API for them.
1573 */ 1573 */
1574 if (!nv_device_is_cpu_coherent(device) && 1574 if (!nv_device_is_cpu_coherent(device) &&
1575 ttm->caching_state == tt_uncached) 1575 ttm->caching_state == tt_uncached) {
1576 ttm_dma_unpopulate(ttm_dma, dev->dev); 1576 ttm_dma_unpopulate(ttm_dma, dev->dev);
1577 return;
1578 }
1577 1579
1578#if __OS_HAS_AGP 1580#if __OS_HAS_AGP
1579 if (drm->agp.stat == ENABLED) { 1581 if (drm->agp.stat == ENABLED) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 5d93902a91ab..f8042433752b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -876,7 +876,6 @@ nouveau_display_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
876 if (ret) 876 if (ret)
877 return ret; 877 return ret;
878 878
879 bo->gem.dumb = true;
880 ret = drm_gem_handle_create(file_priv, &bo->gem, &args->handle); 879 ret = drm_gem_handle_create(file_priv, &bo->gem, &args->handle);
881 drm_gem_object_unreference_unlocked(&bo->gem); 880 drm_gem_object_unreference_unlocked(&bo->gem);
882 return ret; 881 return ret;
@@ -892,14 +891,6 @@ nouveau_display_dumb_map_offset(struct drm_file *file_priv,
892 gem = drm_gem_object_lookup(dev, file_priv, handle); 891 gem = drm_gem_object_lookup(dev, file_priv, handle);
893 if (gem) { 892 if (gem) {
894 struct nouveau_bo *bo = nouveau_gem_object(gem); 893 struct nouveau_bo *bo = nouveau_gem_object(gem);
895
896 /*
897 * We don't allow dumb mmaps on objects created using another
898 * interface.
899 */
900 WARN_ONCE(!(gem->dumb || gem->import_attach),
901 "Illegal dumb map of accelerated buffer.\n");
902
903 *poffset = drm_vma_node_offset_addr(&bo->bo.vma_node); 894 *poffset = drm_vma_node_offset_addr(&bo->bo.vma_node);
904 drm_gem_object_unreference_unlocked(gem); 895 drm_gem_object_unreference_unlocked(gem);
905 return 0; 896 return 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 28d51a22a4bf..bf0f9e21d714 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -36,7 +36,14 @@ void
36nouveau_gem_object_del(struct drm_gem_object *gem) 36nouveau_gem_object_del(struct drm_gem_object *gem)
37{ 37{
38 struct nouveau_bo *nvbo = nouveau_gem_object(gem); 38 struct nouveau_bo *nvbo = nouveau_gem_object(gem);
39 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
39 struct ttm_buffer_object *bo = &nvbo->bo; 40 struct ttm_buffer_object *bo = &nvbo->bo;
41 struct device *dev = drm->dev->dev;
42 int ret;
43
44 ret = pm_runtime_get_sync(dev);
45 if (WARN_ON(ret < 0 && ret != -EACCES))
46 return;
40 47
41 if (gem->import_attach) 48 if (gem->import_attach)
42 drm_prime_gem_destroy(gem, nvbo->bo.sg); 49 drm_prime_gem_destroy(gem, nvbo->bo.sg);
@@ -46,6 +53,9 @@ nouveau_gem_object_del(struct drm_gem_object *gem)
46 /* reset filp so nouveau_bo_del_ttm() can test for it */ 53 /* reset filp so nouveau_bo_del_ttm() can test for it */
47 gem->filp = NULL; 54 gem->filp = NULL;
48 ttm_bo_unref(&bo); 55 ttm_bo_unref(&bo);
56
57 pm_runtime_mark_last_busy(dev);
58 pm_runtime_put_autosuspend(dev);
49} 59}
50 60
51int 61int
@@ -53,7 +63,9 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)
53{ 63{
54 struct nouveau_cli *cli = nouveau_cli(file_priv); 64 struct nouveau_cli *cli = nouveau_cli(file_priv);
55 struct nouveau_bo *nvbo = nouveau_gem_object(gem); 65 struct nouveau_bo *nvbo = nouveau_gem_object(gem);
66 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
56 struct nouveau_vma *vma; 67 struct nouveau_vma *vma;
68 struct device *dev = drm->dev->dev;
57 int ret; 69 int ret;
58 70
59 if (!cli->vm) 71 if (!cli->vm)
@@ -71,11 +83,16 @@ nouveau_gem_object_open(struct drm_gem_object *gem, struct drm_file *file_priv)
71 goto out; 83 goto out;
72 } 84 }
73 85
86 ret = pm_runtime_get_sync(dev);
87 if (ret < 0 && ret != -EACCES)
88 goto out;
89
74 ret = nouveau_bo_vma_add(nvbo, cli->vm, vma); 90 ret = nouveau_bo_vma_add(nvbo, cli->vm, vma);
75 if (ret) { 91 if (ret)
76 kfree(vma); 92 kfree(vma);
77 goto out; 93
78 } 94 pm_runtime_mark_last_busy(dev);
95 pm_runtime_put_autosuspend(dev);
79 } else { 96 } else {
80 vma->refcount++; 97 vma->refcount++;
81 } 98 }
@@ -129,6 +146,8 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
129{ 146{
130 struct nouveau_cli *cli = nouveau_cli(file_priv); 147 struct nouveau_cli *cli = nouveau_cli(file_priv);
131 struct nouveau_bo *nvbo = nouveau_gem_object(gem); 148 struct nouveau_bo *nvbo = nouveau_gem_object(gem);
149 struct nouveau_drm *drm = nouveau_bdev(nvbo->bo.bdev);
150 struct device *dev = drm->dev->dev;
132 struct nouveau_vma *vma; 151 struct nouveau_vma *vma;
133 int ret; 152 int ret;
134 153
@@ -141,8 +160,14 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct drm_file *file_priv)
141 160
142 vma = nouveau_bo_vma_find(nvbo, cli->vm); 161 vma = nouveau_bo_vma_find(nvbo, cli->vm);
143 if (vma) { 162 if (vma) {
144 if (--vma->refcount == 0) 163 if (--vma->refcount == 0) {
145 nouveau_gem_object_unmap(nvbo, vma); 164 ret = pm_runtime_get_sync(dev);
165 if (!WARN_ON(ret < 0 && ret != -EACCES)) {
166 nouveau_gem_object_unmap(nvbo, vma);
167 pm_runtime_mark_last_busy(dev);
168 pm_runtime_put_autosuspend(dev);
169 }
170 }
146 } 171 }
147 ttm_bo_unreserve(&nvbo->bo); 172 ttm_bo_unreserve(&nvbo->bo);
148} 173}
@@ -444,9 +469,6 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
444 list_for_each_entry(nvbo, list, entry) { 469 list_for_each_entry(nvbo, list, entry) {
445 struct drm_nouveau_gem_pushbuf_bo *b = &pbbo[nvbo->pbbo_index]; 470 struct drm_nouveau_gem_pushbuf_bo *b = &pbbo[nvbo->pbbo_index];
446 471
447 WARN_ONCE(nvbo->gem.dumb,
448 "GPU use of dumb buffer is illegal.\n");
449
450 ret = nouveau_gem_set_domain(&nvbo->gem, b->read_domains, 472 ret = nouveau_gem_set_domain(&nvbo->gem, b->read_domains,
451 b->write_domains, 473 b->write_domains,
452 b->valid_domains); 474 b->valid_domains);
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
index 753a6def61e7..3d1cfcb96b6b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
@@ -28,6 +28,7 @@
28#include "nouveau_ttm.h" 28#include "nouveau_ttm.h"
29#include "nouveau_gem.h" 29#include "nouveau_gem.h"
30 30
31#include "drm_legacy.h"
31static int 32static int
32nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long psize) 33nouveau_vram_manager_init(struct ttm_mem_type_manager *man, unsigned long psize)
33{ 34{
@@ -281,7 +282,7 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma)
281 struct nouveau_drm *drm = nouveau_drm(file_priv->minor->dev); 282 struct nouveau_drm *drm = nouveau_drm(file_priv->minor->dev);
282 283
283 if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET)) 284 if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET))
284 return -EINVAL; 285 return drm_legacy_mmap(filp, vma);
285 286
286 return ttm_bo_mmap(filp, vma, &drm->ttm.bdev); 287 return ttm_bo_mmap(filp, vma, &drm->ttm.bdev);
287} 288}
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index d59ec491dbb9..ed644a4f6f57 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1851,10 +1851,9 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1851 return pll; 1851 return pll;
1852 } 1852 }
1853 /* otherwise, pick one of the plls */ 1853 /* otherwise, pick one of the plls */
1854 if ((rdev->family == CHIP_KAVERI) || 1854 if ((rdev->family == CHIP_KABINI) ||
1855 (rdev->family == CHIP_KABINI) ||
1856 (rdev->family == CHIP_MULLINS)) { 1855 (rdev->family == CHIP_MULLINS)) {
1857 /* KB/KV/ML has PPLL1 and PPLL2 */ 1856 /* KB/ML has PPLL1 and PPLL2 */
1858 pll_in_use = radeon_get_pll_use_mask(crtc); 1857 pll_in_use = radeon_get_pll_use_mask(crtc);
1859 if (!(pll_in_use & (1 << ATOM_PPLL2))) 1858 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1860 return ATOM_PPLL2; 1859 return ATOM_PPLL2;
@@ -1863,7 +1862,7 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1863 DRM_ERROR("unable to allocate a PPLL\n"); 1862 DRM_ERROR("unable to allocate a PPLL\n");
1864 return ATOM_PPLL_INVALID; 1863 return ATOM_PPLL_INVALID;
1865 } else { 1864 } else {
1866 /* CI has PPLL0, PPLL1, and PPLL2 */ 1865 /* CI/KV has PPLL0, PPLL1, and PPLL2 */
1867 pll_in_use = radeon_get_pll_use_mask(crtc); 1866 pll_in_use = radeon_get_pll_use_mask(crtc);
1868 if (!(pll_in_use & (1 << ATOM_PPLL2))) 1867 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1869 return ATOM_PPLL2; 1868 return ATOM_PPLL2;
@@ -2155,6 +2154,7 @@ static void atombios_crtc_disable(struct drm_crtc *crtc)
2155 case ATOM_PPLL0: 2154 case ATOM_PPLL0:
2156 /* disable the ppll */ 2155 /* disable the ppll */
2157 if ((rdev->family == CHIP_ARUBA) || 2156 if ((rdev->family == CHIP_ARUBA) ||
2157 (rdev->family == CHIP_KAVERI) ||
2158 (rdev->family == CHIP_BONAIRE) || 2158 (rdev->family == CHIP_BONAIRE) ||
2159 (rdev->family == CHIP_HAWAII)) 2159 (rdev->family == CHIP_HAWAII))
2160 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id, 2160 atombios_crtc_program_pll(crtc, radeon_crtc->crtc_id, radeon_crtc->pll_id,
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 11ba9d21b89b..db42a670f995 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -492,6 +492,10 @@ int radeon_dp_mode_valid_helper(struct drm_connector *connector,
492 struct radeon_connector_atom_dig *dig_connector; 492 struct radeon_connector_atom_dig *dig_connector;
493 int dp_clock; 493 int dp_clock;
494 494
495 if ((mode->clock > 340000) &&
496 (!radeon_connector_is_dp12_capable(connector)))
497 return MODE_CLOCK_HIGH;
498
495 if (!radeon_connector->con_priv) 499 if (!radeon_connector->con_priv)
496 return MODE_CLOCK_HIGH; 500 return MODE_CLOCK_HIGH;
497 dig_connector = radeon_connector->con_priv; 501 dig_connector = radeon_connector->con_priv;
diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h
index ba85986febea..03003f8a6de6 100644
--- a/drivers/gpu/drm/radeon/cikd.h
+++ b/drivers/gpu/drm/radeon/cikd.h
@@ -2156,4 +2156,6 @@
2156#define ATC_VM_APERTURE1_HIGH_ADDR 0x330Cu 2156#define ATC_VM_APERTURE1_HIGH_ADDR 0x330Cu
2157#define ATC_VM_APERTURE1_LOW_ADDR 0x3304u 2157#define ATC_VM_APERTURE1_LOW_ADDR 0x3304u
2158 2158
2159#define IH_VMID_0_LUT 0x3D40u
2160
2159#endif 2161#endif
diff --git a/drivers/gpu/drm/radeon/dce3_1_afmt.c b/drivers/gpu/drm/radeon/dce3_1_afmt.c
index 2fe8cfc966d9..bafdf92a5732 100644
--- a/drivers/gpu/drm/radeon/dce3_1_afmt.c
+++ b/drivers/gpu/drm/radeon/dce3_1_afmt.c
@@ -103,7 +103,7 @@ static void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder)
103 } 103 }
104 104
105 sad_count = drm_edid_to_sad(radeon_connector->edid, &sads); 105 sad_count = drm_edid_to_sad(radeon_connector->edid, &sads);
106 if (sad_count < 0) { 106 if (sad_count <= 0) {
107 DRM_ERROR("Couldn't read SADs: %d\n", sad_count); 107 DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
108 return; 108 return;
109 } 109 }
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 9b42001295ba..e3e9c10cfba9 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2745,13 +2745,11 @@ int kv_dpm_init(struct radeon_device *rdev)
2745 pi->enable_auto_thermal_throttling = true; 2745 pi->enable_auto_thermal_throttling = true;
2746 pi->disable_nb_ps3_in_battery = false; 2746 pi->disable_nb_ps3_in_battery = false;
2747 if (radeon_bapm == -1) { 2747 if (radeon_bapm == -1) {
2748 /* There are stability issues reported on with 2748 /* only enable bapm on KB, ML by default */
2749 * bapm enabled on an asrock system. 2749 if (rdev->family == CHIP_KABINI || rdev->family == CHIP_MULLINS)
2750 */
2751 if (rdev->pdev->subsystem_vendor == 0x1849)
2752 pi->bapm_enable = false;
2753 else
2754 pi->bapm_enable = true; 2750 pi->bapm_enable = true;
2751 else
2752 pi->bapm_enable = false;
2755 } else if (radeon_bapm == 0) { 2753 } else if (radeon_bapm == 0) {
2756 pi->bapm_enable = false; 2754 pi->bapm_enable = false;
2757 } else { 2755 } else {
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index fe48f229043e..a46f73737994 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -394,10 +394,9 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
394 return r; 394 return r;
395} 395}
396 396
397static int radeon_mode_mmap(struct drm_file *filp, 397int radeon_mode_dumb_mmap(struct drm_file *filp,
398 struct drm_device *dev, 398 struct drm_device *dev,
399 uint32_t handle, bool dumb, 399 uint32_t handle, uint64_t *offset_p)
400 uint64_t *offset_p)
401{ 400{
402 struct drm_gem_object *gobj; 401 struct drm_gem_object *gobj;
403 struct radeon_bo *robj; 402 struct radeon_bo *robj;
@@ -406,14 +405,6 @@ static int radeon_mode_mmap(struct drm_file *filp,
406 if (gobj == NULL) { 405 if (gobj == NULL) {
407 return -ENOENT; 406 return -ENOENT;
408 } 407 }
409
410 /*
411 * We don't allow dumb mmaps on objects created using another
412 * interface.
413 */
414 WARN_ONCE(dumb && !(gobj->dumb || gobj->import_attach),
415 "Illegal dumb map of GPU buffer.\n");
416
417 robj = gem_to_radeon_bo(gobj); 408 robj = gem_to_radeon_bo(gobj);
418 if (radeon_ttm_tt_has_userptr(robj->tbo.ttm)) { 409 if (radeon_ttm_tt_has_userptr(robj->tbo.ttm)) {
419 drm_gem_object_unreference_unlocked(gobj); 410 drm_gem_object_unreference_unlocked(gobj);
@@ -424,20 +415,12 @@ static int radeon_mode_mmap(struct drm_file *filp,
424 return 0; 415 return 0;
425} 416}
426 417
427int radeon_mode_dumb_mmap(struct drm_file *filp,
428 struct drm_device *dev,
429 uint32_t handle, uint64_t *offset_p)
430{
431 return radeon_mode_mmap(filp, dev, handle, true, offset_p);
432}
433
434int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, 418int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
435 struct drm_file *filp) 419 struct drm_file *filp)
436{ 420{
437 struct drm_radeon_gem_mmap *args = data; 421 struct drm_radeon_gem_mmap *args = data;
438 422
439 return radeon_mode_mmap(filp, dev, args->handle, false, 423 return radeon_mode_dumb_mmap(filp, dev, args->handle, &args->addr_ptr);
440 &args->addr_ptr);
441} 424}
442 425
443int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, 426int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
@@ -763,7 +746,6 @@ int radeon_mode_dumb_create(struct drm_file *file_priv,
763 return -ENOMEM; 746 return -ENOMEM;
764 747
765 r = drm_gem_handle_create(file_priv, gobj, &handle); 748 r = drm_gem_handle_create(file_priv, gobj, &handle);
766 gobj->dumb = true;
767 /* drop reference from allocate - handle holds it now */ 749 /* drop reference from allocate - handle holds it now */
768 drm_gem_object_unreference_unlocked(gobj); 750 drm_gem_object_unreference_unlocked(gobj);
769 if (r) { 751 if (r) {
diff --git a/drivers/gpu/drm/radeon/radeon_kfd.c b/drivers/gpu/drm/radeon/radeon_kfd.c
index 065d02068ec3..8bf87f1203cc 100644
--- a/drivers/gpu/drm/radeon/radeon_kfd.c
+++ b/drivers/gpu/drm/radeon/radeon_kfd.c
@@ -28,6 +28,8 @@
28#include "cikd.h" 28#include "cikd.h"
29#include "cik_reg.h" 29#include "cik_reg.h"
30#include "radeon_kfd.h" 30#include "radeon_kfd.h"
31#include "radeon_ucode.h"
32#include <linux/firmware.h>
31 33
32#define CIK_PIPE_PER_MEC (4) 34#define CIK_PIPE_PER_MEC (4)
33 35
@@ -49,6 +51,7 @@ static uint64_t get_vmem_size(struct kgd_dev *kgd);
49static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd); 51static uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
50 52
51static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd); 53static uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
54static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
52 55
53/* 56/*
54 * Register access functions 57 * Register access functions
@@ -69,7 +72,7 @@ static int kgd_init_pipeline(struct kgd_dev *kgd, uint32_t pipe_id,
69static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id, 72static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
70 uint32_t queue_id, uint32_t __user *wptr); 73 uint32_t queue_id, uint32_t __user *wptr);
71 74
72static bool kgd_hqd_is_occupies(struct kgd_dev *kgd, uint64_t queue_address, 75static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address,
73 uint32_t pipe_id, uint32_t queue_id); 76 uint32_t pipe_id, uint32_t queue_id);
74 77
75static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type, 78static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
@@ -89,14 +92,16 @@ static const struct kfd2kgd_calls kfd2kgd = {
89 .init_memory = kgd_init_memory, 92 .init_memory = kgd_init_memory,
90 .init_pipeline = kgd_init_pipeline, 93 .init_pipeline = kgd_init_pipeline,
91 .hqd_load = kgd_hqd_load, 94 .hqd_load = kgd_hqd_load,
92 .hqd_is_occupies = kgd_hqd_is_occupies, 95 .hqd_is_occupied = kgd_hqd_is_occupied,
93 .hqd_destroy = kgd_hqd_destroy, 96 .hqd_destroy = kgd_hqd_destroy,
97 .get_fw_version = get_fw_version
94}; 98};
95 99
96static const struct kgd2kfd_calls *kgd2kfd; 100static const struct kgd2kfd_calls *kgd2kfd;
97 101
98bool radeon_kfd_init(void) 102bool radeon_kfd_init(void)
99{ 103{
104#if defined(CONFIG_HSA_AMD_MODULE)
100 bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*, 105 bool (*kgd2kfd_init_p)(unsigned, const struct kfd2kgd_calls*,
101 const struct kgd2kfd_calls**); 106 const struct kgd2kfd_calls**);
102 107
@@ -113,6 +118,17 @@ bool radeon_kfd_init(void)
113 } 118 }
114 119
115 return true; 120 return true;
121#elif defined(CONFIG_HSA_AMD)
122 if (!kgd2kfd_init(KFD_INTERFACE_VERSION, &kfd2kgd, &kgd2kfd)) {
123 kgd2kfd = NULL;
124
125 return false;
126 }
127
128 return true;
129#else
130 return false;
131#endif
116} 132}
117 133
118void radeon_kfd_fini(void) 134void radeon_kfd_fini(void)
@@ -374,6 +390,10 @@ static int kgd_set_pasid_vmid_mapping(struct kgd_dev *kgd, unsigned int pasid,
374 cpu_relax(); 390 cpu_relax();
375 write_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_STATUS, 1U << vmid); 391 write_register(kgd, ATC_VMID_PASID_MAPPING_UPDATE_STATUS, 1U << vmid);
376 392
393 /* Mapping vmid to pasid also for IH block */
394 write_register(kgd, IH_VMID_0_LUT + vmid * sizeof(uint32_t),
395 pasid_mapping);
396
377 return 0; 397 return 0;
378} 398}
379 399
@@ -513,7 +533,7 @@ static int kgd_hqd_load(struct kgd_dev *kgd, void *mqd, uint32_t pipe_id,
513 return 0; 533 return 0;
514} 534}
515 535
516static bool kgd_hqd_is_occupies(struct kgd_dev *kgd, uint64_t queue_address, 536static bool kgd_hqd_is_occupied(struct kgd_dev *kgd, uint64_t queue_address,
517 uint32_t pipe_id, uint32_t queue_id) 537 uint32_t pipe_id, uint32_t queue_id)
518{ 538{
519 uint32_t act; 539 uint32_t act;
@@ -552,6 +572,7 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
552 if (timeout == 0) { 572 if (timeout == 0) {
553 pr_err("kfd: cp queue preemption time out (%dms)\n", 573 pr_err("kfd: cp queue preemption time out (%dms)\n",
554 temp); 574 temp);
575 release_queue(kgd);
555 return -ETIME; 576 return -ETIME;
556 } 577 }
557 msleep(20); 578 msleep(20);
@@ -561,3 +582,52 @@ static int kgd_hqd_destroy(struct kgd_dev *kgd, uint32_t reset_type,
561 release_queue(kgd); 582 release_queue(kgd);
562 return 0; 583 return 0;
563} 584}
585
586static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
587{
588 struct radeon_device *rdev = (struct radeon_device *) kgd;
589 const union radeon_firmware_header *hdr;
590
591 BUG_ON(kgd == NULL || rdev->mec_fw == NULL);
592
593 switch (type) {
594 case KGD_ENGINE_PFP:
595 hdr = (const union radeon_firmware_header *) rdev->pfp_fw->data;
596 break;
597
598 case KGD_ENGINE_ME:
599 hdr = (const union radeon_firmware_header *) rdev->me_fw->data;
600 break;
601
602 case KGD_ENGINE_CE:
603 hdr = (const union radeon_firmware_header *) rdev->ce_fw->data;
604 break;
605
606 case KGD_ENGINE_MEC1:
607 hdr = (const union radeon_firmware_header *) rdev->mec_fw->data;
608 break;
609
610 case KGD_ENGINE_MEC2:
611 hdr = (const union radeon_firmware_header *)
612 rdev->mec2_fw->data;
613 break;
614
615 case KGD_ENGINE_RLC:
616 hdr = (const union radeon_firmware_header *) rdev->rlc_fw->data;
617 break;
618
619 case KGD_ENGINE_SDMA:
620 hdr = (const union radeon_firmware_header *)
621 rdev->sdma_fw->data;
622 break;
623
624 default:
625 return 0;
626 }
627
628 if (hdr == NULL)
629 return 0;
630
631 /* Only 12 bit in use*/
632 return hdr->common.ucode_version;
633}
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 7d68223eb469..86fc56434b28 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -529,9 +529,6 @@ int radeon_bo_list_validate(struct radeon_device *rdev,
529 u32 current_domain = 529 u32 current_domain =
530 radeon_mem_type_to_domain(bo->tbo.mem.mem_type); 530 radeon_mem_type_to_domain(bo->tbo.mem.mem_type);
531 531
532 WARN_ONCE(bo->gem_base.dumb,
533 "GPU use of dumb buffer is illegal.\n");
534
535 /* Check if this buffer will be moved and don't move it 532 /* Check if this buffer will be moved and don't move it
536 * if we have moved too many buffers for this IB already. 533 * if we have moved too many buffers for this IB already.
537 * 534 *
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 535403e0c8a2..15aee723db77 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -1703,7 +1703,7 @@ static int radeon_cp_dispatch_texture(struct drm_device * dev,
1703 u32 format; 1703 u32 format;
1704 u32 *buffer; 1704 u32 *buffer;
1705 const u8 __user *data; 1705 const u8 __user *data;
1706 int size, dwords, tex_width, blit_width, spitch; 1706 unsigned int size, dwords, tex_width, blit_width, spitch;
1707 u32 height; 1707 u32 height;
1708 int i; 1708 int i;
1709 u32 texpitch, microtile; 1709 u32 texpitch, microtile;
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 3367960286a6..978993fa3a36 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -168,7 +168,7 @@ static int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
168 const struct tegra_dc_window *window) 168 const struct tegra_dc_window *window)
169{ 169{
170 unsigned h_offset, v_offset, h_size, v_size, h_dda, v_dda, bpp; 170 unsigned h_offset, v_offset, h_size, v_size, h_dda, v_dda, bpp;
171 unsigned long value; 171 unsigned long value, flags;
172 bool yuv, planar; 172 bool yuv, planar;
173 173
174 /* 174 /*
@@ -181,6 +181,8 @@ static int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
181 else 181 else
182 bpp = planar ? 1 : 2; 182 bpp = planar ? 1 : 2;
183 183
184 spin_lock_irqsave(&dc->lock, flags);
185
184 value = WINDOW_A_SELECT << index; 186 value = WINDOW_A_SELECT << index;
185 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER); 187 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER);
186 188
@@ -273,6 +275,7 @@ static int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
273 275
274 case TEGRA_BO_TILING_MODE_BLOCK: 276 case TEGRA_BO_TILING_MODE_BLOCK:
275 DRM_ERROR("hardware doesn't support block linear mode\n"); 277 DRM_ERROR("hardware doesn't support block linear mode\n");
278 spin_unlock_irqrestore(&dc->lock, flags);
276 return -EINVAL; 279 return -EINVAL;
277 } 280 }
278 281
@@ -331,6 +334,8 @@ static int tegra_dc_setup_window(struct tegra_dc *dc, unsigned int index,
331 334
332 tegra_dc_window_commit(dc, index); 335 tegra_dc_window_commit(dc, index);
333 336
337 spin_unlock_irqrestore(&dc->lock, flags);
338
334 return 0; 339 return 0;
335} 340}
336 341
@@ -338,11 +343,14 @@ static int tegra_window_plane_disable(struct drm_plane *plane)
338{ 343{
339 struct tegra_dc *dc = to_tegra_dc(plane->crtc); 344 struct tegra_dc *dc = to_tegra_dc(plane->crtc);
340 struct tegra_plane *p = to_tegra_plane(plane); 345 struct tegra_plane *p = to_tegra_plane(plane);
346 unsigned long flags;
341 u32 value; 347 u32 value;
342 348
343 if (!plane->crtc) 349 if (!plane->crtc)
344 return 0; 350 return 0;
345 351
352 spin_lock_irqsave(&dc->lock, flags);
353
346 value = WINDOW_A_SELECT << p->index; 354 value = WINDOW_A_SELECT << p->index;
347 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER); 355 tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER);
348 356
@@ -352,6 +360,8 @@ static int tegra_window_plane_disable(struct drm_plane *plane)
352 360
353 tegra_dc_window_commit(dc, p->index); 361 tegra_dc_window_commit(dc, p->index);
354 362
363 spin_unlock_irqrestore(&dc->lock, flags);
364
355 return 0; 365 return 0;
356} 366}
357 367
@@ -699,14 +709,16 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
699 struct tegra_bo *bo = tegra_fb_get_plane(fb, 0); 709 struct tegra_bo *bo = tegra_fb_get_plane(fb, 0);
700 unsigned int h_offset = 0, v_offset = 0; 710 unsigned int h_offset = 0, v_offset = 0;
701 struct tegra_bo_tiling tiling; 711 struct tegra_bo_tiling tiling;
712 unsigned long value, flags;
702 unsigned int format, swap; 713 unsigned int format, swap;
703 unsigned long value;
704 int err; 714 int err;
705 715
706 err = tegra_fb_get_tiling(fb, &tiling); 716 err = tegra_fb_get_tiling(fb, &tiling);
707 if (err < 0) 717 if (err < 0)
708 return err; 718 return err;
709 719
720 spin_lock_irqsave(&dc->lock, flags);
721
710 tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER); 722 tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
711 723
712 value = fb->offsets[0] + y * fb->pitches[0] + 724 value = fb->offsets[0] + y * fb->pitches[0] +
@@ -752,6 +764,7 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
752 764
753 case TEGRA_BO_TILING_MODE_BLOCK: 765 case TEGRA_BO_TILING_MODE_BLOCK:
754 DRM_ERROR("hardware doesn't support block linear mode\n"); 766 DRM_ERROR("hardware doesn't support block linear mode\n");
767 spin_unlock_irqrestore(&dc->lock, flags);
755 return -EINVAL; 768 return -EINVAL;
756 } 769 }
757 770
@@ -778,6 +791,8 @@ static int tegra_dc_set_base(struct tegra_dc *dc, int x, int y,
778 tegra_dc_writel(dc, value << 8, DC_CMD_STATE_CONTROL); 791 tegra_dc_writel(dc, value << 8, DC_CMD_STATE_CONTROL);
779 tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL); 792 tegra_dc_writel(dc, value, DC_CMD_STATE_CONTROL);
780 793
794 spin_unlock_irqrestore(&dc->lock, flags);
795
781 return 0; 796 return 0;
782} 797}
783 798
@@ -814,23 +829,32 @@ static void tegra_dc_finish_page_flip(struct tegra_dc *dc)
814 unsigned long flags, base; 829 unsigned long flags, base;
815 struct tegra_bo *bo; 830 struct tegra_bo *bo;
816 831
817 if (!dc->event) 832 spin_lock_irqsave(&drm->event_lock, flags);
833
834 if (!dc->event) {
835 spin_unlock_irqrestore(&drm->event_lock, flags);
818 return; 836 return;
837 }
819 838
820 bo = tegra_fb_get_plane(crtc->primary->fb, 0); 839 bo = tegra_fb_get_plane(crtc->primary->fb, 0);
821 840
841 spin_lock_irqsave(&dc->lock, flags);
842
822 /* check if new start address has been latched */ 843 /* check if new start address has been latched */
844 tegra_dc_writel(dc, WINDOW_A_SELECT, DC_CMD_DISPLAY_WINDOW_HEADER);
823 tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS); 845 tegra_dc_writel(dc, READ_MUX, DC_CMD_STATE_ACCESS);
824 base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR); 846 base = tegra_dc_readl(dc, DC_WINBUF_START_ADDR);
825 tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS); 847 tegra_dc_writel(dc, 0, DC_CMD_STATE_ACCESS);
826 848
849 spin_unlock_irqrestore(&dc->lock, flags);
850
827 if (base == bo->paddr + crtc->primary->fb->offsets[0]) { 851 if (base == bo->paddr + crtc->primary->fb->offsets[0]) {
828 spin_lock_irqsave(&drm->event_lock, flags); 852 drm_crtc_send_vblank_event(crtc, dc->event);
829 drm_send_vblank_event(drm, dc->pipe, dc->event); 853 drm_crtc_vblank_put(crtc);
830 drm_vblank_put(drm, dc->pipe);
831 dc->event = NULL; 854 dc->event = NULL;
832 spin_unlock_irqrestore(&drm->event_lock, flags);
833 } 855 }
856
857 spin_unlock_irqrestore(&drm->event_lock, flags);
834} 858}
835 859
836void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file) 860void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
@@ -843,7 +867,7 @@ void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
843 867
844 if (dc->event && dc->event->base.file_priv == file) { 868 if (dc->event && dc->event->base.file_priv == file) {
845 dc->event->base.destroy(&dc->event->base); 869 dc->event->base.destroy(&dc->event->base);
846 drm_vblank_put(drm, dc->pipe); 870 drm_crtc_vblank_put(crtc);
847 dc->event = NULL; 871 dc->event = NULL;
848 } 872 }
849 873
@@ -853,16 +877,16 @@ void tegra_dc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file)
853static int tegra_dc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb, 877static int tegra_dc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
854 struct drm_pending_vblank_event *event, uint32_t page_flip_flags) 878 struct drm_pending_vblank_event *event, uint32_t page_flip_flags)
855{ 879{
880 unsigned int pipe = drm_crtc_index(crtc);
856 struct tegra_dc *dc = to_tegra_dc(crtc); 881 struct tegra_dc *dc = to_tegra_dc(crtc);
857 struct drm_device *drm = crtc->dev;
858 882
859 if (dc->event) 883 if (dc->event)
860 return -EBUSY; 884 return -EBUSY;
861 885
862 if (event) { 886 if (event) {
863 event->pipe = dc->pipe; 887 event->pipe = pipe;
864 dc->event = event; 888 dc->event = event;
865 drm_vblank_get(drm, dc->pipe); 889 drm_crtc_vblank_get(crtc);
866 } 890 }
867 891
868 tegra_dc_set_base(dc, 0, 0, fb); 892 tegra_dc_set_base(dc, 0, 0, fb);
@@ -1127,7 +1151,7 @@ static irqreturn_t tegra_dc_irq(int irq, void *data)
1127 /* 1151 /*
1128 dev_dbg(dc->dev, "%s(): vertical blank\n", __func__); 1152 dev_dbg(dc->dev, "%s(): vertical blank\n", __func__);
1129 */ 1153 */
1130 drm_handle_vblank(dc->base.dev, dc->pipe); 1154 drm_crtc_handle_vblank(&dc->base);
1131 tegra_dc_finish_page_flip(dc); 1155 tegra_dc_finish_page_flip(dc);
1132 } 1156 }
1133 1157
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index e549afeece1f..d4f827593dfa 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -694,24 +694,28 @@ static const struct file_operations tegra_drm_fops = {
694 .llseek = noop_llseek, 694 .llseek = noop_llseek,
695}; 695};
696 696
697static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm, int pipe) 697static struct drm_crtc *tegra_crtc_from_pipe(struct drm_device *drm,
698 unsigned int pipe)
698{ 699{
699 struct drm_crtc *crtc; 700 struct drm_crtc *crtc;
700 701
701 list_for_each_entry(crtc, &drm->mode_config.crtc_list, head) { 702 list_for_each_entry(crtc, &drm->mode_config.crtc_list, head) {
702 struct tegra_dc *dc = to_tegra_dc(crtc); 703 if (pipe == drm_crtc_index(crtc))
703
704 if (dc->pipe == pipe)
705 return crtc; 704 return crtc;
706 } 705 }
707 706
708 return NULL; 707 return NULL;
709} 708}
710 709
711static u32 tegra_drm_get_vblank_counter(struct drm_device *dev, int crtc) 710static u32 tegra_drm_get_vblank_counter(struct drm_device *drm, int pipe)
712{ 711{
712 struct drm_crtc *crtc = tegra_crtc_from_pipe(drm, pipe);
713
714 if (!crtc)
715 return 0;
716
713 /* TODO: implement real hardware counter using syncpoints */ 717 /* TODO: implement real hardware counter using syncpoints */
714 return drm_vblank_count(dev, crtc); 718 return drm_crtc_vblank_count(crtc);
715} 719}
716 720
717static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe) 721static int tegra_drm_enable_vblank(struct drm_device *drm, int pipe)
diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index da32086cbeaf..8777b7f75791 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -216,32 +216,58 @@ static void tegra_bo_free(struct drm_device *drm, struct tegra_bo *bo)
216 } 216 }
217} 217}
218 218
219static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo, 219static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
220 size_t size)
221{ 220{
221 struct scatterlist *s;
222 struct sg_table *sgt;
223 unsigned int i;
224
222 bo->pages = drm_gem_get_pages(&bo->gem); 225 bo->pages = drm_gem_get_pages(&bo->gem);
223 if (IS_ERR(bo->pages)) 226 if (IS_ERR(bo->pages))
224 return PTR_ERR(bo->pages); 227 return PTR_ERR(bo->pages);
225 228
226 bo->num_pages = size >> PAGE_SHIFT; 229 bo->num_pages = bo->gem.size >> PAGE_SHIFT;
227 230
228 bo->sgt = drm_prime_pages_to_sg(bo->pages, bo->num_pages); 231 sgt = drm_prime_pages_to_sg(bo->pages, bo->num_pages);
229 if (IS_ERR(bo->sgt)) { 232 if (IS_ERR(sgt))
230 drm_gem_put_pages(&bo->gem, bo->pages, false, false); 233 goto put_pages;
231 return PTR_ERR(bo->sgt); 234
235 /*
236 * Fake up the SG table so that dma_map_sg() can be used to flush the
237 * pages associated with it. Note that this relies on the fact that
238 * the DMA API doesn't hook into IOMMU on Tegra, therefore mapping is
239 * only cache maintenance.
240 *
241 * TODO: Replace this by drm_clflash_sg() once it can be implemented
242 * without relying on symbols that are not exported.
243 */
244 for_each_sg(sgt->sgl, s, sgt->nents, i)
245 sg_dma_address(s) = sg_phys(s);
246
247 if (dma_map_sg(drm->dev, sgt->sgl, sgt->nents, DMA_TO_DEVICE) == 0) {
248 sgt = ERR_PTR(-ENOMEM);
249 goto release_sgt;
232 } 250 }
233 251
252 bo->sgt = sgt;
253
234 return 0; 254 return 0;
255
256release_sgt:
257 sg_free_table(sgt);
258 kfree(sgt);
259put_pages:
260 drm_gem_put_pages(&bo->gem, bo->pages, false, false);
261 return PTR_ERR(sgt);
235} 262}
236 263
237static int tegra_bo_alloc(struct drm_device *drm, struct tegra_bo *bo, 264static int tegra_bo_alloc(struct drm_device *drm, struct tegra_bo *bo)
238 size_t size)
239{ 265{
240 struct tegra_drm *tegra = drm->dev_private; 266 struct tegra_drm *tegra = drm->dev_private;
241 int err; 267 int err;
242 268
243 if (tegra->domain) { 269 if (tegra->domain) {
244 err = tegra_bo_get_pages(drm, bo, size); 270 err = tegra_bo_get_pages(drm, bo);
245 if (err < 0) 271 if (err < 0)
246 return err; 272 return err;
247 273
@@ -251,6 +277,8 @@ static int tegra_bo_alloc(struct drm_device *drm, struct tegra_bo *bo,
251 return err; 277 return err;
252 } 278 }
253 } else { 279 } else {
280 size_t size = bo->gem.size;
281
254 bo->vaddr = dma_alloc_writecombine(drm->dev, size, &bo->paddr, 282 bo->vaddr = dma_alloc_writecombine(drm->dev, size, &bo->paddr,
255 GFP_KERNEL | __GFP_NOWARN); 283 GFP_KERNEL | __GFP_NOWARN);
256 if (!bo->vaddr) { 284 if (!bo->vaddr) {
@@ -274,7 +302,7 @@ struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
274 if (IS_ERR(bo)) 302 if (IS_ERR(bo))
275 return bo; 303 return bo;
276 304
277 err = tegra_bo_alloc(drm, bo, size); 305 err = tegra_bo_alloc(drm, bo);
278 if (err < 0) 306 if (err < 0)
279 goto release; 307 goto release;
280 308
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 230b6f887cd8..dfdc26970022 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -27,7 +27,8 @@ if HID
27 27
28config HID_BATTERY_STRENGTH 28config HID_BATTERY_STRENGTH
29 bool "Battery level reporting for HID devices" 29 bool "Battery level reporting for HID devices"
30 depends on HID && POWER_SUPPLY && HID = POWER_SUPPLY 30 depends on HID
31 select POWER_SUPPLY
31 default n 32 default n
32 ---help--- 33 ---help---
33 This option adds support of reporting battery strength (for HID devices 34 This option adds support of reporting battery strength (for HID devices
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index c3d0ac1a0988..8b638792cb43 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1805,6 +1805,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1805 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, 1805 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) },
1806 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) }, 1806 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_I405X) },
1807 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 1807 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
1808 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2) },
1808 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 1809 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X) },
1809 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, 1810 { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) },
1810 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, 1811 { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 7460f3402298..9243359c1821 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -526,6 +526,7 @@
526#define USB_DEVICE_ID_KYE_GPEN_560 0x5003 526#define USB_DEVICE_ID_KYE_GPEN_560 0x5003
527#define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 527#define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010
528#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011 528#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011
529#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2 0x501a
529#define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013 530#define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013
530 531
531#define USB_VENDOR_ID_LABTEC 0x1020 532#define USB_VENDOR_ID_LABTEC 0x1020
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index e0a0f06ac5ef..9505605b6e22 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -312,6 +312,9 @@ static const struct hid_device_id hid_battery_quirks[] = {
312 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), 312 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
313 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, 313 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE },
314 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 314 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
315 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
316 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE },
317 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
315 USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), 318 USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
316 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, 319 HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE },
317 {} 320 {}
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
index b92bf01a1ae8..158fcf577fae 100644
--- a/drivers/hid/hid-kye.c
+++ b/drivers/hid/hid-kye.c
@@ -323,6 +323,7 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
323 } 323 }
324 break; 324 break;
325 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: 325 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
326 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2:
326 if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) { 327 if (*rsize == MOUSEPEN_I608X_RDESC_ORIG_SIZE) {
327 rdesc = mousepen_i608x_rdesc_fixed; 328 rdesc = mousepen_i608x_rdesc_fixed;
328 *rsize = sizeof(mousepen_i608x_rdesc_fixed); 329 *rsize = sizeof(mousepen_i608x_rdesc_fixed);
@@ -415,6 +416,7 @@ static int kye_probe(struct hid_device *hdev, const struct hid_device_id *id)
415 switch (id->product) { 416 switch (id->product) {
416 case USB_DEVICE_ID_KYE_EASYPEN_I405X: 417 case USB_DEVICE_ID_KYE_EASYPEN_I405X:
417 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X: 418 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X:
419 case USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2:
418 case USB_DEVICE_ID_KYE_EASYPEN_M610X: 420 case USB_DEVICE_ID_KYE_EASYPEN_M610X:
419 ret = kye_tablet_enable(hdev); 421 ret = kye_tablet_enable(hdev);
420 if (ret) { 422 if (ret) {
@@ -446,6 +448,8 @@ static const struct hid_device_id kye_devices[] = {
446 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 448 { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
447 USB_DEVICE_ID_KYE_MOUSEPEN_I608X) }, 449 USB_DEVICE_ID_KYE_MOUSEPEN_I608X) },
448 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 450 { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
451 USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2) },
452 { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
449 USB_DEVICE_ID_KYE_EASYPEN_M610X) }, 453 USB_DEVICE_ID_KYE_EASYPEN_M610X) },
450 { HID_USB_DEVICE(USB_VENDOR_ID_KYE, 454 { HID_USB_DEVICE(USB_VENDOR_ID_KYE,
451 USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) }, 455 USB_DEVICE_ID_GENIUS_GILA_GAMING_MOUSE) },
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index c917ab61aafa..5bc6d80d5be7 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -962,10 +962,24 @@ static int logi_dj_raw_event(struct hid_device *hdev,
962 962
963 switch (data[0]) { 963 switch (data[0]) {
964 case REPORT_ID_DJ_SHORT: 964 case REPORT_ID_DJ_SHORT:
965 if (size != DJREPORT_SHORT_LENGTH) {
966 dev_err(&hdev->dev, "DJ report of bad size (%d)", size);
967 return false;
968 }
965 return logi_dj_dj_event(hdev, report, data, size); 969 return logi_dj_dj_event(hdev, report, data, size);
966 case REPORT_ID_HIDPP_SHORT: 970 case REPORT_ID_HIDPP_SHORT:
967 /* intentional fallthrough */ 971 if (size != HIDPP_REPORT_SHORT_LENGTH) {
972 dev_err(&hdev->dev,
973 "Short HID++ report of bad size (%d)", size);
974 return false;
975 }
976 return logi_dj_hidpp_event(hdev, report, data, size);
968 case REPORT_ID_HIDPP_LONG: 977 case REPORT_ID_HIDPP_LONG:
978 if (size != HIDPP_REPORT_LONG_LENGTH) {
979 dev_err(&hdev->dev,
980 "Long HID++ report of bad size (%d)", size);
981 return false;
982 }
969 return logi_dj_hidpp_event(hdev, report, data, size); 983 return logi_dj_hidpp_event(hdev, report, data, size);
970 } 984 }
971 985
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 2f420c0b6609..a93cefe0e522 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -282,6 +282,33 @@ static inline bool hidpp_report_is_connect_event(struct hidpp_report *report)
282 (report->rap.sub_id == 0x41); 282 (report->rap.sub_id == 0x41);
283} 283}
284 284
285/**
286 * hidpp_prefix_name() prefixes the current given name with "Logitech ".
287 */
288static void hidpp_prefix_name(char **name, int name_length)
289{
290#define PREFIX_LENGTH 9 /* "Logitech " */
291
292 int new_length;
293 char *new_name;
294
295 if (name_length > PREFIX_LENGTH &&
296 strncmp(*name, "Logitech ", PREFIX_LENGTH) == 0)
297 /* The prefix has is already in the name */
298 return;
299
300 new_length = PREFIX_LENGTH + name_length;
301 new_name = kzalloc(new_length, GFP_KERNEL);
302 if (!new_name)
303 return;
304
305 snprintf(new_name, new_length, "Logitech %s", *name);
306
307 kfree(*name);
308
309 *name = new_name;
310}
311
285/* -------------------------------------------------------------------------- */ 312/* -------------------------------------------------------------------------- */
286/* HIDP++ 1.0 commands */ 313/* HIDP++ 1.0 commands */
287/* -------------------------------------------------------------------------- */ 314/* -------------------------------------------------------------------------- */
@@ -321,6 +348,10 @@ static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev)
321 return NULL; 348 return NULL;
322 349
323 memcpy(name, &response.rap.params[2], len); 350 memcpy(name, &response.rap.params[2], len);
351
352 /* include the terminating '\0' */
353 hidpp_prefix_name(&name, len + 1);
354
324 return name; 355 return name;
325} 356}
326 357
@@ -498,6 +529,9 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp)
498 index += ret; 529 index += ret;
499 } 530 }
500 531
532 /* include the terminating '\0' */
533 hidpp_prefix_name(&name, __name_length + 1);
534
501 return name; 535 return name;
502} 536}
503 537
@@ -794,18 +828,25 @@ static int wtp_raw_event(struct hid_device *hdev, u8 *data, int size)
794 828
795 switch (data[0]) { 829 switch (data[0]) {
796 case 0x02: 830 case 0x02:
831 if (size < 2) {
832 hid_err(hdev, "Received HID report of bad size (%d)",
833 size);
834 return 1;
835 }
797 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { 836 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) {
798 input_event(wd->input, EV_KEY, BTN_LEFT, 837 input_event(wd->input, EV_KEY, BTN_LEFT,
799 !!(data[1] & 0x01)); 838 !!(data[1] & 0x01));
800 input_event(wd->input, EV_KEY, BTN_RIGHT, 839 input_event(wd->input, EV_KEY, BTN_RIGHT,
801 !!(data[1] & 0x02)); 840 !!(data[1] & 0x02));
802 input_sync(wd->input); 841 input_sync(wd->input);
842 return 0;
803 } else { 843 } else {
804 if (size < 21) 844 if (size < 21)
805 return 1; 845 return 1;
806 return wtp_mouse_raw_xy_event(hidpp, &data[7]); 846 return wtp_mouse_raw_xy_event(hidpp, &data[7]);
807 } 847 }
808 case REPORT_ID_HIDPP_LONG: 848 case REPORT_ID_HIDPP_LONG:
849 /* size is already checked in hidpp_raw_event. */
809 if ((report->fap.feature_index != wd->mt_feature_index) || 850 if ((report->fap.feature_index != wd->mt_feature_index) ||
810 (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY)) 851 (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY))
811 return 1; 852 return 1;
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c
index 1a07e07d99a0..47d7e74231e5 100644
--- a/drivers/hid/hid-roccat-pyra.c
+++ b/drivers/hid/hid-roccat-pyra.c
@@ -35,6 +35,8 @@ static struct class *pyra_class;
35static void profile_activated(struct pyra_device *pyra, 35static void profile_activated(struct pyra_device *pyra,
36 unsigned int new_profile) 36 unsigned int new_profile)
37{ 37{
38 if (new_profile >= ARRAY_SIZE(pyra->profile_settings))
39 return;
38 pyra->actual_profile = new_profile; 40 pyra->actual_profile = new_profile;
39 pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi; 41 pyra->actual_cpi = pyra->profile_settings[pyra->actual_profile].y_cpi;
40} 42}
@@ -257,9 +259,11 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp,
257 if (off != 0 || count != PYRA_SIZE_SETTINGS) 259 if (off != 0 || count != PYRA_SIZE_SETTINGS)
258 return -EINVAL; 260 return -EINVAL;
259 261
260 mutex_lock(&pyra->pyra_lock);
261
262 settings = (struct pyra_settings const *)buf; 262 settings = (struct pyra_settings const *)buf;
263 if (settings->startup_profile >= ARRAY_SIZE(pyra->profile_settings))
264 return -EINVAL;
265
266 mutex_lock(&pyra->pyra_lock);
263 267
264 retval = pyra_set_settings(usb_dev, settings); 268 retval = pyra_set_settings(usb_dev, settings);
265 if (retval) { 269 if (retval) {
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index d32037cbf9db..d43e967e7533 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -706,12 +706,7 @@ static int i2c_hid_start(struct hid_device *hid)
706 706
707static void i2c_hid_stop(struct hid_device *hid) 707static void i2c_hid_stop(struct hid_device *hid)
708{ 708{
709 struct i2c_client *client = hid->driver_data;
710 struct i2c_hid *ihid = i2c_get_clientdata(client);
711
712 hid->claimed = 0; 709 hid->claimed = 0;
713
714 i2c_hid_free_buffers(ihid);
715} 710}
716 711
717static int i2c_hid_open(struct hid_device *hid) 712static int i2c_hid_open(struct hid_device *hid)
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index dc89be90b35e..b27b3d33ebab 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -124,6 +124,7 @@ static const struct hid_blacklist {
124 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, 124 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT },
125 { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS }, 125 { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS },
126 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X, HID_QUIRK_MULTI_INPUT }, 126 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X, HID_QUIRK_MULTI_INPUT },
127 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_MOUSEPEN_I608X_2, HID_QUIRK_MULTI_INPUT },
127 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X, HID_QUIRK_MULTI_INPUT }, 128 { USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M610X, HID_QUIRK_MULTI_INPUT },
128 { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS }, 129 { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS },
129 { USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD, HID_QUIRK_NO_INIT_REPORTS }, 130 { USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD, HID_QUIRK_NO_INIT_REPORTS },
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 8afa28e4570e..18d4b2c8fe55 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -28,6 +28,13 @@
28#include <linux/cdev.h> 28#include <linux/cdev.h>
29#include "input-compat.h" 29#include "input-compat.h"
30 30
31enum evdev_clock_type {
32 EV_CLK_REAL = 0,
33 EV_CLK_MONO,
34 EV_CLK_BOOT,
35 EV_CLK_MAX
36};
37
31struct evdev { 38struct evdev {
32 int open; 39 int open;
33 struct input_handle handle; 40 struct input_handle handle;
@@ -49,12 +56,32 @@ struct evdev_client {
49 struct fasync_struct *fasync; 56 struct fasync_struct *fasync;
50 struct evdev *evdev; 57 struct evdev *evdev;
51 struct list_head node; 58 struct list_head node;
52 int clkid; 59 int clk_type;
53 bool revoked; 60 bool revoked;
54 unsigned int bufsize; 61 unsigned int bufsize;
55 struct input_event buffer[]; 62 struct input_event buffer[];
56}; 63};
57 64
65static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
66{
67 switch (clkid) {
68
69 case CLOCK_REALTIME:
70 client->clk_type = EV_CLK_REAL;
71 break;
72 case CLOCK_MONOTONIC:
73 client->clk_type = EV_CLK_MONO;
74 break;
75 case CLOCK_BOOTTIME:
76 client->clk_type = EV_CLK_BOOT;
77 break;
78 default:
79 return -EINVAL;
80 }
81
82 return 0;
83}
84
58/* flush queued events of type @type, caller must hold client->buffer_lock */ 85/* flush queued events of type @type, caller must hold client->buffer_lock */
59static void __evdev_flush_queue(struct evdev_client *client, unsigned int type) 86static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
60{ 87{
@@ -108,8 +135,11 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
108 struct input_event ev; 135 struct input_event ev;
109 ktime_t time; 136 ktime_t time;
110 137
111 time = (client->clkid == CLOCK_MONOTONIC) ? 138 time = client->clk_type == EV_CLK_REAL ?
112 ktime_get() : ktime_get_real(); 139 ktime_get_real() :
140 client->clk_type == EV_CLK_MONO ?
141 ktime_get() :
142 ktime_get_boottime();
113 143
114 ev.time = ktime_to_timeval(time); 144 ev.time = ktime_to_timeval(time);
115 ev.type = EV_SYN; 145 ev.type = EV_SYN;
@@ -159,7 +189,7 @@ static void __pass_event(struct evdev_client *client,
159 189
160static void evdev_pass_values(struct evdev_client *client, 190static void evdev_pass_values(struct evdev_client *client,
161 const struct input_value *vals, unsigned int count, 191 const struct input_value *vals, unsigned int count,
162 ktime_t mono, ktime_t real) 192 ktime_t *ev_time)
163{ 193{
164 struct evdev *evdev = client->evdev; 194 struct evdev *evdev = client->evdev;
165 const struct input_value *v; 195 const struct input_value *v;
@@ -169,8 +199,7 @@ static void evdev_pass_values(struct evdev_client *client,
169 if (client->revoked) 199 if (client->revoked)
170 return; 200 return;
171 201
172 event.time = ktime_to_timeval(client->clkid == CLOCK_MONOTONIC ? 202 event.time = ktime_to_timeval(ev_time[client->clk_type]);
173 mono : real);
174 203
175 /* Interrupts are disabled, just acquire the lock. */ 204 /* Interrupts are disabled, just acquire the lock. */
176 spin_lock(&client->buffer_lock); 205 spin_lock(&client->buffer_lock);
@@ -198,21 +227,22 @@ static void evdev_events(struct input_handle *handle,
198{ 227{
199 struct evdev *evdev = handle->private; 228 struct evdev *evdev = handle->private;
200 struct evdev_client *client; 229 struct evdev_client *client;
201 ktime_t time_mono, time_real; 230 ktime_t ev_time[EV_CLK_MAX];
202 231
203 time_mono = ktime_get(); 232 ev_time[EV_CLK_MONO] = ktime_get();
204 time_real = ktime_mono_to_real(time_mono); 233 ev_time[EV_CLK_REAL] = ktime_mono_to_real(ev_time[EV_CLK_MONO]);
234 ev_time[EV_CLK_BOOT] = ktime_mono_to_any(ev_time[EV_CLK_MONO],
235 TK_OFFS_BOOT);
205 236
206 rcu_read_lock(); 237 rcu_read_lock();
207 238
208 client = rcu_dereference(evdev->grab); 239 client = rcu_dereference(evdev->grab);
209 240
210 if (client) 241 if (client)
211 evdev_pass_values(client, vals, count, time_mono, time_real); 242 evdev_pass_values(client, vals, count, ev_time);
212 else 243 else
213 list_for_each_entry_rcu(client, &evdev->client_list, node) 244 list_for_each_entry_rcu(client, &evdev->client_list, node)
214 evdev_pass_values(client, vals, count, 245 evdev_pass_values(client, vals, count, ev_time);
215 time_mono, time_real);
216 246
217 rcu_read_unlock(); 247 rcu_read_unlock();
218} 248}
@@ -877,10 +907,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
877 case EVIOCSCLOCKID: 907 case EVIOCSCLOCKID:
878 if (copy_from_user(&i, p, sizeof(unsigned int))) 908 if (copy_from_user(&i, p, sizeof(unsigned int)))
879 return -EFAULT; 909 return -EFAULT;
880 if (i != CLOCK_MONOTONIC && i != CLOCK_REALTIME) 910
881 return -EINVAL; 911 return evdev_set_clk_type(client, i);
882 client->clkid = i;
883 return 0;
884 912
885 case EVIOCGKEYCODE: 913 case EVIOCGKEYCODE:
886 return evdev_handle_get_keycode(dev, p); 914 return evdev_handle_get_keycode(dev, p);
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 04217c2e345c..213e3a1903ee 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1974,18 +1974,22 @@ static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
1974 1974
1975 events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */ 1975 events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
1976 1976
1977 for (i = 0; i < ABS_CNT; i++) { 1977 if (test_bit(EV_ABS, dev->evbit)) {
1978 if (test_bit(i, dev->absbit)) { 1978 for (i = 0; i < ABS_CNT; i++) {
1979 if (input_is_mt_axis(i)) 1979 if (test_bit(i, dev->absbit)) {
1980 events += mt_slots; 1980 if (input_is_mt_axis(i))
1981 else 1981 events += mt_slots;
1982 events++; 1982 else
1983 events++;
1984 }
1983 } 1985 }
1984 } 1986 }
1985 1987
1986 for (i = 0; i < REL_CNT; i++) 1988 if (test_bit(EV_REL, dev->evbit)) {
1987 if (test_bit(i, dev->relbit)) 1989 for (i = 0; i < REL_CNT; i++)
1988 events++; 1990 if (test_bit(i, dev->relbit))
1991 events++;
1992 }
1989 1993
1990 /* Make room for KEY and MSC events */ 1994 /* Make room for KEY and MSC events */
1991 events += 7; 1995 events += 7;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 96ee26c555e0..a5d9b3f3c871 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -559,6 +559,7 @@ config KEYBOARD_SH_KEYSC
559config KEYBOARD_STMPE 559config KEYBOARD_STMPE
560 tristate "STMPE keypad support" 560 tristate "STMPE keypad support"
561 depends on MFD_STMPE 561 depends on MFD_STMPE
562 depends on OF
562 select INPUT_MATRIXKMAP 563 select INPUT_MATRIXKMAP
563 help 564 help
564 Say Y here if you want to use the keypad controller on STMPE I/O 565 Say Y here if you want to use the keypad controller on STMPE I/O
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index d4dd78a7d56b..883d6aed5b9a 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -35,9 +35,13 @@
35struct gpio_button_data { 35struct gpio_button_data {
36 const struct gpio_keys_button *button; 36 const struct gpio_keys_button *button;
37 struct input_dev *input; 37 struct input_dev *input;
38 struct timer_list timer; 38
39 struct work_struct work; 39 struct timer_list release_timer;
40 unsigned int timer_debounce; /* in msecs */ 40 unsigned int release_delay; /* in msecs, for IRQ-only buttons */
41
42 struct delayed_work work;
43 unsigned int software_debounce; /* in msecs, for GPIO-driven buttons */
44
41 unsigned int irq; 45 unsigned int irq;
42 spinlock_t lock; 46 spinlock_t lock;
43 bool disabled; 47 bool disabled;
@@ -116,11 +120,14 @@ static void gpio_keys_disable_button(struct gpio_button_data *bdata)
116{ 120{
117 if (!bdata->disabled) { 121 if (!bdata->disabled) {
118 /* 122 /*
119 * Disable IRQ and possible debouncing timer. 123 * Disable IRQ and associated timer/work structure.
120 */ 124 */
121 disable_irq(bdata->irq); 125 disable_irq(bdata->irq);
122 if (bdata->timer_debounce) 126
123 del_timer_sync(&bdata->timer); 127 if (gpio_is_valid(bdata->button->gpio))
128 cancel_delayed_work_sync(&bdata->work);
129 else
130 del_timer_sync(&bdata->release_timer);
124 131
125 bdata->disabled = true; 132 bdata->disabled = true;
126 } 133 }
@@ -343,7 +350,7 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
343static void gpio_keys_gpio_work_func(struct work_struct *work) 350static void gpio_keys_gpio_work_func(struct work_struct *work)
344{ 351{
345 struct gpio_button_data *bdata = 352 struct gpio_button_data *bdata =
346 container_of(work, struct gpio_button_data, work); 353 container_of(work, struct gpio_button_data, work.work);
347 354
348 gpio_keys_gpio_report_event(bdata); 355 gpio_keys_gpio_report_event(bdata);
349 356
@@ -351,13 +358,6 @@ static void gpio_keys_gpio_work_func(struct work_struct *work)
351 pm_relax(bdata->input->dev.parent); 358 pm_relax(bdata->input->dev.parent);
352} 359}
353 360
354static void gpio_keys_gpio_timer(unsigned long _data)
355{
356 struct gpio_button_data *bdata = (struct gpio_button_data *)_data;
357
358 schedule_work(&bdata->work);
359}
360
361static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) 361static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
362{ 362{
363 struct gpio_button_data *bdata = dev_id; 363 struct gpio_button_data *bdata = dev_id;
@@ -366,11 +366,10 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id)
366 366
367 if (bdata->button->wakeup) 367 if (bdata->button->wakeup)
368 pm_stay_awake(bdata->input->dev.parent); 368 pm_stay_awake(bdata->input->dev.parent);
369 if (bdata->timer_debounce) 369
370 mod_timer(&bdata->timer, 370 mod_delayed_work(system_wq,
371 jiffies + msecs_to_jiffies(bdata->timer_debounce)); 371 &bdata->work,
372 else 372 msecs_to_jiffies(bdata->software_debounce));
373 schedule_work(&bdata->work);
374 373
375 return IRQ_HANDLED; 374 return IRQ_HANDLED;
376} 375}
@@ -408,7 +407,7 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
408 input_event(input, EV_KEY, button->code, 1); 407 input_event(input, EV_KEY, button->code, 1);
409 input_sync(input); 408 input_sync(input);
410 409
411 if (!bdata->timer_debounce) { 410 if (!bdata->release_delay) {
412 input_event(input, EV_KEY, button->code, 0); 411 input_event(input, EV_KEY, button->code, 0);
413 input_sync(input); 412 input_sync(input);
414 goto out; 413 goto out;
@@ -417,9 +416,9 @@ static irqreturn_t gpio_keys_irq_isr(int irq, void *dev_id)
417 bdata->key_pressed = true; 416 bdata->key_pressed = true;
418 } 417 }
419 418
420 if (bdata->timer_debounce) 419 if (bdata->release_delay)
421 mod_timer(&bdata->timer, 420 mod_timer(&bdata->release_timer,
422 jiffies + msecs_to_jiffies(bdata->timer_debounce)); 421 jiffies + msecs_to_jiffies(bdata->release_delay));
423out: 422out:
424 spin_unlock_irqrestore(&bdata->lock, flags); 423 spin_unlock_irqrestore(&bdata->lock, flags);
425 return IRQ_HANDLED; 424 return IRQ_HANDLED;
@@ -429,10 +428,10 @@ static void gpio_keys_quiesce_key(void *data)
429{ 428{
430 struct gpio_button_data *bdata = data; 429 struct gpio_button_data *bdata = data;
431 430
432 if (bdata->timer_debounce) 431 if (gpio_is_valid(bdata->button->gpio))
433 del_timer_sync(&bdata->timer); 432 cancel_delayed_work_sync(&bdata->work);
434 433 else
435 cancel_work_sync(&bdata->work); 434 del_timer_sync(&bdata->release_timer);
436} 435}
437 436
438static int gpio_keys_setup_key(struct platform_device *pdev, 437static int gpio_keys_setup_key(struct platform_device *pdev,
@@ -466,23 +465,25 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
466 button->debounce_interval * 1000); 465 button->debounce_interval * 1000);
467 /* use timer if gpiolib doesn't provide debounce */ 466 /* use timer if gpiolib doesn't provide debounce */
468 if (error < 0) 467 if (error < 0)
469 bdata->timer_debounce = 468 bdata->software_debounce =
470 button->debounce_interval; 469 button->debounce_interval;
471 } 470 }
472 471
473 irq = gpio_to_irq(button->gpio); 472 if (button->irq) {
474 if (irq < 0) { 473 bdata->irq = button->irq;
475 error = irq; 474 } else {
476 dev_err(dev, 475 irq = gpio_to_irq(button->gpio);
477 "Unable to get irq number for GPIO %d, error %d\n", 476 if (irq < 0) {
478 button->gpio, error); 477 error = irq;
479 return error; 478 dev_err(dev,
479 "Unable to get irq number for GPIO %d, error %d\n",
480 button->gpio, error);
481 return error;
482 }
483 bdata->irq = irq;
480 } 484 }
481 bdata->irq = irq;
482 485
483 INIT_WORK(&bdata->work, gpio_keys_gpio_work_func); 486 INIT_DELAYED_WORK(&bdata->work, gpio_keys_gpio_work_func);
484 setup_timer(&bdata->timer,
485 gpio_keys_gpio_timer, (unsigned long)bdata);
486 487
487 isr = gpio_keys_gpio_isr; 488 isr = gpio_keys_gpio_isr;
488 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING; 489 irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
@@ -499,8 +500,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
499 return -EINVAL; 500 return -EINVAL;
500 } 501 }
501 502
502 bdata->timer_debounce = button->debounce_interval; 503 bdata->release_delay = button->debounce_interval;
503 setup_timer(&bdata->timer, 504 setup_timer(&bdata->release_timer,
504 gpio_keys_irq_timer, (unsigned long)bdata); 505 gpio_keys_irq_timer, (unsigned long)bdata);
505 506
506 isr = gpio_keys_irq_isr; 507 isr = gpio_keys_irq_isr;
@@ -510,7 +511,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
510 input_set_capability(input, button->type ?: EV_KEY, button->code); 511 input_set_capability(input, button->type ?: EV_KEY, button->code);
511 512
512 /* 513 /*
513 * Install custom action to cancel debounce timer and 514 * Install custom action to cancel release timer and
514 * workqueue item. 515 * workqueue item.
515 */ 516 */
516 error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata); 517 error = devm_add_action(&pdev->dev, gpio_keys_quiesce_key, bdata);
@@ -618,33 +619,30 @@ gpio_keys_get_devtree_pdata(struct device *dev)
618 619
619 i = 0; 620 i = 0;
620 for_each_child_of_node(node, pp) { 621 for_each_child_of_node(node, pp) {
621 int gpio = -1;
622 enum of_gpio_flags flags; 622 enum of_gpio_flags flags;
623 623
624 button = &pdata->buttons[i++]; 624 button = &pdata->buttons[i++];
625 625
626 if (!of_find_property(pp, "gpios", NULL)) { 626 button->gpio = of_get_gpio_flags(pp, 0, &flags);
627 button->irq = irq_of_parse_and_map(pp, 0); 627 if (button->gpio < 0) {
628 if (button->irq == 0) { 628 error = button->gpio;
629 i--; 629 if (error != -ENOENT) {
630 pdata->nbuttons--;
631 dev_warn(dev, "Found button without gpios or irqs\n");
632 continue;
633 }
634 } else {
635 gpio = of_get_gpio_flags(pp, 0, &flags);
636 if (gpio < 0) {
637 error = gpio;
638 if (error != -EPROBE_DEFER) 630 if (error != -EPROBE_DEFER)
639 dev_err(dev, 631 dev_err(dev,
640 "Failed to get gpio flags, error: %d\n", 632 "Failed to get gpio flags, error: %d\n",
641 error); 633 error);
642 return ERR_PTR(error); 634 return ERR_PTR(error);
643 } 635 }
636 } else {
637 button->active_low = flags & OF_GPIO_ACTIVE_LOW;
644 } 638 }
645 639
646 button->gpio = gpio; 640 button->irq = irq_of_parse_and_map(pp, 0);
647 button->active_low = flags & OF_GPIO_ACTIVE_LOW; 641
642 if (!gpio_is_valid(button->gpio) && !button->irq) {
643 dev_err(dev, "Found button without gpios or irqs\n");
644 return ERR_PTR(-EINVAL);
645 }
648 646
649 if (of_property_read_u32(pp, "linux,code", &button->code)) { 647 if (of_property_read_u32(pp, "linux,code", &button->code)) {
650 dev_err(dev, "Button without keycode: 0x%x\n", 648 dev_err(dev, "Button without keycode: 0x%x\n",
@@ -659,6 +657,8 @@ gpio_keys_get_devtree_pdata(struct device *dev)
659 657
660 button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); 658 button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
661 659
660 button->can_disable = !!of_get_property(pp, "linux,can-disable", NULL);
661
662 if (of_property_read_u32(pp, "debounce-interval", 662 if (of_property_read_u32(pp, "debounce-interval",
663 &button->debounce_interval)) 663 &button->debounce_interval))
664 button->debounce_interval = 5; 664 button->debounce_interval = 5;
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index 610a8af795a1..5b152f25a8e1 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -473,7 +473,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
473 if (error) 473 if (error)
474 goto bail1; 474 goto bail1;
475 475
476 init_completion(&dev->cmd_done); 476 reinit_completion(&dev->cmd_done);
477 serio_write(serio, 0); 477 serio_write(serio, 0);
478 serio_write(serio, 0); 478 serio_write(serio, 0);
479 serio_write(serio, HIL_PKT_CMD >> 8); 479 serio_write(serio, HIL_PKT_CMD >> 8);
@@ -482,7 +482,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
482 if (error) 482 if (error)
483 goto bail1; 483 goto bail1;
484 484
485 init_completion(&dev->cmd_done); 485 reinit_completion(&dev->cmd_done);
486 serio_write(serio, 0); 486 serio_write(serio, 0);
487 serio_write(serio, 0); 487 serio_write(serio, 0);
488 serio_write(serio, HIL_PKT_CMD >> 8); 488 serio_write(serio, HIL_PKT_CMD >> 8);
@@ -491,7 +491,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
491 if (error) 491 if (error)
492 goto bail1; 492 goto bail1;
493 493
494 init_completion(&dev->cmd_done); 494 reinit_completion(&dev->cmd_done);
495 serio_write(serio, 0); 495 serio_write(serio, 0);
496 serio_write(serio, 0); 496 serio_write(serio, 0);
497 serio_write(serio, HIL_PKT_CMD >> 8); 497 serio_write(serio, HIL_PKT_CMD >> 8);
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index ef5e67fb567e..fe6e3f22eed7 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -45,13 +45,14 @@
45#define STMPE_KEYPAD_MAX_ROWS 8 45#define STMPE_KEYPAD_MAX_ROWS 8
46#define STMPE_KEYPAD_MAX_COLS 8 46#define STMPE_KEYPAD_MAX_COLS 8
47#define STMPE_KEYPAD_ROW_SHIFT 3 47#define STMPE_KEYPAD_ROW_SHIFT 3
48#define STMPE_KEYPAD_KEYMAP_SIZE \ 48#define STMPE_KEYPAD_KEYMAP_MAX_SIZE \
49 (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS) 49 (STMPE_KEYPAD_MAX_ROWS * STMPE_KEYPAD_MAX_COLS)
50 50
51/** 51/**
52 * struct stmpe_keypad_variant - model-specific attributes 52 * struct stmpe_keypad_variant - model-specific attributes
53 * @auto_increment: whether the KPC_DATA_BYTE register address 53 * @auto_increment: whether the KPC_DATA_BYTE register address
54 * auto-increments on multiple read 54 * auto-increments on multiple read
55 * @set_pullup: whether the pins need to have their pull-ups set
55 * @num_data: number of data bytes 56 * @num_data: number of data bytes
56 * @num_normal_data: number of normal keys' data bytes 57 * @num_normal_data: number of normal keys' data bytes
57 * @max_cols: maximum number of columns supported 58 * @max_cols: maximum number of columns supported
@@ -61,6 +62,7 @@
61 */ 62 */
62struct stmpe_keypad_variant { 63struct stmpe_keypad_variant {
63 bool auto_increment; 64 bool auto_increment;
65 bool set_pullup;
64 int num_data; 66 int num_data;
65 int num_normal_data; 67 int num_normal_data;
66 int max_cols; 68 int max_cols;
@@ -81,6 +83,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = {
81 }, 83 },
82 [STMPE2401] = { 84 [STMPE2401] = {
83 .auto_increment = false, 85 .auto_increment = false,
86 .set_pullup = true,
84 .num_data = 3, 87 .num_data = 3,
85 .num_normal_data = 2, 88 .num_normal_data = 2,
86 .max_cols = 8, 89 .max_cols = 8,
@@ -90,6 +93,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = {
90 }, 93 },
91 [STMPE2403] = { 94 [STMPE2403] = {
92 .auto_increment = true, 95 .auto_increment = true,
96 .set_pullup = true,
93 .num_data = 5, 97 .num_data = 5,
94 .num_normal_data = 3, 98 .num_normal_data = 3,
95 .max_cols = 8, 99 .max_cols = 8,
@@ -99,16 +103,30 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = {
99 }, 103 },
100}; 104};
101 105
106/**
107 * struct stmpe_keypad - STMPE keypad state container
108 * @stmpe: pointer to parent STMPE device
109 * @input: spawned input device
110 * @variant: STMPE variant
111 * @debounce_ms: debounce interval, in ms. Maximum is
112 * %STMPE_KEYPAD_MAX_DEBOUNCE.
113 * @scan_count: number of key scanning cycles to confirm key data.
114 * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT.
115 * @no_autorepeat: disable key autorepeat
116 * @rows: bitmask for the rows
117 * @cols: bitmask for the columns
118 * @keymap: the keymap
119 */
102struct stmpe_keypad { 120struct stmpe_keypad {
103 struct stmpe *stmpe; 121 struct stmpe *stmpe;
104 struct input_dev *input; 122 struct input_dev *input;
105 const struct stmpe_keypad_variant *variant; 123 const struct stmpe_keypad_variant *variant;
106 const struct stmpe_keypad_platform_data *plat; 124 unsigned int debounce_ms;
107 125 unsigned int scan_count;
126 bool no_autorepeat;
108 unsigned int rows; 127 unsigned int rows;
109 unsigned int cols; 128 unsigned int cols;
110 129 unsigned short keymap[STMPE_KEYPAD_KEYMAP_MAX_SIZE];
111 unsigned short keymap[STMPE_KEYPAD_KEYMAP_SIZE];
112}; 130};
113 131
114static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data) 132static int stmpe_keypad_read_data(struct stmpe_keypad *keypad, u8 *data)
@@ -171,7 +189,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad)
171 unsigned int col_gpios = variant->col_gpios; 189 unsigned int col_gpios = variant->col_gpios;
172 unsigned int row_gpios = variant->row_gpios; 190 unsigned int row_gpios = variant->row_gpios;
173 struct stmpe *stmpe = keypad->stmpe; 191 struct stmpe *stmpe = keypad->stmpe;
192 u8 pureg = stmpe->regs[STMPE_IDX_GPPUR_LSB];
174 unsigned int pins = 0; 193 unsigned int pins = 0;
194 unsigned int pu_pins = 0;
195 int ret;
175 int i; 196 int i;
176 197
177 /* 198 /*
@@ -188,8 +209,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad)
188 for (i = 0; i < variant->max_cols; i++) { 209 for (i = 0; i < variant->max_cols; i++) {
189 int num = __ffs(col_gpios); 210 int num = __ffs(col_gpios);
190 211
191 if (keypad->cols & (1 << i)) 212 if (keypad->cols & (1 << i)) {
192 pins |= 1 << num; 213 pins |= 1 << num;
214 pu_pins |= 1 << num;
215 }
193 216
194 col_gpios &= ~(1 << num); 217 col_gpios &= ~(1 << num);
195 } 218 }
@@ -203,20 +226,43 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad)
203 row_gpios &= ~(1 << num); 226 row_gpios &= ~(1 << num);
204 } 227 }
205 228
206 return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); 229 ret = stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD);
230 if (ret)
231 return ret;
232
233 /*
234 * On STMPE24xx, set pin bias to pull-up on all keypad input
235 * pins (columns), this incidentally happen to be maximum 8 pins
236 * and placed at GPIO0-7 so only the LSB of the pull up register
237 * ever needs to be written.
238 */
239 if (variant->set_pullup) {
240 u8 val;
241
242 ret = stmpe_reg_read(stmpe, pureg);
243 if (ret)
244 return ret;
245
246 /* Do not touch unused pins, may be used for GPIO */
247 val = ret & ~pu_pins;
248 val |= pu_pins;
249
250 ret = stmpe_reg_write(stmpe, pureg, val);
251 }
252
253 return 0;
207} 254}
208 255
209static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad) 256static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
210{ 257{
211 const struct stmpe_keypad_platform_data *plat = keypad->plat;
212 const struct stmpe_keypad_variant *variant = keypad->variant; 258 const struct stmpe_keypad_variant *variant = keypad->variant;
213 struct stmpe *stmpe = keypad->stmpe; 259 struct stmpe *stmpe = keypad->stmpe;
214 int ret; 260 int ret;
215 261
216 if (plat->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) 262 if (keypad->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE)
217 return -EINVAL; 263 return -EINVAL;
218 264
219 if (plat->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) 265 if (keypad->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT)
220 return -EINVAL; 266 return -EINVAL;
221 267
222 ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD); 268 ret = stmpe_enable(stmpe, STMPE_BLOCK_KEYPAD);
@@ -245,7 +291,7 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
245 291
246 ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB, 292 ret = stmpe_set_bits(stmpe, STMPE_KPC_CTRL_MSB,
247 STMPE_KPC_CTRL_MSB_SCAN_COUNT, 293 STMPE_KPC_CTRL_MSB_SCAN_COUNT,
248 plat->scan_count << 4); 294 keypad->scan_count << 4);
249 if (ret < 0) 295 if (ret < 0)
250 return ret; 296 return ret;
251 297
@@ -253,17 +299,18 @@ static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
253 STMPE_KPC_CTRL_LSB_SCAN | 299 STMPE_KPC_CTRL_LSB_SCAN |
254 STMPE_KPC_CTRL_LSB_DEBOUNCE, 300 STMPE_KPC_CTRL_LSB_DEBOUNCE,
255 STMPE_KPC_CTRL_LSB_SCAN | 301 STMPE_KPC_CTRL_LSB_SCAN |
256 (plat->debounce_ms << 1)); 302 (keypad->debounce_ms << 1));
257} 303}
258 304
259static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad) 305static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad,
306 u32 used_rows, u32 used_cols)
260{ 307{
261 int row, col; 308 int row, col;
262 309
263 for (row = 0; row < STMPE_KEYPAD_MAX_ROWS; row++) { 310 for (row = 0; row < used_rows; row++) {
264 for (col = 0; col < STMPE_KEYPAD_MAX_COLS; col++) { 311 for (col = 0; col < used_cols; col++) {
265 int code = MATRIX_SCAN_CODE(row, col, 312 int code = MATRIX_SCAN_CODE(row, col,
266 STMPE_KEYPAD_ROW_SHIFT); 313 STMPE_KEYPAD_ROW_SHIFT);
267 if (keypad->keymap[code] != KEY_RESERVED) { 314 if (keypad->keymap[code] != KEY_RESERVED) {
268 keypad->rows |= 1 << row; 315 keypad->rows |= 1 << row;
269 keypad->cols |= 1 << col; 316 keypad->cols |= 1 << col;
@@ -272,51 +319,17 @@ static void stmpe_keypad_fill_used_pins(struct stmpe_keypad *keypad)
272 } 319 }
273} 320}
274 321
275#ifdef CONFIG_OF
276static const struct stmpe_keypad_platform_data *
277stmpe_keypad_of_probe(struct device *dev)
278{
279 struct device_node *np = dev->of_node;
280 struct stmpe_keypad_platform_data *plat;
281
282 if (!np)
283 return ERR_PTR(-ENODEV);
284
285 plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
286 if (!plat)
287 return ERR_PTR(-ENOMEM);
288
289 of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
290 of_property_read_u32(np, "st,scan-count", &plat->scan_count);
291
292 plat->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");
293
294 return plat;
295}
296#else
297static inline const struct stmpe_keypad_platform_data *
298stmpe_keypad_of_probe(struct device *dev)
299{
300 return ERR_PTR(-EINVAL);
301}
302#endif
303
304static int stmpe_keypad_probe(struct platform_device *pdev) 322static int stmpe_keypad_probe(struct platform_device *pdev)
305{ 323{
306 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 324 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
307 const struct stmpe_keypad_platform_data *plat; 325 struct device_node *np = pdev->dev.of_node;
308 struct stmpe_keypad *keypad; 326 struct stmpe_keypad *keypad;
309 struct input_dev *input; 327 struct input_dev *input;
328 u32 rows;
329 u32 cols;
310 int error; 330 int error;
311 int irq; 331 int irq;
312 332
313 plat = stmpe->pdata->keypad;
314 if (!plat) {
315 plat = stmpe_keypad_of_probe(&pdev->dev);
316 if (IS_ERR(plat))
317 return PTR_ERR(plat);
318 }
319
320 irq = platform_get_irq(pdev, 0); 333 irq = platform_get_irq(pdev, 0);
321 if (irq < 0) 334 if (irq < 0)
322 return irq; 335 return irq;
@@ -326,6 +339,13 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
326 if (!keypad) 339 if (!keypad)
327 return -ENOMEM; 340 return -ENOMEM;
328 341
342 keypad->stmpe = stmpe;
343 keypad->variant = &stmpe_keypad_variants[stmpe->partnum];
344
345 of_property_read_u32(np, "debounce-interval", &keypad->debounce_ms);
346 of_property_read_u32(np, "st,scan-count", &keypad->scan_count);
347 keypad->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");
348
329 input = devm_input_allocate_device(&pdev->dev); 349 input = devm_input_allocate_device(&pdev->dev);
330 if (!input) 350 if (!input)
331 return -ENOMEM; 351 return -ENOMEM;
@@ -334,23 +354,22 @@ static int stmpe_keypad_probe(struct platform_device *pdev)
334 input->id.bustype = BUS_I2C; 354 input->id.bustype = BUS_I2C;
335 input->dev.parent = &pdev->dev; 355 input->dev.parent = &pdev->dev;
336 356
337 error = matrix_keypad_build_keymap(plat->keymap_data, NULL, 357 error = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols);
338 STMPE_KEYPAD_MAX_ROWS, 358 if (error)
339 STMPE_KEYPAD_MAX_COLS, 359 return error;
360
361 error = matrix_keypad_build_keymap(NULL, NULL, rows, cols,
340 keypad->keymap, input); 362 keypad->keymap, input);
341 if (error) 363 if (error)
342 return error; 364 return error;
343 365
344 input_set_capability(input, EV_MSC, MSC_SCAN); 366 input_set_capability(input, EV_MSC, MSC_SCAN);
345 if (!plat->no_autorepeat) 367 if (!keypad->no_autorepeat)
346 __set_bit(EV_REP, input->evbit); 368 __set_bit(EV_REP, input->evbit);
347 369
348 stmpe_keypad_fill_used_pins(keypad); 370 stmpe_keypad_fill_used_pins(keypad, rows, cols);
349 371
350 keypad->stmpe = stmpe;
351 keypad->plat = plat;
352 keypad->input = input; 372 keypad->input = input;
353 keypad->variant = &stmpe_keypad_variants[stmpe->partnum];
354 373
355 error = stmpe_keypad_chip_init(keypad); 374 error = stmpe_keypad_chip_init(keypad);
356 if (error < 0) 375 if (error < 0)
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index d125a019383f..d88d73d83552 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -881,6 +881,34 @@ static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt,
881 unsigned char *pkt, 881 unsigned char *pkt,
882 unsigned char pkt_id) 882 unsigned char pkt_id)
883{ 883{
884 /*
885 * packet-fmt b7 b6 b5 b4 b3 b2 b1 b0
886 * Byte0 TWO & MULTI L 1 R M 1 Y0-2 Y0-1 Y0-0
887 * Byte0 NEW L 1 X1-5 1 1 Y0-2 Y0-1 Y0-0
888 * Byte1 Y0-10 Y0-9 Y0-8 Y0-7 Y0-6 Y0-5 Y0-4 Y0-3
889 * Byte2 X0-11 1 X0-10 X0-9 X0-8 X0-7 X0-6 X0-5
890 * Byte3 X1-11 1 X0-4 X0-3 1 X0-2 X0-1 X0-0
891 * Byte4 TWO X1-10 TWO X1-9 X1-8 X1-7 X1-6 X1-5 X1-4
892 * Byte4 MULTI X1-10 TWO X1-9 X1-8 X1-7 X1-6 Y1-5 1
893 * Byte4 NEW X1-10 TWO X1-9 X1-8 X1-7 X1-6 0 0
894 * Byte5 TWO & NEW Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 Y1-5 Y1-4
895 * Byte5 MULTI Y1-10 0 Y1-9 Y1-8 Y1-7 Y1-6 F-1 F-0
896 * L: Left button
897 * R / M: Non-clickpads: Right / Middle button
898 * Clickpads: When > 2 fingers are down, and some fingers
899 * are in the button area, then the 2 coordinates reported
900 * are for fingers outside the button area and these report
901 * extra fingers being present in the right / left button
902 * area. Note these fingers are not added to the F field!
903 * so if a TWO packet is received and R = 1 then there are
904 * 3 fingers down, etc.
905 * TWO: 1: Two touches present, byte 0/4/5 are in TWO fmt
906 * 0: If byte 4 bit 0 is 1, then byte 0/4/5 are in MULTI fmt
907 * otherwise byte 0 bit 4 must be set and byte 0/4/5 are
908 * in NEW fmt
909 * F: Number of fingers - 3, 0 means 3 fingers, 1 means 4 ...
910 */
911
884 mt[0].x = ((pkt[2] & 0x80) << 4); 912 mt[0].x = ((pkt[2] & 0x80) << 4);
885 mt[0].x |= ((pkt[2] & 0x3F) << 5); 913 mt[0].x |= ((pkt[2] & 0x3F) << 5);
886 mt[0].x |= ((pkt[3] & 0x30) >> 1); 914 mt[0].x |= ((pkt[3] & 0x30) >> 1);
@@ -919,18 +947,21 @@ static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt,
919 947
920static int alps_get_mt_count(struct input_mt_pos *mt) 948static int alps_get_mt_count(struct input_mt_pos *mt)
921{ 949{
922 int i; 950 int i, fingers = 0;
923 951
924 for (i = 0; i < MAX_TOUCHES && mt[i].x != 0 && mt[i].y != 0; i++) 952 for (i = 0; i < MAX_TOUCHES; i++) {
925 /* empty */; 953 if (mt[i].x != 0 || mt[i].y != 0)
954 fingers++;
955 }
926 956
927 return i; 957 return fingers;
928} 958}
929 959
930static int alps_decode_packet_v7(struct alps_fields *f, 960static int alps_decode_packet_v7(struct alps_fields *f,
931 unsigned char *p, 961 unsigned char *p,
932 struct psmouse *psmouse) 962 struct psmouse *psmouse)
933{ 963{
964 struct alps_data *priv = psmouse->private;
934 unsigned char pkt_id; 965 unsigned char pkt_id;
935 966
936 pkt_id = alps_get_packet_id_v7(p); 967 pkt_id = alps_get_packet_id_v7(p);
@@ -938,19 +969,52 @@ static int alps_decode_packet_v7(struct alps_fields *f,
938 return 0; 969 return 0;
939 if (pkt_id == V7_PACKET_ID_UNKNOWN) 970 if (pkt_id == V7_PACKET_ID_UNKNOWN)
940 return -1; 971 return -1;
972 /*
973 * NEW packets are send to indicate a discontinuity in the finger
974 * coordinate reporting. Specifically a finger may have moved from
975 * slot 0 to 1 or vice versa. INPUT_MT_TRACK takes care of this for
976 * us.
977 *
978 * NEW packets have 3 problems:
979 * 1) They do not contain middle / right button info (on non clickpads)
980 * this can be worked around by preserving the old button state
981 * 2) They do not contain an accurate fingercount, and they are
982 * typically send when the number of fingers changes. We cannot use
983 * the old finger count as that may mismatch with the amount of
984 * touch coordinates we've available in the NEW packet
985 * 3) Their x data for the second touch is inaccurate leading to
986 * a possible jump of the x coordinate by 16 units when the first
987 * non NEW packet comes in
988 * Since problems 2 & 3 cannot be worked around, just ignore them.
989 */
990 if (pkt_id == V7_PACKET_ID_NEW)
991 return 1;
941 992
942 alps_get_finger_coordinate_v7(f->mt, p, pkt_id); 993 alps_get_finger_coordinate_v7(f->mt, p, pkt_id);
943 994
944 if (pkt_id == V7_PACKET_ID_TWO || pkt_id == V7_PACKET_ID_MULTI) { 995 if (pkt_id == V7_PACKET_ID_TWO)
945 f->left = (p[0] & 0x80) >> 7; 996 f->fingers = alps_get_mt_count(f->mt);
997 else /* pkt_id == V7_PACKET_ID_MULTI */
998 f->fingers = 3 + (p[5] & 0x03);
999
1000 f->left = (p[0] & 0x80) >> 7;
1001 if (priv->flags & ALPS_BUTTONPAD) {
1002 if (p[0] & 0x20)
1003 f->fingers++;
1004 if (p[0] & 0x10)
1005 f->fingers++;
1006 } else {
946 f->right = (p[0] & 0x20) >> 5; 1007 f->right = (p[0] & 0x20) >> 5;
947 f->middle = (p[0] & 0x10) >> 4; 1008 f->middle = (p[0] & 0x10) >> 4;
948 } 1009 }
949 1010
950 if (pkt_id == V7_PACKET_ID_TWO) 1011 /* Sometimes a single touch is reported in mt[1] rather then mt[0] */
951 f->fingers = alps_get_mt_count(f->mt); 1012 if (f->fingers == 1 && f->mt[0].x == 0 && f->mt[0].y == 0) {
952 else if (pkt_id == V7_PACKET_ID_MULTI) 1013 f->mt[0].x = f->mt[1].x;
953 f->fingers = 3 + (p[5] & 0x03); 1014 f->mt[0].y = f->mt[1].y;
1015 f->mt[1].x = 0;
1016 f->mt[1].y = 0;
1017 }
954 1018
955 return 0; 1019 return 0;
956} 1020}
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 30c8b6998808..354d47ecd66a 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -227,6 +227,7 @@ TRACKPOINT_INT_ATTR(thresh, TP_THRESH, TP_DEF_THRESH);
227TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH); 227TRACKPOINT_INT_ATTR(upthresh, TP_UP_THRESH, TP_DEF_UP_THRESH);
228TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME); 228TRACKPOINT_INT_ATTR(ztime, TP_Z_TIME, TP_DEF_Z_TIME);
229TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV); 229TRACKPOINT_INT_ATTR(jenks, TP_JENKS_CURV, TP_DEF_JENKS_CURV);
230TRACKPOINT_INT_ATTR(drift_time, TP_DRIFT_TIME, TP_DEF_DRIFT_TIME);
230 231
231TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0, 232TRACKPOINT_BIT_ATTR(press_to_select, TP_TOGGLE_PTSON, TP_MASK_PTSON, 0,
232 TP_DEF_PTSON); 233 TP_DEF_PTSON);
@@ -246,6 +247,7 @@ static struct attribute *trackpoint_attrs[] = {
246 &psmouse_attr_upthresh.dattr.attr, 247 &psmouse_attr_upthresh.dattr.attr,
247 &psmouse_attr_ztime.dattr.attr, 248 &psmouse_attr_ztime.dattr.attr,
248 &psmouse_attr_jenks.dattr.attr, 249 &psmouse_attr_jenks.dattr.attr,
250 &psmouse_attr_drift_time.dattr.attr,
249 &psmouse_attr_press_to_select.dattr.attr, 251 &psmouse_attr_press_to_select.dattr.attr,
250 &psmouse_attr_skipback.dattr.attr, 252 &psmouse_attr_skipback.dattr.attr,
251 &psmouse_attr_ext_dev.dattr.attr, 253 &psmouse_attr_ext_dev.dattr.attr,
@@ -312,6 +314,7 @@ static int trackpoint_sync(struct psmouse *psmouse, bool in_power_on_state)
312 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh); 314 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, upthresh);
313 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime); 315 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, ztime);
314 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks); 316 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, jenks);
317 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, drift_time);
315 318
316 /* toggles */ 319 /* toggles */
317 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select); 320 TRACKPOINT_UPDATE(in_power_on_state, psmouse, tp, press_to_select);
@@ -332,6 +335,7 @@ static void trackpoint_defaults(struct trackpoint_data *tp)
332 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh); 335 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, upthresh);
333 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime); 336 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, ztime);
334 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks); 337 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, jenks);
338 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, drift_time);
335 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia); 339 TRACKPOINT_SET_POWER_ON_DEFAULT(tp, inertia);
336 340
337 /* toggles */ 341 /* toggles */
diff --git a/drivers/input/mouse/trackpoint.h b/drivers/input/mouse/trackpoint.h
index ecd0547964a5..5617ed3a7d7a 100644
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -70,6 +70,9 @@
70#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */ 70#define TP_UP_THRESH 0x5A /* Used to generate a 'click' on Z-axis */
71#define TP_Z_TIME 0x5E /* How sharp of a press */ 71#define TP_Z_TIME 0x5E /* How sharp of a press */
72#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */ 72#define TP_JENKS_CURV 0x5D /* Minimum curvature for double click */
73#define TP_DRIFT_TIME 0x5F /* How long a 'hands off' condition */
74 /* must last (x*107ms) for drift */
75 /* correction to occur */
73 76
74/* 77/*
75 * Toggling Flag bits 78 * Toggling Flag bits
@@ -120,6 +123,7 @@
120#define TP_DEF_UP_THRESH 0xFF 123#define TP_DEF_UP_THRESH 0xFF
121#define TP_DEF_Z_TIME 0x26 124#define TP_DEF_Z_TIME 0x26
122#define TP_DEF_JENKS_CURV 0x87 125#define TP_DEF_JENKS_CURV 0x87
126#define TP_DEF_DRIFT_TIME 0x05
123 127
124/* Toggles */ 128/* Toggles */
125#define TP_DEF_MB 0x00 129#define TP_DEF_MB 0x00
@@ -137,6 +141,7 @@ struct trackpoint_data
137 unsigned char draghys, mindrag; 141 unsigned char draghys, mindrag;
138 unsigned char thresh, upthresh; 142 unsigned char thresh, upthresh;
139 unsigned char ztime, jenks; 143 unsigned char ztime, jenks;
144 unsigned char drift_time;
140 145
141 /* toggles */ 146 /* toggles */
142 unsigned char press_to_select; 147 unsigned char press_to_select;
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index bb070206223c..95ee92a91bd2 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -99,13 +99,9 @@
99#define MXT_T6_STATUS_COMSERR (1 << 2) 99#define MXT_T6_STATUS_COMSERR (1 << 2)
100 100
101/* MXT_GEN_POWER_T7 field */ 101/* MXT_GEN_POWER_T7 field */
102struct t7_config { 102#define MXT_POWER_IDLEACQINT 0
103 u8 idle; 103#define MXT_POWER_ACTVACQINT 1
104 u8 active; 104#define MXT_POWER_ACTV2IDLETO 2
105} __packed;
106
107#define MXT_POWER_CFG_RUN 0
108#define MXT_POWER_CFG_DEEPSLEEP 1
109 105
110/* MXT_GEN_ACQUIRE_T8 field */ 106/* MXT_GEN_ACQUIRE_T8 field */
111#define MXT_ACQUIRE_CHRGTIME 0 107#define MXT_ACQUIRE_CHRGTIME 0
@@ -117,6 +113,7 @@ struct t7_config {
117#define MXT_ACQUIRE_ATCHCALSTHR 7 113#define MXT_ACQUIRE_ATCHCALSTHR 7
118 114
119/* MXT_TOUCH_MULTI_T9 field */ 115/* MXT_TOUCH_MULTI_T9 field */
116#define MXT_TOUCH_CTRL 0
120#define MXT_T9_ORIENT 9 117#define MXT_T9_ORIENT 9
121#define MXT_T9_RANGE 18 118#define MXT_T9_RANGE 18
122 119
@@ -256,7 +253,6 @@ struct mxt_data {
256 bool update_input; 253 bool update_input;
257 u8 last_message_count; 254 u8 last_message_count;
258 u8 num_touchids; 255 u8 num_touchids;
259 struct t7_config t7_cfg;
260 256
261 /* Cached parameters from object table */ 257 /* Cached parameters from object table */
262 u16 T5_address; 258 u16 T5_address;
@@ -672,6 +668,20 @@ static void mxt_proc_t6_messages(struct mxt_data *data, u8 *msg)
672 data->t6_status = status; 668 data->t6_status = status;
673} 669}
674 670
671static int mxt_write_object(struct mxt_data *data,
672 u8 type, u8 offset, u8 val)
673{
674 struct mxt_object *object;
675 u16 reg;
676
677 object = mxt_get_object(data, type);
678 if (!object || offset >= mxt_obj_size(object))
679 return -EINVAL;
680
681 reg = object->start_address;
682 return mxt_write_reg(data->client, reg + offset, val);
683}
684
675static void mxt_input_button(struct mxt_data *data, u8 *message) 685static void mxt_input_button(struct mxt_data *data, u8 *message)
676{ 686{
677 struct input_dev *input = data->input_dev; 687 struct input_dev *input = data->input_dev;
@@ -1742,60 +1752,6 @@ err_free_object_table:
1742 return error; 1752 return error;
1743} 1753}
1744 1754
1745static int mxt_set_t7_power_cfg(struct mxt_data *data, u8 sleep)
1746{
1747 struct device *dev = &data->client->dev;
1748 int error;
1749 struct t7_config *new_config;
1750 struct t7_config deepsleep = { .active = 0, .idle = 0 };
1751
1752 if (sleep == MXT_POWER_CFG_DEEPSLEEP)
1753 new_config = &deepsleep;
1754 else
1755 new_config = &data->t7_cfg;
1756
1757 error = __mxt_write_reg(data->client, data->T7_address,
1758 sizeof(data->t7_cfg), new_config);
1759 if (error)
1760 return error;
1761
1762 dev_dbg(dev, "Set T7 ACTV:%d IDLE:%d\n",
1763 new_config->active, new_config->idle);
1764
1765 return 0;
1766}
1767
1768static int mxt_init_t7_power_cfg(struct mxt_data *data)
1769{
1770 struct device *dev = &data->client->dev;
1771 int error;
1772 bool retry = false;
1773
1774recheck:
1775 error = __mxt_read_reg(data->client, data->T7_address,
1776 sizeof(data->t7_cfg), &data->t7_cfg);
1777 if (error)
1778 return error;
1779
1780 if (data->t7_cfg.active == 0 || data->t7_cfg.idle == 0) {
1781 if (!retry) {
1782 dev_dbg(dev, "T7 cfg zero, resetting\n");
1783 mxt_soft_reset(data);
1784 retry = true;
1785 goto recheck;
1786 } else {
1787 dev_dbg(dev, "T7 cfg zero after reset, overriding\n");
1788 data->t7_cfg.active = 20;
1789 data->t7_cfg.idle = 100;
1790 return mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN);
1791 }
1792 }
1793
1794 dev_dbg(dev, "Initialized power cfg: ACTV %d, IDLE %d\n",
1795 data->t7_cfg.active, data->t7_cfg.idle);
1796 return 0;
1797}
1798
1799static int mxt_configure_objects(struct mxt_data *data, 1755static int mxt_configure_objects(struct mxt_data *data,
1800 const struct firmware *cfg) 1756 const struct firmware *cfg)
1801{ 1757{
@@ -1809,12 +1765,6 @@ static int mxt_configure_objects(struct mxt_data *data,
1809 dev_warn(dev, "Error %d updating config\n", error); 1765 dev_warn(dev, "Error %d updating config\n", error);
1810 } 1766 }
1811 1767
1812 error = mxt_init_t7_power_cfg(data);
1813 if (error) {
1814 dev_err(dev, "Failed to initialize power cfg\n");
1815 return error;
1816 }
1817
1818 error = mxt_initialize_t9_input_device(data); 1768 error = mxt_initialize_t9_input_device(data);
1819 if (error) 1769 if (error)
1820 return error; 1770 return error;
@@ -2093,15 +2043,16 @@ static const struct attribute_group mxt_attr_group = {
2093 2043
2094static void mxt_start(struct mxt_data *data) 2044static void mxt_start(struct mxt_data *data)
2095{ 2045{
2096 mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN); 2046 /* Touch enable */
2097 2047 mxt_write_object(data,
2098 /* Recalibrate since chip has been in deep sleep */ 2048 MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0x83);
2099 mxt_t6_command(data, MXT_COMMAND_CALIBRATE, 1, false);
2100} 2049}
2101 2050
2102static void mxt_stop(struct mxt_data *data) 2051static void mxt_stop(struct mxt_data *data)
2103{ 2052{
2104 mxt_set_t7_power_cfg(data, MXT_POWER_CFG_DEEPSLEEP); 2053 /* Touch disable */
2054 mxt_write_object(data,
2055 MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0);
2105} 2056}
2106 2057
2107static int mxt_input_open(struct input_dev *dev) 2058static int mxt_input_open(struct input_dev *dev)
@@ -2266,6 +2217,8 @@ static int __maybe_unused mxt_resume(struct device *dev)
2266 struct mxt_data *data = i2c_get_clientdata(client); 2217 struct mxt_data *data = i2c_get_clientdata(client);
2267 struct input_dev *input_dev = data->input_dev; 2218 struct input_dev *input_dev = data->input_dev;
2268 2219
2220 mxt_soft_reset(data);
2221
2269 mutex_lock(&input_dev->mutex); 2222 mutex_lock(&input_dev->mutex);
2270 2223
2271 if (input_dev->users) 2224 if (input_dev->users)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 3793fcc7e5db..d4c24fb7704f 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -850,9 +850,11 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
850} 850}
851 851
852#define EDT_ATTR_CHECKSET(name, reg) \ 852#define EDT_ATTR_CHECKSET(name, reg) \
853do { \
853 if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \ 854 if (pdata->name >= edt_ft5x06_attr_##name.limit_low && \
854 pdata->name <= edt_ft5x06_attr_##name.limit_high) \ 855 pdata->name <= edt_ft5x06_attr_##name.limit_high) \
855 edt_ft5x06_register_write(tsdata, reg, pdata->name) 856 edt_ft5x06_register_write(tsdata, reg, pdata->name); \
857} while (0)
856 858
857#define EDT_GET_PROP(name, reg) { \ 859#define EDT_GET_PROP(name, reg) { \
858 u32 val; \ 860 u32 val; \
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 1232336b960e..40dfbc0444c0 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4029,14 +4029,6 @@ static int device_notifier(struct notifier_block *nb,
4029 if (action != BUS_NOTIFY_REMOVED_DEVICE) 4029 if (action != BUS_NOTIFY_REMOVED_DEVICE)
4030 return 0; 4030 return 0;
4031 4031
4032 /*
4033 * If the device is still attached to a device driver we can't
4034 * tear down the domain yet as DMA mappings may still be in use.
4035 * Wait for the BUS_NOTIFY_UNBOUND_DRIVER event to do that.
4036 */
4037 if (action == BUS_NOTIFY_DEL_DEVICE && dev->driver != NULL)
4038 return 0;
4039
4040 domain = find_domain(dev); 4032 domain = find_domain(dev);
4041 if (!domain) 4033 if (!domain)
4042 return 0; 4034 return 0;
@@ -4428,6 +4420,10 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
4428 domain_remove_one_dev_info(old_domain, dev); 4420 domain_remove_one_dev_info(old_domain, dev);
4429 else 4421 else
4430 domain_remove_dev_info(old_domain); 4422 domain_remove_dev_info(old_domain);
4423
4424 if (!domain_type_is_vm_or_si(old_domain) &&
4425 list_empty(&old_domain->devices))
4426 domain_exit(old_domain);
4431 } 4427 }
4432 } 4428 }
4433 4429
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 68dfb0fd5ee9..748693192c20 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -558,7 +558,7 @@ static pmd_t *ipmmu_alloc_pmd(struct ipmmu_vmsa_device *mmu, pgd_t *pgd,
558 558
559static u64 ipmmu_page_prot(unsigned int prot, u64 type) 559static u64 ipmmu_page_prot(unsigned int prot, u64 type)
560{ 560{
561 u64 pgprot = ARM_VMSA_PTE_XN | ARM_VMSA_PTE_nG | ARM_VMSA_PTE_AF 561 u64 pgprot = ARM_VMSA_PTE_nG | ARM_VMSA_PTE_AF
562 | ARM_VMSA_PTE_SH_IS | ARM_VMSA_PTE_AP_UNPRIV 562 | ARM_VMSA_PTE_SH_IS | ARM_VMSA_PTE_AP_UNPRIV
563 | ARM_VMSA_PTE_NS | type; 563 | ARM_VMSA_PTE_NS | type;
564 564
@@ -568,8 +568,8 @@ static u64 ipmmu_page_prot(unsigned int prot, u64 type)
568 if (prot & IOMMU_CACHE) 568 if (prot & IOMMU_CACHE)
569 pgprot |= IMMAIR_ATTR_IDX_WBRWA << ARM_VMSA_PTE_ATTRINDX_SHIFT; 569 pgprot |= IMMAIR_ATTR_IDX_WBRWA << ARM_VMSA_PTE_ATTRINDX_SHIFT;
570 570
571 if (prot & IOMMU_EXEC) 571 if (prot & IOMMU_NOEXEC)
572 pgprot &= ~ARM_VMSA_PTE_XN; 572 pgprot |= ARM_VMSA_PTE_XN;
573 else if (!(prot & (IOMMU_READ | IOMMU_WRITE))) 573 else if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
574 /* If no access create a faulting entry to avoid TLB fills. */ 574 /* If no access create a faulting entry to avoid TLB fills. */
575 pgprot &= ~ARM_VMSA_PTE_PAGE; 575 pgprot &= ~ARM_VMSA_PTE_PAGE;
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index b2023af384b9..6a8b1ec4a48a 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1009,7 +1009,6 @@ static struct platform_driver rk_iommu_driver = {
1009 .remove = rk_iommu_remove, 1009 .remove = rk_iommu_remove,
1010 .driver = { 1010 .driver = {
1011 .name = "rk_iommu", 1011 .name = "rk_iommu",
1012 .owner = THIS_MODULE,
1013 .of_match_table = of_match_ptr(rk_iommu_dt_ids), 1012 .of_match_table = of_match_ptr(rk_iommu_dt_ids),
1014 }, 1013 },
1015}; 1014};
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 8735543eacdb..493478989dbd 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1127,6 +1127,24 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block,
1127 schedule_zero(tc, virt_block, data_dest, cell, bio); 1127 schedule_zero(tc, virt_block, data_dest, cell, bio);
1128} 1128}
1129 1129
1130static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
1131
1132static void check_for_space(struct pool *pool)
1133{
1134 int r;
1135 dm_block_t nr_free;
1136
1137 if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE)
1138 return;
1139
1140 r = dm_pool_get_free_block_count(pool->pmd, &nr_free);
1141 if (r)
1142 return;
1143
1144 if (nr_free)
1145 set_pool_mode(pool, PM_WRITE);
1146}
1147
1130/* 1148/*
1131 * A non-zero return indicates read_only or fail_io mode. 1149 * A non-zero return indicates read_only or fail_io mode.
1132 * Many callers don't care about the return value. 1150 * Many callers don't care about the return value.
@@ -1141,6 +1159,8 @@ static int commit(struct pool *pool)
1141 r = dm_pool_commit_metadata(pool->pmd); 1159 r = dm_pool_commit_metadata(pool->pmd);
1142 if (r) 1160 if (r)
1143 metadata_operation_failed(pool, "dm_pool_commit_metadata", r); 1161 metadata_operation_failed(pool, "dm_pool_commit_metadata", r);
1162 else
1163 check_for_space(pool);
1144 1164
1145 return r; 1165 return r;
1146} 1166}
@@ -1159,8 +1179,6 @@ static void check_low_water_mark(struct pool *pool, dm_block_t free_blocks)
1159 } 1179 }
1160} 1180}
1161 1181
1162static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
1163
1164static int alloc_data_block(struct thin_c *tc, dm_block_t *result) 1182static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
1165{ 1183{
1166 int r; 1184 int r;
@@ -2155,7 +2173,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
2155 pool->process_cell = process_cell_read_only; 2173 pool->process_cell = process_cell_read_only;
2156 pool->process_discard_cell = process_discard_cell; 2174 pool->process_discard_cell = process_discard_cell;
2157 pool->process_prepared_mapping = process_prepared_mapping; 2175 pool->process_prepared_mapping = process_prepared_mapping;
2158 pool->process_prepared_discard = process_prepared_discard_passdown; 2176 pool->process_prepared_discard = process_prepared_discard;
2159 2177
2160 if (!pool->pf.error_if_no_space && no_space_timeout) 2178 if (!pool->pf.error_if_no_space && no_space_timeout)
2161 queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout); 2179 queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout);
@@ -3814,6 +3832,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
3814 r = -EINVAL; 3832 r = -EINVAL;
3815 goto bad; 3833 goto bad;
3816 } 3834 }
3835 atomic_set(&tc->refcount, 1);
3836 init_completion(&tc->can_destroy);
3817 list_add_tail_rcu(&tc->list, &tc->pool->active_thins); 3837 list_add_tail_rcu(&tc->list, &tc->pool->active_thins);
3818 spin_unlock_irqrestore(&tc->pool->lock, flags); 3838 spin_unlock_irqrestore(&tc->pool->lock, flags);
3819 /* 3839 /*
@@ -3826,9 +3846,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
3826 3846
3827 dm_put(pool_md); 3847 dm_put(pool_md);
3828 3848
3829 atomic_set(&tc->refcount, 1);
3830 init_completion(&tc->can_destroy);
3831
3832 return 0; 3849 return 0;
3833 3850
3834bad: 3851bad:
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 4c06585bf165..b98cd9d84435 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -899,7 +899,7 @@ static void disable_write_same(struct mapped_device *md)
899 899
900static void clone_endio(struct bio *bio, int error) 900static void clone_endio(struct bio *bio, int error)
901{ 901{
902 int r = 0; 902 int r = error;
903 struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); 903 struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
904 struct dm_io *io = tio->io; 904 struct dm_io *io = tio->io;
905 struct mapped_device *md = tio->io->md; 905 struct mapped_device *md = tio->io->md;
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index e2f9df1c0c36..2d7fae94c861 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -519,6 +519,7 @@ static const u8 stmpe1601_regs[] = {
519 [STMPE_IDX_GPDR_LSB] = STMPE1601_REG_GPIO_SET_DIR_LSB, 519 [STMPE_IDX_GPDR_LSB] = STMPE1601_REG_GPIO_SET_DIR_LSB,
520 [STMPE_IDX_GPRER_LSB] = STMPE1601_REG_GPIO_RE_LSB, 520 [STMPE_IDX_GPRER_LSB] = STMPE1601_REG_GPIO_RE_LSB,
521 [STMPE_IDX_GPFER_LSB] = STMPE1601_REG_GPIO_FE_LSB, 521 [STMPE_IDX_GPFER_LSB] = STMPE1601_REG_GPIO_FE_LSB,
522 [STMPE_IDX_GPPUR_LSB] = STMPE1601_REG_GPIO_PU_LSB,
522 [STMPE_IDX_GPAFR_U_MSB] = STMPE1601_REG_GPIO_AF_U_MSB, 523 [STMPE_IDX_GPAFR_U_MSB] = STMPE1601_REG_GPIO_AF_U_MSB,
523 [STMPE_IDX_IEGPIOR_LSB] = STMPE1601_REG_INT_EN_GPIO_MASK_LSB, 524 [STMPE_IDX_IEGPIOR_LSB] = STMPE1601_REG_INT_EN_GPIO_MASK_LSB,
524 [STMPE_IDX_ISGPIOR_MSB] = STMPE1601_REG_INT_STA_GPIO_MSB, 525 [STMPE_IDX_ISGPIOR_MSB] = STMPE1601_REG_INT_STA_GPIO_MSB,
@@ -667,6 +668,7 @@ static const u8 stmpe1801_regs[] = {
667 [STMPE_IDX_GPDR_LSB] = STMPE1801_REG_GPIO_SET_DIR_LOW, 668 [STMPE_IDX_GPDR_LSB] = STMPE1801_REG_GPIO_SET_DIR_LOW,
668 [STMPE_IDX_GPRER_LSB] = STMPE1801_REG_GPIO_RE_LOW, 669 [STMPE_IDX_GPRER_LSB] = STMPE1801_REG_GPIO_RE_LOW,
669 [STMPE_IDX_GPFER_LSB] = STMPE1801_REG_GPIO_FE_LOW, 670 [STMPE_IDX_GPFER_LSB] = STMPE1801_REG_GPIO_FE_LOW,
671 [STMPE_IDX_GPPUR_LSB] = STMPE1801_REG_GPIO_PULL_UP_LOW,
670 [STMPE_IDX_IEGPIOR_LSB] = STMPE1801_REG_INT_EN_GPIO_MASK_LOW, 672 [STMPE_IDX_IEGPIOR_LSB] = STMPE1801_REG_INT_EN_GPIO_MASK_LOW,
671 [STMPE_IDX_ISGPIOR_LSB] = STMPE1801_REG_INT_STA_GPIO_LOW, 673 [STMPE_IDX_ISGPIOR_LSB] = STMPE1801_REG_INT_STA_GPIO_LOW,
672}; 674};
@@ -750,6 +752,8 @@ static const u8 stmpe24xx_regs[] = {
750 [STMPE_IDX_GPDR_LSB] = STMPE24XX_REG_GPDR_LSB, 752 [STMPE_IDX_GPDR_LSB] = STMPE24XX_REG_GPDR_LSB,
751 [STMPE_IDX_GPRER_LSB] = STMPE24XX_REG_GPRER_LSB, 753 [STMPE_IDX_GPRER_LSB] = STMPE24XX_REG_GPRER_LSB,
752 [STMPE_IDX_GPFER_LSB] = STMPE24XX_REG_GPFER_LSB, 754 [STMPE_IDX_GPFER_LSB] = STMPE24XX_REG_GPFER_LSB,
755 [STMPE_IDX_GPPUR_LSB] = STMPE24XX_REG_GPPUR_LSB,
756 [STMPE_IDX_GPPDR_LSB] = STMPE24XX_REG_GPPDR_LSB,
753 [STMPE_IDX_GPAFR_U_MSB] = STMPE24XX_REG_GPAFR_U_MSB, 757 [STMPE_IDX_GPAFR_U_MSB] = STMPE24XX_REG_GPAFR_U_MSB,
754 [STMPE_IDX_IEGPIOR_LSB] = STMPE24XX_REG_IEGPIOR_LSB, 758 [STMPE_IDX_IEGPIOR_LSB] = STMPE24XX_REG_IEGPIOR_LSB,
755 [STMPE_IDX_ISGPIOR_MSB] = STMPE24XX_REG_ISGPIOR_MSB, 759 [STMPE_IDX_ISGPIOR_MSB] = STMPE24XX_REG_ISGPIOR_MSB,
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index bee0abf82040..84adb46b3e2f 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -188,6 +188,7 @@ int stmpe_remove(struct stmpe *stmpe);
188#define STMPE1601_REG_GPIO_ED_MSB 0x8A 188#define STMPE1601_REG_GPIO_ED_MSB 0x8A
189#define STMPE1601_REG_GPIO_RE_LSB 0x8D 189#define STMPE1601_REG_GPIO_RE_LSB 0x8D
190#define STMPE1601_REG_GPIO_FE_LSB 0x8F 190#define STMPE1601_REG_GPIO_FE_LSB 0x8F
191#define STMPE1601_REG_GPIO_PU_LSB 0x91
191#define STMPE1601_REG_GPIO_AF_U_MSB 0x92 192#define STMPE1601_REG_GPIO_AF_U_MSB 0x92
192 193
193#define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3) 194#define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3)
@@ -276,6 +277,8 @@ int stmpe_remove(struct stmpe *stmpe);
276#define STMPE24XX_REG_GPEDR_MSB 0x8C 277#define STMPE24XX_REG_GPEDR_MSB 0x8C
277#define STMPE24XX_REG_GPRER_LSB 0x91 278#define STMPE24XX_REG_GPRER_LSB 0x91
278#define STMPE24XX_REG_GPFER_LSB 0x94 279#define STMPE24XX_REG_GPFER_LSB 0x94
280#define STMPE24XX_REG_GPPUR_LSB 0x97
281#define STMPE24XX_REG_GPPDR_LSB 0x9a
279#define STMPE24XX_REG_GPAFR_U_MSB 0x9B 282#define STMPE24XX_REG_GPAFR_U_MSB 0x9B
280 283
281#define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3) 284#define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 02ad79229f65..7466ce098e60 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -886,7 +886,7 @@ static int mmc_select_bus_width(struct mmc_card *card)
886 unsigned idx, bus_width = 0; 886 unsigned idx, bus_width = 0;
887 int err = 0; 887 int err = 0;
888 888
889 if (!mmc_can_ext_csd(card) && 889 if (!mmc_can_ext_csd(card) ||
890 !(host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) 890 !(host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA)))
891 return 0; 891 return 0;
892 892
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 184c434ae305..0dceba1a2ba1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1648,7 +1648,7 @@ static int __bond_release_one(struct net_device *bond_dev,
1648 /* slave is not a slave or master is not master of this slave */ 1648 /* slave is not a slave or master is not master of this slave */
1649 if (!(slave_dev->flags & IFF_SLAVE) || 1649 if (!(slave_dev->flags & IFF_SLAVE) ||
1650 !netdev_has_upper_dev(slave_dev, bond_dev)) { 1650 !netdev_has_upper_dev(slave_dev, bond_dev)) {
1651 netdev_err(bond_dev, "cannot release %s\n", 1651 netdev_dbg(bond_dev, "cannot release %s\n",
1652 slave_dev->name); 1652 slave_dev->name);
1653 return -EINVAL; 1653 return -EINVAL;
1654 } 1654 }
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index a5fefb9059c5..b306210b02b7 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -257,7 +257,6 @@ static int cfv_rx_poll(struct napi_struct *napi, int quota)
257 struct vringh_kiov *riov = &cfv->ctx.riov; 257 struct vringh_kiov *riov = &cfv->ctx.riov;
258 unsigned int skb_len; 258 unsigned int skb_len;
259 259
260again:
261 do { 260 do {
262 skb = NULL; 261 skb = NULL;
263 262
@@ -322,7 +321,6 @@ exit:
322 napi_schedule_prep(napi)) { 321 napi_schedule_prep(napi)) {
323 vringh_notify_disable_kern(cfv->vr_rx); 322 vringh_notify_disable_kern(cfv->vr_rx);
324 __napi_schedule(napi); 323 __napi_schedule(napi);
325 goto again;
326 } 324 }
327 break; 325 break;
328 326
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c
index 89c8d9fc97de..57e97910c728 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -246,13 +246,13 @@ static int ne2k_pci_init_one(struct pci_dev *pdev,
246 246
247 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) { 247 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) {
248 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n"); 248 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n");
249 return -ENODEV; 249 goto err_out;
250 } 250 }
251 251
252 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) { 252 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) {
253 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n", 253 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n",
254 NE_IO_EXTENT, ioaddr); 254 NE_IO_EXTENT, ioaddr);
255 return -EBUSY; 255 goto err_out;
256 } 256 }
257 257
258 reg0 = inb(ioaddr); 258 reg0 = inb(ioaddr);
@@ -392,6 +392,8 @@ err_out_free_netdev:
392 free_netdev (dev); 392 free_netdev (dev);
393err_out_free_res: 393err_out_free_res:
394 release_region (ioaddr, NE_IO_EXTENT); 394 release_region (ioaddr, NE_IO_EXTENT);
395err_out:
396 pci_disable_device(pdev);
395 return -ENODEV; 397 return -ENODEV;
396} 398}
397 399
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index df76050d0a9d..eadcb053807e 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -156,18 +156,6 @@ source "drivers/net/ethernet/realtek/Kconfig"
156source "drivers/net/ethernet/renesas/Kconfig" 156source "drivers/net/ethernet/renesas/Kconfig"
157source "drivers/net/ethernet/rdc/Kconfig" 157source "drivers/net/ethernet/rdc/Kconfig"
158source "drivers/net/ethernet/rocker/Kconfig" 158source "drivers/net/ethernet/rocker/Kconfig"
159
160config S6GMAC
161 tristate "S6105 GMAC ethernet support"
162 depends on XTENSA_VARIANT_S6000
163 select PHYLIB
164 ---help---
165 This driver supports the on chip ethernet device on the
166 S6105 xtensa processor.
167
168 To compile this driver as a module, choose M here. The module
169 will be called s6gmac.
170
171source "drivers/net/ethernet/samsung/Kconfig" 159source "drivers/net/ethernet/samsung/Kconfig"
172source "drivers/net/ethernet/seeq/Kconfig" 160source "drivers/net/ethernet/seeq/Kconfig"
173source "drivers/net/ethernet/silan/Kconfig" 161source "drivers/net/ethernet/silan/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index bf56f8b36e90..1367afcd0a8b 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -66,7 +66,6 @@ obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/
66obj-$(CONFIG_SH_ETH) += renesas/ 66obj-$(CONFIG_SH_ETH) += renesas/
67obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ 67obj-$(CONFIG_NET_VENDOR_RDC) += rdc/
68obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/ 68obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/
69obj-$(CONFIG_S6GMAC) += s6gmac.o
70obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/ 69obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/
71obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/ 70obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/
72obj-$(CONFIG_NET_VENDOR_SILAN) += silan/ 71obj-$(CONFIG_NET_VENDOR_SILAN) += silan/
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 1fcd5568a352..f3470d96837a 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -850,8 +850,10 @@ static int emac_probe(struct platform_device *pdev)
850 } 850 }
851 851
852 db->clk = devm_clk_get(&pdev->dev, NULL); 852 db->clk = devm_clk_get(&pdev->dev, NULL);
853 if (IS_ERR(db->clk)) 853 if (IS_ERR(db->clk)) {
854 ret = PTR_ERR(db->clk);
854 goto out; 855 goto out;
856 }
855 857
856 clk_prepare_enable(db->clk); 858 clk_prepare_enable(db->clk);
857 859
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 3498760dc22a..760c72c6e2ac 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -1170,10 +1170,6 @@ tx_request_irq_error:
1170init_error: 1170init_error:
1171 free_skbufs(dev); 1171 free_skbufs(dev);
1172alloc_skbuf_error: 1172alloc_skbuf_error:
1173 if (priv->phydev) {
1174 phy_disconnect(priv->phydev);
1175 priv->phydev = NULL;
1176 }
1177phy_error: 1173phy_error:
1178 return ret; 1174 return ret;
1179} 1175}
@@ -1186,12 +1182,9 @@ static int tse_shutdown(struct net_device *dev)
1186 int ret; 1182 int ret;
1187 unsigned long int flags; 1183 unsigned long int flags;
1188 1184
1189 /* Stop and disconnect the PHY */ 1185 /* Stop the PHY */
1190 if (priv->phydev) { 1186 if (priv->phydev)
1191 phy_stop(priv->phydev); 1187 phy_stop(priv->phydev);
1192 phy_disconnect(priv->phydev);
1193 priv->phydev = NULL;
1194 }
1195 1188
1196 netif_stop_queue(dev); 1189 netif_stop_queue(dev);
1197 napi_disable(&priv->napi); 1190 napi_disable(&priv->napi);
@@ -1525,6 +1518,10 @@ err_free_netdev:
1525static int altera_tse_remove(struct platform_device *pdev) 1518static int altera_tse_remove(struct platform_device *pdev)
1526{ 1519{
1527 struct net_device *ndev = platform_get_drvdata(pdev); 1520 struct net_device *ndev = platform_get_drvdata(pdev);
1521 struct altera_tse_private *priv = netdev_priv(ndev);
1522
1523 if (priv->phydev)
1524 phy_disconnect(priv->phydev);
1528 1525
1529 platform_set_drvdata(pdev, NULL); 1526 platform_set_drvdata(pdev, NULL);
1530 altera_tse_mdio_destroy(ndev); 1527 altera_tse_mdio_destroy(ndev);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 9f5e38769a29..72eef9fc883e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12553,9 +12553,11 @@ static int bnx2x_get_phys_port_id(struct net_device *netdev,
12553 return 0; 12553 return 0;
12554} 12554}
12555 12555
12556static bool bnx2x_gso_check(struct sk_buff *skb, struct net_device *dev) 12556static netdev_features_t bnx2x_features_check(struct sk_buff *skb,
12557 struct net_device *dev,
12558 netdev_features_t features)
12557{ 12559{
12558 return vxlan_gso_check(skb); 12560 return vxlan_features_check(skb, features);
12559} 12561}
12560 12562
12561static const struct net_device_ops bnx2x_netdev_ops = { 12563static const struct net_device_ops bnx2x_netdev_ops = {
@@ -12589,7 +12591,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {
12589#endif 12591#endif
12590 .ndo_get_phys_port_id = bnx2x_get_phys_port_id, 12592 .ndo_get_phys_port_id = bnx2x_get_phys_port_id,
12591 .ndo_set_vf_link_state = bnx2x_set_vf_link_state, 12593 .ndo_set_vf_link_state = bnx2x_set_vf_link_state,
12592 .ndo_gso_check = bnx2x_gso_check, 12594 .ndo_features_check = bnx2x_features_check,
12593}; 12595};
12594 12596
12595static int bnx2x_set_coherency_mask(struct bnx2x *bp) 12597static int bnx2x_set_coherency_mask(struct bnx2x *bp)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index bb48a610b72a..553dcd8a9df2 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -17800,23 +17800,6 @@ static int tg3_init_one(struct pci_dev *pdev,
17800 goto err_out_apeunmap; 17800 goto err_out_apeunmap;
17801 } 17801 }
17802 17802
17803 /*
17804 * Reset chip in case UNDI or EFI driver did not shutdown
17805 * DMA self test will enable WDMAC and we'll see (spurious)
17806 * pending DMA on the PCI bus at that point.
17807 */
17808 if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) ||
17809 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
17810 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
17811 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
17812 }
17813
17814 err = tg3_test_dma(tp);
17815 if (err) {
17816 dev_err(&pdev->dev, "DMA engine test failed, aborting\n");
17817 goto err_out_apeunmap;
17818 }
17819
17820 intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW; 17803 intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW;
17821 rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW; 17804 rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW;
17822 sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW; 17805 sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW;
@@ -17861,6 +17844,23 @@ static int tg3_init_one(struct pci_dev *pdev,
17861 sndmbx += 0xc; 17844 sndmbx += 0xc;
17862 } 17845 }
17863 17846
17847 /*
17848 * Reset chip in case UNDI or EFI driver did not shutdown
17849 * DMA self test will enable WDMAC and we'll see (spurious)
17850 * pending DMA on the PCI bus at that point.
17851 */
17852 if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) ||
17853 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
17854 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
17855 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
17856 }
17857
17858 err = tg3_test_dma(tp);
17859 if (err) {
17860 dev_err(&pdev->dev, "DMA engine test failed, aborting\n");
17861 goto err_out_apeunmap;
17862 }
17863
17864 tg3_init_coal(tp); 17864 tg3_init_coal(tp);
17865 17865
17866 pci_set_drvdata(pdev, dev); 17866 pci_set_drvdata(pdev, dev);
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 7d6aa8c87df8..619083a860a4 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -172,7 +172,7 @@ bnad_get_debug_drvinfo(struct bnad *bnad, void *buffer, u32 len)
172 172
173 /* Retrieve flash partition info */ 173 /* Retrieve flash partition info */
174 fcomp.comp_status = 0; 174 fcomp.comp_status = 0;
175 init_completion(&fcomp.comp); 175 reinit_completion(&fcomp.comp);
176 spin_lock_irqsave(&bnad->bna_lock, flags); 176 spin_lock_irqsave(&bnad->bna_lock, flags);
177 ret = bfa_nw_flash_get_attr(&bnad->bna.flash, &drvinfo->flash_attr, 177 ret = bfa_nw_flash_get_attr(&bnad->bna.flash, &drvinfo->flash_attr,
178 bnad_cb_completion, &fcomp); 178 bnad_cb_completion, &fcomp);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
index d00a751f0588..6049f70e110c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
@@ -96,6 +96,9 @@ struct port_info {
96 s16 xact_addr_filt; /* index of our MAC address filter */ 96 s16 xact_addr_filt; /* index of our MAC address filter */
97 u16 rss_size; /* size of VI's RSS table slice */ 97 u16 rss_size; /* size of VI's RSS table slice */
98 u8 pidx; /* index into adapter port[] */ 98 u8 pidx; /* index into adapter port[] */
99 s8 mdio_addr;
100 u8 port_type; /* firmware port type */
101 u8 mod_type; /* firmware module type */
99 u8 port_id; /* physical port ID */ 102 u8 port_id; /* physical port ID */
100 u8 nqsets; /* # of "Queue Sets" */ 103 u8 nqsets; /* # of "Queue Sets" */
101 u8 first_qset; /* index of first "Queue Set" */ 104 u8 first_qset; /* index of first "Queue Set" */
@@ -522,6 +525,7 @@ static inline struct adapter *netdev2adap(const struct net_device *dev)
522 * is "contracted" to provide for the common code. 525 * is "contracted" to provide for the common code.
523 */ 526 */
524void t4vf_os_link_changed(struct adapter *, int, int); 527void t4vf_os_link_changed(struct adapter *, int, int);
528void t4vf_os_portmod_changed(struct adapter *, int);
525 529
526/* 530/*
527 * SGE function prototype declarations. 531 * SGE function prototype declarations.
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index aa74ec34a467..2215d432a059 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -44,6 +44,7 @@
44#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
45#include <linux/debugfs.h> 45#include <linux/debugfs.h>
46#include <linux/ethtool.h> 46#include <linux/ethtool.h>
47#include <linux/mdio.h>
47 48
48#include "t4vf_common.h" 49#include "t4vf_common.h"
49#include "t4vf_defs.h" 50#include "t4vf_defs.h"
@@ -210,6 +211,38 @@ void t4vf_os_link_changed(struct adapter *adapter, int pidx, int link_ok)
210} 211}
211 212
212/* 213/*
214 * THe port module type has changed on the indicated "port" (Virtual
215 * Interface).
216 */
217void t4vf_os_portmod_changed(struct adapter *adapter, int pidx)
218{
219 static const char * const mod_str[] = {
220 NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM"
221 };
222 const struct net_device *dev = adapter->port[pidx];
223 const struct port_info *pi = netdev_priv(dev);
224
225 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
226 dev_info(adapter->pdev_dev, "%s: port module unplugged\n",
227 dev->name);
228 else if (pi->mod_type < ARRAY_SIZE(mod_str))
229 dev_info(adapter->pdev_dev, "%s: %s port module inserted\n",
230 dev->name, mod_str[pi->mod_type]);
231 else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED)
232 dev_info(adapter->pdev_dev, "%s: unsupported optical port "
233 "module inserted\n", dev->name);
234 else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN)
235 dev_info(adapter->pdev_dev, "%s: unknown port module inserted,"
236 "forcing TWINAX\n", dev->name);
237 else if (pi->mod_type == FW_PORT_MOD_TYPE_ERROR)
238 dev_info(adapter->pdev_dev, "%s: transceiver module error\n",
239 dev->name);
240 else
241 dev_info(adapter->pdev_dev, "%s: unknown module type %d "
242 "inserted\n", dev->name, pi->mod_type);
243}
244
245/*
213 * Net device operations. 246 * Net device operations.
214 * ====================== 247 * ======================
215 */ 248 */
@@ -1193,24 +1226,103 @@ static void cxgb4vf_poll_controller(struct net_device *dev)
1193 * state of the port to which we're linked. 1226 * state of the port to which we're linked.
1194 */ 1227 */
1195 1228
1196/* 1229static unsigned int t4vf_from_fw_linkcaps(enum fw_port_type type,
1197 * Return current port link settings. 1230 unsigned int caps)
1198 */ 1231{
1199static int cxgb4vf_get_settings(struct net_device *dev, 1232 unsigned int v = 0;
1200 struct ethtool_cmd *cmd) 1233
1201{ 1234 if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XFI ||
1202 const struct port_info *pi = netdev_priv(dev); 1235 type == FW_PORT_TYPE_BT_XAUI) {
1236 v |= SUPPORTED_TP;
1237 if (caps & FW_PORT_CAP_SPEED_100M)
1238 v |= SUPPORTED_100baseT_Full;
1239 if (caps & FW_PORT_CAP_SPEED_1G)
1240 v |= SUPPORTED_1000baseT_Full;
1241 if (caps & FW_PORT_CAP_SPEED_10G)
1242 v |= SUPPORTED_10000baseT_Full;
1243 } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
1244 v |= SUPPORTED_Backplane;
1245 if (caps & FW_PORT_CAP_SPEED_1G)
1246 v |= SUPPORTED_1000baseKX_Full;
1247 if (caps & FW_PORT_CAP_SPEED_10G)
1248 v |= SUPPORTED_10000baseKX4_Full;
1249 } else if (type == FW_PORT_TYPE_KR)
1250 v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
1251 else if (type == FW_PORT_TYPE_BP_AP)
1252 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
1253 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full;
1254 else if (type == FW_PORT_TYPE_BP4_AP)
1255 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
1256 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full |
1257 SUPPORTED_10000baseKX4_Full;
1258 else if (type == FW_PORT_TYPE_FIBER_XFI ||
1259 type == FW_PORT_TYPE_FIBER_XAUI ||
1260 type == FW_PORT_TYPE_SFP ||
1261 type == FW_PORT_TYPE_QSFP_10G ||
1262 type == FW_PORT_TYPE_QSA) {
1263 v |= SUPPORTED_FIBRE;
1264 if (caps & FW_PORT_CAP_SPEED_1G)
1265 v |= SUPPORTED_1000baseT_Full;
1266 if (caps & FW_PORT_CAP_SPEED_10G)
1267 v |= SUPPORTED_10000baseT_Full;
1268 } else if (type == FW_PORT_TYPE_BP40_BA ||
1269 type == FW_PORT_TYPE_QSFP) {
1270 v |= SUPPORTED_40000baseSR4_Full;
1271 v |= SUPPORTED_FIBRE;
1272 }
1273
1274 if (caps & FW_PORT_CAP_ANEG)
1275 v |= SUPPORTED_Autoneg;
1276 return v;
1277}
1278
1279static int cxgb4vf_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1280{
1281 const struct port_info *p = netdev_priv(dev);
1282
1283 if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
1284 p->port_type == FW_PORT_TYPE_BT_XFI ||
1285 p->port_type == FW_PORT_TYPE_BT_XAUI)
1286 cmd->port = PORT_TP;
1287 else if (p->port_type == FW_PORT_TYPE_FIBER_XFI ||
1288 p->port_type == FW_PORT_TYPE_FIBER_XAUI)
1289 cmd->port = PORT_FIBRE;
1290 else if (p->port_type == FW_PORT_TYPE_SFP ||
1291 p->port_type == FW_PORT_TYPE_QSFP_10G ||
1292 p->port_type == FW_PORT_TYPE_QSA ||
1293 p->port_type == FW_PORT_TYPE_QSFP) {
1294 if (p->mod_type == FW_PORT_MOD_TYPE_LR ||
1295 p->mod_type == FW_PORT_MOD_TYPE_SR ||
1296 p->mod_type == FW_PORT_MOD_TYPE_ER ||
1297 p->mod_type == FW_PORT_MOD_TYPE_LRM)
1298 cmd->port = PORT_FIBRE;
1299 else if (p->mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
1300 p->mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE)
1301 cmd->port = PORT_DA;
1302 else
1303 cmd->port = PORT_OTHER;
1304 } else
1305 cmd->port = PORT_OTHER;
1203 1306
1204 cmd->supported = pi->link_cfg.supported; 1307 if (p->mdio_addr >= 0) {
1205 cmd->advertising = pi->link_cfg.advertising; 1308 cmd->phy_address = p->mdio_addr;
1309 cmd->transceiver = XCVR_EXTERNAL;
1310 cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
1311 MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
1312 } else {
1313 cmd->phy_address = 0; /* not really, but no better option */
1314 cmd->transceiver = XCVR_INTERNAL;
1315 cmd->mdio_support = 0;
1316 }
1317
1318 cmd->supported = t4vf_from_fw_linkcaps(p->port_type,
1319 p->link_cfg.supported);
1320 cmd->advertising = t4vf_from_fw_linkcaps(p->port_type,
1321 p->link_cfg.advertising);
1206 ethtool_cmd_speed_set(cmd, 1322 ethtool_cmd_speed_set(cmd,
1207 netif_carrier_ok(dev) ? pi->link_cfg.speed : -1); 1323 netif_carrier_ok(dev) ? p->link_cfg.speed : 0);
1208 cmd->duplex = DUPLEX_FULL; 1324 cmd->duplex = DUPLEX_FULL;
1209 1325 cmd->autoneg = p->link_cfg.autoneg;
1210 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
1211 cmd->phy_address = pi->port_id;
1212 cmd->transceiver = XCVR_EXTERNAL;
1213 cmd->autoneg = pi->link_cfg.autoneg;
1214 cmd->maxtxpkt = 0; 1326 cmd->maxtxpkt = 0;
1215 cmd->maxrxpkt = 0; 1327 cmd->maxrxpkt = 0;
1216 return 0; 1328 return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
index 8d3237f5e364..b9debb4f29a3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
@@ -230,7 +230,7 @@ struct adapter_params {
230 230
231static inline bool is_10g_port(const struct link_config *lc) 231static inline bool is_10g_port(const struct link_config *lc)
232{ 232{
233 return (lc->supported & SUPPORTED_10000baseT_Full) != 0; 233 return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
234} 234}
235 235
236static inline bool is_x_10g_port(const struct link_config *lc) 236static inline bool is_x_10g_port(const struct link_config *lc)
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 02e8833b7797..21dc9a20308c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -245,6 +245,10 @@ static int hash_mac_addr(const u8 *addr)
245 return a & 0x3f; 245 return a & 0x3f;
246} 246}
247 247
248#define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
249 FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \
250 FW_PORT_CAP_SPEED_100G | FW_PORT_CAP_ANEG)
251
248/** 252/**
249 * init_link_config - initialize a link's SW state 253 * init_link_config - initialize a link's SW state
250 * @lc: structure holding the link state 254 * @lc: structure holding the link state
@@ -259,8 +263,8 @@ static void init_link_config(struct link_config *lc, unsigned int caps)
259 lc->requested_speed = 0; 263 lc->requested_speed = 0;
260 lc->speed = 0; 264 lc->speed = 0;
261 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX; 265 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX;
262 if (lc->supported & SUPPORTED_Autoneg) { 266 if (lc->supported & FW_PORT_CAP_ANEG) {
263 lc->advertising = lc->supported; 267 lc->advertising = lc->supported & ADVERT_MASK;
264 lc->autoneg = AUTONEG_ENABLE; 268 lc->autoneg = AUTONEG_ENABLE;
265 lc->requested_fc |= PAUSE_AUTONEG; 269 lc->requested_fc |= PAUSE_AUTONEG;
266 } else { 270 } else {
@@ -280,7 +284,6 @@ int t4vf_port_init(struct adapter *adapter, int pidx)
280 struct fw_vi_cmd vi_cmd, vi_rpl; 284 struct fw_vi_cmd vi_cmd, vi_rpl;
281 struct fw_port_cmd port_cmd, port_rpl; 285 struct fw_port_cmd port_cmd, port_rpl;
282 int v; 286 int v;
283 u32 word;
284 287
285 /* 288 /*
286 * Execute a VI Read command to get our Virtual Interface information 289 * Execute a VI Read command to get our Virtual Interface information
@@ -319,19 +322,11 @@ int t4vf_port_init(struct adapter *adapter, int pidx)
319 if (v) 322 if (v)
320 return v; 323 return v;
321 324
322 v = 0; 325 v = be32_to_cpu(port_rpl.u.info.lstatus_to_modtype);
323 word = be16_to_cpu(port_rpl.u.info.pcap); 326 pi->port_type = FW_PORT_CMD_PTYPE_G(v);
324 if (word & FW_PORT_CAP_SPEED_100M) 327 pi->mod_type = FW_PORT_MOD_TYPE_NA;
325 v |= SUPPORTED_100baseT_Full; 328
326 if (word & FW_PORT_CAP_SPEED_1G) 329 init_link_config(&pi->link_cfg, be16_to_cpu(port_rpl.u.info.pcap));
327 v |= SUPPORTED_1000baseT_Full;
328 if (word & FW_PORT_CAP_SPEED_10G)
329 v |= SUPPORTED_10000baseT_Full;
330 if (word & FW_PORT_CAP_SPEED_40G)
331 v |= SUPPORTED_40000baseSR4_Full;
332 if (word & FW_PORT_CAP_ANEG)
333 v |= SUPPORTED_Autoneg;
334 init_link_config(&pi->link_cfg, v);
335 330
336 return 0; 331 return 0;
337} 332}
@@ -1491,7 +1486,7 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1491 */ 1486 */
1492 const struct fw_port_cmd *port_cmd = 1487 const struct fw_port_cmd *port_cmd =
1493 (const struct fw_port_cmd *)rpl; 1488 (const struct fw_port_cmd *)rpl;
1494 u32 word; 1489 u32 stat, mod;
1495 int action, port_id, link_ok, speed, fc, pidx; 1490 int action, port_id, link_ok, speed, fc, pidx;
1496 1491
1497 /* 1492 /*
@@ -1509,21 +1504,21 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1509 port_id = FW_PORT_CMD_PORTID_G( 1504 port_id = FW_PORT_CMD_PORTID_G(
1510 be32_to_cpu(port_cmd->op_to_portid)); 1505 be32_to_cpu(port_cmd->op_to_portid));
1511 1506
1512 word = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype); 1507 stat = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype);
1513 link_ok = (word & FW_PORT_CMD_LSTATUS_F) != 0; 1508 link_ok = (stat & FW_PORT_CMD_LSTATUS_F) != 0;
1514 speed = 0; 1509 speed = 0;
1515 fc = 0; 1510 fc = 0;
1516 if (word & FW_PORT_CMD_RXPAUSE_F) 1511 if (stat & FW_PORT_CMD_RXPAUSE_F)
1517 fc |= PAUSE_RX; 1512 fc |= PAUSE_RX;
1518 if (word & FW_PORT_CMD_TXPAUSE_F) 1513 if (stat & FW_PORT_CMD_TXPAUSE_F)
1519 fc |= PAUSE_TX; 1514 fc |= PAUSE_TX;
1520 if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M)) 1515 if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M))
1521 speed = 100; 1516 speed = 100;
1522 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G)) 1517 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G))
1523 speed = 1000; 1518 speed = 1000;
1524 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G)) 1519 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G))
1525 speed = 10000; 1520 speed = 10000;
1526 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G)) 1521 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G))
1527 speed = 40000; 1522 speed = 40000;
1528 1523
1529 /* 1524 /*
@@ -1540,12 +1535,21 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1540 continue; 1535 continue;
1541 1536
1542 lc = &pi->link_cfg; 1537 lc = &pi->link_cfg;
1538
1539 mod = FW_PORT_CMD_MODTYPE_G(stat);
1540 if (mod != pi->mod_type) {
1541 pi->mod_type = mod;
1542 t4vf_os_portmod_changed(adapter, pidx);
1543 }
1544
1543 if (link_ok != lc->link_ok || speed != lc->speed || 1545 if (link_ok != lc->link_ok || speed != lc->speed ||
1544 fc != lc->fc) { 1546 fc != lc->fc) {
1545 /* something changed */ 1547 /* something changed */
1546 lc->link_ok = link_ok; 1548 lc->link_ok = link_ok;
1547 lc->speed = speed; 1549 lc->speed = speed;
1548 lc->fc = fc; 1550 lc->fc = fc;
1551 lc->supported =
1552 be16_to_cpu(port_cmd->u.info.pcap);
1549 t4vf_os_link_changed(adapter, pidx, link_ok); 1553 t4vf_os_link_changed(adapter, pidx, link_ok);
1550 } 1554 }
1551 } 1555 }
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 868d0f605d60..b29e027c476e 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1060,10 +1060,14 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
1060 PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3); 1060 PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3);
1061 } 1061 }
1062 1062
1063 if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc) { 1063 /* Hardware does not provide whole packet checksum. It only
1064 skb->csum = htons(checksum); 1064 * provides pseudo checksum. Since hw validates the packet
1065 skb->ip_summed = CHECKSUM_COMPLETE; 1065 * checksum but not provide us the checksum value. use
1066 } 1066 * CHECSUM_UNNECESSARY.
1067 */
1068 if ((netdev->features & NETIF_F_RXCSUM) && tcp_udp_csum_ok &&
1069 ipv4_csum_ok)
1070 skb->ip_summed = CHECKSUM_UNNECESSARY;
1067 1071
1068 if (vlan_stripped) 1072 if (vlan_stripped)
1069 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); 1073 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
@@ -1612,7 +1616,7 @@ static int enic_open(struct net_device *netdev)
1612 if (vnic_rq_desc_used(&enic->rq[i]) == 0) { 1616 if (vnic_rq_desc_used(&enic->rq[i]) == 0) {
1613 netdev_err(netdev, "Unable to alloc receive buffers\n"); 1617 netdev_err(netdev, "Unable to alloc receive buffers\n");
1614 err = -ENOMEM; 1618 err = -ENOMEM;
1615 goto err_out_notify_unset; 1619 goto err_out_free_rq;
1616 } 1620 }
1617 } 1621 }
1618 1622
@@ -1645,7 +1649,9 @@ static int enic_open(struct net_device *netdev)
1645 1649
1646 return 0; 1650 return 0;
1647 1651
1648err_out_notify_unset: 1652err_out_free_rq:
1653 for (i = 0; i < enic->rq_count; i++)
1654 vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1649 enic_dev_notify_unset(enic); 1655 enic_dev_notify_unset(enic);
1650err_out_free_intr: 1656err_out_free_intr:
1651 enic_free_intr(enic); 1657 enic_free_intr(enic);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 196073110e32..41a0a5498da7 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4459,9 +4459,11 @@ done:
4459 adapter->vxlan_port_count--; 4459 adapter->vxlan_port_count--;
4460} 4460}
4461 4461
4462static bool be_gso_check(struct sk_buff *skb, struct net_device *dev) 4462static netdev_features_t be_features_check(struct sk_buff *skb,
4463 struct net_device *dev,
4464 netdev_features_t features)
4463{ 4465{
4464 return vxlan_gso_check(skb); 4466 return vxlan_features_check(skb, features);
4465} 4467}
4466#endif 4468#endif
4467 4469
@@ -4492,7 +4494,7 @@ static const struct net_device_ops be_netdev_ops = {
4492#ifdef CONFIG_BE2NET_VXLAN 4494#ifdef CONFIG_BE2NET_VXLAN
4493 .ndo_add_vxlan_port = be_add_vxlan_port, 4495 .ndo_add_vxlan_port = be_add_vxlan_port,
4494 .ndo_del_vxlan_port = be_del_vxlan_port, 4496 .ndo_del_vxlan_port = be_del_vxlan_port,
4495 .ndo_gso_check = be_gso_check, 4497 .ndo_features_check = be_features_check,
4496#endif 4498#endif
4497}; 4499};
4498 4500
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 781065eb5431..e9c3a87e5b11 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -1543,7 +1543,7 @@ static int e100_phy_init(struct nic *nic)
1543 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr); 1543 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr);
1544 } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) && 1544 } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
1545 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) && 1545 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) &&
1546 !(nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) { 1546 (nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) {
1547 /* enable/disable MDI/MDI-X auto-switching. */ 1547 /* enable/disable MDI/MDI-X auto-switching. */
1548 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG, 1548 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG,
1549 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH); 1549 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index 433a55886ad2..cb0de455683e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -829,7 +829,7 @@ static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
829 if (desc_n >= ring->count || desc_n < 0) { 829 if (desc_n >= ring->count || desc_n < 0) {
830 dev_info(&pf->pdev->dev, 830 dev_info(&pf->pdev->dev,
831 "descriptor %d not found\n", desc_n); 831 "descriptor %d not found\n", desc_n);
832 return; 832 goto out;
833 } 833 }
834 if (!is_rx_ring) { 834 if (!is_rx_ring) {
835 txd = I40E_TX_DESC(ring, desc_n); 835 txd = I40E_TX_DESC(ring, desc_n);
@@ -855,6 +855,8 @@ static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
855 } else { 855 } else {
856 dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n"); 856 dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
857 } 857 }
858
859out:
858 kfree(ring); 860 kfree(ring);
859} 861}
860 862
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index 051ea94bdcd3..0f69ef81751a 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -1125,7 +1125,7 @@ static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
1125 u32 swmask = mask; 1125 u32 swmask = mask;
1126 u32 fwmask = mask << 16; 1126 u32 fwmask = mask << 16;
1127 s32 ret_val = 0; 1127 s32 ret_val = 0;
1128 s32 i = 0, timeout = 200; /* FIXME: find real value to use here */ 1128 s32 i = 0, timeout = 200;
1129 1129
1130 while (i < timeout) { 1130 while (i < timeout) {
1131 if (igb_get_hw_semaphore(hw)) { 1131 if (igb_get_hw_semaphore(hw)) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 190cbd931f6b..d0d6dc1b8e46 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2365,9 +2365,11 @@ static void mlx4_en_del_vxlan_port(struct net_device *dev,
2365 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task); 2365 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
2366} 2366}
2367 2367
2368static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev) 2368static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
2369 struct net_device *dev,
2370 netdev_features_t features)
2369{ 2371{
2370 return vxlan_gso_check(skb); 2372 return vxlan_features_check(skb, features);
2371} 2373}
2372#endif 2374#endif
2373 2375
@@ -2400,7 +2402,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
2400#ifdef CONFIG_MLX4_EN_VXLAN 2402#ifdef CONFIG_MLX4_EN_VXLAN
2401 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2403 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2402 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2404 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2403 .ndo_gso_check = mlx4_en_gso_check, 2405 .ndo_features_check = mlx4_en_features_check,
2404#endif 2406#endif
2405}; 2407};
2406 2408
@@ -2434,7 +2436,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
2434#ifdef CONFIG_MLX4_EN_VXLAN 2436#ifdef CONFIG_MLX4_EN_VXLAN
2435 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2437 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2436 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2438 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2437 .ndo_gso_check = mlx4_en_gso_check, 2439 .ndo_features_check = mlx4_en_features_check,
2438#endif 2440#endif
2439}; 2441};
2440 2442
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index a308d41e4de0..e3357bf523df 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -962,7 +962,17 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
962 tx_desc->ctrl.owner_opcode = op_own; 962 tx_desc->ctrl.owner_opcode = op_own;
963 if (send_doorbell) { 963 if (send_doorbell) {
964 wmb(); 964 wmb();
965 iowrite32(ring->doorbell_qpn, 965 /* Since there is no iowrite*_native() that writes the
966 * value as is, without byteswapping - using the one
967 * the doesn't do byteswapping in the relevant arch
968 * endianness.
969 */
970#if defined(__LITTLE_ENDIAN)
971 iowrite32(
972#else
973 iowrite32be(
974#endif
975 ring->doorbell_qpn,
966 ring->bf.uar->map + MLX4_SEND_DOORBELL); 976 ring->bf.uar->map + MLX4_SEND_DOORBELL);
967 } else { 977 } else {
968 ring->xmit_more++; 978 ring->xmit_more++;
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 943cbd47d832..03e9eb0dc761 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1829,7 +1829,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1829 err = mlx4_dev_cap(dev, &dev_cap); 1829 err = mlx4_dev_cap(dev, &dev_cap);
1830 if (err) { 1830 if (err) {
1831 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting\n"); 1831 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting\n");
1832 goto err_stop_fw; 1832 return err;
1833 } 1833 }
1834 1834
1835 choose_steering_mode(dev, &dev_cap); 1835 choose_steering_mode(dev, &dev_cap);
@@ -1860,7 +1860,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1860 &init_hca); 1860 &init_hca);
1861 if ((long long) icm_size < 0) { 1861 if ((long long) icm_size < 0) {
1862 err = icm_size; 1862 err = icm_size;
1863 goto err_stop_fw; 1863 return err;
1864 } 1864 }
1865 1865
1866 dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1; 1866 dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
@@ -1874,7 +1874,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1874 1874
1875 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size); 1875 err = mlx4_init_icm(dev, &dev_cap, &init_hca, icm_size);
1876 if (err) 1876 if (err)
1877 goto err_stop_fw; 1877 return err;
1878 1878
1879 err = mlx4_INIT_HCA(dev, &init_hca); 1879 err = mlx4_INIT_HCA(dev, &init_hca);
1880 if (err) { 1880 if (err) {
@@ -1886,7 +1886,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
1886 err = mlx4_query_func(dev, &dev_cap); 1886 err = mlx4_query_func(dev, &dev_cap);
1887 if (err < 0) { 1887 if (err < 0) {
1888 mlx4_err(dev, "QUERY_FUNC command failed, aborting.\n"); 1888 mlx4_err(dev, "QUERY_FUNC command failed, aborting.\n");
1889 goto err_stop_fw; 1889 goto err_close;
1890 } else if (err & MLX4_QUERY_FUNC_NUM_SYS_EQS) { 1890 } else if (err & MLX4_QUERY_FUNC_NUM_SYS_EQS) {
1891 dev->caps.num_eqs = dev_cap.max_eqs; 1891 dev->caps.num_eqs = dev_cap.max_eqs;
1892 dev->caps.reserved_eqs = dev_cap.reserved_eqs; 1892 dev->caps.reserved_eqs = dev_cap.reserved_eqs;
@@ -2006,11 +2006,6 @@ err_free_icm:
2006 if (!mlx4_is_slave(dev)) 2006 if (!mlx4_is_slave(dev))
2007 mlx4_free_icms(dev); 2007 mlx4_free_icms(dev);
2008 2008
2009err_stop_fw:
2010 if (!mlx4_is_slave(dev)) {
2011 mlx4_UNMAP_FA(dev);
2012 mlx4_free_icm(dev, priv->fw.fw_icm, 0);
2013 }
2014 return err; 2009 return err;
2015} 2010}
2016 2011
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index d6f549685c0f..7094a9c70fd5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -584,6 +584,7 @@ EXPORT_SYMBOL_GPL(mlx4_mr_free);
584void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr) 584void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr)
585{ 585{
586 mlx4_mtt_cleanup(dev, &mr->mtt); 586 mlx4_mtt_cleanup(dev, &mr->mtt);
587 mr->mtt.order = -1;
587} 588}
588EXPORT_SYMBOL_GPL(mlx4_mr_rereg_mem_cleanup); 589EXPORT_SYMBOL_GPL(mlx4_mr_rereg_mem_cleanup);
589 590
@@ -593,14 +594,14 @@ int mlx4_mr_rereg_mem_write(struct mlx4_dev *dev, struct mlx4_mr *mr,
593{ 594{
594 int err; 595 int err;
595 596
596 mpt_entry->start = cpu_to_be64(iova);
597 mpt_entry->length = cpu_to_be64(size);
598 mpt_entry->entity_size = cpu_to_be32(page_shift);
599
600 err = mlx4_mtt_init(dev, npages, page_shift, &mr->mtt); 597 err = mlx4_mtt_init(dev, npages, page_shift, &mr->mtt);
601 if (err) 598 if (err)
602 return err; 599 return err;
603 600
601 mpt_entry->start = cpu_to_be64(mr->iova);
602 mpt_entry->length = cpu_to_be64(mr->size);
603 mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift);
604
604 mpt_entry->pd_flags &= cpu_to_be32(MLX4_MPT_PD_MASK | 605 mpt_entry->pd_flags &= cpu_to_be32(MLX4_MPT_PD_MASK |
605 MLX4_MPT_PD_FLAG_EN_INV); 606 MLX4_MPT_PD_FLAG_EN_INV);
606 mpt_entry->flags &= cpu_to_be32(MLX4_MPT_FLAG_FREE | 607 mpt_entry->flags &= cpu_to_be32(MLX4_MPT_FLAG_FREE |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index f1ebed6c63b1..2fa6ae026e4f 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -2303,12 +2303,6 @@ static inline int port_chk_force_flow_ctrl(struct ksz_hw *hw, int p)
2303 2303
2304/* Spanning Tree */ 2304/* Spanning Tree */
2305 2305
2306static inline void port_cfg_dis_learn(struct ksz_hw *hw, int p, int set)
2307{
2308 port_cfg(hw, p,
2309 KS8842_PORT_CTRL_2_OFFSET, PORT_LEARN_DISABLE, set);
2310}
2311
2312static inline void port_cfg_rx(struct ksz_hw *hw, int p, int set) 2306static inline void port_cfg_rx(struct ksz_hw *hw, int p, int set)
2313{ 2307{
2314 port_cfg(hw, p, 2308 port_cfg(hw, p,
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index af099057f0e9..71af98bb72cb 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -4033,8 +4033,10 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4033 (void)pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); 4033 (void)pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
4034 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd), 4034 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd),
4035 &mgp->cmd_bus, GFP_KERNEL); 4035 &mgp->cmd_bus, GFP_KERNEL);
4036 if (mgp->cmd == NULL) 4036 if (!mgp->cmd) {
4037 status = -ENOMEM;
4037 goto abort_with_enabled; 4038 goto abort_with_enabled;
4039 }
4038 4040
4039 mgp->board_span = pci_resource_len(pdev, 0); 4041 mgp->board_span = pci_resource_len(pdev, 0);
4040 mgp->iomem_base = pci_resource_start(pdev, 0); 4042 mgp->iomem_base = pci_resource_start(pdev, 0);
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
index c2f09af5c25b..4847713211ca 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -146,10 +146,7 @@ static int ql_wait_for_drvr_lock(struct ql3_adapter *qdev)
146{ 146{
147 int i = 0; 147 int i = 0;
148 148
149 while (i < 10) { 149 do {
150 if (i)
151 ssleep(1);
152
153 if (ql_sem_lock(qdev, 150 if (ql_sem_lock(qdev,
154 QL_DRVR_SEM_MASK, 151 QL_DRVR_SEM_MASK,
155 (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index) 152 (QL_RESOURCE_BITS_BASE_CODE | (qdev->mac_index)
@@ -158,7 +155,8 @@ static int ql_wait_for_drvr_lock(struct ql3_adapter *qdev)
158 "driver lock acquired\n"); 155 "driver lock acquired\n");
159 return 1; 156 return 1;
160 } 157 }
161 } 158 ssleep(1);
159 } while (++i < 10);
162 160
163 netdev_err(qdev->ndev, "Timed out waiting for driver lock...\n"); 161 netdev_err(qdev->ndev, "Timed out waiting for driver lock...\n");
164 return 0; 162 return 0;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 1aa25b13ace1..2528c3fb6b90 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -505,9 +505,11 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,
505 adapter->flags |= QLCNIC_DEL_VXLAN_PORT; 505 adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
506} 506}
507 507
508static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev) 508static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
509 struct net_device *dev,
510 netdev_features_t features)
509{ 511{
510 return vxlan_gso_check(skb); 512 return vxlan_features_check(skb, features);
511} 513}
512#endif 514#endif
513 515
@@ -532,7 +534,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
532#ifdef CONFIG_QLCNIC_VXLAN 534#ifdef CONFIG_QLCNIC_VXLAN
533 .ndo_add_vxlan_port = qlcnic_add_vxlan_port, 535 .ndo_add_vxlan_port = qlcnic_add_vxlan_port,
534 .ndo_del_vxlan_port = qlcnic_del_vxlan_port, 536 .ndo_del_vxlan_port = qlcnic_del_vxlan_port,
535 .ndo_gso_check = qlcnic_gso_check, 537 .ndo_features_check = qlcnic_features_check,
536#endif 538#endif
537#ifdef CONFIG_NET_POLL_CONTROLLER 539#ifdef CONFIG_NET_POLL_CONTROLLER
538 .ndo_poll_controller = qlcnic_poll_controller, 540 .ndo_poll_controller = qlcnic_poll_controller,
@@ -2603,6 +2605,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2603 } else { 2605 } else {
2604 dev_err(&pdev->dev, 2606 dev_err(&pdev->dev,
2605 "%s: failed. Please Reboot\n", __func__); 2607 "%s: failed. Please Reboot\n", __func__);
2608 err = -ENODEV;
2606 goto err_out_free_hw; 2609 goto err_out_free_hw;
2607 } 2610 }
2608 2611
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
index 6d0b9dfac313..78bb4ceb1cdd 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -787,10 +787,10 @@ static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
787 if (rc) 787 if (rc)
788 goto err_out; 788 goto err_out;
789 789
790 disable_dev_on_err = 1;
790 rc = pci_request_regions (pdev, DRV_NAME); 791 rc = pci_request_regions (pdev, DRV_NAME);
791 if (rc) 792 if (rc)
792 goto err_out; 793 goto err_out;
793 disable_dev_on_err = 1;
794 794
795 pci_set_master (pdev); 795 pci_set_master (pdev);
796 796
@@ -1110,6 +1110,7 @@ static int rtl8139_init_one(struct pci_dev *pdev,
1110 return 0; 1110 return 0;
1111 1111
1112err_out: 1112err_out:
1113 netif_napi_del(&tp->napi);
1113 __rtl8139_cleanup_dev (dev); 1114 __rtl8139_cleanup_dev (dev);
1114 pci_disable_device (pdev); 1115 pci_disable_device (pdev);
1115 return i; 1116 return i;
@@ -1124,6 +1125,7 @@ static void rtl8139_remove_one(struct pci_dev *pdev)
1124 assert (dev != NULL); 1125 assert (dev != NULL);
1125 1126
1126 cancel_delayed_work_sync(&tp->thread); 1127 cancel_delayed_work_sync(&tp->thread);
1128 netif_napi_del(&tp->napi);
1127 1129
1128 unregister_netdev (dev); 1130 unregister_netdev (dev);
1129 1131
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
deleted file mode 100644
index f537cbea20e5..000000000000
--- a/drivers/net/ethernet/s6gmac.c
+++ /dev/null
@@ -1,1058 +0,0 @@
1/*
2 * Ethernet driver for S6105 on chip network device
3 * (c)2008 emlix GmbH http://www.emlix.com
4 * Authors: Oskar Schirmer <oskar@scara.com>
5 * Daniel Gloeckner <dg@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/types.h>
16#include <linux/delay.h>
17#include <linux/spinlock.h>
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/if.h>
21#include <linux/stddef.h>
22#include <linux/mii.h>
23#include <linux/phy.h>
24#include <linux/platform_device.h>
25#include <variant/hardware.h>
26#include <variant/dmac.h>
27
28#define DRV_NAME "s6gmac"
29#define DRV_PRMT DRV_NAME ": "
30
31
32/* register declarations */
33
34#define S6_GMAC_MACCONF1 0x000
35#define S6_GMAC_MACCONF1_TXENA 0
36#define S6_GMAC_MACCONF1_SYNCTX 1
37#define S6_GMAC_MACCONF1_RXENA 2
38#define S6_GMAC_MACCONF1_SYNCRX 3
39#define S6_GMAC_MACCONF1_TXFLOWCTRL 4
40#define S6_GMAC_MACCONF1_RXFLOWCTRL 5
41#define S6_GMAC_MACCONF1_LOOPBACK 8
42#define S6_GMAC_MACCONF1_RESTXFUNC 16
43#define S6_GMAC_MACCONF1_RESRXFUNC 17
44#define S6_GMAC_MACCONF1_RESTXMACCTRL 18
45#define S6_GMAC_MACCONF1_RESRXMACCTRL 19
46#define S6_GMAC_MACCONF1_SIMULRES 30
47#define S6_GMAC_MACCONF1_SOFTRES 31
48#define S6_GMAC_MACCONF2 0x004
49#define S6_GMAC_MACCONF2_FULL 0
50#define S6_GMAC_MACCONF2_CRCENA 1
51#define S6_GMAC_MACCONF2_PADCRCENA 2
52#define S6_GMAC_MACCONF2_LENGTHFCHK 4
53#define S6_GMAC_MACCONF2_HUGEFRAMENA 5
54#define S6_GMAC_MACCONF2_IFMODE 8
55#define S6_GMAC_MACCONF2_IFMODE_NIBBLE 1
56#define S6_GMAC_MACCONF2_IFMODE_BYTE 2
57#define S6_GMAC_MACCONF2_IFMODE_MASK 3
58#define S6_GMAC_MACCONF2_PREAMBLELEN 12
59#define S6_GMAC_MACCONF2_PREAMBLELEN_MASK 0x0F
60#define S6_GMAC_MACIPGIFG 0x008
61#define S6_GMAC_MACIPGIFG_B2BINTERPGAP 0
62#define S6_GMAC_MACIPGIFG_B2BINTERPGAP_MASK 0x7F
63#define S6_GMAC_MACIPGIFG_MINIFGENFORCE 8
64#define S6_GMAC_MACIPGIFG_B2BINTERPGAP2 16
65#define S6_GMAC_MACIPGIFG_B2BINTERPGAP1 24
66#define S6_GMAC_MACHALFDUPLEX 0x00C
67#define S6_GMAC_MACHALFDUPLEX_COLLISWIN 0
68#define S6_GMAC_MACHALFDUPLEX_COLLISWIN_MASK 0x3F
69#define S6_GMAC_MACHALFDUPLEX_RETXMAX 12
70#define S6_GMAC_MACHALFDUPLEX_RETXMAX_MASK 0x0F
71#define S6_GMAC_MACHALFDUPLEX_EXCESSDEF 16
72#define S6_GMAC_MACHALFDUPLEX_NOBACKOFF 17
73#define S6_GMAC_MACHALFDUPLEX_BPNOBCKOF 18
74#define S6_GMAC_MACHALFDUPLEX_ALTBEBENA 19
75#define S6_GMAC_MACHALFDUPLEX_ALTBEBTRN 20
76#define S6_GMAC_MACHALFDUPLEX_ALTBEBTR_MASK 0x0F
77#define S6_GMAC_MACMAXFRAMELEN 0x010
78#define S6_GMAC_MACMIICONF 0x020
79#define S6_GMAC_MACMIICONF_CSEL 0
80#define S6_GMAC_MACMIICONF_CSEL_DIV10 0
81#define S6_GMAC_MACMIICONF_CSEL_DIV12 1
82#define S6_GMAC_MACMIICONF_CSEL_DIV14 2
83#define S6_GMAC_MACMIICONF_CSEL_DIV18 3
84#define S6_GMAC_MACMIICONF_CSEL_DIV24 4
85#define S6_GMAC_MACMIICONF_CSEL_DIV34 5
86#define S6_GMAC_MACMIICONF_CSEL_DIV68 6
87#define S6_GMAC_MACMIICONF_CSEL_DIV168 7
88#define S6_GMAC_MACMIICONF_CSEL_MASK 7
89#define S6_GMAC_MACMIICONF_PREAMBLESUPR 4
90#define S6_GMAC_MACMIICONF_SCANAUTOINCR 5
91#define S6_GMAC_MACMIICMD 0x024
92#define S6_GMAC_MACMIICMD_READ 0
93#define S6_GMAC_MACMIICMD_SCAN 1
94#define S6_GMAC_MACMIIADDR 0x028
95#define S6_GMAC_MACMIIADDR_REG 0
96#define S6_GMAC_MACMIIADDR_REG_MASK 0x1F
97#define S6_GMAC_MACMIIADDR_PHY 8
98#define S6_GMAC_MACMIIADDR_PHY_MASK 0x1F
99#define S6_GMAC_MACMIICTRL 0x02C
100#define S6_GMAC_MACMIISTAT 0x030
101#define S6_GMAC_MACMIIINDI 0x034
102#define S6_GMAC_MACMIIINDI_BUSY 0
103#define S6_GMAC_MACMIIINDI_SCAN 1
104#define S6_GMAC_MACMIIINDI_INVAL 2
105#define S6_GMAC_MACINTERFSTAT 0x03C
106#define S6_GMAC_MACINTERFSTAT_LINKFAIL 3
107#define S6_GMAC_MACINTERFSTAT_EXCESSDEF 9
108#define S6_GMAC_MACSTATADDR1 0x040
109#define S6_GMAC_MACSTATADDR2 0x044
110
111#define S6_GMAC_FIFOCONF0 0x048
112#define S6_GMAC_FIFOCONF0_HSTRSTWT 0
113#define S6_GMAC_FIFOCONF0_HSTRSTSR 1
114#define S6_GMAC_FIFOCONF0_HSTRSTFR 2
115#define S6_GMAC_FIFOCONF0_HSTRSTST 3
116#define S6_GMAC_FIFOCONF0_HSTRSTFT 4
117#define S6_GMAC_FIFOCONF0_WTMENREQ 8
118#define S6_GMAC_FIFOCONF0_SRFENREQ 9
119#define S6_GMAC_FIFOCONF0_FRFENREQ 10
120#define S6_GMAC_FIFOCONF0_STFENREQ 11
121#define S6_GMAC_FIFOCONF0_FTFENREQ 12
122#define S6_GMAC_FIFOCONF0_WTMENRPLY 16
123#define S6_GMAC_FIFOCONF0_SRFENRPLY 17
124#define S6_GMAC_FIFOCONF0_FRFENRPLY 18
125#define S6_GMAC_FIFOCONF0_STFENRPLY 19
126#define S6_GMAC_FIFOCONF0_FTFENRPLY 20
127#define S6_GMAC_FIFOCONF1 0x04C
128#define S6_GMAC_FIFOCONF2 0x050
129#define S6_GMAC_FIFOCONF2_CFGLWM 0
130#define S6_GMAC_FIFOCONF2_CFGHWM 16
131#define S6_GMAC_FIFOCONF3 0x054
132#define S6_GMAC_FIFOCONF3_CFGFTTH 0
133#define S6_GMAC_FIFOCONF3_CFGHWMFT 16
134#define S6_GMAC_FIFOCONF4 0x058
135#define S6_GMAC_FIFOCONF_RSV_PREVDROP 0
136#define S6_GMAC_FIFOCONF_RSV_RUNT 1
137#define S6_GMAC_FIFOCONF_RSV_FALSECAR 2
138#define S6_GMAC_FIFOCONF_RSV_CODEERR 3
139#define S6_GMAC_FIFOCONF_RSV_CRCERR 4
140#define S6_GMAC_FIFOCONF_RSV_LENGTHERR 5
141#define S6_GMAC_FIFOCONF_RSV_LENRANGE 6
142#define S6_GMAC_FIFOCONF_RSV_OK 7
143#define S6_GMAC_FIFOCONF_RSV_MULTICAST 8
144#define S6_GMAC_FIFOCONF_RSV_BROADCAST 9
145#define S6_GMAC_FIFOCONF_RSV_DRIBBLE 10
146#define S6_GMAC_FIFOCONF_RSV_CTRLFRAME 11
147#define S6_GMAC_FIFOCONF_RSV_PAUSECTRL 12
148#define S6_GMAC_FIFOCONF_RSV_UNOPCODE 13
149#define S6_GMAC_FIFOCONF_RSV_VLANTAG 14
150#define S6_GMAC_FIFOCONF_RSV_LONGEVENT 15
151#define S6_GMAC_FIFOCONF_RSV_TRUNCATED 16
152#define S6_GMAC_FIFOCONF_RSV_MASK 0x3FFFF
153#define S6_GMAC_FIFOCONF5 0x05C
154#define S6_GMAC_FIFOCONF5_DROPLT64 18
155#define S6_GMAC_FIFOCONF5_CFGBYTM 19
156#define S6_GMAC_FIFOCONF5_RXDROPSIZE 20
157#define S6_GMAC_FIFOCONF5_RXDROPSIZE_MASK 0xF
158
159#define S6_GMAC_STAT_REGS 0x080
160#define S6_GMAC_STAT_SIZE_MIN 12
161#define S6_GMAC_STATTR64 0x080
162#define S6_GMAC_STATTR64_SIZE 18
163#define S6_GMAC_STATTR127 0x084
164#define S6_GMAC_STATTR127_SIZE 18
165#define S6_GMAC_STATTR255 0x088
166#define S6_GMAC_STATTR255_SIZE 18
167#define S6_GMAC_STATTR511 0x08C
168#define S6_GMAC_STATTR511_SIZE 18
169#define S6_GMAC_STATTR1K 0x090
170#define S6_GMAC_STATTR1K_SIZE 18
171#define S6_GMAC_STATTRMAX 0x094
172#define S6_GMAC_STATTRMAX_SIZE 18
173#define S6_GMAC_STATTRMGV 0x098
174#define S6_GMAC_STATTRMGV_SIZE 18
175#define S6_GMAC_STATRBYT 0x09C
176#define S6_GMAC_STATRBYT_SIZE 24
177#define S6_GMAC_STATRPKT 0x0A0
178#define S6_GMAC_STATRPKT_SIZE 18
179#define S6_GMAC_STATRFCS 0x0A4
180#define S6_GMAC_STATRFCS_SIZE 12
181#define S6_GMAC_STATRMCA 0x0A8
182#define S6_GMAC_STATRMCA_SIZE 18
183#define S6_GMAC_STATRBCA 0x0AC
184#define S6_GMAC_STATRBCA_SIZE 22
185#define S6_GMAC_STATRXCF 0x0B0
186#define S6_GMAC_STATRXCF_SIZE 18
187#define S6_GMAC_STATRXPF 0x0B4
188#define S6_GMAC_STATRXPF_SIZE 12
189#define S6_GMAC_STATRXUO 0x0B8
190#define S6_GMAC_STATRXUO_SIZE 12
191#define S6_GMAC_STATRALN 0x0BC
192#define S6_GMAC_STATRALN_SIZE 12
193#define S6_GMAC_STATRFLR 0x0C0
194#define S6_GMAC_STATRFLR_SIZE 16
195#define S6_GMAC_STATRCDE 0x0C4
196#define S6_GMAC_STATRCDE_SIZE 12
197#define S6_GMAC_STATRCSE 0x0C8
198#define S6_GMAC_STATRCSE_SIZE 12
199#define S6_GMAC_STATRUND 0x0CC
200#define S6_GMAC_STATRUND_SIZE 12
201#define S6_GMAC_STATROVR 0x0D0
202#define S6_GMAC_STATROVR_SIZE 12
203#define S6_GMAC_STATRFRG 0x0D4
204#define S6_GMAC_STATRFRG_SIZE 12
205#define S6_GMAC_STATRJBR 0x0D8
206#define S6_GMAC_STATRJBR_SIZE 12
207#define S6_GMAC_STATRDRP 0x0DC
208#define S6_GMAC_STATRDRP_SIZE 12
209#define S6_GMAC_STATTBYT 0x0E0
210#define S6_GMAC_STATTBYT_SIZE 24
211#define S6_GMAC_STATTPKT 0x0E4
212#define S6_GMAC_STATTPKT_SIZE 18
213#define S6_GMAC_STATTMCA 0x0E8
214#define S6_GMAC_STATTMCA_SIZE 18
215#define S6_GMAC_STATTBCA 0x0EC
216#define S6_GMAC_STATTBCA_SIZE 18
217#define S6_GMAC_STATTXPF 0x0F0
218#define S6_GMAC_STATTXPF_SIZE 12
219#define S6_GMAC_STATTDFR 0x0F4
220#define S6_GMAC_STATTDFR_SIZE 12
221#define S6_GMAC_STATTEDF 0x0F8
222#define S6_GMAC_STATTEDF_SIZE 12
223#define S6_GMAC_STATTSCL 0x0FC
224#define S6_GMAC_STATTSCL_SIZE 12
225#define S6_GMAC_STATTMCL 0x100
226#define S6_GMAC_STATTMCL_SIZE 12
227#define S6_GMAC_STATTLCL 0x104
228#define S6_GMAC_STATTLCL_SIZE 12
229#define S6_GMAC_STATTXCL 0x108
230#define S6_GMAC_STATTXCL_SIZE 12
231#define S6_GMAC_STATTNCL 0x10C
232#define S6_GMAC_STATTNCL_SIZE 13
233#define S6_GMAC_STATTPFH 0x110
234#define S6_GMAC_STATTPFH_SIZE 12
235#define S6_GMAC_STATTDRP 0x114
236#define S6_GMAC_STATTDRP_SIZE 12
237#define S6_GMAC_STATTJBR 0x118
238#define S6_GMAC_STATTJBR_SIZE 12
239#define S6_GMAC_STATTFCS 0x11C
240#define S6_GMAC_STATTFCS_SIZE 12
241#define S6_GMAC_STATTXCF 0x120
242#define S6_GMAC_STATTXCF_SIZE 12
243#define S6_GMAC_STATTOVR 0x124
244#define S6_GMAC_STATTOVR_SIZE 12
245#define S6_GMAC_STATTUND 0x128
246#define S6_GMAC_STATTUND_SIZE 12
247#define S6_GMAC_STATTFRG 0x12C
248#define S6_GMAC_STATTFRG_SIZE 12
249#define S6_GMAC_STATCARRY(n) (0x130 + 4*(n))
250#define S6_GMAC_STATCARRYMSK(n) (0x138 + 4*(n))
251#define S6_GMAC_STATCARRY1_RDRP 0
252#define S6_GMAC_STATCARRY1_RJBR 1
253#define S6_GMAC_STATCARRY1_RFRG 2
254#define S6_GMAC_STATCARRY1_ROVR 3
255#define S6_GMAC_STATCARRY1_RUND 4
256#define S6_GMAC_STATCARRY1_RCSE 5
257#define S6_GMAC_STATCARRY1_RCDE 6
258#define S6_GMAC_STATCARRY1_RFLR 7
259#define S6_GMAC_STATCARRY1_RALN 8
260#define S6_GMAC_STATCARRY1_RXUO 9
261#define S6_GMAC_STATCARRY1_RXPF 10
262#define S6_GMAC_STATCARRY1_RXCF 11
263#define S6_GMAC_STATCARRY1_RBCA 12
264#define S6_GMAC_STATCARRY1_RMCA 13
265#define S6_GMAC_STATCARRY1_RFCS 14
266#define S6_GMAC_STATCARRY1_RPKT 15
267#define S6_GMAC_STATCARRY1_RBYT 16
268#define S6_GMAC_STATCARRY1_TRMGV 25
269#define S6_GMAC_STATCARRY1_TRMAX 26
270#define S6_GMAC_STATCARRY1_TR1K 27
271#define S6_GMAC_STATCARRY1_TR511 28
272#define S6_GMAC_STATCARRY1_TR255 29
273#define S6_GMAC_STATCARRY1_TR127 30
274#define S6_GMAC_STATCARRY1_TR64 31
275#define S6_GMAC_STATCARRY2_TDRP 0
276#define S6_GMAC_STATCARRY2_TPFH 1
277#define S6_GMAC_STATCARRY2_TNCL 2
278#define S6_GMAC_STATCARRY2_TXCL 3
279#define S6_GMAC_STATCARRY2_TLCL 4
280#define S6_GMAC_STATCARRY2_TMCL 5
281#define S6_GMAC_STATCARRY2_TSCL 6
282#define S6_GMAC_STATCARRY2_TEDF 7
283#define S6_GMAC_STATCARRY2_TDFR 8
284#define S6_GMAC_STATCARRY2_TXPF 9
285#define S6_GMAC_STATCARRY2_TBCA 10
286#define S6_GMAC_STATCARRY2_TMCA 11
287#define S6_GMAC_STATCARRY2_TPKT 12
288#define S6_GMAC_STATCARRY2_TBYT 13
289#define S6_GMAC_STATCARRY2_TFRG 14
290#define S6_GMAC_STATCARRY2_TUND 15
291#define S6_GMAC_STATCARRY2_TOVR 16
292#define S6_GMAC_STATCARRY2_TXCF 17
293#define S6_GMAC_STATCARRY2_TFCS 18
294#define S6_GMAC_STATCARRY2_TJBR 19
295
296#define S6_GMAC_HOST_PBLKCTRL 0x140
297#define S6_GMAC_HOST_PBLKCTRL_TXENA 0
298#define S6_GMAC_HOST_PBLKCTRL_RXENA 1
299#define S6_GMAC_HOST_PBLKCTRL_TXSRES 2
300#define S6_GMAC_HOST_PBLKCTRL_RXSRES 3
301#define S6_GMAC_HOST_PBLKCTRL_TXBSIZ 8
302#define S6_GMAC_HOST_PBLKCTRL_RXBSIZ 12
303#define S6_GMAC_HOST_PBLKCTRL_SIZ_16 4
304#define S6_GMAC_HOST_PBLKCTRL_SIZ_32 5
305#define S6_GMAC_HOST_PBLKCTRL_SIZ_64 6
306#define S6_GMAC_HOST_PBLKCTRL_SIZ_128 7
307#define S6_GMAC_HOST_PBLKCTRL_SIZ_MASK 0xF
308#define S6_GMAC_HOST_PBLKCTRL_STATENA 16
309#define S6_GMAC_HOST_PBLKCTRL_STATAUTOZ 17
310#define S6_GMAC_HOST_PBLKCTRL_STATCLEAR 18
311#define S6_GMAC_HOST_PBLKCTRL_RGMII 19
312#define S6_GMAC_HOST_INTMASK 0x144
313#define S6_GMAC_HOST_INTSTAT 0x148
314#define S6_GMAC_HOST_INT_TXBURSTOVER 3
315#define S6_GMAC_HOST_INT_TXPREWOVER 4
316#define S6_GMAC_HOST_INT_RXBURSTUNDER 5
317#define S6_GMAC_HOST_INT_RXPOSTRFULL 6
318#define S6_GMAC_HOST_INT_RXPOSTRUNDER 7
319#define S6_GMAC_HOST_RXFIFOHWM 0x14C
320#define S6_GMAC_HOST_CTRLFRAMXP 0x150
321#define S6_GMAC_HOST_DSTADDRLO(n) (0x160 + 8*(n))
322#define S6_GMAC_HOST_DSTADDRHI(n) (0x164 + 8*(n))
323#define S6_GMAC_HOST_DSTMASKLO(n) (0x180 + 8*(n))
324#define S6_GMAC_HOST_DSTMASKHI(n) (0x184 + 8*(n))
325
326#define S6_GMAC_BURST_PREWR 0x1B0
327#define S6_GMAC_BURST_PREWR_LEN 0
328#define S6_GMAC_BURST_PREWR_LEN_MASK ((1 << 20) - 1)
329#define S6_GMAC_BURST_PREWR_CFE 20
330#define S6_GMAC_BURST_PREWR_PPE 21
331#define S6_GMAC_BURST_PREWR_FCS 22
332#define S6_GMAC_BURST_PREWR_PAD 23
333#define S6_GMAC_BURST_POSTRD 0x1D0
334#define S6_GMAC_BURST_POSTRD_LEN 0
335#define S6_GMAC_BURST_POSTRD_LEN_MASK ((1 << 20) - 1)
336#define S6_GMAC_BURST_POSTRD_DROP 20
337
338
339/* data handling */
340
341#define S6_NUM_TX_SKB 8 /* must be larger than TX fifo size */
342#define S6_NUM_RX_SKB 16
343#define S6_MAX_FRLEN 1536
344
345struct s6gmac {
346 u32 reg;
347 u32 tx_dma;
348 u32 rx_dma;
349 u32 io;
350 u8 tx_chan;
351 u8 rx_chan;
352 spinlock_t lock;
353 u8 tx_skb_i, tx_skb_o;
354 u8 rx_skb_i, rx_skb_o;
355 struct sk_buff *tx_skb[S6_NUM_TX_SKB];
356 struct sk_buff *rx_skb[S6_NUM_RX_SKB];
357 unsigned long carry[sizeof(struct net_device_stats) / sizeof(long)];
358 unsigned long stats[sizeof(struct net_device_stats) / sizeof(long)];
359 struct phy_device *phydev;
360 struct {
361 struct mii_bus *bus;
362 int irq[PHY_MAX_ADDR];
363 } mii;
364 struct {
365 unsigned int mbit;
366 u8 giga;
367 u8 isup;
368 u8 full;
369 } link;
370};
371
372static void s6gmac_rx_fillfifo(struct net_device *dev)
373{
374 struct s6gmac *pd = netdev_priv(dev);
375 struct sk_buff *skb;
376 while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) &&
377 (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) &&
378 (skb = netdev_alloc_skb(dev, S6_MAX_FRLEN + 2))) {
379 pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb;
380 s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan,
381 pd->io, (u32)skb->data, S6_MAX_FRLEN);
382 }
383}
384
385static void s6gmac_rx_interrupt(struct net_device *dev)
386{
387 struct s6gmac *pd = netdev_priv(dev);
388 u32 pfx;
389 struct sk_buff *skb;
390 while (((u8)(pd->rx_skb_i - pd->rx_skb_o)) >
391 s6dmac_pending_count(pd->rx_dma, pd->rx_chan)) {
392 skb = pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB];
393 pfx = readl(pd->reg + S6_GMAC_BURST_POSTRD);
394 if (pfx & (1 << S6_GMAC_BURST_POSTRD_DROP)) {
395 dev_kfree_skb_irq(skb);
396 } else {
397 skb_put(skb, (pfx >> S6_GMAC_BURST_POSTRD_LEN)
398 & S6_GMAC_BURST_POSTRD_LEN_MASK);
399 skb->protocol = eth_type_trans(skb, dev);
400 skb->ip_summed = CHECKSUM_UNNECESSARY;
401 netif_rx(skb);
402 }
403 }
404}
405
406static void s6gmac_tx_interrupt(struct net_device *dev)
407{
408 struct s6gmac *pd = netdev_priv(dev);
409 while (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >
410 s6dmac_pending_count(pd->tx_dma, pd->tx_chan)) {
411 dev_kfree_skb_irq(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
412 }
413 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
414 netif_wake_queue(dev);
415}
416
417struct s6gmac_statinf {
418 unsigned reg_size : 4; /* 0: unused */
419 unsigned reg_off : 6;
420 unsigned net_index : 6;
421};
422
423#define S6_STATS_B (8 * sizeof(u32))
424#define S6_STATS_C(b, r, f) [b] = { \
425 BUILD_BUG_ON_ZERO(r##_SIZE < S6_GMAC_STAT_SIZE_MIN) + \
426 BUILD_BUG_ON_ZERO((r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1)) \
427 >= (1<<4)) + \
428 r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1), \
429 BUILD_BUG_ON_ZERO(((unsigned)((r - S6_GMAC_STAT_REGS) / sizeof(u32))) \
430 >= ((1<<6)-1)) + \
431 (r - S6_GMAC_STAT_REGS) / sizeof(u32), \
432 BUILD_BUG_ON_ZERO((offsetof(struct net_device_stats, f)) \
433 % sizeof(unsigned long)) + \
434 BUILD_BUG_ON_ZERO((((unsigned)(offsetof(struct net_device_stats, f)) \
435 / sizeof(unsigned long)) >= (1<<6))) + \
436 BUILD_BUG_ON_ZERO((sizeof(((struct net_device_stats *)0)->f) \
437 != sizeof(unsigned long))) + \
438 (offsetof(struct net_device_stats, f)) / sizeof(unsigned long)},
439
440static const struct s6gmac_statinf statinf[2][S6_STATS_B] = { {
441 S6_STATS_C(S6_GMAC_STATCARRY1_RBYT, S6_GMAC_STATRBYT, rx_bytes)
442 S6_STATS_C(S6_GMAC_STATCARRY1_RPKT, S6_GMAC_STATRPKT, rx_packets)
443 S6_STATS_C(S6_GMAC_STATCARRY1_RFCS, S6_GMAC_STATRFCS, rx_crc_errors)
444 S6_STATS_C(S6_GMAC_STATCARRY1_RMCA, S6_GMAC_STATRMCA, multicast)
445 S6_STATS_C(S6_GMAC_STATCARRY1_RALN, S6_GMAC_STATRALN, rx_frame_errors)
446 S6_STATS_C(S6_GMAC_STATCARRY1_RFLR, S6_GMAC_STATRFLR, rx_length_errors)
447 S6_STATS_C(S6_GMAC_STATCARRY1_RCDE, S6_GMAC_STATRCDE, rx_missed_errors)
448 S6_STATS_C(S6_GMAC_STATCARRY1_RUND, S6_GMAC_STATRUND, rx_length_errors)
449 S6_STATS_C(S6_GMAC_STATCARRY1_ROVR, S6_GMAC_STATROVR, rx_length_errors)
450 S6_STATS_C(S6_GMAC_STATCARRY1_RFRG, S6_GMAC_STATRFRG, rx_crc_errors)
451 S6_STATS_C(S6_GMAC_STATCARRY1_RJBR, S6_GMAC_STATRJBR, rx_crc_errors)
452 S6_STATS_C(S6_GMAC_STATCARRY1_RDRP, S6_GMAC_STATRDRP, rx_dropped)
453}, {
454 S6_STATS_C(S6_GMAC_STATCARRY2_TBYT, S6_GMAC_STATTBYT, tx_bytes)
455 S6_STATS_C(S6_GMAC_STATCARRY2_TPKT, S6_GMAC_STATTPKT, tx_packets)
456 S6_STATS_C(S6_GMAC_STATCARRY2_TEDF, S6_GMAC_STATTEDF, tx_aborted_errors)
457 S6_STATS_C(S6_GMAC_STATCARRY2_TXCL, S6_GMAC_STATTXCL, tx_aborted_errors)
458 S6_STATS_C(S6_GMAC_STATCARRY2_TNCL, S6_GMAC_STATTNCL, collisions)
459 S6_STATS_C(S6_GMAC_STATCARRY2_TDRP, S6_GMAC_STATTDRP, tx_dropped)
460 S6_STATS_C(S6_GMAC_STATCARRY2_TJBR, S6_GMAC_STATTJBR, tx_errors)
461 S6_STATS_C(S6_GMAC_STATCARRY2_TFCS, S6_GMAC_STATTFCS, tx_errors)
462 S6_STATS_C(S6_GMAC_STATCARRY2_TOVR, S6_GMAC_STATTOVR, tx_errors)
463 S6_STATS_C(S6_GMAC_STATCARRY2_TUND, S6_GMAC_STATTUND, tx_errors)
464 S6_STATS_C(S6_GMAC_STATCARRY2_TFRG, S6_GMAC_STATTFRG, tx_errors)
465} };
466
467static void s6gmac_stats_collect(struct s6gmac *pd,
468 const struct s6gmac_statinf *inf)
469{
470 int b;
471 for (b = 0; b < S6_STATS_B; b++) {
472 if (inf[b].reg_size) {
473 pd->stats[inf[b].net_index] +=
474 readl(pd->reg + S6_GMAC_STAT_REGS
475 + sizeof(u32) * inf[b].reg_off);
476 }
477 }
478}
479
480static void s6gmac_stats_carry(struct s6gmac *pd,
481 const struct s6gmac_statinf *inf, u32 mask)
482{
483 int b;
484 while (mask) {
485 b = fls(mask) - 1;
486 mask &= ~(1 << b);
487 pd->carry[inf[b].net_index] += (1 << inf[b].reg_size);
488 }
489}
490
491static inline u32 s6gmac_stats_pending(struct s6gmac *pd, int carry)
492{
493 int r = readl(pd->reg + S6_GMAC_STATCARRY(carry)) &
494 ~readl(pd->reg + S6_GMAC_STATCARRYMSK(carry));
495 return r;
496}
497
498static inline void s6gmac_stats_interrupt(struct s6gmac *pd, int carry)
499{
500 u32 mask;
501 mask = s6gmac_stats_pending(pd, carry);
502 if (mask) {
503 writel(mask, pd->reg + S6_GMAC_STATCARRY(carry));
504 s6gmac_stats_carry(pd, &statinf[carry][0], mask);
505 }
506}
507
508static irqreturn_t s6gmac_interrupt(int irq, void *dev_id)
509{
510 struct net_device *dev = (struct net_device *)dev_id;
511 struct s6gmac *pd = netdev_priv(dev);
512 if (!dev)
513 return IRQ_NONE;
514 spin_lock(&pd->lock);
515 if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan))
516 s6gmac_rx_interrupt(dev);
517 s6gmac_rx_fillfifo(dev);
518 if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan))
519 s6gmac_tx_interrupt(dev);
520 s6gmac_stats_interrupt(pd, 0);
521 s6gmac_stats_interrupt(pd, 1);
522 spin_unlock(&pd->lock);
523 return IRQ_HANDLED;
524}
525
526static inline void s6gmac_set_dstaddr(struct s6gmac *pd, int n,
527 u32 addrlo, u32 addrhi, u32 masklo, u32 maskhi)
528{
529 writel(addrlo, pd->reg + S6_GMAC_HOST_DSTADDRLO(n));
530 writel(addrhi, pd->reg + S6_GMAC_HOST_DSTADDRHI(n));
531 writel(masklo, pd->reg + S6_GMAC_HOST_DSTMASKLO(n));
532 writel(maskhi, pd->reg + S6_GMAC_HOST_DSTMASKHI(n));
533}
534
535static inline void s6gmac_stop_device(struct net_device *dev)
536{
537 struct s6gmac *pd = netdev_priv(dev);
538 writel(0, pd->reg + S6_GMAC_MACCONF1);
539}
540
541static inline void s6gmac_init_device(struct net_device *dev)
542{
543 struct s6gmac *pd = netdev_priv(dev);
544 int is_rgmii = !!(pd->phydev->supported
545 & (SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half));
546#if 0
547 writel(1 << S6_GMAC_MACCONF1_SYNCTX |
548 1 << S6_GMAC_MACCONF1_SYNCRX |
549 1 << S6_GMAC_MACCONF1_TXFLOWCTRL |
550 1 << S6_GMAC_MACCONF1_RXFLOWCTRL |
551 1 << S6_GMAC_MACCONF1_RESTXFUNC |
552 1 << S6_GMAC_MACCONF1_RESRXFUNC |
553 1 << S6_GMAC_MACCONF1_RESTXMACCTRL |
554 1 << S6_GMAC_MACCONF1_RESRXMACCTRL,
555 pd->reg + S6_GMAC_MACCONF1);
556#endif
557 writel(1 << S6_GMAC_MACCONF1_SOFTRES, pd->reg + S6_GMAC_MACCONF1);
558 udelay(1000);
559 writel(1 << S6_GMAC_MACCONF1_TXENA | 1 << S6_GMAC_MACCONF1_RXENA,
560 pd->reg + S6_GMAC_MACCONF1);
561 writel(1 << S6_GMAC_HOST_PBLKCTRL_TXSRES |
562 1 << S6_GMAC_HOST_PBLKCTRL_RXSRES,
563 pd->reg + S6_GMAC_HOST_PBLKCTRL);
564 writel(S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ |
565 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ |
566 1 << S6_GMAC_HOST_PBLKCTRL_STATENA |
567 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR |
568 is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII,
569 pd->reg + S6_GMAC_HOST_PBLKCTRL);
570 writel(1 << S6_GMAC_MACCONF1_TXENA |
571 1 << S6_GMAC_MACCONF1_RXENA |
572 (dev->flags & IFF_LOOPBACK ? 1 : 0)
573 << S6_GMAC_MACCONF1_LOOPBACK,
574 pd->reg + S6_GMAC_MACCONF1);
575 writel(dev->mtu && (dev->mtu < (S6_MAX_FRLEN - ETH_HLEN-ETH_FCS_LEN)) ?
576 dev->mtu+ETH_HLEN+ETH_FCS_LEN : S6_MAX_FRLEN,
577 pd->reg + S6_GMAC_MACMAXFRAMELEN);
578 writel((pd->link.full ? 1 : 0) << S6_GMAC_MACCONF2_FULL |
579 1 << S6_GMAC_MACCONF2_PADCRCENA |
580 1 << S6_GMAC_MACCONF2_LENGTHFCHK |
581 (pd->link.giga ?
582 S6_GMAC_MACCONF2_IFMODE_BYTE :
583 S6_GMAC_MACCONF2_IFMODE_NIBBLE)
584 << S6_GMAC_MACCONF2_IFMODE |
585 7 << S6_GMAC_MACCONF2_PREAMBLELEN,
586 pd->reg + S6_GMAC_MACCONF2);
587 writel(0, pd->reg + S6_GMAC_MACSTATADDR1);
588 writel(0, pd->reg + S6_GMAC_MACSTATADDR2);
589 writel(1 << S6_GMAC_FIFOCONF0_WTMENREQ |
590 1 << S6_GMAC_FIFOCONF0_SRFENREQ |
591 1 << S6_GMAC_FIFOCONF0_FRFENREQ |
592 1 << S6_GMAC_FIFOCONF0_STFENREQ |
593 1 << S6_GMAC_FIFOCONF0_FTFENREQ,
594 pd->reg + S6_GMAC_FIFOCONF0);
595 writel(128 << S6_GMAC_FIFOCONF3_CFGFTTH |
596 128 << S6_GMAC_FIFOCONF3_CFGHWMFT,
597 pd->reg + S6_GMAC_FIFOCONF3);
598 writel((S6_GMAC_FIFOCONF_RSV_MASK & ~(
599 1 << S6_GMAC_FIFOCONF_RSV_RUNT |
600 1 << S6_GMAC_FIFOCONF_RSV_CRCERR |
601 1 << S6_GMAC_FIFOCONF_RSV_OK |
602 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE |
603 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME |
604 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL |
605 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE |
606 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED)) |
607 1 << S6_GMAC_FIFOCONF5_DROPLT64 |
608 pd->link.giga << S6_GMAC_FIFOCONF5_CFGBYTM |
609 1 << S6_GMAC_FIFOCONF5_RXDROPSIZE,
610 pd->reg + S6_GMAC_FIFOCONF5);
611 writel(1 << S6_GMAC_FIFOCONF_RSV_RUNT |
612 1 << S6_GMAC_FIFOCONF_RSV_CRCERR |
613 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE |
614 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME |
615 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL |
616 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE |
617 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED,
618 pd->reg + S6_GMAC_FIFOCONF4);
619 s6gmac_set_dstaddr(pd, 0,
620 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFFFF, 0x0000FFFF);
621 s6gmac_set_dstaddr(pd, 1,
622 dev->dev_addr[5] |
623 dev->dev_addr[4] << 8 |
624 dev->dev_addr[3] << 16 |
625 dev->dev_addr[2] << 24,
626 dev->dev_addr[1] |
627 dev->dev_addr[0] << 8,
628 0xFFFFFFFF, 0x0000FFFF);
629 s6gmac_set_dstaddr(pd, 2,
630 0x00000000, 0x00000100, 0x00000000, 0x00000100);
631 s6gmac_set_dstaddr(pd, 3,
632 0x00000000, 0x00000000, 0x00000000, 0x00000000);
633 writel(1 << S6_GMAC_HOST_PBLKCTRL_TXENA |
634 1 << S6_GMAC_HOST_PBLKCTRL_RXENA |
635 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ |
636 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ |
637 1 << S6_GMAC_HOST_PBLKCTRL_STATENA |
638 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR |
639 is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII,
640 pd->reg + S6_GMAC_HOST_PBLKCTRL);
641}
642
643static void s6mii_enable(struct s6gmac *pd)
644{
645 writel(readl(pd->reg + S6_GMAC_MACCONF1) &
646 ~(1 << S6_GMAC_MACCONF1_SOFTRES),
647 pd->reg + S6_GMAC_MACCONF1);
648 writel((readl(pd->reg + S6_GMAC_MACMIICONF)
649 & ~(S6_GMAC_MACMIICONF_CSEL_MASK << S6_GMAC_MACMIICONF_CSEL))
650 | (S6_GMAC_MACMIICONF_CSEL_DIV168 << S6_GMAC_MACMIICONF_CSEL),
651 pd->reg + S6_GMAC_MACMIICONF);
652}
653
654static int s6mii_busy(struct s6gmac *pd, int tmo)
655{
656 while (readl(pd->reg + S6_GMAC_MACMIIINDI)) {
657 if (--tmo == 0)
658 return -ETIME;
659 udelay(64);
660 }
661 return 0;
662}
663
664static int s6mii_read(struct mii_bus *bus, int phy_addr, int regnum)
665{
666 struct s6gmac *pd = bus->priv;
667 s6mii_enable(pd);
668 if (s6mii_busy(pd, 256))
669 return -ETIME;
670 writel(phy_addr << S6_GMAC_MACMIIADDR_PHY |
671 regnum << S6_GMAC_MACMIIADDR_REG,
672 pd->reg + S6_GMAC_MACMIIADDR);
673 writel(1 << S6_GMAC_MACMIICMD_READ, pd->reg + S6_GMAC_MACMIICMD);
674 writel(0, pd->reg + S6_GMAC_MACMIICMD);
675 if (s6mii_busy(pd, 256))
676 return -ETIME;
677 return (u16)readl(pd->reg + S6_GMAC_MACMIISTAT);
678}
679
680static int s6mii_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value)
681{
682 struct s6gmac *pd = bus->priv;
683 s6mii_enable(pd);
684 if (s6mii_busy(pd, 256))
685 return -ETIME;
686 writel(phy_addr << S6_GMAC_MACMIIADDR_PHY |
687 regnum << S6_GMAC_MACMIIADDR_REG,
688 pd->reg + S6_GMAC_MACMIIADDR);
689 writel(value, pd->reg + S6_GMAC_MACMIICTRL);
690 if (s6mii_busy(pd, 256))
691 return -ETIME;
692 return 0;
693}
694
695static int s6mii_reset(struct mii_bus *bus)
696{
697 struct s6gmac *pd = bus->priv;
698 s6mii_enable(pd);
699 if (s6mii_busy(pd, PHY_INIT_TIMEOUT))
700 return -ETIME;
701 return 0;
702}
703
704static void s6gmac_set_rgmii_txclock(struct s6gmac *pd)
705{
706 u32 pllsel = readl(S6_REG_GREG1 + S6_GREG1_PLLSEL);
707 pllsel &= ~(S6_GREG1_PLLSEL_GMAC_MASK << S6_GREG1_PLLSEL_GMAC);
708 switch (pd->link.mbit) {
709 case 10:
710 pllsel |= S6_GREG1_PLLSEL_GMAC_2500KHZ << S6_GREG1_PLLSEL_GMAC;
711 break;
712 case 100:
713 pllsel |= S6_GREG1_PLLSEL_GMAC_25MHZ << S6_GREG1_PLLSEL_GMAC;
714 break;
715 case 1000:
716 pllsel |= S6_GREG1_PLLSEL_GMAC_125MHZ << S6_GREG1_PLLSEL_GMAC;
717 break;
718 default:
719 return;
720 }
721 writel(pllsel, S6_REG_GREG1 + S6_GREG1_PLLSEL);
722}
723
724static inline void s6gmac_linkisup(struct net_device *dev, int isup)
725{
726 struct s6gmac *pd = netdev_priv(dev);
727 struct phy_device *phydev = pd->phydev;
728
729 pd->link.full = phydev->duplex;
730 pd->link.giga = (phydev->speed == 1000);
731 if (pd->link.mbit != phydev->speed) {
732 pd->link.mbit = phydev->speed;
733 s6gmac_set_rgmii_txclock(pd);
734 }
735 pd->link.isup = isup;
736 if (isup)
737 netif_carrier_on(dev);
738 phy_print_status(phydev);
739}
740
741static void s6gmac_adjust_link(struct net_device *dev)
742{
743 struct s6gmac *pd = netdev_priv(dev);
744 struct phy_device *phydev = pd->phydev;
745 if (pd->link.isup &&
746 (!phydev->link ||
747 (pd->link.mbit != phydev->speed) ||
748 (pd->link.full != phydev->duplex))) {
749 pd->link.isup = 0;
750 netif_tx_disable(dev);
751 if (!phydev->link) {
752 netif_carrier_off(dev);
753 phy_print_status(phydev);
754 }
755 }
756 if (!pd->link.isup && phydev->link) {
757 if (pd->link.full != phydev->duplex) {
758 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
759 if (phydev->duplex)
760 maccfg |= 1 << S6_GMAC_MACCONF2_FULL;
761 else
762 maccfg &= ~(1 << S6_GMAC_MACCONF2_FULL);
763 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
764 }
765
766 if (pd->link.giga != (phydev->speed == 1000)) {
767 u32 fifocfg = readl(pd->reg + S6_GMAC_FIFOCONF5);
768 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
769 maccfg &= ~(S6_GMAC_MACCONF2_IFMODE_MASK
770 << S6_GMAC_MACCONF2_IFMODE);
771 if (phydev->speed == 1000) {
772 fifocfg |= 1 << S6_GMAC_FIFOCONF5_CFGBYTM;
773 maccfg |= S6_GMAC_MACCONF2_IFMODE_BYTE
774 << S6_GMAC_MACCONF2_IFMODE;
775 } else {
776 fifocfg &= ~(1 << S6_GMAC_FIFOCONF5_CFGBYTM);
777 maccfg |= S6_GMAC_MACCONF2_IFMODE_NIBBLE
778 << S6_GMAC_MACCONF2_IFMODE;
779 }
780 writel(fifocfg, pd->reg + S6_GMAC_FIFOCONF5);
781 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
782 }
783
784 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
785 netif_wake_queue(dev);
786 s6gmac_linkisup(dev, 1);
787 }
788}
789
790static inline int s6gmac_phy_start(struct net_device *dev)
791{
792 struct s6gmac *pd = netdev_priv(dev);
793 int i = 0;
794 struct phy_device *p = NULL;
795 while ((i < PHY_MAX_ADDR) && (!(p = pd->mii.bus->phy_map[i])))
796 i++;
797 p = phy_connect(dev, dev_name(&p->dev), &s6gmac_adjust_link,
798 PHY_INTERFACE_MODE_RGMII);
799 if (IS_ERR(p)) {
800 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
801 return PTR_ERR(p);
802 }
803 p->supported &= PHY_GBIT_FEATURES;
804 p->advertising = p->supported;
805 pd->phydev = p;
806 return 0;
807}
808
809static inline void s6gmac_init_stats(struct net_device *dev)
810{
811 struct s6gmac *pd = netdev_priv(dev);
812 u32 mask;
813 mask = 1 << S6_GMAC_STATCARRY1_RDRP |
814 1 << S6_GMAC_STATCARRY1_RJBR |
815 1 << S6_GMAC_STATCARRY1_RFRG |
816 1 << S6_GMAC_STATCARRY1_ROVR |
817 1 << S6_GMAC_STATCARRY1_RUND |
818 1 << S6_GMAC_STATCARRY1_RCDE |
819 1 << S6_GMAC_STATCARRY1_RFLR |
820 1 << S6_GMAC_STATCARRY1_RALN |
821 1 << S6_GMAC_STATCARRY1_RMCA |
822 1 << S6_GMAC_STATCARRY1_RFCS |
823 1 << S6_GMAC_STATCARRY1_RPKT |
824 1 << S6_GMAC_STATCARRY1_RBYT;
825 writel(mask, pd->reg + S6_GMAC_STATCARRY(0));
826 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(0));
827 mask = 1 << S6_GMAC_STATCARRY2_TDRP |
828 1 << S6_GMAC_STATCARRY2_TNCL |
829 1 << S6_GMAC_STATCARRY2_TXCL |
830 1 << S6_GMAC_STATCARRY2_TEDF |
831 1 << S6_GMAC_STATCARRY2_TPKT |
832 1 << S6_GMAC_STATCARRY2_TBYT |
833 1 << S6_GMAC_STATCARRY2_TFRG |
834 1 << S6_GMAC_STATCARRY2_TUND |
835 1 << S6_GMAC_STATCARRY2_TOVR |
836 1 << S6_GMAC_STATCARRY2_TFCS |
837 1 << S6_GMAC_STATCARRY2_TJBR;
838 writel(mask, pd->reg + S6_GMAC_STATCARRY(1));
839 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(1));
840}
841
842static inline void s6gmac_init_dmac(struct net_device *dev)
843{
844 struct s6gmac *pd = netdev_priv(dev);
845 s6dmac_disable_chan(pd->tx_dma, pd->tx_chan);
846 s6dmac_disable_chan(pd->rx_dma, pd->rx_chan);
847 s6dmac_disable_error_irqs(pd->tx_dma, 1 << S6_HIFDMA_GMACTX);
848 s6dmac_disable_error_irqs(pd->rx_dma, 1 << S6_HIFDMA_GMACRX);
849}
850
851static int s6gmac_tx(struct sk_buff *skb, struct net_device *dev)
852{
853 struct s6gmac *pd = netdev_priv(dev);
854 unsigned long flags;
855
856 spin_lock_irqsave(&pd->lock, flags);
857 writel(skb->len << S6_GMAC_BURST_PREWR_LEN |
858 0 << S6_GMAC_BURST_PREWR_CFE |
859 1 << S6_GMAC_BURST_PREWR_PPE |
860 1 << S6_GMAC_BURST_PREWR_FCS |
861 ((skb->len < ETH_ZLEN) ? 1 : 0) << S6_GMAC_BURST_PREWR_PAD,
862 pd->reg + S6_GMAC_BURST_PREWR);
863 s6dmac_put_fifo_cache(pd->tx_dma, pd->tx_chan,
864 (u32)skb->data, pd->io, skb->len);
865 if (s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
866 netif_stop_queue(dev);
867 if (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >= S6_NUM_TX_SKB) {
868 printk(KERN_ERR "GMAC BUG: skb tx ring overflow [%x, %x]\n",
869 pd->tx_skb_o, pd->tx_skb_i);
870 BUG();
871 }
872 pd->tx_skb[(pd->tx_skb_i++) % S6_NUM_TX_SKB] = skb;
873 spin_unlock_irqrestore(&pd->lock, flags);
874 return 0;
875}
876
877static void s6gmac_tx_timeout(struct net_device *dev)
878{
879 struct s6gmac *pd = netdev_priv(dev);
880 unsigned long flags;
881 spin_lock_irqsave(&pd->lock, flags);
882 s6gmac_tx_interrupt(dev);
883 spin_unlock_irqrestore(&pd->lock, flags);
884}
885
886static int s6gmac_open(struct net_device *dev)
887{
888 struct s6gmac *pd = netdev_priv(dev);
889 unsigned long flags;
890 phy_read_status(pd->phydev);
891 spin_lock_irqsave(&pd->lock, flags);
892 pd->link.mbit = 0;
893 s6gmac_linkisup(dev, pd->phydev->link);
894 s6gmac_init_device(dev);
895 s6gmac_init_stats(dev);
896 s6gmac_init_dmac(dev);
897 s6gmac_rx_fillfifo(dev);
898 s6dmac_enable_chan(pd->rx_dma, pd->rx_chan,
899 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1);
900 s6dmac_enable_chan(pd->tx_dma, pd->tx_chan,
901 2, 0, 1, 0, 0, 0, 0, 7, -1, 2, 0, 1);
902 writel(0 << S6_GMAC_HOST_INT_TXBURSTOVER |
903 0 << S6_GMAC_HOST_INT_TXPREWOVER |
904 0 << S6_GMAC_HOST_INT_RXBURSTUNDER |
905 0 << S6_GMAC_HOST_INT_RXPOSTRFULL |
906 0 << S6_GMAC_HOST_INT_RXPOSTRUNDER,
907 pd->reg + S6_GMAC_HOST_INTMASK);
908 spin_unlock_irqrestore(&pd->lock, flags);
909 phy_start(pd->phydev);
910 netif_start_queue(dev);
911 return 0;
912}
913
914static int s6gmac_stop(struct net_device *dev)
915{
916 struct s6gmac *pd = netdev_priv(dev);
917 unsigned long flags;
918 netif_stop_queue(dev);
919 phy_stop(pd->phydev);
920 spin_lock_irqsave(&pd->lock, flags);
921 s6gmac_init_dmac(dev);
922 s6gmac_stop_device(dev);
923 while (pd->tx_skb_i != pd->tx_skb_o)
924 dev_kfree_skb(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
925 while (pd->rx_skb_i != pd->rx_skb_o)
926 dev_kfree_skb(pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB]);
927 spin_unlock_irqrestore(&pd->lock, flags);
928 return 0;
929}
930
931static struct net_device_stats *s6gmac_stats(struct net_device *dev)
932{
933 struct s6gmac *pd = netdev_priv(dev);
934 struct net_device_stats *st = (struct net_device_stats *)&pd->stats;
935 int i;
936 do {
937 unsigned long flags;
938 spin_lock_irqsave(&pd->lock, flags);
939 for (i = 0; i < ARRAY_SIZE(pd->stats); i++)
940 pd->stats[i] =
941 pd->carry[i] << (S6_GMAC_STAT_SIZE_MIN - 1);
942 s6gmac_stats_collect(pd, &statinf[0][0]);
943 s6gmac_stats_collect(pd, &statinf[1][0]);
944 i = s6gmac_stats_pending(pd, 0) |
945 s6gmac_stats_pending(pd, 1);
946 spin_unlock_irqrestore(&pd->lock, flags);
947 } while (i);
948 st->rx_errors = st->rx_crc_errors +
949 st->rx_frame_errors +
950 st->rx_length_errors +
951 st->rx_missed_errors;
952 st->tx_errors += st->tx_aborted_errors;
953 return st;
954}
955
956static int s6gmac_probe(struct platform_device *pdev)
957{
958 struct net_device *dev;
959 struct s6gmac *pd;
960 int res;
961 unsigned long i;
962 struct mii_bus *mb;
963
964 dev = alloc_etherdev(sizeof(*pd));
965 if (!dev)
966 return -ENOMEM;
967
968 dev->open = s6gmac_open;
969 dev->stop = s6gmac_stop;
970 dev->hard_start_xmit = s6gmac_tx;
971 dev->tx_timeout = s6gmac_tx_timeout;
972 dev->watchdog_timeo = HZ;
973 dev->get_stats = s6gmac_stats;
974 dev->irq = platform_get_irq(pdev, 0);
975 pd = netdev_priv(dev);
976 memset(pd, 0, sizeof(*pd));
977 spin_lock_init(&pd->lock);
978 pd->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0)->start;
979 i = platform_get_resource(pdev, IORESOURCE_DMA, 0)->start;
980 pd->tx_dma = DMA_MASK_DMAC(i);
981 pd->tx_chan = DMA_INDEX_CHNL(i);
982 i = platform_get_resource(pdev, IORESOURCE_DMA, 1)->start;
983 pd->rx_dma = DMA_MASK_DMAC(i);
984 pd->rx_chan = DMA_INDEX_CHNL(i);
985 pd->io = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
986 res = request_irq(dev->irq, s6gmac_interrupt, 0, dev->name, dev);
987 if (res) {
988 printk(KERN_ERR DRV_PRMT "irq request failed: %d\n", dev->irq);
989 goto errirq;
990 }
991 res = register_netdev(dev);
992 if (res) {
993 printk(KERN_ERR DRV_PRMT "error registering device %s\n",
994 dev->name);
995 goto errdev;
996 }
997 mb = mdiobus_alloc();
998 if (!mb) {
999 printk(KERN_ERR DRV_PRMT "error allocating mii bus\n");
1000 res = -ENOMEM;
1001 goto errmii;
1002 }
1003 mb->name = "s6gmac_mii";
1004 mb->read = s6mii_read;
1005 mb->write = s6mii_write;
1006 mb->reset = s6mii_reset;
1007 mb->priv = pd;
1008 snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id);
1009 mb->phy_mask = ~(1 << 0);
1010 mb->irq = &pd->mii.irq[0];
1011 for (i = 0; i < PHY_MAX_ADDR; i++) {
1012 int n = platform_get_irq(pdev, i + 1);
1013 if (n < 0)
1014 n = PHY_POLL;
1015 pd->mii.irq[i] = n;
1016 }
1017 mdiobus_register(mb);
1018 pd->mii.bus = mb;
1019 res = s6gmac_phy_start(dev);
1020 if (res)
1021 return res;
1022 platform_set_drvdata(pdev, dev);
1023 return 0;
1024errmii:
1025 unregister_netdev(dev);
1026errdev:
1027 free_irq(dev->irq, dev);
1028errirq:
1029 free_netdev(dev);
1030 return res;
1031}
1032
1033static int s6gmac_remove(struct platform_device *pdev)
1034{
1035 struct net_device *dev = platform_get_drvdata(pdev);
1036 if (dev) {
1037 struct s6gmac *pd = netdev_priv(dev);
1038 mdiobus_unregister(pd->mii.bus);
1039 unregister_netdev(dev);
1040 free_irq(dev->irq, dev);
1041 free_netdev(dev);
1042 }
1043 return 0;
1044}
1045
1046static struct platform_driver s6gmac_driver = {
1047 .probe = s6gmac_probe,
1048 .remove = s6gmac_remove,
1049 .driver = {
1050 .name = "s6gmac",
1051 },
1052};
1053
1054module_platform_driver(s6gmac_driver);
1055
1056MODULE_LICENSE("GPL");
1057MODULE_DESCRIPTION("S6105 on chip Ethernet driver");
1058MODULE_AUTHOR("Oskar Schirmer <oskar@scara.com>");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 118a427d1942..8c6b7c1651e5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1671,7 +1671,7 @@ static void stmmac_init_tx_coalesce(struct stmmac_priv *priv)
1671 * 0 on success and an appropriate (-)ve integer as defined in errno.h 1671 * 0 on success and an appropriate (-)ve integer as defined in errno.h
1672 * file on failure. 1672 * file on failure.
1673 */ 1673 */
1674static int stmmac_hw_setup(struct net_device *dev) 1674static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
1675{ 1675{
1676 struct stmmac_priv *priv = netdev_priv(dev); 1676 struct stmmac_priv *priv = netdev_priv(dev);
1677 int ret; 1677 int ret;
@@ -1708,9 +1708,11 @@ static int stmmac_hw_setup(struct net_device *dev)
1708 1708
1709 stmmac_mmc_setup(priv); 1709 stmmac_mmc_setup(priv);
1710 1710
1711 ret = stmmac_init_ptp(priv); 1711 if (init_ptp) {
1712 if (ret && ret != -EOPNOTSUPP) 1712 ret = stmmac_init_ptp(priv);
1713 pr_warn("%s: failed PTP initialisation\n", __func__); 1713 if (ret && ret != -EOPNOTSUPP)
1714 pr_warn("%s: failed PTP initialisation\n", __func__);
1715 }
1714 1716
1715#ifdef CONFIG_DEBUG_FS 1717#ifdef CONFIG_DEBUG_FS
1716 ret = stmmac_init_fs(dev); 1718 ret = stmmac_init_fs(dev);
@@ -1787,7 +1789,7 @@ static int stmmac_open(struct net_device *dev)
1787 goto init_error; 1789 goto init_error;
1788 } 1790 }
1789 1791
1790 ret = stmmac_hw_setup(dev); 1792 ret = stmmac_hw_setup(dev, true);
1791 if (ret < 0) { 1793 if (ret < 0) {
1792 pr_err("%s: Hw setup failed\n", __func__); 1794 pr_err("%s: Hw setup failed\n", __func__);
1793 goto init_error; 1795 goto init_error;
@@ -3036,7 +3038,7 @@ int stmmac_resume(struct net_device *ndev)
3036 netif_device_attach(ndev); 3038 netif_device_attach(ndev);
3037 3039
3038 init_dma_desc_rings(ndev, GFP_ATOMIC); 3040 init_dma_desc_rings(ndev, GFP_ATOMIC);
3039 stmmac_hw_setup(ndev); 3041 stmmac_hw_setup(ndev, false);
3040 stmmac_init_tx_coalesce(priv); 3042 stmmac_init_tx_coalesce(priv);
3041 3043
3042 napi_enable(&priv->napi); 3044 napi_enable(&priv->napi);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 4032b170fe24..3039de2465ba 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -430,7 +430,6 @@ static struct platform_driver stmmac_pltfr_driver = {
430 .remove = stmmac_pltfr_remove, 430 .remove = stmmac_pltfr_remove,
431 .driver = { 431 .driver = {
432 .name = STMMAC_RESOURCE_NAME, 432 .name = STMMAC_RESOURCE_NAME,
433 .owner = THIS_MODULE,
434 .pm = &stmmac_pltfr_pm_ops, 433 .pm = &stmmac_pltfr_pm_ops,
435 .of_match_table = of_match_ptr(stmmac_dt_ids), 434 .of_match_table = of_match_ptr(stmmac_dt_ids),
436 }, 435 },
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index 45c408ef67d0..d2835bf7b4fb 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -1201,6 +1201,7 @@ static int vnet_handle_offloads(struct vnet_port *port, struct sk_buff *skb)
1201 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO); 1201 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO);
1202 if (IS_ERR(segs)) { 1202 if (IS_ERR(segs)) {
1203 dev->stats.tx_dropped++; 1203 dev->stats.tx_dropped++;
1204 dev_kfree_skb_any(skb);
1204 return NETDEV_TX_OK; 1205 return NETDEV_TX_OK;
1205 } 1206 }
1206 1207
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c560f9aeb55d..e61ee8351272 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -757,6 +757,14 @@ requeue:
757static irqreturn_t cpsw_interrupt(int irq, void *dev_id) 757static irqreturn_t cpsw_interrupt(int irq, void *dev_id)
758{ 758{
759 struct cpsw_priv *priv = dev_id; 759 struct cpsw_priv *priv = dev_id;
760 int value = irq - priv->irqs_table[0];
761
762 /* NOTICE: Ending IRQ here. The trick with the 'value' variable above
763 * is to make sure we will always write the correct value to the EOI
764 * register. Namely 0 for RX_THRESH Interrupt, 1 for RX Interrupt, 2
765 * for TX Interrupt and 3 for MISC Interrupt.
766 */
767 cpdma_ctlr_eoi(priv->dma, value);
760 768
761 cpsw_intr_disable(priv); 769 cpsw_intr_disable(priv);
762 if (priv->irq_enabled == true) { 770 if (priv->irq_enabled == true) {
@@ -786,8 +794,6 @@ static int cpsw_poll(struct napi_struct *napi, int budget)
786 int num_tx, num_rx; 794 int num_tx, num_rx;
787 795
788 num_tx = cpdma_chan_process(priv->txch, 128); 796 num_tx = cpdma_chan_process(priv->txch, 128);
789 if (num_tx)
790 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
791 797
792 num_rx = cpdma_chan_process(priv->rxch, budget); 798 num_rx = cpdma_chan_process(priv->rxch, budget);
793 if (num_rx < budget) { 799 if (num_rx < budget) {
@@ -795,7 +801,6 @@ static int cpsw_poll(struct napi_struct *napi, int budget)
795 801
796 napi_complete(napi); 802 napi_complete(napi);
797 cpsw_intr_enable(priv); 803 cpsw_intr_enable(priv);
798 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
799 prim_cpsw = cpsw_get_slave_priv(priv, 0); 804 prim_cpsw = cpsw_get_slave_priv(priv, 0);
800 if (prim_cpsw->irq_enabled == false) { 805 if (prim_cpsw->irq_enabled == false) {
801 prim_cpsw->irq_enabled = true; 806 prim_cpsw->irq_enabled = true;
@@ -1310,8 +1315,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
1310 napi_enable(&priv->napi); 1315 napi_enable(&priv->napi);
1311 cpdma_ctlr_start(priv->dma); 1316 cpdma_ctlr_start(priv->dma);
1312 cpsw_intr_enable(priv); 1317 cpsw_intr_enable(priv);
1313 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
1314 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
1315 1318
1316 prim_cpsw = cpsw_get_slave_priv(priv, 0); 1319 prim_cpsw = cpsw_get_slave_priv(priv, 0);
1317 if (prim_cpsw->irq_enabled == false) { 1320 if (prim_cpsw->irq_enabled == false) {
@@ -1578,9 +1581,6 @@ static void cpsw_ndo_tx_timeout(struct net_device *ndev)
1578 cpdma_chan_start(priv->txch); 1581 cpdma_chan_start(priv->txch);
1579 cpdma_ctlr_int_ctrl(priv->dma, true); 1582 cpdma_ctlr_int_ctrl(priv->dma, true);
1580 cpsw_intr_enable(priv); 1583 cpsw_intr_enable(priv);
1581 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
1582 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
1583
1584} 1584}
1585 1585
1586static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p) 1586static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
@@ -1620,9 +1620,6 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
1620 cpsw_interrupt(ndev->irq, priv); 1620 cpsw_interrupt(ndev->irq, priv);
1621 cpdma_ctlr_int_ctrl(priv->dma, true); 1621 cpdma_ctlr_int_ctrl(priv->dma, true);
1622 cpsw_intr_enable(priv); 1622 cpsw_intr_enable(priv);
1623 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
1624 cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
1625
1626} 1623}
1627#endif 1624#endif
1628 1625
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 9c2d91ea0af4..dbcbf0c5bcfa 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -1043,6 +1043,7 @@ static int temac_of_probe(struct platform_device *op)
1043 lp->regs = of_iomap(op->dev.of_node, 0); 1043 lp->regs = of_iomap(op->dev.of_node, 0);
1044 if (!lp->regs) { 1044 if (!lp->regs) {
1045 dev_err(&op->dev, "could not map temac regs.\n"); 1045 dev_err(&op->dev, "could not map temac regs.\n");
1046 rc = -ENOMEM;
1046 goto nodev; 1047 goto nodev;
1047 } 1048 }
1048 1049
@@ -1062,6 +1063,7 @@ static int temac_of_probe(struct platform_device *op)
1062 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0); 1063 np = of_parse_phandle(op->dev.of_node, "llink-connected", 0);
1063 if (!np) { 1064 if (!np) {
1064 dev_err(&op->dev, "could not find DMA node\n"); 1065 dev_err(&op->dev, "could not find DMA node\n");
1066 rc = -ENODEV;
1065 goto err_iounmap; 1067 goto err_iounmap;
1066 } 1068 }
1067 1069
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 44b8d2bad8c3..4c9b4fa1d3c1 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -388,7 +388,6 @@ struct axidma_bd {
388 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors 388 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
389 * @tx_irq: Axidma TX IRQ number 389 * @tx_irq: Axidma TX IRQ number
390 * @rx_irq: Axidma RX IRQ number 390 * @rx_irq: Axidma RX IRQ number
391 * @temac_type: axienet type to identify between soft and hard temac
392 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X 391 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
393 * @options: AxiEthernet option word 392 * @options: AxiEthernet option word
394 * @last_link: Phy link state in which the PHY was negotiated earlier 393 * @last_link: Phy link state in which the PHY was negotiated earlier
@@ -431,7 +430,6 @@ struct axienet_local {
431 430
432 int tx_irq; 431 int tx_irq;
433 int rx_irq; 432 int rx_irq;
434 u32 temac_type;
435 u32 phy_type; 433 u32 phy_type;
436 434
437 u32 options; /* Current options word */ 435 u32 options; /* Current options word */
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 4ea2d4e6f1d1..a6d2860b712c 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1501,6 +1501,7 @@ static int axienet_of_probe(struct platform_device *op)
1501 lp->regs = of_iomap(op->dev.of_node, 0); 1501 lp->regs = of_iomap(op->dev.of_node, 0);
1502 if (!lp->regs) { 1502 if (!lp->regs) {
1503 dev_err(&op->dev, "could not map Axi Ethernet regs.\n"); 1503 dev_err(&op->dev, "could not map Axi Ethernet regs.\n");
1504 ret = -ENOMEM;
1504 goto nodev; 1505 goto nodev;
1505 } 1506 }
1506 /* Setup checksum offload, but default to off if not specified */ 1507 /* Setup checksum offload, but default to off if not specified */
@@ -1555,10 +1556,6 @@ static int axienet_of_probe(struct platform_device *op)
1555 if ((be32_to_cpup(p)) >= 0x4000) 1556 if ((be32_to_cpup(p)) >= 0x4000)
1556 lp->jumbo_support = 1; 1557 lp->jumbo_support = 1;
1557 } 1558 }
1558 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type",
1559 NULL);
1560 if (p)
1561 lp->temac_type = be32_to_cpup(p);
1562 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL); 1559 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL);
1563 if (p) 1560 if (p)
1564 lp->phy_type = be32_to_cpup(p); 1561 lp->phy_type = be32_to_cpup(p);
@@ -1567,6 +1564,7 @@ static int axienet_of_probe(struct platform_device *op)
1567 np = of_parse_phandle(op->dev.of_node, "axistream-connected", 0); 1564 np = of_parse_phandle(op->dev.of_node, "axistream-connected", 0);
1568 if (!np) { 1565 if (!np) {
1569 dev_err(&op->dev, "could not find DMA node\n"); 1566 dev_err(&op->dev, "could not find DMA node\n");
1567 ret = -ENODEV;
1570 goto err_iounmap; 1568 goto err_iounmap;
1571 } 1569 }
1572 lp->dma_regs = of_iomap(np, 0); 1570 lp->dma_regs = of_iomap(np, 0);
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 24858799c204..9d4ce388510a 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1109,6 +1109,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
1109 res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0); 1109 res = platform_get_resource(ofdev, IORESOURCE_IRQ, 0);
1110 if (!res) { 1110 if (!res) {
1111 dev_err(dev, "no IRQ found\n"); 1111 dev_err(dev, "no IRQ found\n");
1112 rc = -ENXIO;
1112 goto error; 1113 goto error;
1113 } 1114 }
1114 1115
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 2f48f790c9b4..384ca4f4de4a 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -590,6 +590,7 @@ struct nvsp_message {
590 590
591 591
592#define NETVSC_RECEIVE_BUFFER_ID 0xcafe 592#define NETVSC_RECEIVE_BUFFER_ID 0xcafe
593#define NETVSC_SEND_BUFFER_ID 0
593 594
594#define NETVSC_PACKET_SIZE 4096 595#define NETVSC_PACKET_SIZE 4096
595 596
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index dd867e6cabd6..9f49c0129a78 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -161,8 +161,8 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
161 161
162 /* Deal with the send buffer we may have setup. 162 /* Deal with the send buffer we may have setup.
163 * If we got a send section size, it means we received a 163 * If we got a send section size, it means we received a
164 * SendsendBufferComplete msg (ie sent 164 * NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent
165 * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need 165 * NVSP_MSG1_TYPE_SEND_SEND_BUF msg) therefore, we need
166 * to send a revoke msg here 166 * to send a revoke msg here
167 */ 167 */
168 if (net_device->send_section_size) { 168 if (net_device->send_section_size) {
@@ -172,7 +172,8 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
172 172
173 revoke_packet->hdr.msg_type = 173 revoke_packet->hdr.msg_type =
174 NVSP_MSG1_TYPE_REVOKE_SEND_BUF; 174 NVSP_MSG1_TYPE_REVOKE_SEND_BUF;
175 revoke_packet->msg.v1_msg.revoke_recv_buf.id = 0; 175 revoke_packet->msg.v1_msg.revoke_send_buf.id =
176 NETVSC_SEND_BUFFER_ID;
176 177
177 ret = vmbus_sendpacket(net_device->dev->channel, 178 ret = vmbus_sendpacket(net_device->dev->channel,
178 revoke_packet, 179 revoke_packet,
@@ -204,7 +205,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
204 net_device->send_buf_gpadl_handle = 0; 205 net_device->send_buf_gpadl_handle = 0;
205 } 206 }
206 if (net_device->send_buf) { 207 if (net_device->send_buf) {
207 /* Free up the receive buffer */ 208 /* Free up the send buffer */
208 vfree(net_device->send_buf); 209 vfree(net_device->send_buf);
209 net_device->send_buf = NULL; 210 net_device->send_buf = NULL;
210 } 211 }
@@ -339,9 +340,9 @@ static int netvsc_init_buf(struct hv_device *device)
339 init_packet = &net_device->channel_init_pkt; 340 init_packet = &net_device->channel_init_pkt;
340 memset(init_packet, 0, sizeof(struct nvsp_message)); 341 memset(init_packet, 0, sizeof(struct nvsp_message));
341 init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_SEND_BUF; 342 init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_SEND_BUF;
342 init_packet->msg.v1_msg.send_recv_buf.gpadl_handle = 343 init_packet->msg.v1_msg.send_send_buf.gpadl_handle =
343 net_device->send_buf_gpadl_handle; 344 net_device->send_buf_gpadl_handle;
344 init_packet->msg.v1_msg.send_recv_buf.id = 0; 345 init_packet->msg.v1_msg.send_send_buf.id = NETVSC_SEND_BUFFER_ID;
345 346
346 /* Send the gpadl notification request */ 347 /* Send the gpadl notification request */
347 ret = vmbus_sendpacket(device->channel, init_packet, 348 ret = vmbus_sendpacket(device->channel, init_packet,
@@ -364,7 +365,7 @@ static int netvsc_init_buf(struct hv_device *device)
364 netdev_err(ndev, "Unable to complete send buffer " 365 netdev_err(ndev, "Unable to complete send buffer "
365 "initialization with NetVsp - status %d\n", 366 "initialization with NetVsp - status %d\n",
366 init_packet->msg.v1_msg. 367 init_packet->msg.v1_msg.
367 send_recv_buf_complete.status); 368 send_send_buf_complete.status);
368 ret = -EINVAL; 369 ret = -EINVAL;
369 goto cleanup; 370 goto cleanup;
370 } 371 }
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c530de1e63f5..3ad8ca76196d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -88,6 +88,7 @@ struct kszphy_priv {
88 88
89static const struct kszphy_type ksz8021_type = { 89static const struct kszphy_type ksz8021_type = {
90 .led_mode_reg = MII_KSZPHY_CTRL_2, 90 .led_mode_reg = MII_KSZPHY_CTRL_2,
91 .has_broadcast_disable = true,
91 .has_rmii_ref_clk_sel = true, 92 .has_rmii_ref_clk_sel = true,
92}; 93};
93 94
@@ -258,19 +259,6 @@ static int kszphy_config_init(struct phy_device *phydev)
258 return 0; 259 return 0;
259} 260}
260 261
261static int ksz8021_config_init(struct phy_device *phydev)
262{
263 int rc;
264
265 rc = kszphy_config_init(phydev);
266 if (rc)
267 return rc;
268
269 rc = kszphy_broadcast_disable(phydev);
270
271 return rc < 0 ? rc : 0;
272}
273
274static int ksz9021_load_values_from_of(struct phy_device *phydev, 262static int ksz9021_load_values_from_of(struct phy_device *phydev,
275 struct device_node *of_node, u16 reg, 263 struct device_node *of_node, u16 reg,
276 char *field1, char *field2, 264 char *field1, char *field2,
@@ -584,7 +572,7 @@ static struct phy_driver ksphy_driver[] = {
584 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 572 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
585 .driver_data = &ksz8021_type, 573 .driver_data = &ksz8021_type,
586 .probe = kszphy_probe, 574 .probe = kszphy_probe,
587 .config_init = ksz8021_config_init, 575 .config_init = kszphy_config_init,
588 .config_aneg = genphy_config_aneg, 576 .config_aneg = genphy_config_aneg,
589 .read_status = genphy_read_status, 577 .read_status = genphy_read_status,
590 .ack_interrupt = kszphy_ack_interrupt, 578 .ack_interrupt = kszphy_ack_interrupt,
@@ -601,7 +589,7 @@ static struct phy_driver ksphy_driver[] = {
601 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 589 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
602 .driver_data = &ksz8021_type, 590 .driver_data = &ksz8021_type,
603 .probe = kszphy_probe, 591 .probe = kszphy_probe,
604 .config_init = ksz8021_config_init, 592 .config_init = kszphy_config_init,
605 .config_aneg = genphy_config_aneg, 593 .config_aneg = genphy_config_aneg,
606 .read_status = genphy_read_status, 594 .read_status = genphy_read_status,
607 .ack_interrupt = kszphy_ack_interrupt, 595 .ack_interrupt = kszphy_ack_interrupt,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index b8a82b86f909..602dc6668c3a 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -56,6 +56,8 @@ struct qmi_wwan_state {
56/* default ethernet address used by the modem */ 56/* default ethernet address used by the modem */
57static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3}; 57static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3};
58 58
59static const u8 buggy_fw_addr[ETH_ALEN] = {0x00, 0xa0, 0xc6, 0x00, 0x00, 0x00};
60
59/* Make up an ethernet header if the packet doesn't have one. 61/* Make up an ethernet header if the packet doesn't have one.
60 * 62 *
61 * A firmware bug common among several devices cause them to send raw 63 * A firmware bug common among several devices cause them to send raw
@@ -332,10 +334,12 @@ next_desc:
332 usb_driver_release_interface(driver, info->data); 334 usb_driver_release_interface(driver, info->data);
333 } 335 }
334 336
335 /* Never use the same address on both ends of the link, even 337 /* Never use the same address on both ends of the link, even if the
336 * if the buggy firmware told us to. 338 * buggy firmware told us to. Or, if device is assigned the well-known
339 * buggy firmware MAC address, replace it with a random address,
337 */ 340 */
338 if (ether_addr_equal(dev->net->dev_addr, default_modem_addr)) 341 if (ether_addr_equal(dev->net->dev_addr, default_modem_addr) ||
342 ether_addr_equal(dev->net->dev_addr, buggy_fw_addr))
339 eth_hw_addr_random(dev->net); 343 eth_hw_addr_random(dev->net);
340 344
341 /* make MAC addr easily distinguishable from an IP header */ 345 /* make MAC addr easily distinguishable from an IP header */
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2d1c77e81836..57ec23e8ccfa 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1897,6 +1897,22 @@ static void _rtl8152_set_rx_mode(struct net_device *netdev)
1897 netif_wake_queue(netdev); 1897 netif_wake_queue(netdev);
1898} 1898}
1899 1899
1900static netdev_features_t
1901rtl8152_features_check(struct sk_buff *skb, struct net_device *dev,
1902 netdev_features_t features)
1903{
1904 u32 mss = skb_shinfo(skb)->gso_size;
1905 int max_offset = mss ? GTTCPHO_MAX : TCPHO_MAX;
1906 int offset = skb_transport_offset(skb);
1907
1908 if ((mss || skb->ip_summed == CHECKSUM_PARTIAL) && offset > max_offset)
1909 features &= ~(NETIF_F_ALL_CSUM | NETIF_F_GSO_MASK);
1910 else if ((skb->len + sizeof(struct tx_desc)) > agg_buf_sz)
1911 features &= ~NETIF_F_GSO_MASK;
1912
1913 return features;
1914}
1915
1900static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, 1916static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb,
1901 struct net_device *netdev) 1917 struct net_device *netdev)
1902{ 1918{
@@ -3706,6 +3722,7 @@ static const struct net_device_ops rtl8152_netdev_ops = {
3706 .ndo_set_mac_address = rtl8152_set_mac_address, 3722 .ndo_set_mac_address = rtl8152_set_mac_address,
3707 .ndo_change_mtu = rtl8152_change_mtu, 3723 .ndo_change_mtu = rtl8152_change_mtu,
3708 .ndo_validate_addr = eth_validate_addr, 3724 .ndo_validate_addr = eth_validate_addr,
3725 .ndo_features_check = rtl8152_features_check,
3709}; 3726};
3710 3727
3711static void r8152b_get_version(struct r8152 *tp) 3728static void r8152b_get_version(struct r8152 *tp)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b8bd7191572d..5ca97713bfb3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -760,7 +760,6 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
760 container_of(napi, struct receive_queue, napi); 760 container_of(napi, struct receive_queue, napi);
761 unsigned int r, received = 0; 761 unsigned int r, received = 0;
762 762
763again:
764 received += virtnet_receive(rq, budget - received); 763 received += virtnet_receive(rq, budget - received);
765 764
766 /* Out of packets? */ 765 /* Out of packets? */
@@ -771,7 +770,6 @@ again:
771 napi_schedule_prep(napi)) { 770 napi_schedule_prep(napi)) {
772 virtqueue_disable_cb(rq->vq); 771 virtqueue_disable_cb(rq->vq);
773 __napi_schedule(napi); 772 __napi_schedule(napi);
774 goto again;
775 } 773 }
776 } 774 }
777 775
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 49d9f2291998..7fbd89fbe107 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1579,8 +1579,10 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1579 bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk); 1579 bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk);
1580 1580
1581 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1581 skb = udp_tunnel_handle_offloads(skb, udp_sum);
1582 if (IS_ERR(skb)) 1582 if (IS_ERR(skb)) {
1583 return -EINVAL; 1583 err = -EINVAL;
1584 goto err;
1585 }
1584 1586
1585 skb_scrub_packet(skb, xnet); 1587 skb_scrub_packet(skb, xnet);
1586 1588
@@ -1590,12 +1592,16 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1590 1592
1591 /* Need space for new headers (invalidates iph ptr) */ 1593 /* Need space for new headers (invalidates iph ptr) */
1592 err = skb_cow_head(skb, min_headroom); 1594 err = skb_cow_head(skb, min_headroom);
1593 if (unlikely(err)) 1595 if (unlikely(err)) {
1594 return err; 1596 kfree_skb(skb);
1597 goto err;
1598 }
1595 1599
1596 skb = vlan_hwaccel_push_inside(skb); 1600 skb = vlan_hwaccel_push_inside(skb);
1597 if (WARN_ON(!skb)) 1601 if (WARN_ON(!skb)) {
1598 return -ENOMEM; 1602 err = -ENOMEM;
1603 goto err;
1604 }
1599 1605
1600 vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh)); 1606 vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
1601 vxh->vx_flags = htonl(VXLAN_FLAGS); 1607 vxh->vx_flags = htonl(VXLAN_FLAGS);
@@ -1606,6 +1612,9 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1606 udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio, 1612 udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio,
1607 ttl, src_port, dst_port); 1613 ttl, src_port, dst_port);
1608 return 0; 1614 return 0;
1615err:
1616 dst_release(dst);
1617 return err;
1609} 1618}
1610#endif 1619#endif
1611 1620
@@ -1621,7 +1630,7 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
1621 1630
1622 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1631 skb = udp_tunnel_handle_offloads(skb, udp_sum);
1623 if (IS_ERR(skb)) 1632 if (IS_ERR(skb))
1624 return -EINVAL; 1633 return PTR_ERR(skb);
1625 1634
1626 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len 1635 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
1627 + VXLAN_HLEN + sizeof(struct iphdr) 1636 + VXLAN_HLEN + sizeof(struct iphdr)
@@ -1629,8 +1638,10 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
1629 1638
1630 /* Need space for new headers (invalidates iph ptr) */ 1639 /* Need space for new headers (invalidates iph ptr) */
1631 err = skb_cow_head(skb, min_headroom); 1640 err = skb_cow_head(skb, min_headroom);
1632 if (unlikely(err)) 1641 if (unlikely(err)) {
1642 kfree_skb(skb);
1633 return err; 1643 return err;
1644 }
1634 1645
1635 skb = vlan_hwaccel_push_inside(skb); 1646 skb = vlan_hwaccel_push_inside(skb);
1636 if (WARN_ON(!skb)) 1647 if (WARN_ON(!skb))
@@ -1776,9 +1787,12 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1776 tos, ttl, df, src_port, dst_port, 1787 tos, ttl, df, src_port, dst_port,
1777 htonl(vni << 8), 1788 htonl(vni << 8),
1778 !net_eq(vxlan->net, dev_net(vxlan->dev))); 1789 !net_eq(vxlan->net, dev_net(vxlan->dev)));
1779 1790 if (err < 0) {
1780 if (err < 0) 1791 /* skb is already freed. */
1792 skb = NULL;
1781 goto rt_tx_error; 1793 goto rt_tx_error;
1794 }
1795
1782 iptunnel_xmit_stats(err, &dev->stats, dev->tstats); 1796 iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
1783#if IS_ENABLED(CONFIG_IPV6) 1797#if IS_ENABLED(CONFIG_IPV6)
1784 } else { 1798 } else {
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index 3c06e9365949..9880dae2a569 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -1070,7 +1070,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
1070 */ 1070 */
1071 if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) && 1071 if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
1072 ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) || 1072 ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
1073 (sdiodev->pdata->oob_irq_supported))) 1073 (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
1074 bus_if->wowl_supported = true; 1074 bus_if->wowl_supported = true;
1075#endif 1075#endif
1076 1076
@@ -1167,7 +1167,7 @@ static int brcmf_ops_sdio_resume(struct device *dev)
1167 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; 1167 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
1168 1168
1169 brcmf_dbg(SDIO, "Enter\n"); 1169 brcmf_dbg(SDIO, "Enter\n");
1170 if (sdiodev->pdata->oob_irq_supported) 1170 if (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)
1171 disable_irq_wake(sdiodev->pdata->oob_irq_nr); 1171 disable_irq_wake(sdiodev->pdata->oob_irq_nr);
1172 brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS); 1172 brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS);
1173 atomic_set(&sdiodev->suspend, false); 1173 atomic_set(&sdiodev->suspend, false);
diff --git a/drivers/net/wireless/ipw2x00/Kconfig b/drivers/net/wireless/ipw2x00/Kconfig
index 91c0cb3c368e..21de4fe6cf2d 100644
--- a/drivers/net/wireless/ipw2x00/Kconfig
+++ b/drivers/net/wireless/ipw2x00/Kconfig
@@ -65,7 +65,8 @@ config IPW2100_DEBUG
65 65
66config IPW2200 66config IPW2200
67 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" 67 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
68 depends on PCI && CFG80211 && CFG80211_WEXT 68 depends on PCI && CFG80211
69 select CFG80211_WEXT
69 select WIRELESS_EXT 70 select WIRELESS_EXT
70 select WEXT_SPY 71 select WEXT_SPY
71 select WEXT_PRIV 72 select WEXT_PRIV
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 38de1513e4de..850b85a47806 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -1323,10 +1323,10 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
1323 1323
1324 try_again: 1324 try_again:
1325 /* try next, if any */ 1325 /* try next, if any */
1326 kfree(pieces);
1327 release_firmware(ucode_raw); 1326 release_firmware(ucode_raw);
1328 if (iwl_request_firmware(drv, false)) 1327 if (iwl_request_firmware(drv, false))
1329 goto out_unbind; 1328 goto out_unbind;
1329 kfree(pieces);
1330 return; 1330 return;
1331 1331
1332 out_free_fw: 1332 out_free_fw:
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index 9564ae173d06..1f7f15eb86da 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -310,6 +310,7 @@ static inline unsigned int FH_MEM_CBBC_QUEUE(unsigned int chnl)
310#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) 310#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
311 311
312#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 312#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
313#define FH_MEM_TB_MAX_LENGTH (0x00020000)
313 314
314/* TFDB Area - TFDs buffer table */ 315/* TFDB Area - TFDs buffer table */
315#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) 316#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 31a5b3f4266c..e880f9d4717b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1004,8 +1004,13 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
1004{ 1004{
1005 lockdep_assert_held(&mvm->mutex); 1005 lockdep_assert_held(&mvm->mutex);
1006 1006
1007 /* disallow low power states when the FW is down */ 1007 /*
1008 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); 1008 * Disallow low power states when the FW is down by taking
1009 * the UCODE_DOWN ref. in case of ongoing hw restart the
1010 * ref is already taken, so don't take it again.
1011 */
1012 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1013 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
1009 1014
1010 /* async_handlers_wk is now blocked */ 1015 /* async_handlers_wk is now blocked */
1011 1016
@@ -1023,6 +1028,12 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
1023 /* the fw is stopped, the aux sta is dead: clean up driver state */ 1028 /* the fw is stopped, the aux sta is dead: clean up driver state */
1024 iwl_mvm_del_aux_sta(mvm); 1029 iwl_mvm_del_aux_sta(mvm);
1025 1030
1031 /*
1032 * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete()
1033 * won't be called in this case).
1034 */
1035 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1036
1026 mvm->ucode_loaded = false; 1037 mvm->ucode_loaded = false;
1027} 1038}
1028 1039
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 3ee8e3848876..2f0c4b170344 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -367,7 +367,11 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
367 367
368/* 3165 Series */ 368/* 3165 Series */
369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)}, 372 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)},
373 {IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)},
374 {IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)},
371 375
372/* 7265 Series */ 376/* 7265 Series */
373 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)}, 377 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 5d79a1f44b8e..523fe0c88dcb 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -614,7 +614,7 @@ static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,
614{ 614{
615 u8 *v_addr; 615 u8 *v_addr;
616 dma_addr_t p_addr; 616 dma_addr_t p_addr;
617 u32 offset, chunk_sz = section->len; 617 u32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len);
618 int ret = 0; 618 int ret = 0;
619 619
620 IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n", 620 IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n",
@@ -1012,16 +1012,21 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1012 /* Stop the device, and put it in low power state */ 1012 /* Stop the device, and put it in low power state */
1013 iwl_pcie_apm_stop(trans); 1013 iwl_pcie_apm_stop(trans);
1014 1014
1015 /* Upon stop, the APM issues an interrupt if HW RF kill is set. 1015 /* stop and reset the on-board processor */
1016 * Clean again the interrupt here 1016 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1017 udelay(20);
1018
1019 /*
1020 * Upon stop, the APM issues an interrupt if HW RF kill is set.
1021 * This is a bug in certain verions of the hardware.
1022 * Certain devices also keep sending HW RF kill interrupt all
1023 * the time, unless the interrupt is ACKed even if the interrupt
1024 * should be masked. Re-ACK all the interrupts here.
1017 */ 1025 */
1018 spin_lock(&trans_pcie->irq_lock); 1026 spin_lock(&trans_pcie->irq_lock);
1019 iwl_disable_interrupts(trans); 1027 iwl_disable_interrupts(trans);
1020 spin_unlock(&trans_pcie->irq_lock); 1028 spin_unlock(&trans_pcie->irq_lock);
1021 1029
1022 /* stop and reset the on-board processor */
1023 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1024 udelay(20);
1025 1030
1026 /* clear all status bits */ 1031 /* clear all status bits */
1027 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1032 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index efbaf2ae1999..794204e34fba 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -737,6 +737,7 @@ static void connect(struct backend_info *be)
737 } 737 }
738 738
739 queue->remaining_credit = credit_bytes; 739 queue->remaining_credit = credit_bytes;
740 queue->credit_usec = credit_usec;
740 741
741 err = connect_rings(be, queue); 742 err = connect_rings(be, queue);
742 if (err) { 743 if (err) {
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index ba74f0aa60c7..3c22dbebc80f 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -89,6 +89,7 @@ struct rockchip_iomux {
89 * @reg_pull: optional separate register for additional pull settings 89 * @reg_pull: optional separate register for additional pull settings
90 * @clk: clock of the gpio bank 90 * @clk: clock of the gpio bank
91 * @irq: interrupt of the gpio bank 91 * @irq: interrupt of the gpio bank
92 * @saved_enables: Saved content of GPIO_INTEN at suspend time.
92 * @pin_base: first pin number 93 * @pin_base: first pin number
93 * @nr_pins: number of pins in this bank 94 * @nr_pins: number of pins in this bank
94 * @name: name of the bank 95 * @name: name of the bank
@@ -107,6 +108,7 @@ struct rockchip_pin_bank {
107 struct regmap *regmap_pull; 108 struct regmap *regmap_pull;
108 struct clk *clk; 109 struct clk *clk;
109 int irq; 110 int irq;
111 u32 saved_enables;
110 u32 pin_base; 112 u32 pin_base;
111 u8 nr_pins; 113 u8 nr_pins;
112 char *name; 114 char *name;
@@ -1543,6 +1545,51 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
1543 return 0; 1545 return 0;
1544} 1546}
1545 1547
1548static void rockchip_irq_suspend(struct irq_data *d)
1549{
1550 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1551 struct rockchip_pin_bank *bank = gc->private;
1552
1553 bank->saved_enables = irq_reg_readl(gc, GPIO_INTEN);
1554 irq_reg_writel(gc, gc->wake_active, GPIO_INTEN);
1555}
1556
1557static void rockchip_irq_resume(struct irq_data *d)
1558{
1559 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1560 struct rockchip_pin_bank *bank = gc->private;
1561
1562 irq_reg_writel(gc, bank->saved_enables, GPIO_INTEN);
1563}
1564
1565static void rockchip_irq_disable(struct irq_data *d)
1566{
1567 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1568 u32 val;
1569
1570 irq_gc_lock(gc);
1571
1572 val = irq_reg_readl(gc, GPIO_INTEN);
1573 val &= ~d->mask;
1574 irq_reg_writel(gc, val, GPIO_INTEN);
1575
1576 irq_gc_unlock(gc);
1577}
1578
1579static void rockchip_irq_enable(struct irq_data *d)
1580{
1581 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1582 u32 val;
1583
1584 irq_gc_lock(gc);
1585
1586 val = irq_reg_readl(gc, GPIO_INTEN);
1587 val |= d->mask;
1588 irq_reg_writel(gc, val, GPIO_INTEN);
1589
1590 irq_gc_unlock(gc);
1591}
1592
1546static int rockchip_interrupts_register(struct platform_device *pdev, 1593static int rockchip_interrupts_register(struct platform_device *pdev,
1547 struct rockchip_pinctrl *info) 1594 struct rockchip_pinctrl *info)
1548{ 1595{
@@ -1581,12 +1628,16 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
1581 gc = irq_get_domain_generic_chip(bank->domain, 0); 1628 gc = irq_get_domain_generic_chip(bank->domain, 0);
1582 gc->reg_base = bank->reg_base; 1629 gc->reg_base = bank->reg_base;
1583 gc->private = bank; 1630 gc->private = bank;
1584 gc->chip_types[0].regs.mask = GPIO_INTEN; 1631 gc->chip_types[0].regs.mask = GPIO_INTMASK;
1585 gc->chip_types[0].regs.ack = GPIO_PORTS_EOI; 1632 gc->chip_types[0].regs.ack = GPIO_PORTS_EOI;
1586 gc->chip_types[0].chip.irq_ack = irq_gc_ack_set_bit; 1633 gc->chip_types[0].chip.irq_ack = irq_gc_ack_set_bit;
1587 gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; 1634 gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit;
1588 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; 1635 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit;
1636 gc->chip_types[0].chip.irq_enable = rockchip_irq_enable;
1637 gc->chip_types[0].chip.irq_disable = rockchip_irq_disable;
1589 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; 1638 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake;
1639 gc->chip_types[0].chip.irq_suspend = rockchip_irq_suspend;
1640 gc->chip_types[0].chip.irq_resume = rockchip_irq_resume;
1590 gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; 1641 gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type;
1591 gc->wake_enabled = IRQ_MSK(bank->nr_pins); 1642 gc->wake_enabled = IRQ_MSK(bank->nr_pins);
1592 1643
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 7c9d51382248..9e5ec00084bb 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1012,8 +1012,10 @@ static void st_pinconf_dbg_show(struct pinctrl_dev *pctldev,
1012 struct seq_file *s, unsigned pin_id) 1012 struct seq_file *s, unsigned pin_id)
1013{ 1013{
1014 unsigned long config; 1014 unsigned long config;
1015 st_pinconf_get(pctldev, pin_id, &config);
1016 1015
1016 mutex_unlock(&pctldev->mutex);
1017 st_pinconf_get(pctldev, pin_id, &config);
1018 mutex_lock(&pctldev->mutex);
1017 seq_printf(s, "[OE:%ld,PU:%ld,OD:%ld]\n" 1019 seq_printf(s, "[OE:%ld,PU:%ld,OD:%ld]\n"
1018 "\t\t[retime:%ld,invclk:%ld,clknotdat:%ld," 1020 "\t\t[retime:%ld,invclk:%ld,clknotdat:%ld,"
1019 "de:%ld,rt-clk:%ld,rt-delay:%ld]", 1021 "de:%ld,rt-clk:%ld,rt-delay:%ld]",
@@ -1443,6 +1445,7 @@ static struct gpio_chip st_gpio_template = {
1443 1445
1444static struct irq_chip st_gpio_irqchip = { 1446static struct irq_chip st_gpio_irqchip = {
1445 .name = "GPIO", 1447 .name = "GPIO",
1448 .irq_disable = st_gpio_irq_mask,
1446 .irq_mask = st_gpio_irq_mask, 1449 .irq_mask = st_gpio_irq_mask,
1447 .irq_unmask = st_gpio_irq_unmask, 1450 .irq_unmask = st_gpio_irq_unmask,
1448 .irq_set_type = st_gpio_irq_set_type, 1451 .irq_set_type = st_gpio_irq_set_type,
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index c71443c4f265..97b5e4ee1ca4 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -1041,6 +1041,7 @@ static const struct x86_cpu_id rapl_ids[] = {
1041 RAPL_CPU(0x45, rapl_defaults_core),/* Haswell ULT */ 1041 RAPL_CPU(0x45, rapl_defaults_core),/* Haswell ULT */
1042 RAPL_CPU(0x4C, rapl_defaults_atom),/* Braswell */ 1042 RAPL_CPU(0x4C, rapl_defaults_atom),/* Braswell */
1043 RAPL_CPU(0x4A, rapl_defaults_atom),/* Tangier */ 1043 RAPL_CPU(0x4A, rapl_defaults_atom),/* Tangier */
1044 RAPL_CPU(0x56, rapl_defaults_core),/* Future Xeon */
1044 RAPL_CPU(0x5A, rapl_defaults_atom),/* Annidale */ 1045 RAPL_CPU(0x5A, rapl_defaults_atom),/* Annidale */
1045 {} 1046 {}
1046}; 1047};
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
index c1444c3d84c2..2809ae0d6bcd 100644
--- a/drivers/regulator/s2mps11.c
+++ b/drivers/regulator/s2mps11.c
@@ -570,7 +570,7 @@ static struct regulator_ops s2mps14_reg_ops = {
570 .enable_mask = S2MPS14_ENABLE_MASK \ 570 .enable_mask = S2MPS14_ENABLE_MASK \
571} 571}
572 572
573#define regulator_desc_s2mps14_buck(num, min, step) { \ 573#define regulator_desc_s2mps14_buck(num, min, step, min_sel) { \
574 .name = "BUCK"#num, \ 574 .name = "BUCK"#num, \
575 .id = S2MPS14_BUCK##num, \ 575 .id = S2MPS14_BUCK##num, \
576 .ops = &s2mps14_reg_ops, \ 576 .ops = &s2mps14_reg_ops, \
@@ -579,7 +579,7 @@ static struct regulator_ops s2mps14_reg_ops = {
579 .min_uV = min, \ 579 .min_uV = min, \
580 .uV_step = step, \ 580 .uV_step = step, \
581 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \ 581 .n_voltages = S2MPS14_BUCK_N_VOLTAGES, \
582 .linear_min_sel = S2MPS14_BUCK1235_START_SEL, \ 582 .linear_min_sel = min_sel, \
583 .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \ 583 .ramp_delay = S2MPS14_BUCK_RAMP_DELAY, \
584 .vsel_reg = S2MPS14_REG_B1CTRL2 + (num - 1) * 2, \ 584 .vsel_reg = S2MPS14_REG_B1CTRL2 + (num - 1) * 2, \
585 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \ 585 .vsel_mask = S2MPS14_BUCK_VSEL_MASK, \
@@ -613,11 +613,16 @@ static const struct regulator_desc s2mps14_regulators[] = {
613 regulator_desc_s2mps14_ldo(23, MIN_800_MV, STEP_25_MV), 613 regulator_desc_s2mps14_ldo(23, MIN_800_MV, STEP_25_MV),
614 regulator_desc_s2mps14_ldo(24, MIN_1800_MV, STEP_25_MV), 614 regulator_desc_s2mps14_ldo(24, MIN_1800_MV, STEP_25_MV),
615 regulator_desc_s2mps14_ldo(25, MIN_1800_MV, STEP_25_MV), 615 regulator_desc_s2mps14_ldo(25, MIN_1800_MV, STEP_25_MV),
616 regulator_desc_s2mps14_buck(1, MIN_600_MV, STEP_6_25_MV), 616 regulator_desc_s2mps14_buck(1, MIN_600_MV, STEP_6_25_MV,
617 regulator_desc_s2mps14_buck(2, MIN_600_MV, STEP_6_25_MV), 617 S2MPS14_BUCK1235_START_SEL),
618 regulator_desc_s2mps14_buck(3, MIN_600_MV, STEP_6_25_MV), 618 regulator_desc_s2mps14_buck(2, MIN_600_MV, STEP_6_25_MV,
619 regulator_desc_s2mps14_buck(4, MIN_1400_MV, STEP_12_5_MV), 619 S2MPS14_BUCK1235_START_SEL),
620 regulator_desc_s2mps14_buck(5, MIN_600_MV, STEP_6_25_MV), 620 regulator_desc_s2mps14_buck(3, MIN_600_MV, STEP_6_25_MV,
621 S2MPS14_BUCK1235_START_SEL),
622 regulator_desc_s2mps14_buck(4, MIN_1400_MV, STEP_12_5_MV,
623 S2MPS14_BUCK4_START_SEL),
624 regulator_desc_s2mps14_buck(5, MIN_600_MV, STEP_6_25_MV,
625 S2MPS14_BUCK1235_START_SEL),
621}; 626};
622 627
623static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, 628static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11,
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index f15cddfeb897..f211dfb7b913 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1141,34 +1141,6 @@ config RTC_DRV_AT91SAM9
1141 probably want to use the real RTC block instead of the "RTT as an 1141 probably want to use the real RTC block instead of the "RTT as an
1142 RTC" driver. 1142 RTC" driver.
1143 1143
1144config RTC_DRV_AT91SAM9_RTT
1145 int
1146 range 0 1
1147 default 0
1148 depends on RTC_DRV_AT91SAM9
1149 help
1150 This option is only relevant for legacy board support and
1151 won't be used when booting a DT board.
1152
1153 More than one RTT module is available. You can choose which
1154 one will be used as an RTC. The default of zero is normally
1155 OK to use, though some systems use that for non-RTC purposes.
1156
1157config RTC_DRV_AT91SAM9_GPBR
1158 int
1159 range 0 3
1160 default 0
1161 prompt "Backup Register Number"
1162 depends on RTC_DRV_AT91SAM9
1163 help
1164 This option is only relevant for legacy board support and
1165 won't be used when booting a DT board.
1166
1167 The RTC driver needs to use one of the General Purpose Backup
1168 Registers (GPBRs) as well as the RTT. You can choose which one
1169 will be used. The default of zero is normally OK to use, but
1170 on some systems other software needs to use that register.
1171
1172config RTC_DRV_AU1XXX 1144config RTC_DRV_AU1XXX
1173 tristate "Au1xxx Counter0 RTC support" 1145 tristate "Au1xxx Counter0 RTC support"
1174 depends on MIPS_ALCHEMY 1146 depends on MIPS_ALCHEMY
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 3b73b96619e2..26270c351624 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -39,7 +39,7 @@
39 39
40#define DRV_NAME "fnic" 40#define DRV_NAME "fnic"
41#define DRV_DESCRIPTION "Cisco FCoE HBA Driver" 41#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
42#define DRV_VERSION "1.6.0.16" 42#define DRV_VERSION "1.6.0.17"
43#define PFX DRV_NAME ": " 43#define PFX DRV_NAME ": "
44#define DFX DRV_NAME "%d: " 44#define DFX DRV_NAME "%d: "
45 45
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 2097de42a147..155b286f1a9d 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -1892,6 +1892,21 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
1892 goto fnic_abort_cmd_end; 1892 goto fnic_abort_cmd_end;
1893 } 1893 }
1894 1894
1895 /* IO out of order */
1896
1897 if (!(CMD_FLAGS(sc) & (FNIC_IO_ABORTED | FNIC_IO_DONE))) {
1898 spin_unlock_irqrestore(io_lock, flags);
1899 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
1900 "Issuing Host reset due to out of order IO\n");
1901
1902 if (fnic_host_reset(sc) == FAILED) {
1903 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
1904 "fnic_host_reset failed.\n");
1905 }
1906 ret = FAILED;
1907 goto fnic_abort_cmd_end;
1908 }
1909
1895 CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE; 1910 CMD_STATE(sc) = FNIC_IOREQ_ABTS_COMPLETE;
1896 1911
1897 /* 1912 /*
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 12ca291c1380..cce1cbc1a927 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -734,7 +734,9 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
734 * Return target busy if we've received a non-zero retry_delay_timer 734 * Return target busy if we've received a non-zero retry_delay_timer
735 * in a FCP_RSP. 735 * in a FCP_RSP.
736 */ 736 */
737 if (time_after(jiffies, fcport->retry_delay_timestamp)) 737 if (fcport->retry_delay_timestamp == 0) {
738 /* retry delay not set */
739 } else if (time_after(jiffies, fcport->retry_delay_timestamp))
738 fcport->retry_delay_timestamp = 0; 740 fcport->retry_delay_timestamp = 0;
739 else 741 else
740 goto qc24_target_busy; 742 goto qc24_target_busy;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index e42fff6e8c10..8afb01604d51 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1041,7 +1041,7 @@ retry:
1041 } 1041 }
1042 /* signal not to enter either branch of the if () below */ 1042 /* signal not to enter either branch of the if () below */
1043 timeleft = 0; 1043 timeleft = 0;
1044 rtn = NEEDS_RETRY; 1044 rtn = FAILED;
1045 } else { 1045 } else {
1046 timeleft = wait_for_completion_timeout(&done, timeout); 1046 timeleft = wait_for_completion_timeout(&done, timeout);
1047 rtn = SUCCESS; 1047 rtn = SUCCESS;
@@ -1081,7 +1081,7 @@ retry:
1081 rtn = FAILED; 1081 rtn = FAILED;
1082 break; 1082 break;
1083 } 1083 }
1084 } else if (!rtn) { 1084 } else if (rtn != FAILED) {
1085 scsi_abort_eh_cmnd(scmd); 1085 scsi_abort_eh_cmnd(scmd);
1086 rtn = FAILED; 1086 rtn = FAILED;
1087 } 1087 }
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index fedab3c21ddf..399516925d80 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2623,8 +2623,9 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
2623 sd_config_discard(sdkp, SD_LBP_WS16); 2623 sd_config_discard(sdkp, SD_LBP_WS16);
2624 2624
2625 } else { /* LBP VPD page tells us what to use */ 2625 } else { /* LBP VPD page tells us what to use */
2626 2626 if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz)
2627 if (sdkp->lbpws) 2627 sd_config_discard(sdkp, SD_LBP_UNMAP);
2628 else if (sdkp->lbpws)
2628 sd_config_discard(sdkp, SD_LBP_WS16); 2629 sd_config_discard(sdkp, SD_LBP_WS16);
2629 else if (sdkp->lbpws10) 2630 else if (sdkp->lbpws10)
2630 sd_config_discard(sdkp, SD_LBP_WS10); 2631 sd_config_discard(sdkp, SD_LBP_WS10);
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index b410499cddca..aad6683db81b 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -341,7 +341,7 @@ static int img_spfi_start_dma(struct spi_master *master,
341 default: 341 default:
342 rxconf.src_addr = spfi->phys + SPFI_RX_8BIT_VALID_DATA; 342 rxconf.src_addr = spfi->phys + SPFI_RX_8BIT_VALID_DATA;
343 rxconf.src_addr_width = 1; 343 rxconf.src_addr_width = 1;
344 rxconf.src_maxburst = 1; 344 rxconf.src_maxburst = 4;
345 } 345 }
346 dmaengine_slave_config(spfi->rx_ch, &rxconf); 346 dmaengine_slave_config(spfi->rx_ch, &rxconf);
347 347
@@ -368,7 +368,7 @@ static int img_spfi_start_dma(struct spi_master *master,
368 default: 368 default:
369 txconf.dst_addr = spfi->phys + SPFI_TX_8BIT_VALID_DATA; 369 txconf.dst_addr = spfi->phys + SPFI_TX_8BIT_VALID_DATA;
370 txconf.dst_addr_width = 1; 370 txconf.dst_addr_width = 1;
371 txconf.dst_maxburst = 1; 371 txconf.dst_maxburst = 4;
372 break; 372 break;
373 } 373 }
374 dmaengine_slave_config(spfi->tx_ch, &txconf); 374 dmaengine_slave_config(spfi->tx_ch, &txconf);
@@ -390,14 +390,14 @@ static int img_spfi_start_dma(struct spi_master *master,
390 dma_async_issue_pending(spfi->rx_ch); 390 dma_async_issue_pending(spfi->rx_ch);
391 } 391 }
392 392
393 spfi_start(spfi);
394
393 if (xfer->tx_buf) { 395 if (xfer->tx_buf) {
394 spfi->tx_dma_busy = true; 396 spfi->tx_dma_busy = true;
395 dmaengine_submit(txdesc); 397 dmaengine_submit(txdesc);
396 dma_async_issue_pending(spfi->tx_ch); 398 dma_async_issue_pending(spfi->tx_ch);
397 } 399 }
398 400
399 spfi_start(spfi);
400
401 return 1; 401 return 1;
402 402
403stop_dma: 403stop_dma:
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 239be7cbe5a8..96a5fc0878d8 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -480,6 +480,8 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
480 struct device_node *np = spi->master->dev.of_node; 480 struct device_node *np = spi->master->dev.of_node;
481 struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master); 481 struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
482 482
483 pm_runtime_get_sync(&p->pdev->dev);
484
483 if (!np) { 485 if (!np) {
484 /* 486 /*
485 * Use spi->controller_data for CS (same strategy as spi_gpio), 487 * Use spi->controller_data for CS (same strategy as spi_gpio),
@@ -498,6 +500,9 @@ static int sh_msiof_spi_setup(struct spi_device *spi)
498 if (spi->cs_gpio >= 0) 500 if (spi->cs_gpio >= 0)
499 gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); 501 gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
500 502
503
504 pm_runtime_put_sync(&p->pdev->dev);
505
501 return 0; 506 return 0;
502} 507}
503 508
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 1bf891bd321a..4f361b77c749 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -264,7 +264,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
264 264
265 if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) && 265 if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) &&
266 inode->i_sb->s_root != NULL && 266 inode->i_sb->s_root != NULL &&
267 is_root_inode(inode)) 267 !is_root_inode(inode))
268 ll_invalidate_aliases(inode); 268 ll_invalidate_aliases(inode);
269 269
270 iput(inode); 270 iput(inode);
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index ad09e51ffae4..f65f0d109fc8 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -4,6 +4,8 @@
4 * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com) 4 * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)
5 * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org> 5 * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org>
6 * 6 *
7 * Copyright (C) 2014 Viresh Kumar <viresh.kumar@linaro.org>
8 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -28,6 +30,20 @@
28#include <linux/cpu.h> 30#include <linux/cpu.h>
29#include <linux/cpu_cooling.h> 31#include <linux/cpu_cooling.h>
30 32
33/*
34 * Cooling state <-> CPUFreq frequency
35 *
36 * Cooling states are translated to frequencies throughout this driver and this
37 * is the relation between them.
38 *
39 * Highest cooling state corresponds to lowest possible frequency.
40 *
41 * i.e.
42 * level 0 --> 1st Max Freq
43 * level 1 --> 2nd Max Freq
44 * ...
45 */
46
31/** 47/**
32 * struct cpufreq_cooling_device - data for cooling device with cpufreq 48 * struct cpufreq_cooling_device - data for cooling device with cpufreq
33 * @id: unique integer value corresponding to each cpufreq_cooling_device 49 * @id: unique integer value corresponding to each cpufreq_cooling_device
@@ -38,25 +54,27 @@
38 * cooling devices. 54 * cooling devices.
39 * @cpufreq_val: integer value representing the absolute value of the clipped 55 * @cpufreq_val: integer value representing the absolute value of the clipped
40 * frequency. 56 * frequency.
57 * @max_level: maximum cooling level. One less than total number of valid
58 * cpufreq frequencies.
41 * @allowed_cpus: all the cpus involved for this cpufreq_cooling_device. 59 * @allowed_cpus: all the cpus involved for this cpufreq_cooling_device.
60 * @node: list_head to link all cpufreq_cooling_device together.
42 * 61 *
43 * This structure is required for keeping information of each 62 * This structure is required for keeping information of each registered
44 * cpufreq_cooling_device registered. In order to prevent corruption of this a 63 * cpufreq_cooling_device.
45 * mutex lock cooling_cpufreq_lock is used.
46 */ 64 */
47struct cpufreq_cooling_device { 65struct cpufreq_cooling_device {
48 int id; 66 int id;
49 struct thermal_cooling_device *cool_dev; 67 struct thermal_cooling_device *cool_dev;
50 unsigned int cpufreq_state; 68 unsigned int cpufreq_state;
51 unsigned int cpufreq_val; 69 unsigned int cpufreq_val;
70 unsigned int max_level;
71 unsigned int *freq_table; /* In descending order */
52 struct cpumask allowed_cpus; 72 struct cpumask allowed_cpus;
53 struct list_head node; 73 struct list_head node;
54}; 74};
55static DEFINE_IDR(cpufreq_idr); 75static DEFINE_IDR(cpufreq_idr);
56static DEFINE_MUTEX(cooling_cpufreq_lock); 76static DEFINE_MUTEX(cooling_cpufreq_lock);
57 77
58static unsigned int cpufreq_dev_count;
59
60static LIST_HEAD(cpufreq_dev_list); 78static LIST_HEAD(cpufreq_dev_list);
61 79
62/** 80/**
@@ -98,120 +116,30 @@ static void release_idr(struct idr *idr, int id)
98/* Below code defines functions to be used for cpufreq as cooling device */ 116/* Below code defines functions to be used for cpufreq as cooling device */
99 117
100/** 118/**
101 * is_cpufreq_valid - function to check frequency transitioning capability. 119 * get_level: Find the level for a particular frequency
102 * @cpu: cpu for which check is needed. 120 * @cpufreq_dev: cpufreq_dev for which the property is required
121 * @freq: Frequency
103 * 122 *
104 * This function will check the current state of the system if 123 * Return: level on success, THERMAL_CSTATE_INVALID on error.
105 * it is capable of changing the frequency for a given @cpu.
106 *
107 * Return: 0 if the system is not currently capable of changing
108 * the frequency of given cpu. !0 in case the frequency is changeable.
109 */ 124 */
110static int is_cpufreq_valid(int cpu) 125static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_dev,
126 unsigned int freq)
111{ 127{
112 struct cpufreq_policy policy; 128 unsigned long level;
113
114 return !cpufreq_get_policy(&policy, cpu);
115}
116
117enum cpufreq_cooling_property {
118 GET_LEVEL,
119 GET_FREQ,
120 GET_MAXL,
121};
122
123/**
124 * get_property - fetch a property of interest for a give cpu.
125 * @cpu: cpu for which the property is required
126 * @input: query parameter
127 * @output: query return
128 * @property: type of query (frequency, level, max level)
129 *
130 * This is the common function to
131 * 1. get maximum cpu cooling states
132 * 2. translate frequency to cooling state
133 * 3. translate cooling state to frequency
134 * Note that the code may be not in good shape
135 * but it is written in this way in order to:
136 * a) reduce duplicate code as most of the code can be shared.
137 * b) make sure the logic is consistent when translating between
138 * cooling states and frequencies.
139 *
140 * Return: 0 on success, -EINVAL when invalid parameters are passed.
141 */
142static int get_property(unsigned int cpu, unsigned long input,
143 unsigned int *output,
144 enum cpufreq_cooling_property property)
145{
146 int i;
147 unsigned long max_level = 0, level = 0;
148 unsigned int freq = CPUFREQ_ENTRY_INVALID;
149 int descend = -1;
150 struct cpufreq_frequency_table *pos, *table =
151 cpufreq_frequency_get_table(cpu);
152
153 if (!output)
154 return -EINVAL;
155
156 if (!table)
157 return -EINVAL;
158
159 cpufreq_for_each_valid_entry(pos, table) {
160 /* ignore duplicate entry */
161 if (freq == pos->frequency)
162 continue;
163
164 /* get the frequency order */
165 if (freq != CPUFREQ_ENTRY_INVALID && descend == -1)
166 descend = freq > pos->frequency;
167
168 freq = pos->frequency;
169 max_level++;
170 }
171
172 /* No valid cpu frequency entry */
173 if (max_level == 0)
174 return -EINVAL;
175 129
176 /* max_level is an index, not a counter */ 130 for (level = 0; level <= cpufreq_dev->max_level; level++) {
177 max_level--; 131 if (freq == cpufreq_dev->freq_table[level])
132 return level;
178 133
179 /* get max level */ 134 if (freq > cpufreq_dev->freq_table[level])
180 if (property == GET_MAXL) { 135 break;
181 *output = (unsigned int)max_level;
182 return 0;
183 } 136 }
184 137
185 if (property == GET_FREQ) 138 return THERMAL_CSTATE_INVALID;
186 level = descend ? input : (max_level - input);
187
188 i = 0;
189 cpufreq_for_each_valid_entry(pos, table) {
190 /* ignore duplicate entry */
191 if (freq == pos->frequency)
192 continue;
193
194 /* now we have a valid frequency entry */
195 freq = pos->frequency;
196
197 if (property == GET_LEVEL && (unsigned int)input == freq) {
198 /* get level by frequency */
199 *output = descend ? i : (max_level - i);
200 return 0;
201 }
202 if (property == GET_FREQ && level == i) {
203 /* get frequency by level */
204 *output = freq;
205 return 0;
206 }
207 i++;
208 }
209
210 return -EINVAL;
211} 139}
212 140
213/** 141/**
214 * cpufreq_cooling_get_level - for a give cpu, return the cooling level. 142 * cpufreq_cooling_get_level - for a given cpu, return the cooling level.
215 * @cpu: cpu for which the level is required 143 * @cpu: cpu for which the level is required
216 * @freq: the frequency of interest 144 * @freq: the frequency of interest
217 * 145 *
@@ -223,77 +151,21 @@ static int get_property(unsigned int cpu, unsigned long input,
223 */ 151 */
224unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq) 152unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
225{ 153{
226 unsigned int val; 154 struct cpufreq_cooling_device *cpufreq_dev;
227
228 if (get_property(cpu, (unsigned long)freq, &val, GET_LEVEL))
229 return THERMAL_CSTATE_INVALID;
230
231 return (unsigned long)val;
232}
233EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level);
234
235/**
236 * get_cpu_frequency - get the absolute value of frequency from level.
237 * @cpu: cpu for which frequency is fetched.
238 * @level: cooling level
239 *
240 * This function matches cooling level with frequency. Based on a cooling level
241 * of frequency, equals cooling state of cpu cooling device, it will return
242 * the corresponding frequency.
243 * e.g level=0 --> 1st MAX FREQ, level=1 ---> 2nd MAX FREQ, .... etc
244 *
245 * Return: 0 on error, the corresponding frequency otherwise.
246 */
247static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
248{
249 int ret = 0;
250 unsigned int freq;
251
252 ret = get_property(cpu, level, &freq, GET_FREQ);
253 if (ret)
254 return 0;
255
256 return freq;
257}
258
259/**
260 * cpufreq_apply_cooling - function to apply frequency clipping.
261 * @cpufreq_device: cpufreq_cooling_device pointer containing frequency
262 * clipping data.
263 * @cooling_state: value of the cooling state.
264 *
265 * Function used to make sure the cpufreq layer is aware of current thermal
266 * limits. The limits are applied by updating the cpufreq policy.
267 *
268 * Return: 0 on success, an error code otherwise (-EINVAL in case wrong
269 * cooling state).
270 */
271static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device,
272 unsigned long cooling_state)
273{
274 unsigned int cpuid, clip_freq;
275 struct cpumask *mask = &cpufreq_device->allowed_cpus;
276 unsigned int cpu = cpumask_any(mask);
277
278
279 /* Check if the old cooling action is same as new cooling action */
280 if (cpufreq_device->cpufreq_state == cooling_state)
281 return 0;
282
283 clip_freq = get_cpu_frequency(cpu, cooling_state);
284 if (!clip_freq)
285 return -EINVAL;
286
287 cpufreq_device->cpufreq_state = cooling_state;
288 cpufreq_device->cpufreq_val = clip_freq;
289 155
290 for_each_cpu(cpuid, mask) { 156 mutex_lock(&cooling_cpufreq_lock);
291 if (is_cpufreq_valid(cpuid)) 157 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) {
292 cpufreq_update_policy(cpuid); 158 if (cpumask_test_cpu(cpu, &cpufreq_dev->allowed_cpus)) {
159 mutex_unlock(&cooling_cpufreq_lock);
160 return get_level(cpufreq_dev, freq);
161 }
293 } 162 }
163 mutex_unlock(&cooling_cpufreq_lock);
294 164
295 return 0; 165 pr_err("%s: cpu:%d not part of any cooling device\n", __func__, cpu);
166 return THERMAL_CSTATE_INVALID;
296} 167}
168EXPORT_SYMBOL_GPL(cpufreq_cooling_get_level);
297 169
298/** 170/**
299 * cpufreq_thermal_notifier - notifier callback for cpufreq policy change. 171 * cpufreq_thermal_notifier - notifier callback for cpufreq policy change.
@@ -323,11 +195,6 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
323 &cpufreq_dev->allowed_cpus)) 195 &cpufreq_dev->allowed_cpus))
324 continue; 196 continue;
325 197
326 if (!cpufreq_dev->cpufreq_val)
327 cpufreq_dev->cpufreq_val = get_cpu_frequency(
328 cpumask_any(&cpufreq_dev->allowed_cpus),
329 cpufreq_dev->cpufreq_state);
330
331 max_freq = cpufreq_dev->cpufreq_val; 198 max_freq = cpufreq_dev->cpufreq_val;
332 199
333 if (policy->max != max_freq) 200 if (policy->max != max_freq)
@@ -354,19 +221,9 @@ static int cpufreq_get_max_state(struct thermal_cooling_device *cdev,
354 unsigned long *state) 221 unsigned long *state)
355{ 222{
356 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 223 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
357 struct cpumask *mask = &cpufreq_device->allowed_cpus;
358 unsigned int cpu;
359 unsigned int count = 0;
360 int ret;
361
362 cpu = cpumask_any(mask);
363
364 ret = get_property(cpu, 0, &count, GET_MAXL);
365 224
366 if (count > 0) 225 *state = cpufreq_device->max_level;
367 *state = count; 226 return 0;
368
369 return ret;
370} 227}
371 228
372/** 229/**
@@ -403,8 +260,24 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
403 unsigned long state) 260 unsigned long state)
404{ 261{
405 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 262 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
263 unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus);
264 unsigned int clip_freq;
265
266 /* Request state should be less than max_level */
267 if (WARN_ON(state > cpufreq_device->max_level))
268 return -EINVAL;
269
270 /* Check if the old cooling action is same as new cooling action */
271 if (cpufreq_device->cpufreq_state == state)
272 return 0;
406 273
407 return cpufreq_apply_cooling(cpufreq_device, state); 274 clip_freq = cpufreq_device->freq_table[state];
275 cpufreq_device->cpufreq_state = state;
276 cpufreq_device->cpufreq_val = clip_freq;
277
278 cpufreq_update_policy(cpu);
279
280 return 0;
408} 281}
409 282
410/* Bind cpufreq callbacks to thermal cooling device ops */ 283/* Bind cpufreq callbacks to thermal cooling device ops */
@@ -419,10 +292,25 @@ static struct notifier_block thermal_cpufreq_notifier_block = {
419 .notifier_call = cpufreq_thermal_notifier, 292 .notifier_call = cpufreq_thermal_notifier,
420}; 293};
421 294
295static unsigned int find_next_max(struct cpufreq_frequency_table *table,
296 unsigned int prev_max)
297{
298 struct cpufreq_frequency_table *pos;
299 unsigned int max = 0;
300
301 cpufreq_for_each_valid_entry(pos, table) {
302 if (pos->frequency > max && pos->frequency < prev_max)
303 max = pos->frequency;
304 }
305
306 return max;
307}
308
422/** 309/**
423 * __cpufreq_cooling_register - helper function to create cpufreq cooling device 310 * __cpufreq_cooling_register - helper function to create cpufreq cooling device
424 * @np: a valid struct device_node to the cooling device device tree node 311 * @np: a valid struct device_node to the cooling device device tree node
425 * @clip_cpus: cpumask of cpus where the frequency constraints will happen. 312 * @clip_cpus: cpumask of cpus where the frequency constraints will happen.
313 * Normally this should be same as cpufreq policy->related_cpus.
426 * 314 *
427 * This interface function registers the cpufreq cooling device with the name 315 * This interface function registers the cpufreq cooling device with the name
428 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 316 * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq
@@ -437,37 +325,42 @@ __cpufreq_cooling_register(struct device_node *np,
437 const struct cpumask *clip_cpus) 325 const struct cpumask *clip_cpus)
438{ 326{
439 struct thermal_cooling_device *cool_dev; 327 struct thermal_cooling_device *cool_dev;
440 struct cpufreq_cooling_device *cpufreq_dev = NULL; 328 struct cpufreq_cooling_device *cpufreq_dev;
441 unsigned int min = 0, max = 0;
442 char dev_name[THERMAL_NAME_LENGTH]; 329 char dev_name[THERMAL_NAME_LENGTH];
443 int ret = 0, i; 330 struct cpufreq_frequency_table *pos, *table;
444 struct cpufreq_policy policy; 331 unsigned int freq, i;
332 int ret;
445 333
446 /* Verify that all the clip cpus have same freq_min, freq_max limit */ 334 table = cpufreq_frequency_get_table(cpumask_first(clip_cpus));
447 for_each_cpu(i, clip_cpus) { 335 if (!table) {
448 /* continue if cpufreq policy not found and not return error */ 336 pr_debug("%s: CPUFreq table not found\n", __func__);
449 if (!cpufreq_get_policy(&policy, i)) 337 return ERR_PTR(-EPROBE_DEFER);
450 continue;
451 if (min == 0 && max == 0) {
452 min = policy.cpuinfo.min_freq;
453 max = policy.cpuinfo.max_freq;
454 } else {
455 if (min != policy.cpuinfo.min_freq ||
456 max != policy.cpuinfo.max_freq)
457 return ERR_PTR(-EINVAL);
458 }
459 } 338 }
460 cpufreq_dev = kzalloc(sizeof(struct cpufreq_cooling_device), 339
461 GFP_KERNEL); 340 cpufreq_dev = kzalloc(sizeof(*cpufreq_dev), GFP_KERNEL);
462 if (!cpufreq_dev) 341 if (!cpufreq_dev)
463 return ERR_PTR(-ENOMEM); 342 return ERR_PTR(-ENOMEM);
464 343
344 /* Find max levels */
345 cpufreq_for_each_valid_entry(pos, table)
346 cpufreq_dev->max_level++;
347
348 cpufreq_dev->freq_table = kmalloc(sizeof(*cpufreq_dev->freq_table) *
349 cpufreq_dev->max_level, GFP_KERNEL);
350 if (!cpufreq_dev->freq_table) {
351 cool_dev = ERR_PTR(-ENOMEM);
352 goto free_cdev;
353 }
354
355 /* max_level is an index, not a counter */
356 cpufreq_dev->max_level--;
357
465 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus); 358 cpumask_copy(&cpufreq_dev->allowed_cpus, clip_cpus);
466 359
467 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); 360 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id);
468 if (ret) { 361 if (ret) {
469 kfree(cpufreq_dev); 362 cool_dev = ERR_PTR(ret);
470 return ERR_PTR(-EINVAL); 363 goto free_table;
471 } 364 }
472 365
473 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d", 366 snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
@@ -475,25 +368,44 @@ __cpufreq_cooling_register(struct device_node *np,
475 368
476 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, 369 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
477 &cpufreq_cooling_ops); 370 &cpufreq_cooling_ops);
478 if (IS_ERR(cool_dev)) { 371 if (IS_ERR(cool_dev))
479 release_idr(&cpufreq_idr, cpufreq_dev->id); 372 goto remove_idr;
480 kfree(cpufreq_dev); 373
481 return cool_dev; 374 /* Fill freq-table in descending order of frequencies */
375 for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) {
376 freq = find_next_max(table, freq);
377 cpufreq_dev->freq_table[i] = freq;
378
379 /* Warn for duplicate entries */
380 if (!freq)
381 pr_warn("%s: table has duplicate entries\n", __func__);
382 else
383 pr_debug("%s: freq:%u KHz\n", __func__, freq);
482 } 384 }
385
386 cpufreq_dev->cpufreq_val = cpufreq_dev->freq_table[0];
483 cpufreq_dev->cool_dev = cool_dev; 387 cpufreq_dev->cool_dev = cool_dev;
484 cpufreq_dev->cpufreq_state = 0; 388
485 mutex_lock(&cooling_cpufreq_lock); 389 mutex_lock(&cooling_cpufreq_lock);
486 390
487 /* Register the notifier for first cpufreq cooling device */ 391 /* Register the notifier for first cpufreq cooling device */
488 if (cpufreq_dev_count == 0) 392 if (list_empty(&cpufreq_dev_list))
489 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 393 cpufreq_register_notifier(&thermal_cpufreq_notifier_block,
490 CPUFREQ_POLICY_NOTIFIER); 394 CPUFREQ_POLICY_NOTIFIER);
491 cpufreq_dev_count++;
492 list_add(&cpufreq_dev->node, &cpufreq_dev_list); 395 list_add(&cpufreq_dev->node, &cpufreq_dev_list);
493 396
494 mutex_unlock(&cooling_cpufreq_lock); 397 mutex_unlock(&cooling_cpufreq_lock);
495 398
496 return cool_dev; 399 return cool_dev;
400
401remove_idr:
402 release_idr(&cpufreq_idr, cpufreq_dev->id);
403free_table:
404 kfree(cpufreq_dev->freq_table);
405free_cdev:
406 kfree(cpufreq_dev);
407
408 return cool_dev;
497} 409}
498 410
499/** 411/**
@@ -554,16 +466,16 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
554 cpufreq_dev = cdev->devdata; 466 cpufreq_dev = cdev->devdata;
555 mutex_lock(&cooling_cpufreq_lock); 467 mutex_lock(&cooling_cpufreq_lock);
556 list_del(&cpufreq_dev->node); 468 list_del(&cpufreq_dev->node);
557 cpufreq_dev_count--;
558 469
559 /* Unregister the notifier for the last cpufreq cooling device */ 470 /* Unregister the notifier for the last cpufreq cooling device */
560 if (cpufreq_dev_count == 0) 471 if (list_empty(&cpufreq_dev_list))
561 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, 472 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block,
562 CPUFREQ_POLICY_NOTIFIER); 473 CPUFREQ_POLICY_NOTIFIER);
563 mutex_unlock(&cooling_cpufreq_lock); 474 mutex_unlock(&cooling_cpufreq_lock);
564 475
565 thermal_cooling_device_unregister(cpufreq_dev->cool_dev); 476 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
566 release_idr(&cpufreq_idr, cpufreq_dev->id); 477 release_idr(&cpufreq_idr, cpufreq_dev->id);
478 kfree(cpufreq_dev->freq_table);
567 kfree(cpufreq_dev); 479 kfree(cpufreq_dev);
568} 480}
569EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister); 481EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister);
diff --git a/drivers/thermal/db8500_cpufreq_cooling.c b/drivers/thermal/db8500_cpufreq_cooling.c
index 000d53e934a0..607b62c7e611 100644
--- a/drivers/thermal/db8500_cpufreq_cooling.c
+++ b/drivers/thermal/db8500_cpufreq_cooling.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20#include <linux/cpu_cooling.h> 20#include <linux/cpu_cooling.h>
21#include <linux/cpufreq.h>
22#include <linux/err.h> 21#include <linux/err.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/of.h> 23#include <linux/of.h>
@@ -28,18 +27,17 @@
28static int db8500_cpufreq_cooling_probe(struct platform_device *pdev) 27static int db8500_cpufreq_cooling_probe(struct platform_device *pdev)
29{ 28{
30 struct thermal_cooling_device *cdev; 29 struct thermal_cooling_device *cdev;
31 struct cpumask mask_val;
32
33 /* make sure cpufreq driver has been initialized */
34 if (!cpufreq_frequency_get_table(0))
35 return -EPROBE_DEFER;
36
37 cpumask_set_cpu(0, &mask_val);
38 cdev = cpufreq_cooling_register(&mask_val);
39 30
31 cdev = cpufreq_cooling_register(cpu_present_mask);
40 if (IS_ERR(cdev)) { 32 if (IS_ERR(cdev)) {
41 dev_err(&pdev->dev, "Failed to register cooling device\n"); 33 int ret = PTR_ERR(cdev);
42 return PTR_ERR(cdev); 34
35 if (ret != -EPROBE_DEFER)
36 dev_err(&pdev->dev,
37 "Failed to register cooling device %d\n",
38 ret);
39
40 return ret;
43 } 41 }
44 42
45 platform_set_drvdata(pdev, cdev); 43 platform_set_drvdata(pdev, cdev);
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 88b32f942dcf..c1188ac053c9 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -9,7 +9,6 @@
9 9
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/cpu_cooling.h> 11#include <linux/cpu_cooling.h>
12#include <linux/cpufreq.h>
13#include <linux/delay.h> 12#include <linux/delay.h>
14#include <linux/device.h> 13#include <linux/device.h>
15#include <linux/init.h> 14#include <linux/init.h>
@@ -454,15 +453,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
454 const struct of_device_id *of_id = 453 const struct of_device_id *of_id =
455 of_match_device(of_imx_thermal_match, &pdev->dev); 454 of_match_device(of_imx_thermal_match, &pdev->dev);
456 struct imx_thermal_data *data; 455 struct imx_thermal_data *data;
457 struct cpumask clip_cpus;
458 struct regmap *map; 456 struct regmap *map;
459 int measure_freq; 457 int measure_freq;
460 int ret; 458 int ret;
461 459
462 if (!cpufreq_get_current_driver()) {
463 dev_dbg(&pdev->dev, "no cpufreq driver!");
464 return -EPROBE_DEFER;
465 }
466 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 460 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
467 if (!data) 461 if (!data)
468 return -ENOMEM; 462 return -ENOMEM;
@@ -516,12 +510,13 @@ static int imx_thermal_probe(struct platform_device *pdev)
516 regmap_write(map, MISC0 + REG_SET, MISC0_REFTOP_SELBIASOFF); 510 regmap_write(map, MISC0 + REG_SET, MISC0_REFTOP_SELBIASOFF);
517 regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN); 511 regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
518 512
519 cpumask_set_cpu(0, &clip_cpus); 513 data->cdev = cpufreq_cooling_register(cpu_present_mask);
520 data->cdev = cpufreq_cooling_register(&clip_cpus);
521 if (IS_ERR(data->cdev)) { 514 if (IS_ERR(data->cdev)) {
522 ret = PTR_ERR(data->cdev); 515 ret = PTR_ERR(data->cdev);
523 dev_err(&pdev->dev, 516 if (ret != -EPROBE_DEFER)
524 "failed to register cpufreq cooling device: %d\n", ret); 517 dev_err(&pdev->dev,
518 "failed to register cpufreq cooling device: %d\n",
519 ret);
525 return ret; 520 return ret;
526 } 521 }
527 522
diff --git a/drivers/thermal/int340x_thermal/Makefile b/drivers/thermal/int340x_thermal/Makefile
index ffe40bffaf1a..d4413698a85f 100644
--- a/drivers/thermal/int340x_thermal/Makefile
+++ b/drivers/thermal/int340x_thermal/Makefile
@@ -1,4 +1,5 @@
1obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o 1obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o
2obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o 2obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o
3obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o 3obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o
4obj-$(CONFIG_INT340X_THERMAL) += processor_thermal_device.o
4obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o 5obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
diff --git a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
index e4e61b3fb11e..231cabc16e16 100644
--- a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
+++ b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c
@@ -82,7 +82,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp,
82 struct acpi_buffer trt_format = { sizeof("RRNNNNNN"), "RRNNNNNN" }; 82 struct acpi_buffer trt_format = { sizeof("RRNNNNNN"), "RRNNNNNN" };
83 83
84 if (!acpi_has_method(handle, "_TRT")) 84 if (!acpi_has_method(handle, "_TRT"))
85 return 0; 85 return -ENODEV;
86 86
87 status = acpi_evaluate_object(handle, "_TRT", NULL, &buffer); 87 status = acpi_evaluate_object(handle, "_TRT", NULL, &buffer);
88 if (ACPI_FAILURE(status)) 88 if (ACPI_FAILURE(status))
@@ -167,7 +167,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp,
167 sizeof("RRNNNNNNNNNNN"), "RRNNNNNNNNNNN" }; 167 sizeof("RRNNNNNNNNNNN"), "RRNNNNNNNNNNN" };
168 168
169 if (!acpi_has_method(handle, "_ART")) 169 if (!acpi_has_method(handle, "_ART"))
170 return 0; 170 return -ENODEV;
171 171
172 status = acpi_evaluate_object(handle, "_ART", NULL, &buffer); 172 status = acpi_evaluate_object(handle, "_ART", NULL, &buffer);
173 if (ACPI_FAILURE(status)) 173 if (ACPI_FAILURE(status))
@@ -321,8 +321,8 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd,
321 unsigned long length = 0; 321 unsigned long length = 0;
322 int count = 0; 322 int count = 0;
323 char __user *arg = (void __user *)__arg; 323 char __user *arg = (void __user *)__arg;
324 struct trt *trts; 324 struct trt *trts = NULL;
325 struct art *arts; 325 struct art *arts = NULL;
326 326
327 switch (cmd) { 327 switch (cmd) {
328 case ACPI_THERMAL_GET_TRT_COUNT: 328 case ACPI_THERMAL_GET_TRT_COUNT:
diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
index dcb306ea14a4..65a98a97df07 100644
--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
@@ -335,7 +335,6 @@ static struct platform_driver int3400_thermal_driver = {
335 .remove = int3400_thermal_remove, 335 .remove = int3400_thermal_remove,
336 .driver = { 336 .driver = {
337 .name = "int3400 thermal", 337 .name = "int3400 thermal",
338 .owner = THIS_MODULE,
339 .acpi_match_table = ACPI_PTR(int3400_thermal_match), 338 .acpi_match_table = ACPI_PTR(int3400_thermal_match),
340 }, 339 },
341}; 340};
diff --git a/drivers/thermal/int340x_thermal/int3402_thermal.c b/drivers/thermal/int340x_thermal/int3402_thermal.c
index a5d08c14ba24..c5cbc3af3a05 100644
--- a/drivers/thermal/int340x_thermal/int3402_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3402_thermal.c
@@ -231,7 +231,6 @@ static struct platform_driver int3402_thermal_driver = {
231 .remove = int3402_thermal_remove, 231 .remove = int3402_thermal_remove,
232 .driver = { 232 .driver = {
233 .name = "int3402 thermal", 233 .name = "int3402 thermal",
234 .owner = THIS_MODULE,
235 .acpi_match_table = int3402_thermal_match, 234 .acpi_match_table = int3402_thermal_match,
236 }, 235 },
237}; 236};
diff --git a/drivers/thermal/int340x_thermal/int3403_thermal.c b/drivers/thermal/int340x_thermal/int3403_thermal.c
index 1bfa6a69e77a..0faf500d8a77 100644
--- a/drivers/thermal/int340x_thermal/int3403_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3403_thermal.c
@@ -301,6 +301,8 @@ static int int3403_sensor_remove(struct int3403_priv *priv)
301{ 301{
302 struct int3403_sensor *obj = priv->priv; 302 struct int3403_sensor *obj = priv->priv;
303 303
304 acpi_remove_notify_handler(priv->adev->handle,
305 ACPI_DEVICE_NOTIFY, int3403_notify);
304 thermal_zone_device_unregister(obj->tzone); 306 thermal_zone_device_unregister(obj->tzone);
305 return 0; 307 return 0;
306} 308}
@@ -369,6 +371,7 @@ static int int3403_cdev_add(struct int3403_priv *priv)
369 p = buf.pointer; 371 p = buf.pointer;
370 if (!p || (p->type != ACPI_TYPE_PACKAGE)) { 372 if (!p || (p->type != ACPI_TYPE_PACKAGE)) {
371 printk(KERN_WARNING "Invalid PPSS data\n"); 373 printk(KERN_WARNING "Invalid PPSS data\n");
374 kfree(buf.pointer);
372 return -EFAULT; 375 return -EFAULT;
373 } 376 }
374 377
@@ -381,6 +384,7 @@ static int int3403_cdev_add(struct int3403_priv *priv)
381 384
382 priv->priv = obj; 385 priv->priv = obj;
383 386
387 kfree(buf.pointer);
384 /* TODO: add ACPI notification support */ 388 /* TODO: add ACPI notification support */
385 389
386 return result; 390 return result;
diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
new file mode 100644
index 000000000000..31bb553aac26
--- /dev/null
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -0,0 +1,309 @@
1/*
2 * processor_thermal_device.c
3 * Copyright (c) 2014, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 */
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/pci.h>
19#include <linux/platform_device.h>
20#include <linux/acpi.h>
21
22/* Broadwell-U/HSB thermal reporting device */
23#define PCI_DEVICE_ID_PROC_BDW_THERMAL 0x1603
24#define PCI_DEVICE_ID_PROC_HSB_THERMAL 0x0A03
25
26/* Braswell thermal reporting device */
27#define PCI_DEVICE_ID_PROC_BSW_THERMAL 0x22DC
28
29struct power_config {
30 u32 index;
31 u32 min_uw;
32 u32 max_uw;
33 u32 tmin_us;
34 u32 tmax_us;
35 u32 step_uw;
36};
37
38struct proc_thermal_device {
39 struct device *dev;
40 struct acpi_device *adev;
41 struct power_config power_limits[2];
42};
43
44enum proc_thermal_emum_mode_type {
45 PROC_THERMAL_NONE,
46 PROC_THERMAL_PCI,
47 PROC_THERMAL_PLATFORM_DEV
48};
49
50/*
51 * We can have only one type of enumeration, PCI or Platform,
52 * not both. So we don't need instance specific data.
53 */
54static enum proc_thermal_emum_mode_type proc_thermal_emum_mode =
55 PROC_THERMAL_NONE;
56
57#define POWER_LIMIT_SHOW(index, suffix) \
58static ssize_t power_limit_##index##_##suffix##_show(struct device *dev, \
59 struct device_attribute *attr, \
60 char *buf) \
61{ \
62 struct pci_dev *pci_dev; \
63 struct platform_device *pdev; \
64 struct proc_thermal_device *proc_dev; \
65\
66 if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) { \
67 pdev = to_platform_device(dev); \
68 proc_dev = platform_get_drvdata(pdev); \
69 } else { \
70 pci_dev = to_pci_dev(dev); \
71 proc_dev = pci_get_drvdata(pci_dev); \
72 } \
73 return sprintf(buf, "%lu\n",\
74 (unsigned long)proc_dev->power_limits[index].suffix * 1000); \
75}
76
77POWER_LIMIT_SHOW(0, min_uw)
78POWER_LIMIT_SHOW(0, max_uw)
79POWER_LIMIT_SHOW(0, step_uw)
80POWER_LIMIT_SHOW(0, tmin_us)
81POWER_LIMIT_SHOW(0, tmax_us)
82
83POWER_LIMIT_SHOW(1, min_uw)
84POWER_LIMIT_SHOW(1, max_uw)
85POWER_LIMIT_SHOW(1, step_uw)
86POWER_LIMIT_SHOW(1, tmin_us)
87POWER_LIMIT_SHOW(1, tmax_us)
88
89static DEVICE_ATTR_RO(power_limit_0_min_uw);
90static DEVICE_ATTR_RO(power_limit_0_max_uw);
91static DEVICE_ATTR_RO(power_limit_0_step_uw);
92static DEVICE_ATTR_RO(power_limit_0_tmin_us);
93static DEVICE_ATTR_RO(power_limit_0_tmax_us);
94
95static DEVICE_ATTR_RO(power_limit_1_min_uw);
96static DEVICE_ATTR_RO(power_limit_1_max_uw);
97static DEVICE_ATTR_RO(power_limit_1_step_uw);
98static DEVICE_ATTR_RO(power_limit_1_tmin_us);
99static DEVICE_ATTR_RO(power_limit_1_tmax_us);
100
101static struct attribute *power_limit_attrs[] = {
102 &dev_attr_power_limit_0_min_uw.attr,
103 &dev_attr_power_limit_1_min_uw.attr,
104 &dev_attr_power_limit_0_max_uw.attr,
105 &dev_attr_power_limit_1_max_uw.attr,
106 &dev_attr_power_limit_0_step_uw.attr,
107 &dev_attr_power_limit_1_step_uw.attr,
108 &dev_attr_power_limit_0_tmin_us.attr,
109 &dev_attr_power_limit_1_tmin_us.attr,
110 &dev_attr_power_limit_0_tmax_us.attr,
111 &dev_attr_power_limit_1_tmax_us.attr,
112 NULL
113};
114
115static struct attribute_group power_limit_attribute_group = {
116 .attrs = power_limit_attrs,
117 .name = "power_limits"
118};
119
120static int proc_thermal_add(struct device *dev,
121 struct proc_thermal_device **priv)
122{
123 struct proc_thermal_device *proc_priv;
124 struct acpi_device *adev;
125 acpi_status status;
126 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
127 union acpi_object *elements, *ppcc;
128 union acpi_object *p;
129 int i;
130 int ret;
131
132 adev = ACPI_COMPANION(dev);
133
134 status = acpi_evaluate_object(adev->handle, "PPCC", NULL, &buf);
135 if (ACPI_FAILURE(status))
136 return -ENODEV;
137
138 p = buf.pointer;
139 if (!p || (p->type != ACPI_TYPE_PACKAGE)) {
140 dev_err(dev, "Invalid PPCC data\n");
141 ret = -EFAULT;
142 goto free_buffer;
143 }
144 if (!p->package.count) {
145 dev_err(dev, "Invalid PPCC package size\n");
146 ret = -EFAULT;
147 goto free_buffer;
148 }
149
150 proc_priv = devm_kzalloc(dev, sizeof(*proc_priv), GFP_KERNEL);
151 if (!proc_priv) {
152 ret = -ENOMEM;
153 goto free_buffer;
154 }
155
156 proc_priv->dev = dev;
157 proc_priv->adev = adev;
158
159 for (i = 0; i < min((int)p->package.count - 1, 2); ++i) {
160 elements = &(p->package.elements[i+1]);
161 if (elements->type != ACPI_TYPE_PACKAGE ||
162 elements->package.count != 6) {
163 ret = -EFAULT;
164 goto free_buffer;
165 }
166 ppcc = elements->package.elements;
167 proc_priv->power_limits[i].index = ppcc[0].integer.value;
168 proc_priv->power_limits[i].min_uw = ppcc[1].integer.value;
169 proc_priv->power_limits[i].max_uw = ppcc[2].integer.value;
170 proc_priv->power_limits[i].tmin_us = ppcc[3].integer.value;
171 proc_priv->power_limits[i].tmax_us = ppcc[4].integer.value;
172 proc_priv->power_limits[i].step_uw = ppcc[5].integer.value;
173 }
174
175 *priv = proc_priv;
176
177 ret = sysfs_create_group(&dev->kobj,
178 &power_limit_attribute_group);
179
180free_buffer:
181 kfree(buf.pointer);
182
183 return ret;
184}
185
186void proc_thermal_remove(struct proc_thermal_device *proc_priv)
187{
188 sysfs_remove_group(&proc_priv->dev->kobj,
189 &power_limit_attribute_group);
190}
191
192static int int3401_add(struct platform_device *pdev)
193{
194 struct proc_thermal_device *proc_priv;
195 int ret;
196
197 if (proc_thermal_emum_mode == PROC_THERMAL_PCI) {
198 dev_err(&pdev->dev, "error: enumerated as PCI dev\n");
199 return -ENODEV;
200 }
201
202 ret = proc_thermal_add(&pdev->dev, &proc_priv);
203 if (ret)
204 return ret;
205
206 platform_set_drvdata(pdev, proc_priv);
207 proc_thermal_emum_mode = PROC_THERMAL_PLATFORM_DEV;
208
209 return 0;
210}
211
212static int int3401_remove(struct platform_device *pdev)
213{
214 proc_thermal_remove(platform_get_drvdata(pdev));
215
216 return 0;
217}
218
219static int proc_thermal_pci_probe(struct pci_dev *pdev,
220 const struct pci_device_id *unused)
221{
222 struct proc_thermal_device *proc_priv;
223 int ret;
224
225 if (proc_thermal_emum_mode == PROC_THERMAL_PLATFORM_DEV) {
226 dev_err(&pdev->dev, "error: enumerated as platform dev\n");
227 return -ENODEV;
228 }
229
230 ret = pci_enable_device(pdev);
231 if (ret < 0) {
232 dev_err(&pdev->dev, "error: could not enable device\n");
233 return ret;
234 }
235
236 ret = proc_thermal_add(&pdev->dev, &proc_priv);
237 if (ret) {
238 pci_disable_device(pdev);
239 return ret;
240 }
241
242 pci_set_drvdata(pdev, proc_priv);
243 proc_thermal_emum_mode = PROC_THERMAL_PCI;
244
245 return 0;
246}
247
248static void proc_thermal_pci_remove(struct pci_dev *pdev)
249{
250 proc_thermal_remove(pci_get_drvdata(pdev));
251 pci_disable_device(pdev);
252}
253
254static const struct pci_device_id proc_thermal_pci_ids[] = {
255 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BDW_THERMAL)},
256 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_HSB_THERMAL)},
257 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BSW_THERMAL)},
258 { 0, },
259};
260
261MODULE_DEVICE_TABLE(pci, proc_thermal_pci_ids);
262
263static struct pci_driver proc_thermal_pci_driver = {
264 .name = "proc_thermal",
265 .probe = proc_thermal_pci_probe,
266 .remove = proc_thermal_pci_remove,
267 .id_table = proc_thermal_pci_ids,
268};
269
270static const struct acpi_device_id int3401_device_ids[] = {
271 {"INT3401", 0},
272 {"", 0},
273};
274MODULE_DEVICE_TABLE(acpi, int3401_device_ids);
275
276static struct platform_driver int3401_driver = {
277 .probe = int3401_add,
278 .remove = int3401_remove,
279 .driver = {
280 .name = "int3401 thermal",
281 .acpi_match_table = int3401_device_ids,
282 },
283};
284
285static int __init proc_thermal_init(void)
286{
287 int ret;
288
289 ret = platform_driver_register(&int3401_driver);
290 if (ret)
291 return ret;
292
293 ret = pci_register_driver(&proc_thermal_pci_driver);
294
295 return ret;
296}
297
298static void __exit proc_thermal_exit(void)
299{
300 platform_driver_unregister(&int3401_driver);
301 pci_unregister_driver(&proc_thermal_pci_driver);
302}
303
304module_init(proc_thermal_init);
305module_exit(proc_thermal_exit);
306
307MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
308MODULE_DESCRIPTION("Processor Thermal Reporting Device Driver");
309MODULE_LICENSE("GPL v2");
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index e98b4249187c..6ceebd659dd4 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -688,6 +688,7 @@ static const struct x86_cpu_id intel_powerclamp_ids[] = {
688 { X86_VENDOR_INTEL, 6, 0x45}, 688 { X86_VENDOR_INTEL, 6, 0x45},
689 { X86_VENDOR_INTEL, 6, 0x46}, 689 { X86_VENDOR_INTEL, 6, 0x46},
690 { X86_VENDOR_INTEL, 6, 0x4c}, 690 { X86_VENDOR_INTEL, 6, 0x4c},
691 { X86_VENDOR_INTEL, 6, 0x56},
691 {} 692 {}
692}; 693};
693MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids); 694MODULE_DEVICE_TABLE(x86cpu, intel_powerclamp_ids);
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 1bcddfc60e91..9c6ce548e363 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -677,7 +677,6 @@ static SIMPLE_DEV_PM_OPS(rockchip_thermal_pm_ops,
677static struct platform_driver rockchip_thermal_driver = { 677static struct platform_driver rockchip_thermal_driver = {
678 .driver = { 678 .driver = {
679 .name = "rockchip-thermal", 679 .name = "rockchip-thermal",
680 .owner = THIS_MODULE,
681 .pm = &rockchip_thermal_pm_ops, 680 .pm = &rockchip_thermal_pm_ops,
682 .of_match_table = of_rockchip_thermal_match, 681 .of_match_table = of_rockchip_thermal_match,
683 }, 682 },
diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig
index f760389a204c..c43306ecc0ab 100644
--- a/drivers/thermal/samsung/Kconfig
+++ b/drivers/thermal/samsung/Kconfig
@@ -1,6 +1,6 @@
1config EXYNOS_THERMAL 1config EXYNOS_THERMAL
2 tristate "Exynos thermal management unit driver" 2 tristate "Exynos thermal management unit driver"
3 depends on ARCH_HAS_BANDGAP && OF 3 depends on OF
4 help 4 help
5 If you say yes here you get support for the TMU (Thermal Management 5 If you say yes here you get support for the TMU (Thermal Management
6 Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises 6 Unit) driver for SAMSUNG EXYNOS series of SoCs. This driver initialises
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index b6be572704a4..6dc3815cc73f 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -347,7 +347,6 @@ void exynos_report_trigger(struct thermal_sensor_conf *conf)
347int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) 347int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
348{ 348{
349 int ret; 349 int ret;
350 struct cpumask mask_val;
351 struct exynos_thermal_zone *th_zone; 350 struct exynos_thermal_zone *th_zone;
352 351
353 if (!sensor_conf || !sensor_conf->read_temperature) { 352 if (!sensor_conf || !sensor_conf->read_temperature) {
@@ -367,13 +366,14 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
367 * sensor 366 * sensor
368 */ 367 */
369 if (sensor_conf->cooling_data.freq_clip_count > 0) { 368 if (sensor_conf->cooling_data.freq_clip_count > 0) {
370 cpumask_set_cpu(0, &mask_val);
371 th_zone->cool_dev[th_zone->cool_dev_size] = 369 th_zone->cool_dev[th_zone->cool_dev_size] =
372 cpufreq_cooling_register(&mask_val); 370 cpufreq_cooling_register(cpu_present_mask);
373 if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) { 371 if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
374 dev_err(sensor_conf->dev, 372 ret = PTR_ERR(th_zone->cool_dev[th_zone->cool_dev_size]);
375 "Failed to register cpufreq cooling device\n"); 373 if (ret != -EPROBE_DEFER)
376 ret = -EINVAL; 374 dev_err(sensor_conf->dev,
375 "Failed to register cpufreq cooling device: %d\n",
376 ret);
377 goto err_unregister; 377 goto err_unregister;
378 } 378 }
379 th_zone->cool_dev_size++; 379 th_zone->cool_dev_size++;
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index d44d91d681d4..d2f1e62a4232 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -927,7 +927,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
927 /* Register the sensor with thermal management interface */ 927 /* Register the sensor with thermal management interface */
928 ret = exynos_register_thermal(sensor_conf); 928 ret = exynos_register_thermal(sensor_conf);
929 if (ret) { 929 if (ret) {
930 dev_err(&pdev->dev, "Failed to register thermal interface\n"); 930 if (ret != -EPROBE_DEFER)
931 dev_err(&pdev->dev,
932 "Failed to register thermal interface: %d\n",
933 ret);
931 goto err_clk; 934 goto err_clk;
932 } 935 }
933 data->reg_conf = sensor_conf; 936 data->reg_conf = sensor_conf;
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 84fdf0792e27..87e0b0782023 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -930,7 +930,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
930 struct thermal_zone_device *pos1; 930 struct thermal_zone_device *pos1;
931 struct thermal_cooling_device *pos2; 931 struct thermal_cooling_device *pos2;
932 unsigned long max_state; 932 unsigned long max_state;
933 int result; 933 int result, ret;
934 934
935 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) 935 if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE))
936 return -EINVAL; 936 return -EINVAL;
@@ -947,7 +947,9 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
947 if (tz != pos1 || cdev != pos2) 947 if (tz != pos1 || cdev != pos2)
948 return -EINVAL; 948 return -EINVAL;
949 949
950 cdev->ops->get_max_state(cdev, &max_state); 950 ret = cdev->ops->get_max_state(cdev, &max_state);
951 if (ret)
952 return ret;
951 953
952 /* lower default 0, upper default max_state */ 954 /* lower default 0, upper default max_state */
953 lower = lower == THERMAL_NO_LIMIT ? 0 : lower; 955 lower = lower == THERMAL_NO_LIMIT ? 0 : lower;
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 5fd03865e396..3fb054a10f6a 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -28,7 +28,6 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/workqueue.h> 29#include <linux/workqueue.h>
30#include <linux/thermal.h> 30#include <linux/thermal.h>
31#include <linux/cpufreq.h>
32#include <linux/cpumask.h> 31#include <linux/cpumask.h>
33#include <linux/cpu_cooling.h> 32#include <linux/cpu_cooling.h>
34#include <linux/of.h> 33#include <linux/of.h>
@@ -407,17 +406,17 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id)
407 if (!data) 406 if (!data)
408 return -EINVAL; 407 return -EINVAL;
409 408
410 if (!cpufreq_get_current_driver()) {
411 dev_dbg(bgp->dev, "no cpufreq driver yet\n");
412 return -EPROBE_DEFER;
413 }
414
415 /* Register cooling device */ 409 /* Register cooling device */
416 data->cool_dev = cpufreq_cooling_register(cpu_present_mask); 410 data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
417 if (IS_ERR(data->cool_dev)) { 411 if (IS_ERR(data->cool_dev)) {
418 dev_err(bgp->dev, 412 int ret = PTR_ERR(data->cool_dev);
419 "Failed to register cpufreq cooling device\n"); 413
420 return PTR_ERR(data->cool_dev); 414 if (ret != -EPROBE_DEFER)
415 dev_err(bgp->dev,
416 "Failed to register cpu cooling device %d\n",
417 ret);
418
419 return ret;
421 } 420 }
422 ti_bandgap_set_sensor_data(bgp, id, data); 421 ti_bandgap_set_sensor_data(bgp, id, data);
423 422
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 255201f22126..7cc0122a18ce 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -840,13 +840,11 @@ static const struct vfio_device_ops vfio_pci_ops = {
840 840
841static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 841static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
842{ 842{
843 u8 type;
844 struct vfio_pci_device *vdev; 843 struct vfio_pci_device *vdev;
845 struct iommu_group *group; 844 struct iommu_group *group;
846 int ret; 845 int ret;
847 846
848 pci_read_config_byte(pdev, PCI_HEADER_TYPE, &type); 847 if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL)
849 if ((type & PCI_HEADER_TYPE) != PCI_HEADER_TYPE_NORMAL)
850 return -EINVAL; 848 return -EINVAL;
851 849
852 group = iommu_group_get(&pdev->dev); 850 group = iommu_group_get(&pdev->dev);
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 14419a8ccbb6..d415d69dc237 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -538,7 +538,7 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
538 ++headcount; 538 ++headcount;
539 seg += in; 539 seg += in;
540 } 540 }
541 heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen); 541 heads[headcount - 1].len = cpu_to_vhost32(vq, len + datalen);
542 *iovcount = seg; 542 *iovcount = seg;
543 if (unlikely(log)) 543 if (unlikely(log))
544 *log_num = nlogs; 544 *log_num = nlogs;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ed71b5347a76..cb807d0ea498 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -713,9 +713,13 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
713 r = -EFAULT; 713 r = -EFAULT;
714 break; 714 break;
715 } 715 }
716 if ((a.avail_user_addr & (sizeof *vq->avail->ring - 1)) || 716
717 (a.used_user_addr & (sizeof *vq->used->ring - 1)) || 717 /* Make sure it's safe to cast pointers to vring types. */
718 (a.log_guest_addr & (sizeof *vq->used->ring - 1))) { 718 BUILD_BUG_ON(__alignof__ *vq->avail > VRING_AVAIL_ALIGN_SIZE);
719 BUILD_BUG_ON(__alignof__ *vq->used > VRING_USED_ALIGN_SIZE);
720 if ((a.avail_user_addr & (VRING_AVAIL_ALIGN_SIZE - 1)) ||
721 (a.used_user_addr & (VRING_USED_ALIGN_SIZE - 1)) ||
722 (a.log_guest_addr & (sizeof(u64) - 1))) {
719 r = -EINVAL; 723 r = -EINVAL;
720 break; 724 break;
721 } 725 }
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index 900aa4ecd617..d6cab1fd9a47 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c
@@ -83,9 +83,10 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy
83 cancel_delayed_work_sync(&info->deferred_work); 83 cancel_delayed_work_sync(&info->deferred_work);
84 84
85 /* Run it immediately */ 85 /* Run it immediately */
86 err = schedule_delayed_work(&info->deferred_work, 0); 86 schedule_delayed_work(&info->deferred_work, 0);
87 mutex_unlock(&inode->i_mutex); 87 mutex_unlock(&inode->i_mutex);
88 return err; 88
89 return 0;
89} 90}
90EXPORT_SYMBOL_GPL(fb_deferred_io_fsync); 91EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);
91 92
diff --git a/drivers/video/fbdev/omap2/dss/hdmi_pll.c b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
index 87accdb59c81..ac83ef5cfd7d 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi_pll.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
@@ -132,7 +132,6 @@ static const struct dss_pll_hw dss_omap4_hdmi_pll_hw = {
132 .mX_max = 127, 132 .mX_max = 127,
133 .fint_min = 500000, 133 .fint_min = 500000,
134 .fint_max = 2500000, 134 .fint_max = 2500000,
135 .clkdco_max = 1800000000,
136 135
137 .clkdco_min = 500000000, 136 .clkdco_min = 500000000,
138 .clkdco_low = 1000000000, 137 .clkdco_low = 1000000000,
@@ -156,7 +155,6 @@ static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = {
156 .mX_max = 127, 155 .mX_max = 127,
157 .fint_min = 620000, 156 .fint_min = 620000,
158 .fint_max = 2500000, 157 .fint_max = 2500000,
159 .clkdco_max = 1800000000,
160 158
161 .clkdco_min = 750000000, 159 .clkdco_min = 750000000,
162 .clkdco_low = 1500000000, 160 .clkdco_low = 1500000000,
diff --git a/drivers/video/fbdev/omap2/dss/pll.c b/drivers/video/fbdev/omap2/dss/pll.c
index 50bc62c5d367..335ffac224b9 100644
--- a/drivers/video/fbdev/omap2/dss/pll.c
+++ b/drivers/video/fbdev/omap2/dss/pll.c
@@ -97,7 +97,8 @@ int dss_pll_enable(struct dss_pll *pll)
97 return 0; 97 return 0;
98 98
99err_enable: 99err_enable:
100 regulator_disable(pll->regulator); 100 if (pll->regulator)
101 regulator_disable(pll->regulator);
101err_reg: 102err_reg:
102 clk_disable_unprepare(pll->clkin); 103 clk_disable_unprepare(pll->clkin);
103 return r; 104 return r;
diff --git a/drivers/video/fbdev/omap2/dss/sdi.c b/drivers/video/fbdev/omap2/dss/sdi.c
index d51a983075bc..5c2ccab5a958 100644
--- a/drivers/video/fbdev/omap2/dss/sdi.c
+++ b/drivers/video/fbdev/omap2/dss/sdi.c
@@ -342,6 +342,8 @@ static void sdi_init_output(struct platform_device *pdev)
342 out->output_type = OMAP_DISPLAY_TYPE_SDI; 342 out->output_type = OMAP_DISPLAY_TYPE_SDI;
343 out->name = "sdi.0"; 343 out->name = "sdi.0";
344 out->dispc_channel = OMAP_DSS_CHANNEL_LCD; 344 out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
345 /* We have SDI only on OMAP3, where it's on port 1 */
346 out->port_num = 1;
345 out->ops.sdi = &sdi_ops; 347 out->ops.sdi = &sdi_ops;
346 out->owner = THIS_MODULE; 348 out->owner = THIS_MODULE;
347 349
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index 940cd196eef5..10fbfd8ab963 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -21,6 +21,21 @@ static bool nologo;
21module_param(nologo, bool, 0); 21module_param(nologo, bool, 0);
22MODULE_PARM_DESC(nologo, "Disables startup logo"); 22MODULE_PARM_DESC(nologo, "Disables startup logo");
23 23
24/*
25 * Logos are located in the initdata, and will be freed in kernel_init.
26 * Use late_init to mark the logos as freed to prevent any further use.
27 */
28
29static bool logos_freed;
30
31static int __init fb_logo_late_init(void)
32{
33 logos_freed = true;
34 return 0;
35}
36
37late_initcall(fb_logo_late_init);
38
24/* logo's are marked __initdata. Use __init_refok to tell 39/* logo's are marked __initdata. Use __init_refok to tell
25 * modpost that it is intended that this function uses data 40 * modpost that it is intended that this function uses data
26 * marked __initdata. 41 * marked __initdata.
@@ -29,7 +44,7 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
29{ 44{
30 const struct linux_logo *logo = NULL; 45 const struct linux_logo *logo = NULL;
31 46
32 if (nologo) 47 if (nologo || logos_freed)
33 return NULL; 48 return NULL;
34 49
35 if (depth >= 1) { 50 if (depth >= 1) {
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 2ef9529809d8..9756f21b809e 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -282,6 +282,7 @@ void vp_del_vqs(struct virtio_device *vdev)
282 282
283 vp_free_vectors(vdev); 283 vp_free_vectors(vdev);
284 kfree(vp_dev->vqs); 284 kfree(vp_dev->vqs);
285 vp_dev->vqs = NULL;
285} 286}
286 287
287static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs, 288static int vp_try_to_find_vqs(struct virtio_device *vdev, unsigned nvqs,
@@ -421,15 +422,6 @@ int vp_set_vq_affinity(struct virtqueue *vq, int cpu)
421 return 0; 422 return 0;
422} 423}
423 424
424void virtio_pci_release_dev(struct device *_d)
425{
426 /*
427 * No need for a release method as we allocate/free
428 * all devices together with the pci devices.
429 * Provide an empty one to avoid getting a warning from core.
430 */
431}
432
433#ifdef CONFIG_PM_SLEEP 425#ifdef CONFIG_PM_SLEEP
434static int virtio_pci_freeze(struct device *dev) 426static int virtio_pci_freeze(struct device *dev)
435{ 427{
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h
index adddb647b21d..5a497289b7e9 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -126,7 +126,6 @@ const char *vp_bus_name(struct virtio_device *vdev);
126 * - ignore the affinity request if we're using INTX 126 * - ignore the affinity request if we're using INTX
127 */ 127 */
128int vp_set_vq_affinity(struct virtqueue *vq, int cpu); 128int vp_set_vq_affinity(struct virtqueue *vq, int cpu);
129void virtio_pci_release_dev(struct device *);
130 129
131int virtio_pci_legacy_probe(struct pci_dev *pci_dev, 130int virtio_pci_legacy_probe(struct pci_dev *pci_dev,
132 const struct pci_device_id *id); 131 const struct pci_device_id *id);
diff --git a/drivers/virtio/virtio_pci_legacy.c b/drivers/virtio/virtio_pci_legacy.c
index 6c76f0f5658c..a5486e65e04b 100644
--- a/drivers/virtio/virtio_pci_legacy.c
+++ b/drivers/virtio/virtio_pci_legacy.c
@@ -211,6 +211,17 @@ static const struct virtio_config_ops virtio_pci_config_ops = {
211 .set_vq_affinity = vp_set_vq_affinity, 211 .set_vq_affinity = vp_set_vq_affinity,
212}; 212};
213 213
214static void virtio_pci_release_dev(struct device *_d)
215{
216 struct virtio_device *vdev = dev_to_virtio(_d);
217 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
218
219 /* As struct device is a kobject, it's not safe to
220 * free the memory (including the reference counter itself)
221 * until it's release callback. */
222 kfree(vp_dev);
223}
224
214/* the PCI probing function */ 225/* the PCI probing function */
215int virtio_pci_legacy_probe(struct pci_dev *pci_dev, 226int virtio_pci_legacy_probe(struct pci_dev *pci_dev,
216 const struct pci_device_id *id) 227 const struct pci_device_id *id)
@@ -302,5 +313,4 @@ void virtio_pci_legacy_remove(struct pci_dev *pci_dev)
302 pci_iounmap(pci_dev, vp_dev->ioaddr); 313 pci_iounmap(pci_dev, vp_dev->ioaddr);
303 pci_release_regions(pci_dev); 314 pci_release_regions(pci_dev);
304 pci_disable_device(pci_dev); 315 pci_disable_device(pci_dev);
305 kfree(vp_dev);
306} 316}
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 2d3e32ebfd15..8729cf68d2fe 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -1552,7 +1552,6 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb,
1552{ 1552{
1553 int ret; 1553 int ret;
1554 int type; 1554 int type;
1555 struct btrfs_tree_block_info *info;
1556 struct btrfs_extent_inline_ref *eiref; 1555 struct btrfs_extent_inline_ref *eiref;
1557 1556
1558 if (*ptr == (unsigned long)-1) 1557 if (*ptr == (unsigned long)-1)
@@ -1573,9 +1572,17 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb,
1573 } 1572 }
1574 1573
1575 /* we can treat both ref types equally here */ 1574 /* we can treat both ref types equally here */
1576 info = (struct btrfs_tree_block_info *)(ei + 1);
1577 *out_root = btrfs_extent_inline_ref_offset(eb, eiref); 1575 *out_root = btrfs_extent_inline_ref_offset(eb, eiref);
1578 *out_level = btrfs_tree_block_level(eb, info); 1576
1577 if (key->type == BTRFS_EXTENT_ITEM_KEY) {
1578 struct btrfs_tree_block_info *info;
1579
1580 info = (struct btrfs_tree_block_info *)(ei + 1);
1581 *out_level = btrfs_tree_block_level(eb, info);
1582 } else {
1583 ASSERT(key->type == BTRFS_METADATA_ITEM_KEY);
1584 *out_level = (u8)key->offset;
1585 }
1579 1586
1580 if (ret == 1) 1587 if (ret == 1)
1581 *ptr = (unsigned long)-1; 1588 *ptr = (unsigned long)-1;
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 054577bddaf2..de4e70fb3cbb 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1857,6 +1857,14 @@ int btrfs_delayed_delete_inode_ref(struct inode *inode)
1857{ 1857{
1858 struct btrfs_delayed_node *delayed_node; 1858 struct btrfs_delayed_node *delayed_node;
1859 1859
1860 /*
1861 * we don't do delayed inode updates during log recovery because it
1862 * leads to enospc problems. This means we also can't do
1863 * delayed inode refs
1864 */
1865 if (BTRFS_I(inode)->root->fs_info->log_root_recovering)
1866 return -EAGAIN;
1867
1860 delayed_node = btrfs_get_or_create_delayed_node(inode); 1868 delayed_node = btrfs_get_or_create_delayed_node(inode);
1861 if (IS_ERR(delayed_node)) 1869 if (IS_ERR(delayed_node))
1862 return PTR_ERR(delayed_node); 1870 return PTR_ERR(delayed_node);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a80b97100d90..15116585e714 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3139,9 +3139,11 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
3139 struct extent_buffer *leaf; 3139 struct extent_buffer *leaf;
3140 3140
3141 ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1); 3141 ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1);
3142 if (ret < 0) 3142 if (ret) {
3143 if (ret > 0)
3144 ret = -ENOENT;
3143 goto fail; 3145 goto fail;
3144 BUG_ON(ret); /* Corruption */ 3146 }
3145 3147
3146 leaf = path->nodes[0]; 3148 leaf = path->nodes[0];
3147 bi = btrfs_item_ptr_offset(leaf, path->slots[0]); 3149 bi = btrfs_item_ptr_offset(leaf, path->slots[0]);
@@ -3149,11 +3151,9 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
3149 btrfs_mark_buffer_dirty(leaf); 3151 btrfs_mark_buffer_dirty(leaf);
3150 btrfs_release_path(path); 3152 btrfs_release_path(path);
3151fail: 3153fail:
3152 if (ret) { 3154 if (ret)
3153 btrfs_abort_transaction(trans, root, ret); 3155 btrfs_abort_transaction(trans, root, ret);
3154 return ret; 3156 return ret;
3155 }
3156 return 0;
3157 3157
3158} 3158}
3159 3159
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e687bb0dc73a..8bf326affb94 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6255,8 +6255,10 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
6255 6255
6256out_fail: 6256out_fail:
6257 btrfs_end_transaction(trans, root); 6257 btrfs_end_transaction(trans, root);
6258 if (drop_on_err) 6258 if (drop_on_err) {
6259 inode_dec_link_count(inode);
6259 iput(inode); 6260 iput(inode);
6261 }
6260 btrfs_balance_delayed_items(root); 6262 btrfs_balance_delayed_items(root);
6261 btrfs_btree_balance_dirty(root); 6263 btrfs_btree_balance_dirty(root);
6262 return err; 6264 return err;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index f2bb13a23f86..9e1569ffbf6e 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2607,9 +2607,9 @@ static int scrub_extent_for_parity(struct scrub_parity *sparity,
2607 ret = scrub_pages_for_parity(sparity, logical, l, physical, dev, 2607 ret = scrub_pages_for_parity(sparity, logical, l, physical, dev,
2608 flags, gen, mirror_num, 2608 flags, gen, mirror_num,
2609 have_csum ? csum : NULL); 2609 have_csum ? csum : NULL);
2610skip:
2611 if (ret) 2610 if (ret)
2612 return ret; 2611 return ret;
2612skip:
2613 len -= l; 2613 len -= l;
2614 logical += l; 2614 logical += l;
2615 physical += l; 2615 physical += l;
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index f5013d92a7e6..c81c0e004588 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1416,7 +1416,7 @@ void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 dout("fill_inline_data %p %llx.%llx len %lu locked_page %p\n", 1419 dout("fill_inline_data %p %llx.%llx len %zu locked_page %p\n",
1420 inode, ceph_vinop(inode), len, locked_page); 1420 inode, ceph_vinop(inode), len, locked_page);
1421 1421
1422 if (len > 0) { 1422 if (len > 0) {
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 6e139111fdb2..22b289a3b1c4 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -661,16 +661,16 @@ set_credits(struct TCP_Server_Info *server, const int val)
661 server->ops->set_credits(server, val); 661 server->ops->set_credits(server, val);
662} 662}
663 663
664static inline __u64 664static inline __le64
665get_next_mid64(struct TCP_Server_Info *server) 665get_next_mid64(struct TCP_Server_Info *server)
666{ 666{
667 return server->ops->get_next_mid(server); 667 return cpu_to_le64(server->ops->get_next_mid(server));
668} 668}
669 669
670static inline __le16 670static inline __le16
671get_next_mid(struct TCP_Server_Info *server) 671get_next_mid(struct TCP_Server_Info *server)
672{ 672{
673 __u16 mid = get_next_mid64(server); 673 __u16 mid = server->ops->get_next_mid(server);
674 /* 674 /*
675 * The value in the SMB header should be little endian for easy 675 * The value in the SMB header should be little endian for easy
676 * on-the-wire decoding. 676 * on-the-wire decoding.
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index b333ff60781d..abae6dd2c6b9 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -926,6 +926,7 @@ cifs_NTtimeToUnix(__le64 ntutc)
926 926
927 /* Subtract the NTFS time offset, then convert to 1s intervals. */ 927 /* Subtract the NTFS time offset, then convert to 1s intervals. */
928 s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET; 928 s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
929 u64 abs_t;
929 930
930 /* 931 /*
931 * Unfortunately can not use normal 64 bit division on 32 bit arch, but 932 * Unfortunately can not use normal 64 bit division on 32 bit arch, but
@@ -933,13 +934,14 @@ cifs_NTtimeToUnix(__le64 ntutc)
933 * to special case them 934 * to special case them
934 */ 935 */
935 if (t < 0) { 936 if (t < 0) {
936 t = -t; 937 abs_t = -t;
937 ts.tv_nsec = (long)(do_div(t, 10000000) * 100); 938 ts.tv_nsec = (long)(do_div(abs_t, 10000000) * 100);
938 ts.tv_nsec = -ts.tv_nsec; 939 ts.tv_nsec = -ts.tv_nsec;
939 ts.tv_sec = -t; 940 ts.tv_sec = -abs_t;
940 } else { 941 } else {
941 ts.tv_nsec = (long)do_div(t, 10000000) * 100; 942 abs_t = t;
942 ts.tv_sec = t; 943 ts.tv_nsec = (long)do_div(abs_t, 10000000) * 100;
944 ts.tv_sec = abs_t;
943 } 945 }
944 946
945 return ts; 947 return ts;
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 8eaf20a80649..c295338e0a98 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -69,7 +69,8 @@ static inline void dump_cifs_file_struct(struct file *file, char *label)
69 * Attempt to preload the dcache with the results from the FIND_FIRST/NEXT 69 * Attempt to preload the dcache with the results from the FIND_FIRST/NEXT
70 * 70 *
71 * Find the dentry that matches "name". If there isn't one, create one. If it's 71 * Find the dentry that matches "name". If there isn't one, create one. If it's
72 * a negative dentry or the uniqueid changed, then drop it and recreate it. 72 * a negative dentry or the uniqueid or filetype(mode) changed,
73 * then drop it and recreate it.
73 */ 74 */
74static void 75static void
75cifs_prime_dcache(struct dentry *parent, struct qstr *name, 76cifs_prime_dcache(struct dentry *parent, struct qstr *name,
@@ -97,8 +98,11 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
97 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) 98 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM))
98 fattr->cf_uniqueid = CIFS_I(inode)->uniqueid; 99 fattr->cf_uniqueid = CIFS_I(inode)->uniqueid;
99 100
100 /* update inode in place if i_ino didn't change */ 101 /* update inode in place
101 if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { 102 * if both i_ino and i_mode didn't change */
103 if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid &&
104 (inode->i_mode & S_IFMT) ==
105 (fattr->cf_mode & S_IFMT)) {
102 cifs_fattr_to_inode(inode, fattr); 106 cifs_fattr_to_inode(inode, fattr);
103 goto out; 107 goto out;
104 } 108 }
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index f1cefc9763ed..689f035915cf 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -32,12 +32,14 @@
32static int 32static int
33check_smb2_hdr(struct smb2_hdr *hdr, __u64 mid) 33check_smb2_hdr(struct smb2_hdr *hdr, __u64 mid)
34{ 34{
35 __u64 wire_mid = le64_to_cpu(hdr->MessageId);
36
35 /* 37 /*
36 * Make sure that this really is an SMB, that it is a response, 38 * Make sure that this really is an SMB, that it is a response,
37 * and that the message ids match. 39 * and that the message ids match.
38 */ 40 */
39 if ((*(__le32 *)hdr->ProtocolId == SMB2_PROTO_NUMBER) && 41 if ((*(__le32 *)hdr->ProtocolId == SMB2_PROTO_NUMBER) &&
40 (mid == hdr->MessageId)) { 42 (mid == wire_mid)) {
41 if (hdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR) 43 if (hdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR)
42 return 0; 44 return 0;
43 else { 45 else {
@@ -51,11 +53,11 @@ check_smb2_hdr(struct smb2_hdr *hdr, __u64 mid)
51 if (*(__le32 *)hdr->ProtocolId != SMB2_PROTO_NUMBER) 53 if (*(__le32 *)hdr->ProtocolId != SMB2_PROTO_NUMBER)
52 cifs_dbg(VFS, "Bad protocol string signature header %x\n", 54 cifs_dbg(VFS, "Bad protocol string signature header %x\n",
53 *(unsigned int *) hdr->ProtocolId); 55 *(unsigned int *) hdr->ProtocolId);
54 if (mid != hdr->MessageId) 56 if (mid != wire_mid)
55 cifs_dbg(VFS, "Mids do not match: %llu and %llu\n", 57 cifs_dbg(VFS, "Mids do not match: %llu and %llu\n",
56 mid, hdr->MessageId); 58 mid, wire_mid);
57 } 59 }
58 cifs_dbg(VFS, "Bad SMB detected. The Mid=%llu\n", hdr->MessageId); 60 cifs_dbg(VFS, "Bad SMB detected. The Mid=%llu\n", wire_mid);
59 return 1; 61 return 1;
60} 62}
61 63
@@ -95,7 +97,7 @@ smb2_check_message(char *buf, unsigned int length)
95{ 97{
96 struct smb2_hdr *hdr = (struct smb2_hdr *)buf; 98 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
97 struct smb2_pdu *pdu = (struct smb2_pdu *)hdr; 99 struct smb2_pdu *pdu = (struct smb2_pdu *)hdr;
98 __u64 mid = hdr->MessageId; 100 __u64 mid = le64_to_cpu(hdr->MessageId);
99 __u32 len = get_rfc1002_length(buf); 101 __u32 len = get_rfc1002_length(buf);
100 __u32 clc_len; /* calculated length */ 102 __u32 clc_len; /* calculated length */
101 int command; 103 int command;
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 93fd0586f9ec..96b5d40a2ece 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -176,10 +176,11 @@ smb2_find_mid(struct TCP_Server_Info *server, char *buf)
176{ 176{
177 struct mid_q_entry *mid; 177 struct mid_q_entry *mid;
178 struct smb2_hdr *hdr = (struct smb2_hdr *)buf; 178 struct smb2_hdr *hdr = (struct smb2_hdr *)buf;
179 __u64 wire_mid = le64_to_cpu(hdr->MessageId);
179 180
180 spin_lock(&GlobalMid_Lock); 181 spin_lock(&GlobalMid_Lock);
181 list_for_each_entry(mid, &server->pending_mid_q, qhead) { 182 list_for_each_entry(mid, &server->pending_mid_q, qhead) {
182 if ((mid->mid == hdr->MessageId) && 183 if ((mid->mid == wire_mid) &&
183 (mid->mid_state == MID_REQUEST_SUBMITTED) && 184 (mid->mid_state == MID_REQUEST_SUBMITTED) &&
184 (mid->command == hdr->Command)) { 185 (mid->command == hdr->Command)) {
185 spin_unlock(&GlobalMid_Lock); 186 spin_unlock(&GlobalMid_Lock);
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index ce858477002a..70867d54fb8b 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -110,7 +110,7 @@ struct smb2_hdr {
110 __le16 CreditRequest; /* CreditResponse */ 110 __le16 CreditRequest; /* CreditResponse */
111 __le32 Flags; 111 __le32 Flags;
112 __le32 NextCommand; 112 __le32 NextCommand;
113 __u64 MessageId; /* opaque - so can stay little endian */ 113 __le64 MessageId;
114 __le32 ProcessId; 114 __le32 ProcessId;
115 __u32 TreeId; /* opaque - so do not make little endian */ 115 __u32 TreeId; /* opaque - so do not make little endian */
116 __u64 SessionId; /* opaque - so do not make little endian */ 116 __u64 SessionId; /* opaque - so do not make little endian */
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 5111e7272db6..d4c5b6f109a7 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -490,7 +490,7 @@ smb2_mid_entry_alloc(const struct smb2_hdr *smb_buffer,
490 return temp; 490 return temp;
491 else { 491 else {
492 memset(temp, 0, sizeof(struct mid_q_entry)); 492 memset(temp, 0, sizeof(struct mid_q_entry));
493 temp->mid = smb_buffer->MessageId; /* always LE */ 493 temp->mid = le64_to_cpu(smb_buffer->MessageId);
494 temp->pid = current->pid; 494 temp->pid = current->pid;
495 temp->command = smb_buffer->Command; /* Always LE */ 495 temp->command = smb_buffer->Command; /* Always LE */
496 temp->when_alloc = jiffies; 496 temp->when_alloc = jiffies;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e5d3eadf47b1..bed43081720f 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5166,8 +5166,8 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5166 5166
5167 /* fallback to generic here if not in extents fmt */ 5167 /* fallback to generic here if not in extents fmt */
5168 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) 5168 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
5169 return __generic_block_fiemap(inode, fieinfo, start, len, 5169 return generic_block_fiemap(inode, fieinfo, start, len,
5170 ext4_get_block); 5170 ext4_get_block);
5171 5171
5172 if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS)) 5172 if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))
5173 return -EBADR; 5173 return -EBADR;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 513c12cf444c..8131be8c0af3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -273,19 +273,24 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
273 * we determine this extent as a data or a hole according to whether the 273 * we determine this extent as a data or a hole according to whether the
274 * page cache has data or not. 274 * page cache has data or not.
275 */ 275 */
276static int ext4_find_unwritten_pgoff(struct inode *inode, int whence, 276static int ext4_find_unwritten_pgoff(struct inode *inode,
277 loff_t endoff, loff_t *offset) 277 int whence,
278 struct ext4_map_blocks *map,
279 loff_t *offset)
278{ 280{
279 struct pagevec pvec; 281 struct pagevec pvec;
282 unsigned int blkbits;
280 pgoff_t index; 283 pgoff_t index;
281 pgoff_t end; 284 pgoff_t end;
285 loff_t endoff;
282 loff_t startoff; 286 loff_t startoff;
283 loff_t lastoff; 287 loff_t lastoff;
284 int found = 0; 288 int found = 0;
285 289
290 blkbits = inode->i_sb->s_blocksize_bits;
286 startoff = *offset; 291 startoff = *offset;
287 lastoff = startoff; 292 lastoff = startoff;
288 293 endoff = (loff_t)(map->m_lblk + map->m_len) << blkbits;
289 294
290 index = startoff >> PAGE_CACHE_SHIFT; 295 index = startoff >> PAGE_CACHE_SHIFT;
291 end = endoff >> PAGE_CACHE_SHIFT; 296 end = endoff >> PAGE_CACHE_SHIFT;
@@ -403,144 +408,147 @@ out:
403static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize) 408static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
404{ 409{
405 struct inode *inode = file->f_mapping->host; 410 struct inode *inode = file->f_mapping->host;
406 struct fiemap_extent_info fie; 411 struct ext4_map_blocks map;
407 struct fiemap_extent ext[2]; 412 struct extent_status es;
408 loff_t next; 413 ext4_lblk_t start, last, end;
409 int i, ret = 0; 414 loff_t dataoff, isize;
415 int blkbits;
416 int ret = 0;
410 417
411 mutex_lock(&inode->i_mutex); 418 mutex_lock(&inode->i_mutex);
412 if (offset >= inode->i_size) { 419
420 isize = i_size_read(inode);
421 if (offset >= isize) {
413 mutex_unlock(&inode->i_mutex); 422 mutex_unlock(&inode->i_mutex);
414 return -ENXIO; 423 return -ENXIO;
415 } 424 }
416 fie.fi_flags = 0; 425
417 fie.fi_extents_max = 2; 426 blkbits = inode->i_sb->s_blocksize_bits;
418 fie.fi_extents_start = (struct fiemap_extent __user *) &ext; 427 start = offset >> blkbits;
419 while (1) { 428 last = start;
420 mm_segment_t old_fs = get_fs(); 429 end = isize >> blkbits;
421 430 dataoff = offset;
422 fie.fi_extents_mapped = 0; 431
423 memset(ext, 0, sizeof(*ext) * fie.fi_extents_max); 432 do {
424 433 map.m_lblk = last;
425 set_fs(get_ds()); 434 map.m_len = end - last + 1;
426 ret = ext4_fiemap(inode, &fie, offset, maxsize - offset); 435 ret = ext4_map_blocks(NULL, inode, &map, 0);
427 set_fs(old_fs); 436 if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {
428 if (ret) 437 if (last != start)
438 dataoff = (loff_t)last << blkbits;
429 break; 439 break;
440 }
430 441
431 /* No extents found, EOF */ 442 /*
432 if (!fie.fi_extents_mapped) { 443 * If there is a delay extent at this offset,
433 ret = -ENXIO; 444 * it will be as a data.
445 */
446 ext4_es_find_delayed_extent_range(inode, last, last, &es);
447 if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {
448 if (last != start)
449 dataoff = (loff_t)last << blkbits;
434 break; 450 break;
435 } 451 }
436 for (i = 0; i < fie.fi_extents_mapped; i++) {
437 next = (loff_t)(ext[i].fe_length + ext[i].fe_logical);
438 452
439 if (offset < (loff_t)ext[i].fe_logical) 453 /*
440 offset = (loff_t)ext[i].fe_logical; 454 * If there is a unwritten extent at this offset,
441 /* 455 * it will be as a data or a hole according to page
442 * If extent is not unwritten, then it contains valid 456 * cache that has data or not.
443 * data, mapped or delayed. 457 */
444 */ 458 if (map.m_flags & EXT4_MAP_UNWRITTEN) {
445 if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN)) 459 int unwritten;
446 goto out; 460 unwritten = ext4_find_unwritten_pgoff(inode, SEEK_DATA,
461 &map, &dataoff);
462 if (unwritten)
463 break;
464 }
447 465
448 /* 466 last++;
449 * If there is a unwritten extent at this offset, 467 dataoff = (loff_t)last << blkbits;
450 * it will be as a data or a hole according to page 468 } while (last <= end);
451 * cache that has data or not.
452 */
453 if (ext4_find_unwritten_pgoff(inode, SEEK_DATA,
454 next, &offset))
455 goto out;
456 469
457 if (ext[i].fe_flags & FIEMAP_EXTENT_LAST) {
458 ret = -ENXIO;
459 goto out;
460 }
461 offset = next;
462 }
463 }
464 if (offset > inode->i_size)
465 offset = inode->i_size;
466out:
467 mutex_unlock(&inode->i_mutex); 470 mutex_unlock(&inode->i_mutex);
468 if (ret)
469 return ret;
470 471
471 return vfs_setpos(file, offset, maxsize); 472 if (dataoff > isize)
473 return -ENXIO;
474
475 return vfs_setpos(file, dataoff, maxsize);
472} 476}
473 477
474/* 478/*
475 * ext4_seek_hole() retrieves the offset for SEEK_HOLE 479 * ext4_seek_hole() retrieves the offset for SEEK_HOLE.
476 */ 480 */
477static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize) 481static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
478{ 482{
479 struct inode *inode = file->f_mapping->host; 483 struct inode *inode = file->f_mapping->host;
480 struct fiemap_extent_info fie; 484 struct ext4_map_blocks map;
481 struct fiemap_extent ext[2]; 485 struct extent_status es;
482 loff_t next; 486 ext4_lblk_t start, last, end;
483 int i, ret = 0; 487 loff_t holeoff, isize;
488 int blkbits;
489 int ret = 0;
484 490
485 mutex_lock(&inode->i_mutex); 491 mutex_lock(&inode->i_mutex);
486 if (offset >= inode->i_size) { 492
493 isize = i_size_read(inode);
494 if (offset >= isize) {
487 mutex_unlock(&inode->i_mutex); 495 mutex_unlock(&inode->i_mutex);
488 return -ENXIO; 496 return -ENXIO;
489 } 497 }
490 498
491 fie.fi_flags = 0; 499 blkbits = inode->i_sb->s_blocksize_bits;
492 fie.fi_extents_max = 2; 500 start = offset >> blkbits;
493 fie.fi_extents_start = (struct fiemap_extent __user *)&ext; 501 last = start;
494 while (1) { 502 end = isize >> blkbits;
495 mm_segment_t old_fs = get_fs(); 503 holeoff = offset;
496
497 fie.fi_extents_mapped = 0;
498 memset(ext, 0, sizeof(*ext));
499 504
500 set_fs(get_ds()); 505 do {
501 ret = ext4_fiemap(inode, &fie, offset, maxsize - offset); 506 map.m_lblk = last;
502 set_fs(old_fs); 507 map.m_len = end - last + 1;
503 if (ret) 508 ret = ext4_map_blocks(NULL, inode, &map, 0);
504 break; 509 if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) {
510 last += ret;
511 holeoff = (loff_t)last << blkbits;
512 continue;
513 }
505 514
506 /* No extents found */ 515 /*
507 if (!fie.fi_extents_mapped) 516 * If there is a delay extent at this offset,
508 break; 517 * we will skip this extent.
518 */
519 ext4_es_find_delayed_extent_range(inode, last, last, &es);
520 if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) {
521 last = es.es_lblk + es.es_len;
522 holeoff = (loff_t)last << blkbits;
523 continue;
524 }
509 525
510 for (i = 0; i < fie.fi_extents_mapped; i++) { 526 /*
511 next = (loff_t)(ext[i].fe_logical + ext[i].fe_length); 527 * If there is a unwritten extent at this offset,
512 /* 528 * it will be as a data or a hole according to page
513 * If extent is not unwritten, then it contains valid 529 * cache that has data or not.
514 * data, mapped or delayed. 530 */
515 */ 531 if (map.m_flags & EXT4_MAP_UNWRITTEN) {
516 if (!(ext[i].fe_flags & FIEMAP_EXTENT_UNWRITTEN)) { 532 int unwritten;
517 if (offset < (loff_t)ext[i].fe_logical) 533 unwritten = ext4_find_unwritten_pgoff(inode, SEEK_HOLE,
518 goto out; 534 &map, &holeoff);
519 offset = next; 535 if (!unwritten) {
536 last += ret;
537 holeoff = (loff_t)last << blkbits;
520 continue; 538 continue;
521 } 539 }
522 /*
523 * If there is a unwritten extent at this offset,
524 * it will be as a data or a hole according to page
525 * cache that has data or not.
526 */
527 if (ext4_find_unwritten_pgoff(inode, SEEK_HOLE,
528 next, &offset))
529 goto out;
530
531 offset = next;
532 if (ext[i].fe_flags & FIEMAP_EXTENT_LAST)
533 goto out;
534 } 540 }
535 } 541
536 if (offset > inode->i_size) 542 /* find a hole */
537 offset = inode->i_size; 543 break;
538out: 544 } while (last <= end);
545
539 mutex_unlock(&inode->i_mutex); 546 mutex_unlock(&inode->i_mutex);
540 if (ret)
541 return ret;
542 547
543 return vfs_setpos(file, offset, maxsize); 548 if (holeoff > isize)
549 holeoff = isize;
550
551 return vfs_setpos(file, holeoff, maxsize);
544} 552}
545 553
546/* 554/*
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index bf76f405a5f9..8a8ec6293b19 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -24,6 +24,18 @@ int ext4_resize_begin(struct super_block *sb)
24 return -EPERM; 24 return -EPERM;
25 25
26 /* 26 /*
27 * If we are not using the primary superblock/GDT copy don't resize,
28 * because the user tools have no way of handling this. Probably a
29 * bad time to do it anyways.
30 */
31 if (EXT4_SB(sb)->s_sbh->b_blocknr !=
32 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
33 ext4_warning(sb, "won't resize using backup superblock at %llu",
34 (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
35 return -EPERM;
36 }
37
38 /*
27 * We are not allowed to do online-resizing on a filesystem mounted 39 * We are not allowed to do online-resizing on a filesystem mounted
28 * with error, because it can destroy the filesystem easily. 40 * with error, because it can destroy the filesystem easily.
29 */ 41 */
@@ -758,18 +770,6 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
758 "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n", 770 "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n",
759 gdb_num); 771 gdb_num);
760 772
761 /*
762 * If we are not using the primary superblock/GDT copy don't resize,
763 * because the user tools have no way of handling this. Probably a
764 * bad time to do it anyways.
765 */
766 if (EXT4_SB(sb)->s_sbh->b_blocknr !=
767 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {
768 ext4_warning(sb, "won't resize using backup superblock at %llu",
769 (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr);
770 return -EPERM;
771 }
772
773 gdb_bh = sb_bread(sb, gdblock); 773 gdb_bh = sb_bread(sb, gdblock);
774 if (!gdb_bh) 774 if (!gdb_bh)
775 return -EIO; 775 return -EIO;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 43c92b1685cb..74c5f53595fb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3482,7 +3482,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3482 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, 3482 if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
3483 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) && 3483 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) &&
3484 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) 3484 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
3485 ext4_warning(sb, KERN_INFO "metadata_csum and uninit_bg are " 3485 ext4_warning(sb, "metadata_csum and uninit_bg are "
3486 "redundant flags; please run fsck."); 3486 "redundant flags; please run fsck.");
3487 3487
3488 /* Check for a known checksum algorithm */ 3488 /* Check for a known checksum algorithm */
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 99d440a4a6ba..ee85cd4e136a 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -740,14 +740,15 @@ static int __init fcntl_init(void)
740 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY 740 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
741 * is defined as O_NONBLOCK on some platforms and not on others. 741 * is defined as O_NONBLOCK on some platforms and not on others.
742 */ 742 */
743 BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( 743 BUILD_BUG_ON(21 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
744 O_RDONLY | O_WRONLY | O_RDWR | 744 O_RDONLY | O_WRONLY | O_RDWR |
745 O_CREAT | O_EXCL | O_NOCTTY | 745 O_CREAT | O_EXCL | O_NOCTTY |
746 O_TRUNC | O_APPEND | /* O_NONBLOCK | */ 746 O_TRUNC | O_APPEND | /* O_NONBLOCK | */
747 __O_SYNC | O_DSYNC | FASYNC | 747 __O_SYNC | O_DSYNC | FASYNC |
748 O_DIRECT | O_LARGEFILE | O_DIRECTORY | 748 O_DIRECT | O_LARGEFILE | O_DIRECTORY |
749 O_NOFOLLOW | O_NOATIME | O_CLOEXEC | 749 O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
750 __FMODE_EXEC | O_PATH | __O_TMPFILE 750 __FMODE_EXEC | O_PATH | __O_TMPFILE |
751 __FMODE_NONOTIFY
751 )); 752 ));
752 753
753 fasync_cache = kmem_cache_create("fasync_cache", 754 fasync_cache = kmem_cache_create("fasync_cache",
diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c
index bb63254ed848..735d7522a3a9 100644
--- a/fs/isofs/rock.c
+++ b/fs/isofs/rock.c
@@ -362,6 +362,9 @@ repeat:
362 rs.cont_size = isonum_733(rr->u.CE.size); 362 rs.cont_size = isonum_733(rr->u.CE.size);
363 break; 363 break;
364 case SIG('E', 'R'): 364 case SIG('E', 'R'):
365 /* Invalid length of ER tag id? */
366 if (rr->u.ER.len_id + offsetof(struct rock_ridge, u.ER.data) > rr->len)
367 goto out;
365 ISOFS_SB(inode->i_sb)->s_rock = 1; 368 ISOFS_SB(inode->i_sb)->s_rock = 1;
366 printk(KERN_DEBUG "ISO 9660 Extensions: "); 369 printk(KERN_DEBUG "ISO 9660 Extensions: ");
367 { 370 {
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 3550a9c87616..c06a1ba80d73 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3897,11 +3897,11 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
3897 status = nfs4_setlease(dp); 3897 status = nfs4_setlease(dp);
3898 goto out; 3898 goto out;
3899 } 3899 }
3900 atomic_inc(&fp->fi_delegees);
3901 if (fp->fi_had_conflict) { 3900 if (fp->fi_had_conflict) {
3902 status = -EAGAIN; 3901 status = -EAGAIN;
3903 goto out_unlock; 3902 goto out_unlock;
3904 } 3903 }
3904 atomic_inc(&fp->fi_delegees);
3905 hash_delegation_locked(dp, fp); 3905 hash_delegation_locked(dp, fp);
3906 status = 0; 3906 status = 0;
3907out_unlock: 3907out_unlock:
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index c991616acca9..bff8567aa42d 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -259,16 +259,15 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
259 struct fsnotify_event *kevent; 259 struct fsnotify_event *kevent;
260 char __user *start; 260 char __user *start;
261 int ret; 261 int ret;
262 DEFINE_WAIT(wait); 262 DEFINE_WAIT_FUNC(wait, woken_wake_function);
263 263
264 start = buf; 264 start = buf;
265 group = file->private_data; 265 group = file->private_data;
266 266
267 pr_debug("%s: group=%p\n", __func__, group); 267 pr_debug("%s: group=%p\n", __func__, group);
268 268
269 add_wait_queue(&group->notification_waitq, &wait);
269 while (1) { 270 while (1) {
270 prepare_to_wait(&group->notification_waitq, &wait, TASK_INTERRUPTIBLE);
271
272 mutex_lock(&group->notification_mutex); 271 mutex_lock(&group->notification_mutex);
273 kevent = get_one_event(group, count); 272 kevent = get_one_event(group, count);
274 mutex_unlock(&group->notification_mutex); 273 mutex_unlock(&group->notification_mutex);
@@ -289,7 +288,8 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
289 288
290 if (start != buf) 289 if (start != buf)
291 break; 290 break;
292 schedule(); 291
292 wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
293 continue; 293 continue;
294 } 294 }
295 295
@@ -318,8 +318,8 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
318 buf += ret; 318 buf += ret;
319 count -= ret; 319 count -= ret;
320 } 320 }
321 remove_wait_queue(&group->notification_waitq, &wait);
321 322
322 finish_wait(&group->notification_waitq, &wait);
323 if (start != buf && ret != -EFAULT) 323 if (start != buf && ret != -EFAULT)
324 ret = buf - start; 324 ret = buf - start;
325 return ret; 325 return ret;
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 79b5af5e6a7b..cecd875653e4 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2023,11 +2023,8 @@ leave:
2023 dlm_lockres_drop_inflight_ref(dlm, res); 2023 dlm_lockres_drop_inflight_ref(dlm, res);
2024 spin_unlock(&res->spinlock); 2024 spin_unlock(&res->spinlock);
2025 2025
2026 if (ret < 0) { 2026 if (ret < 0)
2027 mlog_errno(ret); 2027 mlog_errno(ret);
2028 if (newlock)
2029 dlm_lock_put(newlock);
2030 }
2031 2028
2032 return ret; 2029 return ret;
2033} 2030}
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index b931e04e3388..914c121ec890 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -94,6 +94,14 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
94 struct inode *inode, 94 struct inode *inode,
95 const char *symname); 95 const char *symname);
96 96
97static int ocfs2_double_lock(struct ocfs2_super *osb,
98 struct buffer_head **bh1,
99 struct inode *inode1,
100 struct buffer_head **bh2,
101 struct inode *inode2,
102 int rename);
103
104static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2);
97/* An orphan dir name is an 8 byte value, printed as a hex string */ 105/* An orphan dir name is an 8 byte value, printed as a hex string */
98#define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64))) 106#define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64)))
99 107
@@ -678,8 +686,10 @@ static int ocfs2_link(struct dentry *old_dentry,
678{ 686{
679 handle_t *handle; 687 handle_t *handle;
680 struct inode *inode = old_dentry->d_inode; 688 struct inode *inode = old_dentry->d_inode;
689 struct inode *old_dir = old_dentry->d_parent->d_inode;
681 int err; 690 int err;
682 struct buffer_head *fe_bh = NULL; 691 struct buffer_head *fe_bh = NULL;
692 struct buffer_head *old_dir_bh = NULL;
683 struct buffer_head *parent_fe_bh = NULL; 693 struct buffer_head *parent_fe_bh = NULL;
684 struct ocfs2_dinode *fe = NULL; 694 struct ocfs2_dinode *fe = NULL;
685 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); 695 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
@@ -696,19 +706,33 @@ static int ocfs2_link(struct dentry *old_dentry,
696 706
697 dquot_initialize(dir); 707 dquot_initialize(dir);
698 708
699 err = ocfs2_inode_lock_nested(dir, &parent_fe_bh, 1, OI_LS_PARENT); 709 err = ocfs2_double_lock(osb, &old_dir_bh, old_dir,
710 &parent_fe_bh, dir, 0);
700 if (err < 0) { 711 if (err < 0) {
701 if (err != -ENOENT) 712 if (err != -ENOENT)
702 mlog_errno(err); 713 mlog_errno(err);
703 return err; 714 return err;
704 } 715 }
705 716
717 /* make sure both dirs have bhs
718 * get an extra ref on old_dir_bh if old==new */
719 if (!parent_fe_bh) {
720 if (old_dir_bh) {
721 parent_fe_bh = old_dir_bh;
722 get_bh(parent_fe_bh);
723 } else {
724 mlog(ML_ERROR, "%s: no old_dir_bh!\n", osb->uuid_str);
725 err = -EIO;
726 goto out;
727 }
728 }
729
706 if (!dir->i_nlink) { 730 if (!dir->i_nlink) {
707 err = -ENOENT; 731 err = -ENOENT;
708 goto out; 732 goto out;
709 } 733 }
710 734
711 err = ocfs2_lookup_ino_from_name(dir, old_dentry->d_name.name, 735 err = ocfs2_lookup_ino_from_name(old_dir, old_dentry->d_name.name,
712 old_dentry->d_name.len, &old_de_ino); 736 old_dentry->d_name.len, &old_de_ino);
713 if (err) { 737 if (err) {
714 err = -ENOENT; 738 err = -ENOENT;
@@ -801,10 +825,11 @@ out_unlock_inode:
801 ocfs2_inode_unlock(inode, 1); 825 ocfs2_inode_unlock(inode, 1);
802 826
803out: 827out:
804 ocfs2_inode_unlock(dir, 1); 828 ocfs2_double_unlock(old_dir, dir);
805 829
806 brelse(fe_bh); 830 brelse(fe_bh);
807 brelse(parent_fe_bh); 831 brelse(parent_fe_bh);
832 brelse(old_dir_bh);
808 833
809 ocfs2_free_dir_lookup_result(&lookup); 834 ocfs2_free_dir_lookup_result(&lookup);
810 835
@@ -1072,14 +1097,15 @@ static int ocfs2_check_if_ancestor(struct ocfs2_super *osb,
1072} 1097}
1073 1098
1074/* 1099/*
1075 * The only place this should be used is rename! 1100 * The only place this should be used is rename and link!
1076 * if they have the same id, then the 1st one is the only one locked. 1101 * if they have the same id, then the 1st one is the only one locked.
1077 */ 1102 */
1078static int ocfs2_double_lock(struct ocfs2_super *osb, 1103static int ocfs2_double_lock(struct ocfs2_super *osb,
1079 struct buffer_head **bh1, 1104 struct buffer_head **bh1,
1080 struct inode *inode1, 1105 struct inode *inode1,
1081 struct buffer_head **bh2, 1106 struct buffer_head **bh2,
1082 struct inode *inode2) 1107 struct inode *inode2,
1108 int rename)
1083{ 1109{
1084 int status; 1110 int status;
1085 int inode1_is_ancestor, inode2_is_ancestor; 1111 int inode1_is_ancestor, inode2_is_ancestor;
@@ -1127,7 +1153,7 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
1127 } 1153 }
1128 /* lock id2 */ 1154 /* lock id2 */
1129 status = ocfs2_inode_lock_nested(inode2, bh2, 1, 1155 status = ocfs2_inode_lock_nested(inode2, bh2, 1,
1130 OI_LS_RENAME1); 1156 rename == 1 ? OI_LS_RENAME1 : OI_LS_PARENT);
1131 if (status < 0) { 1157 if (status < 0) {
1132 if (status != -ENOENT) 1158 if (status != -ENOENT)
1133 mlog_errno(status); 1159 mlog_errno(status);
@@ -1136,7 +1162,8 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
1136 } 1162 }
1137 1163
1138 /* lock id1 */ 1164 /* lock id1 */
1139 status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_RENAME2); 1165 status = ocfs2_inode_lock_nested(inode1, bh1, 1,
1166 rename == 1 ? OI_LS_RENAME2 : OI_LS_PARENT);
1140 if (status < 0) { 1167 if (status < 0) {
1141 /* 1168 /*
1142 * An error return must mean that no cluster locks 1169 * An error return must mean that no cluster locks
@@ -1252,7 +1279,7 @@ static int ocfs2_rename(struct inode *old_dir,
1252 1279
1253 /* if old and new are the same, this'll just do one lock. */ 1280 /* if old and new are the same, this'll just do one lock. */
1254 status = ocfs2_double_lock(osb, &old_dir_bh, old_dir, 1281 status = ocfs2_double_lock(osb, &old_dir_bh, old_dir,
1255 &new_dir_bh, new_dir); 1282 &new_dir_bh, new_dir, 1);
1256 if (status < 0) { 1283 if (status < 0) {
1257 mlog_errno(status); 1284 mlog_errno(status);
1258 goto bail; 1285 goto bail;
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index a012c51caffd..05e90edd1992 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -57,6 +57,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
57 sector_t offset; 57 sector_t offset;
58 int i, num, ret = 0; 58 int i, num, ret = 0;
59 struct extent_position epos = { NULL, 0, {0, 0} }; 59 struct extent_position epos = { NULL, 0, {0, 0} };
60 struct super_block *sb = dir->i_sb;
60 61
61 if (ctx->pos == 0) { 62 if (ctx->pos == 0) {
62 if (!dir_emit_dot(file, ctx)) 63 if (!dir_emit_dot(file, ctx))
@@ -76,16 +77,16 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
76 if (nf_pos == 0) 77 if (nf_pos == 0)
77 nf_pos = udf_ext0_offset(dir); 78 nf_pos = udf_ext0_offset(dir);
78 79
79 fibh.soffset = fibh.eoffset = nf_pos & (dir->i_sb->s_blocksize - 1); 80 fibh.soffset = fibh.eoffset = nf_pos & (sb->s_blocksize - 1);
80 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { 81 if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
81 if (inode_bmap(dir, nf_pos >> dir->i_sb->s_blocksize_bits, 82 if (inode_bmap(dir, nf_pos >> sb->s_blocksize_bits,
82 &epos, &eloc, &elen, &offset) 83 &epos, &eloc, &elen, &offset)
83 != (EXT_RECORDED_ALLOCATED >> 30)) { 84 != (EXT_RECORDED_ALLOCATED >> 30)) {
84 ret = -ENOENT; 85 ret = -ENOENT;
85 goto out; 86 goto out;
86 } 87 }
87 block = udf_get_lb_pblock(dir->i_sb, &eloc, offset); 88 block = udf_get_lb_pblock(sb, &eloc, offset);
88 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 89 if ((++offset << sb->s_blocksize_bits) < elen) {
89 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 90 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
90 epos.offset -= sizeof(struct short_ad); 91 epos.offset -= sizeof(struct short_ad);
91 else if (iinfo->i_alloc_type == 92 else if (iinfo->i_alloc_type ==
@@ -95,18 +96,18 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
95 offset = 0; 96 offset = 0;
96 } 97 }
97 98
98 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { 99 if (!(fibh.sbh = fibh.ebh = udf_tread(sb, block))) {
99 ret = -EIO; 100 ret = -EIO;
100 goto out; 101 goto out;
101 } 102 }
102 103
103 if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { 104 if (!(offset & ((16 >> (sb->s_blocksize_bits - 9)) - 1))) {
104 i = 16 >> (dir->i_sb->s_blocksize_bits - 9); 105 i = 16 >> (sb->s_blocksize_bits - 9);
105 if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) 106 if (i + offset > (elen >> sb->s_blocksize_bits))
106 i = (elen >> dir->i_sb->s_blocksize_bits) - offset; 107 i = (elen >> sb->s_blocksize_bits) - offset;
107 for (num = 0; i > 0; i--) { 108 for (num = 0; i > 0; i--) {
108 block = udf_get_lb_pblock(dir->i_sb, &eloc, offset + i); 109 block = udf_get_lb_pblock(sb, &eloc, offset + i);
109 tmp = udf_tgetblk(dir->i_sb, block); 110 tmp = udf_tgetblk(sb, block);
110 if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp)) 111 if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
111 bha[num++] = tmp; 112 bha[num++] = tmp;
112 else 113 else
@@ -152,12 +153,12 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
152 } 153 }
153 154
154 if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 155 if ((cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
155 if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) 156 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE))
156 continue; 157 continue;
157 } 158 }
158 159
159 if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) { 160 if ((cfi.fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
160 if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) 161 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE))
161 continue; 162 continue;
162 } 163 }
163 164
@@ -167,12 +168,12 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
167 continue; 168 continue;
168 } 169 }
169 170
170 flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); 171 flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
171 if (!flen) 172 if (!flen)
172 continue; 173 continue;
173 174
174 tloc = lelb_to_cpu(cfi.icb.extLocation); 175 tloc = lelb_to_cpu(cfi.icb.extLocation);
175 iblock = udf_get_lb_pblock(dir->i_sb, &tloc, 0); 176 iblock = udf_get_lb_pblock(sb, &tloc, 0);
176 if (!dir_emit(ctx, fname, flen, iblock, DT_UNKNOWN)) 177 if (!dir_emit(ctx, fname, flen, iblock, DT_UNKNOWN))
177 goto out; 178 goto out;
178 } /* end while */ 179 } /* end while */
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index c9b4df5810d5..5bc71d9a674a 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1489,6 +1489,20 @@ reread:
1489 } 1489 }
1490 inode->i_generation = iinfo->i_unique; 1490 inode->i_generation = iinfo->i_unique;
1491 1491
1492 /* Sanity checks for files in ICB so that we don't get confused later */
1493 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
1494 /*
1495 * For file in ICB data is stored in allocation descriptor
1496 * so sizes should match
1497 */
1498 if (iinfo->i_lenAlloc != inode->i_size)
1499 goto out;
1500 /* File in ICB has to fit in there... */
1501 if (inode->i_size > inode->i_sb->s_blocksize -
1502 udf_file_entry_alloc_offset(inode))
1503 goto out;
1504 }
1505
1492 switch (fe->icbTag.fileType) { 1506 switch (fe->icbTag.fileType) {
1493 case ICBTAG_FILE_TYPE_DIRECTORY: 1507 case ICBTAG_FILE_TYPE_DIRECTORY:
1494 inode->i_op = &udf_dir_inode_operations; 1508 inode->i_op = &udf_dir_inode_operations;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index c12e260fd6c4..33b246b82c98 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -159,18 +159,19 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
159 struct udf_inode_info *dinfo = UDF_I(dir); 159 struct udf_inode_info *dinfo = UDF_I(dir);
160 int isdotdot = child->len == 2 && 160 int isdotdot = child->len == 2 &&
161 child->name[0] == '.' && child->name[1] == '.'; 161 child->name[0] == '.' && child->name[1] == '.';
162 struct super_block *sb = dir->i_sb;
162 163
163 size = udf_ext0_offset(dir) + dir->i_size; 164 size = udf_ext0_offset(dir) + dir->i_size;
164 f_pos = udf_ext0_offset(dir); 165 f_pos = udf_ext0_offset(dir);
165 166
166 fibh->sbh = fibh->ebh = NULL; 167 fibh->sbh = fibh->ebh = NULL;
167 fibh->soffset = fibh->eoffset = f_pos & (dir->i_sb->s_blocksize - 1); 168 fibh->soffset = fibh->eoffset = f_pos & (sb->s_blocksize - 1);
168 if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { 169 if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) {
169 if (inode_bmap(dir, f_pos >> dir->i_sb->s_blocksize_bits, &epos, 170 if (inode_bmap(dir, f_pos >> sb->s_blocksize_bits, &epos,
170 &eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30)) 171 &eloc, &elen, &offset) != (EXT_RECORDED_ALLOCATED >> 30))
171 goto out_err; 172 goto out_err;
172 block = udf_get_lb_pblock(dir->i_sb, &eloc, offset); 173 block = udf_get_lb_pblock(sb, &eloc, offset);
173 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 174 if ((++offset << sb->s_blocksize_bits) < elen) {
174 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 175 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
175 epos.offset -= sizeof(struct short_ad); 176 epos.offset -= sizeof(struct short_ad);
176 else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) 177 else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
@@ -178,7 +179,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
178 } else 179 } else
179 offset = 0; 180 offset = 0;
180 181
181 fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); 182 fibh->sbh = fibh->ebh = udf_tread(sb, block);
182 if (!fibh->sbh) 183 if (!fibh->sbh)
183 goto out_err; 184 goto out_err;
184 } 185 }
@@ -217,12 +218,12 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
217 } 218 }
218 219
219 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 220 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
220 if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNDELETE)) 221 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNDELETE))
221 continue; 222 continue;
222 } 223 }
223 224
224 if ((cfi->fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) { 225 if ((cfi->fileCharacteristics & FID_FILE_CHAR_HIDDEN) != 0) {
225 if (!UDF_QUERY_FLAG(dir->i_sb, UDF_FLAG_UNHIDE)) 226 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_UNHIDE))
226 continue; 227 continue;
227 } 228 }
228 229
@@ -233,7 +234,7 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
233 if (!lfi) 234 if (!lfi)
234 continue; 235 continue;
235 236
236 flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi); 237 flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
237 if (flen && udf_match(flen, fname, child->len, child->name)) 238 if (flen && udf_match(flen, fname, child->len, child->name))
238 goto out_ok; 239 goto out_ok;
239 } 240 }
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index 6fb7945c1e6e..ac10ca939f26 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -30,49 +30,73 @@
30#include <linux/buffer_head.h> 30#include <linux/buffer_head.h>
31#include "udf_i.h" 31#include "udf_i.h"
32 32
33static void udf_pc_to_char(struct super_block *sb, unsigned char *from, 33static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
34 int fromlen, unsigned char *to) 34 int fromlen, unsigned char *to, int tolen)
35{ 35{
36 struct pathComponent *pc; 36 struct pathComponent *pc;
37 int elen = 0; 37 int elen = 0;
38 int comp_len;
38 unsigned char *p = to; 39 unsigned char *p = to;
39 40
41 /* Reserve one byte for terminating \0 */
42 tolen--;
40 while (elen < fromlen) { 43 while (elen < fromlen) {
41 pc = (struct pathComponent *)(from + elen); 44 pc = (struct pathComponent *)(from + elen);
45 elen += sizeof(struct pathComponent);
42 switch (pc->componentType) { 46 switch (pc->componentType) {
43 case 1: 47 case 1:
44 /* 48 /*
45 * Symlink points to some place which should be agreed 49 * Symlink points to some place which should be agreed
46 * upon between originator and receiver of the media. Ignore. 50 * upon between originator and receiver of the media. Ignore.
47 */ 51 */
48 if (pc->lengthComponentIdent > 0) 52 if (pc->lengthComponentIdent > 0) {
53 elen += pc->lengthComponentIdent;
49 break; 54 break;
55 }
50 /* Fall through */ 56 /* Fall through */
51 case 2: 57 case 2:
58 if (tolen == 0)
59 return -ENAMETOOLONG;
52 p = to; 60 p = to;
53 *p++ = '/'; 61 *p++ = '/';
62 tolen--;
54 break; 63 break;
55 case 3: 64 case 3:
65 if (tolen < 3)
66 return -ENAMETOOLONG;
56 memcpy(p, "../", 3); 67 memcpy(p, "../", 3);
57 p += 3; 68 p += 3;
69 tolen -= 3;
58 break; 70 break;
59 case 4: 71 case 4:
72 if (tolen < 2)
73 return -ENAMETOOLONG;
60 memcpy(p, "./", 2); 74 memcpy(p, "./", 2);
61 p += 2; 75 p += 2;
76 tolen -= 2;
62 /* that would be . - just ignore */ 77 /* that would be . - just ignore */
63 break; 78 break;
64 case 5: 79 case 5:
65 p += udf_get_filename(sb, pc->componentIdent, p, 80 elen += pc->lengthComponentIdent;
66 pc->lengthComponentIdent); 81 if (elen > fromlen)
82 return -EIO;
83 comp_len = udf_get_filename(sb, pc->componentIdent,
84 pc->lengthComponentIdent,
85 p, tolen);
86 p += comp_len;
87 tolen -= comp_len;
88 if (tolen == 0)
89 return -ENAMETOOLONG;
67 *p++ = '/'; 90 *p++ = '/';
91 tolen--;
68 break; 92 break;
69 } 93 }
70 elen += sizeof(struct pathComponent) + pc->lengthComponentIdent;
71 } 94 }
72 if (p > to + 1) 95 if (p > to + 1)
73 p[-1] = '\0'; 96 p[-1] = '\0';
74 else 97 else
75 p[0] = '\0'; 98 p[0] = '\0';
99 return 0;
76} 100}
77 101
78static int udf_symlink_filler(struct file *file, struct page *page) 102static int udf_symlink_filler(struct file *file, struct page *page)
@@ -80,11 +104,17 @@ static int udf_symlink_filler(struct file *file, struct page *page)
80 struct inode *inode = page->mapping->host; 104 struct inode *inode = page->mapping->host;
81 struct buffer_head *bh = NULL; 105 struct buffer_head *bh = NULL;
82 unsigned char *symlink; 106 unsigned char *symlink;
83 int err = -EIO; 107 int err;
84 unsigned char *p = kmap(page); 108 unsigned char *p = kmap(page);
85 struct udf_inode_info *iinfo; 109 struct udf_inode_info *iinfo;
86 uint32_t pos; 110 uint32_t pos;
87 111
112 /* We don't support symlinks longer than one block */
113 if (inode->i_size > inode->i_sb->s_blocksize) {
114 err = -ENAMETOOLONG;
115 goto out_unmap;
116 }
117
88 iinfo = UDF_I(inode); 118 iinfo = UDF_I(inode);
89 pos = udf_block_map(inode, 0); 119 pos = udf_block_map(inode, 0);
90 120
@@ -94,14 +124,18 @@ static int udf_symlink_filler(struct file *file, struct page *page)
94 } else { 124 } else {
95 bh = sb_bread(inode->i_sb, pos); 125 bh = sb_bread(inode->i_sb, pos);
96 126
97 if (!bh) 127 if (!bh) {
98 goto out; 128 err = -EIO;
129 goto out_unlock_inode;
130 }
99 131
100 symlink = bh->b_data; 132 symlink = bh->b_data;
101 } 133 }
102 134
103 udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p); 135 err = udf_pc_to_char(inode->i_sb, symlink, inode->i_size, p, PAGE_SIZE);
104 brelse(bh); 136 brelse(bh);
137 if (err)
138 goto out_unlock_inode;
105 139
106 up_read(&iinfo->i_data_sem); 140 up_read(&iinfo->i_data_sem);
107 SetPageUptodate(page); 141 SetPageUptodate(page);
@@ -109,9 +143,10 @@ static int udf_symlink_filler(struct file *file, struct page *page)
109 unlock_page(page); 143 unlock_page(page);
110 return 0; 144 return 0;
111 145
112out: 146out_unlock_inode:
113 up_read(&iinfo->i_data_sem); 147 up_read(&iinfo->i_data_sem);
114 SetPageError(page); 148 SetPageError(page);
149out_unmap:
115 kunmap(page); 150 kunmap(page);
116 unlock_page(page); 151 unlock_page(page);
117 return err; 152 return err;
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 1cc3c993ebd0..47bb3f5ca360 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -211,7 +211,8 @@ udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
211} 211}
212 212
213/* unicode.c */ 213/* unicode.c */
214extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int); 214extern int udf_get_filename(struct super_block *, uint8_t *, int, uint8_t *,
215 int);
215extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, 216extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
216 int); 217 int);
217extern int udf_build_ustr(struct ustr *, dstring *, int); 218extern int udf_build_ustr(struct ustr *, dstring *, int);
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index afd470e588ff..b84fee372734 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -28,7 +28,8 @@
28 28
29#include "udf_sb.h" 29#include "udf_sb.h"
30 30
31static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int); 31static int udf_translate_to_linux(uint8_t *, int, uint8_t *, int, uint8_t *,
32 int);
32 33
33static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen) 34static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
34{ 35{
@@ -333,8 +334,8 @@ try_again:
333 return u_len + 1; 334 return u_len + 1;
334} 335}
335 336
336int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname, 337int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
337 int flen) 338 uint8_t *dname, int dlen)
338{ 339{
339 struct ustr *filename, *unifilename; 340 struct ustr *filename, *unifilename;
340 int len = 0; 341 int len = 0;
@@ -347,7 +348,7 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
347 if (!unifilename) 348 if (!unifilename)
348 goto out1; 349 goto out1;
349 350
350 if (udf_build_ustr_exact(unifilename, sname, flen)) 351 if (udf_build_ustr_exact(unifilename, sname, slen))
351 goto out2; 352 goto out2;
352 353
353 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 354 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
@@ -366,7 +367,8 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
366 } else 367 } else
367 goto out2; 368 goto out2;
368 369
369 len = udf_translate_to_linux(dname, filename->u_name, filename->u_len, 370 len = udf_translate_to_linux(dname, dlen,
371 filename->u_name, filename->u_len,
370 unifilename->u_name, unifilename->u_len); 372 unifilename->u_name, unifilename->u_len);
371out2: 373out2:
372 kfree(unifilename); 374 kfree(unifilename);
@@ -403,10 +405,12 @@ int udf_put_filename(struct super_block *sb, const uint8_t *sname,
403#define EXT_MARK '.' 405#define EXT_MARK '.'
404#define CRC_MARK '#' 406#define CRC_MARK '#'
405#define EXT_SIZE 5 407#define EXT_SIZE 5
408/* Number of chars we need to store generated CRC to make filename unique */
409#define CRC_LEN 5
406 410
407static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, 411static int udf_translate_to_linux(uint8_t *newName, int newLen,
408 int udfLen, uint8_t *fidName, 412 uint8_t *udfName, int udfLen,
409 int fidNameLen) 413 uint8_t *fidName, int fidNameLen)
410{ 414{
411 int index, newIndex = 0, needsCRC = 0; 415 int index, newIndex = 0, needsCRC = 0;
412 int extIndex = 0, newExtIndex = 0, hasExt = 0; 416 int extIndex = 0, newExtIndex = 0, hasExt = 0;
@@ -439,7 +443,7 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
439 newExtIndex = newIndex; 443 newExtIndex = newIndex;
440 } 444 }
441 } 445 }
442 if (newIndex < 256) 446 if (newIndex < newLen)
443 newName[newIndex++] = curr; 447 newName[newIndex++] = curr;
444 else 448 else
445 needsCRC = 1; 449 needsCRC = 1;
@@ -467,13 +471,13 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
467 } 471 }
468 ext[localExtIndex++] = curr; 472 ext[localExtIndex++] = curr;
469 } 473 }
470 maxFilenameLen = 250 - localExtIndex; 474 maxFilenameLen = newLen - CRC_LEN - localExtIndex;
471 if (newIndex > maxFilenameLen) 475 if (newIndex > maxFilenameLen)
472 newIndex = maxFilenameLen; 476 newIndex = maxFilenameLen;
473 else 477 else
474 newIndex = newExtIndex; 478 newIndex = newExtIndex;
475 } else if (newIndex > 250) 479 } else if (newIndex > newLen - CRC_LEN)
476 newIndex = 250; 480 newIndex = newLen - CRC_LEN;
477 newName[newIndex++] = CRC_MARK; 481 newName[newIndex++] = CRC_MARK;
478 valueCRC = crc_itu_t(0, fidName, fidNameLen); 482 valueCRC = crc_itu_t(0, fidName, fidNameLen);
479 newName[newIndex++] = hex_asc_upper_hi(valueCRC >> 8); 483 newName[newIndex++] = hex_asc_upper_hi(valueCRC >> 8);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 3ca9b751f122..b95dc32a6e6b 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -196,8 +196,8 @@ struct acpi_processor_flags {
196struct acpi_processor { 196struct acpi_processor {
197 acpi_handle handle; 197 acpi_handle handle;
198 u32 acpi_id; 198 u32 acpi_id;
199 u32 apic_id; 199 u32 phys_id; /* CPU hardware ID such as APIC ID for x86 */
200 u32 id; 200 u32 id; /* CPU logical ID allocated by OS */
201 u32 pblk; 201 u32 pblk;
202 int performance_platform_limit; 202 int performance_platform_limit;
203 int throttling_platform_limit; 203 int throttling_platform_limit;
@@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
310#endif /* CONFIG_CPU_FREQ */ 310#endif /* CONFIG_CPU_FREQ */
311 311
312/* in processor_core.c */ 312/* in processor_core.c */
313int acpi_get_apicid(acpi_handle, int type, u32 acpi_id); 313int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
314int acpi_map_cpuid(int apic_id, u32 acpi_id); 314int acpi_map_cpuid(int phys_id, u32 acpi_id);
315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
316 316
317/* in processor_pdc.c */ 317/* in processor_pdc.c */
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8ba35c622e22..e1b2e8b98af7 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -901,11 +901,15 @@ extern int drm_vblank_init(struct drm_device *dev, int num_crtcs);
901extern int drm_wait_vblank(struct drm_device *dev, void *data, 901extern int drm_wait_vblank(struct drm_device *dev, void *data,
902 struct drm_file *filp); 902 struct drm_file *filp);
903extern u32 drm_vblank_count(struct drm_device *dev, int crtc); 903extern u32 drm_vblank_count(struct drm_device *dev, int crtc);
904extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
904extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc, 905extern u32 drm_vblank_count_and_time(struct drm_device *dev, int crtc,
905 struct timeval *vblanktime); 906 struct timeval *vblanktime);
906extern void drm_send_vblank_event(struct drm_device *dev, int crtc, 907extern void drm_send_vblank_event(struct drm_device *dev, int crtc,
907 struct drm_pending_vblank_event *e); 908 struct drm_pending_vblank_event *e);
909extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
910 struct drm_pending_vblank_event *e);
908extern bool drm_handle_vblank(struct drm_device *dev, int crtc); 911extern bool drm_handle_vblank(struct drm_device *dev, int crtc);
912extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
909extern int drm_vblank_get(struct drm_device *dev, int crtc); 913extern int drm_vblank_get(struct drm_device *dev, int crtc);
910extern void drm_vblank_put(struct drm_device *dev, int crtc); 914extern void drm_vblank_put(struct drm_device *dev, int crtc);
911extern int drm_crtc_vblank_get(struct drm_crtc *crtc); 915extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 780511a459c0..1e6ae1458f7a 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -119,13 +119,6 @@ struct drm_gem_object {
119 * simply leave it as NULL. 119 * simply leave it as NULL.
120 */ 120 */
121 struct dma_buf_attachment *import_attach; 121 struct dma_buf_attachment *import_attach;
122
123 /**
124 * dumb - created as dumb buffer
125 * Whether the gem object was created using the dumb buffer interface
126 * as such it may not be used for GPU rendering.
127 */
128 bool dumb;
129}; 122};
130 123
131void drm_gem_object_release(struct drm_gem_object *obj); 124void drm_gem_object_release(struct drm_gem_object *obj);
diff --git a/include/dt-bindings/thermal/thermal.h b/include/dt-bindings/thermal/thermal.h
index 59822a995858..b5e6b0069ac7 100644
--- a/include/dt-bindings/thermal/thermal.h
+++ b/include/dt-bindings/thermal/thermal.h
@@ -11,7 +11,7 @@
11#define _DT_BINDINGS_THERMAL_THERMAL_H 11#define _DT_BINDINGS_THERMAL_THERMAL_H
12 12
13/* On cooling devices upper and lower limits */ 13/* On cooling devices upper and lower limits */
14#define THERMAL_NO_LIMIT (-1UL) 14#define THERMAL_NO_LIMIT (~0)
15 15
16#endif 16#endif
17 17
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 856d381b1d5b..d459cd17b477 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -147,8 +147,8 @@ void acpi_numa_arch_fixup(void);
147 147
148#ifdef CONFIG_ACPI_HOTPLUG_CPU 148#ifdef CONFIG_ACPI_HOTPLUG_CPU
149/* Arch dependent functions for cpu hotplug support */ 149/* Arch dependent functions for cpu hotplug support */
150int acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu); 150int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu);
151int acpi_unmap_lsapic(int cpu); 151int acpi_unmap_cpu(int cpu);
152#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 152#endif /* CONFIG_ACPI_HOTPLUG_CPU */
153 153
154int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base); 154int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base);
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 0c04917c2f12..af84234e1f6e 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -47,6 +47,7 @@ struct sk_buff;
47 47
48struct audit_krule { 48struct audit_krule {
49 int vers_ops; 49 int vers_ops;
50 u32 pflags;
50 u32 flags; 51 u32 flags;
51 u32 listnr; 52 u32 listnr;
52 u32 action; 53 u32 action;
@@ -64,6 +65,9 @@ struct audit_krule {
64 u64 prio; 65 u64 prio;
65}; 66};
66 67
68/* Flag to indicate legacy AUDIT_LOGINUID unset usage */
69#define AUDIT_LOGINUID_LEGACY 0x1
70
67struct audit_field { 71struct audit_field {
68 u32 type; 72 u32 type;
69 union { 73 union {
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 5d86416d35f2..61b19c46bdb3 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -87,8 +87,8 @@ struct ceph_osd_req_op {
87 struct ceph_osd_data osd_data; 87 struct ceph_osd_data osd_data;
88 } extent; 88 } extent;
89 struct { 89 struct {
90 __le32 name_len; 90 u32 name_len;
91 __le32 value_len; 91 u32 value_len;
92 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */ 92 __u8 cmp_op; /* CEPH_OSD_CMPXATTR_OP_* */
93 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */ 93 __u8 cmp_mode; /* CEPH_OSD_CMPXATTR_MODE_* */
94 struct ceph_osd_data osd_data; 94 struct ceph_osd_data osd_data;
diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h
index c303d383def1..bd955270d5aa 100644
--- a/include/linux/cpu_cooling.h
+++ b/include/linux/cpu_cooling.h
@@ -50,7 +50,7 @@ static inline struct thermal_cooling_device *
50of_cpufreq_cooling_register(struct device_node *np, 50of_cpufreq_cooling_register(struct device_node *np,
51 const struct cpumask *clip_cpus) 51 const struct cpumask *clip_cpus)
52{ 52{
53 return NULL; 53 return ERR_PTR(-ENOSYS);
54} 54}
55#endif 55#endif
56 56
@@ -65,13 +65,13 @@ unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
65static inline struct thermal_cooling_device * 65static inline struct thermal_cooling_device *
66cpufreq_cooling_register(const struct cpumask *clip_cpus) 66cpufreq_cooling_register(const struct cpumask *clip_cpus)
67{ 67{
68 return NULL; 68 return ERR_PTR(-ENOSYS);
69} 69}
70static inline struct thermal_cooling_device * 70static inline struct thermal_cooling_device *
71of_cpufreq_cooling_register(struct device_node *np, 71of_cpufreq_cooling_register(struct device_node *np,
72 const struct cpumask *clip_cpus) 72 const struct cpumask *clip_cpus)
73{ 73{
74 return NULL; 74 return ERR_PTR(-ENOSYS);
75} 75}
76static inline 76static inline
77void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 77void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index a07e087f54b2..ab70f3bc44ad 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -53,7 +53,6 @@ struct cpuidle_state {
53}; 53};
54 54
55/* Idle State Flags */ 55/* Idle State Flags */
56#define CPUIDLE_FLAG_TIME_INVALID (0x01) /* is residency time measurable? */
57#define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */ 56#define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
58#define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */ 57#define CPUIDLE_FLAG_TIMER_STOP (0x04) /* timer is stopped on this state */
59 58
@@ -89,8 +88,6 @@ DECLARE_PER_CPU(struct cpuidle_device, cpuidle_dev);
89/** 88/**
90 * cpuidle_get_last_residency - retrieves the last state's residency time 89 * cpuidle_get_last_residency - retrieves the last state's residency time
91 * @dev: the target CPU 90 * @dev: the target CPU
92 *
93 * NOTE: this value is invalid if CPUIDLE_FLAG_TIME_INVALID is set
94 */ 91 */
95static inline int cpuidle_get_last_residency(struct cpuidle_device *dev) 92static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
96{ 93{
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f90c0282c114..42efe13077b6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -135,7 +135,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
135#define FMODE_CAN_WRITE ((__force fmode_t)0x40000) 135#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)
136 136
137/* File was opened by fanotify and shouldn't generate fanotify events */ 137/* File was opened by fanotify and shouldn't generate fanotify events */
138#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 138#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
139 139
140/* 140/*
141 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector 141 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index 290db1269c4c..75ae2e2631fc 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -13,11 +13,54 @@
13 * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com> 13 * Copyright (C) 2009 Jason Wessel <jason.wessel@windriver.com>
14 */ 14 */
15 15
16/* Shifted versions of the command enable bits are be used if the command
17 * has no arguments (see kdb_check_flags). This allows commands, such as
18 * go, to have different permissions depending upon whether it is called
19 * with an argument.
20 */
21#define KDB_ENABLE_NO_ARGS_SHIFT 10
22
16typedef enum { 23typedef enum {
17 KDB_REPEAT_NONE = 0, /* Do not repeat this command */ 24 KDB_ENABLE_ALL = (1 << 0), /* Enable everything */
18 KDB_REPEAT_NO_ARGS, /* Repeat the command without arguments */ 25 KDB_ENABLE_MEM_READ = (1 << 1),
19 KDB_REPEAT_WITH_ARGS, /* Repeat the command including its arguments */ 26 KDB_ENABLE_MEM_WRITE = (1 << 2),
20} kdb_repeat_t; 27 KDB_ENABLE_REG_READ = (1 << 3),
28 KDB_ENABLE_REG_WRITE = (1 << 4),
29 KDB_ENABLE_INSPECT = (1 << 5),
30 KDB_ENABLE_FLOW_CTRL = (1 << 6),
31 KDB_ENABLE_SIGNAL = (1 << 7),
32 KDB_ENABLE_REBOOT = (1 << 8),
33 /* User exposed values stop here, all remaining flags are
34 * exclusively used to describe a commands behaviour.
35 */
36
37 KDB_ENABLE_ALWAYS_SAFE = (1 << 9),
38 KDB_ENABLE_MASK = (1 << KDB_ENABLE_NO_ARGS_SHIFT) - 1,
39
40 KDB_ENABLE_ALL_NO_ARGS = KDB_ENABLE_ALL << KDB_ENABLE_NO_ARGS_SHIFT,
41 KDB_ENABLE_MEM_READ_NO_ARGS = KDB_ENABLE_MEM_READ
42 << KDB_ENABLE_NO_ARGS_SHIFT,
43 KDB_ENABLE_MEM_WRITE_NO_ARGS = KDB_ENABLE_MEM_WRITE
44 << KDB_ENABLE_NO_ARGS_SHIFT,
45 KDB_ENABLE_REG_READ_NO_ARGS = KDB_ENABLE_REG_READ
46 << KDB_ENABLE_NO_ARGS_SHIFT,
47 KDB_ENABLE_REG_WRITE_NO_ARGS = KDB_ENABLE_REG_WRITE
48 << KDB_ENABLE_NO_ARGS_SHIFT,
49 KDB_ENABLE_INSPECT_NO_ARGS = KDB_ENABLE_INSPECT
50 << KDB_ENABLE_NO_ARGS_SHIFT,
51 KDB_ENABLE_FLOW_CTRL_NO_ARGS = KDB_ENABLE_FLOW_CTRL
52 << KDB_ENABLE_NO_ARGS_SHIFT,
53 KDB_ENABLE_SIGNAL_NO_ARGS = KDB_ENABLE_SIGNAL
54 << KDB_ENABLE_NO_ARGS_SHIFT,
55 KDB_ENABLE_REBOOT_NO_ARGS = KDB_ENABLE_REBOOT
56 << KDB_ENABLE_NO_ARGS_SHIFT,
57 KDB_ENABLE_ALWAYS_SAFE_NO_ARGS = KDB_ENABLE_ALWAYS_SAFE
58 << KDB_ENABLE_NO_ARGS_SHIFT,
59 KDB_ENABLE_MASK_NO_ARGS = KDB_ENABLE_MASK << KDB_ENABLE_NO_ARGS_SHIFT,
60
61 KDB_REPEAT_NO_ARGS = 0x40000000, /* Repeat the command w/o arguments */
62 KDB_REPEAT_WITH_ARGS = 0x80000000, /* Repeat the command with args */
63} kdb_cmdflags_t;
21 64
22typedef int (*kdb_func_t)(int, const char **); 65typedef int (*kdb_func_t)(int, const char **);
23 66
@@ -62,6 +105,7 @@ extern atomic_t kdb_event;
62#define KDB_BADLENGTH (-19) 105#define KDB_BADLENGTH (-19)
63#define KDB_NOBP (-20) 106#define KDB_NOBP (-20)
64#define KDB_BADADDR (-21) 107#define KDB_BADADDR (-21)
108#define KDB_NOPERM (-22)
65 109
66/* 110/*
67 * kdb_diemsg 111 * kdb_diemsg
@@ -146,17 +190,17 @@ static inline const char *kdb_walk_kallsyms(loff_t *pos)
146 190
147/* Dynamic kdb shell command registration */ 191/* Dynamic kdb shell command registration */
148extern int kdb_register(char *, kdb_func_t, char *, char *, short); 192extern int kdb_register(char *, kdb_func_t, char *, char *, short);
149extern int kdb_register_repeat(char *, kdb_func_t, char *, char *, 193extern int kdb_register_flags(char *, kdb_func_t, char *, char *,
150 short, kdb_repeat_t); 194 short, kdb_cmdflags_t);
151extern int kdb_unregister(char *); 195extern int kdb_unregister(char *);
152#else /* ! CONFIG_KGDB_KDB */ 196#else /* ! CONFIG_KGDB_KDB */
153static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; } 197static inline __printf(1, 2) int kdb_printf(const char *fmt, ...) { return 0; }
154static inline void kdb_init(int level) {} 198static inline void kdb_init(int level) {}
155static inline int kdb_register(char *cmd, kdb_func_t func, char *usage, 199static inline int kdb_register(char *cmd, kdb_func_t func, char *usage,
156 char *help, short minlen) { return 0; } 200 char *help, short minlen) { return 0; }
157static inline int kdb_register_repeat(char *cmd, kdb_func_t func, char *usage, 201static inline int kdb_register_flags(char *cmd, kdb_func_t func, char *usage,
158 char *help, short minlen, 202 char *help, short minlen,
159 kdb_repeat_t repeat) { return 0; } 203 kdb_cmdflags_t flags) { return 0; }
160static inline int kdb_unregister(char *cmd) { return 0; } 204static inline int kdb_unregister(char *cmd) { return 0; }
161#endif /* CONFIG_KGDB_KDB */ 205#endif /* CONFIG_KGDB_KDB */
162enum { 206enum {
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 575a86c7fcbd..f742b6717d52 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -50,6 +50,8 @@ enum {
50 STMPE_IDX_GPEDR_MSB, 50 STMPE_IDX_GPEDR_MSB,
51 STMPE_IDX_GPRER_LSB, 51 STMPE_IDX_GPRER_LSB,
52 STMPE_IDX_GPFER_LSB, 52 STMPE_IDX_GPFER_LSB,
53 STMPE_IDX_GPPUR_LSB,
54 STMPE_IDX_GPPDR_LSB,
53 STMPE_IDX_GPAFR_U_MSB, 55 STMPE_IDX_GPAFR_U_MSB,
54 STMPE_IDX_IEGPIOR_LSB, 56 STMPE_IDX_IEGPIOR_LSB,
55 STMPE_IDX_ISGPIOR_LSB, 57 STMPE_IDX_ISGPIOR_LSB,
@@ -113,24 +115,6 @@ extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
113extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks); 115extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
114extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks); 116extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
115 117
116struct matrix_keymap_data;
117
118/**
119 * struct stmpe_keypad_platform_data - STMPE keypad platform data
120 * @keymap_data: key map table and size
121 * @debounce_ms: debounce interval, in ms. Maximum is
122 * %STMPE_KEYPAD_MAX_DEBOUNCE.
123 * @scan_count: number of key scanning cycles to confirm key data.
124 * Maximum is %STMPE_KEYPAD_MAX_SCAN_COUNT.
125 * @no_autorepeat: disable key autorepeat
126 */
127struct stmpe_keypad_platform_data {
128 const struct matrix_keymap_data *keymap_data;
129 unsigned int debounce_ms;
130 unsigned int scan_count;
131 bool no_autorepeat;
132};
133
134#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0) 118#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
135 119
136/** 120/**
@@ -199,7 +183,6 @@ struct stmpe_ts_platform_data {
199 * @irq_gpio: gpio number over which irq will be requested (significant only if 183 * @irq_gpio: gpio number over which irq will be requested (significant only if
200 * irq_over_gpio is true) 184 * irq_over_gpio is true)
201 * @gpio: GPIO-specific platform data 185 * @gpio: GPIO-specific platform data
202 * @keypad: keypad-specific platform data
203 * @ts: touchscreen-specific platform data 186 * @ts: touchscreen-specific platform data
204 */ 187 */
205struct stmpe_platform_data { 188struct stmpe_platform_data {
@@ -212,7 +195,6 @@ struct stmpe_platform_data {
212 int autosleep_timeout; 195 int autosleep_timeout;
213 196
214 struct stmpe_gpio_platform_data *gpio; 197 struct stmpe_gpio_platform_data *gpio;
215 struct stmpe_keypad_platform_data *keypad;
216 struct stmpe_ts_platform_data *ts; 198 struct stmpe_ts_platform_data *ts;
217}; 199};
218 200
diff --git a/include/linux/mm.h b/include/linux/mm.h
index f80d0194c9bc..80fc92a49649 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1952,7 +1952,7 @@ extern int expand_downwards(struct vm_area_struct *vma,
1952#if VM_GROWSUP 1952#if VM_GROWSUP
1953extern int expand_upwards(struct vm_area_struct *vma, unsigned long address); 1953extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
1954#else 1954#else
1955 #define expand_upwards(vma, address) do { } while (0) 1955 #define expand_upwards(vma, address) (0)
1956#endif 1956#endif
1957 1957
1958/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ 1958/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index c31f74d76ebd..679e6e90aa4c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1012,12 +1012,15 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
1012 * Callback to use for xmit over the accelerated station. This 1012 * Callback to use for xmit over the accelerated station. This
1013 * is used in place of ndo_start_xmit on accelerated net 1013 * is used in place of ndo_start_xmit on accelerated net
1014 * devices. 1014 * devices.
1015 * bool (*ndo_gso_check) (struct sk_buff *skb, 1015 * netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
1016 * struct net_device *dev); 1016 * struct net_device *dev
1017 * netdev_features_t features);
1017 * Called by core transmit path to determine if device is capable of 1018 * Called by core transmit path to determine if device is capable of
1018 * performing GSO on a packet. The device returns true if it is 1019 * performing offload operations on a given packet. This is to give
1019 * able to GSO the packet, false otherwise. If the return value is 1020 * the device an opportunity to implement any restrictions that cannot
1020 * false the stack will do software GSO. 1021 * be otherwise expressed by feature flags. The check is called with
1022 * the set of features that the stack has calculated and it returns
1023 * those the driver believes to be appropriate.
1021 * 1024 *
1022 * int (*ndo_switch_parent_id_get)(struct net_device *dev, 1025 * int (*ndo_switch_parent_id_get)(struct net_device *dev,
1023 * struct netdev_phys_item_id *psid); 1026 * struct netdev_phys_item_id *psid);
@@ -1178,8 +1181,9 @@ struct net_device_ops {
1178 struct net_device *dev, 1181 struct net_device *dev,
1179 void *priv); 1182 void *priv);
1180 int (*ndo_get_lock_subclass)(struct net_device *dev); 1183 int (*ndo_get_lock_subclass)(struct net_device *dev);
1181 bool (*ndo_gso_check) (struct sk_buff *skb, 1184 netdev_features_t (*ndo_features_check) (struct sk_buff *skb,
1182 struct net_device *dev); 1185 struct net_device *dev,
1186 netdev_features_t features);
1183#ifdef CONFIG_NET_SWITCHDEV 1187#ifdef CONFIG_NET_SWITCHDEV
1184 int (*ndo_switch_parent_id_get)(struct net_device *dev, 1188 int (*ndo_switch_parent_id_get)(struct net_device *dev,
1185 struct netdev_phys_item_id *psid); 1189 struct netdev_phys_item_id *psid);
@@ -3611,8 +3615,6 @@ static inline bool netif_needs_gso(struct net_device *dev, struct sk_buff *skb,
3611 netdev_features_t features) 3615 netdev_features_t features)
3612{ 3616{
3613 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || 3617 return skb_is_gso(skb) && (!skb_gso_ok(skb, features) ||
3614 (dev->netdev_ops->ndo_gso_check &&
3615 !dev->netdev_ops->ndo_gso_check(skb, dev)) ||
3616 unlikely((skb->ip_summed != CHECKSUM_PARTIAL) && 3618 unlikely((skb->ip_summed != CHECKSUM_PARTIAL) &&
3617 (skb->ip_summed != CHECKSUM_UNNECESSARY))); 3619 (skb->ip_summed != CHECKSUM_UNNECESSARY)));
3618} 3620}
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 9e572daa15d5..02fc86d2348e 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -46,8 +46,8 @@ struct netlink_kernel_cfg {
46 unsigned int flags; 46 unsigned int flags;
47 void (*input)(struct sk_buff *skb); 47 void (*input)(struct sk_buff *skb);
48 struct mutex *cb_mutex; 48 struct mutex *cb_mutex;
49 int (*bind)(int group); 49 int (*bind)(struct net *net, int group);
50 void (*unbind)(int group); 50 void (*unbind)(struct net *net, int group);
51 bool (*compare)(struct net *net, struct sock *sk); 51 bool (*compare)(struct net *net, struct sock *sk);
52}; 52};
53 53
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 7ea069cd3257..4b3736f7065c 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -251,7 +251,7 @@ pgoff_t page_cache_prev_hole(struct address_space *mapping,
251#define FGP_NOWAIT 0x00000020 251#define FGP_NOWAIT 0x00000020
252 252
253struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, 253struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
254 int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask); 254 int fgp_flags, gfp_t cache_gfp_mask);
255 255
256/** 256/**
257 * find_get_page - find and get a page reference 257 * find_get_page - find and get a page reference
@@ -266,13 +266,13 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
266static inline struct page *find_get_page(struct address_space *mapping, 266static inline struct page *find_get_page(struct address_space *mapping,
267 pgoff_t offset) 267 pgoff_t offset)
268{ 268{
269 return pagecache_get_page(mapping, offset, 0, 0, 0); 269 return pagecache_get_page(mapping, offset, 0, 0);
270} 270}
271 271
272static inline struct page *find_get_page_flags(struct address_space *mapping, 272static inline struct page *find_get_page_flags(struct address_space *mapping,
273 pgoff_t offset, int fgp_flags) 273 pgoff_t offset, int fgp_flags)
274{ 274{
275 return pagecache_get_page(mapping, offset, fgp_flags, 0, 0); 275 return pagecache_get_page(mapping, offset, fgp_flags, 0);
276} 276}
277 277
278/** 278/**
@@ -292,7 +292,7 @@ static inline struct page *find_get_page_flags(struct address_space *mapping,
292static inline struct page *find_lock_page(struct address_space *mapping, 292static inline struct page *find_lock_page(struct address_space *mapping,
293 pgoff_t offset) 293 pgoff_t offset)
294{ 294{
295 return pagecache_get_page(mapping, offset, FGP_LOCK, 0, 0); 295 return pagecache_get_page(mapping, offset, FGP_LOCK, 0);
296} 296}
297 297
298/** 298/**
@@ -319,7 +319,7 @@ static inline struct page *find_or_create_page(struct address_space *mapping,
319{ 319{
320 return pagecache_get_page(mapping, offset, 320 return pagecache_get_page(mapping, offset,
321 FGP_LOCK|FGP_ACCESSED|FGP_CREAT, 321 FGP_LOCK|FGP_ACCESSED|FGP_CREAT,
322 gfp_mask, gfp_mask & GFP_RECLAIM_MASK); 322 gfp_mask);
323} 323}
324 324
325/** 325/**
@@ -340,8 +340,7 @@ static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
340{ 340{
341 return pagecache_get_page(mapping, index, 341 return pagecache_get_page(mapping, index,
342 FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT, 342 FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
343 mapping_gfp_mask(mapping), 343 mapping_gfp_mask(mapping));
344 GFP_NOFS);
345} 344}
346 345
347struct page *find_get_entry(struct address_space *mapping, pgoff_t offset); 346struct page *find_get_entry(struct address_space *mapping, pgoff_t offset);
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 486e84ccb1f9..4f7a61ca4b39 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -79,11 +79,6 @@ struct perf_branch_stack {
79 struct perf_branch_entry entries[0]; 79 struct perf_branch_entry entries[0];
80}; 80};
81 81
82struct perf_regs {
83 __u64 abi;
84 struct pt_regs *regs;
85};
86
87struct task_struct; 82struct task_struct;
88 83
89/* 84/*
@@ -610,7 +605,14 @@ struct perf_sample_data {
610 u32 reserved; 605 u32 reserved;
611 } cpu_entry; 606 } cpu_entry;
612 struct perf_callchain_entry *callchain; 607 struct perf_callchain_entry *callchain;
608
609 /*
610 * regs_user may point to task_pt_regs or to regs_user_copy, depending
611 * on arch details.
612 */
613 struct perf_regs regs_user; 613 struct perf_regs regs_user;
614 struct pt_regs regs_user_copy;
615
614 struct perf_regs regs_intr; 616 struct perf_regs regs_intr;
615 u64 stack_user_size; 617 u64 stack_user_size;
616} ____cacheline_aligned; 618} ____cacheline_aligned;
diff --git a/include/linux/perf_regs.h b/include/linux/perf_regs.h
index 3c73d5fe18be..a5f98d53d732 100644
--- a/include/linux/perf_regs.h
+++ b/include/linux/perf_regs.h
@@ -1,11 +1,19 @@
1#ifndef _LINUX_PERF_REGS_H 1#ifndef _LINUX_PERF_REGS_H
2#define _LINUX_PERF_REGS_H 2#define _LINUX_PERF_REGS_H
3 3
4struct perf_regs {
5 __u64 abi;
6 struct pt_regs *regs;
7};
8
4#ifdef CONFIG_HAVE_PERF_REGS 9#ifdef CONFIG_HAVE_PERF_REGS
5#include <asm/perf_regs.h> 10#include <asm/perf_regs.h>
6u64 perf_reg_value(struct pt_regs *regs, int idx); 11u64 perf_reg_value(struct pt_regs *regs, int idx);
7int perf_reg_validate(u64 mask); 12int perf_reg_validate(u64 mask);
8u64 perf_reg_abi(struct task_struct *task); 13u64 perf_reg_abi(struct task_struct *task);
14void perf_get_regs_user(struct perf_regs *regs_user,
15 struct pt_regs *regs,
16 struct pt_regs *regs_user_copy);
9#else 17#else
10static inline u64 perf_reg_value(struct pt_regs *regs, int idx) 18static inline u64 perf_reg_value(struct pt_regs *regs, int idx)
11{ 19{
@@ -21,5 +29,13 @@ static inline u64 perf_reg_abi(struct task_struct *task)
21{ 29{
22 return PERF_SAMPLE_REGS_ABI_NONE; 30 return PERF_SAMPLE_REGS_ABI_NONE;
23} 31}
32
33static inline void perf_get_regs_user(struct perf_regs *regs_user,
34 struct pt_regs *regs,
35 struct pt_regs *regs_user_copy)
36{
37 regs_user->regs = task_pt_regs(current);
38 regs_user->abi = perf_reg_abi(current);
39}
24#endif /* CONFIG_HAVE_PERF_REGS */ 40#endif /* CONFIG_HAVE_PERF_REGS */
25#endif /* _LINUX_PERF_REGS_H */ 41#endif /* _LINUX_PERF_REGS_H */
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 6cd20d5e651b..a9edab2c787a 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -271,6 +271,8 @@ typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
271int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, 271int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
272 void *data); 272 void *data);
273void of_genpd_del_provider(struct device_node *np); 273void of_genpd_del_provider(struct device_node *np);
274struct generic_pm_domain *of_genpd_get_from_provider(
275 struct of_phandle_args *genpdspec);
274 276
275struct generic_pm_domain *__of_genpd_xlate_simple( 277struct generic_pm_domain *__of_genpd_xlate_simple(
276 struct of_phandle_args *genpdspec, 278 struct of_phandle_args *genpdspec,
@@ -288,6 +290,12 @@ static inline int __of_genpd_add_provider(struct device_node *np,
288} 290}
289static inline void of_genpd_del_provider(struct device_node *np) {} 291static inline void of_genpd_del_provider(struct device_node *np) {}
290 292
293static inline struct generic_pm_domain *of_genpd_get_from_provider(
294 struct of_phandle_args *genpdspec)
295{
296 return NULL;
297}
298
291#define __of_genpd_xlate_simple NULL 299#define __of_genpd_xlate_simple NULL
292#define __of_genpd_xlate_onecell NULL 300#define __of_genpd_xlate_onecell NULL
293 301
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index c0c2bce6b0b7..d9d7e7e56352 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -37,6 +37,16 @@ struct anon_vma {
37 atomic_t refcount; 37 atomic_t refcount;
38 38
39 /* 39 /*
40 * Count of child anon_vmas and VMAs which points to this anon_vma.
41 *
42 * This counter is used for making decision about reusing anon_vma
43 * instead of forking new one. See comments in function anon_vma_clone.
44 */
45 unsigned degree;
46
47 struct anon_vma *parent; /* Parent of this anon_vma */
48
49 /*
40 * NOTE: the LSB of the rb_root.rb_node is set by 50 * NOTE: the LSB of the rb_root.rb_node is set by
41 * mm_take_all_locks() _after_ taking the above lock. So the 51 * mm_take_all_locks() _after_ taking the above lock. So the
42 * rb_root must only be read/written after taking the above lock 52 * rb_root must only be read/written after taking the above lock
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index c611a02fbc51..fc52e307efab 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -38,7 +38,7 @@
38#define THERMAL_CSTATE_INVALID -1UL 38#define THERMAL_CSTATE_INVALID -1UL
39 39
40/* No upper/lower limit requirement */ 40/* No upper/lower limit requirement */
41#define THERMAL_NO_LIMIT THERMAL_CSTATE_INVALID 41#define THERMAL_NO_LIMIT ((u32)~0)
42 42
43/* Unit conversion macros */ 43/* Unit conversion macros */
44#define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \ 44#define KELVIN_TO_CELSIUS(t) (long)(((long)t-2732 >= 0) ? \
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index a219be961c0a..00048339c23e 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -177,7 +177,6 @@ int write_cache_pages(struct address_space *mapping,
177 struct writeback_control *wbc, writepage_t writepage, 177 struct writeback_control *wbc, writepage_t writepage,
178 void *data); 178 void *data);
179int do_writepages(struct address_space *mapping, struct writeback_control *wbc); 179int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
180void set_page_dirty_balance(struct page *page);
181void writeback_set_ratelimit(void); 180void writeback_set_ratelimit(void);
182void tag_pages_for_writeback(struct address_space *mapping, 181void tag_pages_for_writeback(struct address_space *mapping,
183 pgoff_t start, pgoff_t end); 182 pgoff_t start, pgoff_t end);
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index af10c2cf8a1d..84125088c309 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -31,6 +31,9 @@ struct genl_info;
31 * do additional, common, filtering and return an error 31 * do additional, common, filtering and return an error
32 * @post_doit: called after an operation's doit callback, it may 32 * @post_doit: called after an operation's doit callback, it may
33 * undo operations done by pre_doit, for example release locks 33 * undo operations done by pre_doit, for example release locks
34 * @mcast_bind: a socket bound to the given multicast group (which
35 * is given as the offset into the groups array)
36 * @mcast_unbind: a socket was unbound from the given multicast group
34 * @attrbuf: buffer to store parsed attributes 37 * @attrbuf: buffer to store parsed attributes
35 * @family_list: family list 38 * @family_list: family list
36 * @mcgrps: multicast groups used by this family (private) 39 * @mcgrps: multicast groups used by this family (private)
@@ -53,6 +56,8 @@ struct genl_family {
53 void (*post_doit)(const struct genl_ops *ops, 56 void (*post_doit)(const struct genl_ops *ops,
54 struct sk_buff *skb, 57 struct sk_buff *skb,
55 struct genl_info *info); 58 struct genl_info *info);
59 int (*mcast_bind)(struct net *net, int group);
60 void (*mcast_unbind)(struct net *net, int group);
56 struct nlattr ** attrbuf; /* private */ 61 struct nlattr ** attrbuf; /* private */
57 const struct genl_ops * ops; /* private */ 62 const struct genl_ops * ops; /* private */
58 const struct genl_multicast_group *mcgrps; /* private */ 63 const struct genl_multicast_group *mcgrps; /* private */
@@ -395,11 +400,11 @@ static inline int genl_set_err(struct genl_family *family, struct net *net,
395} 400}
396 401
397static inline int genl_has_listeners(struct genl_family *family, 402static inline int genl_has_listeners(struct genl_family *family,
398 struct sock *sk, unsigned int group) 403 struct net *net, unsigned int group)
399{ 404{
400 if (WARN_ON_ONCE(group >= family->n_mcgrps)) 405 if (WARN_ON_ONCE(group >= family->n_mcgrps))
401 return -EINVAL; 406 return -EINVAL;
402 group = family->mcgrp_offset + group; 407 group = family->mcgrp_offset + group;
403 return netlink_has_listeners(sk, group); 408 return netlink_has_listeners(net->genl_sock, group);
404} 409}
405#endif /* __NET_GENERIC_NETLINK_H */ 410#endif /* __NET_GENERIC_NETLINK_H */
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 58d719ddaa60..29c7be8808d5 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1270,8 +1270,7 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1270 * 1270 *
1271 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the 1271 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
1272 * driver to indicate that it requires IV generation for this 1272 * driver to indicate that it requires IV generation for this
1273 * particular key. Setting this flag does not necessarily mean that SKBs 1273 * particular key.
1274 * will have sufficient tailroom for ICV or MIC.
1275 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by 1274 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
1276 * the driver for a TKIP key if it requires Michael MIC 1275 * the driver for a TKIP key if it requires Michael MIC
1277 * generation in software. 1276 * generation in software.
@@ -1283,9 +1282,7 @@ struct ieee80211_vif *wdev_to_ieee80211_vif(struct wireless_dev *wdev);
1283 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver 1282 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
1284 * if space should be prepared for the IV, but the IV 1283 * if space should be prepared for the IV, but the IV
1285 * itself should not be generated. Do not set together with 1284 * itself should not be generated. Do not set together with
1286 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. Setting this flag does 1285 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key.
1287 * not necessarily mean that SKBs will have sufficient tailroom for ICV or
1288 * MIC.
1289 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received 1286 * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received
1290 * management frames. The flag can help drivers that have a hardware 1287 * management frames. The flag can help drivers that have a hardware
1291 * crypto implementation that doesn't deal with management frames 1288 * crypto implementation that doesn't deal with management frames
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index eb070b3674a1..76f708486aae 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -190,7 +190,6 @@ struct neigh_hash_table {
190 190
191 191
192struct neigh_table { 192struct neigh_table {
193 struct neigh_table *next;
194 int family; 193 int family;
195 int entry_size; 194 int entry_size;
196 int key_len; 195 int key_len;
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 57cccd0052e5..903461aa5644 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -1,6 +1,9 @@
1#ifndef __NET_VXLAN_H 1#ifndef __NET_VXLAN_H
2#define __NET_VXLAN_H 1 2#define __NET_VXLAN_H 1
3 3
4#include <linux/ip.h>
5#include <linux/ipv6.h>
6#include <linux/if_vlan.h>
4#include <linux/skbuff.h> 7#include <linux/skbuff.h>
5#include <linux/netdevice.h> 8#include <linux/netdevice.h>
6#include <linux/udp.h> 9#include <linux/udp.h>
@@ -51,16 +54,33 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
51 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, 54 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
52 __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); 55 __be16 src_port, __be16 dst_port, __be32 vni, bool xnet);
53 56
54static inline bool vxlan_gso_check(struct sk_buff *skb) 57static inline netdev_features_t vxlan_features_check(struct sk_buff *skb,
58 netdev_features_t features)
55{ 59{
56 if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) && 60 u8 l4_hdr = 0;
61
62 if (!skb->encapsulation)
63 return features;
64
65 switch (vlan_get_protocol(skb)) {
66 case htons(ETH_P_IP):
67 l4_hdr = ip_hdr(skb)->protocol;
68 break;
69 case htons(ETH_P_IPV6):
70 l4_hdr = ipv6_hdr(skb)->nexthdr;
71 break;
72 default:
73 return features;;
74 }
75
76 if ((l4_hdr == IPPROTO_UDP) &&
57 (skb->inner_protocol_type != ENCAP_TYPE_ETHER || 77 (skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
58 skb->inner_protocol != htons(ETH_P_TEB) || 78 skb->inner_protocol != htons(ETH_P_TEB) ||
59 (skb_inner_mac_header(skb) - skb_transport_header(skb) != 79 (skb_inner_mac_header(skb) - skb_transport_header(skb) !=
60 sizeof(struct udphdr) + sizeof(struct vxlanhdr)))) 80 sizeof(struct udphdr) + sizeof(struct vxlanhdr))))
61 return false; 81 return features & ~(NETIF_F_ALL_CSUM | NETIF_F_GSO_MASK);
62 82
63 return true; 83 return features;
64} 84}
65 85
66/* IP header + UDP + VXLAN + Ethernet header */ 86/* IP header + UDP + VXLAN + Ethernet header */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 1e7f74acc2ec..b429b73e875e 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -857,7 +857,7 @@ static inline unsigned int params_channels(const struct snd_pcm_hw_params *p)
857} 857}
858 858
859/** 859/**
860 * params_channels - Get the sample rate from the hw params 860 * params_rate - Get the sample rate from the hw params
861 * @p: hw params 861 * @p: hw params
862 */ 862 */
863static inline unsigned int params_rate(const struct snd_pcm_hw_params *p) 863static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
@@ -866,7 +866,7 @@ static inline unsigned int params_rate(const struct snd_pcm_hw_params *p)
866} 866}
867 867
868/** 868/**
869 * params_channels - Get the period size (in frames) from the hw params 869 * params_period_size - Get the period size (in frames) from the hw params
870 * @p: hw params 870 * @p: hw params
871 */ 871 */
872static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p) 872static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
@@ -875,7 +875,7 @@ static inline unsigned int params_period_size(const struct snd_pcm_hw_params *p)
875} 875}
876 876
877/** 877/**
878 * params_channels - Get the number of periods from the hw params 878 * params_periods - Get the number of periods from the hw params
879 * @p: hw params 879 * @p: hw params
880 */ 880 */
881static inline unsigned int params_periods(const struct snd_pcm_hw_params *p) 881static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
@@ -884,7 +884,7 @@ static inline unsigned int params_periods(const struct snd_pcm_hw_params *p)
884} 884}
885 885
886/** 886/**
887 * params_channels - Get the buffer size (in frames) from the hw params 887 * params_buffer_size - Get the buffer size (in frames) from the hw params
888 * @p: hw params 888 * @p: hw params
889 */ 889 */
890static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p) 890static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
@@ -893,7 +893,7 @@ static inline unsigned int params_buffer_size(const struct snd_pcm_hw_params *p)
893} 893}
894 894
895/** 895/**
896 * params_channels - Get the buffer size (in bytes) from the hw params 896 * params_buffer_bytes - Get the buffer size (in bytes) from the hw params
897 * @p: hw params 897 * @p: hw params
898 */ 898 */
899static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p) 899static inline unsigned int params_buffer_bytes(const struct snd_pcm_hw_params *p)
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index 7543b3e51331..e063effe0cc1 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -5,7 +5,7 @@
5 5
6/* 6/*
7 * FMODE_EXEC is 0x20 7 * FMODE_EXEC is 0x20
8 * FMODE_NONOTIFY is 0x1000000 8 * FMODE_NONOTIFY is 0x4000000
9 * These cannot be used by userspace O_* until internal and external open 9 * These cannot be used by userspace O_* until internal and external open
10 * flags are split. 10 * flags are split.
11 * -Eric Paris 11 * -Eric Paris
diff --git a/include/uapi/linux/in6.h b/include/uapi/linux/in6.h
index 74a2a1773494..79b12b004ade 100644
--- a/include/uapi/linux/in6.h
+++ b/include/uapi/linux/in6.h
@@ -149,7 +149,7 @@ struct in6_flowlabel_req {
149/* 149/*
150 * IPV6 socket options 150 * IPV6 socket options
151 */ 151 */
152 152#if __UAPI_DEF_IPV6_OPTIONS
153#define IPV6_ADDRFORM 1 153#define IPV6_ADDRFORM 1
154#define IPV6_2292PKTINFO 2 154#define IPV6_2292PKTINFO 2
155#define IPV6_2292HOPOPTS 3 155#define IPV6_2292HOPOPTS 3
@@ -196,6 +196,7 @@ struct in6_flowlabel_req {
196 196
197#define IPV6_IPSEC_POLICY 34 197#define IPV6_IPSEC_POLICY 34
198#define IPV6_XFRM_POLICY 35 198#define IPV6_XFRM_POLICY 35
199#endif
199 200
200/* 201/*
201 * Multicast: 202 * Multicast:
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 7acef41fc209..af94f31e33ac 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -128,27 +128,34 @@ struct kfd_ioctl_get_process_apertures_args {
128 uint32_t pad; 128 uint32_t pad;
129}; 129};
130 130
131#define KFD_IOC_MAGIC 'K' 131#define AMDKFD_IOCTL_BASE 'K'
132#define AMDKFD_IO(nr) _IO(AMDKFD_IOCTL_BASE, nr)
133#define AMDKFD_IOR(nr, type) _IOR(AMDKFD_IOCTL_BASE, nr, type)
134#define AMDKFD_IOW(nr, type) _IOW(AMDKFD_IOCTL_BASE, nr, type)
135#define AMDKFD_IOWR(nr, type) _IOWR(AMDKFD_IOCTL_BASE, nr, type)
132 136
133#define KFD_IOC_GET_VERSION \ 137#define AMDKFD_IOC_GET_VERSION \
134 _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args) 138 AMDKFD_IOR(0x01, struct kfd_ioctl_get_version_args)
135 139
136#define KFD_IOC_CREATE_QUEUE \ 140#define AMDKFD_IOC_CREATE_QUEUE \
137 _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args) 141 AMDKFD_IOWR(0x02, struct kfd_ioctl_create_queue_args)
138 142
139#define KFD_IOC_DESTROY_QUEUE \ 143#define AMDKFD_IOC_DESTROY_QUEUE \
140 _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args) 144 AMDKFD_IOWR(0x03, struct kfd_ioctl_destroy_queue_args)
141 145
142#define KFD_IOC_SET_MEMORY_POLICY \ 146#define AMDKFD_IOC_SET_MEMORY_POLICY \
143 _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args) 147 AMDKFD_IOW(0x04, struct kfd_ioctl_set_memory_policy_args)
144 148
145#define KFD_IOC_GET_CLOCK_COUNTERS \ 149#define AMDKFD_IOC_GET_CLOCK_COUNTERS \
146 _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args) 150 AMDKFD_IOWR(0x05, struct kfd_ioctl_get_clock_counters_args)
147 151
148#define KFD_IOC_GET_PROCESS_APERTURES \ 152#define AMDKFD_IOC_GET_PROCESS_APERTURES \
149 _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args) 153 AMDKFD_IOR(0x06, struct kfd_ioctl_get_process_apertures_args)
150 154
151#define KFD_IOC_UPDATE_QUEUE \ 155#define AMDKFD_IOC_UPDATE_QUEUE \
152 _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args) 156 AMDKFD_IOW(0x07, struct kfd_ioctl_update_queue_args)
157
158#define AMDKFD_COMMAND_START 0x01
159#define AMDKFD_COMMAND_END 0x08
153 160
154#endif 161#endif
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index c140620dad92..e28807ad17fa 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -69,6 +69,7 @@
69#define __UAPI_DEF_SOCKADDR_IN6 0 69#define __UAPI_DEF_SOCKADDR_IN6 0
70#define __UAPI_DEF_IPV6_MREQ 0 70#define __UAPI_DEF_IPV6_MREQ 0
71#define __UAPI_DEF_IPPROTO_V6 0 71#define __UAPI_DEF_IPPROTO_V6 0
72#define __UAPI_DEF_IPV6_OPTIONS 0
72 73
73#else 74#else
74 75
@@ -82,6 +83,7 @@
82#define __UAPI_DEF_SOCKADDR_IN6 1 83#define __UAPI_DEF_SOCKADDR_IN6 1
83#define __UAPI_DEF_IPV6_MREQ 1 84#define __UAPI_DEF_IPV6_MREQ 1
84#define __UAPI_DEF_IPPROTO_V6 1 85#define __UAPI_DEF_IPPROTO_V6 1
86#define __UAPI_DEF_IPV6_OPTIONS 1
85 87
86#endif /* _NETINET_IN_H */ 88#endif /* _NETINET_IN_H */
87 89
@@ -103,6 +105,7 @@
103#define __UAPI_DEF_SOCKADDR_IN6 1 105#define __UAPI_DEF_SOCKADDR_IN6 1
104#define __UAPI_DEF_IPV6_MREQ 1 106#define __UAPI_DEF_IPV6_MREQ 1
105#define __UAPI_DEF_IPPROTO_V6 1 107#define __UAPI_DEF_IPPROTO_V6 1
108#define __UAPI_DEF_IPV6_OPTIONS 1
106 109
107/* Definitions for xattr.h */ 110/* Definitions for xattr.h */
108#define __UAPI_DEF_XATTR 1 111#define __UAPI_DEF_XATTR 1
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index 61c818a7fe70..a3318f31e8e7 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -101,6 +101,13 @@ struct vring {
101 struct vring_used *used; 101 struct vring_used *used;
102}; 102};
103 103
104/* Alignment requirements for vring elements.
105 * When using pre-virtio 1.0 layout, these fall out naturally.
106 */
107#define VRING_AVAIL_ALIGN_SIZE 2
108#define VRING_USED_ALIGN_SIZE 4
109#define VRING_DESC_ALIGN_SIZE 16
110
104/* The standard layout for the ring is a continuous chunk of memory which looks 111/* The standard layout for the ring is a continuous chunk of memory which looks
105 * like this. We assume num is a power of 2. 112 * like this. We assume num is a power of 2.
106 * 113 *
diff --git a/kernel/audit.c b/kernel/audit.c
index f8f203e8018c..72ab759a0b43 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -429,7 +429,7 @@ static void kauditd_send_skb(struct sk_buff *skb)
429 * This function doesn't consume an skb as might be expected since it has to 429 * This function doesn't consume an skb as might be expected since it has to
430 * copy it anyways. 430 * copy it anyways.
431 */ 431 */
432static void kauditd_send_multicast_skb(struct sk_buff *skb) 432static void kauditd_send_multicast_skb(struct sk_buff *skb, gfp_t gfp_mask)
433{ 433{
434 struct sk_buff *copy; 434 struct sk_buff *copy;
435 struct audit_net *aunet = net_generic(&init_net, audit_net_id); 435 struct audit_net *aunet = net_generic(&init_net, audit_net_id);
@@ -448,11 +448,11 @@ static void kauditd_send_multicast_skb(struct sk_buff *skb)
448 * no reason for new multicast clients to continue with this 448 * no reason for new multicast clients to continue with this
449 * non-compliance. 449 * non-compliance.
450 */ 450 */
451 copy = skb_copy(skb, GFP_KERNEL); 451 copy = skb_copy(skb, gfp_mask);
452 if (!copy) 452 if (!copy)
453 return; 453 return;
454 454
455 nlmsg_multicast(sock, copy, 0, AUDIT_NLGRP_READLOG, GFP_KERNEL); 455 nlmsg_multicast(sock, copy, 0, AUDIT_NLGRP_READLOG, gfp_mask);
456} 456}
457 457
458/* 458/*
@@ -1100,7 +1100,7 @@ static void audit_receive(struct sk_buff *skb)
1100} 1100}
1101 1101
1102/* Run custom bind function on netlink socket group connect or bind requests. */ 1102/* Run custom bind function on netlink socket group connect or bind requests. */
1103static int audit_bind(int group) 1103static int audit_bind(struct net *net, int group)
1104{ 1104{
1105 if (!capable(CAP_AUDIT_READ)) 1105 if (!capable(CAP_AUDIT_READ))
1106 return -EPERM; 1106 return -EPERM;
@@ -1940,7 +1940,7 @@ void audit_log_end(struct audit_buffer *ab)
1940 struct nlmsghdr *nlh = nlmsg_hdr(ab->skb); 1940 struct nlmsghdr *nlh = nlmsg_hdr(ab->skb);
1941 1941
1942 nlh->nlmsg_len = ab->skb->len; 1942 nlh->nlmsg_len = ab->skb->len;
1943 kauditd_send_multicast_skb(ab->skb); 1943 kauditd_send_multicast_skb(ab->skb, ab->gfp_mask);
1944 1944
1945 /* 1945 /*
1946 * The original kaudit unicast socket sends up messages with 1946 * The original kaudit unicast socket sends up messages with
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 3598e13f2a65..4f68a326d92e 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -442,19 +442,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
442 if ((f->type == AUDIT_LOGINUID) && (f->val == AUDIT_UID_UNSET)) { 442 if ((f->type == AUDIT_LOGINUID) && (f->val == AUDIT_UID_UNSET)) {
443 f->type = AUDIT_LOGINUID_SET; 443 f->type = AUDIT_LOGINUID_SET;
444 f->val = 0; 444 f->val = 0;
445 } 445 entry->rule.pflags |= AUDIT_LOGINUID_LEGACY;
446
447 if ((f->type == AUDIT_PID) || (f->type == AUDIT_PPID)) {
448 struct pid *pid;
449 rcu_read_lock();
450 pid = find_vpid(f->val);
451 if (!pid) {
452 rcu_read_unlock();
453 err = -ESRCH;
454 goto exit_free;
455 }
456 f->val = pid_nr(pid);
457 rcu_read_unlock();
458 } 446 }
459 447
460 err = audit_field_valid(entry, f); 448 err = audit_field_valid(entry, f);
@@ -630,6 +618,13 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
630 data->buflen += data->values[i] = 618 data->buflen += data->values[i] =
631 audit_pack_string(&bufp, krule->filterkey); 619 audit_pack_string(&bufp, krule->filterkey);
632 break; 620 break;
621 case AUDIT_LOGINUID_SET:
622 if (krule->pflags & AUDIT_LOGINUID_LEGACY && !f->val) {
623 data->fields[i] = AUDIT_LOGINUID;
624 data->values[i] = AUDIT_UID_UNSET;
625 break;
626 }
627 /* fallthrough if set */
633 default: 628 default:
634 data->values[i] = f->val; 629 data->values[i] = f->val;
635 } 630 }
@@ -646,6 +641,7 @@ static int audit_compare_rule(struct audit_krule *a, struct audit_krule *b)
646 int i; 641 int i;
647 642
648 if (a->flags != b->flags || 643 if (a->flags != b->flags ||
644 a->pflags != b->pflags ||
649 a->listnr != b->listnr || 645 a->listnr != b->listnr ||
650 a->action != b->action || 646 a->action != b->action ||
651 a->field_count != b->field_count) 647 a->field_count != b->field_count)
@@ -764,6 +760,7 @@ struct audit_entry *audit_dupe_rule(struct audit_krule *old)
764 new = &entry->rule; 760 new = &entry->rule;
765 new->vers_ops = old->vers_ops; 761 new->vers_ops = old->vers_ops;
766 new->flags = old->flags; 762 new->flags = old->flags;
763 new->pflags = old->pflags;
767 new->listnr = old->listnr; 764 new->listnr = old->listnr;
768 new->action = old->action; 765 new->action = old->action;
769 for (i = 0; i < AUDIT_BITMASK_SIZE; i++) 766 for (i = 0; i < AUDIT_BITMASK_SIZE; i++)
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index c75522a83678..072566dd0caf 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -72,6 +72,8 @@
72#include <linux/fs_struct.h> 72#include <linux/fs_struct.h>
73#include <linux/compat.h> 73#include <linux/compat.h>
74#include <linux/ctype.h> 74#include <linux/ctype.h>
75#include <linux/string.h>
76#include <uapi/linux/limits.h>
75 77
76#include "audit.h" 78#include "audit.h"
77 79
@@ -1861,8 +1863,7 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
1861 } 1863 }
1862 1864
1863 list_for_each_entry_reverse(n, &context->names_list, list) { 1865 list_for_each_entry_reverse(n, &context->names_list, list) {
1864 /* does the name pointer match? */ 1866 if (!n->name || strcmp(n->name->name, name->name))
1865 if (!n->name || n->name->name != name->name)
1866 continue; 1867 continue;
1867 1868
1868 /* match the correct record type */ 1869 /* match the correct record type */
@@ -1877,12 +1878,48 @@ void __audit_inode(struct filename *name, const struct dentry *dentry,
1877 } 1878 }
1878 1879
1879out_alloc: 1880out_alloc:
1880 /* unable to find the name from a previous getname(). Allocate a new 1881 /* unable to find an entry with both a matching name and type */
1881 * anonymous entry. 1882 n = audit_alloc_name(context, AUDIT_TYPE_UNKNOWN);
1882 */
1883 n = audit_alloc_name(context, AUDIT_TYPE_NORMAL);
1884 if (!n) 1883 if (!n)
1885 return; 1884 return;
1885 /* unfortunately, while we may have a path name to record with the
1886 * inode, we can't always rely on the string lasting until the end of
1887 * the syscall so we need to create our own copy, it may fail due to
1888 * memory allocation issues, but we do our best */
1889 if (name) {
1890 /* we can't use getname_kernel() due to size limits */
1891 size_t len = strlen(name->name) + 1;
1892 struct filename *new = __getname();
1893
1894 if (unlikely(!new))
1895 goto out;
1896
1897 if (len <= (PATH_MAX - sizeof(*new))) {
1898 new->name = (char *)(new) + sizeof(*new);
1899 new->separate = false;
1900 } else if (len <= PATH_MAX) {
1901 /* this looks odd, but is due to final_putname() */
1902 struct filename *new2;
1903
1904 new2 = kmalloc(sizeof(*new2), GFP_KERNEL);
1905 if (unlikely(!new2)) {
1906 __putname(new);
1907 goto out;
1908 }
1909 new2->name = (char *)new;
1910 new2->separate = true;
1911 new = new2;
1912 } else {
1913 /* we should never get here, but let's be safe */
1914 __putname(new);
1915 goto out;
1916 }
1917 strlcpy((char *)new->name, name->name, len);
1918 new->uptr = NULL;
1919 new->aname = n;
1920 n->name = new;
1921 n->name_put = true;
1922 }
1886out: 1923out:
1887 if (parent) { 1924 if (parent) {
1888 n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL; 1925 n->name_len = n->name ? parent_len(n->name->name) : AUDIT_NAME_FULL;
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 1adf62b39b96..07ce18ca71e0 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -27,6 +27,9 @@
27 * version 2. This program is licensed "as is" without any warranty of any 27 * version 2. This program is licensed "as is" without any warranty of any
28 * kind, whether express or implied. 28 * kind, whether express or implied.
29 */ 29 */
30
31#define pr_fmt(fmt) "KGDB: " fmt
32
30#include <linux/pid_namespace.h> 33#include <linux/pid_namespace.h>
31#include <linux/clocksource.h> 34#include <linux/clocksource.h>
32#include <linux/serial_core.h> 35#include <linux/serial_core.h>
@@ -196,8 +199,8 @@ int __weak kgdb_validate_break_address(unsigned long addr)
196 return err; 199 return err;
197 err = kgdb_arch_remove_breakpoint(&tmp); 200 err = kgdb_arch_remove_breakpoint(&tmp);
198 if (err) 201 if (err)
199 printk(KERN_ERR "KGDB: Critical breakpoint error, kernel " 202 pr_err("Critical breakpoint error, kernel memory destroyed at: %lx\n",
200 "memory destroyed at: %lx", addr); 203 addr);
201 return err; 204 return err;
202} 205}
203 206
@@ -256,8 +259,8 @@ int dbg_activate_sw_breakpoints(void)
256 error = kgdb_arch_set_breakpoint(&kgdb_break[i]); 259 error = kgdb_arch_set_breakpoint(&kgdb_break[i]);
257 if (error) { 260 if (error) {
258 ret = error; 261 ret = error;
259 printk(KERN_INFO "KGDB: BP install failed: %lx", 262 pr_info("BP install failed: %lx\n",
260 kgdb_break[i].bpt_addr); 263 kgdb_break[i].bpt_addr);
261 continue; 264 continue;
262 } 265 }
263 266
@@ -319,8 +322,8 @@ int dbg_deactivate_sw_breakpoints(void)
319 continue; 322 continue;
320 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); 323 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);
321 if (error) { 324 if (error) {
322 printk(KERN_INFO "KGDB: BP remove failed: %lx\n", 325 pr_info("BP remove failed: %lx\n",
323 kgdb_break[i].bpt_addr); 326 kgdb_break[i].bpt_addr);
324 ret = error; 327 ret = error;
325 } 328 }
326 329
@@ -367,7 +370,7 @@ int dbg_remove_all_break(void)
367 goto setundefined; 370 goto setundefined;
368 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]); 371 error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);
369 if (error) 372 if (error)
370 printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n", 373 pr_err("breakpoint remove failed: %lx\n",
371 kgdb_break[i].bpt_addr); 374 kgdb_break[i].bpt_addr);
372setundefined: 375setundefined:
373 kgdb_break[i].state = BP_UNDEFINED; 376 kgdb_break[i].state = BP_UNDEFINED;
@@ -400,9 +403,9 @@ static int kgdb_io_ready(int print_wait)
400 if (print_wait) { 403 if (print_wait) {
401#ifdef CONFIG_KGDB_KDB 404#ifdef CONFIG_KGDB_KDB
402 if (!dbg_kdb_mode) 405 if (!dbg_kdb_mode)
403 printk(KERN_CRIT "KGDB: waiting... or $3#33 for KDB\n"); 406 pr_crit("waiting... or $3#33 for KDB\n");
404#else 407#else
405 printk(KERN_CRIT "KGDB: Waiting for remote debugger\n"); 408 pr_crit("Waiting for remote debugger\n");
406#endif 409#endif
407 } 410 }
408 return 1; 411 return 1;
@@ -430,8 +433,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks)
430 exception_level = 0; 433 exception_level = 0;
431 kgdb_skipexception(ks->ex_vector, ks->linux_regs); 434 kgdb_skipexception(ks->ex_vector, ks->linux_regs);
432 dbg_activate_sw_breakpoints(); 435 dbg_activate_sw_breakpoints();
433 printk(KERN_CRIT "KGDB: re-enter error: breakpoint removed %lx\n", 436 pr_crit("re-enter error: breakpoint removed %lx\n", addr);
434 addr);
435 WARN_ON_ONCE(1); 437 WARN_ON_ONCE(1);
436 438
437 return 1; 439 return 1;
@@ -444,7 +446,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks)
444 panic("Recursive entry to debugger"); 446 panic("Recursive entry to debugger");
445 } 447 }
446 448
447 printk(KERN_CRIT "KGDB: re-enter exception: ALL breakpoints killed\n"); 449 pr_crit("re-enter exception: ALL breakpoints killed\n");
448#ifdef CONFIG_KGDB_KDB 450#ifdef CONFIG_KGDB_KDB
449 /* Allow kdb to debug itself one level */ 451 /* Allow kdb to debug itself one level */
450 return 0; 452 return 0;
@@ -471,6 +473,7 @@ static int kgdb_cpu_enter(struct kgdb_state *ks, struct pt_regs *regs,
471 int cpu; 473 int cpu;
472 int trace_on = 0; 474 int trace_on = 0;
473 int online_cpus = num_online_cpus(); 475 int online_cpus = num_online_cpus();
476 u64 time_left;
474 477
475 kgdb_info[ks->cpu].enter_kgdb++; 478 kgdb_info[ks->cpu].enter_kgdb++;
476 kgdb_info[ks->cpu].exception_state |= exception_state; 479 kgdb_info[ks->cpu].exception_state |= exception_state;
@@ -595,9 +598,13 @@ return_normal:
595 /* 598 /*
596 * Wait for the other CPUs to be notified and be waiting for us: 599 * Wait for the other CPUs to be notified and be waiting for us:
597 */ 600 */
598 while (kgdb_do_roundup && (atomic_read(&masters_in_kgdb) + 601 time_left = loops_per_jiffy * HZ;
599 atomic_read(&slaves_in_kgdb)) != online_cpus) 602 while (kgdb_do_roundup && --time_left &&
603 (atomic_read(&masters_in_kgdb) + atomic_read(&slaves_in_kgdb)) !=
604 online_cpus)
600 cpu_relax(); 605 cpu_relax();
606 if (!time_left)
607 pr_crit("KGDB: Timed out waiting for secondary CPUs.\n");
601 608
602 /* 609 /*
603 * At this point the primary processor is completely 610 * At this point the primary processor is completely
@@ -795,15 +802,15 @@ static struct console kgdbcons = {
795static void sysrq_handle_dbg(int key) 802static void sysrq_handle_dbg(int key)
796{ 803{
797 if (!dbg_io_ops) { 804 if (!dbg_io_ops) {
798 printk(KERN_CRIT "ERROR: No KGDB I/O module available\n"); 805 pr_crit("ERROR: No KGDB I/O module available\n");
799 return; 806 return;
800 } 807 }
801 if (!kgdb_connected) { 808 if (!kgdb_connected) {
802#ifdef CONFIG_KGDB_KDB 809#ifdef CONFIG_KGDB_KDB
803 if (!dbg_kdb_mode) 810 if (!dbg_kdb_mode)
804 printk(KERN_CRIT "KGDB or $3#33 for KDB\n"); 811 pr_crit("KGDB or $3#33 for KDB\n");
805#else 812#else
806 printk(KERN_CRIT "Entering KGDB\n"); 813 pr_crit("Entering KGDB\n");
807#endif 814#endif
808 } 815 }
809 816
@@ -945,7 +952,7 @@ static void kgdb_initial_breakpoint(void)
945{ 952{
946 kgdb_break_asap = 0; 953 kgdb_break_asap = 0;
947 954
948 printk(KERN_CRIT "kgdb: Waiting for connection from remote gdb...\n"); 955 pr_crit("Waiting for connection from remote gdb...\n");
949 kgdb_breakpoint(); 956 kgdb_breakpoint();
950} 957}
951 958
@@ -964,8 +971,7 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops)
964 if (dbg_io_ops) { 971 if (dbg_io_ops) {
965 spin_unlock(&kgdb_registration_lock); 972 spin_unlock(&kgdb_registration_lock);
966 973
967 printk(KERN_ERR "kgdb: Another I/O driver is already " 974 pr_err("Another I/O driver is already registered with KGDB\n");
968 "registered with KGDB.\n");
969 return -EBUSY; 975 return -EBUSY;
970 } 976 }
971 977
@@ -981,8 +987,7 @@ int kgdb_register_io_module(struct kgdb_io *new_dbg_io_ops)
981 987
982 spin_unlock(&kgdb_registration_lock); 988 spin_unlock(&kgdb_registration_lock);
983 989
984 printk(KERN_INFO "kgdb: Registered I/O driver %s.\n", 990 pr_info("Registered I/O driver %s\n", new_dbg_io_ops->name);
985 new_dbg_io_ops->name);
986 991
987 /* Arm KGDB now. */ 992 /* Arm KGDB now. */
988 kgdb_register_callbacks(); 993 kgdb_register_callbacks();
@@ -1017,8 +1022,7 @@ void kgdb_unregister_io_module(struct kgdb_io *old_dbg_io_ops)
1017 1022
1018 spin_unlock(&kgdb_registration_lock); 1023 spin_unlock(&kgdb_registration_lock);
1019 1024
1020 printk(KERN_INFO 1025 pr_info("Unregistered I/O driver %s, debugger disabled\n",
1021 "kgdb: Unregistered I/O driver %s, debugger disabled.\n",
1022 old_dbg_io_ops->name); 1026 old_dbg_io_ops->name);
1023} 1027}
1024EXPORT_SYMBOL_GPL(kgdb_unregister_io_module); 1028EXPORT_SYMBOL_GPL(kgdb_unregister_io_module);
diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c
index b20d544f20c2..e1dbf4a2c69e 100644
--- a/kernel/debug/kdb/kdb_bp.c
+++ b/kernel/debug/kdb/kdb_bp.c
@@ -531,22 +531,29 @@ void __init kdb_initbptab(void)
531 for (i = 0, bp = kdb_breakpoints; i < KDB_MAXBPT; i++, bp++) 531 for (i = 0, bp = kdb_breakpoints; i < KDB_MAXBPT; i++, bp++)
532 bp->bp_free = 1; 532 bp->bp_free = 1;
533 533
534 kdb_register_repeat("bp", kdb_bp, "[<vaddr>]", 534 kdb_register_flags("bp", kdb_bp, "[<vaddr>]",
535 "Set/Display breakpoints", 0, KDB_REPEAT_NO_ARGS); 535 "Set/Display breakpoints", 0,
536 kdb_register_repeat("bl", kdb_bp, "[<vaddr>]", 536 KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS);
537 "Display breakpoints", 0, KDB_REPEAT_NO_ARGS); 537 kdb_register_flags("bl", kdb_bp, "[<vaddr>]",
538 "Display breakpoints", 0,
539 KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS);
538 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) 540 if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT)
539 kdb_register_repeat("bph", kdb_bp, "[<vaddr>]", 541 kdb_register_flags("bph", kdb_bp, "[<vaddr>]",
540 "[datar [length]|dataw [length]] Set hw brk", 0, KDB_REPEAT_NO_ARGS); 542 "[datar [length]|dataw [length]] Set hw brk", 0,
541 kdb_register_repeat("bc", kdb_bc, "<bpnum>", 543 KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS);
542 "Clear Breakpoint", 0, KDB_REPEAT_NONE); 544 kdb_register_flags("bc", kdb_bc, "<bpnum>",
543 kdb_register_repeat("be", kdb_bc, "<bpnum>", 545 "Clear Breakpoint", 0,
544 "Enable Breakpoint", 0, KDB_REPEAT_NONE); 546 KDB_ENABLE_FLOW_CTRL);
545 kdb_register_repeat("bd", kdb_bc, "<bpnum>", 547 kdb_register_flags("be", kdb_bc, "<bpnum>",
546 "Disable Breakpoint", 0, KDB_REPEAT_NONE); 548 "Enable Breakpoint", 0,
547 549 KDB_ENABLE_FLOW_CTRL);
548 kdb_register_repeat("ss", kdb_ss, "", 550 kdb_register_flags("bd", kdb_bc, "<bpnum>",
549 "Single Step", 1, KDB_REPEAT_NO_ARGS); 551 "Disable Breakpoint", 0,
552 KDB_ENABLE_FLOW_CTRL);
553
554 kdb_register_flags("ss", kdb_ss, "",
555 "Single Step", 1,
556 KDB_ENABLE_FLOW_CTRL | KDB_REPEAT_NO_ARGS);
550 /* 557 /*
551 * Architecture dependent initialization. 558 * Architecture dependent initialization.
552 */ 559 */
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c
index 8859ca34dcfe..15e1a7af5dd0 100644
--- a/kernel/debug/kdb/kdb_debugger.c
+++ b/kernel/debug/kdb/kdb_debugger.c
@@ -129,6 +129,10 @@ int kdb_stub(struct kgdb_state *ks)
129 ks->pass_exception = 1; 129 ks->pass_exception = 1;
130 KDB_FLAG_SET(CATASTROPHIC); 130 KDB_FLAG_SET(CATASTROPHIC);
131 } 131 }
132 /* set CATASTROPHIC if the system contains unresponsive processors */
133 for_each_online_cpu(i)
134 if (!kgdb_info[i].enter_kgdb)
135 KDB_FLAG_SET(CATASTROPHIC);
132 if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) { 136 if (KDB_STATE(SSBPT) && reason == KDB_REASON_SSTEP) {
133 KDB_STATE_CLEAR(SSBPT); 137 KDB_STATE_CLEAR(SSBPT);
134 KDB_STATE_CLEAR(DOING_SS); 138 KDB_STATE_CLEAR(DOING_SS);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 379650b984f8..f191bddf64b8 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/ctype.h> 14#include <linux/ctype.h>
15#include <linux/types.h>
15#include <linux/string.h> 16#include <linux/string.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/kmsg_dump.h> 18#include <linux/kmsg_dump.h>
@@ -23,6 +24,7 @@
23#include <linux/vmalloc.h> 24#include <linux/vmalloc.h>
24#include <linux/atomic.h> 25#include <linux/atomic.h>
25#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/moduleparam.h>
26#include <linux/mm.h> 28#include <linux/mm.h>
27#include <linux/init.h> 29#include <linux/init.h>
28#include <linux/kallsyms.h> 30#include <linux/kallsyms.h>
@@ -42,6 +44,12 @@
42#include <linux/slab.h> 44#include <linux/slab.h>
43#include "kdb_private.h" 45#include "kdb_private.h"
44 46
47#undef MODULE_PARAM_PREFIX
48#define MODULE_PARAM_PREFIX "kdb."
49
50static int kdb_cmd_enabled = CONFIG_KDB_DEFAULT_ENABLE;
51module_param_named(cmd_enable, kdb_cmd_enabled, int, 0600);
52
45#define GREP_LEN 256 53#define GREP_LEN 256
46char kdb_grep_string[GREP_LEN]; 54char kdb_grep_string[GREP_LEN];
47int kdb_grepping_flag; 55int kdb_grepping_flag;
@@ -121,6 +129,7 @@ static kdbmsg_t kdbmsgs[] = {
121 KDBMSG(BADLENGTH, "Invalid length field"), 129 KDBMSG(BADLENGTH, "Invalid length field"),
122 KDBMSG(NOBP, "No Breakpoint exists"), 130 KDBMSG(NOBP, "No Breakpoint exists"),
123 KDBMSG(BADADDR, "Invalid address"), 131 KDBMSG(BADADDR, "Invalid address"),
132 KDBMSG(NOPERM, "Permission denied"),
124}; 133};
125#undef KDBMSG 134#undef KDBMSG
126 135
@@ -188,6 +197,26 @@ struct task_struct *kdb_curr_task(int cpu)
188} 197}
189 198
190/* 199/*
200 * Check whether the flags of the current command and the permissions
201 * of the kdb console has allow a command to be run.
202 */
203static inline bool kdb_check_flags(kdb_cmdflags_t flags, int permissions,
204 bool no_args)
205{
206 /* permissions comes from userspace so needs massaging slightly */
207 permissions &= KDB_ENABLE_MASK;
208 permissions |= KDB_ENABLE_ALWAYS_SAFE;
209
210 /* some commands change group when launched with no arguments */
211 if (no_args)
212 permissions |= permissions << KDB_ENABLE_NO_ARGS_SHIFT;
213
214 flags |= KDB_ENABLE_ALL;
215
216 return permissions & flags;
217}
218
219/*
191 * kdbgetenv - This function will return the character string value of 220 * kdbgetenv - This function will return the character string value of
192 * an environment variable. 221 * an environment variable.
193 * Parameters: 222 * Parameters:
@@ -476,6 +505,15 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
476 kdb_symtab_t symtab; 505 kdb_symtab_t symtab;
477 506
478 /* 507 /*
508 * If the enable flags prohibit both arbitrary memory access
509 * and flow control then there are no reasonable grounds to
510 * provide symbol lookup.
511 */
512 if (!kdb_check_flags(KDB_ENABLE_MEM_READ | KDB_ENABLE_FLOW_CTRL,
513 kdb_cmd_enabled, false))
514 return KDB_NOPERM;
515
516 /*
479 * Process arguments which follow the following syntax: 517 * Process arguments which follow the following syntax:
480 * 518 *
481 * symbol | numeric-address [+/- numeric-offset] 519 * symbol | numeric-address [+/- numeric-offset]
@@ -641,8 +679,13 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
641 if (!s->count) 679 if (!s->count)
642 s->usable = 0; 680 s->usable = 0;
643 if (s->usable) 681 if (s->usable)
644 kdb_register(s->name, kdb_exec_defcmd, 682 /* macros are always safe because when executed each
645 s->usage, s->help, 0); 683 * internal command re-enters kdb_parse() and is
684 * safety checked individually.
685 */
686 kdb_register_flags(s->name, kdb_exec_defcmd, s->usage,
687 s->help, 0,
688 KDB_ENABLE_ALWAYS_SAFE);
646 return 0; 689 return 0;
647 } 690 }
648 if (!s->usable) 691 if (!s->usable)
@@ -1003,25 +1046,22 @@ int kdb_parse(const char *cmdstr)
1003 1046
1004 if (i < kdb_max_commands) { 1047 if (i < kdb_max_commands) {
1005 int result; 1048 int result;
1049
1050 if (!kdb_check_flags(tp->cmd_flags, kdb_cmd_enabled, argc <= 1))
1051 return KDB_NOPERM;
1052
1006 KDB_STATE_SET(CMD); 1053 KDB_STATE_SET(CMD);
1007 result = (*tp->cmd_func)(argc-1, (const char **)argv); 1054 result = (*tp->cmd_func)(argc-1, (const char **)argv);
1008 if (result && ignore_errors && result > KDB_CMD_GO) 1055 if (result && ignore_errors && result > KDB_CMD_GO)
1009 result = 0; 1056 result = 0;
1010 KDB_STATE_CLEAR(CMD); 1057 KDB_STATE_CLEAR(CMD);
1011 switch (tp->cmd_repeat) { 1058
1012 case KDB_REPEAT_NONE: 1059 if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS)
1013 argc = 0; 1060 return result;
1014 if (argv[0]) 1061
1015 *(argv[0]) = '\0'; 1062 argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0;
1016 break; 1063 if (argv[argc])
1017 case KDB_REPEAT_NO_ARGS: 1064 *(argv[argc]) = '\0';
1018 argc = 1;
1019 if (argv[1])
1020 *(argv[1]) = '\0';
1021 break;
1022 case KDB_REPEAT_WITH_ARGS:
1023 break;
1024 }
1025 return result; 1065 return result;
1026 } 1066 }
1027 1067
@@ -1921,10 +1961,14 @@ static int kdb_rm(int argc, const char **argv)
1921 */ 1961 */
1922static int kdb_sr(int argc, const char **argv) 1962static int kdb_sr(int argc, const char **argv)
1923{ 1963{
1964 bool check_mask =
1965 !kdb_check_flags(KDB_ENABLE_ALL, kdb_cmd_enabled, false);
1966
1924 if (argc != 1) 1967 if (argc != 1)
1925 return KDB_ARGCOUNT; 1968 return KDB_ARGCOUNT;
1969
1926 kdb_trap_printk++; 1970 kdb_trap_printk++;
1927 __handle_sysrq(*argv[1], false); 1971 __handle_sysrq(*argv[1], check_mask);
1928 kdb_trap_printk--; 1972 kdb_trap_printk--;
1929 1973
1930 return 0; 1974 return 0;
@@ -2157,6 +2201,8 @@ static void kdb_cpu_status(void)
2157 for (start_cpu = -1, i = 0; i < NR_CPUS; i++) { 2201 for (start_cpu = -1, i = 0; i < NR_CPUS; i++) {
2158 if (!cpu_online(i)) { 2202 if (!cpu_online(i)) {
2159 state = 'F'; /* cpu is offline */ 2203 state = 'F'; /* cpu is offline */
2204 } else if (!kgdb_info[i].enter_kgdb) {
2205 state = 'D'; /* cpu is online but unresponsive */
2160 } else { 2206 } else {
2161 state = ' '; /* cpu is responding to kdb */ 2207 state = ' '; /* cpu is responding to kdb */
2162 if (kdb_task_state_char(KDB_TSK(i)) == 'I') 2208 if (kdb_task_state_char(KDB_TSK(i)) == 'I')
@@ -2210,7 +2256,7 @@ static int kdb_cpu(int argc, const char **argv)
2210 /* 2256 /*
2211 * Validate cpunum 2257 * Validate cpunum
2212 */ 2258 */
2213 if ((cpunum > NR_CPUS) || !cpu_online(cpunum)) 2259 if ((cpunum > NR_CPUS) || !kgdb_info[cpunum].enter_kgdb)
2214 return KDB_BADCPUNUM; 2260 return KDB_BADCPUNUM;
2215 2261
2216 dbg_switch_cpu = cpunum; 2262 dbg_switch_cpu = cpunum;
@@ -2375,6 +2421,8 @@ static int kdb_help(int argc, const char **argv)
2375 return 0; 2421 return 0;
2376 if (!kt->cmd_name) 2422 if (!kt->cmd_name)
2377 continue; 2423 continue;
2424 if (!kdb_check_flags(kt->cmd_flags, kdb_cmd_enabled, true))
2425 continue;
2378 if (strlen(kt->cmd_usage) > 20) 2426 if (strlen(kt->cmd_usage) > 20)
2379 space = "\n "; 2427 space = "\n ";
2380 kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name, 2428 kdb_printf("%-15.15s %-20s%s%s\n", kt->cmd_name,
@@ -2629,7 +2677,7 @@ static int kdb_grep_help(int argc, const char **argv)
2629} 2677}
2630 2678
2631/* 2679/*
2632 * kdb_register_repeat - This function is used to register a kernel 2680 * kdb_register_flags - This function is used to register a kernel
2633 * debugger command. 2681 * debugger command.
2634 * Inputs: 2682 * Inputs:
2635 * cmd Command name 2683 * cmd Command name
@@ -2641,12 +2689,12 @@ static int kdb_grep_help(int argc, const char **argv)
2641 * zero for success, one if a duplicate command. 2689 * zero for success, one if a duplicate command.
2642 */ 2690 */
2643#define kdb_command_extend 50 /* arbitrary */ 2691#define kdb_command_extend 50 /* arbitrary */
2644int kdb_register_repeat(char *cmd, 2692int kdb_register_flags(char *cmd,
2645 kdb_func_t func, 2693 kdb_func_t func,
2646 char *usage, 2694 char *usage,
2647 char *help, 2695 char *help,
2648 short minlen, 2696 short minlen,
2649 kdb_repeat_t repeat) 2697 kdb_cmdflags_t flags)
2650{ 2698{
2651 int i; 2699 int i;
2652 kdbtab_t *kp; 2700 kdbtab_t *kp;
@@ -2694,19 +2742,18 @@ int kdb_register_repeat(char *cmd,
2694 kp->cmd_func = func; 2742 kp->cmd_func = func;
2695 kp->cmd_usage = usage; 2743 kp->cmd_usage = usage;
2696 kp->cmd_help = help; 2744 kp->cmd_help = help;
2697 kp->cmd_flags = 0;
2698 kp->cmd_minlen = minlen; 2745 kp->cmd_minlen = minlen;
2699 kp->cmd_repeat = repeat; 2746 kp->cmd_flags = flags;
2700 2747
2701 return 0; 2748 return 0;
2702} 2749}
2703EXPORT_SYMBOL_GPL(kdb_register_repeat); 2750EXPORT_SYMBOL_GPL(kdb_register_flags);
2704 2751
2705 2752
2706/* 2753/*
2707 * kdb_register - Compatibility register function for commands that do 2754 * kdb_register - Compatibility register function for commands that do
2708 * not need to specify a repeat state. Equivalent to 2755 * not need to specify a repeat state. Equivalent to
2709 * kdb_register_repeat with KDB_REPEAT_NONE. 2756 * kdb_register_flags with flags set to 0.
2710 * Inputs: 2757 * Inputs:
2711 * cmd Command name 2758 * cmd Command name
2712 * func Function to execute the command 2759 * func Function to execute the command
@@ -2721,8 +2768,7 @@ int kdb_register(char *cmd,
2721 char *help, 2768 char *help,
2722 short minlen) 2769 short minlen)
2723{ 2770{
2724 return kdb_register_repeat(cmd, func, usage, help, minlen, 2771 return kdb_register_flags(cmd, func, usage, help, minlen, 0);
2725 KDB_REPEAT_NONE);
2726} 2772}
2727EXPORT_SYMBOL_GPL(kdb_register); 2773EXPORT_SYMBOL_GPL(kdb_register);
2728 2774
@@ -2764,80 +2810,109 @@ static void __init kdb_inittab(void)
2764 for_each_kdbcmd(kp, i) 2810 for_each_kdbcmd(kp, i)
2765 kp->cmd_name = NULL; 2811 kp->cmd_name = NULL;
2766 2812
2767 kdb_register_repeat("md", kdb_md, "<vaddr>", 2813 kdb_register_flags("md", kdb_md, "<vaddr>",
2768 "Display Memory Contents, also mdWcN, e.g. md8c1", 1, 2814 "Display Memory Contents, also mdWcN, e.g. md8c1", 1,
2769 KDB_REPEAT_NO_ARGS); 2815 KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);
2770 kdb_register_repeat("mdr", kdb_md, "<vaddr> <bytes>", 2816 kdb_register_flags("mdr", kdb_md, "<vaddr> <bytes>",
2771 "Display Raw Memory", 0, KDB_REPEAT_NO_ARGS); 2817 "Display Raw Memory", 0,
2772 kdb_register_repeat("mdp", kdb_md, "<paddr> <bytes>", 2818 KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);
2773 "Display Physical Memory", 0, KDB_REPEAT_NO_ARGS); 2819 kdb_register_flags("mdp", kdb_md, "<paddr> <bytes>",
2774 kdb_register_repeat("mds", kdb_md, "<vaddr>", 2820 "Display Physical Memory", 0,
2775 "Display Memory Symbolically", 0, KDB_REPEAT_NO_ARGS); 2821 KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);
2776 kdb_register_repeat("mm", kdb_mm, "<vaddr> <contents>", 2822 kdb_register_flags("mds", kdb_md, "<vaddr>",
2777 "Modify Memory Contents", 0, KDB_REPEAT_NO_ARGS); 2823 "Display Memory Symbolically", 0,
2778 kdb_register_repeat("go", kdb_go, "[<vaddr>]", 2824 KDB_ENABLE_MEM_READ | KDB_REPEAT_NO_ARGS);
2779 "Continue Execution", 1, KDB_REPEAT_NONE); 2825 kdb_register_flags("mm", kdb_mm, "<vaddr> <contents>",
2780 kdb_register_repeat("rd", kdb_rd, "", 2826 "Modify Memory Contents", 0,
2781 "Display Registers", 0, KDB_REPEAT_NONE); 2827 KDB_ENABLE_MEM_WRITE | KDB_REPEAT_NO_ARGS);
2782 kdb_register_repeat("rm", kdb_rm, "<reg> <contents>", 2828 kdb_register_flags("go", kdb_go, "[<vaddr>]",
2783 "Modify Registers", 0, KDB_REPEAT_NONE); 2829 "Continue Execution", 1,
2784 kdb_register_repeat("ef", kdb_ef, "<vaddr>", 2830 KDB_ENABLE_REG_WRITE | KDB_ENABLE_ALWAYS_SAFE_NO_ARGS);
2785 "Display exception frame", 0, KDB_REPEAT_NONE); 2831 kdb_register_flags("rd", kdb_rd, "",
2786 kdb_register_repeat("bt", kdb_bt, "[<vaddr>]", 2832 "Display Registers", 0,
2787 "Stack traceback", 1, KDB_REPEAT_NONE); 2833 KDB_ENABLE_REG_READ);
2788 kdb_register_repeat("btp", kdb_bt, "<pid>", 2834 kdb_register_flags("rm", kdb_rm, "<reg> <contents>",
2789 "Display stack for process <pid>", 0, KDB_REPEAT_NONE); 2835 "Modify Registers", 0,
2790 kdb_register_repeat("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]", 2836 KDB_ENABLE_REG_WRITE);
2791 "Backtrace all processes matching state flag", 0, KDB_REPEAT_NONE); 2837 kdb_register_flags("ef", kdb_ef, "<vaddr>",
2792 kdb_register_repeat("btc", kdb_bt, "", 2838 "Display exception frame", 0,
2793 "Backtrace current process on each cpu", 0, KDB_REPEAT_NONE); 2839 KDB_ENABLE_MEM_READ);
2794 kdb_register_repeat("btt", kdb_bt, "<vaddr>", 2840 kdb_register_flags("bt", kdb_bt, "[<vaddr>]",
2841 "Stack traceback", 1,
2842 KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS);
2843 kdb_register_flags("btp", kdb_bt, "<pid>",
2844 "Display stack for process <pid>", 0,
2845 KDB_ENABLE_INSPECT);
2846 kdb_register_flags("bta", kdb_bt, "[D|R|S|T|C|Z|E|U|I|M|A]",
2847 "Backtrace all processes matching state flag", 0,
2848 KDB_ENABLE_INSPECT);
2849 kdb_register_flags("btc", kdb_bt, "",
2850 "Backtrace current process on each cpu", 0,
2851 KDB_ENABLE_INSPECT);
2852 kdb_register_flags("btt", kdb_bt, "<vaddr>",
2795 "Backtrace process given its struct task address", 0, 2853 "Backtrace process given its struct task address", 0,
2796 KDB_REPEAT_NONE); 2854 KDB_ENABLE_MEM_READ | KDB_ENABLE_INSPECT_NO_ARGS);
2797 kdb_register_repeat("env", kdb_env, "", 2855 kdb_register_flags("env", kdb_env, "",
2798 "Show environment variables", 0, KDB_REPEAT_NONE); 2856 "Show environment variables", 0,
2799 kdb_register_repeat("set", kdb_set, "", 2857 KDB_ENABLE_ALWAYS_SAFE);
2800 "Set environment variables", 0, KDB_REPEAT_NONE); 2858 kdb_register_flags("set", kdb_set, "",
2801 kdb_register_repeat("help", kdb_help, "", 2859 "Set environment variables", 0,
2802 "Display Help Message", 1, KDB_REPEAT_NONE); 2860 KDB_ENABLE_ALWAYS_SAFE);
2803 kdb_register_repeat("?", kdb_help, "", 2861 kdb_register_flags("help", kdb_help, "",
2804 "Display Help Message", 0, KDB_REPEAT_NONE); 2862 "Display Help Message", 1,
2805 kdb_register_repeat("cpu", kdb_cpu, "<cpunum>", 2863 KDB_ENABLE_ALWAYS_SAFE);
2806 "Switch to new cpu", 0, KDB_REPEAT_NONE); 2864 kdb_register_flags("?", kdb_help, "",
2807 kdb_register_repeat("kgdb", kdb_kgdb, "", 2865 "Display Help Message", 0,
2808 "Enter kgdb mode", 0, KDB_REPEAT_NONE); 2866 KDB_ENABLE_ALWAYS_SAFE);
2809 kdb_register_repeat("ps", kdb_ps, "[<flags>|A]", 2867 kdb_register_flags("cpu", kdb_cpu, "<cpunum>",
2810 "Display active task list", 0, KDB_REPEAT_NONE); 2868 "Switch to new cpu", 0,
2811 kdb_register_repeat("pid", kdb_pid, "<pidnum>", 2869 KDB_ENABLE_ALWAYS_SAFE_NO_ARGS);
2812 "Switch to another task", 0, KDB_REPEAT_NONE); 2870 kdb_register_flags("kgdb", kdb_kgdb, "",
2813 kdb_register_repeat("reboot", kdb_reboot, "", 2871 "Enter kgdb mode", 0, 0);
2814 "Reboot the machine immediately", 0, KDB_REPEAT_NONE); 2872 kdb_register_flags("ps", kdb_ps, "[<flags>|A]",
2873 "Display active task list", 0,
2874 KDB_ENABLE_INSPECT);
2875 kdb_register_flags("pid", kdb_pid, "<pidnum>",
2876 "Switch to another task", 0,
2877 KDB_ENABLE_INSPECT);
2878 kdb_register_flags("reboot", kdb_reboot, "",
2879 "Reboot the machine immediately", 0,
2880 KDB_ENABLE_REBOOT);
2815#if defined(CONFIG_MODULES) 2881#if defined(CONFIG_MODULES)
2816 kdb_register_repeat("lsmod", kdb_lsmod, "", 2882 kdb_register_flags("lsmod", kdb_lsmod, "",
2817 "List loaded kernel modules", 0, KDB_REPEAT_NONE); 2883 "List loaded kernel modules", 0,
2884 KDB_ENABLE_INSPECT);
2818#endif 2885#endif
2819#if defined(CONFIG_MAGIC_SYSRQ) 2886#if defined(CONFIG_MAGIC_SYSRQ)
2820 kdb_register_repeat("sr", kdb_sr, "<key>", 2887 kdb_register_flags("sr", kdb_sr, "<key>",
2821 "Magic SysRq key", 0, KDB_REPEAT_NONE); 2888 "Magic SysRq key", 0,
2889 KDB_ENABLE_ALWAYS_SAFE);
2822#endif 2890#endif
2823#if defined(CONFIG_PRINTK) 2891#if defined(CONFIG_PRINTK)
2824 kdb_register_repeat("dmesg", kdb_dmesg, "[lines]", 2892 kdb_register_flags("dmesg", kdb_dmesg, "[lines]",
2825 "Display syslog buffer", 0, KDB_REPEAT_NONE); 2893 "Display syslog buffer", 0,
2894 KDB_ENABLE_ALWAYS_SAFE);
2826#endif 2895#endif
2827 if (arch_kgdb_ops.enable_nmi) { 2896 if (arch_kgdb_ops.enable_nmi) {
2828 kdb_register_repeat("disable_nmi", kdb_disable_nmi, "", 2897 kdb_register_flags("disable_nmi", kdb_disable_nmi, "",
2829 "Disable NMI entry to KDB", 0, KDB_REPEAT_NONE); 2898 "Disable NMI entry to KDB", 0,
2830 } 2899 KDB_ENABLE_ALWAYS_SAFE);
2831 kdb_register_repeat("defcmd", kdb_defcmd, "name \"usage\" \"help\"", 2900 }
2832 "Define a set of commands, down to endefcmd", 0, KDB_REPEAT_NONE); 2901 kdb_register_flags("defcmd", kdb_defcmd, "name \"usage\" \"help\"",
2833 kdb_register_repeat("kill", kdb_kill, "<-signal> <pid>", 2902 "Define a set of commands, down to endefcmd", 0,
2834 "Send a signal to a process", 0, KDB_REPEAT_NONE); 2903 KDB_ENABLE_ALWAYS_SAFE);
2835 kdb_register_repeat("summary", kdb_summary, "", 2904 kdb_register_flags("kill", kdb_kill, "<-signal> <pid>",
2836 "Summarize the system", 4, KDB_REPEAT_NONE); 2905 "Send a signal to a process", 0,
2837 kdb_register_repeat("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]", 2906 KDB_ENABLE_SIGNAL);
2838 "Display per_cpu variables", 3, KDB_REPEAT_NONE); 2907 kdb_register_flags("summary", kdb_summary, "",
2839 kdb_register_repeat("grephelp", kdb_grep_help, "", 2908 "Summarize the system", 4,
2840 "Display help on | grep", 0, KDB_REPEAT_NONE); 2909 KDB_ENABLE_ALWAYS_SAFE);
2910 kdb_register_flags("per_cpu", kdb_per_cpu, "<sym> [<bytes>] [<cpu>]",
2911 "Display per_cpu variables", 3,
2912 KDB_ENABLE_MEM_READ);
2913 kdb_register_flags("grephelp", kdb_grep_help, "",
2914 "Display help on | grep", 0,
2915 KDB_ENABLE_ALWAYS_SAFE);
2841} 2916}
2842 2917
2843/* Execute any commands defined in kdb_cmds. */ 2918/* Execute any commands defined in kdb_cmds. */
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index 7afd3c8c41d5..eaacd1693954 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -172,10 +172,9 @@ typedef struct _kdbtab {
172 kdb_func_t cmd_func; /* Function to execute command */ 172 kdb_func_t cmd_func; /* Function to execute command */
173 char *cmd_usage; /* Usage String for this command */ 173 char *cmd_usage; /* Usage String for this command */
174 char *cmd_help; /* Help message for this command */ 174 char *cmd_help; /* Help message for this command */
175 short cmd_flags; /* Parsing flags */
176 short cmd_minlen; /* Minimum legal # command 175 short cmd_minlen; /* Minimum legal # command
177 * chars required */ 176 * chars required */
178 kdb_repeat_t cmd_repeat; /* Does command auto repeat on enter? */ 177 kdb_cmdflags_t cmd_flags; /* Command behaviour flags */
179} kdbtab_t; 178} kdbtab_t;
180 179
181extern int kdb_bt(int, const char **); /* KDB display back trace */ 180extern int kdb_bt(int, const char **); /* KDB display back trace */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4c1ee7f2bebc..882f835a0d85 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4461,18 +4461,14 @@ perf_output_sample_regs(struct perf_output_handle *handle,
4461} 4461}
4462 4462
4463static void perf_sample_regs_user(struct perf_regs *regs_user, 4463static void perf_sample_regs_user(struct perf_regs *regs_user,
4464 struct pt_regs *regs) 4464 struct pt_regs *regs,
4465 struct pt_regs *regs_user_copy)
4465{ 4466{
4466 if (!user_mode(regs)) { 4467 if (user_mode(regs)) {
4467 if (current->mm) 4468 regs_user->abi = perf_reg_abi(current);
4468 regs = task_pt_regs(current);
4469 else
4470 regs = NULL;
4471 }
4472
4473 if (regs) {
4474 regs_user->abi = perf_reg_abi(current);
4475 regs_user->regs = regs; 4469 regs_user->regs = regs;
4470 } else if (current->mm) {
4471 perf_get_regs_user(regs_user, regs, regs_user_copy);
4476 } else { 4472 } else {
4477 regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE; 4473 regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;
4478 regs_user->regs = NULL; 4474 regs_user->regs = NULL;
@@ -4951,7 +4947,8 @@ void perf_prepare_sample(struct perf_event_header *header,
4951 } 4947 }
4952 4948
4953 if (sample_type & (PERF_SAMPLE_REGS_USER | PERF_SAMPLE_STACK_USER)) 4949 if (sample_type & (PERF_SAMPLE_REGS_USER | PERF_SAMPLE_STACK_USER))
4954 perf_sample_regs_user(&data->regs_user, regs); 4950 perf_sample_regs_user(&data->regs_user, regs,
4951 &data->regs_user_copy);
4955 4952
4956 if (sample_type & PERF_SAMPLE_REGS_USER) { 4953 if (sample_type & PERF_SAMPLE_REGS_USER) {
4957 /* regs dump ABI info */ 4954 /* regs dump ABI info */
diff --git a/kernel/exit.c b/kernel/exit.c
index 1ea4369890a3..6806c55475ee 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1287,9 +1287,15 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
1287static int wait_consider_task(struct wait_opts *wo, int ptrace, 1287static int wait_consider_task(struct wait_opts *wo, int ptrace,
1288 struct task_struct *p) 1288 struct task_struct *p)
1289{ 1289{
1290 /*
1291 * We can race with wait_task_zombie() from another thread.
1292 * Ensure that EXIT_ZOMBIE -> EXIT_DEAD/EXIT_TRACE transition
1293 * can't confuse the checks below.
1294 */
1295 int exit_state = ACCESS_ONCE(p->exit_state);
1290 int ret; 1296 int ret;
1291 1297
1292 if (unlikely(p->exit_state == EXIT_DEAD)) 1298 if (unlikely(exit_state == EXIT_DEAD))
1293 return 0; 1299 return 0;
1294 1300
1295 ret = eligible_child(wo, p); 1301 ret = eligible_child(wo, p);
@@ -1310,7 +1316,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1310 return 0; 1316 return 0;
1311 } 1317 }
1312 1318
1313 if (unlikely(p->exit_state == EXIT_TRACE)) { 1319 if (unlikely(exit_state == EXIT_TRACE)) {
1314 /* 1320 /*
1315 * ptrace == 0 means we are the natural parent. In this case 1321 * ptrace == 0 means we are the natural parent. In this case
1316 * we should clear notask_error, debugger will notify us. 1322 * we should clear notask_error, debugger will notify us.
@@ -1337,7 +1343,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1337 } 1343 }
1338 1344
1339 /* slay zombie? */ 1345 /* slay zombie? */
1340 if (p->exit_state == EXIT_ZOMBIE) { 1346 if (exit_state == EXIT_ZOMBIE) {
1341 /* we don't reap group leaders with subthreads */ 1347 /* we don't reap group leaders with subthreads */
1342 if (!delay_group_leader(p)) { 1348 if (!delay_group_leader(p)) {
1343 /* 1349 /*
diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c
index 5cf6731b98e9..3ef3736002d8 100644
--- a/kernel/locking/mutex-debug.c
+++ b/kernel/locking/mutex-debug.c
@@ -80,13 +80,13 @@ void debug_mutex_unlock(struct mutex *lock)
80 DEBUG_LOCKS_WARN_ON(lock->owner != current); 80 DEBUG_LOCKS_WARN_ON(lock->owner != current);
81 81
82 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next); 82 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
83 mutex_clear_owner(lock);
84 } 83 }
85 84
86 /* 85 /*
87 * __mutex_slowpath_needs_to_unlock() is explicitly 0 for debug 86 * __mutex_slowpath_needs_to_unlock() is explicitly 0 for debug
88 * mutexes so that we can do it here after we've verified state. 87 * mutexes so that we can do it here after we've verified state.
89 */ 88 */
89 mutex_clear_owner(lock);
90 atomic_set(&lock->count, 1); 90 atomic_set(&lock->count, 1);
91} 91}
92 92
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b5797b78add6..c0accc00566e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7113,9 +7113,6 @@ void __init sched_init(void)
7113#ifdef CONFIG_RT_GROUP_SCHED 7113#ifdef CONFIG_RT_GROUP_SCHED
7114 alloc_size += 2 * nr_cpu_ids * sizeof(void **); 7114 alloc_size += 2 * nr_cpu_ids * sizeof(void **);
7115#endif 7115#endif
7116#ifdef CONFIG_CPUMASK_OFFSTACK
7117 alloc_size += num_possible_cpus() * cpumask_size();
7118#endif
7119 if (alloc_size) { 7116 if (alloc_size) {
7120 ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT); 7117 ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
7121 7118
@@ -7135,13 +7132,13 @@ void __init sched_init(void)
7135 ptr += nr_cpu_ids * sizeof(void **); 7132 ptr += nr_cpu_ids * sizeof(void **);
7136 7133
7137#endif /* CONFIG_RT_GROUP_SCHED */ 7134#endif /* CONFIG_RT_GROUP_SCHED */
7135 }
7138#ifdef CONFIG_CPUMASK_OFFSTACK 7136#ifdef CONFIG_CPUMASK_OFFSTACK
7139 for_each_possible_cpu(i) { 7137 for_each_possible_cpu(i) {
7140 per_cpu(load_balance_mask, i) = (void *)ptr; 7138 per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node(
7141 ptr += cpumask_size(); 7139 cpumask_size(), GFP_KERNEL, cpu_to_node(i));
7142 }
7143#endif /* CONFIG_CPUMASK_OFFSTACK */
7144 } 7140 }
7141#endif /* CONFIG_CPUMASK_OFFSTACK */
7145 7142
7146 init_rt_bandwidth(&def_rt_bandwidth, 7143 init_rt_bandwidth(&def_rt_bandwidth,
7147 global_rt_period(), global_rt_runtime()); 7144 global_rt_period(), global_rt_runtime());
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index e5db8c6feebd..b52092f2636d 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -570,24 +570,7 @@ void init_dl_task_timer(struct sched_dl_entity *dl_se)
570static 570static
571int dl_runtime_exceeded(struct rq *rq, struct sched_dl_entity *dl_se) 571int dl_runtime_exceeded(struct rq *rq, struct sched_dl_entity *dl_se)
572{ 572{
573 int dmiss = dl_time_before(dl_se->deadline, rq_clock(rq)); 573 return (dl_se->runtime <= 0);
574 int rorun = dl_se->runtime <= 0;
575
576 if (!rorun && !dmiss)
577 return 0;
578
579 /*
580 * If we are beyond our current deadline and we are still
581 * executing, then we have already used some of the runtime of
582 * the next instance. Thus, if we do not account that, we are
583 * stealing bandwidth from the system at each deadline miss!
584 */
585 if (dmiss) {
586 dl_se->runtime = rorun ? dl_se->runtime : 0;
587 dl_se->runtime -= rq_clock(rq) - dl_se->deadline;
588 }
589
590 return 1;
591} 574}
592 575
593extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq); 576extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
@@ -826,10 +809,10 @@ enqueue_dl_entity(struct sched_dl_entity *dl_se,
826 * parameters of the task might need updating. Otherwise, 809 * parameters of the task might need updating. Otherwise,
827 * we want a replenishment of its runtime. 810 * we want a replenishment of its runtime.
828 */ 811 */
829 if (!dl_se->dl_new && flags & ENQUEUE_REPLENISH) 812 if (dl_se->dl_new || flags & ENQUEUE_WAKEUP)
830 replenish_dl_entity(dl_se, pi_se);
831 else
832 update_dl_entity(dl_se, pi_se); 813 update_dl_entity(dl_se, pi_se);
814 else if (flags & ENQUEUE_REPLENISH)
815 replenish_dl_entity(dl_se, pi_se);
833 816
834 __enqueue_dl_entity(dl_se); 817 __enqueue_dl_entity(dl_se);
835} 818}
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index df2cdf77f899..40667cbf371b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4005,6 +4005,10 @@ void __start_cfs_bandwidth(struct cfs_bandwidth *cfs_b, bool force)
4005 4005
4006static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) 4006static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
4007{ 4007{
4008 /* init_cfs_bandwidth() was not called */
4009 if (!cfs_b->throttled_cfs_rq.next)
4010 return;
4011
4008 hrtimer_cancel(&cfs_b->period_timer); 4012 hrtimer_cancel(&cfs_b->period_timer);
4009 hrtimer_cancel(&cfs_b->slack_timer); 4013 hrtimer_cancel(&cfs_b->slack_timer);
4010} 4014}
@@ -4424,7 +4428,7 @@ static long effective_load(struct task_group *tg, int cpu, long wl, long wg)
4424 * wl = S * s'_i; see (2) 4428 * wl = S * s'_i; see (2)
4425 */ 4429 */
4426 if (W > 0 && w < W) 4430 if (W > 0 && w < W)
4427 wl = (w * tg->shares) / W; 4431 wl = (w * (long)tg->shares) / W;
4428 else 4432 else
4429 wl = tg->shares; 4433 wl = tg->shares;
4430 4434
diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c
index b0b1c44e923a..3ccf5c2c1320 100644
--- a/kernel/trace/trace_kdb.c
+++ b/kernel/trace/trace_kdb.c
@@ -132,8 +132,8 @@ static int kdb_ftdump(int argc, const char **argv)
132 132
133static __init int kdb_ftrace_register(void) 133static __init int kdb_ftrace_register(void)
134{ 134{
135 kdb_register_repeat("ftdump", kdb_ftdump, "[skip_#lines] [cpu]", 135 kdb_register_flags("ftdump", kdb_ftdump, "[skip_#lines] [cpu]",
136 "Dump ftrace log", 0, KDB_REPEAT_NONE); 136 "Dump ftrace log", 0, KDB_ENABLE_ALWAYS_SAFE);
137 return 0; 137 return 0;
138} 138}
139 139
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
index 358eb81fa28d..c635a107a7de 100644
--- a/lib/Kconfig.kgdb
+++ b/lib/Kconfig.kgdb
@@ -73,6 +73,31 @@ config KGDB_KDB
73 help 73 help
74 KDB frontend for kernel 74 KDB frontend for kernel
75 75
76config KDB_DEFAULT_ENABLE
77 hex "KDB: Select kdb command functions to be enabled by default"
78 depends on KGDB_KDB
79 default 0x1
80 help
81 Specifiers which kdb commands are enabled by default. This may
82 be set to 1 or 0 to enable all commands or disable almost all
83 commands.
84
85 Alternatively the following bitmask applies:
86
87 0x0002 - allow arbitrary reads from memory and symbol lookup
88 0x0004 - allow arbitrary writes to memory
89 0x0008 - allow current register state to be inspected
90 0x0010 - allow current register state to be modified
91 0x0020 - allow passive inspection (backtrace, process list, lsmod)
92 0x0040 - allow flow control management (breakpoint, single step)
93 0x0080 - enable signalling of processes
94 0x0100 - allow machine to be rebooted
95
96 The config option merely sets the default at boot time. Both
97 issuing 'echo X > /sys/module/kdb/parameters/cmd_enable' or
98 setting with kdb.cmd_enable=X kernel command line option will
99 override the default settings.
100
76config KDB_KEYBOARD 101config KDB_KEYBOARD
77 bool "KGDB_KDB: keyboard as input device" 102 bool "KGDB_KDB: keyboard as input device"
78 depends on VT && KGDB_KDB 103 depends on VT && KGDB_KDB
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index 2404d03e251a..03dd576e6773 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -11,6 +11,7 @@
11 * 2 of the Licence, or (at your option) any later version. 11 * 2 of the Licence, or (at your option) any later version.
12 */ 12 */
13//#define DEBUG 13//#define DEBUG
14#include <linux/rcupdate.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
15#include <linux/err.h> 16#include <linux/err.h>
16#include <linux/assoc_array_priv.h> 17#include <linux/assoc_array_priv.h>
diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug
index 56badfc4810a..957d3da53ddd 100644
--- a/mm/Kconfig.debug
+++ b/mm/Kconfig.debug
@@ -14,7 +14,6 @@ config DEBUG_PAGEALLOC
14 depends on !KMEMCHECK 14 depends on !KMEMCHECK
15 select PAGE_EXTENSION 15 select PAGE_EXTENSION
16 select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC 16 select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC
17 select PAGE_GUARD if ARCH_SUPPORTS_DEBUG_PAGEALLOC
18 ---help--- 17 ---help---
19 Unmap pages from the kernel linear mapping after free_pages(). 18 Unmap pages from the kernel linear mapping after free_pages().
20 This results in a large slowdown, but helps to find certain types 19 This results in a large slowdown, but helps to find certain types
@@ -27,13 +26,5 @@ config DEBUG_PAGEALLOC
27 that would result in incorrect warnings of memory corruption after 26 that would result in incorrect warnings of memory corruption after
28 a resume because free pages are not saved to the suspend image. 27 a resume because free pages are not saved to the suspend image.
29 28
30config WANT_PAGE_DEBUG_FLAGS
31 bool
32
33config PAGE_POISONING 29config PAGE_POISONING
34 bool 30 bool
35 select WANT_PAGE_DEBUG_FLAGS
36
37config PAGE_GUARD
38 bool
39 select WANT_PAGE_DEBUG_FLAGS
diff --git a/mm/filemap.c b/mm/filemap.c
index bd8543c6508f..673e4581a2e5 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1046,8 +1046,7 @@ EXPORT_SYMBOL(find_lock_entry);
1046 * @mapping: the address_space to search 1046 * @mapping: the address_space to search
1047 * @offset: the page index 1047 * @offset: the page index
1048 * @fgp_flags: PCG flags 1048 * @fgp_flags: PCG flags
1049 * @cache_gfp_mask: gfp mask to use for the page cache data page allocation 1049 * @gfp_mask: gfp mask to use for the page cache data page allocation
1050 * @radix_gfp_mask: gfp mask to use for radix tree node allocation
1051 * 1050 *
1052 * Looks up the page cache slot at @mapping & @offset. 1051 * Looks up the page cache slot at @mapping & @offset.
1053 * 1052 *
@@ -1056,11 +1055,9 @@ EXPORT_SYMBOL(find_lock_entry);
1056 * FGP_ACCESSED: the page will be marked accessed 1055 * FGP_ACCESSED: the page will be marked accessed
1057 * FGP_LOCK: Page is return locked 1056 * FGP_LOCK: Page is return locked
1058 * FGP_CREAT: If page is not present then a new page is allocated using 1057 * FGP_CREAT: If page is not present then a new page is allocated using
1059 * @cache_gfp_mask and added to the page cache and the VM's LRU 1058 * @gfp_mask and added to the page cache and the VM's LRU
1060 * list. If radix tree nodes are allocated during page cache 1059 * list. The page is returned locked and with an increased
1061 * insertion then @radix_gfp_mask is used. The page is returned 1060 * refcount. Otherwise, %NULL is returned.
1062 * locked and with an increased refcount. Otherwise, %NULL is
1063 * returned.
1064 * 1061 *
1065 * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even 1062 * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even
1066 * if the GFP flags specified for FGP_CREAT are atomic. 1063 * if the GFP flags specified for FGP_CREAT are atomic.
@@ -1068,7 +1065,7 @@ EXPORT_SYMBOL(find_lock_entry);
1068 * If there is a page cache page, it is returned with an increased refcount. 1065 * If there is a page cache page, it is returned with an increased refcount.
1069 */ 1066 */
1070struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset, 1067struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,
1071 int fgp_flags, gfp_t cache_gfp_mask, gfp_t radix_gfp_mask) 1068 int fgp_flags, gfp_t gfp_mask)
1072{ 1069{
1073 struct page *page; 1070 struct page *page;
1074 1071
@@ -1105,13 +1102,11 @@ no_page:
1105 if (!page && (fgp_flags & FGP_CREAT)) { 1102 if (!page && (fgp_flags & FGP_CREAT)) {
1106 int err; 1103 int err;
1107 if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping)) 1104 if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping))
1108 cache_gfp_mask |= __GFP_WRITE; 1105 gfp_mask |= __GFP_WRITE;
1109 if (fgp_flags & FGP_NOFS) { 1106 if (fgp_flags & FGP_NOFS)
1110 cache_gfp_mask &= ~__GFP_FS; 1107 gfp_mask &= ~__GFP_FS;
1111 radix_gfp_mask &= ~__GFP_FS;
1112 }
1113 1108
1114 page = __page_cache_alloc(cache_gfp_mask); 1109 page = __page_cache_alloc(gfp_mask);
1115 if (!page) 1110 if (!page)
1116 return NULL; 1111 return NULL;
1117 1112
@@ -1122,7 +1117,8 @@ no_page:
1122 if (fgp_flags & FGP_ACCESSED) 1117 if (fgp_flags & FGP_ACCESSED)
1123 __SetPageReferenced(page); 1118 __SetPageReferenced(page);
1124 1119
1125 err = add_to_page_cache_lru(page, mapping, offset, radix_gfp_mask); 1120 err = add_to_page_cache_lru(page, mapping, offset,
1121 gfp_mask & GFP_RECLAIM_MASK);
1126 if (unlikely(err)) { 1122 if (unlikely(err)) {
1127 page_cache_release(page); 1123 page_cache_release(page);
1128 page = NULL; 1124 page = NULL;
@@ -2443,8 +2439,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
2443 fgp_flags |= FGP_NOFS; 2439 fgp_flags |= FGP_NOFS;
2444 2440
2445 page = pagecache_get_page(mapping, index, fgp_flags, 2441 page = pagecache_get_page(mapping, index, fgp_flags,
2446 mapping_gfp_mask(mapping), 2442 mapping_gfp_mask(mapping));
2447 GFP_KERNEL);
2448 if (page) 2443 if (page)
2449 wait_for_stable_page(page); 2444 wait_for_stable_page(page);
2450 2445
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index ef91e856c7e4..851924fa5170 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3043,18 +3043,6 @@ static int mem_cgroup_move_swap_account(swp_entry_t entry,
3043 if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) { 3043 if (swap_cgroup_cmpxchg(entry, old_id, new_id) == old_id) {
3044 mem_cgroup_swap_statistics(from, false); 3044 mem_cgroup_swap_statistics(from, false);
3045 mem_cgroup_swap_statistics(to, true); 3045 mem_cgroup_swap_statistics(to, true);
3046 /*
3047 * This function is only called from task migration context now.
3048 * It postpones page_counter and refcount handling till the end
3049 * of task migration(mem_cgroup_clear_mc()) for performance
3050 * improvement. But we cannot postpone css_get(to) because if
3051 * the process that has been moved to @to does swap-in, the
3052 * refcount of @to might be decreased to 0.
3053 *
3054 * We are in attach() phase, so the cgroup is guaranteed to be
3055 * alive, so we can just call css_get().
3056 */
3057 css_get(&to->css);
3058 return 0; 3046 return 0;
3059 } 3047 }
3060 return -EINVAL; 3048 return -EINVAL;
@@ -4679,6 +4667,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
4679 if (parent_css == NULL) { 4667 if (parent_css == NULL) {
4680 root_mem_cgroup = memcg; 4668 root_mem_cgroup = memcg;
4681 page_counter_init(&memcg->memory, NULL); 4669 page_counter_init(&memcg->memory, NULL);
4670 memcg->soft_limit = PAGE_COUNTER_MAX;
4682 page_counter_init(&memcg->memsw, NULL); 4671 page_counter_init(&memcg->memsw, NULL);
4683 page_counter_init(&memcg->kmem, NULL); 4672 page_counter_init(&memcg->kmem, NULL);
4684 } 4673 }
@@ -4724,6 +4713,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
4724 4713
4725 if (parent->use_hierarchy) { 4714 if (parent->use_hierarchy) {
4726 page_counter_init(&memcg->memory, &parent->memory); 4715 page_counter_init(&memcg->memory, &parent->memory);
4716 memcg->soft_limit = PAGE_COUNTER_MAX;
4727 page_counter_init(&memcg->memsw, &parent->memsw); 4717 page_counter_init(&memcg->memsw, &parent->memsw);
4728 page_counter_init(&memcg->kmem, &parent->kmem); 4718 page_counter_init(&memcg->kmem, &parent->kmem);
4729 4719
@@ -4733,6 +4723,7 @@ mem_cgroup_css_online(struct cgroup_subsys_state *css)
4733 */ 4723 */
4734 } else { 4724 } else {
4735 page_counter_init(&memcg->memory, NULL); 4725 page_counter_init(&memcg->memory, NULL);
4726 memcg->soft_limit = PAGE_COUNTER_MAX;
4736 page_counter_init(&memcg->memsw, NULL); 4727 page_counter_init(&memcg->memsw, NULL);
4737 page_counter_init(&memcg->kmem, NULL); 4728 page_counter_init(&memcg->kmem, NULL);
4738 /* 4729 /*
@@ -4807,7 +4798,7 @@ static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
4807 mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX); 4798 mem_cgroup_resize_limit(memcg, PAGE_COUNTER_MAX);
4808 mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX); 4799 mem_cgroup_resize_memsw_limit(memcg, PAGE_COUNTER_MAX);
4809 memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX); 4800 memcg_update_kmem_limit(memcg, PAGE_COUNTER_MAX);
4810 memcg->soft_limit = 0; 4801 memcg->soft_limit = PAGE_COUNTER_MAX;
4811} 4802}
4812 4803
4813#ifdef CONFIG_MMU 4804#ifdef CONFIG_MMU
diff --git a/mm/memory.c b/mm/memory.c
index 649e7d440bd7..c6565f00fb38 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2137,17 +2137,24 @@ reuse:
2137 if (!dirty_page) 2137 if (!dirty_page)
2138 return ret; 2138 return ret;
2139 2139
2140 /*
2141 * Yes, Virginia, this is actually required to prevent a race
2142 * with clear_page_dirty_for_io() from clearing the page dirty
2143 * bit after it clear all dirty ptes, but before a racing
2144 * do_wp_page installs a dirty pte.
2145 *
2146 * do_shared_fault is protected similarly.
2147 */
2148 if (!page_mkwrite) { 2140 if (!page_mkwrite) {
2149 wait_on_page_locked(dirty_page); 2141 struct address_space *mapping;
2150 set_page_dirty_balance(dirty_page); 2142 int dirtied;
2143
2144 lock_page(dirty_page);
2145 dirtied = set_page_dirty(dirty_page);
2146 VM_BUG_ON_PAGE(PageAnon(dirty_page), dirty_page);
2147 mapping = dirty_page->mapping;
2148 unlock_page(dirty_page);
2149
2150 if (dirtied && mapping) {
2151 /*
2152 * Some device drivers do not set page.mapping
2153 * but still dirty their pages
2154 */
2155 balance_dirty_pages_ratelimited(mapping);
2156 }
2157
2151 /* file_update_time outside page_lock */ 2158 /* file_update_time outside page_lock */
2152 if (vma->vm_file) 2159 if (vma->vm_file)
2153 file_update_time(vma->vm_file); 2160 file_update_time(vma->vm_file);
@@ -2378,12 +2385,12 @@ void unmap_mapping_range(struct address_space *mapping,
2378 details.last_index = ULONG_MAX; 2385 details.last_index = ULONG_MAX;
2379 2386
2380 2387
2381 i_mmap_lock_read(mapping); 2388 i_mmap_lock_write(mapping);
2382 if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap))) 2389 if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap)))
2383 unmap_mapping_range_tree(&mapping->i_mmap, &details); 2390 unmap_mapping_range_tree(&mapping->i_mmap, &details);
2384 if (unlikely(!list_empty(&mapping->i_mmap_nonlinear))) 2391 if (unlikely(!list_empty(&mapping->i_mmap_nonlinear)))
2385 unmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details); 2392 unmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details);
2386 i_mmap_unlock_read(mapping); 2393 i_mmap_unlock_write(mapping);
2387} 2394}
2388EXPORT_SYMBOL(unmap_mapping_range); 2395EXPORT_SYMBOL(unmap_mapping_range);
2389 2396
@@ -2593,7 +2600,7 @@ static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned lo
2593 if (prev && prev->vm_end == address) 2600 if (prev && prev->vm_end == address)
2594 return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM; 2601 return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
2595 2602
2596 expand_downwards(vma, address - PAGE_SIZE); 2603 return expand_downwards(vma, address - PAGE_SIZE);
2597 } 2604 }
2598 if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) { 2605 if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
2599 struct vm_area_struct *next = vma->vm_next; 2606 struct vm_area_struct *next = vma->vm_next;
@@ -2602,7 +2609,7 @@ static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned lo
2602 if (next && next->vm_start == address + PAGE_SIZE) 2609 if (next && next->vm_start == address + PAGE_SIZE)
2603 return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM; 2610 return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
2604 2611
2605 expand_upwards(vma, address + PAGE_SIZE); 2612 return expand_upwards(vma, address + PAGE_SIZE);
2606 } 2613 }
2607 return 0; 2614 return 0;
2608} 2615}
diff --git a/mm/mmap.c b/mm/mmap.c
index 7b36aa7cc89a..7f684d5a8087 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -778,10 +778,12 @@ again: remove_next = 1 + (end > next->vm_end);
778 if (exporter && exporter->anon_vma && !importer->anon_vma) { 778 if (exporter && exporter->anon_vma && !importer->anon_vma) {
779 int error; 779 int error;
780 780
781 importer->anon_vma = exporter->anon_vma;
781 error = anon_vma_clone(importer, exporter); 782 error = anon_vma_clone(importer, exporter);
782 if (error) 783 if (error) {
784 importer->anon_vma = NULL;
783 return error; 785 return error;
784 importer->anon_vma = exporter->anon_vma; 786 }
785 } 787 }
786 } 788 }
787 789
@@ -2099,14 +2101,17 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
2099{ 2101{
2100 struct mm_struct *mm = vma->vm_mm; 2102 struct mm_struct *mm = vma->vm_mm;
2101 struct rlimit *rlim = current->signal->rlim; 2103 struct rlimit *rlim = current->signal->rlim;
2102 unsigned long new_start; 2104 unsigned long new_start, actual_size;
2103 2105
2104 /* address space limit tests */ 2106 /* address space limit tests */
2105 if (!may_expand_vm(mm, grow)) 2107 if (!may_expand_vm(mm, grow))
2106 return -ENOMEM; 2108 return -ENOMEM;
2107 2109
2108 /* Stack limit test */ 2110 /* Stack limit test */
2109 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur)) 2111 actual_size = size;
2112 if (size && (vma->vm_flags & (VM_GROWSUP | VM_GROWSDOWN)))
2113 actual_size -= PAGE_SIZE;
2114 if (actual_size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
2110 return -ENOMEM; 2115 return -ENOMEM;
2111 2116
2112 /* mlock limit tests */ 2117 /* mlock limit tests */
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index d5d81f5384d1..6f4335238e33 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1541,16 +1541,6 @@ pause:
1541 bdi_start_background_writeback(bdi); 1541 bdi_start_background_writeback(bdi);
1542} 1542}
1543 1543
1544void set_page_dirty_balance(struct page *page)
1545{
1546 if (set_page_dirty(page)) {
1547 struct address_space *mapping = page_mapping(page);
1548
1549 if (mapping)
1550 balance_dirty_pages_ratelimited(mapping);
1551 }
1552}
1553
1554static DEFINE_PER_CPU(int, bdp_ratelimits); 1544static DEFINE_PER_CPU(int, bdp_ratelimits);
1555 1545
1556/* 1546/*
@@ -2123,32 +2113,25 @@ EXPORT_SYMBOL(account_page_dirtied);
2123 * page dirty in that case, but not all the buffers. This is a "bottom-up" 2113 * page dirty in that case, but not all the buffers. This is a "bottom-up"
2124 * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying. 2114 * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying.
2125 * 2115 *
2126 * Most callers have locked the page, which pins the address_space in memory. 2116 * The caller must ensure this doesn't race with truncation. Most will simply
2127 * But zap_pte_range() does not lock the page, however in that case the 2117 * hold the page lock, but e.g. zap_pte_range() calls with the page mapped and
2128 * mapping is pinned by the vma's ->vm_file reference. 2118 * the pte lock held, which also locks out truncation.
2129 *
2130 * We take care to handle the case where the page was truncated from the
2131 * mapping by re-checking page_mapping() inside tree_lock.
2132 */ 2119 */
2133int __set_page_dirty_nobuffers(struct page *page) 2120int __set_page_dirty_nobuffers(struct page *page)
2134{ 2121{
2135 if (!TestSetPageDirty(page)) { 2122 if (!TestSetPageDirty(page)) {
2136 struct address_space *mapping = page_mapping(page); 2123 struct address_space *mapping = page_mapping(page);
2137 struct address_space *mapping2;
2138 unsigned long flags; 2124 unsigned long flags;
2139 2125
2140 if (!mapping) 2126 if (!mapping)
2141 return 1; 2127 return 1;
2142 2128
2143 spin_lock_irqsave(&mapping->tree_lock, flags); 2129 spin_lock_irqsave(&mapping->tree_lock, flags);
2144 mapping2 = page_mapping(page); 2130 BUG_ON(page_mapping(page) != mapping);
2145 if (mapping2) { /* Race with truncate? */ 2131 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
2146 BUG_ON(mapping2 != mapping); 2132 account_page_dirtied(page, mapping);
2147 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); 2133 radix_tree_tag_set(&mapping->page_tree, page_index(page),
2148 account_page_dirtied(page, mapping); 2134 PAGECACHE_TAG_DIRTY);
2149 radix_tree_tag_set(&mapping->page_tree,
2150 page_index(page), PAGECACHE_TAG_DIRTY);
2151 }
2152 spin_unlock_irqrestore(&mapping->tree_lock, flags); 2135 spin_unlock_irqrestore(&mapping->tree_lock, flags);
2153 if (mapping->host) { 2136 if (mapping->host) {
2154 /* !PageAnon && !swapper_space */ 2137 /* !PageAnon && !swapper_space */
@@ -2305,12 +2288,10 @@ int clear_page_dirty_for_io(struct page *page)
2305 /* 2288 /*
2306 * We carefully synchronise fault handlers against 2289 * We carefully synchronise fault handlers against
2307 * installing a dirty pte and marking the page dirty 2290 * installing a dirty pte and marking the page dirty
2308 * at this point. We do this by having them hold the 2291 * at this point. We do this by having them hold the
2309 * page lock at some point after installing their 2292 * page lock while dirtying the page, and pages are
2310 * pte, but before marking the page dirty. 2293 * always locked coming in here, so we get the desired
2311 * Pages are always locked coming in here, so we get 2294 * exclusion.
2312 * the desired exclusion. See mm/memory.c:do_wp_page()
2313 * for more comments.
2314 */ 2295 */
2315 if (TestClearPageDirty(page)) { 2296 if (TestClearPageDirty(page)) {
2316 dec_zone_page_state(page, NR_FILE_DIRTY); 2297 dec_zone_page_state(page, NR_FILE_DIRTY);
diff --git a/mm/rmap.c b/mm/rmap.c
index c5bc241127b2..71cd5bd0c17d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -72,6 +72,8 @@ static inline struct anon_vma *anon_vma_alloc(void)
72 anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL); 72 anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
73 if (anon_vma) { 73 if (anon_vma) {
74 atomic_set(&anon_vma->refcount, 1); 74 atomic_set(&anon_vma->refcount, 1);
75 anon_vma->degree = 1; /* Reference for first vma */
76 anon_vma->parent = anon_vma;
75 /* 77 /*
76 * Initialise the anon_vma root to point to itself. If called 78 * Initialise the anon_vma root to point to itself. If called
77 * from fork, the root will be reset to the parents anon_vma. 79 * from fork, the root will be reset to the parents anon_vma.
@@ -188,6 +190,8 @@ int anon_vma_prepare(struct vm_area_struct *vma)
188 if (likely(!vma->anon_vma)) { 190 if (likely(!vma->anon_vma)) {
189 vma->anon_vma = anon_vma; 191 vma->anon_vma = anon_vma;
190 anon_vma_chain_link(vma, avc, anon_vma); 192 anon_vma_chain_link(vma, avc, anon_vma);
193 /* vma reference or self-parent link for new root */
194 anon_vma->degree++;
191 allocated = NULL; 195 allocated = NULL;
192 avc = NULL; 196 avc = NULL;
193 } 197 }
@@ -236,6 +240,14 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
236/* 240/*
237 * Attach the anon_vmas from src to dst. 241 * Attach the anon_vmas from src to dst.
238 * Returns 0 on success, -ENOMEM on failure. 242 * Returns 0 on success, -ENOMEM on failure.
243 *
244 * If dst->anon_vma is NULL this function tries to find and reuse existing
245 * anon_vma which has no vmas and only one child anon_vma. This prevents
246 * degradation of anon_vma hierarchy to endless linear chain in case of
247 * constantly forking task. On the other hand, an anon_vma with more than one
248 * child isn't reused even if there was no alive vma, thus rmap walker has a
249 * good chance of avoiding scanning the whole hierarchy when it searches where
250 * page is mapped.
239 */ 251 */
240int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src) 252int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
241{ 253{
@@ -256,7 +268,21 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
256 anon_vma = pavc->anon_vma; 268 anon_vma = pavc->anon_vma;
257 root = lock_anon_vma_root(root, anon_vma); 269 root = lock_anon_vma_root(root, anon_vma);
258 anon_vma_chain_link(dst, avc, anon_vma); 270 anon_vma_chain_link(dst, avc, anon_vma);
271
272 /*
273 * Reuse existing anon_vma if its degree lower than two,
274 * that means it has no vma and only one anon_vma child.
275 *
276 * Do not chose parent anon_vma, otherwise first child
277 * will always reuse it. Root anon_vma is never reused:
278 * it has self-parent reference and at least one child.
279 */
280 if (!dst->anon_vma && anon_vma != src->anon_vma &&
281 anon_vma->degree < 2)
282 dst->anon_vma = anon_vma;
259 } 283 }
284 if (dst->anon_vma)
285 dst->anon_vma->degree++;
260 unlock_anon_vma_root(root); 286 unlock_anon_vma_root(root);
261 return 0; 287 return 0;
262 288
@@ -280,6 +306,9 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
280 if (!pvma->anon_vma) 306 if (!pvma->anon_vma)
281 return 0; 307 return 0;
282 308
309 /* Drop inherited anon_vma, we'll reuse existing or allocate new. */
310 vma->anon_vma = NULL;
311
283 /* 312 /*
284 * First, attach the new VMA to the parent VMA's anon_vmas, 313 * First, attach the new VMA to the parent VMA's anon_vmas,
285 * so rmap can find non-COWed pages in child processes. 314 * so rmap can find non-COWed pages in child processes.
@@ -288,6 +317,10 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
288 if (error) 317 if (error)
289 return error; 318 return error;
290 319
320 /* An existing anon_vma has been reused, all done then. */
321 if (vma->anon_vma)
322 return 0;
323
291 /* Then add our own anon_vma. */ 324 /* Then add our own anon_vma. */
292 anon_vma = anon_vma_alloc(); 325 anon_vma = anon_vma_alloc();
293 if (!anon_vma) 326 if (!anon_vma)
@@ -301,6 +334,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
301 * lock any of the anon_vmas in this anon_vma tree. 334 * lock any of the anon_vmas in this anon_vma tree.
302 */ 335 */
303 anon_vma->root = pvma->anon_vma->root; 336 anon_vma->root = pvma->anon_vma->root;
337 anon_vma->parent = pvma->anon_vma;
304 /* 338 /*
305 * With refcounts, an anon_vma can stay around longer than the 339 * With refcounts, an anon_vma can stay around longer than the
306 * process it belongs to. The root anon_vma needs to be pinned until 340 * process it belongs to. The root anon_vma needs to be pinned until
@@ -311,6 +345,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
311 vma->anon_vma = anon_vma; 345 vma->anon_vma = anon_vma;
312 anon_vma_lock_write(anon_vma); 346 anon_vma_lock_write(anon_vma);
313 anon_vma_chain_link(vma, avc, anon_vma); 347 anon_vma_chain_link(vma, avc, anon_vma);
348 anon_vma->parent->degree++;
314 anon_vma_unlock_write(anon_vma); 349 anon_vma_unlock_write(anon_vma);
315 350
316 return 0; 351 return 0;
@@ -341,12 +376,16 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
341 * Leave empty anon_vmas on the list - we'll need 376 * Leave empty anon_vmas on the list - we'll need
342 * to free them outside the lock. 377 * to free them outside the lock.
343 */ 378 */
344 if (RB_EMPTY_ROOT(&anon_vma->rb_root)) 379 if (RB_EMPTY_ROOT(&anon_vma->rb_root)) {
380 anon_vma->parent->degree--;
345 continue; 381 continue;
382 }
346 383
347 list_del(&avc->same_vma); 384 list_del(&avc->same_vma);
348 anon_vma_chain_free(avc); 385 anon_vma_chain_free(avc);
349 } 386 }
387 if (vma->anon_vma)
388 vma->anon_vma->degree--;
350 unlock_anon_vma_root(root); 389 unlock_anon_vma_root(root);
351 390
352 /* 391 /*
@@ -357,6 +396,7 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
357 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) { 396 list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {
358 struct anon_vma *anon_vma = avc->anon_vma; 397 struct anon_vma *anon_vma = avc->anon_vma;
359 398
399 BUG_ON(anon_vma->degree);
360 put_anon_vma(anon_vma); 400 put_anon_vma(anon_vma);
361 401
362 list_del(&avc->same_vma); 402 list_del(&avc->same_vma);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index bd9a72bc4a1b..ab2505c3ef54 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2921,18 +2921,20 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, long remaining,
2921 return false; 2921 return false;
2922 2922
2923 /* 2923 /*
2924 * There is a potential race between when kswapd checks its watermarks 2924 * The throttled processes are normally woken up in balance_pgdat() as
2925 * and a process gets throttled. There is also a potential race if 2925 * soon as pfmemalloc_watermark_ok() is true. But there is a potential
2926 * processes get throttled, kswapd wakes, a large process exits therby 2926 * race between when kswapd checks the watermarks and a process gets
2927 * balancing the zones that causes kswapd to miss a wakeup. If kswapd 2927 * throttled. There is also a potential race if processes get
2928 * is going to sleep, no process should be sleeping on pfmemalloc_wait 2928 * throttled, kswapd wakes, a large process exits thereby balancing the
2929 * so wake them now if necessary. If necessary, processes will wake 2929 * zones, which causes kswapd to exit balance_pgdat() before reaching
2930 * kswapd and get throttled again 2930 * the wake up checks. If kswapd is going to sleep, no process should
2931 * be sleeping on pfmemalloc_wait, so wake them now if necessary. If
2932 * the wake up is premature, processes will wake kswapd and get
2933 * throttled again. The difference from wake ups in balance_pgdat() is
2934 * that here we are under prepare_to_wait().
2931 */ 2935 */
2932 if (waitqueue_active(&pgdat->pfmemalloc_wait)) { 2936 if (waitqueue_active(&pgdat->pfmemalloc_wait))
2933 wake_up(&pgdat->pfmemalloc_wait); 2937 wake_up_all(&pgdat->pfmemalloc_wait);
2934 return false;
2935 }
2936 2938
2937 return pgdat_balanced(pgdat, order, classzone_idx); 2939 return pgdat_balanced(pgdat, order, classzone_idx);
2938} 2940}
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index fc1835c6bb40..00f9e144cc97 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -251,7 +251,7 @@ batadv_frag_merge_packets(struct hlist_head *chain, struct sk_buff *skb)
251 kfree(entry); 251 kfree(entry);
252 252
253 /* Make room for the rest of the fragments. */ 253 /* Make room for the rest of the fragments. */
254 if (pskb_expand_head(skb_out, 0, size - skb->len, GFP_ATOMIC) < 0) { 254 if (pskb_expand_head(skb_out, 0, size - skb_out->len, GFP_ATOMIC) < 0) {
255 kfree_skb(skb_out); 255 kfree_skb(skb_out);
256 skb_out = NULL; 256 skb_out = NULL;
257 goto free; 257 goto free;
@@ -434,7 +434,7 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
434 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE 434 * fragments larger than BATADV_FRAG_MAX_FRAG_SIZE
435 */ 435 */
436 mtu = min_t(unsigned, mtu, BATADV_FRAG_MAX_FRAG_SIZE); 436 mtu = min_t(unsigned, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
437 max_fragment_size = (mtu - header_size - ETH_HLEN); 437 max_fragment_size = mtu - header_size;
438 max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS; 438 max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS;
439 439
440 /* Don't even try to fragment, if we need more than 16 fragments */ 440 /* Don't even try to fragment, if we need more than 16 fragments */
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 90cff585b37d..e0bcf9e84273 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -810,7 +810,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
810 goto out; 810 goto out;
811 811
812 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node); 812 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node);
813 if (!gw_node->bandwidth_down == 0) 813 if (!gw_node)
814 goto out; 814 goto out;
815 815
816 switch (atomic_read(&bat_priv->gw_mode)) { 816 switch (atomic_read(&bat_priv->gw_mode)) {
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index ab6bb2af1d45..b24e4bb64fb5 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -685,11 +685,13 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
685 if (orig_initialized) 685 if (orig_initialized)
686 atomic_dec(&bat_priv->mcast.num_disabled); 686 atomic_dec(&bat_priv->mcast.num_disabled);
687 orig->capabilities |= BATADV_ORIG_CAPA_HAS_MCAST; 687 orig->capabilities |= BATADV_ORIG_CAPA_HAS_MCAST;
688 /* If mcast support is being switched off increase the disabled 688 /* If mcast support is being switched off or if this is an initial
689 * mcast node counter. 689 * OGM without mcast support then increase the disabled mcast
690 * node counter.
690 */ 691 */
691 } else if (!orig_mcast_enabled && 692 } else if (!orig_mcast_enabled &&
692 orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) { 693 (orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST ||
694 !orig_initialized)) {
693 atomic_inc(&bat_priv->mcast.num_disabled); 695 atomic_inc(&bat_priv->mcast.num_disabled);
694 orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_MCAST; 696 orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_MCAST;
695 } 697 }
@@ -738,7 +740,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig)
738{ 740{
739 struct batadv_priv *bat_priv = orig->bat_priv; 741 struct batadv_priv *bat_priv = orig->bat_priv;
740 742
741 if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST)) 743 if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) &&
744 orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST)
742 atomic_dec(&bat_priv->mcast.num_disabled); 745 atomic_dec(&bat_priv->mcast.num_disabled);
743 746
744 batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS); 747 batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index 8d04d174669e..fab47f1f3ef9 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -133,7 +133,7 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv)
133 if (!bat_priv->nc.decoding_hash) 133 if (!bat_priv->nc.decoding_hash)
134 goto err; 134 goto err;
135 135
136 batadv_hash_set_lock_class(bat_priv->nc.coding_hash, 136 batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,
137 &batadv_nc_decoding_hash_lock_class_key); 137 &batadv_nc_decoding_hash_lock_class_key);
138 138
139 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker); 139 INIT_DELAYED_WORK(&bat_priv->nc.work, batadv_nc_worker);
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 6a484514cd3e..bea8198d0198 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -570,9 +570,6 @@ static void batadv_orig_node_free_rcu(struct rcu_head *rcu)
570 570
571 batadv_frag_purge_orig(orig_node, NULL); 571 batadv_frag_purge_orig(orig_node, NULL);
572 572
573 batadv_tt_global_del_orig(orig_node->bat_priv, orig_node, -1,
574 "originator timed out");
575
576 if (orig_node->bat_priv->bat_algo_ops->bat_orig_free) 573 if (orig_node->bat_priv->bat_algo_ops->bat_orig_free)
577 orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node); 574 orig_node->bat_priv->bat_algo_ops->bat_orig_free(orig_node);
578 575
@@ -678,6 +675,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
678 atomic_set(&orig_node->last_ttvn, 0); 675 atomic_set(&orig_node->last_ttvn, 0);
679 orig_node->tt_buff = NULL; 676 orig_node->tt_buff = NULL;
680 orig_node->tt_buff_len = 0; 677 orig_node->tt_buff_len = 0;
678 orig_node->last_seen = jiffies;
681 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); 679 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS);
682 orig_node->bcast_seqno_reset = reset_time; 680 orig_node->bcast_seqno_reset = reset_time;
683#ifdef CONFIG_BATMAN_ADV_MCAST 681#ifdef CONFIG_BATMAN_ADV_MCAST
@@ -977,6 +975,9 @@ static void _batadv_purge_orig(struct batadv_priv *bat_priv)
977 if (batadv_purge_orig_node(bat_priv, orig_node)) { 975 if (batadv_purge_orig_node(bat_priv, orig_node)) {
978 batadv_gw_node_delete(bat_priv, orig_node); 976 batadv_gw_node_delete(bat_priv, orig_node);
979 hlist_del_rcu(&orig_node->hash_entry); 977 hlist_del_rcu(&orig_node->hash_entry);
978 batadv_tt_global_del_orig(orig_node->bat_priv,
979 orig_node, -1,
980 "originator timed out");
980 batadv_orig_node_free_ref(orig_node); 981 batadv_orig_node_free_ref(orig_node);
981 continue; 982 continue;
982 } 983 }
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 35f76f2f7824..6648f321864d 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -443,11 +443,13 @@ batadv_find_router(struct batadv_priv *bat_priv,
443 443
444 router = batadv_orig_router_get(orig_node, recv_if); 444 router = batadv_orig_router_get(orig_node, recv_if);
445 445
446 if (!router)
447 return router;
448
446 /* only consider bonding for recv_if == BATADV_IF_DEFAULT (first hop) 449 /* only consider bonding for recv_if == BATADV_IF_DEFAULT (first hop)
447 * and if activated. 450 * and if activated.
448 */ 451 */
449 if (recv_if == BATADV_IF_DEFAULT || !atomic_read(&bat_priv->bonding) || 452 if (!(recv_if == BATADV_IF_DEFAULT && atomic_read(&bat_priv->bonding)))
450 !router)
451 return router; 453 return router;
452 454
453 /* bonding: loop through the list of possible routers found 455 /* bonding: loop through the list of possible routers found
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 76617be1e797..c989253737f0 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -390,7 +390,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
390 390
391drop: 391drop:
392 dev->stats.rx_dropped++; 392 dev->stats.rx_dropped++;
393 kfree_skb(skb);
394 return NET_RX_DROP; 393 return NET_RX_DROP;
395} 394}
396 395
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 85bcc21e84d2..ce82722d049b 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -533,6 +533,9 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
533 533
534 BT_DBG(""); 534 BT_DBG("");
535 535
536 if (!l2cap_is_socket(sock))
537 return -EBADFD;
538
536 baswap((void *) dst, &l2cap_pi(sock->sk)->chan->dst); 539 baswap((void *) dst, &l2cap_pi(sock->sk)->chan->dst);
537 baswap((void *) src, &l2cap_pi(sock->sk)->chan->src); 540 baswap((void *) src, &l2cap_pi(sock->sk)->chan->src);
538 541
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 67fe5e84e68f..278a194e6af4 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -334,6 +334,9 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
334 334
335 BT_DBG(""); 335 BT_DBG("");
336 336
337 if (!l2cap_is_socket(sock))
338 return -EBADFD;
339
337 session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); 340 session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
338 if (!session) 341 if (!session)
339 return -ENOMEM; 342 return -ENOMEM;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 39a5c8a01726..3f2e8b830cbd 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -242,7 +242,8 @@ static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
242 if (rp->status) 242 if (rp->status)
243 return; 243 return;
244 244
245 if (test_bit(HCI_SETUP, &hdev->dev_flags)) 245 if (test_bit(HCI_SETUP, &hdev->dev_flags) ||
246 test_bit(HCI_CONFIG, &hdev->dev_flags))
246 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH); 247 memcpy(hdev->dev_name, rp->name, HCI_MAX_NAME_LENGTH);
247} 248}
248 249
@@ -509,7 +510,8 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
509 if (rp->status) 510 if (rp->status)
510 return; 511 return;
511 512
512 if (test_bit(HCI_SETUP, &hdev->dev_flags)) { 513 if (test_bit(HCI_SETUP, &hdev->dev_flags) ||
514 test_bit(HCI_CONFIG, &hdev->dev_flags)) {
513 hdev->hci_ver = rp->hci_ver; 515 hdev->hci_ver = rp->hci_ver;
514 hdev->hci_rev = __le16_to_cpu(rp->hci_rev); 516 hdev->hci_rev = __le16_to_cpu(rp->hci_rev);
515 hdev->lmp_ver = rp->lmp_ver; 517 hdev->lmp_ver = rp->lmp_ver;
@@ -528,7 +530,8 @@ static void hci_cc_read_local_commands(struct hci_dev *hdev,
528 if (rp->status) 530 if (rp->status)
529 return; 531 return;
530 532
531 if (test_bit(HCI_SETUP, &hdev->dev_flags)) 533 if (test_bit(HCI_SETUP, &hdev->dev_flags) ||
534 test_bit(HCI_CONFIG, &hdev->dev_flags))
532 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands)); 535 memcpy(hdev->commands, rp->commands, sizeof(hdev->commands));
533} 536}
534 537
@@ -2194,7 +2197,12 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
2194 return; 2197 return;
2195 } 2198 }
2196 2199
2197 if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags) && 2200 /* Require HCI_CONNECTABLE or a whitelist entry to accept the
2201 * connection. These features are only touched through mgmt so
2202 * only do the checks if HCI_MGMT is set.
2203 */
2204 if (test_bit(HCI_MGMT, &hdev->dev_flags) &&
2205 !test_bit(HCI_CONNECTABLE, &hdev->dev_flags) &&
2198 !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr, 2206 !hci_bdaddr_list_lookup(&hdev->whitelist, &ev->bdaddr,
2199 BDADDR_BREDR)) { 2207 BDADDR_BREDR)) {
2200 hci_reject_conn(hdev, &ev->bdaddr); 2208 hci_reject_conn(hdev, &ev->bdaddr);
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index cc25d0b74b36..07348e142f16 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -1314,13 +1314,14 @@ int hidp_connection_add(struct hidp_connadd_req *req,
1314{ 1314{
1315 struct hidp_session *session; 1315 struct hidp_session *session;
1316 struct l2cap_conn *conn; 1316 struct l2cap_conn *conn;
1317 struct l2cap_chan *chan = l2cap_pi(ctrl_sock->sk)->chan; 1317 struct l2cap_chan *chan;
1318 int ret; 1318 int ret;
1319 1319
1320 ret = hidp_verify_sockets(ctrl_sock, intr_sock); 1320 ret = hidp_verify_sockets(ctrl_sock, intr_sock);
1321 if (ret) 1321 if (ret)
1322 return ret; 1322 return ret;
1323 1323
1324 chan = l2cap_pi(ctrl_sock->sk)->chan;
1324 conn = NULL; 1325 conn = NULL;
1325 l2cap_chan_lock(chan); 1326 l2cap_chan_lock(chan);
1326 if (chan->conn) 1327 if (chan->conn)
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index 15845814a0f2..ba6eb17226da 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -676,7 +676,7 @@ static int calcu_signature(struct ceph_x_authorizer *au,
676 int ret; 676 int ret;
677 char tmp_enc[40]; 677 char tmp_enc[40];
678 __le32 tmp[5] = { 678 __le32 tmp[5] = {
679 16u, msg->hdr.crc, msg->footer.front_crc, 679 cpu_to_le32(16), msg->hdr.crc, msg->footer.front_crc,
680 msg->footer.middle_crc, msg->footer.data_crc, 680 msg->footer.middle_crc, msg->footer.data_crc,
681 }; 681 };
682 ret = ceph_x_encrypt(&au->session_key, &tmp, sizeof(tmp), 682 ret = ceph_x_encrypt(&au->session_key, &tmp, sizeof(tmp),
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index a83062ceeec9..f2148e22b148 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -717,7 +717,7 @@ static int get_poolop_reply_buf(const char *src, size_t src_len,
717 if (src_len != sizeof(u32) + dst_len) 717 if (src_len != sizeof(u32) + dst_len)
718 return -EINVAL; 718 return -EINVAL;
719 719
720 buf_len = le32_to_cpu(*(u32 *)src); 720 buf_len = le32_to_cpu(*(__le32 *)src);
721 if (buf_len != dst_len) 721 if (buf_len != dst_len)
722 return -EINVAL; 722 return -EINVAL;
723 723
diff --git a/net/core/dev.c b/net/core/dev.c
index f411c28d0a66..683d493aa1bf 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1694,6 +1694,7 @@ int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
1694 1694
1695 skb_scrub_packet(skb, true); 1695 skb_scrub_packet(skb, true);
1696 skb->protocol = eth_type_trans(skb, dev); 1696 skb->protocol = eth_type_trans(skb, dev);
1697 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
1697 1698
1698 return 0; 1699 return 0;
1699} 1700}
@@ -2522,7 +2523,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
2522/* If MPLS offload request, verify we are testing hardware MPLS features 2523/* If MPLS offload request, verify we are testing hardware MPLS features
2523 * instead of standard features for the netdev. 2524 * instead of standard features for the netdev.
2524 */ 2525 */
2525#ifdef CONFIG_NET_MPLS_GSO 2526#if IS_ENABLED(CONFIG_NET_MPLS_GSO)
2526static netdev_features_t net_mpls_features(struct sk_buff *skb, 2527static netdev_features_t net_mpls_features(struct sk_buff *skb,
2527 netdev_features_t features, 2528 netdev_features_t features,
2528 __be16 type) 2529 __be16 type)
@@ -2562,7 +2563,7 @@ static netdev_features_t harmonize_features(struct sk_buff *skb,
2562 2563
2563netdev_features_t netif_skb_features(struct sk_buff *skb) 2564netdev_features_t netif_skb_features(struct sk_buff *skb)
2564{ 2565{
2565 const struct net_device *dev = skb->dev; 2566 struct net_device *dev = skb->dev;
2566 netdev_features_t features = dev->features; 2567 netdev_features_t features = dev->features;
2567 u16 gso_segs = skb_shinfo(skb)->gso_segs; 2568 u16 gso_segs = skb_shinfo(skb)->gso_segs;
2568 __be16 protocol = skb->protocol; 2569 __be16 protocol = skb->protocol;
@@ -2570,11 +2571,21 @@ netdev_features_t netif_skb_features(struct sk_buff *skb)
2570 if (gso_segs > dev->gso_max_segs || gso_segs < dev->gso_min_segs) 2571 if (gso_segs > dev->gso_max_segs || gso_segs < dev->gso_min_segs)
2571 features &= ~NETIF_F_GSO_MASK; 2572 features &= ~NETIF_F_GSO_MASK;
2572 2573
2573 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { 2574 /* If encapsulation offload request, verify we are testing
2574 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2575 * hardware encapsulation features instead of standard
2575 protocol = veh->h_vlan_encapsulated_proto; 2576 * features for the netdev
2576 } else if (!vlan_tx_tag_present(skb)) { 2577 */
2577 return harmonize_features(skb, features); 2578 if (skb->encapsulation)
2579 features &= dev->hw_enc_features;
2580
2581 if (!vlan_tx_tag_present(skb)) {
2582 if (unlikely(protocol == htons(ETH_P_8021Q) ||
2583 protocol == htons(ETH_P_8021AD))) {
2584 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
2585 protocol = veh->h_vlan_encapsulated_proto;
2586 } else {
2587 goto finalize;
2588 }
2578 } 2589 }
2579 2590
2580 features = netdev_intersect_features(features, 2591 features = netdev_intersect_features(features,
@@ -2591,6 +2602,11 @@ netdev_features_t netif_skb_features(struct sk_buff *skb)
2591 NETIF_F_HW_VLAN_CTAG_TX | 2602 NETIF_F_HW_VLAN_CTAG_TX |
2592 NETIF_F_HW_VLAN_STAG_TX); 2603 NETIF_F_HW_VLAN_STAG_TX);
2593 2604
2605finalize:
2606 if (dev->netdev_ops->ndo_features_check)
2607 features &= dev->netdev_ops->ndo_features_check(skb, dev,
2608 features);
2609
2594 return harmonize_features(skb, features); 2610 return harmonize_features(skb, features);
2595} 2611}
2596EXPORT_SYMBOL(netif_skb_features); 2612EXPORT_SYMBOL(netif_skb_features);
@@ -2661,19 +2677,12 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
2661 if (unlikely(!skb)) 2677 if (unlikely(!skb))
2662 goto out_null; 2678 goto out_null;
2663 2679
2664 /* If encapsulation offload request, verify we are testing
2665 * hardware encapsulation features instead of standard
2666 * features for the netdev
2667 */
2668 if (skb->encapsulation)
2669 features &= dev->hw_enc_features;
2670
2671 if (netif_needs_gso(dev, skb, features)) { 2680 if (netif_needs_gso(dev, skb, features)) {
2672 struct sk_buff *segs; 2681 struct sk_buff *segs;
2673 2682
2674 segs = skb_gso_segment(skb, features); 2683 segs = skb_gso_segment(skb, features);
2675 if (IS_ERR(segs)) { 2684 if (IS_ERR(segs)) {
2676 segs = NULL; 2685 goto out_kfree_skb;
2677 } else if (segs) { 2686 } else if (segs) {
2678 consume_skb(skb); 2687 consume_skb(skb);
2679 skb = segs; 2688 skb = segs;
@@ -4557,6 +4566,68 @@ void netif_napi_del(struct napi_struct *napi)
4557} 4566}
4558EXPORT_SYMBOL(netif_napi_del); 4567EXPORT_SYMBOL(netif_napi_del);
4559 4568
4569static int napi_poll(struct napi_struct *n, struct list_head *repoll)
4570{
4571 void *have;
4572 int work, weight;
4573
4574 list_del_init(&n->poll_list);
4575
4576 have = netpoll_poll_lock(n);
4577
4578 weight = n->weight;
4579
4580 /* This NAPI_STATE_SCHED test is for avoiding a race
4581 * with netpoll's poll_napi(). Only the entity which
4582 * obtains the lock and sees NAPI_STATE_SCHED set will
4583 * actually make the ->poll() call. Therefore we avoid
4584 * accidentally calling ->poll() when NAPI is not scheduled.
4585 */
4586 work = 0;
4587 if (test_bit(NAPI_STATE_SCHED, &n->state)) {
4588 work = n->poll(n, weight);
4589 trace_napi_poll(n);
4590 }
4591
4592 WARN_ON_ONCE(work > weight);
4593
4594 if (likely(work < weight))
4595 goto out_unlock;
4596
4597 /* Drivers must not modify the NAPI state if they
4598 * consume the entire weight. In such cases this code
4599 * still "owns" the NAPI instance and therefore can
4600 * move the instance around on the list at-will.
4601 */
4602 if (unlikely(napi_disable_pending(n))) {
4603 napi_complete(n);
4604 goto out_unlock;
4605 }
4606
4607 if (n->gro_list) {
4608 /* flush too old packets
4609 * If HZ < 1000, flush all packets.
4610 */
4611 napi_gro_flush(n, HZ >= 1000);
4612 }
4613
4614 /* Some drivers may have called napi_schedule
4615 * prior to exhausting their budget.
4616 */
4617 if (unlikely(!list_empty(&n->poll_list))) {
4618 pr_warn_once("%s: Budget exhausted after napi rescheduled\n",
4619 n->dev ? n->dev->name : "backlog");
4620 goto out_unlock;
4621 }
4622
4623 list_add_tail(&n->poll_list, repoll);
4624
4625out_unlock:
4626 netpoll_poll_unlock(have);
4627
4628 return work;
4629}
4630
4560static void net_rx_action(struct softirq_action *h) 4631static void net_rx_action(struct softirq_action *h)
4561{ 4632{
4562 struct softnet_data *sd = this_cpu_ptr(&softnet_data); 4633 struct softnet_data *sd = this_cpu_ptr(&softnet_data);
@@ -4564,74 +4635,34 @@ static void net_rx_action(struct softirq_action *h)
4564 int budget = netdev_budget; 4635 int budget = netdev_budget;
4565 LIST_HEAD(list); 4636 LIST_HEAD(list);
4566 LIST_HEAD(repoll); 4637 LIST_HEAD(repoll);
4567 void *have;
4568 4638
4569 local_irq_disable(); 4639 local_irq_disable();
4570 list_splice_init(&sd->poll_list, &list); 4640 list_splice_init(&sd->poll_list, &list);
4571 local_irq_enable(); 4641 local_irq_enable();
4572 4642
4573 while (!list_empty(&list)) { 4643 for (;;) {
4574 struct napi_struct *n; 4644 struct napi_struct *n;
4575 int work, weight;
4576
4577 /* If softirq window is exhausted then punt.
4578 * Allow this to run for 2 jiffies since which will allow
4579 * an average latency of 1.5/HZ.
4580 */
4581 if (unlikely(budget <= 0 || time_after_eq(jiffies, time_limit)))
4582 goto softnet_break;
4583
4584
4585 n = list_first_entry(&list, struct napi_struct, poll_list);
4586 list_del_init(&n->poll_list);
4587 4645
4588 have = netpoll_poll_lock(n); 4646 if (list_empty(&list)) {
4589 4647 if (!sd_has_rps_ipi_waiting(sd) && list_empty(&repoll))
4590 weight = n->weight; 4648 return;
4591 4649 break;
4592 /* This NAPI_STATE_SCHED test is for avoiding a race
4593 * with netpoll's poll_napi(). Only the entity which
4594 * obtains the lock and sees NAPI_STATE_SCHED set will
4595 * actually make the ->poll() call. Therefore we avoid
4596 * accidentally calling ->poll() when NAPI is not scheduled.
4597 */
4598 work = 0;
4599 if (test_bit(NAPI_STATE_SCHED, &n->state)) {
4600 work = n->poll(n, weight);
4601 trace_napi_poll(n);
4602 } 4650 }
4603 4651
4604 WARN_ON_ONCE(work > weight); 4652 n = list_first_entry(&list, struct napi_struct, poll_list);
4605 4653 budget -= napi_poll(n, &repoll);
4606 budget -= work;
4607 4654
4608 /* Drivers must not modify the NAPI state if they 4655 /* If softirq window is exhausted then punt.
4609 * consume the entire weight. In such cases this code 4656 * Allow this to run for 2 jiffies since which will allow
4610 * still "owns" the NAPI instance and therefore can 4657 * an average latency of 1.5/HZ.
4611 * move the instance around on the list at-will.
4612 */ 4658 */
4613 if (unlikely(work == weight)) { 4659 if (unlikely(budget <= 0 ||
4614 if (unlikely(napi_disable_pending(n))) { 4660 time_after_eq(jiffies, time_limit))) {
4615 napi_complete(n); 4661 sd->time_squeeze++;
4616 } else { 4662 break;
4617 if (n->gro_list) {
4618 /* flush too old packets
4619 * If HZ < 1000, flush all packets.
4620 */
4621 napi_gro_flush(n, HZ >= 1000);
4622 }
4623 list_add_tail(&n->poll_list, &repoll);
4624 }
4625 } 4663 }
4626
4627 netpoll_poll_unlock(have);
4628 } 4664 }
4629 4665
4630 if (!sd_has_rps_ipi_waiting(sd) &&
4631 list_empty(&list) &&
4632 list_empty(&repoll))
4633 return;
4634out:
4635 local_irq_disable(); 4666 local_irq_disable();
4636 4667
4637 list_splice_tail_init(&sd->poll_list, &list); 4668 list_splice_tail_init(&sd->poll_list, &list);
@@ -4641,12 +4672,6 @@ out:
4641 __raise_softirq_irqoff(NET_RX_SOFTIRQ); 4672 __raise_softirq_irqoff(NET_RX_SOFTIRQ);
4642 4673
4643 net_rps_action_and_irq_enable(sd); 4674 net_rps_action_and_irq_enable(sd);
4644
4645 return;
4646
4647softnet_break:
4648 sd->time_squeeze++;
4649 goto out;
4650} 4675}
4651 4676
4652struct netdev_adjacent { 4677struct netdev_adjacent {
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ae13ef6b3ea7..395c15b82087 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4148,6 +4148,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
4148 skb->ignore_df = 0; 4148 skb->ignore_df = 0;
4149 skb_dst_drop(skb); 4149 skb_dst_drop(skb);
4150 skb->mark = 0; 4150 skb->mark = 0;
4151 skb_init_secmark(skb);
4151 secpath_reset(skb); 4152 secpath_reset(skb);
4152 nf_reset(skb); 4153 nf_reset(skb);
4153 nf_reset_trace(skb); 4154 nf_reset_trace(skb);
diff --git a/net/ipv4/geneve.c b/net/ipv4/geneve.c
index 95e47c97585e..394a200f93c1 100644
--- a/net/ipv4/geneve.c
+++ b/net/ipv4/geneve.c
@@ -122,14 +122,18 @@ int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
122 int err; 122 int err;
123 123
124 skb = udp_tunnel_handle_offloads(skb, !gs->sock->sk->sk_no_check_tx); 124 skb = udp_tunnel_handle_offloads(skb, !gs->sock->sk->sk_no_check_tx);
125 if (IS_ERR(skb))
126 return PTR_ERR(skb);
125 127
126 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len 128 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
127 + GENEVE_BASE_HLEN + opt_len + sizeof(struct iphdr) 129 + GENEVE_BASE_HLEN + opt_len + sizeof(struct iphdr)
128 + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0); 130 + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
129 131
130 err = skb_cow_head(skb, min_headroom); 132 err = skb_cow_head(skb, min_headroom);
131 if (unlikely(err)) 133 if (unlikely(err)) {
134 kfree_skb(skb);
132 return err; 135 return err;
136 }
133 137
134 skb = vlan_hwaccel_push_inside(skb); 138 skb = vlan_hwaccel_push_inside(skb);
135 if (unlikely(!skb)) 139 if (unlikely(!skb))
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 7f18262e2326..65caf8b95e17 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2019,7 +2019,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2019 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now))) 2019 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now)))
2020 break; 2020 break;
2021 2021
2022 if (tso_segs == 1) { 2022 if (tso_segs == 1 || !max_segs) {
2023 if (unlikely(!tcp_nagle_test(tp, skb, mss_now, 2023 if (unlikely(!tcp_nagle_test(tp, skb, mss_now,
2024 (tcp_skb_is_last(sk, skb) ? 2024 (tcp_skb_is_last(sk, skb) ?
2025 nonagle : TCP_NAGLE_PUSH)))) 2025 nonagle : TCP_NAGLE_PUSH))))
@@ -2032,7 +2032,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2032 } 2032 }
2033 2033
2034 limit = mss_now; 2034 limit = mss_now;
2035 if (tso_segs > 1 && !tcp_urg_mode(tp)) 2035 if (tso_segs > 1 && max_segs && !tcp_urg_mode(tp))
2036 limit = tcp_mss_split_point(sk, skb, mss_now, 2036 limit = tcp_mss_split_point(sk, skb, mss_now,
2037 min_t(unsigned int, 2037 min_t(unsigned int,
2038 cwnd_quota, 2038 cwnd_quota,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5ff87805258e..9c0b54e87b47 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1387,6 +1387,28 @@ ipv6_pktoptions:
1387 return 0; 1387 return 0;
1388} 1388}
1389 1389
1390static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
1391 const struct tcphdr *th)
1392{
1393 /* This is tricky: we move IP6CB at its correct location into
1394 * TCP_SKB_CB(). It must be done after xfrm6_policy_check(), because
1395 * _decode_session6() uses IP6CB().
1396 * barrier() makes sure compiler won't play aliasing games.
1397 */
1398 memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
1399 sizeof(struct inet6_skb_parm));
1400 barrier();
1401
1402 TCP_SKB_CB(skb)->seq = ntohl(th->seq);
1403 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
1404 skb->len - th->doff*4);
1405 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1406 TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);
1407 TCP_SKB_CB(skb)->tcp_tw_isn = 0;
1408 TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);
1409 TCP_SKB_CB(skb)->sacked = 0;
1410}
1411
1390static int tcp_v6_rcv(struct sk_buff *skb) 1412static int tcp_v6_rcv(struct sk_buff *skb)
1391{ 1413{
1392 const struct tcphdr *th; 1414 const struct tcphdr *th;
@@ -1418,24 +1440,9 @@ static int tcp_v6_rcv(struct sk_buff *skb)
1418 1440
1419 th = tcp_hdr(skb); 1441 th = tcp_hdr(skb);
1420 hdr = ipv6_hdr(skb); 1442 hdr = ipv6_hdr(skb);
1421 /* This is tricky : We move IPCB at its correct location into TCP_SKB_CB()
1422 * barrier() makes sure compiler wont play fool^Waliasing games.
1423 */
1424 memmove(&TCP_SKB_CB(skb)->header.h6, IP6CB(skb),
1425 sizeof(struct inet6_skb_parm));
1426 barrier();
1427
1428 TCP_SKB_CB(skb)->seq = ntohl(th->seq);
1429 TCP_SKB_CB(skb)->end_seq = (TCP_SKB_CB(skb)->seq + th->syn + th->fin +
1430 skb->len - th->doff*4);
1431 TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq);
1432 TCP_SKB_CB(skb)->tcp_flags = tcp_flag_byte(th);
1433 TCP_SKB_CB(skb)->tcp_tw_isn = 0;
1434 TCP_SKB_CB(skb)->ip_dsfield = ipv6_get_dsfield(hdr);
1435 TCP_SKB_CB(skb)->sacked = 0;
1436 1443
1437 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest, 1444 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest,
1438 tcp_v6_iif(skb)); 1445 inet6_iif(skb));
1439 if (!sk) 1446 if (!sk)
1440 goto no_tcp_socket; 1447 goto no_tcp_socket;
1441 1448
@@ -1451,6 +1458,8 @@ process:
1451 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 1458 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1452 goto discard_and_relse; 1459 goto discard_and_relse;
1453 1460
1461 tcp_v6_fill_cb(skb, hdr, th);
1462
1454#ifdef CONFIG_TCP_MD5SIG 1463#ifdef CONFIG_TCP_MD5SIG
1455 if (tcp_v6_inbound_md5_hash(sk, skb)) 1464 if (tcp_v6_inbound_md5_hash(sk, skb))
1456 goto discard_and_relse; 1465 goto discard_and_relse;
@@ -1482,6 +1491,8 @@ no_tcp_socket:
1482 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 1491 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
1483 goto discard_it; 1492 goto discard_it;
1484 1493
1494 tcp_v6_fill_cb(skb, hdr, th);
1495
1485 if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) { 1496 if (skb->len < (th->doff<<2) || tcp_checksum_complete(skb)) {
1486csum_error: 1497csum_error:
1487 TCP_INC_STATS_BH(net, TCP_MIB_CSUMERRORS); 1498 TCP_INC_STATS_BH(net, TCP_MIB_CSUMERRORS);
@@ -1505,6 +1516,8 @@ do_time_wait:
1505 goto discard_it; 1516 goto discard_it;
1506 } 1517 }
1507 1518
1519 tcp_v6_fill_cb(skb, hdr, th);
1520
1508 if (skb->len < (th->doff<<2)) { 1521 if (skb->len < (th->doff<<2)) {
1509 inet_twsk_put(inet_twsk(sk)); 1522 inet_twsk_put(inet_twsk(sk));
1510 goto bad_packet; 1523 goto bad_packet;
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 0bb7038121ac..bd4e46ec32bd 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -140,7 +140,9 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
140 if (!ret) { 140 if (!ret) {
141 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 141 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
142 142
143 if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) 143 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
144 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
145 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
144 sdata->crypto_tx_tailroom_needed_cnt--; 146 sdata->crypto_tx_tailroom_needed_cnt--;
145 147
146 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && 148 WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) &&
@@ -188,7 +190,9 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
188 sta = key->sta; 190 sta = key->sta;
189 sdata = key->sdata; 191 sdata = key->sdata;
190 192
191 if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) 193 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
194 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
195 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
192 increment_tailroom_need_count(sdata); 196 increment_tailroom_need_count(sdata);
193 197
194 ret = drv_set_key(key->local, DISABLE_KEY, sdata, 198 ret = drv_set_key(key->local, DISABLE_KEY, sdata,
@@ -884,7 +888,9 @@ void ieee80211_remove_key(struct ieee80211_key_conf *keyconf)
884 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 888 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
885 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 889 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
886 890
887 if (!(key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC)) 891 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) ||
892 (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
893 (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)))
888 increment_tailroom_need_count(key->sdata); 894 increment_tailroom_need_count(key->sdata);
889 } 895 }
890 896
diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c
index ca27837974fe..349295d21946 100644
--- a/net/mpls/mpls_gso.c
+++ b/net/mpls/mpls_gso.c
@@ -31,10 +31,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
31 SKB_GSO_TCPV6 | 31 SKB_GSO_TCPV6 |
32 SKB_GSO_UDP | 32 SKB_GSO_UDP |
33 SKB_GSO_DODGY | 33 SKB_GSO_DODGY |
34 SKB_GSO_TCP_ECN | 34 SKB_GSO_TCP_ECN)))
35 SKB_GSO_GRE |
36 SKB_GSO_GRE_CSUM |
37 SKB_GSO_IPIP)))
38 goto out; 35 goto out;
39 36
40 /* Setup inner SKB. */ 37 /* Setup inner SKB. */
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 13c2e17bbe27..cde4a6702fa3 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -463,7 +463,7 @@ static void nfnetlink_rcv(struct sk_buff *skb)
463} 463}
464 464
465#ifdef CONFIG_MODULES 465#ifdef CONFIG_MODULES
466static int nfnetlink_bind(int group) 466static int nfnetlink_bind(struct net *net, int group)
467{ 467{
468 const struct nfnetlink_subsystem *ss; 468 const struct nfnetlink_subsystem *ss;
469 int type; 469 int type;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 074cf3e91c6f..84ea76ca3f1f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1091,8 +1091,10 @@ static void netlink_remove(struct sock *sk)
1091 mutex_unlock(&nl_sk_hash_lock); 1091 mutex_unlock(&nl_sk_hash_lock);
1092 1092
1093 netlink_table_grab(); 1093 netlink_table_grab();
1094 if (nlk_sk(sk)->subscriptions) 1094 if (nlk_sk(sk)->subscriptions) {
1095 __sk_del_bind_node(sk); 1095 __sk_del_bind_node(sk);
1096 netlink_update_listeners(sk);
1097 }
1096 netlink_table_ungrab(); 1098 netlink_table_ungrab();
1097} 1099}
1098 1100
@@ -1139,8 +1141,8 @@ static int netlink_create(struct net *net, struct socket *sock, int protocol,
1139 struct module *module = NULL; 1141 struct module *module = NULL;
1140 struct mutex *cb_mutex; 1142 struct mutex *cb_mutex;
1141 struct netlink_sock *nlk; 1143 struct netlink_sock *nlk;
1142 int (*bind)(int group); 1144 int (*bind)(struct net *net, int group);
1143 void (*unbind)(int group); 1145 void (*unbind)(struct net *net, int group);
1144 int err = 0; 1146 int err = 0;
1145 1147
1146 sock->state = SS_UNCONNECTED; 1148 sock->state = SS_UNCONNECTED;
@@ -1226,8 +1228,8 @@ static int netlink_release(struct socket *sock)
1226 1228
1227 module_put(nlk->module); 1229 module_put(nlk->module);
1228 1230
1229 netlink_table_grab();
1230 if (netlink_is_kernel(sk)) { 1231 if (netlink_is_kernel(sk)) {
1232 netlink_table_grab();
1231 BUG_ON(nl_table[sk->sk_protocol].registered == 0); 1233 BUG_ON(nl_table[sk->sk_protocol].registered == 0);
1232 if (--nl_table[sk->sk_protocol].registered == 0) { 1234 if (--nl_table[sk->sk_protocol].registered == 0) {
1233 struct listeners *old; 1235 struct listeners *old;
@@ -1241,11 +1243,16 @@ static int netlink_release(struct socket *sock)
1241 nl_table[sk->sk_protocol].flags = 0; 1243 nl_table[sk->sk_protocol].flags = 0;
1242 nl_table[sk->sk_protocol].registered = 0; 1244 nl_table[sk->sk_protocol].registered = 0;
1243 } 1245 }
1244 } else if (nlk->subscriptions) { 1246 netlink_table_ungrab();
1245 netlink_update_listeners(sk);
1246 } 1247 }
1247 netlink_table_ungrab();
1248 1248
1249 if (nlk->netlink_unbind) {
1250 int i;
1251
1252 for (i = 0; i < nlk->ngroups; i++)
1253 if (test_bit(i, nlk->groups))
1254 nlk->netlink_unbind(sock_net(sk), i + 1);
1255 }
1249 kfree(nlk->groups); 1256 kfree(nlk->groups);
1250 nlk->groups = NULL; 1257 nlk->groups = NULL;
1251 1258
@@ -1410,9 +1417,10 @@ static int netlink_realloc_groups(struct sock *sk)
1410 return err; 1417 return err;
1411} 1418}
1412 1419
1413static void netlink_unbind(int group, long unsigned int groups, 1420static void netlink_undo_bind(int group, long unsigned int groups,
1414 struct netlink_sock *nlk) 1421 struct sock *sk)
1415{ 1422{
1423 struct netlink_sock *nlk = nlk_sk(sk);
1416 int undo; 1424 int undo;
1417 1425
1418 if (!nlk->netlink_unbind) 1426 if (!nlk->netlink_unbind)
@@ -1420,7 +1428,7 @@ static void netlink_unbind(int group, long unsigned int groups,
1420 1428
1421 for (undo = 0; undo < group; undo++) 1429 for (undo = 0; undo < group; undo++)
1422 if (test_bit(undo, &groups)) 1430 if (test_bit(undo, &groups))
1423 nlk->netlink_unbind(undo); 1431 nlk->netlink_unbind(sock_net(sk), undo);
1424} 1432}
1425 1433
1426static int netlink_bind(struct socket *sock, struct sockaddr *addr, 1434static int netlink_bind(struct socket *sock, struct sockaddr *addr,
@@ -1458,10 +1466,10 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1458 for (group = 0; group < nlk->ngroups; group++) { 1466 for (group = 0; group < nlk->ngroups; group++) {
1459 if (!test_bit(group, &groups)) 1467 if (!test_bit(group, &groups))
1460 continue; 1468 continue;
1461 err = nlk->netlink_bind(group); 1469 err = nlk->netlink_bind(net, group);
1462 if (!err) 1470 if (!err)
1463 continue; 1471 continue;
1464 netlink_unbind(group, groups, nlk); 1472 netlink_undo_bind(group, groups, sk);
1465 return err; 1473 return err;
1466 } 1474 }
1467 } 1475 }
@@ -1471,7 +1479,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1471 netlink_insert(sk, net, nladdr->nl_pid) : 1479 netlink_insert(sk, net, nladdr->nl_pid) :
1472 netlink_autobind(sock); 1480 netlink_autobind(sock);
1473 if (err) { 1481 if (err) {
1474 netlink_unbind(nlk->ngroups, groups, nlk); 1482 netlink_undo_bind(nlk->ngroups, groups, sk);
1475 return err; 1483 return err;
1476 } 1484 }
1477 } 1485 }
@@ -2122,7 +2130,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
2122 if (!val || val - 1 >= nlk->ngroups) 2130 if (!val || val - 1 >= nlk->ngroups)
2123 return -EINVAL; 2131 return -EINVAL;
2124 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) { 2132 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) {
2125 err = nlk->netlink_bind(val); 2133 err = nlk->netlink_bind(sock_net(sk), val);
2126 if (err) 2134 if (err)
2127 return err; 2135 return err;
2128 } 2136 }
@@ -2131,7 +2139,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
2131 optname == NETLINK_ADD_MEMBERSHIP); 2139 optname == NETLINK_ADD_MEMBERSHIP);
2132 netlink_table_ungrab(); 2140 netlink_table_ungrab();
2133 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind) 2141 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind)
2134 nlk->netlink_unbind(val); 2142 nlk->netlink_unbind(sock_net(sk), val);
2135 2143
2136 err = 0; 2144 err = 0;
2137 break; 2145 break;
diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h
index b20a1731759b..f123a88496f8 100644
--- a/net/netlink/af_netlink.h
+++ b/net/netlink/af_netlink.h
@@ -39,8 +39,8 @@ struct netlink_sock {
39 struct mutex *cb_mutex; 39 struct mutex *cb_mutex;
40 struct mutex cb_def_mutex; 40 struct mutex cb_def_mutex;
41 void (*netlink_rcv)(struct sk_buff *skb); 41 void (*netlink_rcv)(struct sk_buff *skb);
42 int (*netlink_bind)(int group); 42 int (*netlink_bind)(struct net *net, int group);
43 void (*netlink_unbind)(int group); 43 void (*netlink_unbind)(struct net *net, int group);
44 struct module *module; 44 struct module *module;
45#ifdef CONFIG_NETLINK_MMAP 45#ifdef CONFIG_NETLINK_MMAP
46 struct mutex pg_vec_lock; 46 struct mutex pg_vec_lock;
@@ -65,8 +65,8 @@ struct netlink_table {
65 unsigned int groups; 65 unsigned int groups;
66 struct mutex *cb_mutex; 66 struct mutex *cb_mutex;
67 struct module *module; 67 struct module *module;
68 int (*bind)(int group); 68 int (*bind)(struct net *net, int group);
69 void (*unbind)(int group); 69 void (*unbind)(struct net *net, int group);
70 bool (*compare)(struct net *net, struct sock *sock); 70 bool (*compare)(struct net *net, struct sock *sock);
71 int registered; 71 int registered;
72}; 72};
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 76393f2f4b22..2e11061ef885 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -983,11 +983,67 @@ static struct genl_multicast_group genl_ctrl_groups[] = {
983 { .name = "notify", }, 983 { .name = "notify", },
984}; 984};
985 985
986static int genl_bind(struct net *net, int group)
987{
988 int i, err = 0;
989
990 down_read(&cb_lock);
991 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
992 struct genl_family *f;
993
994 list_for_each_entry(f, genl_family_chain(i), family_list) {
995 if (group >= f->mcgrp_offset &&
996 group < f->mcgrp_offset + f->n_mcgrps) {
997 int fam_grp = group - f->mcgrp_offset;
998
999 if (!f->netnsok && net != &init_net)
1000 err = -ENOENT;
1001 else if (f->mcast_bind)
1002 err = f->mcast_bind(net, fam_grp);
1003 else
1004 err = 0;
1005 break;
1006 }
1007 }
1008 }
1009 up_read(&cb_lock);
1010
1011 return err;
1012}
1013
1014static void genl_unbind(struct net *net, int group)
1015{
1016 int i;
1017 bool found = false;
1018
1019 down_read(&cb_lock);
1020 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
1021 struct genl_family *f;
1022
1023 list_for_each_entry(f, genl_family_chain(i), family_list) {
1024 if (group >= f->mcgrp_offset &&
1025 group < f->mcgrp_offset + f->n_mcgrps) {
1026 int fam_grp = group - f->mcgrp_offset;
1027
1028 if (f->mcast_unbind)
1029 f->mcast_unbind(net, fam_grp);
1030 found = true;
1031 break;
1032 }
1033 }
1034 }
1035 up_read(&cb_lock);
1036
1037 WARN_ON(!found);
1038}
1039
986static int __net_init genl_pernet_init(struct net *net) 1040static int __net_init genl_pernet_init(struct net *net)
987{ 1041{
988 struct netlink_kernel_cfg cfg = { 1042 struct netlink_kernel_cfg cfg = {
989 .input = genl_rcv, 1043 .input = genl_rcv,
990 .flags = NL_CFG_F_NONROOT_RECV, 1044 .flags = NL_CFG_F_NONROOT_RECV,
1045 .bind = genl_bind,
1046 .unbind = genl_unbind,
991 }; 1047 };
992 1048
993 /* we'll bump the group number right afterwards */ 1049 /* we'll bump the group number right afterwards */
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 764fdc39c63b..770064c83711 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -147,7 +147,8 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
147 hdr = eth_hdr(skb); 147 hdr = eth_hdr(skb);
148 hdr->h_proto = mpls->mpls_ethertype; 148 hdr->h_proto = mpls->mpls_ethertype;
149 149
150 skb_set_inner_protocol(skb, skb->protocol); 150 if (!skb->inner_protocol)
151 skb_set_inner_protocol(skb, skb->protocol);
151 skb->protocol = mpls->mpls_ethertype; 152 skb->protocol = mpls->mpls_ethertype;
152 153
153 invalidate_flow_key(key); 154 invalidate_flow_key(key);
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 332b5a031739..4e9a5f035cbc 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -83,8 +83,7 @@ static bool ovs_must_notify(struct genl_family *family, struct genl_info *info,
83 unsigned int group) 83 unsigned int group)
84{ 84{
85 return info->nlhdr->nlmsg_flags & NLM_F_ECHO || 85 return info->nlhdr->nlmsg_flags & NLM_F_ECHO ||
86 genl_has_listeners(family, genl_info_net(info)->genl_sock, 86 genl_has_listeners(family, genl_info_net(info), group);
87 group);
88} 87}
89 88
90static void ovs_notify(struct genl_family *family, 89static void ovs_notify(struct genl_family *family,
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 70bef2ab7f2b..da2fae0873a5 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -70,6 +70,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
70{ 70{
71 struct flow_stats *stats; 71 struct flow_stats *stats;
72 int node = numa_node_id(); 72 int node = numa_node_id();
73 int len = skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
73 74
74 stats = rcu_dereference(flow->stats[node]); 75 stats = rcu_dereference(flow->stats[node]);
75 76
@@ -105,7 +106,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
105 if (likely(new_stats)) { 106 if (likely(new_stats)) {
106 new_stats->used = jiffies; 107 new_stats->used = jiffies;
107 new_stats->packet_count = 1; 108 new_stats->packet_count = 1;
108 new_stats->byte_count = skb->len; 109 new_stats->byte_count = len;
109 new_stats->tcp_flags = tcp_flags; 110 new_stats->tcp_flags = tcp_flags;
110 spin_lock_init(&new_stats->lock); 111 spin_lock_init(&new_stats->lock);
111 112
@@ -120,7 +121,7 @@ void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags,
120 121
121 stats->used = jiffies; 122 stats->used = jiffies;
122 stats->packet_count++; 123 stats->packet_count++;
123 stats->byte_count += skb->len; 124 stats->byte_count += len;
124 stats->tcp_flags |= tcp_flags; 125 stats->tcp_flags |= tcp_flags;
125unlock: 126unlock:
126 spin_unlock(&stats->lock); 127 spin_unlock(&stats->lock);
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 9645a21d9eaa..d1eecf707613 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -1753,7 +1753,6 @@ static int __ovs_nla_copy_actions(const struct nlattr *attr,
1753 __be16 eth_type, __be16 vlan_tci, bool log) 1753 __be16 eth_type, __be16 vlan_tci, bool log)
1754{ 1754{
1755 const struct nlattr *a; 1755 const struct nlattr *a;
1756 bool out_tnl_port = false;
1757 int rem, err; 1756 int rem, err;
1758 1757
1759 if (depth >= SAMPLE_ACTION_DEPTH) 1758 if (depth >= SAMPLE_ACTION_DEPTH)
@@ -1796,8 +1795,6 @@ static int __ovs_nla_copy_actions(const struct nlattr *attr,
1796 case OVS_ACTION_ATTR_OUTPUT: 1795 case OVS_ACTION_ATTR_OUTPUT:
1797 if (nla_get_u32(a) >= DP_MAX_PORTS) 1796 if (nla_get_u32(a) >= DP_MAX_PORTS)
1798 return -EINVAL; 1797 return -EINVAL;
1799 out_tnl_port = false;
1800
1801 break; 1798 break;
1802 1799
1803 case OVS_ACTION_ATTR_HASH: { 1800 case OVS_ACTION_ATTR_HASH: {
@@ -1832,12 +1829,6 @@ static int __ovs_nla_copy_actions(const struct nlattr *attr,
1832 case OVS_ACTION_ATTR_PUSH_MPLS: { 1829 case OVS_ACTION_ATTR_PUSH_MPLS: {
1833 const struct ovs_action_push_mpls *mpls = nla_data(a); 1830 const struct ovs_action_push_mpls *mpls = nla_data(a);
1834 1831
1835 /* Networking stack do not allow simultaneous Tunnel
1836 * and MPLS GSO.
1837 */
1838 if (out_tnl_port)
1839 return -EINVAL;
1840
1841 if (!eth_p_mpls(mpls->mpls_ethertype)) 1832 if (!eth_p_mpls(mpls->mpls_ethertype))
1842 return -EINVAL; 1833 return -EINVAL;
1843 /* Prohibit push MPLS other than to a white list 1834 /* Prohibit push MPLS other than to a white list
@@ -1873,11 +1864,9 @@ static int __ovs_nla_copy_actions(const struct nlattr *attr,
1873 1864
1874 case OVS_ACTION_ATTR_SET: 1865 case OVS_ACTION_ATTR_SET:
1875 err = validate_set(a, key, sfa, 1866 err = validate_set(a, key, sfa,
1876 &out_tnl_port, eth_type, log); 1867 &skip_copy, eth_type, log);
1877 if (err) 1868 if (err)
1878 return err; 1869 return err;
1879
1880 skip_copy = out_tnl_port;
1881 break; 1870 break;
1882 1871
1883 case OVS_ACTION_ATTR_SAMPLE: 1872 case OVS_ACTION_ATTR_SAMPLE:
diff --git a/net/openvswitch/vport-geneve.c b/net/openvswitch/vport-geneve.c
index 347fa2325b22..484864dd0e68 100644
--- a/net/openvswitch/vport-geneve.c
+++ b/net/openvswitch/vport-geneve.c
@@ -219,7 +219,10 @@ static int geneve_tnl_send(struct vport *vport, struct sk_buff *skb)
219 false); 219 false);
220 if (err < 0) 220 if (err < 0)
221 ip_rt_put(rt); 221 ip_rt_put(rt);
222 return err;
223
222error: 224error:
225 kfree_skb(skb);
223 return err; 226 return err;
224} 227}
225 228
diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c
index 6b69df545b1d..d4168c442db5 100644
--- a/net/openvswitch/vport-gre.c
+++ b/net/openvswitch/vport-gre.c
@@ -73,7 +73,7 @@ static struct sk_buff *__build_header(struct sk_buff *skb,
73 73
74 skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM)); 74 skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM));
75 if (IS_ERR(skb)) 75 if (IS_ERR(skb))
76 return NULL; 76 return skb;
77 77
78 tpi.flags = filter_tnl_flags(tun_key->tun_flags); 78 tpi.flags = filter_tnl_flags(tun_key->tun_flags);
79 tpi.proto = htons(ETH_P_TEB); 79 tpi.proto = htons(ETH_P_TEB);
@@ -144,7 +144,7 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
144 144
145 if (unlikely(!OVS_CB(skb)->egress_tun_info)) { 145 if (unlikely(!OVS_CB(skb)->egress_tun_info)) {
146 err = -EINVAL; 146 err = -EINVAL;
147 goto error; 147 goto err_free_skb;
148 } 148 }
149 149
150 tun_key = &OVS_CB(skb)->egress_tun_info->tunnel; 150 tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
@@ -157,8 +157,10 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
157 fl.flowi4_proto = IPPROTO_GRE; 157 fl.flowi4_proto = IPPROTO_GRE;
158 158
159 rt = ip_route_output_key(net, &fl); 159 rt = ip_route_output_key(net, &fl);
160 if (IS_ERR(rt)) 160 if (IS_ERR(rt)) {
161 return PTR_ERR(rt); 161 err = PTR_ERR(rt);
162 goto err_free_skb;
163 }
162 164
163 tunnel_hlen = ip_gre_calc_hlen(tun_key->tun_flags); 165 tunnel_hlen = ip_gre_calc_hlen(tun_key->tun_flags);
164 166
@@ -183,8 +185,9 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
183 185
184 /* Push Tunnel header. */ 186 /* Push Tunnel header. */
185 skb = __build_header(skb, tunnel_hlen); 187 skb = __build_header(skb, tunnel_hlen);
186 if (unlikely(!skb)) { 188 if (IS_ERR(skb)) {
187 err = 0; 189 err = PTR_ERR(skb);
190 skb = NULL;
188 goto err_free_rt; 191 goto err_free_rt;
189 } 192 }
190 193
@@ -198,7 +201,8 @@ static int gre_tnl_send(struct vport *vport, struct sk_buff *skb)
198 tun_key->ipv4_tos, tun_key->ipv4_ttl, df, false); 201 tun_key->ipv4_tos, tun_key->ipv4_ttl, df, false);
199err_free_rt: 202err_free_rt:
200 ip_rt_put(rt); 203 ip_rt_put(rt);
201error: 204err_free_skb:
205 kfree_skb(skb);
202 return err; 206 return err;
203} 207}
204 208
diff --git a/net/openvswitch/vport-vxlan.c b/net/openvswitch/vport-vxlan.c
index 38f95a52241b..d7c46b301024 100644
--- a/net/openvswitch/vport-vxlan.c
+++ b/net/openvswitch/vport-vxlan.c
@@ -187,7 +187,9 @@ static int vxlan_tnl_send(struct vport *vport, struct sk_buff *skb)
187 false); 187 false);
188 if (err < 0) 188 if (err < 0)
189 ip_rt_put(rt); 189 ip_rt_put(rt);
190 return err;
190error: 191error:
192 kfree_skb(skb);
191 return err; 193 return err;
192} 194}
193 195
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 9584526c0778..2034c6d9cb5a 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -480,7 +480,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb,
480 stats = this_cpu_ptr(vport->percpu_stats); 480 stats = this_cpu_ptr(vport->percpu_stats);
481 u64_stats_update_begin(&stats->syncp); 481 u64_stats_update_begin(&stats->syncp);
482 stats->rx_packets++; 482 stats->rx_packets++;
483 stats->rx_bytes += skb->len; 483 stats->rx_bytes += skb->len + (vlan_tx_tag_present(skb) ? VLAN_HLEN : 0);
484 u64_stats_update_end(&stats->syncp); 484 u64_stats_update_end(&stats->syncp);
485 485
486 OVS_CB(skb)->input_vport = vport; 486 OVS_CB(skb)->input_vport = vport;
@@ -519,10 +519,9 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
519 u64_stats_update_end(&stats->syncp); 519 u64_stats_update_end(&stats->syncp);
520 } else if (sent < 0) { 520 } else if (sent < 0) {
521 ovs_vport_record_error(vport, VPORT_E_TX_ERROR); 521 ovs_vport_record_error(vport, VPORT_E_TX_ERROR);
522 kfree_skb(skb); 522 } else {
523 } else
524 ovs_vport_record_error(vport, VPORT_E_TX_DROPPED); 523 ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
525 524 }
526 return sent; 525 return sent;
527} 526}
528 527
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index e52a44785681..6880f34a529a 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -785,6 +785,7 @@ static void prb_close_block(struct tpacket_kbdq_core *pkc1,
785 785
786 struct tpacket3_hdr *last_pkt; 786 struct tpacket3_hdr *last_pkt;
787 struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1; 787 struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1;
788 struct sock *sk = &po->sk;
788 789
789 if (po->stats.stats3.tp_drops) 790 if (po->stats.stats3.tp_drops)
790 status |= TP_STATUS_LOSING; 791 status |= TP_STATUS_LOSING;
@@ -809,6 +810,8 @@ static void prb_close_block(struct tpacket_kbdq_core *pkc1,
809 /* Flush the block */ 810 /* Flush the block */
810 prb_flush_block(pkc1, pbd1, status); 811 prb_flush_block(pkc1, pbd1, status);
811 812
813 sk->sk_data_ready(sk);
814
812 pkc1->kactive_blk_num = GET_NEXT_PRB_BLK_NUM(pkc1); 815 pkc1->kactive_blk_num = GET_NEXT_PRB_BLK_NUM(pkc1);
813} 816}
814 817
@@ -2052,12 +2055,12 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2052 smp_wmb(); 2055 smp_wmb();
2053#endif 2056#endif
2054 2057
2055 if (po->tp_version <= TPACKET_V2) 2058 if (po->tp_version <= TPACKET_V2) {
2056 __packet_set_status(po, h.raw, status); 2059 __packet_set_status(po, h.raw, status);
2057 else 2060 sk->sk_data_ready(sk);
2061 } else {
2058 prb_clear_blk_fill_status(&po->rx_ring); 2062 prb_clear_blk_fill_status(&po->rx_ring);
2059 2063 }
2060 sk->sk_data_ready(sk);
2061 2064
2062drop_n_restore: 2065drop_n_restore:
2063 if (skb_head != skb->data && skb_shared(skb)) { 2066 if (skb_head != skb->data && skb_shared(skb)) {
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 1cb61242e55e..4439ac4c1b53 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -606,7 +606,7 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
606 struct kvec *head = buf->head; 606 struct kvec *head = buf->head;
607 struct kvec *tail = buf->tail; 607 struct kvec *tail = buf->tail;
608 int fraglen; 608 int fraglen;
609 int new, old; 609 int new;
610 610
611 if (len > buf->len) { 611 if (len > buf->len) {
612 WARN_ON_ONCE(1); 612 WARN_ON_ONCE(1);
@@ -629,8 +629,8 @@ void xdr_truncate_encode(struct xdr_stream *xdr, size_t len)
629 buf->len -= fraglen; 629 buf->len -= fraglen;
630 630
631 new = buf->page_base + buf->page_len; 631 new = buf->page_base + buf->page_len;
632 old = new + fraglen; 632
633 xdr->page_ptr -= (old >> PAGE_SHIFT) - (new >> PAGE_SHIFT); 633 xdr->page_ptr = buf->pages + (new >> PAGE_SHIFT);
634 634
635 if (buf->page_len) { 635 if (buf->page_len) {
636 xdr->p = page_address(*xdr->page_ptr); 636 xdr->p = page_address(*xdr->page_ptr);
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index 22ba971741e5..29c8675f9a11 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -175,7 +175,7 @@ config CFG80211_INTERNAL_REGDB
175 Most distributions have a CRDA package. So if unsure, say N. 175 Most distributions have a CRDA package. So if unsure, say N.
176 176
177config CFG80211_WEXT 177config CFG80211_WEXT
178 bool 178 bool "cfg80211 wireless extensions compatibility"
179 depends on CFG80211 179 depends on CFG80211
180 select WEXT_CORE 180 select WEXT_CORE
181 help 181 help
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 1bca180db8ad..627f8cbbedb8 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -42,19 +42,19 @@ __clean-files := $(extra-y) $(extra-m) $(extra-) \
42 42
43__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) 43__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
44 44
45# as clean-files is given relative to the current directory, this adds 45# clean-files is given relative to the current directory, unless it
46# a $(obj) prefix, except for absolute paths 46# starts with $(objtree)/ (which means "./", so do not add "./" unless
47# you want to delete a file from the toplevel object directory).
47 48
48__clean-files := $(wildcard \ 49__clean-files := $(wildcard \
49 $(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \ 50 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
50 $(filter /%, $(__clean-files))) 51 $(filter $(objtree)/%, $(__clean-files)))
51 52
52# as clean-dirs is given relative to the current directory, this adds 53# same as clean-files
53# a $(obj) prefix, except for absolute paths
54 54
55__clean-dirs := $(wildcard \ 55__clean-dirs := $(wildcard \
56 $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs))) \ 56 $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
57 $(filter /%, $(clean-dirs))) 57 $(filter $(objtree)/%, $(clean-dirs)))
58 58
59# ========================================================================== 59# ==========================================================================
60 60
diff --git a/security/keys/gc.c b/security/keys/gc.c
index 9609a7f0faea..c7952375ac53 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -148,12 +148,12 @@ static noinline void key_gc_unused_keys(struct list_head *keys)
148 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) 148 if (test_bit(KEY_FLAG_INSTANTIATED, &key->flags))
149 atomic_dec(&key->user->nikeys); 149 atomic_dec(&key->user->nikeys);
150 150
151 key_user_put(key->user);
152
153 /* now throw away the key memory */ 151 /* now throw away the key memory */
154 if (key->type->destroy) 152 if (key->type->destroy)
155 key->type->destroy(key); 153 key->type->destroy(key);
156 154
155 key_user_put(key->user);
156
157 kfree(key->description); 157 kfree(key->description);
158 158
159#ifdef KEY_DEBUGGING 159#ifdef KEY_DEBUGGING
diff --git a/sound/firewire/fireworks/fireworks_transaction.c b/sound/firewire/fireworks/fireworks_transaction.c
index 255dabc6fc33..2a85e4209f0b 100644
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -124,7 +124,7 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode)
124 spin_lock_irq(&efw->lock); 124 spin_lock_irq(&efw->lock);
125 125
126 t = (struct snd_efw_transaction *)data; 126 t = (struct snd_efw_transaction *)data;
127 length = min_t(size_t, t->length * sizeof(t->length), length); 127 length = min_t(size_t, be32_to_cpu(t->length) * sizeof(u32), length);
128 128
129 if (efw->push_ptr < efw->pull_ptr) 129 if (efw->push_ptr < efw->pull_ptr)
130 capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr); 130 capacity = (unsigned int)(efw->pull_ptr - efw->push_ptr);
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 8276a743e22e..0cfc9c8c4b4e 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -1922,10 +1922,18 @@ int azx_mixer_create(struct azx *chip)
1922EXPORT_SYMBOL_GPL(azx_mixer_create); 1922EXPORT_SYMBOL_GPL(azx_mixer_create);
1923 1923
1924 1924
1925static bool is_input_stream(struct azx *chip, unsigned char index)
1926{
1927 return (index >= chip->capture_index_offset &&
1928 index < chip->capture_index_offset + chip->capture_streams);
1929}
1930
1925/* initialize SD streams */ 1931/* initialize SD streams */
1926int azx_init_stream(struct azx *chip) 1932int azx_init_stream(struct azx *chip)
1927{ 1933{
1928 int i; 1934 int i;
1935 int in_stream_tag = 0;
1936 int out_stream_tag = 0;
1929 1937
1930 /* initialize each stream (aka device) 1938 /* initialize each stream (aka device)
1931 * assign the starting bdl address to each stream (device) 1939 * assign the starting bdl address to each stream (device)
@@ -1938,9 +1946,21 @@ int azx_init_stream(struct azx *chip)
1938 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1946 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
1939 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ 1947 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
1940 azx_dev->sd_int_sta_mask = 1 << i; 1948 azx_dev->sd_int_sta_mask = 1 << i;
1941 /* stream tag: must be non-zero and unique */
1942 azx_dev->index = i; 1949 azx_dev->index = i;
1943 azx_dev->stream_tag = i + 1; 1950
1951 /* stream tag must be unique throughout
1952 * the stream direction group,
1953 * valid values 1...15
1954 * use separate stream tag if the flag
1955 * AZX_DCAPS_SEPARATE_STREAM_TAG is used
1956 */
1957 if (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG)
1958 azx_dev->stream_tag =
1959 is_input_stream(chip, i) ?
1960 ++in_stream_tag :
1961 ++out_stream_tag;
1962 else
1963 azx_dev->stream_tag = i + 1;
1944 } 1964 }
1945 1965
1946 return 0; 1966 return 0;
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 2bf0b568e3de..d426a0bd6a5f 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -299,6 +299,9 @@ enum {
299 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\ 299 AZX_DCAPS_PM_RUNTIME | AZX_DCAPS_I915_POWERWELL |\
300 AZX_DCAPS_SNOOP_TYPE(SCH)) 300 AZX_DCAPS_SNOOP_TYPE(SCH))
301 301
302#define AZX_DCAPS_INTEL_SKYLAKE \
303 (AZX_DCAPS_INTEL_PCH | AZX_DCAPS_SEPARATE_STREAM_TAG)
304
302/* quirks for ATI SB / AMD Hudson */ 305/* quirks for ATI SB / AMD Hudson */
303#define AZX_DCAPS_PRESET_ATI_SB \ 306#define AZX_DCAPS_PRESET_ATI_SB \
304 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB |\ 307 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB |\
@@ -2027,7 +2030,7 @@ static const struct pci_device_id azx_ids[] = {
2027 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, 2030 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
2028 /* Sunrise Point-LP */ 2031 /* Sunrise Point-LP */
2029 { PCI_DEVICE(0x8086, 0x9d70), 2032 { PCI_DEVICE(0x8086, 0x9d70),
2030 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, 2033 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_SKYLAKE },
2031 /* Haswell */ 2034 /* Haswell */
2032 { PCI_DEVICE(0x8086, 0x0a0c), 2035 { PCI_DEVICE(0x8086, 0x0a0c),
2033 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, 2036 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL },
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
index aa484fdf4338..166e3e84b963 100644
--- a/sound/pci/hda/hda_priv.h
+++ b/sound/pci/hda/hda_priv.h
@@ -171,6 +171,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
171#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */ 171#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */
172#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */ 172#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */
173#define AZX_DCAPS_NO_MSI64 (1 << 29) /* Stick to 32-bit MSIs */ 173#define AZX_DCAPS_NO_MSI64 (1 << 29) /* Stick to 32-bit MSIs */
174#define AZX_DCAPS_SEPARATE_STREAM_TAG (1 << 30) /* capture and playback use separate stream tag */
174 175
175enum { 176enum {
176 AZX_SNOOP_TYPE_NONE , 177 AZX_SNOOP_TYPE_NONE ,
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 5f13d2d18079..b422e406a9cb 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3353,6 +3353,7 @@ static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
3353{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 3353{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
3354{ .id = 0x10de0070, .name = "GPU 70 HDMI/DP", .patch = patch_nvhdmi }, 3354{ .id = 0x10de0070, .name = "GPU 70 HDMI/DP", .patch = patch_nvhdmi },
3355{ .id = 0x10de0071, .name = "GPU 71 HDMI/DP", .patch = patch_nvhdmi }, 3355{ .id = 0x10de0071, .name = "GPU 71 HDMI/DP", .patch = patch_nvhdmi },
3356{ .id = 0x10de0072, .name = "GPU 72 HDMI/DP", .patch = patch_nvhdmi },
3356{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 3357{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
3357{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, 3358{ .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
3358{ .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi }, 3359{ .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
@@ -3413,6 +3414,7 @@ MODULE_ALIAS("snd-hda-codec-id:10de0060");
3413MODULE_ALIAS("snd-hda-codec-id:10de0067"); 3414MODULE_ALIAS("snd-hda-codec-id:10de0067");
3414MODULE_ALIAS("snd-hda-codec-id:10de0070"); 3415MODULE_ALIAS("snd-hda-codec-id:10de0070");
3415MODULE_ALIAS("snd-hda-codec-id:10de0071"); 3416MODULE_ALIAS("snd-hda-codec-id:10de0071");
3417MODULE_ALIAS("snd-hda-codec-id:10de0072");
3416MODULE_ALIAS("snd-hda-codec-id:10de8001"); 3418MODULE_ALIAS("snd-hda-codec-id:10de8001");
3417MODULE_ALIAS("snd-hda-codec-id:11069f80"); 3419MODULE_ALIAS("snd-hda-codec-id:11069f80");
3418MODULE_ALIAS("snd-hda-codec-id:11069f81"); 3420MODULE_ALIAS("snd-hda-codec-id:11069f81");
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 4f6413e01c13..605d14003d25 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -568,9 +568,9 @@ static void stac_store_hints(struct hda_codec *codec)
568 spec->gpio_mask; 568 spec->gpio_mask;
569 } 569 }
570 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir)) 570 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
571 spec->gpio_mask &= spec->gpio_mask;
572 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
573 spec->gpio_dir &= spec->gpio_mask; 571 spec->gpio_dir &= spec->gpio_mask;
572 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
573 spec->gpio_data &= spec->gpio_mask;
574 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask)) 574 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
575 spec->eapd_mask &= spec->gpio_mask; 575 spec->eapd_mask &= spec->gpio_mask;
576 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute)) 576 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 81fe1464d268..c0fbe1881439 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -784,8 +784,8 @@ static unsigned int bst_tlv[] = {
784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol, 784static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
785 struct snd_ctl_elem_value *ucontrol) 785 struct snd_ctl_elem_value *ucontrol)
786{ 786{
787 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 787 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
788 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 788 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
789 789
790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en; 790 ucontrol->value.integer.value[0] = rt5677->dsp_vad_en;
791 791
@@ -795,8 +795,9 @@ static int rt5677_dsp_vad_get(struct snd_kcontrol *kcontrol,
795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol, 795static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol,
796 struct snd_ctl_elem_value *ucontrol) 796 struct snd_ctl_elem_value *ucontrol)
797{ 797{
798 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 798 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
799 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 799 struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component);
800 struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
800 801
801 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0]; 802 rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0];
802 803
diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index b93168d4f648..8d18bbda661b 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -209,16 +209,9 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
209 209
210 switch (config->chan_nr) { 210 switch (config->chan_nr) {
211 case EIGHT_CHANNEL_SUPPORT: 211 case EIGHT_CHANNEL_SUPPORT:
212 ch_reg = 3;
213 break;
214 case SIX_CHANNEL_SUPPORT: 212 case SIX_CHANNEL_SUPPORT:
215 ch_reg = 2;
216 break;
217 case FOUR_CHANNEL_SUPPORT: 213 case FOUR_CHANNEL_SUPPORT:
218 ch_reg = 1;
219 break;
220 case TWO_CHANNEL_SUPPORT: 214 case TWO_CHANNEL_SUPPORT:
221 ch_reg = 0;
222 break; 215 break;
223 default: 216 default:
224 dev_err(dev->dev, "channel not supported\n"); 217 dev_err(dev->dev, "channel not supported\n");
@@ -227,18 +220,22 @@ static int dw_i2s_hw_params(struct snd_pcm_substream *substream,
227 220
228 i2s_disable_channels(dev, substream->stream); 221 i2s_disable_channels(dev, substream->stream);
229 222
230 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 223 for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) {
231 i2s_write_reg(dev->i2s_base, TCR(ch_reg), xfer_resolution); 224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
232 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02); 225 i2s_write_reg(dev->i2s_base, TCR(ch_reg),
233 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 226 xfer_resolution);
234 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30); 227 i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02);
235 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1); 228 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 } else { 229 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30);
237 i2s_write_reg(dev->i2s_base, RCR(ch_reg), xfer_resolution); 230 i2s_write_reg(dev->i2s_base, TER(ch_reg), 1);
238 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07); 231 } else {
239 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); 232 i2s_write_reg(dev->i2s_base, RCR(ch_reg),
240 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03); 233 xfer_resolution);
241 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1); 234 i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07);
235 irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg));
236 i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03);
237 i2s_write_reg(dev->i2s_base, RER(ch_reg), 1);
238 }
242 } 239 }
243 240
244 i2s_write_reg(dev->i2s_base, CCR, ccr); 241 i2s_write_reg(dev->i2s_base, CCR, ccr);
@@ -263,6 +260,19 @@ static void dw_i2s_shutdown(struct snd_pcm_substream *substream,
263 snd_soc_dai_set_dma_data(dai, substream, NULL); 260 snd_soc_dai_set_dma_data(dai, substream, NULL);
264} 261}
265 262
263static int dw_i2s_prepare(struct snd_pcm_substream *substream,
264 struct snd_soc_dai *dai)
265{
266 struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
267
268 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
269 i2s_write_reg(dev->i2s_base, TXFFR, 1);
270 else
271 i2s_write_reg(dev->i2s_base, RXFFR, 1);
272
273 return 0;
274}
275
266static int dw_i2s_trigger(struct snd_pcm_substream *substream, 276static int dw_i2s_trigger(struct snd_pcm_substream *substream,
267 int cmd, struct snd_soc_dai *dai) 277 int cmd, struct snd_soc_dai *dai)
268{ 278{
@@ -294,6 +304,7 @@ static struct snd_soc_dai_ops dw_i2s_dai_ops = {
294 .startup = dw_i2s_startup, 304 .startup = dw_i2s_startup,
295 .shutdown = dw_i2s_shutdown, 305 .shutdown = dw_i2s_shutdown,
296 .hw_params = dw_i2s_hw_params, 306 .hw_params = dw_i2s_hw_params,
307 .prepare = dw_i2s_prepare,
297 .trigger = dw_i2s_trigger, 308 .trigger = dw_i2s_trigger,
298}; 309};
299 310
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index e989ecf046c9..f86de1211b96 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -89,7 +89,7 @@ config SND_SOC_INTEL_BROADWELL_MACH
89 89
90config SND_SOC_INTEL_BYTCR_RT5640_MACH 90config SND_SOC_INTEL_BYTCR_RT5640_MACH
91 tristate "ASoC Audio DSP Support for MID BYT Platform" 91 tristate "ASoC Audio DSP Support for MID BYT Platform"
92 depends on X86 92 depends on X86 && I2C
93 select SND_SOC_RT5640 93 select SND_SOC_RT5640
94 select SND_SST_MFLD_PLATFORM 94 select SND_SST_MFLD_PLATFORM
95 select SND_SST_IPC_ACPI 95 select SND_SST_IPC_ACPI
@@ -101,7 +101,7 @@ config SND_SOC_INTEL_BYTCR_RT5640_MACH
101 101
102config SND_SOC_INTEL_CHT_BSW_RT5672_MACH 102config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec" 103 tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
104 depends on X86_INTEL_LPSS 104 depends on X86_INTEL_LPSS && I2C
105 select SND_SOC_RT5670 105 select SND_SOC_RT5670
106 select SND_SST_MFLD_PLATFORM 106 select SND_SST_MFLD_PLATFORM
107 select SND_SST_IPC_ACPI 107 select SND_SST_IPC_ACPI
diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c
index f5d0fc1ab10c..eef0c56ec32e 100644
--- a/sound/soc/intel/bytcr_dpcm_rt5640.c
+++ b/sound/soc/intel/bytcr_dpcm_rt5640.c
@@ -227,4 +227,4 @@ module_platform_driver(snd_byt_mc_driver);
227MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); 227MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver");
228MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>"); 228MODULE_AUTHOR("Subhransu S. Prusty <subhransu.s.prusty@intel.com>");
229MODULE_LICENSE("GPL v2"); 229MODULE_LICENSE("GPL v2");
230MODULE_ALIAS("platform:bytrt5640-audio"); 230MODULE_ALIAS("platform:bytt100_rt5640");
diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c
index 4a5bde9c686b..ef2e8b5766a1 100644
--- a/sound/soc/intel/sst-firmware.c
+++ b/sound/soc/intel/sst-firmware.c
@@ -763,8 +763,12 @@ static int block_alloc_fixed(struct sst_dsp *dsp, struct sst_block_allocator *ba
763 /* does block span more than 1 section */ 763 /* does block span more than 1 section */
764 if (ba->offset >= block->offset && ba->offset < block_end) { 764 if (ba->offset >= block->offset && ba->offset < block_end) {
765 765
766 /* add block */
767 list_move(&block->list, &dsp->used_block_list);
768 list_add(&block->module_list, block_list);
766 /* align ba to block boundary */ 769 /* align ba to block boundary */
767 ba->offset = block->offset; 770 ba->size -= block_end - ba->offset;
771 ba->offset = block_end;
768 772
769 err = block_alloc_contiguous(dsp, ba, block_list); 773 err = block_alloc_contiguous(dsp, ba, block_list);
770 if (err < 0) 774 if (err < 0)
diff --git a/sound/soc/intel/sst/sst_acpi.c b/sound/soc/intel/sst/sst_acpi.c
index 3abc29e8a928..2ac72eb5e75d 100644
--- a/sound/soc/intel/sst/sst_acpi.c
+++ b/sound/soc/intel/sst/sst_acpi.c
@@ -343,7 +343,7 @@ int sst_acpi_remove(struct platform_device *pdev)
343} 343}
344 344
345static struct sst_machines sst_acpi_bytcr[] = { 345static struct sst_machines sst_acpi_bytcr[] = {
346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "fw_sst_0f28.bin", 346 {"10EC5640", "T100", "bytt100_rt5640", NULL, "intel/fw_sst_0f28.bin",
347 &byt_rvp_platform_data }, 347 &byt_rvp_platform_data },
348 {}, 348 {},
349}; 349};
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 26ec5117b35c..13d8507333b8 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -454,11 +454,11 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
454 454
455 i2s->playback_dma_data.addr = res->start + I2S_TXDR; 455 i2s->playback_dma_data.addr = res->start + I2S_TXDR;
456 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 456 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
457 i2s->playback_dma_data.maxburst = 16; 457 i2s->playback_dma_data.maxburst = 4;
458 458
459 i2s->capture_dma_data.addr = res->start + I2S_RXDR; 459 i2s->capture_dma_data.addr = res->start + I2S_RXDR;
460 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 460 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
461 i2s->capture_dma_data.maxburst = 16; 461 i2s->capture_dma_data.maxburst = 4;
462 462
463 i2s->dev = &pdev->dev; 463 i2s->dev = &pdev->dev;
464 dev_set_drvdata(&pdev->dev, i2s); 464 dev_set_drvdata(&pdev->dev, i2s);
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h
index 89a5d8bc6ee7..93f456f518a9 100644
--- a/sound/soc/rockchip/rockchip_i2s.h
+++ b/sound/soc/rockchip/rockchip_i2s.h
@@ -127,7 +127,7 @@
127#define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) 127#define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT)
128#define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) 128#define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT)
129#define I2S_DMACR_TDL_SHIFT 0 129#define I2S_DMACR_TDL_SHIFT 0
130#define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) 130#define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT)
131#define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT) 131#define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
132 132
133/* 133/*
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 985052b3fbed..2c62620abca6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3230,7 +3230,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3230 const char *propname) 3230 const char *propname)
3231{ 3231{
3232 struct device_node *np = card->dev->of_node; 3232 struct device_node *np = card->dev->of_node;
3233 int num_routes, old_routes; 3233 int num_routes;
3234 struct snd_soc_dapm_route *routes; 3234 struct snd_soc_dapm_route *routes;
3235 int i, ret; 3235 int i, ret;
3236 3236
@@ -3248,9 +3248,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3248 return -EINVAL; 3248 return -EINVAL;
3249 } 3249 }
3250 3250
3251 old_routes = card->num_dapm_routes; 3251 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3252 routes = devm_kzalloc(card->dev,
3253 (old_routes + num_routes) * sizeof(*routes),
3254 GFP_KERNEL); 3252 GFP_KERNEL);
3255 if (!routes) { 3253 if (!routes) {
3256 dev_err(card->dev, 3254 dev_err(card->dev,
@@ -3258,11 +3256,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3258 return -EINVAL; 3256 return -EINVAL;
3259 } 3257 }
3260 3258
3261 memcpy(routes, card->dapm_routes, old_routes * sizeof(*routes));
3262
3263 for (i = 0; i < num_routes; i++) { 3259 for (i = 0; i < num_routes; i++) {
3264 ret = of_property_read_string_index(np, propname, 3260 ret = of_property_read_string_index(np, propname,
3265 2 * i, &routes[old_routes + i].sink); 3261 2 * i, &routes[i].sink);
3266 if (ret) { 3262 if (ret) {
3267 dev_err(card->dev, 3263 dev_err(card->dev,
3268 "ASoC: Property '%s' index %d could not be read: %d\n", 3264 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3270,7 +3266,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3270 return -EINVAL; 3266 return -EINVAL;
3271 } 3267 }
3272 ret = of_property_read_string_index(np, propname, 3268 ret = of_property_read_string_index(np, propname,
3273 (2 * i) + 1, &routes[old_routes + i].source); 3269 (2 * i) + 1, &routes[i].source);
3274 if (ret) { 3270 if (ret) {
3275 dev_err(card->dev, 3271 dev_err(card->dev,
3276 "ASoC: Property '%s' index %d could not be read: %d\n", 3272 "ASoC: Property '%s' index %d could not be read: %d\n",
@@ -3279,7 +3275,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3279 } 3275 }
3280 } 3276 }
3281 3277
3282 card->num_dapm_routes += num_routes; 3278 card->num_dapm_routes = num_routes;
3283 card->dapm_routes = routes; 3279 card->dapm_routes = routes;
3284 3280
3285 return 0; 3281 return 0;
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index 272844746135..327f8642ca80 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -816,7 +816,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
816 return -EINVAL; 816 return -EINVAL;
817 } 817 }
818 818
819 if (cdev->n_streams < 2) { 819 if (cdev->n_streams < 1) {
820 dev_err(dev, "bogus number of streams: %d\n", cdev->n_streams); 820 dev_err(dev, "bogus number of streams: %d\n", cdev->n_streams);
821 return -EINVAL; 821 return -EINVAL;
822 } 822 }
diff --git a/tools/lib/lockdep/preload.c b/tools/lib/lockdep/preload.c
index 6f803609e498..0b0112c80f22 100644
--- a/tools/lib/lockdep/preload.c
+++ b/tools/lib/lockdep/preload.c
@@ -317,7 +317,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
317 * 317 *
318 * TODO: Hook into free() and add that check there as well. 318 * TODO: Hook into free() and add that check there as well.
319 */ 319 */
320 debug_check_no_locks_freed(mutex, mutex + sizeof(*mutex)); 320 debug_check_no_locks_freed(mutex, sizeof(*mutex));
321 __del_lock(__get_lock(mutex)); 321 __del_lock(__get_lock(mutex));
322 return ll_pthread_mutex_destroy(mutex); 322 return ll_pthread_mutex_destroy(mutex);
323} 323}
@@ -341,7 +341,7 @@ int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
341{ 341{
342 try_init_preload(); 342 try_init_preload();
343 343
344 debug_check_no_locks_freed(rwlock, rwlock + sizeof(*rwlock)); 344 debug_check_no_locks_freed(rwlock, sizeof(*rwlock));
345 __del_lock(__get_lock(rwlock)); 345 __del_lock(__get_lock(rwlock));
346 return ll_pthread_rwlock_destroy(rwlock); 346 return ll_pthread_rwlock_destroy(rwlock);
347} 347}
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index e7417fe97a97..747f86103599 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -232,7 +232,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
232 if (nr_samples > 0) { 232 if (nr_samples > 0) {
233 total_nr_samples += nr_samples; 233 total_nr_samples += nr_samples;
234 hists__collapse_resort(hists, NULL); 234 hists__collapse_resort(hists, NULL);
235 hists__output_resort(hists); 235 hists__output_resort(hists, NULL);
236 236
237 if (symbol_conf.event_group && 237 if (symbol_conf.event_group &&
238 !perf_evsel__is_group_leader(pos)) 238 !perf_evsel__is_group_leader(pos))
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 1ce425d101a9..1fd96c13f199 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -545,6 +545,42 @@ hist_entry__cmp_compute(struct hist_entry *left, struct hist_entry *right,
545 return __hist_entry__cmp_compute(p_left, p_right, c); 545 return __hist_entry__cmp_compute(p_left, p_right, c);
546} 546}
547 547
548static int64_t
549hist_entry__cmp_nop(struct hist_entry *left __maybe_unused,
550 struct hist_entry *right __maybe_unused)
551{
552 return 0;
553}
554
555static int64_t
556hist_entry__cmp_baseline(struct hist_entry *left, struct hist_entry *right)
557{
558 if (sort_compute)
559 return 0;
560
561 if (left->stat.period == right->stat.period)
562 return 0;
563 return left->stat.period > right->stat.period ? 1 : -1;
564}
565
566static int64_t
567hist_entry__cmp_delta(struct hist_entry *left, struct hist_entry *right)
568{
569 return hist_entry__cmp_compute(right, left, COMPUTE_DELTA);
570}
571
572static int64_t
573hist_entry__cmp_ratio(struct hist_entry *left, struct hist_entry *right)
574{
575 return hist_entry__cmp_compute(right, left, COMPUTE_RATIO);
576}
577
578static int64_t
579hist_entry__cmp_wdiff(struct hist_entry *left, struct hist_entry *right)
580{
581 return hist_entry__cmp_compute(right, left, COMPUTE_WEIGHTED_DIFF);
582}
583
548static void insert_hist_entry_by_compute(struct rb_root *root, 584static void insert_hist_entry_by_compute(struct rb_root *root,
549 struct hist_entry *he, 585 struct hist_entry *he,
550 int c) 586 int c)
@@ -605,7 +641,7 @@ static void hists__process(struct hists *hists)
605 hists__precompute(hists); 641 hists__precompute(hists);
606 hists__compute_resort(hists); 642 hists__compute_resort(hists);
607 } else { 643 } else {
608 hists__output_resort(hists); 644 hists__output_resort(hists, NULL);
609 } 645 }
610 646
611 hists__fprintf(hists, true, 0, 0, 0, stdout); 647 hists__fprintf(hists, true, 0, 0, 0, stdout);
@@ -1038,27 +1074,35 @@ static void data__hpp_register(struct data__file *d, int idx)
1038 fmt->header = hpp__header; 1074 fmt->header = hpp__header;
1039 fmt->width = hpp__width; 1075 fmt->width = hpp__width;
1040 fmt->entry = hpp__entry_global; 1076 fmt->entry = hpp__entry_global;
1077 fmt->cmp = hist_entry__cmp_nop;
1078 fmt->collapse = hist_entry__cmp_nop;
1041 1079
1042 /* TODO more colors */ 1080 /* TODO more colors */
1043 switch (idx) { 1081 switch (idx) {
1044 case PERF_HPP_DIFF__BASELINE: 1082 case PERF_HPP_DIFF__BASELINE:
1045 fmt->color = hpp__color_baseline; 1083 fmt->color = hpp__color_baseline;
1084 fmt->sort = hist_entry__cmp_baseline;
1046 break; 1085 break;
1047 case PERF_HPP_DIFF__DELTA: 1086 case PERF_HPP_DIFF__DELTA:
1048 fmt->color = hpp__color_delta; 1087 fmt->color = hpp__color_delta;
1088 fmt->sort = hist_entry__cmp_delta;
1049 break; 1089 break;
1050 case PERF_HPP_DIFF__RATIO: 1090 case PERF_HPP_DIFF__RATIO:
1051 fmt->color = hpp__color_ratio; 1091 fmt->color = hpp__color_ratio;
1092 fmt->sort = hist_entry__cmp_ratio;
1052 break; 1093 break;
1053 case PERF_HPP_DIFF__WEIGHTED_DIFF: 1094 case PERF_HPP_DIFF__WEIGHTED_DIFF:
1054 fmt->color = hpp__color_wdiff; 1095 fmt->color = hpp__color_wdiff;
1096 fmt->sort = hist_entry__cmp_wdiff;
1055 break; 1097 break;
1056 default: 1098 default:
1099 fmt->sort = hist_entry__cmp_nop;
1057 break; 1100 break;
1058 } 1101 }
1059 1102
1060 init_header(d, dfmt); 1103 init_header(d, dfmt);
1061 perf_hpp__column_register(fmt); 1104 perf_hpp__column_register(fmt);
1105 perf_hpp__register_sort_field(fmt);
1062} 1106}
1063 1107
1064static void ui_init(void) 1108static void ui_init(void)
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 011195e38f21..198f3c3aff95 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -19,7 +19,9 @@
19int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused) 19int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
20{ 20{
21 int i; 21 int i;
22 const struct option list_options[] = { 22 bool raw_dump = false;
23 struct option list_options[] = {
24 OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
23 OPT_END() 25 OPT_END()
24 }; 26 };
25 const char * const list_usage[] = { 27 const char * const list_usage[] = {
@@ -27,11 +29,18 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
27 NULL 29 NULL
28 }; 30 };
29 31
32 set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN);
33
30 argc = parse_options(argc, argv, list_options, list_usage, 34 argc = parse_options(argc, argv, list_options, list_usage,
31 PARSE_OPT_STOP_AT_NON_OPTION); 35 PARSE_OPT_STOP_AT_NON_OPTION);
32 36
33 setup_pager(); 37 setup_pager();
34 38
39 if (raw_dump) {
40 print_events(NULL, true);
41 return 0;
42 }
43
35 if (argc == 0) { 44 if (argc == 0) {
36 print_events(NULL, false); 45 print_events(NULL, false);
37 return 0; 46 return 0;
@@ -53,8 +62,6 @@ int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
53 print_hwcache_events(NULL, false); 62 print_hwcache_events(NULL, false);
54 else if (strcmp(argv[i], "pmu") == 0) 63 else if (strcmp(argv[i], "pmu") == 0)
55 print_pmu_events(NULL, false); 64 print_pmu_events(NULL, false);
56 else if (strcmp(argv[i], "--raw-dump") == 0)
57 print_events(NULL, true);
58 else { 65 else {
59 char *sep = strchr(argv[i], ':'), *s; 66 char *sep = strchr(argv[i], ':'), *s;
60 int sep_idx; 67 int sep_idx;
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 39367609c707..072ae8ad67fc 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -457,6 +457,19 @@ static void report__collapse_hists(struct report *rep)
457 ui_progress__finish(); 457 ui_progress__finish();
458} 458}
459 459
460static void report__output_resort(struct report *rep)
461{
462 struct ui_progress prog;
463 struct perf_evsel *pos;
464
465 ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");
466
467 evlist__for_each(rep->session->evlist, pos)
468 hists__output_resort(evsel__hists(pos), &prog);
469
470 ui_progress__finish();
471}
472
460static int __cmd_report(struct report *rep) 473static int __cmd_report(struct report *rep)
461{ 474{
462 int ret; 475 int ret;
@@ -505,13 +518,20 @@ static int __cmd_report(struct report *rep)
505 if (session_done()) 518 if (session_done())
506 return 0; 519 return 0;
507 520
521 /*
522 * recalculate number of entries after collapsing since it
523 * might be changed during the collapse phase.
524 */
525 rep->nr_entries = 0;
526 evlist__for_each(session->evlist, pos)
527 rep->nr_entries += evsel__hists(pos)->nr_entries;
528
508 if (rep->nr_entries == 0) { 529 if (rep->nr_entries == 0) {
509 ui__error("The %s file has no samples!\n", file->path); 530 ui__error("The %s file has no samples!\n", file->path);
510 return 0; 531 return 0;
511 } 532 }
512 533
513 evlist__for_each(session->evlist, pos) 534 report__output_resort(rep);
514 hists__output_resort(evsel__hists(pos));
515 535
516 return report__browse_hists(rep); 536 return report__browse_hists(rep);
517} 537}
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0aa7747ff139..961cea183a83 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -285,7 +285,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
285 } 285 }
286 286
287 hists__collapse_resort(hists, NULL); 287 hists__collapse_resort(hists, NULL);
288 hists__output_resort(hists); 288 hists__output_resort(hists, NULL);
289 289
290 hists__output_recalc_col_len(hists, top->print_entries - printed); 290 hists__output_recalc_col_len(hists, top->print_entries - printed);
291 putchar('\n'); 291 putchar('\n');
@@ -554,7 +554,7 @@ static void perf_top__sort_new_samples(void *arg)
554 } 554 }
555 555
556 hists__collapse_resort(hists, NULL); 556 hists__collapse_resort(hists, NULL);
557 hists__output_resort(hists); 557 hists__output_resort(hists, NULL);
558} 558}
559 559
560static void *display_thread_tui(void *arg) 560static void *display_thread_tui(void *arg)
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 614d5c4978ab..8d110dec393e 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -187,7 +187,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec
187 * function since TEST_ASSERT_VAL() returns in case of failure. 187 * function since TEST_ASSERT_VAL() returns in case of failure.
188 */ 188 */
189 hists__collapse_resort(hists, NULL); 189 hists__collapse_resort(hists, NULL);
190 hists__output_resort(hists); 190 hists__output_resort(hists, NULL);
191 191
192 if (verbose > 2) { 192 if (verbose > 2) {
193 pr_info("use callchain: %d, cumulate callchain: %d\n", 193 pr_info("use callchain: %d, cumulate callchain: %d\n",
@@ -454,12 +454,12 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
454 * 30.00% 10.00% perf perf [.] cmd_record 454 * 30.00% 10.00% perf perf [.] cmd_record
455 * 20.00% 0.00% bash libc [.] malloc 455 * 20.00% 0.00% bash libc [.] malloc
456 * 10.00% 10.00% bash [kernel] [k] page_fault 456 * 10.00% 10.00% bash [kernel] [k] page_fault
457 * 10.00% 10.00% perf [kernel] [k] schedule 457 * 10.00% 10.00% bash bash [.] xmalloc
458 * 10.00% 0.00% perf [kernel] [k] sys_perf_event_open
459 * 10.00% 10.00% perf [kernel] [k] page_fault 458 * 10.00% 10.00% perf [kernel] [k] page_fault
460 * 10.00% 10.00% perf libc [.] free
461 * 10.00% 10.00% perf libc [.] malloc 459 * 10.00% 10.00% perf libc [.] malloc
462 * 10.00% 10.00% bash bash [.] xmalloc 460 * 10.00% 10.00% perf [kernel] [k] schedule
461 * 10.00% 10.00% perf libc [.] free
462 * 10.00% 0.00% perf [kernel] [k] sys_perf_event_open
463 */ 463 */
464 struct result expected[] = { 464 struct result expected[] = {
465 { 7000, 2000, "perf", "perf", "main" }, 465 { 7000, 2000, "perf", "perf", "main" },
@@ -468,12 +468,12 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
468 { 3000, 1000, "perf", "perf", "cmd_record" }, 468 { 3000, 1000, "perf", "perf", "cmd_record" },
469 { 2000, 0, "bash", "libc", "malloc" }, 469 { 2000, 0, "bash", "libc", "malloc" },
470 { 1000, 1000, "bash", "[kernel]", "page_fault" }, 470 { 1000, 1000, "bash", "[kernel]", "page_fault" },
471 { 1000, 1000, "perf", "[kernel]", "schedule" }, 471 { 1000, 1000, "bash", "bash", "xmalloc" },
472 { 1000, 0, "perf", "[kernel]", "sys_perf_event_open" },
473 { 1000, 1000, "perf", "[kernel]", "page_fault" }, 472 { 1000, 1000, "perf", "[kernel]", "page_fault" },
473 { 1000, 1000, "perf", "[kernel]", "schedule" },
474 { 1000, 1000, "perf", "libc", "free" }, 474 { 1000, 1000, "perf", "libc", "free" },
475 { 1000, 1000, "perf", "libc", "malloc" }, 475 { 1000, 1000, "perf", "libc", "malloc" },
476 { 1000, 1000, "bash", "bash", "xmalloc" }, 476 { 1000, 0, "perf", "[kernel]", "sys_perf_event_open" },
477 }; 477 };
478 478
479 symbol_conf.use_callchain = false; 479 symbol_conf.use_callchain = false;
@@ -537,10 +537,13 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
537 * malloc 537 * malloc
538 * main 538 * main
539 * 539 *
540 * 10.00% 10.00% perf [kernel] [k] schedule 540 * 10.00% 10.00% bash bash [.] xmalloc
541 * | 541 * |
542 * --- schedule 542 * --- xmalloc
543 * run_command 543 * malloc
544 * xmalloc <--- NOTE: there's a cycle
545 * malloc
546 * xmalloc
544 * main 547 * main
545 * 548 *
546 * 10.00% 0.00% perf [kernel] [k] sys_perf_event_open 549 * 10.00% 0.00% perf [kernel] [k] sys_perf_event_open
@@ -556,6 +559,12 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
556 * run_command 559 * run_command
557 * main 560 * main
558 * 561 *
562 * 10.00% 10.00% perf [kernel] [k] schedule
563 * |
564 * --- schedule
565 * run_command
566 * main
567 *
559 * 10.00% 10.00% perf libc [.] free 568 * 10.00% 10.00% perf libc [.] free
560 * | 569 * |
561 * --- free 570 * --- free
@@ -570,15 +579,6 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
570 * run_command 579 * run_command
571 * main 580 * main
572 * 581 *
573 * 10.00% 10.00% bash bash [.] xmalloc
574 * |
575 * --- xmalloc
576 * malloc
577 * xmalloc <--- NOTE: there's a cycle
578 * malloc
579 * xmalloc
580 * main
581 *
582 */ 582 */
583 struct result expected[] = { 583 struct result expected[] = {
584 { 7000, 2000, "perf", "perf", "main" }, 584 { 7000, 2000, "perf", "perf", "main" },
@@ -587,12 +587,12 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
587 { 3000, 1000, "perf", "perf", "cmd_record" }, 587 { 3000, 1000, "perf", "perf", "cmd_record" },
588 { 2000, 0, "bash", "libc", "malloc" }, 588 { 2000, 0, "bash", "libc", "malloc" },
589 { 1000, 1000, "bash", "[kernel]", "page_fault" }, 589 { 1000, 1000, "bash", "[kernel]", "page_fault" },
590 { 1000, 1000, "perf", "[kernel]", "schedule" }, 590 { 1000, 1000, "bash", "bash", "xmalloc" },
591 { 1000, 0, "perf", "[kernel]", "sys_perf_event_open" }, 591 { 1000, 0, "perf", "[kernel]", "sys_perf_event_open" },
592 { 1000, 1000, "perf", "[kernel]", "page_fault" }, 592 { 1000, 1000, "perf", "[kernel]", "page_fault" },
593 { 1000, 1000, "perf", "[kernel]", "schedule" },
593 { 1000, 1000, "perf", "libc", "free" }, 594 { 1000, 1000, "perf", "libc", "free" },
594 { 1000, 1000, "perf", "libc", "malloc" }, 595 { 1000, 1000, "perf", "libc", "malloc" },
595 { 1000, 1000, "bash", "bash", "xmalloc" },
596 }; 596 };
597 struct callchain_result expected_callchain[] = { 597 struct callchain_result expected_callchain[] = {
598 { 598 {
@@ -622,9 +622,12 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
622 { "bash", "main" }, }, 622 { "bash", "main" }, },
623 }, 623 },
624 { 624 {
625 3, { { "[kernel]", "schedule" }, 625 6, { { "bash", "xmalloc" },
626 { "perf", "run_command" }, 626 { "libc", "malloc" },
627 { "perf", "main" }, }, 627 { "bash", "xmalloc" },
628 { "libc", "malloc" },
629 { "bash", "xmalloc" },
630 { "bash", "main" }, },
628 }, 631 },
629 { 632 {
630 3, { { "[kernel]", "sys_perf_event_open" }, 633 3, { { "[kernel]", "sys_perf_event_open" },
@@ -638,6 +641,11 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
638 { "perf", "main" }, }, 641 { "perf", "main" }, },
639 }, 642 },
640 { 643 {
644 3, { { "[kernel]", "schedule" },
645 { "perf", "run_command" },
646 { "perf", "main" }, },
647 },
648 {
641 4, { { "libc", "free" }, 649 4, { { "libc", "free" },
642 { "perf", "cmd_record" }, 650 { "perf", "cmd_record" },
643 { "perf", "run_command" }, 651 { "perf", "run_command" },
@@ -649,14 +657,6 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
649 { "perf", "run_command" }, 657 { "perf", "run_command" },
650 { "perf", "main" }, }, 658 { "perf", "main" }, },
651 }, 659 },
652 {
653 6, { { "bash", "xmalloc" },
654 { "libc", "malloc" },
655 { "bash", "xmalloc" },
656 { "libc", "malloc" },
657 { "bash", "xmalloc" },
658 { "bash", "main" }, },
659 },
660 }; 660 };
661 661
662 symbol_conf.use_callchain = true; 662 symbol_conf.use_callchain = true;
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 74f257a81265..59e53db7914c 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -138,7 +138,7 @@ int test__hists_filter(void)
138 struct hists *hists = evsel__hists(evsel); 138 struct hists *hists = evsel__hists(evsel);
139 139
140 hists__collapse_resort(hists, NULL); 140 hists__collapse_resort(hists, NULL);
141 hists__output_resort(hists); 141 hists__output_resort(hists, NULL);
142 142
143 if (verbose > 2) { 143 if (verbose > 2) {
144 pr_info("Normal histogram\n"); 144 pr_info("Normal histogram\n");
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index a748f2be1222..f5547610da02 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -152,7 +152,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine)
152 goto out; 152 goto out;
153 153
154 hists__collapse_resort(hists, NULL); 154 hists__collapse_resort(hists, NULL);
155 hists__output_resort(hists); 155 hists__output_resort(hists, NULL);
156 156
157 if (verbose > 2) { 157 if (verbose > 2) {
158 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order); 158 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -252,7 +252,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine)
252 goto out; 252 goto out;
253 253
254 hists__collapse_resort(hists, NULL); 254 hists__collapse_resort(hists, NULL);
255 hists__output_resort(hists); 255 hists__output_resort(hists, NULL);
256 256
257 if (verbose > 2) { 257 if (verbose > 2) {
258 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order); 258 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -306,7 +306,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine)
306 goto out; 306 goto out;
307 307
308 hists__collapse_resort(hists, NULL); 308 hists__collapse_resort(hists, NULL);
309 hists__output_resort(hists); 309 hists__output_resort(hists, NULL);
310 310
311 if (verbose > 2) { 311 if (verbose > 2) {
312 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order); 312 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -384,7 +384,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine)
384 goto out; 384 goto out;
385 385
386 hists__collapse_resort(hists, NULL); 386 hists__collapse_resort(hists, NULL);
387 hists__output_resort(hists); 387 hists__output_resort(hists, NULL);
388 388
389 if (verbose > 2) { 389 if (verbose > 2) {
390 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order); 390 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
@@ -487,7 +487,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine)
487 goto out; 487 goto out;
488 488
489 hists__collapse_resort(hists, NULL); 489 hists__collapse_resort(hists, NULL);
490 hists__output_resort(hists); 490 hists__output_resort(hists, NULL);
491 491
492 if (verbose > 2) { 492 if (verbose > 2) {
493 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order); 493 pr_info("[fields = %s, sort = %s]\n", field_order, sort_order);
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index e6bb04b5b09b..788506eef567 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -550,7 +550,7 @@ static int hist_browser__show_callchain(struct hist_browser *browser,
550 bool need_percent; 550 bool need_percent;
551 551
552 node = rb_first(root); 552 node = rb_first(root);
553 need_percent = !!rb_next(node); 553 need_percent = node && rb_next(node);
554 554
555 while (node) { 555 while (node) {
556 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node); 556 struct callchain_node *child = rb_entry(node, struct callchain_node, rb_node);
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index dc0d095f318c..482adae3cc44 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -204,6 +204,9 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b,
204 if (ret) 204 if (ret)
205 return ret; 205 return ret;
206 206
207 if (a->thread != b->thread || !symbol_conf.use_callchain)
208 return 0;
209
207 ret = b->callchain->max_depth - a->callchain->max_depth; 210 ret = b->callchain->max_depth - a->callchain->max_depth;
208 } 211 }
209 return ret; 212 return ret;
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index 2f612562978c..3c38f25b1695 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -1,5 +1,8 @@
1#include <signal.h> 1#include <signal.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#ifdef HAVE_BACKTRACE_SUPPORT
4#include <execinfo.h>
5#endif
3 6
4#include "../../util/cache.h" 7#include "../../util/cache.h"
5#include "../../util/debug.h" 8#include "../../util/debug.h"
@@ -88,6 +91,25 @@ int ui__getch(int delay_secs)
88 return SLkp_getkey(); 91 return SLkp_getkey();
89} 92}
90 93
94#ifdef HAVE_BACKTRACE_SUPPORT
95static void ui__signal_backtrace(int sig)
96{
97 void *stackdump[32];
98 size_t size;
99
100 ui__exit(false);
101 psignal(sig, "perf");
102
103 printf("-------- backtrace --------\n");
104 size = backtrace(stackdump, ARRAY_SIZE(stackdump));
105 backtrace_symbols_fd(stackdump, size, STDOUT_FILENO);
106
107 exit(0);
108}
109#else
110# define ui__signal_backtrace ui__signal
111#endif
112
91static void ui__signal(int sig) 113static void ui__signal(int sig)
92{ 114{
93 ui__exit(false); 115 ui__exit(false);
@@ -122,8 +144,8 @@ int ui__init(void)
122 ui_browser__init(); 144 ui_browser__init();
123 tui_progress__init(); 145 tui_progress__init();
124 146
125 signal(SIGSEGV, ui__signal); 147 signal(SIGSEGV, ui__signal_backtrace);
126 signal(SIGFPE, ui__signal); 148 signal(SIGFPE, ui__signal_backtrace);
127 signal(SIGINT, ui__signal); 149 signal(SIGINT, ui__signal);
128 signal(SIGQUIT, ui__signal); 150 signal(SIGQUIT, ui__signal);
129 signal(SIGTERM, ui__signal); 151 signal(SIGTERM, ui__signal);
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 64b377e591e4..14e7a123d43b 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -841,3 +841,33 @@ char *callchain_list__sym_name(struct callchain_list *cl,
841 841
842 return bf; 842 return bf;
843} 843}
844
845static void free_callchain_node(struct callchain_node *node)
846{
847 struct callchain_list *list, *tmp;
848 struct callchain_node *child;
849 struct rb_node *n;
850
851 list_for_each_entry_safe(list, tmp, &node->val, list) {
852 list_del(&list->list);
853 free(list);
854 }
855
856 n = rb_first(&node->rb_root_in);
857 while (n) {
858 child = container_of(n, struct callchain_node, rb_node_in);
859 n = rb_next(n);
860 rb_erase(&child->rb_node_in, &node->rb_root_in);
861
862 free_callchain_node(child);
863 free(child);
864 }
865}
866
867void free_callchain(struct callchain_root *root)
868{
869 if (!symbol_conf.use_callchain)
870 return;
871
872 free_callchain_node(&root->node);
873}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index dbc08cf5f970..c0ec1acc38e4 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -198,4 +198,6 @@ static inline int arch_skip_callchain_idx(struct thread *thread __maybe_unused,
198char *callchain_list__sym_name(struct callchain_list *cl, 198char *callchain_list__sym_name(struct callchain_list *cl,
199 char *bf, size_t bfsize, bool show_dso); 199 char *bf, size_t bfsize, bool show_dso);
200 200
201void free_callchain(struct callchain_root *root);
202
201#endif /* __PERF_CALLCHAIN_H */ 203#endif /* __PERF_CALLCHAIN_H */
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 6e88b9e395df..182395546ddc 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -6,6 +6,7 @@
6#include "evlist.h" 6#include "evlist.h"
7#include "evsel.h" 7#include "evsel.h"
8#include "annotate.h" 8#include "annotate.h"
9#include "ui/progress.h"
9#include <math.h> 10#include <math.h>
10 11
11static bool hists__filter_entry_by_dso(struct hists *hists, 12static bool hists__filter_entry_by_dso(struct hists *hists,
@@ -303,7 +304,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template,
303 size_t callchain_size = 0; 304 size_t callchain_size = 0;
304 struct hist_entry *he; 305 struct hist_entry *he;
305 306
306 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) 307 if (symbol_conf.use_callchain)
307 callchain_size = sizeof(struct callchain_root); 308 callchain_size = sizeof(struct callchain_root);
308 309
309 he = zalloc(sizeof(*he) + callchain_size); 310 he = zalloc(sizeof(*he) + callchain_size);
@@ -736,7 +737,7 @@ iter_add_single_cumulative_entry(struct hist_entry_iter *iter,
736 iter->he = he; 737 iter->he = he;
737 he_cache[iter->curr++] = he; 738 he_cache[iter->curr++] = he;
738 739
739 callchain_append(he->callchain, &callchain_cursor, sample->period); 740 hist_entry__append_callchain(he, sample);
740 741
741 /* 742 /*
742 * We need to re-initialize the cursor since callchain_append() 743 * We need to re-initialize the cursor since callchain_append()
@@ -809,7 +810,8 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
809 iter->he = he; 810 iter->he = he;
810 he_cache[iter->curr++] = he; 811 he_cache[iter->curr++] = he;
811 812
812 callchain_append(he->callchain, &cursor, sample->period); 813 if (symbol_conf.use_callchain)
814 callchain_append(he->callchain, &cursor, sample->period);
813 return 0; 815 return 0;
814} 816}
815 817
@@ -945,6 +947,7 @@ void hist_entry__free(struct hist_entry *he)
945 zfree(&he->mem_info); 947 zfree(&he->mem_info);
946 zfree(&he->stat_acc); 948 zfree(&he->stat_acc);
947 free_srcline(he->srcline); 949 free_srcline(he->srcline);
950 free_callchain(he->callchain);
948 free(he); 951 free(he);
949} 952}
950 953
@@ -987,6 +990,7 @@ static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
987 else 990 else
988 p = &(*p)->rb_right; 991 p = &(*p)->rb_right;
989 } 992 }
993 hists->nr_entries++;
990 994
991 rb_link_node(&he->rb_node_in, parent, p); 995 rb_link_node(&he->rb_node_in, parent, p);
992 rb_insert_color(&he->rb_node_in, root); 996 rb_insert_color(&he->rb_node_in, root);
@@ -1024,7 +1028,10 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
1024 if (!sort__need_collapse) 1028 if (!sort__need_collapse)
1025 return; 1029 return;
1026 1030
1031 hists->nr_entries = 0;
1032
1027 root = hists__get_rotate_entries_in(hists); 1033 root = hists__get_rotate_entries_in(hists);
1034
1028 next = rb_first(root); 1035 next = rb_first(root);
1029 1036
1030 while (next) { 1037 while (next) {
@@ -1119,7 +1126,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
1119 rb_insert_color(&he->rb_node, entries); 1126 rb_insert_color(&he->rb_node, entries);
1120} 1127}
1121 1128
1122void hists__output_resort(struct hists *hists) 1129void hists__output_resort(struct hists *hists, struct ui_progress *prog)
1123{ 1130{
1124 struct rb_root *root; 1131 struct rb_root *root;
1125 struct rb_node *next; 1132 struct rb_node *next;
@@ -1148,6 +1155,9 @@ void hists__output_resort(struct hists *hists)
1148 1155
1149 if (!n->filtered) 1156 if (!n->filtered)
1150 hists__calc_col_len(hists, n); 1157 hists__calc_col_len(hists, n);
1158
1159 if (prog)
1160 ui_progress__update(prog, 1);
1151 } 1161 }
1152} 1162}
1153 1163
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index d0ef9a19a744..46bd50344f85 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -121,7 +121,7 @@ int hist_entry__sort_snprintf(struct hist_entry *he, char *bf, size_t size,
121 struct hists *hists); 121 struct hists *hists);
122void hist_entry__free(struct hist_entry *); 122void hist_entry__free(struct hist_entry *);
123 123
124void hists__output_resort(struct hists *hists); 124void hists__output_resort(struct hists *hists, struct ui_progress *prog);
125void hists__collapse_resort(struct hists *hists, struct ui_progress *prog); 125void hists__collapse_resort(struct hists *hists, struct ui_progress *prog);
126 126
127void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); 127void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 28eb1417cb2a..7f9b8632e433 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -495,9 +495,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev,
495 } 495 }
496 496
497 if (ntevs == 0) { /* No error but failed to find probe point. */ 497 if (ntevs == 0) { /* No error but failed to find probe point. */
498 pr_warning("Probe point '%s' not found.\n", 498 pr_warning("Probe point '%s' not found in debuginfo.\n",
499 synthesize_perf_probe_point(&pev->point)); 499 synthesize_perf_probe_point(&pev->point));
500 return -ENOENT; 500 if (need_dwarf)
501 return -ENOENT;
502 return 0;
501 } 503 }
502 /* Error path : ntevs < 0 */ 504 /* Error path : ntevs < 0 */
503 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs); 505 pr_debug("An error occurred in debuginfo analysis (%d).\n", ntevs);
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index c7918f83b300..b5247d777f0e 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -989,8 +989,24 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
989 int ret = 0; 989 int ret = 0;
990 990
991#if _ELFUTILS_PREREQ(0, 142) 991#if _ELFUTILS_PREREQ(0, 142)
992 Elf *elf;
993 GElf_Ehdr ehdr;
994 GElf_Shdr shdr;
995
992 /* Get the call frame information from this dwarf */ 996 /* Get the call frame information from this dwarf */
993 pf->cfi = dwarf_getcfi_elf(dwarf_getelf(dbg->dbg)); 997 elf = dwarf_getelf(dbg->dbg);
998 if (elf == NULL)
999 return -EINVAL;
1000
1001 if (gelf_getehdr(elf, &ehdr) == NULL)
1002 return -EINVAL;
1003
1004 if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
1005 shdr.sh_type == SHT_PROGBITS) {
1006 pf->cfi = dwarf_getcfi_elf(elf);
1007 } else {
1008 pf->cfi = dwarf_getcfi(dbg->dbg);
1009 }
994#endif 1010#endif
995 1011
996 off = 0; 1012 off = 0;
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
index 7cdcf88659c7..9ea914378985 100644
--- a/tools/power/cpupower/utils/cpupower.c
+++ b/tools/power/cpupower/utils/cpupower.c
@@ -199,7 +199,7 @@ int main(int argc, const char *argv[])
199 } 199 }
200 200
201 get_cpu_info(0, &cpupower_cpu_info); 201 get_cpu_info(0, &cpupower_cpu_info);
202 run_as_root = !getuid(); 202 run_as_root = !geteuid();
203 if (run_as_root) { 203 if (run_as_root) {
204 ret = uname(&uts); 204 ret = uname(&uts);
205 if (!ret && !strcmp(uts.machine, "x86_64") && 205 if (!ret && !strcmp(uts.machine, "x86_64") &&
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 09afe5d87f2b..4e8fe2c7b054 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -361,7 +361,7 @@ unsigned int sysfs_get_idlestate_count(unsigned int cpu)
361 361
362 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpuidle"); 362 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpuidle");
363 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) 363 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
364 return -ENODEV; 364 return 0;
365 365
366 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/cpuidle/state0", cpu); 366 snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/cpuidle/state0", cpu);
367 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) 367 if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c
index 33a5c06d95ca..d273624c93a6 100644
--- a/tools/testing/selftests/exec/execveat.c
+++ b/tools/testing/selftests/exec/execveat.c
@@ -179,11 +179,11 @@ static int check_execveat_pathmax(int dot_dfd, const char *src, int is_script)
179 */ 179 */
180 fd = open(longpath, O_RDONLY); 180 fd = open(longpath, O_RDONLY);
181 if (fd > 0) { 181 if (fd > 0) {
182 printf("Invoke copy of '%s' via filename of length %lu:\n", 182 printf("Invoke copy of '%s' via filename of length %zu:\n",
183 src, strlen(longpath)); 183 src, strlen(longpath));
184 fail += check_execveat(fd, "", AT_EMPTY_PATH); 184 fail += check_execveat(fd, "", AT_EMPTY_PATH);
185 } else { 185 } else {
186 printf("Failed to open length %lu filename, errno=%d (%s)\n", 186 printf("Failed to open length %zu filename, errno=%d (%s)\n",
187 strlen(longpath), errno, strerror(errno)); 187 strlen(longpath), errno, strerror(errno));
188 fail++; 188 fail++;
189 } 189 }
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index f5283438ee05..1cc6e2e19982 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -671,6 +671,7 @@ static void update_memslots(struct kvm_memslots *slots,
671 671
672 WARN_ON(mslots[i].id != id); 672 WARN_ON(mslots[i].id != id);
673 if (!new->npages) { 673 if (!new->npages) {
674 WARN_ON(!mslots[i].npages);
674 new->base_gfn = 0; 675 new->base_gfn = 0;
675 if (mslots[i].npages) 676 if (mslots[i].npages)
676 slots->used_slots--; 677 slots->used_slots--;
@@ -687,12 +688,25 @@ static void update_memslots(struct kvm_memslots *slots,
687 slots->id_to_index[mslots[i].id] = i; 688 slots->id_to_index[mslots[i].id] = i;
688 i++; 689 i++;
689 } 690 }
690 while (i > 0 && 691
691 new->base_gfn > mslots[i - 1].base_gfn) { 692 /*
692 mslots[i] = mslots[i - 1]; 693 * The ">=" is needed when creating a slot with base_gfn == 0,
693 slots->id_to_index[mslots[i].id] = i; 694 * so that it moves before all those with base_gfn == npages == 0.
694 i--; 695 *
695 } 696 * On the other hand, if new->npages is zero, the above loop has
697 * already left i pointing to the beginning of the empty part of
698 * mslots, and the ">=" would move the hole backwards in this
699 * case---which is wrong. So skip the loop when deleting a slot.
700 */
701 if (new->npages) {
702 while (i > 0 &&
703 new->base_gfn >= mslots[i - 1].base_gfn) {
704 mslots[i] = mslots[i - 1];
705 slots->id_to_index[mslots[i].id] = i;
706 i--;
707 }
708 } else
709 WARN_ON_ONCE(i != slots->used_slots);
696 710
697 mslots[i] = *new; 711 mslots[i] = *new;
698 slots->id_to_index[mslots[i].id] = i; 712 slots->id_to_index[mslots[i].id] = i;