aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-05-12 13:19:14 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-12 13:19:14 -0400
commit5f013c9bc70214dcacd5fbed5a06c217d6ff9c59 (patch)
tree34c3a633000e03bca57d0ce55d8759f86edecc03
parent51ee42efa0829cf9e46f8e1c0ab7a9ab6facf3f2 (diff)
parent1a466ae96e9f749d02a73315a3e66375e61a61dd (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/ethernet/altera/altera_sgdma.c net/netlink/af_netlink.c net/sched/cls_api.c net/sched/sch_api.c The netlink conflict dealt with moving to netlink_capable() and netlink_ns_capable() in the 'net' tree vs. supporting 'tc' operations in non-init namespaces. These were simple transformations from netlink_capable to netlink_ns_capable. The Altera driver conflict was simply code removal overlapping some void pointer cast cleanups in net-next. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/arm/arch_timer.txt3
-rw-r--r--Documentation/devicetree/bindings/ata/apm-xgene.txt3
-rw-r--r--Documentation/devicetree/bindings/net/arc_emac.txt12
-rw-r--r--Documentation/devicetree/bindings/net/mdio-gpio.txt2
-rw-r--r--Documentation/devicetree/bindings/net/socfpga-dwmac.txt2
-rw-r--r--Documentation/devicetree/bindings/net/stmmac.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-st.txt4
-rw-r--r--Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/tlv320aic31xx.txt6
-rw-r--r--MAINTAINERS16
-rw-r--r--Makefile2
-rw-r--r--arch/arc/kernel/entry.S8
-rw-r--r--arch/arm/Kconfig17
-rw-r--r--arch/arm/Kconfig.debug12
-rw-r--r--arch/arm/boot/dts/Makefile20
-rw-r--r--arch/arm/boot/dts/am335x-bone-common.dtsi4
-rw-r--r--arch/arm/boot/dts/am335x-evm.dts8
-rw-r--r--arch/arm/boot/dts/am335x-evmsk.dts4
-rw-r--r--arch/arm/boot/dts/am335x-igep0033.dtsi5
-rw-r--r--arch/arm/boot/dts/am33xx.dtsi10
-rw-r--r--arch/arm/boot/dts/am4372.dtsi4
-rw-r--r--arch/arm/boot/dts/armada-370-xp.dtsi1
-rw-r--r--arch/arm/boot/dts/armada-38x.dtsi1
-rw-r--r--arch/arm/boot/dts/dra7.dtsi4
-rw-r--r--arch/arm/boot/dts/dra7xx-clocks.dtsi2
-rw-r--r--arch/arm/boot/dts/imx25.dtsi1
-rw-r--r--arch/arm/boot/dts/imx27-apf27.dts1
-rw-r--r--arch/arm/boot/dts/imx27.dtsi1
-rw-r--r--arch/arm/boot/dts/imx50.dtsi4
-rw-r--r--arch/arm/boot/dts/imx51.dtsi4
-rw-r--r--arch/arm/boot/dts/imx53-m53evk.dts23
-rw-r--r--arch/arm/boot/dts/imx53-qsb-common.dtsi3
-rw-r--r--arch/arm/boot/dts/imx53-tx53-x03x.dts11
-rw-r--r--arch/arm/boot/dts/imx53.dtsi6
-rw-r--r--arch/arm/boot/dts/imx6q-dmo-edmqmx6.dts48
-rw-r--r--arch/arm/boot/dts/imx6q-gw5400-a.dts3
-rw-r--r--arch/arm/boot/dts/imx6qdl-gw52xx.dtsi3
-rw-r--r--arch/arm/boot/dts/imx6qdl-microsom-ar8035.dtsi22
-rw-r--r--arch/arm/boot/dts/imx6qdl.dtsi13
-rw-r--r--arch/arm/boot/dts/imx6sl-evk.dts1
-rw-r--r--arch/arm/boot/dts/imx6sl.dtsi4
-rw-r--r--arch/arm/boot/dts/kirkwood-b3.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-cloudbox.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-dreamplug.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-laplug.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-ns2-common.dtsi4
-rw-r--r--arch/arm/boot/dts/kirkwood-nsa310.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-nsa310a.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-openblocks_a6.dts2
-rw-r--r--arch/arm/boot/dts/kirkwood-openblocks_a7.dts2
-rw-r--r--arch/arm/boot/dts/omap3-beagle-xm-ab.dts16
-rw-r--r--arch/arm/boot/dts/omap3-devkit8000.dts1
-rw-r--r--arch/arm/boot/dts/omap3-lilly-a83x.dtsi1
-rw-r--r--arch/arm/boot/dts/omap3.dtsi2
-rw-r--r--arch/arm/boot/dts/omap4.dtsi4
-rw-r--r--arch/arm/boot/dts/omap5.dtsi10
-rw-r--r--arch/arm/boot/dts/r8a7740.dtsi1
-rw-r--r--arch/arm/boot/dts/r8a7790-lager.dts4
-rw-r--r--arch/arm/boot/dts/r8a7791-koelsch.dts6
-rw-r--r--arch/arm/boot/dts/rk3188.dtsi8
-rw-r--r--arch/arm/boot/dts/sh73a0.dtsi1
-rw-r--r--arch/arm/boot/dts/stih415-pinctrl.dtsi10
-rw-r--r--arch/arm/boot/dts/stih416-pinctrl.dtsi10
-rw-r--r--arch/arm/boot/dts/tegra124.dtsi13
-rw-r--r--arch/arm/boot/dts/vf610-twr.dts2
-rw-r--r--arch/arm/boot/dts/vf610.dtsi4
-rw-r--r--arch/arm/boot/dts/zynq-7000.dtsi23
-rw-r--r--arch/arm/boot/dts/zynq-zc702.dts76
-rw-r--r--arch/arm/boot/dts/zynq-zc706.dts68
-rw-r--r--arch/arm/common/bL_switcher.c6
-rw-r--r--arch/arm/common/mcpm_entry.c5
-rw-r--r--arch/arm/configs/omap2plus_defconfig2
-rw-r--r--arch/arm/configs/u300_defconfig4
-rw-r--r--arch/arm/configs/u8500_defconfig24
-rw-r--r--arch/arm/include/asm/cputype.h14
-rw-r--r--arch/arm/include/asm/div64.h2
-rw-r--r--arch/arm/include/asm/mcpm.h7
-rw-r--r--arch/arm/include/asm/tlb.h12
-rw-r--r--arch/arm/include/uapi/asm/unistd.h1
-rw-r--r--arch/arm/kernel/Makefile1
-rw-r--r--arch/arm/kernel/calls.S1
-rw-r--r--arch/arm/kernel/head.S2
-rw-r--r--arch/arm/kernel/iwmmxt.S8
-rw-r--r--arch/arm/kernel/machine_kexec.c7
-rw-r--r--arch/arm/kernel/pj4-cp0.c42
-rw-r--r--arch/arm/kernel/sys_oabi-compat.c6
-rw-r--r--arch/arm/kvm/Kconfig2
-rw-r--r--arch/arm/kvm/mmu.c15
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c2
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c2
-rw-r--r--arch/arm/mach-imx/clk-imx6q.c29
-rw-r--r--arch/arm/mach-omap2/board-rx51-video.c2
-rw-r--r--arch/arm/mach-omap2/clkt_dpll.c4
-rw-r--r--arch/arm/mach-omap2/gpmc.c15
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c3
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c4
-rw-r--r--arch/arm/mach-omap2/pm34xx.c4
-rw-r--r--arch/arm/mach-pxa/include/mach/hx4700.h1
-rw-r--r--arch/arm/mach-rockchip/platsmp.c2
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c1
-rw-r--r--arch/arm/mach-shmobile/board-lager.c4
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7778.c2
-rw-r--r--arch/arm/mach-spear/time.c2
-rw-r--r--arch/arm/mach-tegra/Kconfig3
-rw-r--r--arch/arm/mach-vexpress/dcscb.c7
-rw-r--r--arch/arm/mach-vexpress/spc.c4
-rw-r--r--arch/arm/mm/Kconfig8
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm/vfp/vfpdouble.c2
-rw-r--r--arch/arm/vfp/vfpsingle.c2
-rw-r--r--arch/arm64/Kconfig2
-rw-r--r--arch/arm64/boot/dts/apm-storm.dtsi3
-rw-r--r--arch/arm64/include/asm/mmu.h3
-rw-r--r--arch/arm64/include/asm/tlb.h6
-rw-r--r--arch/arm64/include/asm/unistd32.h3
-rw-r--r--arch/arm64/kernel/debug-monitors.c3
-rw-r--r--arch/arm64/kernel/early_printk.c6
-rw-r--r--arch/arm64/kernel/setup.c3
-rw-r--r--arch/arm64/kernel/time.c2
-rw-r--r--arch/arm64/mm/dma-mapping.c35
-rw-r--r--arch/arm64/mm/mmu.c3
-rw-r--r--arch/hexagon/include/asm/barrier.h37
-rw-r--r--arch/ia64/include/asm/tlb.h42
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c2
-rw-r--r--arch/parisc/include/uapi/asm/Kbuild3
-rw-r--r--arch/parisc/include/uapi/asm/resource.h7
-rw-r--r--arch/powerpc/boot/main.c8
-rw-r--r--arch/powerpc/boot/ops.h2
-rw-r--r--arch/powerpc/boot/ps3.c4
-rw-r--r--arch/powerpc/include/asm/opal.h42
-rw-r--r--arch/powerpc/include/uapi/asm/setup.h7
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c1
-rw-r--r--arch/powerpc/kernel/rtas_flash.c2
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S18
-rw-r--r--arch/powerpc/mm/hash_native_64.c38
-rw-r--r--arch/powerpc/perf/hv-24x7.c35
-rw-r--r--arch/powerpc/perf/hv-gpci.c6
-rw-r--r--arch/powerpc/platforms/powernv/opal-dump.c94
-rw-r--r--arch/powerpc/platforms/powernv/opal-elog.c11
-rw-r--r--arch/powerpc/platforms/powernv/opal-flash.c118
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c32
-rw-r--r--arch/powerpc/platforms/powernv/opal.c69
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c3
-rw-r--r--arch/powerpc/platforms/powernv/setup.c48
-rw-r--r--arch/powerpc/platforms/powernv/smp.c3
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c5
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c10
-rw-r--r--arch/powerpc/sysdev/ppc4xx_pci.c2
-rw-r--r--arch/s390/include/asm/ccwgroup.h2
-rw-r--r--arch/s390/include/asm/tlb.h13
-rw-r--r--arch/s390/net/bpf_jit_comp.c1
-rw-r--r--arch/sh/include/asm/tlb.h8
-rw-r--r--arch/um/include/asm/tlb.h16
-rw-r--r--arch/um/include/shared/os.h1
-rw-r--r--arch/um/kernel/physmem.c1
-rw-r--r--arch/um/os-Linux/file.c6
-rw-r--r--arch/um/os-Linux/main.c1
-rw-r--r--arch/um/os-Linux/mem.c372
-rw-r--r--arch/x86/Makefile4
-rw-r--r--arch/x86/kernel/apic/io_apic.c5
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_rapl.c3
-rw-r--r--arch/x86/kernel/vsmp_64.c11
-rw-r--r--arch/x86/kvm/vmx.c53
-rw-r--r--arch/x86/vdso/vdso-layout.lds.S19
-rw-r--r--arch/xtensa/Kconfig20
-rw-r--r--arch/xtensa/boot/dts/kc705.dts11
-rw-r--r--arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi28
-rw-r--r--arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi48
-rw-r--r--arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi32
-rw-r--r--arch/xtensa/boot/dts/xtfpga.dtsi37
-rw-r--r--arch/xtensa/include/asm/bootparam.h13
-rw-r--r--arch/xtensa/include/asm/fixmap.h58
-rw-r--r--arch/xtensa/include/asm/highmem.h45
-rw-r--r--arch/xtensa/include/asm/pgtable.h4
-rw-r--r--arch/xtensa/include/asm/sysmem.h38
-rw-r--r--arch/xtensa/include/asm/tlbflush.h11
-rw-r--r--arch/xtensa/kernel/setup.c46
-rw-r--r--arch/xtensa/kernel/smp.c15
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c7
-rw-r--r--arch/xtensa/mm/Makefile1
-rw-r--r--arch/xtensa/mm/cache.c7
-rw-r--r--arch/xtensa/mm/highmem.c72
-rw-r--r--arch/xtensa/mm/init.c299
-rw-r--r--arch/xtensa/mm/mmu.c36
-rw-r--r--arch/xtensa/mm/tlb.c15
-rw-r--r--arch/xtensa/platforms/iss/Makefile3
-rw-r--r--arch/xtensa/platforms/xt2000/setup.c12
-rw-r--r--crypto/crypto_user.c2
-rw-r--r--drivers/acpi/acpi_processor.c7
-rw-r--r--drivers/acpi/acpica/exfield.c104
-rw-r--r--drivers/acpi/bus.c5
-rw-r--r--drivers/acpi/ec.c21
-rw-r--r--drivers/ata/Kconfig5
-rw-r--r--drivers/ata/ahci.c35
-rw-r--r--drivers/ata/ahci.h1
-rw-r--r--drivers/ata/libata-core.c27
-rw-r--r--drivers/ata/pata_arasan_cf.c7
-rw-r--r--drivers/ata/pata_at91.c11
-rw-r--r--drivers/ata/pata_samsung_cf.c10
-rw-r--r--drivers/base/dd.c17
-rw-r--r--drivers/base/platform.c7
-rw-r--r--drivers/block/floppy.c11
-rw-r--r--drivers/bluetooth/ath3k.c2
-rw-r--r--drivers/bluetooth/btusb.c5
-rw-r--r--drivers/clk/tegra/clk-tegra124.c3
-rw-r--r--drivers/clk/versatile/clk-vexpress-osc.c4
-rw-r--r--drivers/clocksource/arm_arch_timer.c6
-rw-r--r--drivers/clocksource/exynos_mct.c12
-rw-r--r--drivers/clocksource/zevio-timer.c7
-rw-r--r--drivers/connector/cn_proc.c2
-rw-r--r--drivers/cpufreq/Kconfig.arm6
-rw-r--r--drivers/cpufreq/longhaul.c36
-rw-r--r--drivers/cpufreq/powernow-k6.c23
-rw-r--r--drivers/cpufreq/powernow-k7.c4
-rw-r--r--drivers/cpufreq/powernv-cpufreq.c1
-rw-r--r--drivers/cpufreq/ppc-corenet-cpufreq.c5
-rw-r--r--drivers/cpufreq/unicore2-cpufreq.c4
-rw-r--r--drivers/dma/Kconfig2
-rw-r--r--drivers/dma/edma.c6
-rw-r--r--drivers/dma/fsl-edma.c12
-rw-r--r--drivers/dma/sirf-dma.c2
-rw-r--r--drivers/gpio/gpiolib-acpi.c12
-rw-r--r--drivers/gpio/gpiolib.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dmabuf.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c2
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c18
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_display.c23
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c11
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h3
-rw-r--r--drivers/gpu/drm/i915/intel_fbdev.c10
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c9
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c54
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h1
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c9
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_irq.c4
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c21
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h4
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c4
-rw-r--r--drivers/gpu/drm/msm/msm_fbdev.c5
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c1
-rw-r--r--drivers/gpu/drm/radeon/cik_sdma.c2
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c35
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c84
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c51
-rw-r--r--drivers/gpu/drm/tegra/dc.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c22
-rw-r--r--drivers/hwmon/coretemp.c4
-rw-r--r--drivers/hwmon/ltc2945.c6
-rw-r--r--drivers/hwmon/vexpress.c83
-rw-r--r--drivers/idle/intel_idle.c3
-rw-r--r--drivers/iio/adc/Kconfig4
-rw-r--r--drivers/iio/adc/at91_adc.c33
-rw-r--r--drivers/iio/adc/exynos_adc.c6
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c7
-rw-r--r--drivers/iio/industrialio-buffer.c6
-rw-r--r--drivers/iio/light/cm32181.c1
-rw-r--r--drivers/iio/light/cm36651.c22
-rw-r--r--drivers/infiniband/hw/cxgb4/Kconfig6
-rw-r--r--drivers/infiniband/hw/cxgb4/cm.c39
-rw-r--r--drivers/infiniband/hw/cxgb4/iw_cxgb4.h1
-rw-r--r--drivers/infiniband/hw/cxgb4/qp.c13
-rw-r--r--drivers/infiniband/hw/cxgb4/t4fw_ri_api.h14
-rw-r--r--drivers/input/misc/da9055_onkey.c1
-rw-r--r--drivers/input/misc/soc_button_array.c1
-rw-r--r--drivers/input/mouse/elantech.c1
-rw-r--r--drivers/input/mouse/synaptics.c97
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h15
-rw-r--r--drivers/input/serio/i8042.c6
-rw-r--r--drivers/input/serio/serio.c14
-rw-r--r--drivers/input/tablet/wacom_sys.c246
-rw-r--r--drivers/input/tablet/wacom_wac.c29
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/iommu/arm-smmu.c4
-rw-r--r--drivers/iommu/dmar.c3
-rw-r--r--drivers/iommu/intel-iommu.c10
-rw-r--r--drivers/irqchip/irq-armada-370-xp.c54
-rw-r--r--drivers/irqchip/irq-crossbar.c2
-rw-r--r--drivers/irqchip/irq-gic.c8
-rw-r--r--drivers/md/dm-cache-target.c1
-rw-r--r--drivers/md/dm-thin.c77
-rw-r--r--drivers/md/dm-verity.c15
-rw-r--r--drivers/media/platform/Kconfig2
-rw-r--r--drivers/mtd/ubi/block.c2
-rw-r--r--drivers/mtd/ubi/wl.c6
-rw-r--r--drivers/net/bonding/bond_sysfs.c2
-rw-r--r--drivers/net/can/c_can/Kconfig7
-rw-r--r--drivers/net/can/c_can/c_can.c660
-rw-r--r--drivers/net/can/c_can/c_can.h23
-rw-r--r--drivers/net/can/c_can/c_can_pci.c9
-rw-r--r--drivers/net/can/c_can/c_can_platform.c2
-rw-r--r--drivers/net/can/dev.c2
-rw-r--r--drivers/net/can/sja1000/sja1000_isa.c16
-rw-r--r--drivers/net/can/slcan.c6
-rw-r--r--drivers/net/ethernet/Kconfig12
-rw-r--r--drivers/net/ethernet/Makefile1
-rw-r--r--drivers/net/ethernet/altera/Kconfig1
-rw-r--r--drivers/net/ethernet/altera/altera_msgdma.c8
-rw-r--r--drivers/net/ethernet/altera/altera_msgdma.h3
-rw-r--r--drivers/net/ethernet/altera/altera_sgdma.c179
-rw-r--r--drivers/net/ethernet/altera/altera_sgdma.h3
-rw-r--r--drivers/net/ethernet/altera/altera_tse.h6
-rw-r--r--drivers/net/ethernet/altera/altera_tse_ethtool.c8
-rw-r--r--drivers/net/ethernet/altera/altera_tse_main.c77
-rw-r--r--drivers/net/ethernet/arc/emac.h2
-rw-r--r--drivers/net/ethernet/arc/emac_main.c61
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c58
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c2
-rw-r--r--drivers/net/ethernet/cadence/Kconfig4
-rw-r--r--drivers/net/ethernet/cadence/macb.c35
-rw-r--r--drivers/net/ethernet/chelsio/Kconfig13
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c2
-rw-r--r--drivers/net/ethernet/ec_bhf.c706
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c223
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c3
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c71
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.h3
-rw-r--r--drivers/net/ethernet/intel/e1000e/phy.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c5
-rw-r--r--drivers/net/ethernet/jme.c53
-rw-r--r--drivers/net/ethernet/marvell/mvmdio.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/port.c35
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c23
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic.h16
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c66
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c9
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h2
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c22
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c7
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h3
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c13
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c31
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h4
-rw-r--r--drivers/net/ethernet/sun/cassini.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c17
-rw-r--r--drivers/net/hyperv/netvsc_drv.c4
-rw-r--r--drivers/net/macvlan.c3
-rw-r--r--drivers/net/macvtap.c9
-rw-r--r--drivers/net/phy/mdio-gpio.c4
-rw-r--r--drivers/net/phy/phy.c11
-rw-r--r--drivers/net/slip/slip.c6
-rw-r--r--drivers/net/team/team.c2
-rw-r--r--drivers/net/usb/cdc_mbim.c57
-rw-r--r--drivers/net/usb/cdc_ncm.c2
-rw-r--r--drivers/net/usb/qmi_wwan.c28
-rw-r--r--drivers/net/wireless/ath/ath9k/ahb.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/ani.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug_sta.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c9
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c14
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/chip.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c22
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/trx.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c6
-rw-r--r--drivers/of/irq.c28
-rw-r--r--drivers/of/platform.c4
-rw-r--r--drivers/of/selftest.c32
-rw-r--r--drivers/of/testcase-data/tests-interrupts.dtsi13
-rw-r--r--drivers/phy/Kconfig1
-rw-r--r--drivers/phy/Makefile9
-rw-r--r--drivers/phy/phy-core.c3
-rw-r--r--drivers/pinctrl/pinctrl-as3722.c17
-rw-r--r--drivers/pinctrl/pinctrl-single.c13
-rw-r--r--drivers/pinctrl/pinctrl-tb10x.c3
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7790.c3
-rw-r--r--drivers/pinctrl/sh-pfc/pfc-r8a7791.c2
-rw-r--r--drivers/pnp/pnpacpi/core.c44
-rw-r--r--drivers/pnp/quirks.c79
-rw-r--r--drivers/power/reset/vexpress-poweroff.c19
-rw-r--r--drivers/ptp/Kconfig3
-rw-r--r--drivers/regulator/pbias-regulator.c76
-rw-r--r--drivers/s390/cio/chsc.c22
-rw-r--r--drivers/scsi/hpsa.c8
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c1
-rw-r--r--drivers/scsi/scsi_error.c12
-rw-r--r--drivers/scsi/scsi_lib.c6
-rw-r--r--drivers/scsi/scsi_netlink.c2
-rw-r--r--drivers/scsi/virtio_scsi.c6
-rw-r--r--drivers/spi/spi-atmel.c3
-rw-r--r--drivers/spi/spi-bfin5xx.c1
-rw-r--r--drivers/spi/spi-sh-hspi.c4
-rw-r--r--drivers/spi/spi-sirf.c20
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c9
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c2
-rw-r--r--drivers/staging/iio/resolver/ad2s1200.c4
-rw-r--r--drivers/tty/hvc/hvc_console.c2
-rw-r--r--drivers/tty/n_tty.c4
-rw-r--r--drivers/tty/serial/8250/8250_core.c4
-rw-r--r--drivers/tty/serial/8250/8250_dma.c9
-rw-r--r--drivers/tty/serial/samsung.c23
-rw-r--r--drivers/tty/serial/serial_core.c39
-rw-r--r--drivers/tty/tty_buffer.c17
-rw-r--r--drivers/usb/chipidea/core.c37
-rw-r--r--drivers/usb/dwc3/core.c2
-rw-r--r--drivers/usb/dwc3/gadget.c12
-rw-r--r--drivers/usb/gadget/at91_udc.c10
-rw-r--r--drivers/usb/gadget/f_fs.c7
-rw-r--r--drivers/usb/gadget/f_rndis.c2
-rw-r--r--drivers/usb/gadget/fsl_udc_core.c6
-rw-r--r--drivers/usb/gadget/inode.c1
-rw-r--r--drivers/usb/gadget/rndis.c1
-rw-r--r--drivers/usb/gadget/u_ether.c101
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/ehci-fsl.c3
-rw-r--r--drivers/usb/host/ohci-hub.c18
-rw-r--r--drivers/usb/host/ohci-pci.c1
-rw-r--r--drivers/usb/host/ohci.h2
-rw-r--r--drivers/usb/host/xhci-pci.c6
-rw-r--r--drivers/usb/host/xhci-ring.c67
-rw-r--r--drivers/usb/host/xhci.c7
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--drivers/usb/musb/musb_dsps.c5
-rw-r--r--drivers/usb/musb/omap2430.c8
-rw-r--r--drivers/usb/phy/phy-am335x-control.c9
-rw-r--r--drivers/usb/phy/phy-fsm-usb.c9
-rw-r--r--drivers/usb/phy/phy.c3
-rw-r--r--drivers/usb/serial/io_ti.c50
-rw-r--r--drivers/usb/serial/option.c81
-rw-r--r--drivers/usb/serial/qcserial.c24
-rw-r--r--drivers/usb/serial/usb-serial.c4
-rw-r--r--drivers/usb/storage/shuttle_usbat.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h14
-rw-r--r--drivers/usb/wusbcore/mmc.c2
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c4
-rw-r--r--drivers/uwb/drp.c9
-rw-r--r--fs/aio.c42
-rw-r--r--fs/btrfs/ctree.h14
-rw-r--r--fs/btrfs/disk-io.c10
-rw-r--r--fs/btrfs/extent-tree.c6
-rw-r--r--fs/btrfs/file.c8
-rw-r--r--fs/btrfs/inode-map.c24
-rw-r--r--fs/btrfs/ioctl.c4
-rw-r--r--fs/btrfs/send.c5
-rw-r--r--fs/btrfs/super.c22
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/ceph/dir.c33
-rw-r--r--fs/ceph/file.c3
-rw-r--r--fs/ceph/inode.c71
-rw-r--r--fs/ceph/ioctl.c3
-rw-r--r--fs/ceph/locks.c1
-rw-r--r--fs/ceph/super.h1
-rw-r--r--fs/compat.c14
-rw-r--r--fs/coredump.c7
-rw-r--r--fs/ext4/balloc.c2
-rw-r--r--fs/ext4/ext4.h17
-rw-r--r--fs/ext4/extents.c109
-rw-r--r--fs/ext4/extents_status.c2
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/inode.c53
-rw-r--r--fs/ext4/mballoc.c18
-rw-r--r--fs/ext4/page-io.c5
-rw-r--r--fs/ext4/super.c51
-rw-r--r--fs/ext4/xattr.c23
-rw-r--r--fs/fcntl.c12
-rw-r--r--fs/kernfs/dir.c9
-rw-r--r--fs/kernfs/file.c2
-rw-r--r--fs/locks.c55
-rw-r--r--fs/nfsd/nfs4callback.c4
-rw-r--r--fs/nfsd/nfs4xdr.c8
-rw-r--r--fs/open.c21
-rw-r--r--fs/ubifs/super.c2
-rw-r--r--fs/xfs/xfs_file.c10
-rw-r--r--include/asm-generic/fixmap.h3
-rw-r--r--include/asm-generic/word-at-a-time.h8
-rw-r--r--include/dt-bindings/clock/tegra124-car.h6
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/ftrace.h2
-rw-r--r--include/linux/interrupt.h35
-rw-r--r--include/linux/irq.h5
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/netdevice.h7
-rw-r--r--include/linux/netlink.h7
-rw-r--r--include/linux/of_irq.h5
-rw-r--r--include/linux/of_mdio.h7
-rw-r--r--include/linux/phy/phy.h16
-rw-r--r--include/linux/regulator/consumer.h4
-rw-r--r--include/linux/serio.h1
-rw-r--r--include/linux/sock_diag.h2
-rw-r--r--include/net/af_vsock.h6
-rw-r--r--include/net/cfg80211.h12
-rw-r--r--include/net/netns/ipv4.h9
-rw-r--r--include/net/sock.h5
-rw-r--r--include/trace/events/ext4.h9
-rw-r--r--include/trace/events/module.h2
-rw-r--r--include/uapi/asm-generic/fcntl.h20
-rw-r--r--include/uapi/linux/input.h1
-rw-r--r--kernel/audit.c4
-rw-r--r--kernel/hrtimer.c22
-rw-r--r--kernel/irq/irqdesc.c7
-rw-r--r--kernel/irq/manage.c17
-rw-r--r--kernel/module.c6
-rw-r--r--kernel/power/suspend.c3
-rw-r--r--kernel/softirq.c5
-rw-r--r--kernel/timer.c2
-rw-r--r--kernel/trace/ftrace.c27
-rw-r--r--kernel/trace/trace_events_trigger.c2
-rw-r--r--mm/memory.c58
-rw-r--r--mm/vmacache.c8
-rw-r--r--net/bluetooth/hci_conn.c9
-rw-r--r--net/bluetooth/hci_event.c6
-rw-r--r--net/bridge/br_netfilter.c4
-rw-r--r--net/bridge/br_netlink.c15
-rw-r--r--net/can/gw.c4
-rw-r--r--net/ceph/osdmap.c9
-rw-r--r--net/core/dev.c22
-rw-r--r--net/core/rtnetlink.c53
-rw-r--r--net/core/sock.c49
-rw-r--r--net/core/sock_diag.c4
-rw-r--r--net/dcb/dcbnl.c2
-rw-r--r--net/decnet/dn_dev.c4
-rw-r--r--net/decnet/dn_fib.c4
-rw-r--r--net/decnet/netfilter/dn_rtmsg.c2
-rw-r--r--net/ipv4/af_inet.c36
-rw-r--r--net/ipv4/fib_semantics.c2
-rw-r--r--net/ipv4/inet_connection_sock.c8
-rw-r--r--net/ipv4/ip_forward.c54
-rw-r--r--net/ipv4/ip_fragment.c5
-rw-r--r--net/ipv4/ip_output.c51
-rw-r--r--net/ipv4/ip_tunnel.c2
-rw-r--r--net/ipv4/netfilter/nf_defrag_ipv4.c5
-rw-r--r--net/ipv4/ping.c6
-rw-r--r--net/ipv4/sysctl_net_ipv4.c42
-rw-r--r--net/ipv4/tcp_cubic.c2
-rw-r--r--net/ipv4/tcp_output.c14
-rw-r--r--net/ipv6/ip6_fib.c3
-rw-r--r--net/ipv6/ip6_output.c6
-rw-r--r--net/ipv6/ip6mr.c2
-rw-r--r--net/ipv6/netfilter.c6
-rw-r--r--net/ipv6/netfilter/ip6t_rpfilter.c1
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/mac80211/rx.c3
-rw-r--r--net/mac80211/sta_info.c3
-rw-r--r--net/mac80211/status.c5
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c3
-rw-r--r--net/netfilter/nfnetlink.c11
-rw-r--r--net/netlink/af_netlink.c75
-rw-r--r--net/netlink/genetlink.c2
-rw-r--r--net/packet/diag.c7
-rw-r--r--net/phonet/pn_netlink.c8
-rw-r--r--net/sched/act_api.c2
-rw-r--r--net/sched/cls_api.c2
-rw-r--r--net/sched/sch_api.c6
-rw-r--r--net/sched/sch_hhf.c11
-rw-r--r--net/sctp/protocol.c7
-rw-r--r--net/sctp/sm_sideeffect.c7
-rw-r--r--net/tipc/netlink.c2
-rw-r--r--net/vmw_vsock/af_vsock.c47
-rw-r--r--net/wireless/scan.c12
-rw-r--r--net/wireless/sme.c2
-rw-r--r--net/xfrm/xfrm_user.c2
-rw-r--r--scripts/sortextable.c5
-rw-r--r--security/selinux/hooks.c6
-rw-r--r--sound/pci/hda/hda_controller.c34
-rw-r--r--sound/pci/hda/hda_intel.c3
-rw-r--r--sound/pci/hda/hda_priv.h1
-rw-r--r--sound/pci/hda/patch_realtek.c1
-rw-r--r--sound/soc/codecs/alc5623.c2
-rw-r--r--sound/soc/codecs/cs42l52.c6
-rw-r--r--sound/soc/codecs/cs42l73.c6
-rw-r--r--sound/soc/codecs/tlv320aic3x.c9
-rw-r--r--sound/soc/fsl/fsl_spdif.h4
-rw-r--r--sound/soc/intel/sst-dsp-priv.h2
-rw-r--r--sound/soc/intel/sst-haswell-ipc.c7
-rw-r--r--sound/soc/jz4740/Makefile2
-rw-r--r--sound/soc/sh/rcar/src.c4
-rw-r--r--sound/soc/sh/rcar/ssi.c4
-rw-r--r--sound/soc/soc-dapm.c1
-rw-r--r--tools/lib/api/fs/debugfs.c4
-rw-r--r--tools/lib/traceevent/event-parse.c1
-rw-r--r--tools/lib/traceevent/event-parse.h4
-rw-r--r--tools/net/bpf_dbg.c2
-rw-r--r--tools/perf/Makefile.perf2
-rw-r--r--tools/perf/arch/x86/tests/dwarf-unwind.c3
-rw-r--r--tools/perf/arch/x86/tests/regs_load.S8
-rw-r--r--tools/perf/builtin-kvm.c1
-rw-r--r--tools/perf/builtin-record.c2
-rw-r--r--tools/perf/config/Makefile46
-rw-r--r--tools/perf/tests/make2
-rw-r--r--tools/perf/util/data.c9
-rw-r--r--tools/perf/util/machine.c16
-rw-r--r--tools/perf/util/symbol-elf.c2
-rw-r--r--tools/power/acpi/Makefile11
-rw-r--r--virt/kvm/arm/vgic.c15
-rw-r--r--virt/kvm/assigned-dev.c3
-rw-r--r--virt/kvm/async_pf.c8
600 files changed, 6816 insertions, 3513 deletions
diff --git a/Documentation/devicetree/bindings/arm/arch_timer.txt b/Documentation/devicetree/bindings/arm/arch_timer.txt
index 06fc7602593a..37b2cafa4e52 100644
--- a/Documentation/devicetree/bindings/arm/arch_timer.txt
+++ b/Documentation/devicetree/bindings/arm/arch_timer.txt
@@ -19,6 +19,9 @@ to deliver its interrupts via SPIs.
19 19
20- clock-frequency : The frequency of the main counter, in Hz. Optional. 20- clock-frequency : The frequency of the main counter, in Hz. Optional.
21 21
22- always-on : a boolean property. If present, the timer is powered through an
23 always-on power domain, therefore it never loses context.
24
22Example: 25Example:
23 26
24 timer { 27 timer {
diff --git a/Documentation/devicetree/bindings/ata/apm-xgene.txt b/Documentation/devicetree/bindings/ata/apm-xgene.txt
index 7bcfbf59810e..a668f0e7d001 100644
--- a/Documentation/devicetree/bindings/ata/apm-xgene.txt
+++ b/Documentation/devicetree/bindings/ata/apm-xgene.txt
@@ -24,6 +24,7 @@ Required properties:
24 * "sata-phy" for the SATA 6.0Gbps PHY 24 * "sata-phy" for the SATA 6.0Gbps PHY
25 25
26Optional properties: 26Optional properties:
27- dma-coherent : Present if dma operations are coherent
27- status : Shall be "ok" if enabled or "disabled" if disabled. 28- status : Shall be "ok" if enabled or "disabled" if disabled.
28 Default is "ok". 29 Default is "ok".
29 30
@@ -55,6 +56,7 @@ Example:
55 <0x0 0x1f22e000 0x0 0x1000>, 56 <0x0 0x1f22e000 0x0 0x1000>,
56 <0x0 0x1f227000 0x0 0x1000>; 57 <0x0 0x1f227000 0x0 0x1000>;
57 interrupts = <0x0 0x87 0x4>; 58 interrupts = <0x0 0x87 0x4>;
59 dma-coherent;
58 status = "ok"; 60 status = "ok";
59 clocks = <&sataclk 0>; 61 clocks = <&sataclk 0>;
60 phys = <&phy2 0>; 62 phys = <&phy2 0>;
@@ -69,6 +71,7 @@ Example:
69 <0x0 0x1f23e000 0x0 0x1000>, 71 <0x0 0x1f23e000 0x0 0x1000>,
70 <0x0 0x1f237000 0x0 0x1000>; 72 <0x0 0x1f237000 0x0 0x1000>;
71 interrupts = <0x0 0x88 0x4>; 73 interrupts = <0x0 0x88 0x4>;
74 dma-coherent;
72 status = "ok"; 75 status = "ok";
73 clocks = <&sataclk 0>; 76 clocks = <&sataclk 0>;
74 phys = <&phy3 0>; 77 phys = <&phy3 0>;
diff --git a/Documentation/devicetree/bindings/net/arc_emac.txt b/Documentation/devicetree/bindings/net/arc_emac.txt
index 7fbb027218a1..a1d71eb43b20 100644
--- a/Documentation/devicetree/bindings/net/arc_emac.txt
+++ b/Documentation/devicetree/bindings/net/arc_emac.txt
@@ -4,11 +4,15 @@ Required properties:
4- compatible: Should be "snps,arc-emac" 4- compatible: Should be "snps,arc-emac"
5- reg: Address and length of the register set for the device 5- reg: Address and length of the register set for the device
6- interrupts: Should contain the EMAC interrupts 6- interrupts: Should contain the EMAC interrupts
7- clock-frequency: CPU frequency. It is needed to calculate and set polling
8period of EMAC.
9- max-speed: see ethernet.txt file in the same directory. 7- max-speed: see ethernet.txt file in the same directory.
10- phy: see ethernet.txt file in the same directory. 8- phy: see ethernet.txt file in the same directory.
11 9
10Clock handling:
11The clock frequency is needed to calculate and set polling period of EMAC.
12It must be provided by one of:
13- clock-frequency: CPU frequency.
14- clocks: reference to the clock supplying the EMAC.
15
12Child nodes of the driver are the individual PHY devices connected to the 16Child nodes of the driver are the individual PHY devices connected to the
13MDIO bus. They must have a "reg" property given the PHY address on the MDIO bus. 17MDIO bus. They must have a "reg" property given the PHY address on the MDIO bus.
14 18
@@ -19,7 +23,11 @@ Examples:
19 reg = <0xc0fc2000 0x3c>; 23 reg = <0xc0fc2000 0x3c>;
20 interrupts = <6>; 24 interrupts = <6>;
21 mac-address = [ 00 11 22 33 44 55 ]; 25 mac-address = [ 00 11 22 33 44 55 ];
26
22 clock-frequency = <80000000>; 27 clock-frequency = <80000000>;
28 /* or */
29 clocks = <&emac_clock>;
30
23 max-speed = <100>; 31 max-speed = <100>;
24 phy = <&phy0>; 32 phy = <&phy0>;
25 33
diff --git a/Documentation/devicetree/bindings/net/mdio-gpio.txt b/Documentation/devicetree/bindings/net/mdio-gpio.txt
index c79bab025369..8dbcf8295c6c 100644
--- a/Documentation/devicetree/bindings/net/mdio-gpio.txt
+++ b/Documentation/devicetree/bindings/net/mdio-gpio.txt
@@ -14,7 +14,7 @@ node.
14Example: 14Example:
15 15
16aliases { 16aliases {
17 mdio-gpio0 = <&mdio0>; 17 mdio-gpio0 = &mdio0;
18}; 18};
19 19
20mdio0: mdio { 20mdio0: mdio {
diff --git a/Documentation/devicetree/bindings/net/socfpga-dwmac.txt b/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
index 636f0ac4e223..2a60cd3e8d5d 100644
--- a/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
@@ -23,5 +23,5 @@ gmac0: ethernet@ff700000 {
23 interrupt-names = "macirq"; 23 interrupt-names = "macirq";
24 mac-address = [00 00 00 00 00 00];/* Filled in by U-Boot */ 24 mac-address = [00 00 00 00 00 00];/* Filled in by U-Boot */
25 clocks = <&emac_0_clk>; 25 clocks = <&emac_0_clk>;
26 clocks-names = "stmmaceth"; 26 clock-names = "stmmaceth";
27}; 27};
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index 80c1fb8bfbb8..a2acd2b26baf 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -33,7 +33,7 @@ Optional properties:
33- max-frame-size: See ethernet.txt file in the same directory 33- max-frame-size: See ethernet.txt file in the same directory
34- clocks: If present, the first clock should be the GMAC main clock, 34- clocks: If present, the first clock should be the GMAC main clock,
35 further clocks may be specified in derived bindings. 35 further clocks may be specified in derived bindings.
36- clocks-names: One name for each entry in the clocks property, the 36- clock-names: One name for each entry in the clocks property, the
37 first one should be "stmmaceth". 37 first one should be "stmmaceth".
38 38
39Examples: 39Examples:
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-st.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-st.txt
index 4bd5be0e5e7d..26bcb18f4e60 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-st.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-st.txt
@@ -83,7 +83,7 @@ Example:
83 reg = <0xfe61f080 0x4>; 83 reg = <0xfe61f080 0x4>;
84 reg-names = "irqmux"; 84 reg-names = "irqmux";
85 interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>; 85 interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
86 interrupts-names = "irqmux"; 86 interrupt-names = "irqmux";
87 ranges = <0 0xfe610000 0x5000>; 87 ranges = <0 0xfe610000 0x5000>;
88 88
89 PIO0: gpio@fe610000 { 89 PIO0: gpio@fe610000 {
@@ -165,7 +165,7 @@ sdhci0:sdhci@fe810000{
165 interrupt-parent = <&PIO3>; 165 interrupt-parent = <&PIO3>;
166 #interrupt-cells = <2>; 166 #interrupt-cells = <2>;
167 interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; /* Interrupt line via PIO3-3 */ 167 interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; /* Interrupt line via PIO3-3 */
168 interrupts-names = "card-detect"; 168 interrupt-names = "card-detect";
169 pinctrl-names = "default"; 169 pinctrl-names = "default";
170 pinctrl-0 = <&pinctrl_mmc>; 170 pinctrl-0 = <&pinctrl_mmc>;
171}; 171};
diff --git a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
index 569b26c4a81e..60ca07996458 100644
--- a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
+++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt
@@ -47,7 +47,7 @@ mcasp0: mcasp0@1d00000 {
47 reg = <0x100000 0x3000>; 47 reg = <0x100000 0x3000>;
48 reg-names "mpu"; 48 reg-names "mpu";
49 interrupts = <82>, <83>; 49 interrupts = <82>, <83>;
50 interrupts-names = "tx", "rx"; 50 interrupt-names = "tx", "rx";
51 op-mode = <0>; /* MCASP_IIS_MODE */ 51 op-mode = <0>; /* MCASP_IIS_MODE */
52 tdm-slots = <2>; 52 tdm-slots = <2>;
53 serial-dir = < 53 serial-dir = <
diff --git a/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt b/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
index 74c66dee3e14..eff12be5e789 100644
--- a/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
+++ b/Documentation/devicetree/bindings/sound/tlv320aic31xx.txt
@@ -13,6 +13,9 @@ Required properties:
13 "ti,tlv320aic3111" - TLV320AIC3111 (stereo speaker amp, MiniDSP) 13 "ti,tlv320aic3111" - TLV320AIC3111 (stereo speaker amp, MiniDSP)
14 14
15- reg - <int> - I2C slave address 15- reg - <int> - I2C slave address
16- HPVDD-supply, SPRVDD-supply, SPLVDD-supply, AVDD-supply, IOVDD-supply,
17 DVDD-supply : power supplies for the device as covered in
18 Documentation/devicetree/bindings/regulator/regulator.txt
16 19
17 20
18Optional properties: 21Optional properties:
@@ -24,9 +27,6 @@ Optional properties:
24 3 or MICBIAS_AVDD - MICBIAS output is connected to AVDD 27 3 or MICBIAS_AVDD - MICBIAS output is connected to AVDD
25 If this node is not mentioned or if the value is unknown, then 28 If this node is not mentioned or if the value is unknown, then
26 micbias is set to 2.0V. 29 micbias is set to 2.0V.
27- HPVDD-supply, SPRVDD-supply, SPLVDD-supply, AVDD-supply, IOVDD-supply,
28 DVDD-supply : power supplies for the device as covered in
29 Documentation/devicetree/bindings/regulator/regulator.txt
30 30
31CODEC output pins: 31CODEC output pins:
32 * HPL 32 * HPL
diff --git a/MAINTAINERS b/MAINTAINERS
index 7bb7eadd078c..bde15ffcccf9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3491,6 +3491,12 @@ S: Maintained
3491F: drivers/extcon/ 3491F: drivers/extcon/
3492F: Documentation/extcon/ 3492F: Documentation/extcon/
3493 3493
3494EXYNOS DP DRIVER
3495M: Jingoo Han <jg1.han@samsung.com>
3496L: dri-devel@lists.freedesktop.org
3497S: Maintained
3498F: drivers/gpu/drm/exynos/exynos_dp*
3499
3494EXYNOS MIPI DISPLAY DRIVERS 3500EXYNOS MIPI DISPLAY DRIVERS
3495M: Inki Dae <inki.dae@samsung.com> 3501M: Inki Dae <inki.dae@samsung.com>
3496M: Donghwa Lee <dh09.lee@samsung.com> 3502M: Donghwa Lee <dh09.lee@samsung.com>
@@ -3556,7 +3562,7 @@ F: include/scsi/libfcoe.h
3556F: include/uapi/scsi/fc/ 3562F: include/uapi/scsi/fc/
3557 3563
3558FILE LOCKING (flock() and fcntl()/lockf()) 3564FILE LOCKING (flock() and fcntl()/lockf())
3559M: Jeff Layton <jlayton@redhat.com> 3565M: Jeff Layton <jlayton@poochiereds.net>
3560M: J. Bruce Fields <bfields@fieldses.org> 3566M: J. Bruce Fields <bfields@fieldses.org>
3561L: linux-fsdevel@vger.kernel.org 3567L: linux-fsdevel@vger.kernel.org
3562S: Maintained 3568S: Maintained
@@ -5114,14 +5120,19 @@ F: drivers/s390/kvm/
5114 5120
5115KERNEL VIRTUAL MACHINE (KVM) FOR ARM 5121KERNEL VIRTUAL MACHINE (KVM) FOR ARM
5116M: Christoffer Dall <christoffer.dall@linaro.org> 5122M: Christoffer Dall <christoffer.dall@linaro.org>
5123M: Marc Zyngier <marc.zyngier@arm.com>
5124L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
5117L: kvmarm@lists.cs.columbia.edu 5125L: kvmarm@lists.cs.columbia.edu
5118W: http://systems.cs.columbia.edu/projects/kvm-arm 5126W: http://systems.cs.columbia.edu/projects/kvm-arm
5119S: Supported 5127S: Supported
5120F: arch/arm/include/uapi/asm/kvm* 5128F: arch/arm/include/uapi/asm/kvm*
5121F: arch/arm/include/asm/kvm* 5129F: arch/arm/include/asm/kvm*
5122F: arch/arm/kvm/ 5130F: arch/arm/kvm/
5131F: virt/kvm/arm/
5132F: include/kvm/arm_*
5123 5133
5124KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64) 5134KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)
5135M: Christoffer Dall <christoffer.dall@linaro.org>
5125M: Marc Zyngier <marc.zyngier@arm.com> 5136M: Marc Zyngier <marc.zyngier@arm.com>
5126L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 5137L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
5127L: kvmarm@lists.cs.columbia.edu 5138L: kvmarm@lists.cs.columbia.edu
@@ -7283,7 +7294,6 @@ F: drivers/video/aty/aty128fb.c
7283RALINK RT2X00 WIRELESS LAN DRIVER 7294RALINK RT2X00 WIRELESS LAN DRIVER
7284P: rt2x00 project 7295P: rt2x00 project
7285M: Ivo van Doorn <IvDoorn@gmail.com> 7296M: Ivo van Doorn <IvDoorn@gmail.com>
7286M: Gertjan van Wingerde <gwingerde@gmail.com>
7287M: Helmut Schaa <helmut.schaa@googlemail.com> 7297M: Helmut Schaa <helmut.schaa@googlemail.com>
7288L: linux-wireless@vger.kernel.org 7298L: linux-wireless@vger.kernel.org
7289L: users@rt2x00.serialmonkey.com (moderated for non-subscribers) 7299L: users@rt2x00.serialmonkey.com (moderated for non-subscribers)
@@ -7299,7 +7309,7 @@ F: Documentation/blockdev/ramdisk.txt
7299F: drivers/block/brd.c 7309F: drivers/block/brd.c
7300 7310
7301RANDOM NUMBER DRIVER 7311RANDOM NUMBER DRIVER
7302M: Theodore Ts'o" <tytso@mit.edu> 7312M: "Theodore Ts'o" <tytso@mit.edu>
7303S: Maintained 7313S: Maintained
7304F: drivers/char/random.c 7314F: drivers/char/random.c
7305 7315
diff --git a/Makefile b/Makefile
index 60ccbfe750a2..28a7259e0f3b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 15 2PATCHLEVEL = 15
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc4
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index 819dd5f7eb05..29b82adbf0b4 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -614,11 +614,13 @@ resume_user_mode_begin:
614 614
615resume_kernel_mode: 615resume_kernel_mode:
616 616
617#ifdef CONFIG_PREEMPT 617 ; Disable Interrupts from this point on
618 618 ; CONFIG_PREEMPT: This is a must for preempt_schedule_irq()
619 ; This is a must for preempt_schedule_irq() 619 ; !CONFIG_PREEMPT: To ensure restore_regs is intr safe
620 IRQ_DISABLE r9 620 IRQ_DISABLE r9
621 621
622#ifdef CONFIG_PREEMPT
623
622 ; Can't preempt if preemption disabled 624 ; Can't preempt if preemption disabled
623 GET_CURR_THR_INFO_FROM_SP r10 625 GET_CURR_THR_INFO_FROM_SP r10
624 ld r8, [r10, THREAD_INFO_PREEMPT_COUNT] 626 ld r8, [r10, THREAD_INFO_PREEMPT_COUNT]
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ab438cb5af55..db3c5414223e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -30,9 +30,9 @@ config ARM
30 select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT) 30 select HAVE_ARCH_SECCOMP_FILTER if (AEABI && !OABI_COMPAT)
31 select HAVE_ARCH_TRACEHOOK 31 select HAVE_ARCH_TRACEHOOK
32 select HAVE_BPF_JIT 32 select HAVE_BPF_JIT
33 select HAVE_CC_STACKPROTECTOR
33 select HAVE_CONTEXT_TRACKING 34 select HAVE_CONTEXT_TRACKING
34 select HAVE_C_RECORDMCOUNT 35 select HAVE_C_RECORDMCOUNT
35 select HAVE_CC_STACKPROTECTOR
36 select HAVE_DEBUG_KMEMLEAK 36 select HAVE_DEBUG_KMEMLEAK
37 select HAVE_DMA_API_DEBUG 37 select HAVE_DMA_API_DEBUG
38 select HAVE_DMA_ATTRS 38 select HAVE_DMA_ATTRS
@@ -311,6 +311,7 @@ config ARCH_MULTIPLATFORM
311 select ARM_HAS_SG_CHAIN 311 select ARM_HAS_SG_CHAIN
312 select ARM_PATCH_PHYS_VIRT 312 select ARM_PATCH_PHYS_VIRT
313 select AUTO_ZRELADDR 313 select AUTO_ZRELADDR
314 select CLKSRC_OF
314 select COMMON_CLK 315 select COMMON_CLK
315 select GENERIC_CLOCKEVENTS 316 select GENERIC_CLOCKEVENTS
316 select MULTI_IRQ_HANDLER 317 select MULTI_IRQ_HANDLER
@@ -422,8 +423,8 @@ config ARCH_EFM32
422 bool "Energy Micro efm32" 423 bool "Energy Micro efm32"
423 depends on !MMU 424 depends on !MMU
424 select ARCH_REQUIRE_GPIOLIB 425 select ARCH_REQUIRE_GPIOLIB
425 select AUTO_ZRELADDR
426 select ARM_NVIC 426 select ARM_NVIC
427 select AUTO_ZRELADDR
427 select CLKSRC_OF 428 select CLKSRC_OF
428 select COMMON_CLK 429 select COMMON_CLK
429 select CPU_V7M 430 select CPU_V7M
@@ -511,8 +512,8 @@ config ARCH_IXP4XX
511 bool "IXP4xx-based" 512 bool "IXP4xx-based"
512 depends on MMU 513 depends on MMU
513 select ARCH_HAS_DMA_SET_COHERENT_MASK 514 select ARCH_HAS_DMA_SET_COHERENT_MASK
514 select ARCH_SUPPORTS_BIG_ENDIAN
515 select ARCH_REQUIRE_GPIOLIB 515 select ARCH_REQUIRE_GPIOLIB
516 select ARCH_SUPPORTS_BIG_ENDIAN
516 select CLKSRC_MMIO 517 select CLKSRC_MMIO
517 select CPU_XSCALE 518 select CPU_XSCALE
518 select DMABOUNCE if PCI 519 select DMABOUNCE if PCI
@@ -1110,9 +1111,9 @@ config ARM_NR_BANKS
1110 default 8 1111 default 8
1111 1112
1112config IWMMXT 1113config IWMMXT
1113 bool "Enable iWMMXt support" if !CPU_PJ4 1114 bool "Enable iWMMXt support"
1114 depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 1115 depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 || CPU_PJ4B
1115 default y if PXA27x || PXA3xx || ARCH_MMP || CPU_PJ4 1116 default y if PXA27x || PXA3xx || ARCH_MMP || CPU_PJ4 || CPU_PJ4B
1116 help 1117 help
1117 Enable support for iWMMXt context switching at run time if 1118 Enable support for iWMMXt context switching at run time if
1118 running on a CPU that supports it. 1119 running on a CPU that supports it.
@@ -1575,8 +1576,8 @@ config BIG_LITTLE
1575config BL_SWITCHER 1576config BL_SWITCHER
1576 bool "big.LITTLE switcher support" 1577 bool "big.LITTLE switcher support"
1577 depends on BIG_LITTLE && MCPM && HOTPLUG_CPU 1578 depends on BIG_LITTLE && MCPM && HOTPLUG_CPU
1578 select CPU_PM
1579 select ARM_CPU_SUSPEND 1579 select ARM_CPU_SUSPEND
1580 select CPU_PM
1580 help 1581 help
1581 The big.LITTLE "switcher" provides the core functionality to 1582 The big.LITTLE "switcher" provides the core functionality to
1582 transparently handle transition between a cluster of A15's 1583 transparently handle transition between a cluster of A15's
@@ -1920,9 +1921,9 @@ config XEN
1920 depends on CPU_V7 && !CPU_V6 1921 depends on CPU_V7 && !CPU_V6
1921 depends on !GENERIC_ATOMIC64 1922 depends on !GENERIC_ATOMIC64
1922 depends on MMU 1923 depends on MMU
1924 select ARCH_DMA_ADDR_T_64BIT
1923 select ARM_PSCI 1925 select ARM_PSCI
1924 select SWIOTLB_XEN 1926 select SWIOTLB_XEN
1925 select ARCH_DMA_ADDR_T_64BIT
1926 help 1927 help
1927 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. 1928 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
1928 1929
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 4a2fc0bf6fc9..eab8ecbe69c1 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1030,9 +1030,9 @@ config DEBUG_UART_PHYS
1030 default 0x40100000 if DEBUG_PXA_UART1 1030 default 0x40100000 if DEBUG_PXA_UART1
1031 default 0x42000000 if ARCH_GEMINI 1031 default 0x42000000 if ARCH_GEMINI
1032 default 0x7c0003f8 if FOOTBRIDGE 1032 default 0x7c0003f8 if FOOTBRIDGE
1033 default 0x80230000 if DEBUG_PICOXCELL_UART
1034 default 0x80070000 if DEBUG_IMX23_UART 1033 default 0x80070000 if DEBUG_IMX23_UART
1035 default 0x80074000 if DEBUG_IMX28_UART 1034 default 0x80074000 if DEBUG_IMX28_UART
1035 default 0x80230000 if DEBUG_PICOXCELL_UART
1036 default 0x808c0000 if ARCH_EP93XX 1036 default 0x808c0000 if ARCH_EP93XX
1037 default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART 1037 default 0x90020000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART
1038 default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX 1038 default 0xb0090000 if DEBUG_VEXPRESS_UART0_CRX
@@ -1096,22 +1096,22 @@ config DEBUG_UART_VIRT
1096 default 0xfeb26000 if DEBUG_RK3X_UART1 1096 default 0xfeb26000 if DEBUG_RK3X_UART1
1097 default 0xfeb30c00 if DEBUG_KEYSTONE_UART0 1097 default 0xfeb30c00 if DEBUG_KEYSTONE_UART0
1098 default 0xfeb31000 if DEBUG_KEYSTONE_UART1 1098 default 0xfeb31000 if DEBUG_KEYSTONE_UART1
1099 default 0xfec12000 if DEBUG_MVEBU_UART || DEBUG_MVEBU_UART_ALTERNATE
1100 default 0xfed60000 if DEBUG_RK29_UART0
1101 default 0xfed64000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2
1102 default 0xfed68000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3
1103 default 0xfec02000 if DEBUG_SOCFPGA_UART 1099 default 0xfec02000 if DEBUG_SOCFPGA_UART
1100 default 0xfec12000 if DEBUG_MVEBU_UART || DEBUG_MVEBU_UART_ALTERNATE
1104 default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0 1101 default 0xfec20000 if DEBUG_DAVINCI_DMx_UART0
1105 default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1 1102 default 0xfed0c000 if DEBUG_DAVINCI_DA8XX_UART1
1106 default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2 1103 default 0xfed0d000 if DEBUG_DAVINCI_DA8XX_UART2
1107 default 0xfed12000 if ARCH_KIRKWOOD 1104 default 0xfed12000 if ARCH_KIRKWOOD
1105 default 0xfed60000 if DEBUG_RK29_UART0
1106 default 0xfed64000 if DEBUG_RK29_UART1 || DEBUG_RK3X_UART2
1107 default 0xfed68000 if DEBUG_RK29_UART2 || DEBUG_RK3X_UART3
1108 default 0xfedc0000 if ARCH_EP93XX 1108 default 0xfedc0000 if ARCH_EP93XX
1109 default 0xfee003f8 if FOOTBRIDGE 1109 default 0xfee003f8 if FOOTBRIDGE
1110 default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART 1110 default 0xfee20000 if DEBUG_NSPIRE_CLASSIC_UART || DEBUG_NSPIRE_CX_UART
1111 default 0xfef36000 if DEBUG_HIGHBANK_UART
1112 default 0xfee82340 if ARCH_IOP13XX 1111 default 0xfee82340 if ARCH_IOP13XX
1113 default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN 1112 default 0xfef00000 if ARCH_IXP4XX && !CPU_BIG_ENDIAN
1114 default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN 1113 default 0xfef00003 if ARCH_IXP4XX && CPU_BIG_ENDIAN
1114 default 0xfef36000 if DEBUG_HIGHBANK_UART
1115 default 0xfefff700 if ARCH_IOP33X 1115 default 0xfefff700 if ARCH_IOP33X
1116 default 0xff003000 if DEBUG_U300_UART 1116 default 0xff003000 if DEBUG_U300_UART
1117 default DEBUG_UART_PHYS if !MMU 1117 default DEBUG_UART_PHYS if !MMU
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 35c146f31e46..377b7c364033 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -51,10 +51,9 @@ dtb-$(CONFIG_ARCH_AT91) += sama5d36ek.dtb
51 51
52dtb-$(CONFIG_ARCH_ATLAS6) += atlas6-evb.dtb 52dtb-$(CONFIG_ARCH_ATLAS6) += atlas6-evb.dtb
53dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb 53dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
54dtb-$(CONFIG_ARCH_BCM_5301X) += bcm4708-netgear-r6250.dtb
54dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm28155-ap.dtb \ 55dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm28155-ap.dtb \
55 bcm21664-garnet.dtb 56 bcm21664-garnet.dtb
56dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
57dtb-$(CONFIG_ARCH_BCM_5301X) += bcm4708-netgear-r6250.dtb
58dtb-$(CONFIG_ARCH_BERLIN) += \ 57dtb-$(CONFIG_ARCH_BERLIN) += \
59 berlin2-sony-nsz-gs7.dtb \ 58 berlin2-sony-nsz-gs7.dtb \
60 berlin2cd-google-chromecast.dtb 59 berlin2cd-google-chromecast.dtb
@@ -246,6 +245,7 @@ dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
246 omap3-sbc-t3730.dtb \ 245 omap3-sbc-t3730.dtb \
247 omap3-devkit8000.dtb \ 246 omap3-devkit8000.dtb \
248 omap3-beagle-xm.dtb \ 247 omap3-beagle-xm.dtb \
248 omap3-beagle-xm-ab.dtb \
249 omap3-evm.dtb \ 249 omap3-evm.dtb \
250 omap3-evm-37xx.dtb \ 250 omap3-evm-37xx.dtb \
251 omap3-ldp.dtb \ 251 omap3-ldp.dtb \
@@ -294,13 +294,6 @@ dtb-$(CONFIG_ARCH_PRIMA2) += prima2-evb.dtb
294dtb-$(CONFIG_ARCH_QCOM) += qcom-msm8660-surf.dtb \ 294dtb-$(CONFIG_ARCH_QCOM) += qcom-msm8660-surf.dtb \
295 qcom-msm8960-cdp.dtb \ 295 qcom-msm8960-cdp.dtb \
296 qcom-apq8074-dragonboard.dtb 296 qcom-apq8074-dragonboard.dtb
297dtb-$(CONFIG_ARCH_U8500) += ste-snowball.dtb \
298 ste-hrefprev60-stuib.dtb \
299 ste-hrefprev60-tvk.dtb \
300 ste-hrefv60plus-stuib.dtb \
301 ste-hrefv60plus-tvk.dtb \
302 ste-ccu8540.dtb \
303 ste-ccu9540.dtb
304dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb 297dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb
305dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \ 298dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \
306 s3c6410-smdk6410.dtb 299 s3c6410-smdk6410.dtb
@@ -369,9 +362,16 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
369 tegra30-cardhu-a04.dtb \ 362 tegra30-cardhu-a04.dtb \
370 tegra114-dalmore.dtb \ 363 tegra114-dalmore.dtb \
371 tegra124-venice2.dtb 364 tegra124-venice2.dtb
365dtb-$(CONFIG_ARCH_U300) += ste-u300.dtb
366dtb-$(CONFIG_ARCH_U8500) += ste-snowball.dtb \
367 ste-hrefprev60-stuib.dtb \
368 ste-hrefprev60-tvk.dtb \
369 ste-hrefv60plus-stuib.dtb \
370 ste-hrefv60plus-tvk.dtb \
371 ste-ccu8540.dtb \
372 ste-ccu9540.dtb
372dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \ 373dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \
373 versatile-pb.dtb 374 versatile-pb.dtb
374dtb-$(CONFIG_ARCH_U300) += ste-u300.dtb
375dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ 375dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \
376 vexpress-v2p-ca9.dtb \ 376 vexpress-v2p-ca9.dtb \
377 vexpress-v2p-ca15-tc1.dtb \ 377 vexpress-v2p-ca15-tc1.dtb \
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index e3f27ec31718..2e7d932887b5 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -183,7 +183,7 @@
183&usb { 183&usb {
184 status = "okay"; 184 status = "okay";
185 185
186 control@44e10000 { 186 control@44e10620 {
187 status = "okay"; 187 status = "okay";
188 }; 188 };
189 189
@@ -204,7 +204,7 @@
204 dr_mode = "host"; 204 dr_mode = "host";
205 }; 205 };
206 206
207 dma-controller@07402000 { 207 dma-controller@47402000 {
208 status = "okay"; 208 status = "okay";
209 }; 209 };
210}; 210};
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index 28ae040e7c3d..6028217ace0f 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -301,8 +301,8 @@
301 301
302 am335x_evm_audio_pins: am335x_evm_audio_pins { 302 am335x_evm_audio_pins: am335x_evm_audio_pins {
303 pinctrl-single,pins = < 303 pinctrl-single,pins = <
304 0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_rx_dv.mcasp1_aclkx */ 304 0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_crs.mcasp1_aclkx */
305 0x110 (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_txd3.mcasp1_fsx */ 305 0x110 (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_rxerr.mcasp1_fsx */
306 0x108 (PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* mii1_col.mcasp1_axr2 */ 306 0x108 (PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* mii1_col.mcasp1_axr2 */
307 0x144 (PIN_INPUT_PULLDOWN | MUX_MODE4) /* rmii1_ref_clk.mcasp1_axr3 */ 307 0x144 (PIN_INPUT_PULLDOWN | MUX_MODE4) /* rmii1_ref_clk.mcasp1_axr3 */
308 >; 308 >;
@@ -331,7 +331,7 @@
331&usb { 331&usb {
332 status = "okay"; 332 status = "okay";
333 333
334 control@44e10000 { 334 control@44e10620 {
335 status = "okay"; 335 status = "okay";
336 }; 336 };
337 337
@@ -352,7 +352,7 @@
352 dr_mode = "host"; 352 dr_mode = "host";
353 }; 353 };
354 354
355 dma-controller@07402000 { 355 dma-controller@47402000 {
356 status = "okay"; 356 status = "okay";
357 }; 357 };
358}; 358};
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts
index ec08f6f677c3..ab238850a7b2 100644
--- a/arch/arm/boot/dts/am335x-evmsk.dts
+++ b/arch/arm/boot/dts/am335x-evmsk.dts
@@ -364,7 +364,7 @@
364&usb { 364&usb {
365 status = "okay"; 365 status = "okay";
366 366
367 control@44e10000 { 367 control@44e10620 {
368 status = "okay"; 368 status = "okay";
369 }; 369 };
370 370
@@ -385,7 +385,7 @@
385 dr_mode = "host"; 385 dr_mode = "host";
386 }; 386 };
387 387
388 dma-controller@07402000 { 388 dma-controller@47402000 {
389 status = "okay"; 389 status = "okay";
390 }; 390 };
391}; 391};
diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi
index 7063311a58d9..9f22c189f636 100644
--- a/arch/arm/boot/dts/am335x-igep0033.dtsi
+++ b/arch/arm/boot/dts/am335x-igep0033.dtsi
@@ -118,7 +118,6 @@
118 reg = <0 0 0>; /* CS0, offset 0 */ 118 reg = <0 0 0>; /* CS0, offset 0 */
119 nand-bus-width = <8>; 119 nand-bus-width = <8>;
120 ti,nand-ecc-opt = "bch8"; 120 ti,nand-ecc-opt = "bch8";
121 gpmc,device-nand = "true";
122 gpmc,device-width = <1>; 121 gpmc,device-width = <1>;
123 gpmc,sync-clk-ps = <0>; 122 gpmc,sync-clk-ps = <0>;
124 gpmc,cs-on-ns = <0>; 123 gpmc,cs-on-ns = <0>;
@@ -202,7 +201,7 @@
202&usb { 201&usb {
203 status = "okay"; 202 status = "okay";
204 203
205 control@44e10000 { 204 control@44e10620 {
206 status = "okay"; 205 status = "okay";
207 }; 206 };
208 207
@@ -223,7 +222,7 @@
223 dr_mode = "host"; 222 dr_mode = "host";
224 }; 223 };
225 224
226 dma-controller@07402000 { 225 dma-controller@47402000 {
227 status = "okay"; 226 status = "okay";
228 }; 227 };
229}; 228};
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index d1e2b363f927..baf56cc92040 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -72,7 +72,7 @@
72 }; 72 };
73 73
74 /* 74 /*
75 * The soc node represents the soc top level view. It is uses for IPs 75 * The soc node represents the soc top level view. It is used for IPs
76 * that are not memory mapped in the MPU view or for the MPU itself. 76 * that are not memory mapped in the MPU view or for the MPU itself.
77 */ 77 */
78 soc { 78 soc {
@@ -94,8 +94,8 @@
94 94
95 /* 95 /*
96 * XXX: Use a flat representation of the AM33XX interconnect. 96 * XXX: Use a flat representation of the AM33XX interconnect.
97 * The real AM33XX interconnect network is quite complex.Since 97 * The real AM33XX interconnect network is quite complex. Since
98 * that will not bring real advantage to represent that in DT 98 * it will not bring real advantage to represent that in DT
99 * for the moment, just use a fake OCP bus entry to represent 99 * for the moment, just use a fake OCP bus entry to represent
100 * the whole bus hierarchy. 100 * the whole bus hierarchy.
101 */ 101 */
@@ -804,7 +804,7 @@
804 <0x46000000 0x400000>; 804 <0x46000000 0x400000>;
805 reg-names = "mpu", "dat"; 805 reg-names = "mpu", "dat";
806 interrupts = <80>, <81>; 806 interrupts = <80>, <81>;
807 interrupts-names = "tx", "rx"; 807 interrupt-names = "tx", "rx";
808 status = "disabled"; 808 status = "disabled";
809 dmas = <&edma 8>, 809 dmas = <&edma 8>,
810 <&edma 9>; 810 <&edma 9>;
@@ -818,7 +818,7 @@
818 <0x46400000 0x400000>; 818 <0x46400000 0x400000>;
819 reg-names = "mpu", "dat"; 819 reg-names = "mpu", "dat";
820 interrupts = <82>, <83>; 820 interrupts = <82>, <83>;
821 interrupts-names = "tx", "rx"; 821 interrupt-names = "tx", "rx";
822 status = "disabled"; 822 status = "disabled";
823 dmas = <&edma 10>, 823 dmas = <&edma 10>,
824 <&edma 11>; 824 <&edma 11>;
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index c2779f653020..03a225505126 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -693,7 +693,7 @@
693 <0x46000000 0x400000>; 693 <0x46000000 0x400000>;
694 reg-names = "mpu", "dat"; 694 reg-names = "mpu", "dat";
695 interrupts = <80>, <81>; 695 interrupts = <80>, <81>;
696 interrupts-names = "tx", "rx"; 696 interrupt-names = "tx", "rx";
697 status = "disabled"; 697 status = "disabled";
698 dmas = <&edma 8>, 698 dmas = <&edma 8>,
699 <&edma 9>; 699 <&edma 9>;
@@ -707,7 +707,7 @@
707 <0x46400000 0x400000>; 707 <0x46400000 0x400000>;
708 reg-names = "mpu", "dat"; 708 reg-names = "mpu", "dat";
709 interrupts = <82>, <83>; 709 interrupts = <82>, <83>;
710 interrupts-names = "tx", "rx"; 710 interrupt-names = "tx", "rx";
711 status = "disabled"; 711 status = "disabled";
712 dmas = <&edma 10>, 712 dmas = <&edma 10>,
713 <&edma 11>; 713 <&edma 11>;
diff --git a/arch/arm/boot/dts/armada-370-xp.dtsi b/arch/arm/boot/dts/armada-370-xp.dtsi
index bbb40f62037d..bb77970c0b12 100644
--- a/arch/arm/boot/dts/armada-370-xp.dtsi
+++ b/arch/arm/boot/dts/armada-370-xp.dtsi
@@ -230,6 +230,7 @@
230 #size-cells = <0>; 230 #size-cells = <0>;
231 compatible = "marvell,orion-mdio"; 231 compatible = "marvell,orion-mdio";
232 reg = <0x72004 0x4>; 232 reg = <0x72004 0x4>;
233 clocks = <&gateclk 4>;
233 }; 234 };
234 235
235 eth1: ethernet@74000 { 236 eth1: ethernet@74000 {
diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi
index a064f59da02d..ca8813bb99ba 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -336,6 +336,7 @@
336 #size-cells = <0>; 336 #size-cells = <0>;
337 compatible = "marvell,orion-mdio"; 337 compatible = "marvell,orion-mdio";
338 reg = <0x72004 0x4>; 338 reg = <0x72004 0x4>;
339 clocks = <&gateclk 4>;
339 }; 340 };
340 341
341 coredivclk: clock@e4250 { 342 coredivclk: clock@e4250 {
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 1c0f8e1893ae..149b55099935 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -80,7 +80,7 @@
80 }; 80 };
81 81
82 /* 82 /*
83 * The soc node represents the soc top level view. It is uses for IPs 83 * The soc node represents the soc top level view. It is used for IPs
84 * that are not memory mapped in the MPU view or for the MPU itself. 84 * that are not memory mapped in the MPU view or for the MPU itself.
85 */ 85 */
86 soc { 86 soc {
@@ -94,7 +94,7 @@
94 /* 94 /*
95 * XXX: Use a flat representation of the SOC interconnect. 95 * XXX: Use a flat representation of the SOC interconnect.
96 * The real OMAP interconnect network is quite complex. 96 * The real OMAP interconnect network is quite complex.
97 * Since that will not bring real advantage to represent that in DT for 97 * Since it will not bring real advantage to represent that in DT for
98 * the moment, just use a fake OCP bus entry to represent the whole bus 98 * the moment, just use a fake OCP bus entry to represent the whole bus
99 * hierarchy. 99 * hierarchy.
100 */ 100 */
diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi b/arch/arm/boot/dts/dra7xx-clocks.dtsi
index e96da9a898ad..cfb8fc753f50 100644
--- a/arch/arm/boot/dts/dra7xx-clocks.dtsi
+++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi
@@ -1640,7 +1640,7 @@
1640 #clock-cells = <0>; 1640 #clock-cells = <0>;
1641 compatible = "ti,mux-clock"; 1641 compatible = "ti,mux-clock";
1642 clocks = <&abe_24m_fclk>, <&abe_sys_clk_div>, <&func_24m_clk>, <&atlclkin3_ck>, <&atl_clkin2_ck>, <&atl_clkin1_ck>, <&atl_clkin0_ck>, <&sys_clkin2>, <&ref_clkin0_ck>, <&ref_clkin1_ck>, <&ref_clkin2_ck>, <&ref_clkin3_ck>, <&mlb_clk>, <&mlbp_clk>; 1642 clocks = <&abe_24m_fclk>, <&abe_sys_clk_div>, <&func_24m_clk>, <&atlclkin3_ck>, <&atl_clkin2_ck>, <&atl_clkin1_ck>, <&atl_clkin0_ck>, <&sys_clkin2>, <&ref_clkin0_ck>, <&ref_clkin1_ck>, <&ref_clkin2_ck>, <&ref_clkin3_ck>, <&mlb_clk>, <&mlbp_clk>;
1643 ti,bit-shift = <28>; 1643 ti,bit-shift = <24>;
1644 reg = <0x1860>; 1644 reg = <0x1860>;
1645 }; 1645 };
1646 1646
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index 32f760e24898..ea323f09dc78 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -56,6 +56,7 @@
56 56
57 osc { 57 osc {
58 compatible = "fsl,imx-osc", "fixed-clock"; 58 compatible = "fsl,imx-osc", "fixed-clock";
59 #clock-cells = <0>;
59 clock-frequency = <24000000>; 60 clock-frequency = <24000000>;
60 }; 61 };
61 }; 62 };
diff --git a/arch/arm/boot/dts/imx27-apf27.dts b/arch/arm/boot/dts/imx27-apf27.dts
index 09f57b39e3ef..73aae4f5e539 100644
--- a/arch/arm/boot/dts/imx27-apf27.dts
+++ b/arch/arm/boot/dts/imx27-apf27.dts
@@ -29,6 +29,7 @@
29 29
30 osc26m { 30 osc26m {
31 compatible = "fsl,imx-osc26m", "fixed-clock"; 31 compatible = "fsl,imx-osc26m", "fixed-clock";
32 #clock-cells = <0>;
32 clock-frequency = <0>; 33 clock-frequency = <0>;
33 }; 34 };
34 }; 35 };
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index 6279e0b4f768..137e010eab35 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -48,6 +48,7 @@
48 48
49 osc26m { 49 osc26m {
50 compatible = "fsl,imx-osc26m", "fixed-clock"; 50 compatible = "fsl,imx-osc26m", "fixed-clock";
51 #clock-cells = <0>;
51 clock-frequency = <26000000>; 52 clock-frequency = <26000000>;
52 }; 53 };
53 }; 54 };
diff --git a/arch/arm/boot/dts/imx50.dtsi b/arch/arm/boot/dts/imx50.dtsi
index 0c75fe3deb35..9c89d1ca97c2 100644
--- a/arch/arm/boot/dts/imx50.dtsi
+++ b/arch/arm/boot/dts/imx50.dtsi
@@ -53,21 +53,25 @@
53 53
54 ckil { 54 ckil {
55 compatible = "fsl,imx-ckil", "fixed-clock"; 55 compatible = "fsl,imx-ckil", "fixed-clock";
56 #clock-cells = <0>;
56 clock-frequency = <32768>; 57 clock-frequency = <32768>;
57 }; 58 };
58 59
59 ckih1 { 60 ckih1 {
60 compatible = "fsl,imx-ckih1", "fixed-clock"; 61 compatible = "fsl,imx-ckih1", "fixed-clock";
62 #clock-cells = <0>;
61 clock-frequency = <22579200>; 63 clock-frequency = <22579200>;
62 }; 64 };
63 65
64 ckih2 { 66 ckih2 {
65 compatible = "fsl,imx-ckih2", "fixed-clock"; 67 compatible = "fsl,imx-ckih2", "fixed-clock";
68 #clock-cells = <0>;
66 clock-frequency = <0>; 69 clock-frequency = <0>;
67 }; 70 };
68 71
69 osc { 72 osc {
70 compatible = "fsl,imx-osc", "fixed-clock"; 73 compatible = "fsl,imx-osc", "fixed-clock";
74 #clock-cells = <0>;
71 clock-frequency = <24000000>; 75 clock-frequency = <24000000>;
72 }; 76 };
73 }; 77 };
diff --git a/arch/arm/boot/dts/imx51.dtsi b/arch/arm/boot/dts/imx51.dtsi
index 5f8216d08f6b..150bb4e2f744 100644
--- a/arch/arm/boot/dts/imx51.dtsi
+++ b/arch/arm/boot/dts/imx51.dtsi
@@ -50,21 +50,25 @@
50 50
51 ckil { 51 ckil {
52 compatible = "fsl,imx-ckil", "fixed-clock"; 52 compatible = "fsl,imx-ckil", "fixed-clock";
53 #clock-cells = <0>;
53 clock-frequency = <32768>; 54 clock-frequency = <32768>;
54 }; 55 };
55 56
56 ckih1 { 57 ckih1 {
57 compatible = "fsl,imx-ckih1", "fixed-clock"; 58 compatible = "fsl,imx-ckih1", "fixed-clock";
59 #clock-cells = <0>;
58 clock-frequency = <0>; 60 clock-frequency = <0>;
59 }; 61 };
60 62
61 ckih2 { 63 ckih2 {
62 compatible = "fsl,imx-ckih2", "fixed-clock"; 64 compatible = "fsl,imx-ckih2", "fixed-clock";
65 #clock-cells = <0>;
63 clock-frequency = <0>; 66 clock-frequency = <0>;
64 }; 67 };
65 68
66 osc { 69 osc {
67 compatible = "fsl,imx-osc", "fixed-clock"; 70 compatible = "fsl,imx-osc", "fixed-clock";
71 #clock-cells = <0>;
68 clock-frequency = <24000000>; 72 clock-frequency = <24000000>;
69 }; 73 };
70 }; 74 };
diff --git a/arch/arm/boot/dts/imx53-m53evk.dts b/arch/arm/boot/dts/imx53-m53evk.dts
index f6d3ac3e5587..d5d146a8b149 100644
--- a/arch/arm/boot/dts/imx53-m53evk.dts
+++ b/arch/arm/boot/dts/imx53-m53evk.dts
@@ -17,7 +17,8 @@
17 compatible = "denx,imx53-m53evk", "fsl,imx53"; 17 compatible = "denx,imx53-m53evk", "fsl,imx53";
18 18
19 memory { 19 memory {
20 reg = <0x70000000 0x20000000>; 20 reg = <0x70000000 0x20000000>,
21 <0xb0000000 0x20000000>;
21 }; 22 };
22 23
23 soc { 24 soc {
@@ -193,17 +194,17 @@
193 irq-trigger = <0x1>; 194 irq-trigger = <0x1>;
194 195
195 stmpe_touchscreen { 196 stmpe_touchscreen {
196 compatible = "stmpe,ts"; 197 compatible = "st,stmpe-ts";
197 reg = <0>; 198 reg = <0>;
198 ts,sample-time = <4>; 199 st,sample-time = <4>;
199 ts,mod-12b = <1>; 200 st,mod-12b = <1>;
200 ts,ref-sel = <0>; 201 st,ref-sel = <0>;
201 ts,adc-freq = <1>; 202 st,adc-freq = <1>;
202 ts,ave-ctrl = <3>; 203 st,ave-ctrl = <3>;
203 ts,touch-det-delay = <3>; 204 st,touch-det-delay = <3>;
204 ts,settling = <4>; 205 st,settling = <4>;
205 ts,fraction-z = <7>; 206 st,fraction-z = <7>;
206 ts,i-drive = <1>; 207 st,i-drive = <1>;
207 }; 208 };
208 }; 209 };
209 210
diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index 3f825a6813da..ede04fa4161f 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -14,7 +14,8 @@
14 14
15/ { 15/ {
16 memory { 16 memory {
17 reg = <0x70000000 0x40000000>; 17 reg = <0x70000000 0x20000000>,
18 <0xb0000000 0x20000000>;
18 }; 19 };
19 20
20 display0: display@di0 { 21 display0: display@di0 {
diff --git a/arch/arm/boot/dts/imx53-tx53-x03x.dts b/arch/arm/boot/dts/imx53-tx53-x03x.dts
index 0217dde3b36b..3b73e81dc3f0 100644
--- a/arch/arm/boot/dts/imx53-tx53-x03x.dts
+++ b/arch/arm/boot/dts/imx53-tx53-x03x.dts
@@ -25,12 +25,17 @@
25 soc { 25 soc {
26 display: display@di0 { 26 display: display@di0 {
27 compatible = "fsl,imx-parallel-display"; 27 compatible = "fsl,imx-parallel-display";
28 crtcs = <&ipu 0>;
29 interface-pix-fmt = "rgb24"; 28 interface-pix-fmt = "rgb24";
30 pinctrl-names = "default"; 29 pinctrl-names = "default";
31 pinctrl-0 = <&pinctrl_rgb24_vga1>; 30 pinctrl-0 = <&pinctrl_rgb24_vga1>;
32 status = "okay"; 31 status = "okay";
33 32
33 port {
34 display0_in: endpoint {
35 remote-endpoint = <&ipu_di0_disp0>;
36 };
37 };
38
34 display-timings { 39 display-timings {
35 VGA { 40 VGA {
36 clock-frequency = <25200000>; 41 clock-frequency = <25200000>;
@@ -293,6 +298,10 @@
293 }; 298 };
294}; 299};
295 300
301&ipu_di0_disp0 {
302 remote-endpoint = <&display0_in>;
303};
304
296&kpp { 305&kpp {
297 pinctrl-names = "default"; 306 pinctrl-names = "default";
298 pinctrl-0 = <&pinctrl_kpp>; 307 pinctrl-0 = <&pinctrl_kpp>;
diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index b57ab57740f6..9c2bff2252d0 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -70,21 +70,25 @@
70 70
71 ckil { 71 ckil {
72 compatible = "fsl,imx-ckil", "fixed-clock"; 72 compatible = "fsl,imx-ckil", "fixed-clock";
73 #clock-cells = <0>;
73 clock-frequency = <32768>; 74 clock-frequency = <32768>;
74 }; 75 };
75 76
76 ckih1 { 77 ckih1 {
77 compatible = "fsl,imx-ckih1", "fixed-clock"; 78 compatible = "fsl,imx-ckih1", "fixed-clock";
79 #clock-cells = <0>;
78 clock-frequency = <22579200>; 80 clock-frequency = <22579200>;
79 }; 81 };
80 82
81 ckih2 { 83 ckih2 {
82 compatible = "fsl,imx-ckih2", "fixed-clock"; 84 compatible = "fsl,imx-ckih2", "fixed-clock";
85 #clock-cells = <0>;
83 clock-frequency = <0>; 86 clock-frequency = <0>;
84 }; 87 };
85 88
86 osc { 89 osc {
87 compatible = "fsl,imx-osc", "fixed-clock"; 90 compatible = "fsl,imx-osc", "fixed-clock";
91 #clock-cells = <0>;
88 clock-frequency = <24000000>; 92 clock-frequency = <24000000>;
89 }; 93 };
90 }; 94 };
@@ -430,7 +434,7 @@
430 434
431 port { 435 port {
432 lvds1_in: endpoint { 436 lvds1_in: endpoint {
433 remote-endpoint = <&ipu_di0_lvds0>; 437 remote-endpoint = <&ipu_di1_lvds1>;
434 }; 438 };
435 }; 439 };
436 }; 440 };
diff --git a/arch/arm/boot/dts/imx6q-dmo-edmqmx6.dts b/arch/arm/boot/dts/imx6q-dmo-edmqmx6.dts
index a63bbb3d46bb..e4ae38fd0269 100644
--- a/arch/arm/boot/dts/imx6q-dmo-edmqmx6.dts
+++ b/arch/arm/boot/dts/imx6q-dmo-edmqmx6.dts
@@ -19,7 +19,10 @@
19 compatible = "dmo,imx6q-edmqmx6", "fsl,imx6q"; 19 compatible = "dmo,imx6q-edmqmx6", "fsl,imx6q";
20 20
21 aliases { 21 aliases {
22 gpio7 = &stmpe_gpio; 22 gpio7 = &stmpe_gpio1;
23 gpio8 = &stmpe_gpio2;
24 stmpe-i2c0 = &stmpe1;
25 stmpe-i2c1 = &stmpe2;
23 }; 26 };
24 27
25 memory { 28 memory {
@@ -40,13 +43,15 @@
40 regulator-always-on; 43 regulator-always-on;
41 }; 44 };
42 45
43 reg_usb_otg_vbus: regulator@1 { 46 reg_usb_otg_switch: regulator@1 {
44 compatible = "regulator-fixed"; 47 compatible = "regulator-fixed";
45 reg = <1>; 48 reg = <1>;
46 regulator-name = "usb_otg_vbus"; 49 regulator-name = "usb_otg_switch";
47 regulator-min-microvolt = <5000000>; 50 regulator-min-microvolt = <5000000>;
48 regulator-max-microvolt = <5000000>; 51 regulator-max-microvolt = <5000000>;
49 gpio = <&gpio7 12 0>; 52 gpio = <&gpio7 12 0>;
53 regulator-boot-on;
54 regulator-always-on;
50 }; 55 };
51 56
52 reg_usb_host1: regulator@2 { 57 reg_usb_host1: regulator@2 {
@@ -65,23 +70,23 @@
65 70
66 led-blue { 71 led-blue {
67 label = "blue"; 72 label = "blue";
68 gpios = <&stmpe_gpio 8 GPIO_ACTIVE_HIGH>; 73 gpios = <&stmpe_gpio1 8 GPIO_ACTIVE_HIGH>;
69 linux,default-trigger = "heartbeat"; 74 linux,default-trigger = "heartbeat";
70 }; 75 };
71 76
72 led-green { 77 led-green {
73 label = "green"; 78 label = "green";
74 gpios = <&stmpe_gpio 9 GPIO_ACTIVE_HIGH>; 79 gpios = <&stmpe_gpio1 9 GPIO_ACTIVE_HIGH>;
75 }; 80 };
76 81
77 led-pink { 82 led-pink {
78 label = "pink"; 83 label = "pink";
79 gpios = <&stmpe_gpio 10 GPIO_ACTIVE_HIGH>; 84 gpios = <&stmpe_gpio1 10 GPIO_ACTIVE_HIGH>;
80 }; 85 };
81 86
82 led-red { 87 led-red {
83 label = "red"; 88 label = "red";
84 gpios = <&stmpe_gpio 11 GPIO_ACTIVE_HIGH>; 89 gpios = <&stmpe_gpio1 11 GPIO_ACTIVE_HIGH>;
85 }; 90 };
86 }; 91 };
87}; 92};
@@ -99,7 +104,8 @@
99 clock-frequency = <100000>; 104 clock-frequency = <100000>;
100 pinctrl-names = "default"; 105 pinctrl-names = "default";
101 pinctrl-0 = <&pinctrl_i2c2 106 pinctrl-0 = <&pinctrl_i2c2
102 &pinctrl_stmpe>; 107 &pinctrl_stmpe1
108 &pinctrl_stmpe2>;
103 status = "okay"; 109 status = "okay";
104 110
105 pmic: pfuze100@08 { 111 pmic: pfuze100@08 {
@@ -205,13 +211,25 @@
205 }; 211 };
206 }; 212 };
207 213
208 stmpe: stmpe1601@40 { 214 stmpe1: stmpe1601@40 {
209 compatible = "st,stmpe1601"; 215 compatible = "st,stmpe1601";
210 reg = <0x40>; 216 reg = <0x40>;
211 interrupts = <30 0>; 217 interrupts = <30 0>;
212 interrupt-parent = <&gpio3>; 218 interrupt-parent = <&gpio3>;
213 219
214 stmpe_gpio: stmpe_gpio { 220 stmpe_gpio1: stmpe_gpio {
221 #gpio-cells = <2>;
222 compatible = "st,stmpe-gpio";
223 };
224 };
225
226 stmpe2: stmpe1601@44 {
227 compatible = "st,stmpe1601";
228 reg = <0x44>;
229 interrupts = <2 0>;
230 interrupt-parent = <&gpio5>;
231
232 stmpe_gpio2: stmpe_gpio {
215 #gpio-cells = <2>; 233 #gpio-cells = <2>;
216 compatible = "st,stmpe-gpio"; 234 compatible = "st,stmpe-gpio";
217 }; 235 };
@@ -273,10 +291,14 @@
273 >; 291 >;
274 }; 292 };
275 293
276 pinctrl_stmpe: stmpegrp { 294 pinctrl_stmpe1: stmpe1grp {
277 fsl,pins = <MX6QDL_PAD_EIM_D30__GPIO3_IO30 0x80000000>; 295 fsl,pins = <MX6QDL_PAD_EIM_D30__GPIO3_IO30 0x80000000>;
278 }; 296 };
279 297
298 pinctrl_stmpe2: stmpe2grp {
299 fsl,pins = <MX6QDL_PAD_EIM_A25__GPIO5_IO02 0x80000000>;
300 };
301
280 pinctrl_uart1: uart1grp { 302 pinctrl_uart1: uart1grp {
281 fsl,pins = < 303 fsl,pins = <
282 MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA 0x1b0b1 304 MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA 0x1b0b1
@@ -293,7 +315,7 @@
293 315
294 pinctrl_usbotg: usbotggrp { 316 pinctrl_usbotg: usbotggrp {
295 fsl,pins = < 317 fsl,pins = <
296 MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x17059 318 MX6QDL_PAD_ENET_RX_ER__USB_OTG_ID 0x17059
297 >; 319 >;
298 }; 320 };
299 321
@@ -344,11 +366,11 @@
344&usbh1 { 366&usbh1 {
345 vbus-supply = <&reg_usb_host1>; 367 vbus-supply = <&reg_usb_host1>;
346 disable-over-current; 368 disable-over-current;
369 dr_mode = "host";
347 status = "okay"; 370 status = "okay";
348}; 371};
349 372
350&usbotg { 373&usbotg {
351 vbus-supply = <&reg_usb_otg_vbus>;
352 pinctrl-names = "default"; 374 pinctrl-names = "default";
353 pinctrl-0 = <&pinctrl_usbotg>; 375 pinctrl-0 = <&pinctrl_usbotg>;
354 disable-over-current; 376 disable-over-current;
diff --git a/arch/arm/boot/dts/imx6q-gw5400-a.dts b/arch/arm/boot/dts/imx6q-gw5400-a.dts
index 902f98310481..e51bb3f0fd56 100644
--- a/arch/arm/boot/dts/imx6q-gw5400-a.dts
+++ b/arch/arm/boot/dts/imx6q-gw5400-a.dts
@@ -487,9 +487,6 @@
487 487
488&ldb { 488&ldb {
489 status = "okay"; 489 status = "okay";
490 lvds-channel@0 {
491 crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>;
492 };
493}; 490};
494 491
495&pcie { 492&pcie {
diff --git a/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi b/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi
index 8e99c9a9bc76..035d3a85c318 100644
--- a/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-gw52xx.dtsi
@@ -436,9 +436,6 @@
436 436
437&ldb { 437&ldb {
438 status = "okay"; 438 status = "okay";
439 lvds-channel@0 {
440 crtcs = <&ipu1 0>, <&ipu1 1>;
441 };
442}; 439};
443 440
444&pcie { 441&pcie {
diff --git a/arch/arm/boot/dts/imx6qdl-microsom-ar8035.dtsi b/arch/arm/boot/dts/imx6qdl-microsom-ar8035.dtsi
index a3cb2fff8f61..d16066608e21 100644
--- a/arch/arm/boot/dts/imx6qdl-microsom-ar8035.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-microsom-ar8035.dtsi
@@ -26,25 +26,25 @@
26 /* GPIO16 -> AR8035 25MHz */ 26 /* GPIO16 -> AR8035 25MHz */
27 MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0xc0000000 27 MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0xc0000000
28 MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x80000000 28 MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x80000000
29 MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0 29 MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b030
30 MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0 30 MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b030
31 MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0 31 MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b030
32 MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0 32 MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b030
33 MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL 0x1b0b0 33 MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL 0x1b030
34 /* AR8035 CLK_25M --> ENET_REF_CLK (V22) */ 34 /* AR8035 CLK_25M --> ENET_REF_CLK (V22) */
35 MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x0a0b1 35 MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x0a0b1
36 /* AR8035 pin strapping: IO voltage: pull up */ 36 /* AR8035 pin strapping: IO voltage: pull up */
37 MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0 37 MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b030
38 /* AR8035 pin strapping: PHYADDR#0: pull down */ 38 /* AR8035 pin strapping: PHYADDR#0: pull down */
39 MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x130b0 39 MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x13030
40 /* AR8035 pin strapping: PHYADDR#1: pull down */ 40 /* AR8035 pin strapping: PHYADDR#1: pull down */
41 MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x130b0 41 MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x13030
42 /* AR8035 pin strapping: MODE#1: pull up */ 42 /* AR8035 pin strapping: MODE#1: pull up */
43 MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0 43 MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b030
44 /* AR8035 pin strapping: MODE#3: pull up */ 44 /* AR8035 pin strapping: MODE#3: pull up */
45 MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0 45 MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b030
46 /* AR8035 pin strapping: MODE#0: pull down */ 46 /* AR8035 pin strapping: MODE#0: pull down */
47 MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x130b0 47 MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x13030
48 48
49 /* 49 /*
50 * As the RMII pins are also connected to RGMII 50 * As the RMII pins are also connected to RGMII
diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 55cb926fa3f7..eca0971d4db1 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -10,6 +10,8 @@
10 * http://www.gnu.org/copyleft/gpl.html 10 * http://www.gnu.org/copyleft/gpl.html
11 */ 11 */
12 12
13#include <dt-bindings/interrupt-controller/arm-gic.h>
14
13#include "skeleton.dtsi" 15#include "skeleton.dtsi"
14 16
15/ { 17/ {
@@ -46,8 +48,6 @@
46 intc: interrupt-controller@00a01000 { 48 intc: interrupt-controller@00a01000 {
47 compatible = "arm,cortex-a9-gic"; 49 compatible = "arm,cortex-a9-gic";
48 #interrupt-cells = <3>; 50 #interrupt-cells = <3>;
49 #address-cells = <1>;
50 #size-cells = <1>;
51 interrupt-controller; 51 interrupt-controller;
52 reg = <0x00a01000 0x1000>, 52 reg = <0x00a01000 0x1000>,
53 <0x00a00100 0x100>; 53 <0x00a00100 0x100>;
@@ -59,16 +59,19 @@
59 59
60 ckil { 60 ckil {
61 compatible = "fsl,imx-ckil", "fixed-clock"; 61 compatible = "fsl,imx-ckil", "fixed-clock";
62 #clock-cells = <0>;
62 clock-frequency = <32768>; 63 clock-frequency = <32768>;
63 }; 64 };
64 65
65 ckih1 { 66 ckih1 {
66 compatible = "fsl,imx-ckih1", "fixed-clock"; 67 compatible = "fsl,imx-ckih1", "fixed-clock";
68 #clock-cells = <0>;
67 clock-frequency = <0>; 69 clock-frequency = <0>;
68 }; 70 };
69 71
70 osc { 72 osc {
71 compatible = "fsl,imx-osc", "fixed-clock"; 73 compatible = "fsl,imx-osc", "fixed-clock";
74 #clock-cells = <0>;
72 clock-frequency = <24000000>; 75 clock-frequency = <24000000>;
73 }; 76 };
74 }; 77 };
@@ -138,6 +141,12 @@
138 0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */ 141 0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
139 num-lanes = <1>; 142 num-lanes = <1>;
140 interrupts = <0 123 IRQ_TYPE_LEVEL_HIGH>; 143 interrupts = <0 123 IRQ_TYPE_LEVEL_HIGH>;
144 #interrupt-cells = <1>;
145 interrupt-map-mask = <0 0 0 0x7>;
146 interrupt-map = <0 0 0 1 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
147 <0 0 0 2 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
148 <0 0 0 3 &intc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
149 <0 0 0 4 &intc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
141 clocks = <&clks 189>, <&clks 187>, <&clks 206>, <&clks 144>; 150 clocks = <&clks 189>, <&clks 187>, <&clks 206>, <&clks 144>;
142 clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi"; 151 clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi";
143 status = "disabled"; 152 status = "disabled";
diff --git a/arch/arm/boot/dts/imx6sl-evk.dts b/arch/arm/boot/dts/imx6sl-evk.dts
index 864d8dfb51ca..a8d9a93fab85 100644
--- a/arch/arm/boot/dts/imx6sl-evk.dts
+++ b/arch/arm/boot/dts/imx6sl-evk.dts
@@ -282,6 +282,7 @@
282 MX6SL_PAD_ECSPI1_MISO__ECSPI1_MISO 0x100b1 282 MX6SL_PAD_ECSPI1_MISO__ECSPI1_MISO 0x100b1
283 MX6SL_PAD_ECSPI1_MOSI__ECSPI1_MOSI 0x100b1 283 MX6SL_PAD_ECSPI1_MOSI__ECSPI1_MOSI 0x100b1
284 MX6SL_PAD_ECSPI1_SCLK__ECSPI1_SCLK 0x100b1 284 MX6SL_PAD_ECSPI1_SCLK__ECSPI1_SCLK 0x100b1
285 MX6SL_PAD_ECSPI1_SS0__GPIO4_IO11 0x80000000
285 >; 286 >;
286 }; 287 };
287 288
diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi
index 3cb4941afeef..d26b099260a3 100644
--- a/arch/arm/boot/dts/imx6sl.dtsi
+++ b/arch/arm/boot/dts/imx6sl.dtsi
@@ -68,8 +68,6 @@
68 intc: interrupt-controller@00a01000 { 68 intc: interrupt-controller@00a01000 {
69 compatible = "arm,cortex-a9-gic"; 69 compatible = "arm,cortex-a9-gic";
70 #interrupt-cells = <3>; 70 #interrupt-cells = <3>;
71 #address-cells = <1>;
72 #size-cells = <1>;
73 interrupt-controller; 71 interrupt-controller;
74 reg = <0x00a01000 0x1000>, 72 reg = <0x00a01000 0x1000>,
75 <0x00a00100 0x100>; 73 <0x00a00100 0x100>;
@@ -81,11 +79,13 @@
81 79
82 ckil { 80 ckil {
83 compatible = "fixed-clock"; 81 compatible = "fixed-clock";
82 #clock-cells = <0>;
84 clock-frequency = <32768>; 83 clock-frequency = <32768>;
85 }; 84 };
86 85
87 osc { 86 osc {
88 compatible = "fixed-clock"; 87 compatible = "fixed-clock";
88 #clock-cells = <0>;
89 clock-frequency = <24000000>; 89 clock-frequency = <24000000>;
90 }; 90 };
91 }; 91 };
diff --git a/arch/arm/boot/dts/kirkwood-b3.dts b/arch/arm/boot/dts/kirkwood-b3.dts
index 40791053106b..6becedebaa4e 100644
--- a/arch/arm/boot/dts/kirkwood-b3.dts
+++ b/arch/arm/boot/dts/kirkwood-b3.dts
@@ -75,7 +75,7 @@
75 m25p16@0 { 75 m25p16@0 {
76 #address-cells = <1>; 76 #address-cells = <1>;
77 #size-cells = <1>; 77 #size-cells = <1>;
78 compatible = "m25p16"; 78 compatible = "st,m25p16";
79 reg = <0>; 79 reg = <0>;
80 spi-max-frequency = <40000000>; 80 spi-max-frequency = <40000000>;
81 mode = <0>; 81 mode = <0>;
diff --git a/arch/arm/boot/dts/kirkwood-cloudbox.dts b/arch/arm/boot/dts/kirkwood-cloudbox.dts
index 0e06fd3cee4d..3b62aeeaa3a2 100644
--- a/arch/arm/boot/dts/kirkwood-cloudbox.dts
+++ b/arch/arm/boot/dts/kirkwood-cloudbox.dts
@@ -46,7 +46,7 @@
46 flash@0 { 46 flash@0 {
47 #address-cells = <1>; 47 #address-cells = <1>;
48 #size-cells = <1>; 48 #size-cells = <1>;
49 compatible = "mx25l4005a"; 49 compatible = "mxicy,mx25l4005a";
50 reg = <0>; 50 reg = <0>;
51 spi-max-frequency = <20000000>; 51 spi-max-frequency = <20000000>;
52 mode = <0>; 52 mode = <0>;
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index ef3463e0ae19..28b3ee369778 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -43,7 +43,7 @@
43 m25p40@0 { 43 m25p40@0 {
44 #address-cells = <1>; 44 #address-cells = <1>;
45 #size-cells = <1>; 45 #size-cells = <1>;
46 compatible = "mx25l1606e"; 46 compatible = "mxicy,mx25l1606e";
47 reg = <0>; 47 reg = <0>;
48 spi-max-frequency = <50000000>; 48 spi-max-frequency = <50000000>;
49 mode = <0>; 49 mode = <0>;
diff --git a/arch/arm/boot/dts/kirkwood-laplug.dts b/arch/arm/boot/dts/kirkwood-laplug.dts
index c9e82eff9bf2..6761ffa2c4ab 100644
--- a/arch/arm/boot/dts/kirkwood-laplug.dts
+++ b/arch/arm/boot/dts/kirkwood-laplug.dts
@@ -48,7 +48,7 @@
48 status = "okay"; 48 status = "okay";
49 49
50 eeprom@50 { 50 eeprom@50 {
51 compatible = "at,24c04"; 51 compatible = "atmel,24c04";
52 pagesize = <16>; 52 pagesize = <16>;
53 reg = <0x50>; 53 reg = <0x50>;
54 }; 54 };
diff --git a/arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts b/arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts
index 2cb0dc529165..32c6fb4a1162 100644
--- a/arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts
+++ b/arch/arm/boot/dts/kirkwood-mv88f6281gtw-ge.dts
@@ -56,7 +56,7 @@
56 flash@0 { 56 flash@0 {
57 #address-cells = <1>; 57 #address-cells = <1>;
58 #size-cells = <1>; 58 #size-cells = <1>;
59 compatible = "mx25l12805d"; 59 compatible = "mxicy,mx25l12805d";
60 reg = <0>; 60 reg = <0>;
61 spi-max-frequency = <50000000>; 61 spi-max-frequency = <50000000>;
62 mode = <0>; 62 mode = <0>;
diff --git a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
index 743152f31a81..e6e5ec4fe6b9 100644
--- a/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ns2-common.dtsi
@@ -32,7 +32,7 @@
32 flash@0 { 32 flash@0 {
33 #address-cells = <1>; 33 #address-cells = <1>;
34 #size-cells = <1>; 34 #size-cells = <1>;
35 compatible = "mx25l4005a"; 35 compatible = "mxicy,mx25l4005a";
36 reg = <0>; 36 reg = <0>;
37 spi-max-frequency = <20000000>; 37 spi-max-frequency = <20000000>;
38 mode = <0>; 38 mode = <0>;
@@ -50,7 +50,7 @@
50 status = "okay"; 50 status = "okay";
51 51
52 eeprom@50 { 52 eeprom@50 {
53 compatible = "at,24c04"; 53 compatible = "atmel,24c04";
54 pagesize = <16>; 54 pagesize = <16>;
55 reg = <0x50>; 55 reg = <0x50>;
56 }; 56 };
diff --git a/arch/arm/boot/dts/kirkwood-nsa310.dts b/arch/arm/boot/dts/kirkwood-nsa310.dts
index 03fa24cf3344..0a07af9d8e58 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310.dts
+++ b/arch/arm/boot/dts/kirkwood-nsa310.dts
@@ -104,7 +104,7 @@
104 status = "okay"; 104 status = "okay";
105 105
106 adt7476: adt7476a@2e { 106 adt7476: adt7476a@2e {
107 compatible = "adt7476"; 107 compatible = "adi,adt7476";
108 reg = <0x2e>; 108 reg = <0x2e>;
109 }; 109 };
110 }; 110 };
diff --git a/arch/arm/boot/dts/kirkwood-nsa310a.dts b/arch/arm/boot/dts/kirkwood-nsa310a.dts
index a5e779452867..27ca6a79c48a 100644
--- a/arch/arm/boot/dts/kirkwood-nsa310a.dts
+++ b/arch/arm/boot/dts/kirkwood-nsa310a.dts
@@ -94,7 +94,7 @@
94 status = "okay"; 94 status = "okay";
95 95
96 lm85: lm85@2e { 96 lm85: lm85@2e {
97 compatible = "lm85"; 97 compatible = "national,lm85";
98 reg = <0x2e>; 98 reg = <0x2e>;
99 }; 99 };
100 }; 100 };
diff --git a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
index b88da9392c32..0650beafc1de 100644
--- a/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
+++ b/arch/arm/boot/dts/kirkwood-openblocks_a6.dts
@@ -40,7 +40,7 @@
40 pinctrl-names = "default"; 40 pinctrl-names = "default";
41 41
42 s35390a: s35390a@30 { 42 s35390a: s35390a@30 {
43 compatible = "s35390a"; 43 compatible = "sii,s35390a";
44 reg = <0x30>; 44 reg = <0x30>;
45 }; 45 };
46 }; 46 };
diff --git a/arch/arm/boot/dts/kirkwood-openblocks_a7.dts b/arch/arm/boot/dts/kirkwood-openblocks_a7.dts
index b2f7cae06839..38520a287514 100644
--- a/arch/arm/boot/dts/kirkwood-openblocks_a7.dts
+++ b/arch/arm/boot/dts/kirkwood-openblocks_a7.dts
@@ -52,7 +52,7 @@
52 pinctrl-names = "default"; 52 pinctrl-names = "default";
53 53
54 s24c02: s24c02@50 { 54 s24c02: s24c02@50 {
55 compatible = "24c02"; 55 compatible = "atmel,24c02";
56 reg = <0x50>; 56 reg = <0x50>;
57 }; 57 };
58 }; 58 };
diff --git a/arch/arm/boot/dts/omap3-beagle-xm-ab.dts b/arch/arm/boot/dts/omap3-beagle-xm-ab.dts
new file mode 100644
index 000000000000..7ac3bcf59d59
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-beagle-xm-ab.dts
@@ -0,0 +1,16 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include "omap3-beagle-xm.dts"
10
11/ {
12 /* HS USB Port 2 Power enable was inverted with the xM C */
13 hsusb2_power: hsusb2_power_reg {
14 enable-active-high;
15 };
16};
diff --git a/arch/arm/boot/dts/omap3-devkit8000.dts b/arch/arm/boot/dts/omap3-devkit8000.dts
index bf5a515a3247..da402f0fdab4 100644
--- a/arch/arm/boot/dts/omap3-devkit8000.dts
+++ b/arch/arm/boot/dts/omap3-devkit8000.dts
@@ -112,7 +112,6 @@
112 reg = <0 0 0>; /* CS0, offset 0 */ 112 reg = <0 0 0>; /* CS0, offset 0 */
113 nand-bus-width = <16>; 113 nand-bus-width = <16>;
114 114
115 gpmc,device-nand;
116 gpmc,sync-clk-ps = <0>; 115 gpmc,sync-clk-ps = <0>;
117 gpmc,cs-on-ns = <0>; 116 gpmc,cs-on-ns = <0>;
118 gpmc,cs-rd-off-ns = <44>; 117 gpmc,cs-rd-off-ns = <44>;
diff --git a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
index 6369d9f43ca2..cc1dce6978f5 100644
--- a/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
+++ b/arch/arm/boot/dts/omap3-lilly-a83x.dtsi
@@ -368,7 +368,6 @@
368 /* no elm on omap3 */ 368 /* no elm on omap3 */
369 369
370 gpmc,mux-add-data = <0>; 370 gpmc,mux-add-data = <0>;
371 gpmc,device-nand;
372 gpmc,device-width = <2>; 371 gpmc,device-width = <2>;
373 gpmc,wait-pin = <0>; 372 gpmc,wait-pin = <0>;
374 gpmc,wait-monitoring-ns = <0>; 373 gpmc,wait-monitoring-ns = <0>;
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 5e5790f631eb..acb9019dc437 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -74,7 +74,7 @@
74 /* 74 /*
75 * XXX: Use a flat representation of the OMAP3 interconnect. 75 * XXX: Use a flat representation of the OMAP3 interconnect.
76 * The real OMAP interconnect network is quite complex. 76 * The real OMAP interconnect network is quite complex.
77 * Since that will not bring real advantage to represent that in DT for 77 * Since it will not bring real advantage to represent that in DT for
78 * the moment, just use a fake OCP bus entry to represent the whole bus 78 * the moment, just use a fake OCP bus entry to represent the whole bus
79 * hierarchy. 79 * hierarchy.
80 */ 80 */
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 27fcac874742..649b5cd38b40 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -72,7 +72,7 @@
72 }; 72 };
73 73
74 /* 74 /*
75 * The soc node represents the soc top level view. It is uses for IPs 75 * The soc node represents the soc top level view. It is used for IPs
76 * that are not memory mapped in the MPU view or for the MPU itself. 76 * that are not memory mapped in the MPU view or for the MPU itself.
77 */ 77 */
78 soc { 78 soc {
@@ -96,7 +96,7 @@
96 /* 96 /*
97 * XXX: Use a flat representation of the OMAP4 interconnect. 97 * XXX: Use a flat representation of the OMAP4 interconnect.
98 * The real OMAP interconnect network is quite complex. 98 * The real OMAP interconnect network is quite complex.
99 * Since that will not bring real advantage to represent that in DT for 99 * Since it will not bring real advantage to represent that in DT for
100 * the moment, just use a fake OCP bus entry to represent the whole bus 100 * the moment, just use a fake OCP bus entry to represent the whole bus
101 * hierarchy. 101 * hierarchy.
102 */ 102 */
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index 6f3de22fb266..f8c9855ce587 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -93,7 +93,7 @@
93 }; 93 };
94 94
95 /* 95 /*
96 * The soc node represents the soc top level view. It is uses for IPs 96 * The soc node represents the soc top level view. It is used for IPs
97 * that are not memory mapped in the MPU view or for the MPU itself. 97 * that are not memory mapped in the MPU view or for the MPU itself.
98 */ 98 */
99 soc { 99 soc {
@@ -107,7 +107,7 @@
107 /* 107 /*
108 * XXX: Use a flat representation of the OMAP3 interconnect. 108 * XXX: Use a flat representation of the OMAP3 interconnect.
109 * The real OMAP interconnect network is quite complex. 109 * The real OMAP interconnect network is quite complex.
110 * Since that will not bring real advantage to represent that in DT for 110 * Since it will not bring real advantage to represent that in DT for
111 * the moment, just use a fake OCP bus entry to represent the whole bus 111 * the moment, just use a fake OCP bus entry to represent the whole bus
112 * hierarchy. 112 * hierarchy.
113 */ 113 */
@@ -813,6 +813,12 @@
813 <0x4a084c00 0x40>; 813 <0x4a084c00 0x40>;
814 reg-names = "phy_rx", "phy_tx", "pll_ctrl"; 814 reg-names = "phy_rx", "phy_tx", "pll_ctrl";
815 ctrl-module = <&omap_control_usb3phy>; 815 ctrl-module = <&omap_control_usb3phy>;
816 clocks = <&usb_phy_cm_clk32k>,
817 <&sys_clkin>,
818 <&usb_otg_ss_refclk960m>;
819 clock-names = "wkupclk",
820 "sysclk",
821 "refclk";
816 #phy-cells = <0>; 822 #phy-cells = <0>;
817 }; 823 };
818 }; 824 };
diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
index 8280884bfa59..2551e9438d35 100644
--- a/arch/arm/boot/dts/r8a7740.dtsi
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -28,7 +28,6 @@
28 gic: interrupt-controller@c2800000 { 28 gic: interrupt-controller@c2800000 {
29 compatible = "arm,cortex-a9-gic"; 29 compatible = "arm,cortex-a9-gic";
30 #interrupt-cells = <3>; 30 #interrupt-cells = <3>;
31 #address-cells = <1>;
32 interrupt-controller; 31 interrupt-controller;
33 reg = <0xc2800000 0x1000>, 32 reg = <0xc2800000 0x1000>,
34 <0xc2000000 0x1000>; 33 <0xc2000000 0x1000>;
diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts
index 6e99eb2df076..d01048ab3e77 100644
--- a/arch/arm/boot/dts/r8a7790-lager.dts
+++ b/arch/arm/boot/dts/r8a7790-lager.dts
@@ -141,12 +141,12 @@
141 }; 141 };
142 142
143 sdhi0_pins: sd0 { 143 sdhi0_pins: sd0 {
144 renesas,gpios = "sdhi0_data4", "sdhi0_ctrl"; 144 renesas,groups = "sdhi0_data4", "sdhi0_ctrl";
145 renesas,function = "sdhi0"; 145 renesas,function = "sdhi0";
146 }; 146 };
147 147
148 sdhi2_pins: sd2 { 148 sdhi2_pins: sd2 {
149 renesas,gpios = "sdhi2_data4", "sdhi2_ctrl"; 149 renesas,groups = "sdhi2_data4", "sdhi2_ctrl";
150 renesas,function = "sdhi2"; 150 renesas,function = "sdhi2";
151 }; 151 };
152 152
diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts
index bdd73e6657b2..de1b6977c69a 100644
--- a/arch/arm/boot/dts/r8a7791-koelsch.dts
+++ b/arch/arm/boot/dts/r8a7791-koelsch.dts
@@ -230,17 +230,17 @@
230 }; 230 };
231 231
232 sdhi0_pins: sd0 { 232 sdhi0_pins: sd0 {
233 renesas,gpios = "sdhi0_data4", "sdhi0_ctrl"; 233 renesas,groups = "sdhi0_data4", "sdhi0_ctrl";
234 renesas,function = "sdhi0"; 234 renesas,function = "sdhi0";
235 }; 235 };
236 236
237 sdhi1_pins: sd1 { 237 sdhi1_pins: sd1 {
238 renesas,gpios = "sdhi1_data4", "sdhi1_ctrl"; 238 renesas,groups = "sdhi1_data4", "sdhi1_ctrl";
239 renesas,function = "sdhi1"; 239 renesas,function = "sdhi1";
240 }; 240 };
241 241
242 sdhi2_pins: sd2 { 242 sdhi2_pins: sd2 {
243 renesas,gpios = "sdhi2_data4", "sdhi2_ctrl"; 243 renesas,groups = "sdhi2_data4", "sdhi2_ctrl";
244 renesas,function = "sdhi2"; 244 renesas,function = "sdhi2";
245 }; 245 };
246 246
diff --git a/arch/arm/boot/dts/rk3188.dtsi b/arch/arm/boot/dts/rk3188.dtsi
index bb36596ea205..ed9a70af3e3f 100644
--- a/arch/arm/boot/dts/rk3188.dtsi
+++ b/arch/arm/boot/dts/rk3188.dtsi
@@ -149,7 +149,7 @@
149 149
150 uart0 { 150 uart0 {
151 uart0_xfer: uart0-xfer { 151 uart0_xfer: uart0-xfer {
152 rockchip,pins = <RK_GPIO1 0 RK_FUNC_1 &pcfg_pull_none>, 152 rockchip,pins = <RK_GPIO1 0 RK_FUNC_1 &pcfg_pull_up>,
153 <RK_GPIO1 1 RK_FUNC_1 &pcfg_pull_none>; 153 <RK_GPIO1 1 RK_FUNC_1 &pcfg_pull_none>;
154 }; 154 };
155 155
@@ -164,7 +164,7 @@
164 164
165 uart1 { 165 uart1 {
166 uart1_xfer: uart1-xfer { 166 uart1_xfer: uart1-xfer {
167 rockchip,pins = <RK_GPIO1 4 RK_FUNC_1 &pcfg_pull_none>, 167 rockchip,pins = <RK_GPIO1 4 RK_FUNC_1 &pcfg_pull_up>,
168 <RK_GPIO1 5 RK_FUNC_1 &pcfg_pull_none>; 168 <RK_GPIO1 5 RK_FUNC_1 &pcfg_pull_none>;
169 }; 169 };
170 170
@@ -179,7 +179,7 @@
179 179
180 uart2 { 180 uart2 {
181 uart2_xfer: uart2-xfer { 181 uart2_xfer: uart2-xfer {
182 rockchip,pins = <RK_GPIO1 8 RK_FUNC_1 &pcfg_pull_none>, 182 rockchip,pins = <RK_GPIO1 8 RK_FUNC_1 &pcfg_pull_up>,
183 <RK_GPIO1 9 RK_FUNC_1 &pcfg_pull_none>; 183 <RK_GPIO1 9 RK_FUNC_1 &pcfg_pull_none>;
184 }; 184 };
185 /* no rts / cts for uart2 */ 185 /* no rts / cts for uart2 */
@@ -187,7 +187,7 @@
187 187
188 uart3 { 188 uart3 {
189 uart3_xfer: uart3-xfer { 189 uart3_xfer: uart3-xfer {
190 rockchip,pins = <RK_GPIO1 10 RK_FUNC_1 &pcfg_pull_none>, 190 rockchip,pins = <RK_GPIO1 10 RK_FUNC_1 &pcfg_pull_up>,
191 <RK_GPIO1 11 RK_FUNC_1 &pcfg_pull_none>; 191 <RK_GPIO1 11 RK_FUNC_1 &pcfg_pull_none>;
192 }; 192 };
193 193
diff --git a/arch/arm/boot/dts/sh73a0.dtsi b/arch/arm/boot/dts/sh73a0.dtsi
index b7bd3b9a6753..5ecf552e1c00 100644
--- a/arch/arm/boot/dts/sh73a0.dtsi
+++ b/arch/arm/boot/dts/sh73a0.dtsi
@@ -34,7 +34,6 @@
34 gic: interrupt-controller@f0001000 { 34 gic: interrupt-controller@f0001000 {
35 compatible = "arm,cortex-a9-gic"; 35 compatible = "arm,cortex-a9-gic";
36 #interrupt-cells = <3>; 36 #interrupt-cells = <3>;
37 #address-cells = <1>;
38 interrupt-controller; 37 interrupt-controller;
39 reg = <0xf0001000 0x1000>, 38 reg = <0xf0001000 0x1000>,
40 <0xf0000100 0x100>; 39 <0xf0000100 0x100>;
diff --git a/arch/arm/boot/dts/stih415-pinctrl.dtsi b/arch/arm/boot/dts/stih415-pinctrl.dtsi
index f09fb10a3791..81df870e5ee6 100644
--- a/arch/arm/boot/dts/stih415-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih415-pinctrl.dtsi
@@ -49,7 +49,7 @@
49 reg = <0xfe61f080 0x4>; 49 reg = <0xfe61f080 0x4>;
50 reg-names = "irqmux"; 50 reg-names = "irqmux";
51 interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>; 51 interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
52 interrupts-names = "irqmux"; 52 interrupt-names = "irqmux";
53 ranges = <0 0xfe610000 0x5000>; 53 ranges = <0 0xfe610000 0x5000>;
54 54
55 PIO0: gpio@fe610000 { 55 PIO0: gpio@fe610000 {
@@ -187,7 +187,7 @@
187 reg = <0xfee0f080 0x4>; 187 reg = <0xfee0f080 0x4>;
188 reg-names = "irqmux"; 188 reg-names = "irqmux";
189 interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>; 189 interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>;
190 interrupts-names = "irqmux"; 190 interrupt-names = "irqmux";
191 ranges = <0 0xfee00000 0x8000>; 191 ranges = <0 0xfee00000 0x8000>;
192 192
193 PIO5: gpio@fee00000 { 193 PIO5: gpio@fee00000 {
@@ -282,7 +282,7 @@
282 reg = <0xfe82f080 0x4>; 282 reg = <0xfe82f080 0x4>;
283 reg-names = "irqmux"; 283 reg-names = "irqmux";
284 interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>; 284 interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>;
285 interrupts-names = "irqmux"; 285 interrupt-names = "irqmux";
286 ranges = <0 0xfe820000 0x8000>; 286 ranges = <0 0xfe820000 0x8000>;
287 287
288 PIO13: gpio@fe820000 { 288 PIO13: gpio@fe820000 {
@@ -423,7 +423,7 @@
423 reg = <0xfd6bf080 0x4>; 423 reg = <0xfd6bf080 0x4>;
424 reg-names = "irqmux"; 424 reg-names = "irqmux";
425 interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; 425 interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
426 interrupts-names = "irqmux"; 426 interrupt-names = "irqmux";
427 ranges = <0 0xfd6b0000 0x3000>; 427 ranges = <0 0xfd6b0000 0x3000>;
428 428
429 PIO100: gpio@fd6b0000 { 429 PIO100: gpio@fd6b0000 {
@@ -460,7 +460,7 @@
460 reg = <0xfd33f080 0x4>; 460 reg = <0xfd33f080 0x4>;
461 reg-names = "irqmux"; 461 reg-names = "irqmux";
462 interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>; 462 interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
463 interrupts-names = "irqmux"; 463 interrupt-names = "irqmux";
464 ranges = <0 0xfd330000 0x5000>; 464 ranges = <0 0xfd330000 0x5000>;
465 465
466 PIO103: gpio@fd330000 { 466 PIO103: gpio@fd330000 {
diff --git a/arch/arm/boot/dts/stih416-pinctrl.dtsi b/arch/arm/boot/dts/stih416-pinctrl.dtsi
index aeea304086eb..250d5ecc951e 100644
--- a/arch/arm/boot/dts/stih416-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stih416-pinctrl.dtsi
@@ -53,7 +53,7 @@
53 reg = <0xfe61f080 0x4>; 53 reg = <0xfe61f080 0x4>;
54 reg-names = "irqmux"; 54 reg-names = "irqmux";
55 interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>; 55 interrupts = <GIC_SPI 182 IRQ_TYPE_LEVEL_HIGH>;
56 interrupts-names = "irqmux"; 56 interrupt-names = "irqmux";
57 ranges = <0 0xfe610000 0x6000>; 57 ranges = <0 0xfe610000 0x6000>;
58 58
59 PIO0: gpio@fe610000 { 59 PIO0: gpio@fe610000 {
@@ -201,7 +201,7 @@
201 reg = <0xfee0f080 0x4>; 201 reg = <0xfee0f080 0x4>;
202 reg-names = "irqmux"; 202 reg-names = "irqmux";
203 interrupts = <GIC_SPI 183 IRQ_TYPE_LEVEL_HIGH>; 203 interrupts = <GIC_SPI 183 IRQ_TYPE_LEVEL_HIGH>;
204 interrupts-names = "irqmux"; 204 interrupt-names = "irqmux";
205 ranges = <0 0xfee00000 0x10000>; 205 ranges = <0 0xfee00000 0x10000>;
206 206
207 PIO5: gpio@fee00000 { 207 PIO5: gpio@fee00000 {
@@ -333,7 +333,7 @@
333 reg = <0xfe82f080 0x4>; 333 reg = <0xfe82f080 0x4>;
334 reg-names = "irqmux"; 334 reg-names = "irqmux";
335 interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>; 335 interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
336 interrupts-names = "irqmux"; 336 interrupt-names = "irqmux";
337 ranges = <0 0xfe820000 0x6000>; 337 ranges = <0 0xfe820000 0x6000>;
338 338
339 PIO13: gpio@fe820000 { 339 PIO13: gpio@fe820000 {
@@ -461,7 +461,7 @@
461 reg = <0xfd6bf080 0x4>; 461 reg = <0xfd6bf080 0x4>;
462 reg-names = "irqmux"; 462 reg-names = "irqmux";
463 interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>; 463 interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
464 interrupts-names = "irqmux"; 464 interrupt-names = "irqmux";
465 ranges = <0 0xfd6b0000 0x3000>; 465 ranges = <0 0xfd6b0000 0x3000>;
466 466
467 PIO100: gpio@fd6b0000 { 467 PIO100: gpio@fd6b0000 {
@@ -498,7 +498,7 @@
498 reg = <0xfd33f080 0x4>; 498 reg = <0xfd33f080 0x4>;
499 reg-names = "irqmux"; 499 reg-names = "irqmux";
500 interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>; 500 interrupts = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
501 interrupts-names = "irqmux"; 501 interrupt-names = "irqmux";
502 ranges = <0 0xfd330000 0x5000>; 502 ranges = <0 0xfd330000 0x5000>;
503 503
504 PIO103: gpio@fd330000 { 504 PIO103: gpio@fd330000 {
diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi
index cf45a1a39483..6d540a025148 100644
--- a/arch/arm/boot/dts/tegra124.dtsi
+++ b/arch/arm/boot/dts/tegra124.dtsi
@@ -233,19 +233,6 @@
233 status = "disabled"; 233 status = "disabled";
234 }; 234 };
235 235
236 serial@0,70006400 {
237 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
238 reg = <0x0 0x70006400 0x0 0x40>;
239 reg-shift = <2>;
240 interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
241 clocks = <&tegra_car TEGRA124_CLK_UARTE>;
242 resets = <&tegra_car 66>;
243 reset-names = "serial";
244 dmas = <&apbdma 20>, <&apbdma 20>;
245 dma-names = "rx", "tx";
246 status = "disabled";
247 };
248
249 pwm@0,7000a000 { 236 pwm@0,7000a000 {
250 compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm"; 237 compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm";
251 reg = <0x0 0x7000a000 0x0 0x100>; 238 reg = <0x0 0x7000a000 0x0 0x100>;
diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
index 7dd1d6ede525..ded361075aab 100644
--- a/arch/arm/boot/dts/vf610-twr.dts
+++ b/arch/arm/boot/dts/vf610-twr.dts
@@ -25,11 +25,13 @@
25 clocks { 25 clocks {
26 audio_ext { 26 audio_ext {
27 compatible = "fixed-clock"; 27 compatible = "fixed-clock";
28 #clock-cells = <0>;
28 clock-frequency = <24576000>; 29 clock-frequency = <24576000>;
29 }; 30 };
30 31
31 enet_ext { 32 enet_ext {
32 compatible = "fixed-clock"; 33 compatible = "fixed-clock";
34 #clock-cells = <0>;
33 clock-frequency = <50000000>; 35 clock-frequency = <50000000>;
34 }; 36 };
35 }; 37 };
diff --git a/arch/arm/boot/dts/vf610.dtsi b/arch/arm/boot/dts/vf610.dtsi
index 804873367669..b8ce0aa7b157 100644
--- a/arch/arm/boot/dts/vf610.dtsi
+++ b/arch/arm/boot/dts/vf610.dtsi
@@ -45,11 +45,13 @@
45 45
46 sxosc { 46 sxosc {
47 compatible = "fixed-clock"; 47 compatible = "fixed-clock";
48 #clock-cells = <0>;
48 clock-frequency = <32768>; 49 clock-frequency = <32768>;
49 }; 50 };
50 51
51 fxosc { 52 fxosc {
52 compatible = "fixed-clock"; 53 compatible = "fixed-clock";
54 #clock-cells = <0>;
53 clock-frequency = <24000000>; 55 clock-frequency = <24000000>;
54 }; 56 };
55 }; 57 };
@@ -72,8 +74,6 @@
72 intc: interrupt-controller@40002000 { 74 intc: interrupt-controller@40002000 {
73 compatible = "arm,cortex-a9-gic"; 75 compatible = "arm,cortex-a9-gic";
74 #interrupt-cells = <3>; 76 #interrupt-cells = <3>;
75 #address-cells = <1>;
76 #size-cells = <1>;
77 interrupt-controller; 77 interrupt-controller;
78 reg = <0x40003000 0x1000>, 78 reg = <0x40003000 0x1000>,
79 <0x40002100 0x100>; 79 <0x40002100 0x100>;
diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi
index 511180769af5..c1176abc34d9 100644
--- a/arch/arm/boot/dts/zynq-7000.dtsi
+++ b/arch/arm/boot/dts/zynq-7000.dtsi
@@ -24,6 +24,7 @@
24 device_type = "cpu"; 24 device_type = "cpu";
25 reg = <0>; 25 reg = <0>;
26 clocks = <&clkc 3>; 26 clocks = <&clkc 3>;
27 clock-latency = <1000>;
27 operating-points = < 28 operating-points = <
28 /* kHz uV */ 29 /* kHz uV */
29 666667 1000000 30 666667 1000000
@@ -54,6 +55,28 @@
54 interrupt-parent = <&intc>; 55 interrupt-parent = <&intc>;
55 ranges; 56 ranges;
56 57
58 i2c0: zynq-i2c@e0004000 {
59 compatible = "cdns,i2c-r1p10";
60 status = "disabled";
61 clocks = <&clkc 38>;
62 interrupt-parent = <&intc>;
63 interrupts = <0 25 4>;
64 reg = <0xe0004000 0x1000>;
65 #address-cells = <1>;
66 #size-cells = <0>;
67 };
68
69 i2c1: zynq-i2c@e0005000 {
70 compatible = "cdns,i2c-r1p10";
71 status = "disabled";
72 clocks = <&clkc 39>;
73 interrupt-parent = <&intc>;
74 interrupts = <0 48 4>;
75 reg = <0xe0005000 0x1000>;
76 #address-cells = <1>;
77 #size-cells = <0>;
78 };
79
57 intc: interrupt-controller@f8f01000 { 80 intc: interrupt-controller@f8f01000 {
58 compatible = "arm,cortex-a9-gic"; 81 compatible = "arm,cortex-a9-gic";
59 #interrupt-cells = <3>; 82 #interrupt-cells = <3>;
diff --git a/arch/arm/boot/dts/zynq-zc702.dts b/arch/arm/boot/dts/zynq-zc702.dts
index c913f77a21eb..5e09cee33d42 100644
--- a/arch/arm/boot/dts/zynq-zc702.dts
+++ b/arch/arm/boot/dts/zynq-zc702.dts
@@ -34,6 +34,82 @@
34 phy-mode = "rgmii"; 34 phy-mode = "rgmii";
35}; 35};
36 36
37&i2c0 {
38 status = "okay";
39 clock-frequency = <400000>;
40
41 i2cswitch@74 {
42 compatible = "nxp,pca9548";
43 #address-cells = <1>;
44 #size-cells = <0>;
45 reg = <0x74>;
46
47 i2c@0 {
48 #address-cells = <1>;
49 #size-cells = <0>;
50 reg = <0>;
51 si570: clock-generator@5d {
52 #clock-cells = <0>;
53 compatible = "silabs,si570";
54 temperature-stability = <50>;
55 reg = <0x5d>;
56 factory-fout = <156250000>;
57 clock-frequency = <148500000>;
58 };
59 };
60
61 i2c@2 {
62 #address-cells = <1>;
63 #size-cells = <0>;
64 reg = <2>;
65 eeprom@54 {
66 compatible = "at,24c08";
67 reg = <0x54>;
68 };
69 };
70
71 i2c@3 {
72 #address-cells = <1>;
73 #size-cells = <0>;
74 reg = <3>;
75 gpio@21 {
76 compatible = "ti,tca6416";
77 reg = <0x21>;
78 gpio-controller;
79 #gpio-cells = <2>;
80 };
81 };
82
83 i2c@4 {
84 #address-cells = <1>;
85 #size-cells = <0>;
86 reg = <4>;
87 rtc@51 {
88 compatible = "nxp,pcf8563";
89 reg = <0x51>;
90 };
91 };
92
93 i2c@7 {
94 #address-cells = <1>;
95 #size-cells = <0>;
96 reg = <7>;
97 hwmon@52 {
98 compatible = "ti,ucd9248";
99 reg = <52>;
100 };
101 hwmon@53 {
102 compatible = "ti,ucd9248";
103 reg = <53>;
104 };
105 hwmon@54 {
106 compatible = "ti,ucd9248";
107 reg = <54>;
108 };
109 };
110 };
111};
112
37&sdhci0 { 113&sdhci0 {
38 status = "okay"; 114 status = "okay";
39}; 115};
diff --git a/arch/arm/boot/dts/zynq-zc706.dts b/arch/arm/boot/dts/zynq-zc706.dts
index 88f62c50382e..4cc9913078cd 100644
--- a/arch/arm/boot/dts/zynq-zc706.dts
+++ b/arch/arm/boot/dts/zynq-zc706.dts
@@ -35,6 +35,74 @@
35 phy-mode = "rgmii"; 35 phy-mode = "rgmii";
36}; 36};
37 37
38&i2c0 {
39 status = "okay";
40 clock-frequency = <400000>;
41
42 i2cswitch@74 {
43 compatible = "nxp,pca9548";
44 #address-cells = <1>;
45 #size-cells = <0>;
46 reg = <0x74>;
47
48 i2c@0 {
49 #address-cells = <1>;
50 #size-cells = <0>;
51 reg = <0>;
52 si570: clock-generator@5d {
53 #clock-cells = <0>;
54 compatible = "silabs,si570";
55 temperature-stability = <50>;
56 reg = <0x5d>;
57 factory-fout = <156250000>;
58 clock-frequency = <148500000>;
59 };
60 };
61
62 i2c@2 {
63 #address-cells = <1>;
64 #size-cells = <0>;
65 reg = <2>;
66 eeprom@54 {
67 compatible = "at,24c08";
68 reg = <0x54>;
69 };
70 };
71
72 i2c@3 {
73 #address-cells = <1>;
74 #size-cells = <0>;
75 reg = <3>;
76 gpio@21 {
77 compatible = "ti,tca6416";
78 reg = <0x21>;
79 gpio-controller;
80 #gpio-cells = <2>;
81 };
82 };
83
84 i2c@4 {
85 #address-cells = <1>;
86 #size-cells = <0>;
87 reg = <4>;
88 rtc@51 {
89 compatible = "nxp,pcf8563";
90 reg = <0x51>;
91 };
92 };
93
94 i2c@7 {
95 #address-cells = <1>;
96 #size-cells = <0>;
97 reg = <7>;
98 ucd90120@65 {
99 compatible = "ti,ucd90120";
100 reg = <0x65>;
101 };
102 };
103 };
104};
105
38&sdhci0 { 106&sdhci0 {
39 status = "okay"; 107 status = "okay";
40}; 108};
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 5774b6ea7ad5..f01c0ee0c87e 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -797,10 +797,8 @@ static int __init bL_switcher_init(void)
797{ 797{
798 int ret; 798 int ret;
799 799
800 if (MAX_NR_CLUSTERS != 2) { 800 if (!mcpm_is_available())
801 pr_err("%s: only dual cluster systems are supported\n", __func__); 801 return -ENODEV;
802 return -EINVAL;
803 }
804 802
805 cpu_notifier(bL_switcher_hotplug_callback, 0); 803 cpu_notifier(bL_switcher_hotplug_callback, 0);
806 804
diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c
index 1e361abc29eb..86fd60fefbc9 100644
--- a/arch/arm/common/mcpm_entry.c
+++ b/arch/arm/common/mcpm_entry.c
@@ -48,6 +48,11 @@ int __init mcpm_platform_register(const struct mcpm_platform_ops *ops)
48 return 0; 48 return 0;
49} 49}
50 50
51bool mcpm_is_available(void)
52{
53 return (platform_ops) ? true : false;
54}
55
51int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster) 56int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster)
52{ 57{
53 if (!platform_ops) 58 if (!platform_ops)
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index a9667957b757..a4e8d017f25b 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -226,7 +226,7 @@ CONFIG_USB_DWC3=m
226CONFIG_USB_TEST=y 226CONFIG_USB_TEST=y
227CONFIG_NOP_USB_XCEIV=y 227CONFIG_NOP_USB_XCEIV=y
228CONFIG_OMAP_USB2=y 228CONFIG_OMAP_USB2=y
229CONFIG_OMAP_USB3=y 229CONFIG_TI_PIPE3=y
230CONFIG_AM335X_PHY_USB=y 230CONFIG_AM335X_PHY_USB=y
231CONFIG_USB_GADGET=y 231CONFIG_USB_GADGET=y
232CONFIG_USB_GADGET_DEBUG=y 232CONFIG_USB_GADGET_DEBUG=y
diff --git a/arch/arm/configs/u300_defconfig b/arch/arm/configs/u300_defconfig
index fd81a1b99cce..aaa95ab606a8 100644
--- a/arch/arm/configs/u300_defconfig
+++ b/arch/arm/configs/u300_defconfig
@@ -11,6 +11,7 @@ CONFIG_MODULES=y
11CONFIG_MODULE_UNLOAD=y 11CONFIG_MODULE_UNLOAD=y
12# CONFIG_LBDAF is not set 12# CONFIG_LBDAF is not set
13# CONFIG_BLK_DEV_BSG is not set 13# CONFIG_BLK_DEV_BSG is not set
14CONFIG_PARTITION_ADVANCED=y
14# CONFIG_IOSCHED_CFQ is not set 15# CONFIG_IOSCHED_CFQ is not set
15# CONFIG_ARCH_MULTI_V7 is not set 16# CONFIG_ARCH_MULTI_V7 is not set
16CONFIG_ARCH_U300=y 17CONFIG_ARCH_U300=y
@@ -21,7 +22,6 @@ CONFIG_ZBOOT_ROM_TEXT=0x0
21CONFIG_ZBOOT_ROM_BSS=0x0 22CONFIG_ZBOOT_ROM_BSS=0x0
22CONFIG_CMDLINE="root=/dev/ram0 rw rootfstype=rootfs console=ttyAMA0,115200n8 lpj=515072" 23CONFIG_CMDLINE="root=/dev/ram0 rw rootfstype=rootfs console=ttyAMA0,115200n8 lpj=515072"
23CONFIG_CPU_IDLE=y 24CONFIG_CPU_IDLE=y
24CONFIG_FPE_NWFPE=y
25# CONFIG_SUSPEND is not set 25# CONFIG_SUSPEND is not set
26CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 26CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
27# CONFIG_PREVENT_FIRMWARE_BUILD is not set 27# CONFIG_PREVENT_FIRMWARE_BUILD is not set
@@ -64,8 +64,8 @@ CONFIG_TMPFS=y
64CONFIG_NLS_CODEPAGE_437=y 64CONFIG_NLS_CODEPAGE_437=y
65CONFIG_NLS_ISO8859_1=y 65CONFIG_NLS_ISO8859_1=y
66CONFIG_PRINTK_TIME=y 66CONFIG_PRINTK_TIME=y
67CONFIG_DEBUG_INFO=y
67CONFIG_DEBUG_FS=y 68CONFIG_DEBUG_FS=y
68# CONFIG_SCHED_DEBUG is not set 69# CONFIG_SCHED_DEBUG is not set
69CONFIG_TIMER_STATS=y 70CONFIG_TIMER_STATS=y
70# CONFIG_DEBUG_PREEMPT is not set 71# CONFIG_DEBUG_PREEMPT is not set
71CONFIG_DEBUG_INFO=y
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index 65f77885c167..d219d6a43238 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -1,16 +1,16 @@
1# CONFIG_SWAP is not set 1# CONFIG_SWAP is not set
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_NO_HZ=y 3CONFIG_NO_HZ_IDLE=y
4CONFIG_HIGH_RES_TIMERS=y 4CONFIG_HIGH_RES_TIMERS=y
5CONFIG_BLK_DEV_INITRD=y 5CONFIG_BLK_DEV_INITRD=y
6CONFIG_KALLSYMS_ALL=y 6CONFIG_KALLSYMS_ALL=y
7CONFIG_MODULES=y 7CONFIG_MODULES=y
8CONFIG_MODULE_UNLOAD=y 8CONFIG_MODULE_UNLOAD=y
9# CONFIG_BLK_DEV_BSG is not set 9# CONFIG_BLK_DEV_BSG is not set
10CONFIG_PARTITION_ADVANCED=y
10CONFIG_ARCH_U8500=y 11CONFIG_ARCH_U8500=y
11CONFIG_MACH_HREFV60=y 12CONFIG_MACH_HREFV60=y
12CONFIG_MACH_SNOWBALL=y 13CONFIG_MACH_SNOWBALL=y
13CONFIG_MACH_UX500_DT=y
14CONFIG_SMP=y 14CONFIG_SMP=y
15CONFIG_NR_CPUS=2 15CONFIG_NR_CPUS=2
16CONFIG_PREEMPT=y 16CONFIG_PREEMPT=y
@@ -34,16 +34,22 @@ CONFIG_IP_PNP=y
34CONFIG_IP_PNP_DHCP=y 34CONFIG_IP_PNP_DHCP=y
35CONFIG_NETFILTER=y 35CONFIG_NETFILTER=y
36CONFIG_PHONET=y 36CONFIG_PHONET=y
37# CONFIG_WIRELESS is not set 37CONFIG_CFG80211=y
38CONFIG_CFG80211_DEBUGFS=y
39CONFIG_MAC80211=y
40CONFIG_MAC80211_LEDS=y
38CONFIG_CAIF=y 41CONFIG_CAIF=y
39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 42CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
43CONFIG_DEVTMPFS=y
44CONFIG_DEVTMPFS_MOUNT=y
40CONFIG_BLK_DEV_RAM=y 45CONFIG_BLK_DEV_RAM=y
41CONFIG_BLK_DEV_RAM_SIZE=65536 46CONFIG_BLK_DEV_RAM_SIZE=65536
42CONFIG_SENSORS_BH1780=y 47CONFIG_SENSORS_BH1780=y
43CONFIG_NETDEVICES=y 48CONFIG_NETDEVICES=y
44CONFIG_SMSC911X=y 49CONFIG_SMSC911X=y
45CONFIG_SMSC_PHY=y 50CONFIG_SMSC_PHY=y
46# CONFIG_WLAN is not set 51CONFIG_CW1200=y
52CONFIG_CW1200_WLAN_SDIO=y
47# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 53# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
48CONFIG_INPUT_EVDEV=y 54CONFIG_INPUT_EVDEV=y
49# CONFIG_KEYBOARD_ATKBD is not set 55# CONFIG_KEYBOARD_ATKBD is not set
@@ -85,15 +91,12 @@ CONFIG_AB8500_USB=y
85CONFIG_USB_GADGET=y 91CONFIG_USB_GADGET=y
86CONFIG_USB_ETH=m 92CONFIG_USB_ETH=m
87CONFIG_MMC=y 93CONFIG_MMC=y
88CONFIG_MMC_UNSAFE_RESUME=y
89# CONFIG_MMC_BLOCK_BOUNCE is not set
90CONFIG_MMC_ARMMMCI=y 94CONFIG_MMC_ARMMMCI=y
91CONFIG_NEW_LEDS=y 95CONFIG_NEW_LEDS=y
92CONFIG_LEDS_CLASS=y 96CONFIG_LEDS_CLASS=y
93CONFIG_LEDS_LM3530=y 97CONFIG_LEDS_LM3530=y
94CONFIG_LEDS_GPIO=y 98CONFIG_LEDS_GPIO=y
95CONFIG_LEDS_LP5521=y 99CONFIG_LEDS_LP5521=y
96CONFIG_LEDS_TRIGGERS=y
97CONFIG_LEDS_TRIGGER_HEARTBEAT=y 100CONFIG_LEDS_TRIGGER_HEARTBEAT=y
98CONFIG_RTC_CLASS=y 101CONFIG_RTC_CLASS=y
99CONFIG_RTC_DRV_AB8500=y 102CONFIG_RTC_DRV_AB8500=y
@@ -103,6 +106,11 @@ CONFIG_STE_DMA40=y
103CONFIG_STAGING=y 106CONFIG_STAGING=y
104CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4=y 107CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4=y
105CONFIG_HSEM_U8500=y 108CONFIG_HSEM_U8500=y
109CONFIG_IIO=y
110CONFIG_IIO_ST_ACCEL_3AXIS=y
111CONFIG_IIO_ST_GYRO_3AXIS=y
112CONFIG_IIO_ST_MAGN_3AXIS=y
113CONFIG_IIO_ST_PRESS=y
106CONFIG_EXT2_FS=y 114CONFIG_EXT2_FS=y
107CONFIG_EXT2_FS_XATTR=y 115CONFIG_EXT2_FS_XATTR=y
108CONFIG_EXT2_FS_POSIX_ACL=y 116CONFIG_EXT2_FS_POSIX_ACL=y
@@ -110,8 +118,6 @@ CONFIG_EXT2_FS_SECURITY=y
110CONFIG_EXT3_FS=y 118CONFIG_EXT3_FS=y
111CONFIG_EXT4_FS=y 119CONFIG_EXT4_FS=y
112CONFIG_VFAT_FS=y 120CONFIG_VFAT_FS=y
113CONFIG_DEVTMPFS=y
114CONFIG_DEVTMPFS_MOUNT=y
115CONFIG_TMPFS=y 121CONFIG_TMPFS=y
116CONFIG_TMPFS_POSIX_ACL=y 122CONFIG_TMPFS_POSIX_ACL=y
117# CONFIG_MISC_FILESYSTEMS is not set 123# CONFIG_MISC_FILESYSTEMS is not set
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index c651e3b26ec7..4764344367d4 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -222,22 +222,22 @@ static inline int cpu_is_xsc3(void)
222#endif 222#endif
223 223
224/* 224/*
225 * Marvell's PJ4 core is based on V7 version. It has some modification 225 * Marvell's PJ4 and PJ4B cores are based on V7 version,
226 * for coprocessor setting. For this reason, we need a way to distinguish 226 * but require a specical sequence for enabling coprocessors.
227 * it. 227 * For this reason, we need a way to distinguish them.
228 */ 228 */
229#ifndef CONFIG_CPU_PJ4 229#if defined(CONFIG_CPU_PJ4) || defined(CONFIG_CPU_PJ4B)
230#define cpu_is_pj4() 0
231#else
232static inline int cpu_is_pj4(void) 230static inline int cpu_is_pj4(void)
233{ 231{
234 unsigned int id; 232 unsigned int id;
235 233
236 id = read_cpuid_id(); 234 id = read_cpuid_id();
237 if ((id & 0xfffffff0) == 0x562f5840) 235 if ((id & 0xff0fff00) == 0x560f5800)
238 return 1; 236 return 1;
239 237
240 return 0; 238 return 0;
241} 239}
240#else
241#define cpu_is_pj4() 0
242#endif 242#endif
243#endif 243#endif
diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
index 191ada6e4d2d..662c7bd06108 100644
--- a/arch/arm/include/asm/div64.h
+++ b/arch/arm/include/asm/div64.h
@@ -156,7 +156,7 @@
156 /* Select the best insn combination to perform the */ \ 156 /* Select the best insn combination to perform the */ \
157 /* actual __m * __n / (__p << 64) operation. */ \ 157 /* actual __m * __n / (__p << 64) operation. */ \
158 if (!__c) { \ 158 if (!__c) { \
159 asm ( "umull %Q0, %R0, %1, %Q2\n\t" \ 159 asm ( "umull %Q0, %R0, %Q1, %Q2\n\t" \
160 "mov %Q0, #0" \ 160 "mov %Q0, #0" \
161 : "=&r" (__res) \ 161 : "=&r" (__res) \
162 : "r" (__m), "r" (__n) \ 162 : "r" (__m), "r" (__n) \
diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h
index 608516ebabfe..a5ff410dcdb6 100644
--- a/arch/arm/include/asm/mcpm.h
+++ b/arch/arm/include/asm/mcpm.h
@@ -54,6 +54,13 @@ void mcpm_set_early_poke(unsigned cpu, unsigned cluster,
54 */ 54 */
55 55
56/** 56/**
57 * mcpm_is_available - returns whether MCPM is initialized and available
58 *
59 * This returns true or false accordingly.
60 */
61bool mcpm_is_available(void);
62
63/**
57 * mcpm_cpu_power_up - make given CPU in given cluster runable 64 * mcpm_cpu_power_up - make given CPU in given cluster runable
58 * 65 *
59 * @cpu: CPU number within given cluster 66 * @cpu: CPU number within given cluster
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index 0baf7f0d9394..f1a0dace3efe 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -98,15 +98,25 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb)
98 } 98 }
99} 99}
100 100
101static inline void tlb_flush_mmu(struct mmu_gather *tlb) 101static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
102{ 102{
103 tlb_flush(tlb); 103 tlb_flush(tlb);
104}
105
106static inline void tlb_flush_mmu_free(struct mmu_gather *tlb)
107{
104 free_pages_and_swap_cache(tlb->pages, tlb->nr); 108 free_pages_and_swap_cache(tlb->pages, tlb->nr);
105 tlb->nr = 0; 109 tlb->nr = 0;
106 if (tlb->pages == tlb->local) 110 if (tlb->pages == tlb->local)
107 __tlb_alloc_page(tlb); 111 __tlb_alloc_page(tlb);
108} 112}
109 113
114static inline void tlb_flush_mmu(struct mmu_gather *tlb)
115{
116 tlb_flush_mmu_tlbonly(tlb);
117 tlb_flush_mmu_free(tlb);
118}
119
110static inline void 120static inline void
111tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end) 121tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
112{ 122{
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index fb5584d0cc05..ba94446c72d9 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -408,6 +408,7 @@
408#define __NR_finit_module (__NR_SYSCALL_BASE+379) 408#define __NR_finit_module (__NR_SYSCALL_BASE+379)
409#define __NR_sched_setattr (__NR_SYSCALL_BASE+380) 409#define __NR_sched_setattr (__NR_SYSCALL_BASE+380)
410#define __NR_sched_getattr (__NR_SYSCALL_BASE+381) 410#define __NR_sched_getattr (__NR_SYSCALL_BASE+381)
411#define __NR_renameat2 (__NR_SYSCALL_BASE+382)
411 412
412/* 413/*
413 * This may need to be greater than __NR_last_syscall+1 in order to 414 * This may need to be greater than __NR_last_syscall+1 in order to
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index a766bcbaf8ad..040619c32d68 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -79,6 +79,7 @@ obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o
79obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o 79obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o
80obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o 80obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o
81obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o 81obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o
82obj-$(CONFIG_CPU_PJ4B) += pj4-cp0.o
82obj-$(CONFIG_IWMMXT) += iwmmxt.o 83obj-$(CONFIG_IWMMXT) += iwmmxt.o
83obj-$(CONFIG_PERF_EVENTS) += perf_regs.o 84obj-$(CONFIG_PERF_EVENTS) += perf_regs.o
84obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o perf_event_cpu.o 85obj-$(CONFIG_HW_PERF_EVENTS) += perf_event.o perf_event_cpu.o
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 166e945de832..8f51bdcdacbb 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -391,6 +391,7 @@
391 CALL(sys_finit_module) 391 CALL(sys_finit_module)
392/* 380 */ CALL(sys_sched_setattr) 392/* 380 */ CALL(sys_sched_setattr)
393 CALL(sys_sched_getattr) 393 CALL(sys_sched_getattr)
394 CALL(sys_renameat2)
394#ifndef syscalls_counted 395#ifndef syscalls_counted
395.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 396.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
396#define syscalls_counted 397#define syscalls_counted
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index f8c08839edf3..591d6e4a6492 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -587,7 +587,7 @@ __fixup_pv_table:
587 add r6, r6, r3 @ adjust __pv_phys_pfn_offset address 587 add r6, r6, r3 @ adjust __pv_phys_pfn_offset address
588 add r7, r7, r3 @ adjust __pv_offset address 588 add r7, r7, r3 @ adjust __pv_offset address
589 mov r0, r8, lsr #12 @ convert to PFN 589 mov r0, r8, lsr #12 @ convert to PFN
590 str r0, [r6, #LOW_OFFSET] @ save computed PHYS_OFFSET to __pv_phys_pfn_offset 590 str r0, [r6] @ save computed PHYS_OFFSET to __pv_phys_pfn_offset
591 strcc ip, [r7, #HIGH_OFFSET] @ save to __pv_offset high bits 591 strcc ip, [r7, #HIGH_OFFSET] @ save to __pv_offset high bits
592 mov r6, r3, lsr #24 @ constant for add/sub instructions 592 mov r6, r3, lsr #24 @ constant for add/sub instructions
593 teq r3, r6, lsl #24 @ must be 16MiB aligned 593 teq r3, r6, lsl #24 @ must be 16MiB aligned
diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S
index a08783823b32..2452dd1bef53 100644
--- a/arch/arm/kernel/iwmmxt.S
+++ b/arch/arm/kernel/iwmmxt.S
@@ -19,12 +19,16 @@
19#include <asm/thread_info.h> 19#include <asm/thread_info.h>
20#include <asm/asm-offsets.h> 20#include <asm/asm-offsets.h>
21 21
22#if defined(CONFIG_CPU_PJ4) 22#if defined(CONFIG_CPU_PJ4) || defined(CONFIG_CPU_PJ4B)
23#define PJ4(code...) code 23#define PJ4(code...) code
24#define XSC(code...) 24#define XSC(code...)
25#else 25#elif defined(CONFIG_CPU_MOHAWK) || \
26 defined(CONFIG_CPU_XSC3) || \
27 defined(CONFIG_CPU_XSCALE)
26#define PJ4(code...) 28#define PJ4(code...)
27#define XSC(code...) code 29#define XSC(code...) code
30#else
31#error "Unsupported iWMMXt architecture"
28#endif 32#endif
29 33
30#define MMX_WR0 (0x00) 34#define MMX_WR0 (0x00)
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index f0d180d8b29f..8cf0996aa1a8 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -184,3 +184,10 @@ void machine_kexec(struct kimage *image)
184 184
185 soft_restart(reboot_entry_phys); 185 soft_restart(reboot_entry_phys);
186} 186}
187
188void arch_crash_save_vmcoreinfo(void)
189{
190#ifdef CONFIG_ARM_LPAE
191 VMCOREINFO_CONFIG(ARM_LPAE);
192#endif
193}
diff --git a/arch/arm/kernel/pj4-cp0.c b/arch/arm/kernel/pj4-cp0.c
index fc7208636284..8153e36b2491 100644
--- a/arch/arm/kernel/pj4-cp0.c
+++ b/arch/arm/kernel/pj4-cp0.c
@@ -45,7 +45,7 @@ static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t)
45 return NOTIFY_DONE; 45 return NOTIFY_DONE;
46} 46}
47 47
48static struct notifier_block iwmmxt_notifier_block = { 48static struct notifier_block __maybe_unused iwmmxt_notifier_block = {
49 .notifier_call = iwmmxt_do, 49 .notifier_call = iwmmxt_do,
50}; 50};
51 51
@@ -72,6 +72,33 @@ static void __init pj4_cp_access_write(u32 value)
72 : "=r" (temp) : "r" (value)); 72 : "=r" (temp) : "r" (value));
73} 73}
74 74
75static int __init pj4_get_iwmmxt_version(void)
76{
77 u32 cp_access, wcid;
78
79 cp_access = pj4_cp_access_read();
80 pj4_cp_access_write(cp_access | 0xf);
81
82 /* check if coprocessor 0 and 1 are available */
83 if ((pj4_cp_access_read() & 0xf) != 0xf) {
84 pj4_cp_access_write(cp_access);
85 return -ENODEV;
86 }
87
88 /* read iWMMXt coprocessor id register p1, c0 */
89 __asm__ __volatile__ ("mrc p1, 0, %0, c0, c0, 0\n" : "=r" (wcid));
90
91 pj4_cp_access_write(cp_access);
92
93 /* iWMMXt v1 */
94 if ((wcid & 0xffffff00) == 0x56051000)
95 return 1;
96 /* iWMMXt v2 */
97 if ((wcid & 0xffffff00) == 0x56052000)
98 return 2;
99
100 return -EINVAL;
101}
75 102
76/* 103/*
77 * Disable CP0/CP1 on boot, and let call_fpe() and the iWMMXt lazy 104 * Disable CP0/CP1 on boot, and let call_fpe() and the iWMMXt lazy
@@ -79,17 +106,26 @@ static void __init pj4_cp_access_write(u32 value)
79 */ 106 */
80static int __init pj4_cp0_init(void) 107static int __init pj4_cp0_init(void)
81{ 108{
82 u32 cp_access; 109 u32 __maybe_unused cp_access;
110 int vers;
83 111
84 if (!cpu_is_pj4()) 112 if (!cpu_is_pj4())
85 return 0; 113 return 0;
86 114
115 vers = pj4_get_iwmmxt_version();
116 if (vers < 0)
117 return 0;
118
119#ifndef CONFIG_IWMMXT
120 pr_info("PJ4 iWMMXt coprocessor detected, but kernel support is missing.\n");
121#else
87 cp_access = pj4_cp_access_read() & ~0xf; 122 cp_access = pj4_cp_access_read() & ~0xf;
88 pj4_cp_access_write(cp_access); 123 pj4_cp_access_write(cp_access);
89 124
90 printk(KERN_INFO "PJ4 iWMMXt coprocessor enabled.\n"); 125 pr_info("PJ4 iWMMXt v%d coprocessor enabled.\n", vers);
91 elf_hwcap |= HWCAP_IWMMXT; 126 elf_hwcap |= HWCAP_IWMMXT;
92 thread_register_notifier(&iwmmxt_notifier_block); 127 thread_register_notifier(&iwmmxt_notifier_block);
128#endif
93 129
94 return 0; 130 return 0;
95} 131}
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c
index 702bd329d9d0..e90a3148f385 100644
--- a/arch/arm/kernel/sys_oabi-compat.c
+++ b/arch/arm/kernel/sys_oabi-compat.c
@@ -203,9 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
203 int ret; 203 int ret;
204 204
205 switch (cmd) { 205 switch (cmd) {
206 case F_GETLKP: 206 case F_OFD_GETLK:
207 case F_SETLKP: 207 case F_OFD_SETLK:
208 case F_SETLKPW: 208 case F_OFD_SETLKW:
209 case F_GETLK64: 209 case F_GETLK64:
210 case F_SETLK64: 210 case F_SETLK64:
211 case F_SETLKW64: 211 case F_SETLKW64:
diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig
index 466bd299b1a8..4be5bb150bdd 100644
--- a/arch/arm/kvm/Kconfig
+++ b/arch/arm/kvm/Kconfig
@@ -23,7 +23,7 @@ config KVM
23 select HAVE_KVM_CPU_RELAX_INTERCEPT 23 select HAVE_KVM_CPU_RELAX_INTERCEPT
24 select KVM_MMIO 24 select KVM_MMIO
25 select KVM_ARM_HOST 25 select KVM_ARM_HOST
26 depends on ARM_VIRT_EXT && ARM_LPAE 26 depends on ARM_VIRT_EXT && ARM_LPAE && !CPU_BIG_ENDIAN
27 ---help--- 27 ---help---
28 Support hosting virtualized guest machines. You will also 28 Support hosting virtualized guest machines. You will also
29 need to select one or more of the processor modules below. 29 need to select one or more of the processor modules below.
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 80bb1e6c2c29..16f804938b8f 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -42,6 +42,8 @@ static unsigned long hyp_idmap_start;
42static unsigned long hyp_idmap_end; 42static unsigned long hyp_idmap_end;
43static phys_addr_t hyp_idmap_vector; 43static phys_addr_t hyp_idmap_vector;
44 44
45#define pgd_order get_order(PTRS_PER_PGD * sizeof(pgd_t))
46
45#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x)) 47#define kvm_pmd_huge(_x) (pmd_huge(_x) || pmd_trans_huge(_x))
46 48
47static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) 49static void kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
@@ -293,14 +295,14 @@ void free_boot_hyp_pgd(void)
293 if (boot_hyp_pgd) { 295 if (boot_hyp_pgd) {
294 unmap_range(NULL, boot_hyp_pgd, hyp_idmap_start, PAGE_SIZE); 296 unmap_range(NULL, boot_hyp_pgd, hyp_idmap_start, PAGE_SIZE);
295 unmap_range(NULL, boot_hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE); 297 unmap_range(NULL, boot_hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
296 kfree(boot_hyp_pgd); 298 free_pages((unsigned long)boot_hyp_pgd, pgd_order);
297 boot_hyp_pgd = NULL; 299 boot_hyp_pgd = NULL;
298 } 300 }
299 301
300 if (hyp_pgd) 302 if (hyp_pgd)
301 unmap_range(NULL, hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE); 303 unmap_range(NULL, hyp_pgd, TRAMPOLINE_VA, PAGE_SIZE);
302 304
303 kfree(init_bounce_page); 305 free_page((unsigned long)init_bounce_page);
304 init_bounce_page = NULL; 306 init_bounce_page = NULL;
305 307
306 mutex_unlock(&kvm_hyp_pgd_mutex); 308 mutex_unlock(&kvm_hyp_pgd_mutex);
@@ -330,7 +332,7 @@ void free_hyp_pgds(void)
330 for (addr = VMALLOC_START; is_vmalloc_addr((void*)addr); addr += PGDIR_SIZE) 332 for (addr = VMALLOC_START; is_vmalloc_addr((void*)addr); addr += PGDIR_SIZE)
331 unmap_range(NULL, hyp_pgd, KERN_TO_HYP(addr), PGDIR_SIZE); 333 unmap_range(NULL, hyp_pgd, KERN_TO_HYP(addr), PGDIR_SIZE);
332 334
333 kfree(hyp_pgd); 335 free_pages((unsigned long)hyp_pgd, pgd_order);
334 hyp_pgd = NULL; 336 hyp_pgd = NULL;
335 } 337 }
336 338
@@ -1024,7 +1026,7 @@ int kvm_mmu_init(void)
1024 size_t len = __hyp_idmap_text_end - __hyp_idmap_text_start; 1026 size_t len = __hyp_idmap_text_end - __hyp_idmap_text_start;
1025 phys_addr_t phys_base; 1027 phys_addr_t phys_base;
1026 1028
1027 init_bounce_page = kmalloc(PAGE_SIZE, GFP_KERNEL); 1029 init_bounce_page = (void *)__get_free_page(GFP_KERNEL);
1028 if (!init_bounce_page) { 1030 if (!init_bounce_page) {
1029 kvm_err("Couldn't allocate HYP init bounce page\n"); 1031 kvm_err("Couldn't allocate HYP init bounce page\n");
1030 err = -ENOMEM; 1032 err = -ENOMEM;
@@ -1050,8 +1052,9 @@ int kvm_mmu_init(void)
1050 (unsigned long)phys_base); 1052 (unsigned long)phys_base);
1051 } 1053 }
1052 1054
1053 hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL); 1055 hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
1054 boot_hyp_pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL); 1056 boot_hyp_pgd = (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, pgd_order);
1057
1055 if (!hyp_pgd || !boot_hyp_pgd) { 1058 if (!hyp_pgd || !boot_hyp_pgd) {
1056 kvm_err("Hyp mode PGD not allocated\n"); 1059 kvm_err("Hyp mode PGD not allocated\n");
1057 err = -ENOMEM; 1060 err = -ENOMEM;
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 8b1b0a870025..a0282928e9c1 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -1296,7 +1296,7 @@ static struct resource adc_resources[] = {
1296}; 1296};
1297 1297
1298static struct platform_device at91_adc_device = { 1298static struct platform_device at91_adc_device = {
1299 .name = "at91_adc", 1299 .name = "at91sam9260-adc",
1300 .id = -1, 1300 .id = -1,
1301 .dev = { 1301 .dev = {
1302 .platform_data = &adc_data, 1302 .platform_data = &adc_data,
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 77b04c2edd78..dab362c06487 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1204,7 +1204,7 @@ static struct resource adc_resources[] = {
1204}; 1204};
1205 1205
1206static struct platform_device at91_adc_device = { 1206static struct platform_device at91_adc_device = {
1207 .name = "at91_adc", 1207 .name = "at91sam9g45-adc",
1208 .id = -1, 1208 .id = -1,
1209 .dev = { 1209 .dev = {
1210 .platform_data = &adc_data, 1210 .platform_data = &adc_data,
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index b0e7f9d2c245..2b4d6acfa34a 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -208,8 +208,8 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
208 * the "output_enable" bit as a gate, even though it's really just 208 * the "output_enable" bit as a gate, even though it's really just
209 * enabling clock output. 209 * enabling clock output.
210 */ 210 */
211 clk[lvds1_gate] = imx_clk_gate("lvds1_gate", "dummy", base + 0x160, 10); 211 clk[lvds1_gate] = imx_clk_gate("lvds1_gate", "lvds1_sel", base + 0x160, 10);
212 clk[lvds2_gate] = imx_clk_gate("lvds2_gate", "dummy", base + 0x160, 11); 212 clk[lvds2_gate] = imx_clk_gate("lvds2_gate", "lvds2_sel", base + 0x160, 11);
213 213
214 /* name parent_name reg idx */ 214 /* name parent_name reg idx */
215 clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus", base + 0x100, 0); 215 clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus", base + 0x100, 0);
@@ -258,14 +258,14 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
258 clk[ipu2_sel] = imx_clk_mux("ipu2_sel", base + 0x3c, 14, 2, ipu_sels, ARRAY_SIZE(ipu_sels)); 258 clk[ipu2_sel] = imx_clk_mux("ipu2_sel", base + 0x3c, 14, 2, ipu_sels, ARRAY_SIZE(ipu_sels));
259 clk[ldb_di0_sel] = imx_clk_mux_flags("ldb_di0_sel", base + 0x2c, 9, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels), CLK_SET_RATE_PARENT); 259 clk[ldb_di0_sel] = imx_clk_mux_flags("ldb_di0_sel", base + 0x2c, 9, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels), CLK_SET_RATE_PARENT);
260 clk[ldb_di1_sel] = imx_clk_mux_flags("ldb_di1_sel", base + 0x2c, 12, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels), CLK_SET_RATE_PARENT); 260 clk[ldb_di1_sel] = imx_clk_mux_flags("ldb_di1_sel", base + 0x2c, 12, 3, ldb_di_sels, ARRAY_SIZE(ldb_di_sels), CLK_SET_RATE_PARENT);
261 clk[ipu1_di0_pre_sel] = imx_clk_mux("ipu1_di0_pre_sel", base + 0x34, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); 261 clk[ipu1_di0_pre_sel] = imx_clk_mux_flags("ipu1_di0_pre_sel", base + 0x34, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels), CLK_SET_RATE_PARENT);
262 clk[ipu1_di1_pre_sel] = imx_clk_mux("ipu1_di1_pre_sel", base + 0x34, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); 262 clk[ipu1_di1_pre_sel] = imx_clk_mux_flags("ipu1_di1_pre_sel", base + 0x34, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels), CLK_SET_RATE_PARENT);
263 clk[ipu2_di0_pre_sel] = imx_clk_mux("ipu2_di0_pre_sel", base + 0x38, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); 263 clk[ipu2_di0_pre_sel] = imx_clk_mux_flags("ipu2_di0_pre_sel", base + 0x38, 6, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels), CLK_SET_RATE_PARENT);
264 clk[ipu2_di1_pre_sel] = imx_clk_mux("ipu2_di1_pre_sel", base + 0x38, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels)); 264 clk[ipu2_di1_pre_sel] = imx_clk_mux_flags("ipu2_di1_pre_sel", base + 0x38, 15, 3, ipu_di_pre_sels, ARRAY_SIZE(ipu_di_pre_sels), CLK_SET_RATE_PARENT);
265 clk[ipu1_di0_sel] = imx_clk_mux("ipu1_di0_sel", base + 0x34, 0, 3, ipu1_di0_sels, ARRAY_SIZE(ipu1_di0_sels)); 265 clk[ipu1_di0_sel] = imx_clk_mux_flags("ipu1_di0_sel", base + 0x34, 0, 3, ipu1_di0_sels, ARRAY_SIZE(ipu1_di0_sels), CLK_SET_RATE_PARENT);
266 clk[ipu1_di1_sel] = imx_clk_mux("ipu1_di1_sel", base + 0x34, 9, 3, ipu1_di1_sels, ARRAY_SIZE(ipu1_di1_sels)); 266 clk[ipu1_di1_sel] = imx_clk_mux_flags("ipu1_di1_sel", base + 0x34, 9, 3, ipu1_di1_sels, ARRAY_SIZE(ipu1_di1_sels), CLK_SET_RATE_PARENT);
267 clk[ipu2_di0_sel] = imx_clk_mux("ipu2_di0_sel", base + 0x38, 0, 3, ipu2_di0_sels, ARRAY_SIZE(ipu2_di0_sels)); 267 clk[ipu2_di0_sel] = imx_clk_mux_flags("ipu2_di0_sel", base + 0x38, 0, 3, ipu2_di0_sels, ARRAY_SIZE(ipu2_di0_sels), CLK_SET_RATE_PARENT);
268 clk[ipu2_di1_sel] = imx_clk_mux("ipu2_di1_sel", base + 0x38, 9, 3, ipu2_di1_sels, ARRAY_SIZE(ipu2_di1_sels)); 268 clk[ipu2_di1_sel] = imx_clk_mux_flags("ipu2_di1_sel", base + 0x38, 9, 3, ipu2_di1_sels, ARRAY_SIZE(ipu2_di1_sels), CLK_SET_RATE_PARENT);
269 clk[hsi_tx_sel] = imx_clk_mux("hsi_tx_sel", base + 0x30, 28, 1, hsi_tx_sels, ARRAY_SIZE(hsi_tx_sels)); 269 clk[hsi_tx_sel] = imx_clk_mux("hsi_tx_sel", base + 0x30, 28, 1, hsi_tx_sels, ARRAY_SIZE(hsi_tx_sels));
270 clk[pcie_axi_sel] = imx_clk_mux("pcie_axi_sel", base + 0x18, 10, 1, pcie_axi_sels, ARRAY_SIZE(pcie_axi_sels)); 270 clk[pcie_axi_sel] = imx_clk_mux("pcie_axi_sel", base + 0x18, 10, 1, pcie_axi_sels, ARRAY_SIZE(pcie_axi_sels));
271 clk[ssi1_sel] = imx_clk_fixup_mux("ssi1_sel", base + 0x1c, 10, 2, ssi_sels, ARRAY_SIZE(ssi_sels), imx_cscmr1_fixup); 271 clk[ssi1_sel] = imx_clk_fixup_mux("ssi1_sel", base + 0x1c, 10, 2, ssi_sels, ARRAY_SIZE(ssi_sels), imx_cscmr1_fixup);
@@ -445,6 +445,15 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
445 clk_set_parent(clk[ldb_di1_sel], clk[pll5_video_div]); 445 clk_set_parent(clk[ldb_di1_sel], clk[pll5_video_div]);
446 } 446 }
447 447
448 clk_set_parent(clk[ipu1_di0_pre_sel], clk[pll5_video_div]);
449 clk_set_parent(clk[ipu1_di1_pre_sel], clk[pll5_video_div]);
450 clk_set_parent(clk[ipu2_di0_pre_sel], clk[pll5_video_div]);
451 clk_set_parent(clk[ipu2_di1_pre_sel], clk[pll5_video_div]);
452 clk_set_parent(clk[ipu1_di0_sel], clk[ipu1_di0_pre]);
453 clk_set_parent(clk[ipu1_di1_sel], clk[ipu1_di1_pre]);
454 clk_set_parent(clk[ipu2_di0_sel], clk[ipu2_di0_pre]);
455 clk_set_parent(clk[ipu2_di1_sel], clk[ipu2_di1_pre]);
456
448 /* 457 /*
449 * The gpmi needs 100MHz frequency in the EDO/Sync mode, 458 * The gpmi needs 100MHz frequency in the EDO/Sync mode,
450 * We can not get the 100MHz from the pll2_pfd0_352m. 459 * We can not get the 100MHz from the pll2_pfd0_352m.
diff --git a/arch/arm/mach-omap2/board-rx51-video.c b/arch/arm/mach-omap2/board-rx51-video.c
index 43a90c8d6837..9cfebc5c7455 100644
--- a/arch/arm/mach-omap2/board-rx51-video.c
+++ b/arch/arm/mach-omap2/board-rx51-video.c
@@ -48,7 +48,7 @@ static struct omap_dss_board_info rx51_dss_board_info = {
48 48
49static int __init rx51_video_init(void) 49static int __init rx51_video_init(void)
50{ 50{
51 if (!machine_is_nokia_rx51() && !of_machine_is_compatible("nokia,omap3-n900")) 51 if (!machine_is_nokia_rx51())
52 return 0; 52 return 0;
53 53
54 if (omap_mux_init_gpio(RX51_LCD_RESET_GPIO, OMAP_PIN_OUTPUT)) { 54 if (omap_mux_init_gpio(RX51_LCD_RESET_GPIO, OMAP_PIN_OUTPUT)) {
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
index 2649ce445845..332af927f4d3 100644
--- a/arch/arm/mach-omap2/clkt_dpll.c
+++ b/arch/arm/mach-omap2/clkt_dpll.c
@@ -209,7 +209,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw)
209 if (v == OMAP3XXX_EN_DPLL_LPBYPASS || 209 if (v == OMAP3XXX_EN_DPLL_LPBYPASS ||
210 v == OMAP3XXX_EN_DPLL_FRBYPASS) 210 v == OMAP3XXX_EN_DPLL_FRBYPASS)
211 return 1; 211 return 1;
212 } else if (soc_is_am33xx() || cpu_is_omap44xx()) { 212 } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx()) {
213 if (v == OMAP4XXX_EN_DPLL_LPBYPASS || 213 if (v == OMAP4XXX_EN_DPLL_LPBYPASS ||
214 v == OMAP4XXX_EN_DPLL_FRBYPASS || 214 v == OMAP4XXX_EN_DPLL_FRBYPASS ||
215 v == OMAP4XXX_EN_DPLL_MNBYPASS) 215 v == OMAP4XXX_EN_DPLL_MNBYPASS)
@@ -255,7 +255,7 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)
255 if (v == OMAP3XXX_EN_DPLL_LPBYPASS || 255 if (v == OMAP3XXX_EN_DPLL_LPBYPASS ||
256 v == OMAP3XXX_EN_DPLL_FRBYPASS) 256 v == OMAP3XXX_EN_DPLL_FRBYPASS)
257 return __clk_get_rate(dd->clk_bypass); 257 return __clk_get_rate(dd->clk_bypass);
258 } else if (soc_is_am33xx() || cpu_is_omap44xx()) { 258 } else if (soc_is_am33xx() || cpu_is_omap44xx() || soc_is_am43xx()) {
259 if (v == OMAP4XXX_EN_DPLL_LPBYPASS || 259 if (v == OMAP4XXX_EN_DPLL_LPBYPASS ||
260 v == OMAP4XXX_EN_DPLL_FRBYPASS || 260 v == OMAP4XXX_EN_DPLL_FRBYPASS ||
261 v == OMAP4XXX_EN_DPLL_MNBYPASS) 261 v == OMAP4XXX_EN_DPLL_MNBYPASS)
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index ab43755364f5..9fe8c949305c 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -501,7 +501,7 @@ static int gpmc_cs_delete_mem(int cs)
501 int r; 501 int r;
502 502
503 spin_lock(&gpmc_mem_lock); 503 spin_lock(&gpmc_mem_lock);
504 r = release_resource(&gpmc_cs_mem[cs]); 504 r = release_resource(res);
505 res->start = 0; 505 res->start = 0;
506 res->end = 0; 506 res->end = 0;
507 spin_unlock(&gpmc_mem_lock); 507 spin_unlock(&gpmc_mem_lock);
@@ -527,6 +527,14 @@ static int gpmc_cs_remap(int cs, u32 base)
527 pr_err("%s: requested chip-select is disabled\n", __func__); 527 pr_err("%s: requested chip-select is disabled\n", __func__);
528 return -ENODEV; 528 return -ENODEV;
529 } 529 }
530
531 /*
532 * Make sure we ignore any device offsets from the GPMC partition
533 * allocated for the chip select and that the new base confirms
534 * to the GPMC 16MB minimum granularity.
535 */
536 base &= ~(SZ_16M - 1);
537
530 gpmc_cs_get_memconf(cs, &old_base, &size); 538 gpmc_cs_get_memconf(cs, &old_base, &size);
531 if (base == old_base) 539 if (base == old_base)
532 return 0; 540 return 0;
@@ -586,6 +594,8 @@ EXPORT_SYMBOL(gpmc_cs_request);
586 594
587void gpmc_cs_free(int cs) 595void gpmc_cs_free(int cs)
588{ 596{
597 struct resource *res = &gpmc_cs_mem[cs];
598
589 spin_lock(&gpmc_mem_lock); 599 spin_lock(&gpmc_mem_lock);
590 if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) { 600 if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) {
591 printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs); 601 printk(KERN_ERR "Trying to free non-reserved GPMC CS%d\n", cs);
@@ -594,7 +604,8 @@ void gpmc_cs_free(int cs)
594 return; 604 return;
595 } 605 }
596 gpmc_cs_disable_mem(cs); 606 gpmc_cs_disable_mem(cs);
597 release_resource(&gpmc_cs_mem[cs]); 607 if (res->flags)
608 release_resource(res);
598 gpmc_cs_set_reserved(cs, 0); 609 gpmc_cs_set_reserved(cs, 0);
599 spin_unlock(&gpmc_mem_lock); 610 spin_unlock(&gpmc_mem_lock);
600} 611}
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 1f33f5db10d5..66c60fe1104c 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2546,11 +2546,12 @@ static int __init _init(struct omap_hwmod *oh, void *data)
2546 return -EINVAL; 2546 return -EINVAL;
2547 } 2547 }
2548 2548
2549 if (np) 2549 if (np) {
2550 if (of_find_property(np, "ti,no-reset-on-init", NULL)) 2550 if (of_find_property(np, "ti,no-reset-on-init", NULL))
2551 oh->flags |= HWMOD_INIT_NO_RESET; 2551 oh->flags |= HWMOD_INIT_NO_RESET;
2552 if (of_find_property(np, "ti,no-idle-on-init", NULL)) 2552 if (of_find_property(np, "ti,no-idle-on-init", NULL))
2553 oh->flags |= HWMOD_INIT_NO_IDLE; 2553 oh->flags |= HWMOD_INIT_NO_IDLE;
2554 }
2554 2555
2555 oh->_state = _HWMOD_STATE_INITIALIZED; 2556 oh->_state = _HWMOD_STATE_INITIALIZED;
2556 2557
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index a123ff0070bd..71ac7d5f3385 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1964,7 +1964,7 @@ static struct omap_hwmod_irq_info omap3xxx_usb_host_hs_irqs[] = {
1964static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = { 1964static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = {
1965 .name = "usb_host_hs", 1965 .name = "usb_host_hs",
1966 .class = &omap3xxx_usb_host_hs_hwmod_class, 1966 .class = &omap3xxx_usb_host_hs_hwmod_class,
1967 .clkdm_name = "l3_init_clkdm", 1967 .clkdm_name = "usbhost_clkdm",
1968 .mpu_irqs = omap3xxx_usb_host_hs_irqs, 1968 .mpu_irqs = omap3xxx_usb_host_hs_irqs,
1969 .main_clk = "usbhost_48m_fck", 1969 .main_clk = "usbhost_48m_fck",
1970 .prcm = { 1970 .prcm = {
@@ -2047,7 +2047,7 @@ static struct omap_hwmod_irq_info omap3xxx_usb_tll_hs_irqs[] = {
2047static struct omap_hwmod omap3xxx_usb_tll_hs_hwmod = { 2047static struct omap_hwmod omap3xxx_usb_tll_hs_hwmod = {
2048 .name = "usb_tll_hs", 2048 .name = "usb_tll_hs",
2049 .class = &omap3xxx_usb_tll_hs_hwmod_class, 2049 .class = &omap3xxx_usb_tll_hs_hwmod_class,
2050 .clkdm_name = "l3_init_clkdm", 2050 .clkdm_name = "core_l4_clkdm",
2051 .mpu_irqs = omap3xxx_usb_tll_hs_irqs, 2051 .mpu_irqs = omap3xxx_usb_tll_hs_irqs,
2052 .main_clk = "usbtll_fck", 2052 .main_clk = "usbtll_fck",
2053 .prcm = { 2053 .prcm = {
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 1f3770a8a728..87099bb6de69 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -330,10 +330,6 @@ void omap_sram_idle(void)
330 omap3_sram_restore_context(); 330 omap3_sram_restore_context();
331 omap2_sms_restore_context(); 331 omap2_sms_restore_context();
332 } 332 }
333 if (core_next_state == PWRDM_POWER_OFF)
334 omap2_prm_clear_mod_reg_bits(OMAP3430_AUTO_OFF_MASK,
335 OMAP3430_GR_MOD,
336 OMAP3_PRM_VOLTCTRL_OFFSET);
337 } 333 }
338 omap3_intc_resume_idle(); 334 omap3_intc_resume_idle();
339 335
diff --git a/arch/arm/mach-pxa/include/mach/hx4700.h b/arch/arm/mach-pxa/include/mach/hx4700.h
index 8bc02913517c..0e1bb46264f9 100644
--- a/arch/arm/mach-pxa/include/mach/hx4700.h
+++ b/arch/arm/mach-pxa/include/mach/hx4700.h
@@ -14,6 +14,7 @@
14 14
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/mfd/asic3.h> 16#include <linux/mfd/asic3.h>
17#include "irqs.h" /* PXA_NR_BUILTIN_GPIO */
17 18
18#define HX4700_ASIC3_GPIO_BASE PXA_NR_BUILTIN_GPIO 19#define HX4700_ASIC3_GPIO_BASE PXA_NR_BUILTIN_GPIO
19#define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS) 20#define HX4700_EGPIO_BASE (HX4700_ASIC3_GPIO_BASE + ASIC3_NUM_GPIOS)
diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c
index dbfa5a26cfff..072842f6491b 100644
--- a/arch/arm/mach-rockchip/platsmp.c
+++ b/arch/arm/mach-rockchip/platsmp.c
@@ -152,7 +152,7 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus)
152 152
153 node = of_find_compatible_node(NULL, NULL, "rockchip,rk3066-pmu"); 153 node = of_find_compatible_node(NULL, NULL, "rockchip,rk3066-pmu");
154 if (!node) { 154 if (!node) {
155 pr_err("%s: could not find sram dt node\n", __func__); 155 pr_err("%s: could not find pmu dt node\n", __func__);
156 return; 156 return;
157 } 157 }
158 158
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 2858f380beae..486063db2a2f 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -992,6 +992,7 @@ static struct asoc_simple_card_info fsi_wm8978_info = {
992 .platform = "sh_fsi2", 992 .platform = "sh_fsi2",
993 .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM, 993 .daifmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM,
994 .cpu_dai = { 994 .cpu_dai = {
995 .fmt = SND_SOC_DAIFMT_IB_NF,
995 .name = "fsia-dai", 996 .name = "fsia-dai",
996 }, 997 },
997 .codec_dai = { 998 .codec_dai = {
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c
index f0104bfe544e..18c7e0311aa6 100644
--- a/arch/arm/mach-shmobile/board-lager.c
+++ b/arch/arm/mach-shmobile/board-lager.c
@@ -588,14 +588,12 @@ static struct asoc_simple_card_info rsnd_card_info = {
588 .card = "SSI01-AK4643", 588 .card = "SSI01-AK4643",
589 .codec = "ak4642-codec.2-0012", 589 .codec = "ak4642-codec.2-0012",
590 .platform = "rcar_sound", 590 .platform = "rcar_sound",
591 .daifmt = SND_SOC_DAIFMT_LEFT_J, 591 .daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
592 .cpu_dai = { 592 .cpu_dai = {
593 .name = "rcar_sound", 593 .name = "rcar_sound",
594 .fmt = SND_SOC_DAIFMT_CBS_CFS,
595 }, 594 },
596 .codec_dai = { 595 .codec_dai = {
597 .name = "ak4642-hifi", 596 .name = "ak4642-hifi",
598 .fmt = SND_SOC_DAIFMT_CBM_CFM,
599 .sysclk = 11289600, 597 .sysclk = 11289600,
600 }, 598 },
601}; 599};
diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c
index 2009a9bc6356..9989b1b06ffd 100644
--- a/arch/arm/mach-shmobile/clock-r8a7778.c
+++ b/arch/arm/mach-shmobile/clock-r8a7778.c
@@ -170,7 +170,7 @@ static struct clk mstp_clks[MSTP_NR] = {
170 [MSTP010] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 10, 0), /* SSI2 */ 170 [MSTP010] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 10, 0), /* SSI2 */
171 [MSTP009] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 9, 0), /* SSI3 */ 171 [MSTP009] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 9, 0), /* SSI3 */
172 [MSTP008] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 8, 0), /* SRU */ 172 [MSTP008] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 8, 0), /* SRU */
173 [MSTP007] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 7, 0), /* HSPI */ 173 [MSTP007] = SH_CLK_MSTP32(&s_clk, MSTPCR0, 7, 0), /* HSPI */
174}; 174};
175 175
176static struct clk_lookup lookups[] = { 176static struct clk_lookup lookups[] = {
diff --git a/arch/arm/mach-spear/time.c b/arch/arm/mach-spear/time.c
index 64790353951f..26fda4ed4d51 100644
--- a/arch/arm/mach-spear/time.c
+++ b/arch/arm/mach-spear/time.c
@@ -71,7 +71,7 @@ static void clockevent_set_mode(enum clock_event_mode mode,
71static int clockevent_next_event(unsigned long evt, 71static int clockevent_next_event(unsigned long evt,
72 struct clock_event_device *clk_event_dev); 72 struct clock_event_device *clk_event_dev);
73 73
74static void spear_clocksource_init(void) 74static void __init spear_clocksource_init(void)
75{ 75{
76 u32 tick_rate; 76 u32 tick_rate;
77 u16 val; 77 u16 val;
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 92d660f9610f..55b305d51669 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -70,7 +70,4 @@ config TEGRA_AHB
70 which controls AHB bus master arbitration and some 70 which controls AHB bus master arbitration and some
71 performance parameters(priority, prefech size). 71 performance parameters(priority, prefech size).
72 72
73config TEGRA_EMC_SCALING_ENABLE
74 bool "Enable scaling the memory frequency"
75
76endmenu 73endmenu
diff --git a/arch/arm/mach-vexpress/dcscb.c b/arch/arm/mach-vexpress/dcscb.c
index 788495d35cf9..30b993399ed7 100644
--- a/arch/arm/mach-vexpress/dcscb.c
+++ b/arch/arm/mach-vexpress/dcscb.c
@@ -51,12 +51,14 @@ static int dcscb_allcpus_mask[2];
51static int dcscb_power_up(unsigned int cpu, unsigned int cluster) 51static int dcscb_power_up(unsigned int cpu, unsigned int cluster)
52{ 52{
53 unsigned int rst_hold, cpumask = (1 << cpu); 53 unsigned int rst_hold, cpumask = (1 << cpu);
54 unsigned int all_mask = dcscb_allcpus_mask[cluster]; 54 unsigned int all_mask;
55 55
56 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); 56 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
57 if (cpu >= 4 || cluster >= 2) 57 if (cpu >= 4 || cluster >= 2)
58 return -EINVAL; 58 return -EINVAL;
59 59
60 all_mask = dcscb_allcpus_mask[cluster];
61
60 /* 62 /*
61 * Since this is called with IRQs enabled, and no arch_spin_lock_irq 63 * Since this is called with IRQs enabled, and no arch_spin_lock_irq
62 * variant exists, we need to disable IRQs manually here. 64 * variant exists, we need to disable IRQs manually here.
@@ -101,11 +103,12 @@ static void dcscb_power_down(void)
101 cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0); 103 cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
102 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); 104 cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
103 cpumask = (1 << cpu); 105 cpumask = (1 << cpu);
104 all_mask = dcscb_allcpus_mask[cluster];
105 106
106 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster); 107 pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
107 BUG_ON(cpu >= 4 || cluster >= 2); 108 BUG_ON(cpu >= 4 || cluster >= 2);
108 109
110 all_mask = dcscb_allcpus_mask[cluster];
111
109 __mcpm_cpu_going_down(cpu, cluster); 112 __mcpm_cpu_going_down(cpu, cluster);
110 113
111 arch_spin_lock(&dcscb_lock); 114 arch_spin_lock(&dcscb_lock);
diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index c26ef5b92ca7..2c2754e79cb3 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -392,7 +392,7 @@ static irqreturn_t ve_spc_irq_handler(int irq, void *data)
392 * +--------------------------+ 392 * +--------------------------+
393 * | 31 20 | 19 0 | 393 * | 31 20 | 19 0 |
394 * +--------------------------+ 394 * +--------------------------+
395 * | u_volt | freq(kHz) | 395 * | m_volt | freq(kHz) |
396 * +--------------------------+ 396 * +--------------------------+
397 */ 397 */
398#define MULT_FACTOR 20 398#define MULT_FACTOR 20
@@ -414,7 +414,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
414 ret = ve_spc_read_sys_cfg(SYSCFG_SCC, off, &data); 414 ret = ve_spc_read_sys_cfg(SYSCFG_SCC, off, &data);
415 if (!ret) { 415 if (!ret) {
416 opps->freq = (data & FREQ_MASK) * MULT_FACTOR; 416 opps->freq = (data & FREQ_MASK) * MULT_FACTOR;
417 opps->u_volt = data >> VOLT_SHIFT; 417 opps->u_volt = (data >> VOLT_SHIFT) * 1000;
418 } else { 418 } else {
419 break; 419 break;
420 } 420 }
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index f5ad9ee70426..5bf7c3c3b301 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -420,29 +420,29 @@ config CPU_32v3
420 bool 420 bool
421 select CPU_USE_DOMAINS if MMU 421 select CPU_USE_DOMAINS if MMU
422 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 422 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
423 select TLS_REG_EMUL if SMP || !MMU
424 select NEED_KUSER_HELPERS 423 select NEED_KUSER_HELPERS
424 select TLS_REG_EMUL if SMP || !MMU
425 425
426config CPU_32v4 426config CPU_32v4
427 bool 427 bool
428 select CPU_USE_DOMAINS if MMU 428 select CPU_USE_DOMAINS if MMU
429 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 429 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
430 select TLS_REG_EMUL if SMP || !MMU
431 select NEED_KUSER_HELPERS 430 select NEED_KUSER_HELPERS
431 select TLS_REG_EMUL if SMP || !MMU
432 432
433config CPU_32v4T 433config CPU_32v4T
434 bool 434 bool
435 select CPU_USE_DOMAINS if MMU 435 select CPU_USE_DOMAINS if MMU
436 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 436 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
437 select TLS_REG_EMUL if SMP || !MMU
438 select NEED_KUSER_HELPERS 437 select NEED_KUSER_HELPERS
438 select TLS_REG_EMUL if SMP || !MMU
439 439
440config CPU_32v5 440config CPU_32v5
441 bool 441 bool
442 select CPU_USE_DOMAINS if MMU 442 select CPU_USE_DOMAINS if MMU
443 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP 443 select NEEDS_SYSCALL_FOR_CMPXCHG if SMP
444 select TLS_REG_EMUL if SMP || !MMU
445 select NEED_KUSER_HELPERS 444 select NEED_KUSER_HELPERS
445 select TLS_REG_EMUL if SMP || !MMU
446 446
447config CPU_32v6 447config CPU_32v6
448 bool 448 bool
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index f62aa0677e5c..6b00be1f971e 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1963,8 +1963,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
1963 mapping->nr_bitmaps = 1; 1963 mapping->nr_bitmaps = 1;
1964 mapping->extensions = extensions; 1964 mapping->extensions = extensions;
1965 mapping->base = base; 1965 mapping->base = base;
1966 mapping->size = bitmap_size << PAGE_SHIFT;
1967 mapping->bits = BITS_PER_BYTE * bitmap_size; 1966 mapping->bits = BITS_PER_BYTE * bitmap_size;
1967 mapping->size = mapping->bits << PAGE_SHIFT;
1968 1968
1969 spin_lock_init(&mapping->lock); 1969 spin_lock_init(&mapping->lock);
1970 1970
diff --git a/arch/arm/vfp/vfpdouble.c b/arch/arm/vfp/vfpdouble.c
index 6cac43bd1d86..423f56dd4028 100644
--- a/arch/arm/vfp/vfpdouble.c
+++ b/arch/arm/vfp/vfpdouble.c
@@ -866,6 +866,8 @@ vfp_double_multiply_accumulate(int dd, int dn, int dm, u32 fpscr, u32 negate, ch
866 vdp.sign = vfp_sign_negate(vdp.sign); 866 vdp.sign = vfp_sign_negate(vdp.sign);
867 867
868 vfp_double_unpack(&vdn, vfp_get_double(dd)); 868 vfp_double_unpack(&vdn, vfp_get_double(dd));
869 if (vdn.exponent == 0 && vdn.significand)
870 vfp_double_normalise_denormal(&vdn);
869 if (negate & NEG_SUBTRACT) 871 if (negate & NEG_SUBTRACT)
870 vdn.sign = vfp_sign_negate(vdn.sign); 872 vdn.sign = vfp_sign_negate(vdn.sign);
871 873
diff --git a/arch/arm/vfp/vfpsingle.c b/arch/arm/vfp/vfpsingle.c
index b252631b406b..4f96c1617aae 100644
--- a/arch/arm/vfp/vfpsingle.c
+++ b/arch/arm/vfp/vfpsingle.c
@@ -915,6 +915,8 @@ vfp_single_multiply_accumulate(int sd, int sn, s32 m, u32 fpscr, u32 negate, cha
915 v = vfp_get_float(sd); 915 v = vfp_get_float(sd);
916 pr_debug("VFP: s%u = %08x\n", sd, v); 916 pr_debug("VFP: s%u = %08x\n", sd, v);
917 vfp_single_unpack(&vsn, v); 917 vfp_single_unpack(&vsn, v);
918 if (vsn.exponent == 0 && vsn.significand)
919 vfp_single_normalise_denormal(&vsn);
918 if (negate & NEG_SUBTRACT) 920 if (negate & NEG_SUBTRACT)
919 vsn.sign = vfp_sign_negate(vsn.sign); 921 vsn.sign = vfp_sign_negate(vsn.sign);
920 922
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index e6e4d3749a6e..e759af5d7098 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -323,8 +323,6 @@ menu "CPU Power Management"
323 323
324source "drivers/cpuidle/Kconfig" 324source "drivers/cpuidle/Kconfig"
325 325
326source "kernel/power/Kconfig"
327
328source "drivers/cpufreq/Kconfig" 326source "drivers/cpufreq/Kconfig"
329 327
330endmenu 328endmenu
diff --git a/arch/arm64/boot/dts/apm-storm.dtsi b/arch/arm64/boot/dts/apm-storm.dtsi
index 93f4b2dd9248..f8c40a66e65d 100644
--- a/arch/arm64/boot/dts/apm-storm.dtsi
+++ b/arch/arm64/boot/dts/apm-storm.dtsi
@@ -307,6 +307,7 @@
307 <0x0 0x1f21e000 0x0 0x1000>, 307 <0x0 0x1f21e000 0x0 0x1000>,
308 <0x0 0x1f217000 0x0 0x1000>; 308 <0x0 0x1f217000 0x0 0x1000>;
309 interrupts = <0x0 0x86 0x4>; 309 interrupts = <0x0 0x86 0x4>;
310 dma-coherent;
310 status = "disabled"; 311 status = "disabled";
311 clocks = <&sata01clk 0>; 312 clocks = <&sata01clk 0>;
312 phys = <&phy1 0>; 313 phys = <&phy1 0>;
@@ -321,6 +322,7 @@
321 <0x0 0x1f22e000 0x0 0x1000>, 322 <0x0 0x1f22e000 0x0 0x1000>,
322 <0x0 0x1f227000 0x0 0x1000>; 323 <0x0 0x1f227000 0x0 0x1000>;
323 interrupts = <0x0 0x87 0x4>; 324 interrupts = <0x0 0x87 0x4>;
325 dma-coherent;
324 status = "ok"; 326 status = "ok";
325 clocks = <&sata23clk 0>; 327 clocks = <&sata23clk 0>;
326 phys = <&phy2 0>; 328 phys = <&phy2 0>;
@@ -334,6 +336,7 @@
334 <0x0 0x1f23d000 0x0 0x1000>, 336 <0x0 0x1f23d000 0x0 0x1000>,
335 <0x0 0x1f23e000 0x0 0x1000>; 337 <0x0 0x1f23e000 0x0 0x1000>;
336 interrupts = <0x0 0x88 0x4>; 338 interrupts = <0x0 0x88 0x4>;
339 dma-coherent;
337 status = "ok"; 340 status = "ok";
338 clocks = <&sata45clk 0>; 341 clocks = <&sata45clk 0>;
339 phys = <&phy3 0>; 342 phys = <&phy3 0>;
diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h
index f600d400c07d..aff0292c8f4d 100644
--- a/arch/arm64/include/asm/mmu.h
+++ b/arch/arm64/include/asm/mmu.h
@@ -22,6 +22,9 @@ typedef struct {
22 void *vdso; 22 void *vdso;
23} mm_context_t; 23} mm_context_t;
24 24
25#define INIT_MM_CONTEXT(name) \
26 .context.id_lock = __RAW_SPIN_LOCK_UNLOCKED(name.context.id_lock),
27
25#define ASID(mm) ((mm)->context.id & 0xffff) 28#define ASID(mm) ((mm)->context.id & 0xffff)
26 29
27extern void paging_init(void); 30extern void paging_init(void);
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 72cadf52ca80..80e2c08900d6 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -19,6 +19,7 @@
19#ifndef __ASM_TLB_H 19#ifndef __ASM_TLB_H
20#define __ASM_TLB_H 20#define __ASM_TLB_H
21 21
22#define __tlb_remove_pmd_tlb_entry __tlb_remove_pmd_tlb_entry
22 23
23#include <asm-generic/tlb.h> 24#include <asm-generic/tlb.h>
24 25
@@ -99,5 +100,10 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp,
99} 100}
100#endif 101#endif
101 102
103static inline void __tlb_remove_pmd_tlb_entry(struct mmu_gather *tlb, pmd_t *pmdp,
104 unsigned long address)
105{
106 tlb_add_flush(tlb, address);
107}
102 108
103#endif 109#endif
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index bb8eb8a78e67..c8d8fc17bd5a 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -403,8 +403,9 @@ __SYSCALL(378, sys_kcmp)
403__SYSCALL(379, sys_finit_module) 403__SYSCALL(379, sys_finit_module)
404__SYSCALL(380, sys_sched_setattr) 404__SYSCALL(380, sys_sched_setattr)
405__SYSCALL(381, sys_sched_getattr) 405__SYSCALL(381, sys_sched_getattr)
406__SYSCALL(382, sys_renameat2)
406 407
407#define __NR_compat_syscalls 379 408#define __NR_compat_syscalls 383
408 409
409/* 410/*
410 * Compat syscall numbers used by the AArch64 kernel. 411 * Compat syscall numbers used by the AArch64 kernel.
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index ed3955a95747..a7fb874b595e 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -318,9 +318,6 @@ static int brk_handler(unsigned long addr, unsigned int esr,
318 if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED) 318 if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
319 return 0; 319 return 0;
320 320
321 pr_warn("unexpected brk exception at %lx, esr=0x%x\n",
322 (long)instruction_pointer(regs), esr);
323
324 if (!user_mode(regs)) 321 if (!user_mode(regs))
325 return -EFAULT; 322 return -EFAULT;
326 323
diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c
index ffbbdde7aba1..2dc36d00addf 100644
--- a/arch/arm64/kernel/early_printk.c
+++ b/arch/arm64/kernel/early_printk.c
@@ -143,10 +143,8 @@ static int __init setup_early_printk(char *buf)
143 } 143 }
144 /* no options parsing yet */ 144 /* no options parsing yet */
145 145
146 if (paddr) { 146 if (paddr)
147 set_fixmap_io(FIX_EARLYCON_MEM_BASE, paddr); 147 early_base = (void __iomem *)set_fixmap_offset_io(FIX_EARLYCON_MEM_BASE, paddr);
148 early_base = (void __iomem *)fix_to_virt(FIX_EARLYCON_MEM_BASE);
149 }
150 148
151 printch = match->printch; 149 printch = match->printch;
152 early_console = &early_console_dev; 150 early_console = &early_console_dev;
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 720853f70b6b..7ec784653b29 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -393,11 +393,10 @@ void __init setup_arch(char **cmdline_p)
393 393
394static int __init arm64_device_init(void) 394static int __init arm64_device_init(void)
395{ 395{
396 of_clk_init(NULL);
397 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 396 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
398 return 0; 397 return 0;
399} 398}
400arch_initcall(arm64_device_init); 399arch_initcall_sync(arm64_device_init);
401 400
402static DEFINE_PER_CPU(struct cpu, cpu_data); 401static DEFINE_PER_CPU(struct cpu, cpu_data);
403 402
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index 29c39d5d77e3..6815987b50f8 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -33,6 +33,7 @@
33#include <linux/irq.h> 33#include <linux/irq.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/clocksource.h> 35#include <linux/clocksource.h>
36#include <linux/clk-provider.h>
36 37
37#include <clocksource/arm_arch_timer.h> 38#include <clocksource/arm_arch_timer.h>
38 39
@@ -65,6 +66,7 @@ void __init time_init(void)
65{ 66{
66 u32 arch_timer_rate; 67 u32 arch_timer_rate;
67 68
69 of_clk_init(NULL);
68 clocksource_of_init(); 70 clocksource_of_init();
69 71
70 arch_timer_rate = arch_timer_get_rate(); 72 arch_timer_rate = arch_timer_get_rate();
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 0ba347e59f06..c851eb44dc50 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -22,8 +22,11 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <linux/dma-contiguous.h> 24#include <linux/dma-contiguous.h>
25#include <linux/of.h>
26#include <linux/platform_device.h>
25#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
26#include <linux/swiotlb.h> 28#include <linux/swiotlb.h>
29#include <linux/amba/bus.h>
27 30
28#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
29 32
@@ -305,17 +308,45 @@ struct dma_map_ops coherent_swiotlb_dma_ops = {
305}; 308};
306EXPORT_SYMBOL(coherent_swiotlb_dma_ops); 309EXPORT_SYMBOL(coherent_swiotlb_dma_ops);
307 310
311static int dma_bus_notifier(struct notifier_block *nb,
312 unsigned long event, void *_dev)
313{
314 struct device *dev = _dev;
315
316 if (event != BUS_NOTIFY_ADD_DEVICE)
317 return NOTIFY_DONE;
318
319 if (of_property_read_bool(dev->of_node, "dma-coherent"))
320 set_dma_ops(dev, &coherent_swiotlb_dma_ops);
321
322 return NOTIFY_OK;
323}
324
325static struct notifier_block platform_bus_nb = {
326 .notifier_call = dma_bus_notifier,
327};
328
329static struct notifier_block amba_bus_nb = {
330 .notifier_call = dma_bus_notifier,
331};
332
308extern int swiotlb_late_init_with_default_size(size_t default_size); 333extern int swiotlb_late_init_with_default_size(size_t default_size);
309 334
310static int __init swiotlb_late_init(void) 335static int __init swiotlb_late_init(void)
311{ 336{
312 size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT); 337 size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT);
313 338
314 dma_ops = &coherent_swiotlb_dma_ops; 339 /*
340 * These must be registered before of_platform_populate().
341 */
342 bus_register_notifier(&platform_bus_type, &platform_bus_nb);
343 bus_register_notifier(&amba_bustype, &amba_bus_nb);
344
345 dma_ops = &noncoherent_swiotlb_dma_ops;
315 346
316 return swiotlb_late_init_with_default_size(swiotlb_size); 347 return swiotlb_late_init_with_default_size(swiotlb_size);
317} 348}
318subsys_initcall(swiotlb_late_init); 349arch_initcall(swiotlb_late_init);
319 350
320#define PREALLOC_DMA_DEBUG_ENTRIES 4096 351#define PREALLOC_DMA_DEBUG_ENTRIES 4096
321 352
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 6b7e89569a3a..0a472c41a67f 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -374,6 +374,9 @@ int kern_addr_valid(unsigned long addr)
374 if (pmd_none(*pmd)) 374 if (pmd_none(*pmd))
375 return 0; 375 return 0;
376 376
377 if (pmd_sect(*pmd))
378 return pfn_valid(pmd_pfn(*pmd));
379
377 pte = pte_offset_kernel(pmd, addr); 380 pte = pte_offset_kernel(pmd, addr);
378 if (pte_none(*pte)) 381 if (pte_none(*pte))
379 return 0; 382 return 0;
diff --git a/arch/hexagon/include/asm/barrier.h b/arch/hexagon/include/asm/barrier.h
deleted file mode 100644
index 4e863daea25b..000000000000
--- a/arch/hexagon/include/asm/barrier.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Memory barrier definitions for the Hexagon architecture
3 *
4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#ifndef _ASM_BARRIER_H
22#define _ASM_BARRIER_H
23
24#define rmb() barrier()
25#define read_barrier_depends() barrier()
26#define wmb() barrier()
27#define mb() barrier()
28#define smp_rmb() barrier()
29#define smp_read_barrier_depends() barrier()
30#define smp_wmb() barrier()
31#define smp_mb() barrier()
32
33/* Set a value and use a memory barrier. Used by the scheduler somewhere. */
34#define set_mb(var, value) \
35 do { var = value; mb(); } while (0)
36
37#endif /* _ASM_BARRIER_H */
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
index bc5efc7c3f3f..39d64e0df1de 100644
--- a/arch/ia64/include/asm/tlb.h
+++ b/arch/ia64/include/asm/tlb.h
@@ -91,18 +91,9 @@ extern struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
91#define RR_RID_MASK 0x00000000ffffff00L 91#define RR_RID_MASK 0x00000000ffffff00L
92#define RR_TO_RID(val) ((val >> 8) & 0xffffff) 92#define RR_TO_RID(val) ((val >> 8) & 0xffffff)
93 93
94/*
95 * Flush the TLB for address range START to END and, if not in fast mode, release the
96 * freed pages that where gathered up to this point.
97 */
98static inline void 94static inline void
99ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end) 95ia64_tlb_flush_mmu_tlbonly(struct mmu_gather *tlb, unsigned long start, unsigned long end)
100{ 96{
101 unsigned long i;
102 unsigned int nr;
103
104 if (!tlb->need_flush)
105 return;
106 tlb->need_flush = 0; 97 tlb->need_flush = 0;
107 98
108 if (tlb->fullmm) { 99 if (tlb->fullmm) {
@@ -135,6 +126,14 @@ ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long e
135 flush_tlb_range(&vma, ia64_thash(start), ia64_thash(end)); 126 flush_tlb_range(&vma, ia64_thash(start), ia64_thash(end));
136 } 127 }
137 128
129}
130
131static inline void
132ia64_tlb_flush_mmu_free(struct mmu_gather *tlb)
133{
134 unsigned long i;
135 unsigned int nr;
136
138 /* lastly, release the freed pages */ 137 /* lastly, release the freed pages */
139 nr = tlb->nr; 138 nr = tlb->nr;
140 139
@@ -144,6 +143,19 @@ ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long e
144 free_page_and_swap_cache(tlb->pages[i]); 143 free_page_and_swap_cache(tlb->pages[i]);
145} 144}
146 145
146/*
147 * Flush the TLB for address range START to END and, if not in fast mode, release the
148 * freed pages that where gathered up to this point.
149 */
150static inline void
151ia64_tlb_flush_mmu (struct mmu_gather *tlb, unsigned long start, unsigned long end)
152{
153 if (!tlb->need_flush)
154 return;
155 ia64_tlb_flush_mmu_tlbonly(tlb, start, end);
156 ia64_tlb_flush_mmu_free(tlb);
157}
158
147static inline void __tlb_alloc_page(struct mmu_gather *tlb) 159static inline void __tlb_alloc_page(struct mmu_gather *tlb)
148{ 160{
149 unsigned long addr = __get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0); 161 unsigned long addr = __get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
@@ -206,6 +218,16 @@ static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page)
206 return tlb->max - tlb->nr; 218 return tlb->max - tlb->nr;
207} 219}
208 220
221static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
222{
223 ia64_tlb_flush_mmu_tlbonly(tlb, tlb->start_addr, tlb->end_addr);
224}
225
226static inline void tlb_flush_mmu_free(struct mmu_gather *tlb)
227{
228 ia64_tlb_flush_mmu_free(tlb);
229}
230
209static inline void tlb_flush_mmu(struct mmu_gather *tlb) 231static inline void tlb_flush_mmu(struct mmu_gather *tlb)
210{ 232{
211 ia64_tlb_flush_mmu(tlb, tlb->start_addr, tlb->end_addr); 233 ia64_tlb_flush_mmu(tlb, tlb->start_addr, tlb->end_addr);
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index c2bb4f896ce7..3aa5b46b2d40 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -635,7 +635,7 @@ static void octeon_irq_cpu_offline_ciu(struct irq_data *data)
635 cpumask_clear(&new_affinity); 635 cpumask_clear(&new_affinity);
636 cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity); 636 cpumask_set_cpu(cpumask_first(cpu_online_mask), &new_affinity);
637 } 637 }
638 __irq_set_affinity_locked(data, &new_affinity); 638 irq_set_affinity_locked(data, &new_affinity, false);
639} 639}
640 640
641static int octeon_irq_ciu_set_affinity(struct irq_data *data, 641static int octeon_irq_ciu_set_affinity(struct irq_data *data,
diff --git a/arch/parisc/include/uapi/asm/Kbuild b/arch/parisc/include/uapi/asm/Kbuild
index a580642555b6..348356c99514 100644
--- a/arch/parisc/include/uapi/asm/Kbuild
+++ b/arch/parisc/include/uapi/asm/Kbuild
@@ -1,6 +1,8 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4generic-y += resource.h
5
4header-y += bitsperlong.h 6header-y += bitsperlong.h
5header-y += byteorder.h 7header-y += byteorder.h
6header-y += errno.h 8header-y += errno.h
@@ -13,7 +15,6 @@ header-y += msgbuf.h
13header-y += pdc.h 15header-y += pdc.h
14header-y += posix_types.h 16header-y += posix_types.h
15header-y += ptrace.h 17header-y += ptrace.h
16header-y += resource.h
17header-y += sembuf.h 18header-y += sembuf.h
18header-y += setup.h 19header-y += setup.h
19header-y += shmbuf.h 20header-y += shmbuf.h
diff --git a/arch/parisc/include/uapi/asm/resource.h b/arch/parisc/include/uapi/asm/resource.h
deleted file mode 100644
index 8b06343b62ed..000000000000
--- a/arch/parisc/include/uapi/asm/resource.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _ASM_PARISC_RESOURCE_H
2#define _ASM_PARISC_RESOURCE_H
3
4#define _STK_LIM_MAX 10 * _STK_LIM
5#include <asm-generic/resource.h>
6
7#endif
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index a28f02165e97..d367a0aece2a 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -139,18 +139,18 @@ static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen,
139 * edit the command line passed to vmlinux (by setting /chosen/bootargs). 139 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
140 * The buffer is put in it's own section so that tools may locate it easier. 140 * The buffer is put in it's own section so that tools may locate it easier.
141 */ 141 */
142static char cmdline[COMMAND_LINE_SIZE] 142static char cmdline[BOOT_COMMAND_LINE_SIZE]
143 __attribute__((__section__("__builtin_cmdline"))); 143 __attribute__((__section__("__builtin_cmdline")));
144 144
145static void prep_cmdline(void *chosen) 145static void prep_cmdline(void *chosen)
146{ 146{
147 if (cmdline[0] == '\0') 147 if (cmdline[0] == '\0')
148 getprop(chosen, "bootargs", cmdline, COMMAND_LINE_SIZE-1); 148 getprop(chosen, "bootargs", cmdline, BOOT_COMMAND_LINE_SIZE-1);
149 149
150 printf("\n\rLinux/PowerPC load: %s", cmdline); 150 printf("\n\rLinux/PowerPC load: %s", cmdline);
151 /* If possible, edit the command line */ 151 /* If possible, edit the command line */
152 if (console_ops.edit_cmdline) 152 if (console_ops.edit_cmdline)
153 console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE); 153 console_ops.edit_cmdline(cmdline, BOOT_COMMAND_LINE_SIZE);
154 printf("\n\r"); 154 printf("\n\r");
155 155
156 /* Put the command line back into the devtree for the kernel */ 156 /* Put the command line back into the devtree for the kernel */
@@ -174,7 +174,7 @@ void start(void)
174 * built-in command line wasn't set by an external tool */ 174 * built-in command line wasn't set by an external tool */
175 if ((loader_info.cmdline_len > 0) && (cmdline[0] == '\0')) 175 if ((loader_info.cmdline_len > 0) && (cmdline[0] == '\0'))
176 memmove(cmdline, loader_info.cmdline, 176 memmove(cmdline, loader_info.cmdline,
177 min(loader_info.cmdline_len, COMMAND_LINE_SIZE-1)); 177 min(loader_info.cmdline_len, BOOT_COMMAND_LINE_SIZE-1));
178 178
179 if (console_ops.open && (console_ops.open() < 0)) 179 if (console_ops.open && (console_ops.open() < 0))
180 exit(); 180 exit();
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index b3218ce451bb..8aad3c55aeda 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -15,7 +15,7 @@
15#include "types.h" 15#include "types.h"
16#include "string.h" 16#include "string.h"
17 17
18#define COMMAND_LINE_SIZE 512 18#define BOOT_COMMAND_LINE_SIZE 2048
19#define MAX_PATH_LEN 256 19#define MAX_PATH_LEN 256
20#define MAX_PROP_LEN 256 /* What should this be? */ 20#define MAX_PROP_LEN 256 /* What should this be? */
21 21
diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c
index 9954d98871d0..4ec2d86d3c50 100644
--- a/arch/powerpc/boot/ps3.c
+++ b/arch/powerpc/boot/ps3.c
@@ -47,13 +47,13 @@ BSS_STACK(4096);
47 * The buffer is put in it's own section so that tools may locate it easier. 47 * The buffer is put in it's own section so that tools may locate it easier.
48 */ 48 */
49 49
50static char cmdline[COMMAND_LINE_SIZE] 50static char cmdline[BOOT_COMMAND_LINE_SIZE]
51 __attribute__((__section__("__builtin_cmdline"))); 51 __attribute__((__section__("__builtin_cmdline")));
52 52
53static void prep_cmdline(void *chosen) 53static void prep_cmdline(void *chosen)
54{ 54{
55 if (cmdline[0] == '\0') 55 if (cmdline[0] == '\0')
56 getprop(chosen, "bootargs", cmdline, COMMAND_LINE_SIZE-1); 56 getprop(chosen, "bootargs", cmdline, BOOT_COMMAND_LINE_SIZE-1);
57 else 57 else
58 setprop_str(chosen, "bootargs", cmdline); 58 setprop_str(chosen, "bootargs", cmdline);
59 59
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index a2efdaa020b0..66ad7a74116f 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -41,14 +41,14 @@ struct opal_takeover_args {
41 * size except the last one in the list to be as well. 41 * size except the last one in the list to be as well.
42 */ 42 */
43struct opal_sg_entry { 43struct opal_sg_entry {
44 void *data; 44 __be64 data;
45 long length; 45 __be64 length;
46}; 46};
47 47
48/* sg list */ 48/* SG list */
49struct opal_sg_list { 49struct opal_sg_list {
50 unsigned long num_entries; 50 __be64 length;
51 struct opal_sg_list *next; 51 __be64 next;
52 struct opal_sg_entry entry[]; 52 struct opal_sg_entry entry[];
53}; 53};
54 54
@@ -858,8 +858,8 @@ int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
858int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, 858int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
859 uint32_t addr, __be32 *data, uint32_t sz); 859 uint32_t addr, __be32 *data, uint32_t sz);
860 860
861int64_t opal_read_elog(uint64_t buffer, size_t size, uint64_t log_id); 861int64_t opal_read_elog(uint64_t buffer, uint64_t size, uint64_t log_id);
862int64_t opal_get_elog_size(uint64_t *log_id, size_t *size, uint64_t *elog_type); 862int64_t opal_get_elog_size(__be64 *log_id, __be64 *size, __be64 *elog_type);
863int64_t opal_write_elog(uint64_t buffer, uint64_t size, uint64_t offset); 863int64_t opal_write_elog(uint64_t buffer, uint64_t size, uint64_t offset);
864int64_t opal_send_ack_elog(uint64_t log_id); 864int64_t opal_send_ack_elog(uint64_t log_id);
865void opal_resend_pending_logs(void); 865void opal_resend_pending_logs(void);
@@ -868,23 +868,24 @@ int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result);
868int64_t opal_manage_flash(uint8_t op); 868int64_t opal_manage_flash(uint8_t op);
869int64_t opal_update_flash(uint64_t blk_list); 869int64_t opal_update_flash(uint64_t blk_list);
870int64_t opal_dump_init(uint8_t dump_type); 870int64_t opal_dump_init(uint8_t dump_type);
871int64_t opal_dump_info(uint32_t *dump_id, uint32_t *dump_size); 871int64_t opal_dump_info(__be32 *dump_id, __be32 *dump_size);
872int64_t opal_dump_info2(uint32_t *dump_id, uint32_t *dump_size, uint32_t *dump_type); 872int64_t opal_dump_info2(__be32 *dump_id, __be32 *dump_size, __be32 *dump_type);
873int64_t opal_dump_read(uint32_t dump_id, uint64_t buffer); 873int64_t opal_dump_read(uint32_t dump_id, uint64_t buffer);
874int64_t opal_dump_ack(uint32_t dump_id); 874int64_t opal_dump_ack(uint32_t dump_id);
875int64_t opal_dump_resend_notification(void); 875int64_t opal_dump_resend_notification(void);
876 876
877int64_t opal_get_msg(uint64_t buffer, size_t size); 877int64_t opal_get_msg(uint64_t buffer, uint64_t size);
878int64_t opal_check_completion(uint64_t buffer, size_t size, uint64_t token); 878int64_t opal_check_completion(uint64_t buffer, uint64_t size, uint64_t token);
879int64_t opal_sync_host_reboot(void); 879int64_t opal_sync_host_reboot(void);
880int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer, 880int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer,
881 size_t length); 881 uint64_t length);
882int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer, 882int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer,
883 size_t length); 883 uint64_t length);
884int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data); 884int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);
885 885
886/* Internal functions */ 886/* Internal functions */
887extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); 887extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
888 int depth, void *data);
888extern int early_init_dt_scan_recoverable_ranges(unsigned long node, 889extern int early_init_dt_scan_recoverable_ranges(unsigned long node,
889 const char *uname, int depth, void *data); 890 const char *uname, int depth, void *data);
890 891
@@ -893,10 +894,6 @@ extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
893 894
894extern void hvc_opal_init_early(void); 895extern void hvc_opal_init_early(void);
895 896
896/* Internal functions */
897extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
898 int depth, void *data);
899
900extern int opal_notifier_register(struct notifier_block *nb); 897extern int opal_notifier_register(struct notifier_block *nb);
901extern int opal_notifier_unregister(struct notifier_block *nb); 898extern int opal_notifier_unregister(struct notifier_block *nb);
902 899
@@ -906,9 +903,6 @@ extern void opal_notifier_enable(void);
906extern void opal_notifier_disable(void); 903extern void opal_notifier_disable(void);
907extern void opal_notifier_update_evt(uint64_t evt_mask, uint64_t evt_val); 904extern void opal_notifier_update_evt(uint64_t evt_mask, uint64_t evt_val);
908 905
909extern int opal_get_chars(uint32_t vtermno, char *buf, int count);
910extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
911
912extern int __opal_async_get_token(void); 906extern int __opal_async_get_token(void);
913extern int opal_async_get_token_interruptible(void); 907extern int opal_async_get_token_interruptible(void);
914extern int __opal_async_release_token(int token); 908extern int __opal_async_release_token(int token);
@@ -916,8 +910,6 @@ extern int opal_async_release_token(int token);
916extern int opal_async_wait_response(uint64_t token, struct opal_msg *msg); 910extern int opal_async_wait_response(uint64_t token, struct opal_msg *msg);
917extern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data); 911extern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data);
918 912
919extern void hvc_opal_init_early(void);
920
921struct rtc_time; 913struct rtc_time;
922extern int opal_set_rtc_time(struct rtc_time *tm); 914extern int opal_set_rtc_time(struct rtc_time *tm);
923extern void opal_get_rtc_time(struct rtc_time *tm); 915extern void opal_get_rtc_time(struct rtc_time *tm);
@@ -937,6 +929,10 @@ extern int opal_resync_timebase(void);
937 929
938extern void opal_lpc_init(void); 930extern void opal_lpc_init(void);
939 931
932struct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr,
933 unsigned long vmalloc_size);
934void opal_free_sg_list(struct opal_sg_list *sg);
935
940#endif /* __ASSEMBLY__ */ 936#endif /* __ASSEMBLY__ */
941 937
942#endif /* __OPAL_H */ 938#endif /* __OPAL_H */
diff --git a/arch/powerpc/include/uapi/asm/setup.h b/arch/powerpc/include/uapi/asm/setup.h
index 552df83f1a49..ae3fb68cb28e 100644
--- a/arch/powerpc/include/uapi/asm/setup.h
+++ b/arch/powerpc/include/uapi/asm/setup.h
@@ -1 +1,6 @@
1#include <asm-generic/setup.h> 1#ifndef _UAPI_ASM_POWERPC_SETUP_H
2#define _UAPI_ASM_POWERPC_SETUP_H
3
4#define COMMAND_LINE_SIZE 2048
5
6#endif /* _UAPI_ASM_POWERPC_SETUP_H */
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 3bd77edd7610..450850a49dce 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -120,6 +120,7 @@ EXPORT_SYMBOL(giveup_spe);
120EXPORT_SYMBOL(flush_instruction_cache); 120EXPORT_SYMBOL(flush_instruction_cache);
121#endif 121#endif
122EXPORT_SYMBOL(flush_dcache_range); 122EXPORT_SYMBOL(flush_dcache_range);
123EXPORT_SYMBOL(flush_icache_range);
123 124
124#ifdef CONFIG_SMP 125#ifdef CONFIG_SMP
125#ifdef CONFIG_PPC32 126#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 2f3cdb01506d..658e89d2025b 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -705,7 +705,7 @@ static int __init rtas_flash_init(void)
705 if (rtas_token("ibm,update-flash-64-and-reboot") == 705 if (rtas_token("ibm,update-flash-64-and-reboot") ==
706 RTAS_UNKNOWN_SERVICE) { 706 RTAS_UNKNOWN_SERVICE) {
707 pr_info("rtas_flash: no firmware flash support\n"); 707 pr_info("rtas_flash: no firmware flash support\n");
708 return 1; 708 return -EINVAL;
709 } 709 }
710 710
711 rtas_validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL); 711 rtas_validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL);
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index ffbb871c2bd8..b031f932c0cc 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -242,6 +242,12 @@ kvm_novcpu_exit:
242 */ 242 */
243 .globl kvm_start_guest 243 .globl kvm_start_guest
244kvm_start_guest: 244kvm_start_guest:
245
246 /* Set runlatch bit the minute you wake up from nap */
247 mfspr r1, SPRN_CTRLF
248 ori r1, r1, 1
249 mtspr SPRN_CTRLT, r1
250
245 ld r2,PACATOC(r13) 251 ld r2,PACATOC(r13)
246 252
247 li r0,KVM_HWTHREAD_IN_KVM 253 li r0,KVM_HWTHREAD_IN_KVM
@@ -309,6 +315,11 @@ kvm_no_guest:
309 li r0, KVM_HWTHREAD_IN_NAP 315 li r0, KVM_HWTHREAD_IN_NAP
310 stb r0, HSTATE_HWTHREAD_STATE(r13) 316 stb r0, HSTATE_HWTHREAD_STATE(r13)
311kvm_do_nap: 317kvm_do_nap:
318 /* Clear the runlatch bit before napping */
319 mfspr r2, SPRN_CTRLF
320 clrrdi r2, r2, 1
321 mtspr SPRN_CTRLT, r2
322
312 li r3, LPCR_PECE0 323 li r3, LPCR_PECE0
313 mfspr r4, SPRN_LPCR 324 mfspr r4, SPRN_LPCR
314 rlwimi r4, r3, 0, LPCR_PECE0 | LPCR_PECE1 325 rlwimi r4, r3, 0, LPCR_PECE0 | LPCR_PECE1
@@ -1999,8 +2010,13 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206)
1999 2010
2000 /* 2011 /*
2001 * Take a nap until a decrementer or external or doobell interrupt 2012 * Take a nap until a decrementer or external or doobell interrupt
2002 * occurs, with PECE1, PECE0 and PECEDP set in LPCR 2013 * occurs, with PECE1, PECE0 and PECEDP set in LPCR. Also clear the
2014 * runlatch bit before napping.
2003 */ 2015 */
2016 mfspr r2, SPRN_CTRLF
2017 clrrdi r2, r2, 1
2018 mtspr SPRN_CTRLT, r2
2019
2004 li r0,1 2020 li r0,1
2005 stb r0,HSTATE_HWTHREAD_REQ(r13) 2021 stb r0,HSTATE_HWTHREAD_REQ(r13)
2006 mfspr r5,SPRN_LPCR 2022 mfspr r5,SPRN_LPCR
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 3ea26c25590b..cf1d325eae8b 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -82,17 +82,14 @@ static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
82 va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1); 82 va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1);
83 va |= penc << 12; 83 va |= penc << 12;
84 va |= ssize << 8; 84 va |= ssize << 8;
85 /* Add AVAL part */ 85 /*
86 if (psize != apsize) { 86 * AVAL bits:
87 /* 87 * We don't need all the bits, but rest of the bits
88 * MPSS, 64K base page size and 16MB parge page size 88 * must be ignored by the processor.
89 * We don't need all the bits, but rest of the bits 89 * vpn cover upto 65 bits of va. (0...65) and we need
90 * must be ignored by the processor. 90 * 58..64 bits of va.
91 * vpn cover upto 65 bits of va. (0...65) and we need 91 */
92 * 58..64 bits of va. 92 va |= (vpn & 0xfe); /* AVAL */
93 */
94 va |= (vpn & 0xfe);
95 }
96 va |= 1; /* L */ 93 va |= 1; /* L */
97 asm volatile(ASM_FTR_IFCLR("tlbie %0,1", PPC_TLBIE(%1,%0), %2) 94 asm volatile(ASM_FTR_IFCLR("tlbie %0,1", PPC_TLBIE(%1,%0), %2)
98 : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206) 95 : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206)
@@ -133,17 +130,14 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
133 va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1); 130 va &= ~((1ul << mmu_psize_defs[apsize].shift) - 1);
134 va |= penc << 12; 131 va |= penc << 12;
135 va |= ssize << 8; 132 va |= ssize << 8;
136 /* Add AVAL part */ 133 /*
137 if (psize != apsize) { 134 * AVAL bits:
138 /* 135 * We don't need all the bits, but rest of the bits
139 * MPSS, 64K base page size and 16MB parge page size 136 * must be ignored by the processor.
140 * We don't need all the bits, but rest of the bits 137 * vpn cover upto 65 bits of va. (0...65) and we need
141 * must be ignored by the processor. 138 * 58..64 bits of va.
142 * vpn cover upto 65 bits of va. (0...65) and we need 139 */
143 * 58..64 bits of va. 140 va |= (vpn & 0xfe);
144 */
145 va |= (vpn & 0xfe);
146 }
147 va |= 1; /* L */ 141 va |= 1; /* L */
148 asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)" 142 asm volatile(".long 0x7c000224 | (%0 << 11) | (1 << 21)"
149 : : "r"(va) : "memory"); 143 : : "r"(va) : "memory");
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 297c91051413..e0766b82e165 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -155,16 +155,28 @@ static ssize_t read_offset_data(void *dest, size_t dest_len,
155 return copy_len; 155 return copy_len;
156} 156}
157 157
158static unsigned long h_get_24x7_catalog_page(char page[static 4096], 158static unsigned long h_get_24x7_catalog_page_(unsigned long phys_4096,
159 u32 version, u32 index) 159 unsigned long version,
160 unsigned long index)
160{ 161{
161 WARN_ON(!IS_ALIGNED((unsigned long)page, 4096)); 162 pr_devel("h_get_24x7_catalog_page(0x%lx, %lu, %lu)",
163 phys_4096,
164 version,
165 index);
166 WARN_ON(!IS_ALIGNED(phys_4096, 4096));
162 return plpar_hcall_norets(H_GET_24X7_CATALOG_PAGE, 167 return plpar_hcall_norets(H_GET_24X7_CATALOG_PAGE,
163 virt_to_phys(page), 168 phys_4096,
164 version, 169 version,
165 index); 170 index);
166} 171}
167 172
173static unsigned long h_get_24x7_catalog_page(char page[],
174 u64 version, u32 index)
175{
176 return h_get_24x7_catalog_page_(virt_to_phys(page),
177 version, index);
178}
179
168static ssize_t catalog_read(struct file *filp, struct kobject *kobj, 180static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
169 struct bin_attribute *bin_attr, char *buf, 181 struct bin_attribute *bin_attr, char *buf,
170 loff_t offset, size_t count) 182 loff_t offset, size_t count)
@@ -173,7 +185,7 @@ static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
173 ssize_t ret = 0; 185 ssize_t ret = 0;
174 size_t catalog_len = 0, catalog_page_len = 0, page_count = 0; 186 size_t catalog_len = 0, catalog_page_len = 0, page_count = 0;
175 loff_t page_offset = 0; 187 loff_t page_offset = 0;
176 uint32_t catalog_version_num = 0; 188 uint64_t catalog_version_num = 0;
177 void *page = kmem_cache_alloc(hv_page_cache, GFP_USER); 189 void *page = kmem_cache_alloc(hv_page_cache, GFP_USER);
178 struct hv_24x7_catalog_page_0 *page_0 = page; 190 struct hv_24x7_catalog_page_0 *page_0 = page;
179 if (!page) 191 if (!page)
@@ -185,7 +197,7 @@ static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
185 goto e_free; 197 goto e_free;
186 } 198 }
187 199
188 catalog_version_num = be32_to_cpu(page_0->version); 200 catalog_version_num = be64_to_cpu(page_0->version);
189 catalog_page_len = be32_to_cpu(page_0->length); 201 catalog_page_len = be32_to_cpu(page_0->length);
190 catalog_len = catalog_page_len * 4096; 202 catalog_len = catalog_page_len * 4096;
191 203
@@ -208,8 +220,9 @@ static ssize_t catalog_read(struct file *filp, struct kobject *kobj,
208 page, 4096, page_offset * 4096); 220 page, 4096, page_offset * 4096);
209e_free: 221e_free:
210 if (hret) 222 if (hret)
211 pr_err("h_get_24x7_catalog_page(ver=%d, page=%lld) failed: rc=%ld\n", 223 pr_err("h_get_24x7_catalog_page(ver=%lld, page=%lld) failed:"
212 catalog_version_num, page_offset, hret); 224 " rc=%ld\n",
225 catalog_version_num, page_offset, hret);
213 kfree(page); 226 kfree(page);
214 227
215 pr_devel("catalog_read: offset=%lld(%lld) count=%zu(%zu) catalog_len=%zu(%zu) => %zd\n", 228 pr_devel("catalog_read: offset=%lld(%lld) count=%zu(%zu) catalog_len=%zu(%zu) => %zd\n",
@@ -243,7 +256,7 @@ e_free: \
243static DEVICE_ATTR_RO(_name) 256static DEVICE_ATTR_RO(_name)
244 257
245PAGE_0_ATTR(catalog_version, "%lld\n", 258PAGE_0_ATTR(catalog_version, "%lld\n",
246 (unsigned long long)be32_to_cpu(page_0->version)); 259 (unsigned long long)be64_to_cpu(page_0->version));
247PAGE_0_ATTR(catalog_len, "%lld\n", 260PAGE_0_ATTR(catalog_len, "%lld\n",
248 (unsigned long long)be32_to_cpu(page_0->length) * 4096); 261 (unsigned long long)be32_to_cpu(page_0->length) * 4096);
249static BIN_ATTR_RO(catalog, 0/* real length varies */); 262static BIN_ATTR_RO(catalog, 0/* real length varies */);
@@ -485,13 +498,13 @@ static int hv_24x7_init(void)
485 struct hv_perf_caps caps; 498 struct hv_perf_caps caps;
486 499
487 if (!firmware_has_feature(FW_FEATURE_LPAR)) { 500 if (!firmware_has_feature(FW_FEATURE_LPAR)) {
488 pr_info("not a virtualized system, not enabling\n"); 501 pr_debug("not a virtualized system, not enabling\n");
489 return -ENODEV; 502 return -ENODEV;
490 } 503 }
491 504
492 hret = hv_perf_caps_get(&caps); 505 hret = hv_perf_caps_get(&caps);
493 if (hret) { 506 if (hret) {
494 pr_info("could not obtain capabilities, error 0x%80lx, not enabling\n", 507 pr_debug("could not obtain capabilities, not enabling, rc=%ld\n",
495 hret); 508 hret);
496 return -ENODEV; 509 return -ENODEV;
497 } 510 }
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 278ba7b9c2b5..c9d399a2df82 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -78,7 +78,7 @@ static ssize_t kernel_version_show(struct device *dev,
78 return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT); 78 return sprintf(page, "0x%x\n", COUNTER_INFO_VERSION_CURRENT);
79} 79}
80 80
81DEVICE_ATTR_RO(kernel_version); 81static DEVICE_ATTR_RO(kernel_version);
82HV_CAPS_ATTR(version, "0x%x\n"); 82HV_CAPS_ATTR(version, "0x%x\n");
83HV_CAPS_ATTR(ga, "%d\n"); 83HV_CAPS_ATTR(ga, "%d\n");
84HV_CAPS_ATTR(expanded, "%d\n"); 84HV_CAPS_ATTR(expanded, "%d\n");
@@ -273,13 +273,13 @@ static int hv_gpci_init(void)
273 struct hv_perf_caps caps; 273 struct hv_perf_caps caps;
274 274
275 if (!firmware_has_feature(FW_FEATURE_LPAR)) { 275 if (!firmware_has_feature(FW_FEATURE_LPAR)) {
276 pr_info("not a virtualized system, not enabling\n"); 276 pr_debug("not a virtualized system, not enabling\n");
277 return -ENODEV; 277 return -ENODEV;
278 } 278 }
279 279
280 hret = hv_perf_caps_get(&caps); 280 hret = hv_perf_caps_get(&caps);
281 if (hret) { 281 if (hret) {
282 pr_info("could not obtain capabilities, error 0x%80lx, not enabling\n", 282 pr_debug("could not obtain capabilities, not enabling, rc=%ld\n",
283 hret); 283 hret);
284 return -ENODEV; 284 return -ENODEV;
285 } 285 }
diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
index b9827b0d87e4..788a1977b9a5 100644
--- a/arch/powerpc/platforms/powernv/opal-dump.c
+++ b/arch/powerpc/platforms/powernv/opal-dump.c
@@ -209,89 +209,20 @@ static struct kobj_type dump_ktype = {
209 .default_attrs = dump_default_attrs, 209 .default_attrs = dump_default_attrs,
210}; 210};
211 211
212static void free_dump_sg_list(struct opal_sg_list *list) 212static int64_t dump_read_info(uint32_t *dump_id, uint32_t *dump_size, uint32_t *dump_type)
213{
214 struct opal_sg_list *sg1;
215 while (list) {
216 sg1 = list->next;
217 kfree(list);
218 list = sg1;
219 }
220 list = NULL;
221}
222
223static struct opal_sg_list *dump_data_to_sglist(struct dump_obj *dump)
224{
225 struct opal_sg_list *sg1, *list = NULL;
226 void *addr;
227 int64_t size;
228
229 addr = dump->buffer;
230 size = dump->size;
231
232 sg1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
233 if (!sg1)
234 goto nomem;
235
236 list = sg1;
237 sg1->num_entries = 0;
238 while (size > 0) {
239 /* Translate virtual address to physical address */
240 sg1->entry[sg1->num_entries].data =
241 (void *)(vmalloc_to_pfn(addr) << PAGE_SHIFT);
242
243 if (size > PAGE_SIZE)
244 sg1->entry[sg1->num_entries].length = PAGE_SIZE;
245 else
246 sg1->entry[sg1->num_entries].length = size;
247
248 sg1->num_entries++;
249 if (sg1->num_entries >= SG_ENTRIES_PER_NODE) {
250 sg1->next = kzalloc(PAGE_SIZE, GFP_KERNEL);
251 if (!sg1->next)
252 goto nomem;
253
254 sg1 = sg1->next;
255 sg1->num_entries = 0;
256 }
257 addr += PAGE_SIZE;
258 size -= PAGE_SIZE;
259 }
260 return list;
261
262nomem:
263 pr_err("%s : Failed to allocate memory\n", __func__);
264 free_dump_sg_list(list);
265 return NULL;
266}
267
268static void sglist_to_phy_addr(struct opal_sg_list *list)
269{
270 struct opal_sg_list *sg, *next;
271
272 for (sg = list; sg; sg = next) {
273 next = sg->next;
274 /* Don't translate NULL pointer for last entry */
275 if (sg->next)
276 sg->next = (struct opal_sg_list *)__pa(sg->next);
277 else
278 sg->next = NULL;
279
280 /* Convert num_entries to length */
281 sg->num_entries =
282 sg->num_entries * sizeof(struct opal_sg_entry) + 16;
283 }
284}
285
286static int64_t dump_read_info(uint32_t *id, uint32_t *size, uint32_t *type)
287{ 213{
214 __be32 id, size, type;
288 int rc; 215 int rc;
289 *type = 0xffffffff;
290 216
291 rc = opal_dump_info2(id, size, type); 217 type = cpu_to_be32(0xffffffff);
292 218
219 rc = opal_dump_info2(&id, &size, &type);
293 if (rc == OPAL_PARAMETER) 220 if (rc == OPAL_PARAMETER)
294 rc = opal_dump_info(id, size); 221 rc = opal_dump_info(&id, &size);
222
223 *dump_id = be32_to_cpu(id);
224 *dump_size = be32_to_cpu(size);
225 *dump_type = be32_to_cpu(type);
295 226
296 if (rc) 227 if (rc)
297 pr_warn("%s: Failed to get dump info (%d)\n", 228 pr_warn("%s: Failed to get dump info (%d)\n",
@@ -314,15 +245,12 @@ static int64_t dump_read_data(struct dump_obj *dump)
314 } 245 }
315 246
316 /* Generate SG list */ 247 /* Generate SG list */
317 list = dump_data_to_sglist(dump); 248 list = opal_vmalloc_to_sg_list(dump->buffer, dump->size);
318 if (!list) { 249 if (!list) {
319 rc = -ENOMEM; 250 rc = -ENOMEM;
320 goto out; 251 goto out;
321 } 252 }
322 253
323 /* Translate sg list addr to real address */
324 sglist_to_phy_addr(list);
325
326 /* First entry address */ 254 /* First entry address */
327 addr = __pa(list); 255 addr = __pa(list);
328 256
@@ -341,7 +269,7 @@ static int64_t dump_read_data(struct dump_obj *dump)
341 __func__, dump->id); 269 __func__, dump->id);
342 270
343 /* Free SG list */ 271 /* Free SG list */
344 free_dump_sg_list(list); 272 opal_free_sg_list(list);
345 273
346out: 274out:
347 return rc; 275 return rc;
diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
index ef7bc2a97862..10268c41d830 100644
--- a/arch/powerpc/platforms/powernv/opal-elog.c
+++ b/arch/powerpc/platforms/powernv/opal-elog.c
@@ -238,18 +238,25 @@ static struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type)
238 238
239static void elog_work_fn(struct work_struct *work) 239static void elog_work_fn(struct work_struct *work)
240{ 240{
241 size_t elog_size; 241 __be64 size;
242 __be64 id;
243 __be64 type;
244 uint64_t elog_size;
242 uint64_t log_id; 245 uint64_t log_id;
243 uint64_t elog_type; 246 uint64_t elog_type;
244 int rc; 247 int rc;
245 char name[2+16+1]; 248 char name[2+16+1];
246 249
247 rc = opal_get_elog_size(&log_id, &elog_size, &elog_type); 250 rc = opal_get_elog_size(&id, &size, &type);
248 if (rc != OPAL_SUCCESS) { 251 if (rc != OPAL_SUCCESS) {
249 pr_err("ELOG: Opal log read failed\n"); 252 pr_err("ELOG: Opal log read failed\n");
250 return; 253 return;
251 } 254 }
252 255
256 elog_size = be64_to_cpu(size);
257 log_id = be64_to_cpu(id);
258 elog_type = be64_to_cpu(type);
259
253 BUG_ON(elog_size > OPAL_MAX_ERRLOG_SIZE); 260 BUG_ON(elog_size > OPAL_MAX_ERRLOG_SIZE);
254 261
255 if (elog_size >= OPAL_MAX_ERRLOG_SIZE) 262 if (elog_size >= OPAL_MAX_ERRLOG_SIZE)
diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
index 714ef972406b..dc487ff04704 100644
--- a/arch/powerpc/platforms/powernv/opal-flash.c
+++ b/arch/powerpc/platforms/powernv/opal-flash.c
@@ -79,9 +79,6 @@
79/* XXX: Assume candidate image size is <= 1GB */ 79/* XXX: Assume candidate image size is <= 1GB */
80#define MAX_IMAGE_SIZE 0x40000000 80#define MAX_IMAGE_SIZE 0x40000000
81 81
82/* Flash sg list version */
83#define SG_LIST_VERSION (1UL)
84
85/* Image status */ 82/* Image status */
86enum { 83enum {
87 IMAGE_INVALID, 84 IMAGE_INVALID,
@@ -131,11 +128,15 @@ static DEFINE_MUTEX(image_data_mutex);
131 */ 128 */
132static inline void opal_flash_validate(void) 129static inline void opal_flash_validate(void)
133{ 130{
134 struct validate_flash_t *args_buf = &validate_flash_data; 131 long ret;
132 void *buf = validate_flash_data.buf;
133 __be32 size, result;
135 134
136 args_buf->status = opal_validate_flash(__pa(args_buf->buf), 135 ret = opal_validate_flash(__pa(buf), &size, &result);
137 &(args_buf->buf_size), 136
138 &(args_buf->result)); 137 validate_flash_data.status = ret;
138 validate_flash_data.buf_size = be32_to_cpu(size);
139 validate_flash_data.result = be32_to_cpu(result);
139} 140}
140 141
141/* 142/*
@@ -268,93 +269,11 @@ static ssize_t manage_store(struct kobject *kobj,
268} 269}
269 270
270/* 271/*
271 * Free sg list
272 */
273static void free_sg_list(struct opal_sg_list *list)
274{
275 struct opal_sg_list *sg1;
276 while (list) {
277 sg1 = list->next;
278 kfree(list);
279 list = sg1;
280 }
281 list = NULL;
282}
283
284/*
285 * Build candidate image scatter gather list
286 *
287 * list format:
288 * -----------------------------------
289 * | VER (8) | Entry length in bytes |
290 * -----------------------------------
291 * | Pointer to next entry |
292 * -----------------------------------
293 * | Address of memory area 1 |
294 * -----------------------------------
295 * | Length of memory area 1 |
296 * -----------------------------------
297 * | ......... |
298 * -----------------------------------
299 * | ......... |
300 * -----------------------------------
301 * | Address of memory area N |
302 * -----------------------------------
303 * | Length of memory area N |
304 * -----------------------------------
305 */
306static struct opal_sg_list *image_data_to_sglist(void)
307{
308 struct opal_sg_list *sg1, *list = NULL;
309 void *addr;
310 int size;
311
312 addr = image_data.data;
313 size = image_data.size;
314
315 sg1 = kzalloc(PAGE_SIZE, GFP_KERNEL);
316 if (!sg1)
317 return NULL;
318
319 list = sg1;
320 sg1->num_entries = 0;
321 while (size > 0) {
322 /* Translate virtual address to physical address */
323 sg1->entry[sg1->num_entries].data =
324 (void *)(vmalloc_to_pfn(addr) << PAGE_SHIFT);
325
326 if (size > PAGE_SIZE)
327 sg1->entry[sg1->num_entries].length = PAGE_SIZE;
328 else
329 sg1->entry[sg1->num_entries].length = size;
330
331 sg1->num_entries++;
332 if (sg1->num_entries >= SG_ENTRIES_PER_NODE) {
333 sg1->next = kzalloc(PAGE_SIZE, GFP_KERNEL);
334 if (!sg1->next) {
335 pr_err("%s : Failed to allocate memory\n",
336 __func__);
337 goto nomem;
338 }
339
340 sg1 = sg1->next;
341 sg1->num_entries = 0;
342 }
343 addr += PAGE_SIZE;
344 size -= PAGE_SIZE;
345 }
346 return list;
347nomem:
348 free_sg_list(list);
349 return NULL;
350}
351
352/*
353 * OPAL update flash 272 * OPAL update flash
354 */ 273 */
355static int opal_flash_update(int op) 274static int opal_flash_update(int op)
356{ 275{
357 struct opal_sg_list *sg, *list, *next; 276 struct opal_sg_list *list;
358 unsigned long addr; 277 unsigned long addr;
359 int64_t rc = OPAL_PARAMETER; 278 int64_t rc = OPAL_PARAMETER;
360 279
@@ -364,30 +283,13 @@ static int opal_flash_update(int op)
364 goto flash; 283 goto flash;
365 } 284 }
366 285
367 list = image_data_to_sglist(); 286 list = opal_vmalloc_to_sg_list(image_data.data, image_data.size);
368 if (!list) 287 if (!list)
369 goto invalid_img; 288 goto invalid_img;
370 289
371 /* First entry address */ 290 /* First entry address */
372 addr = __pa(list); 291 addr = __pa(list);
373 292
374 /* Translate sg list address to absolute */
375 for (sg = list; sg; sg = next) {
376 next = sg->next;
377 /* Don't translate NULL pointer for last entry */
378 if (sg->next)
379 sg->next = (struct opal_sg_list *)__pa(sg->next);
380 else
381 sg->next = NULL;
382
383 /*
384 * Convert num_entries to version/length format
385 * to satisfy OPAL.
386 */
387 sg->num_entries = (SG_LIST_VERSION << 56) |
388 (sg->num_entries * sizeof(struct opal_sg_entry) + 16);
389 }
390
391 pr_alert("FLASH: Image is %u bytes\n", image_data.size); 293 pr_alert("FLASH: Image is %u bytes\n", image_data.size);
392 pr_alert("FLASH: Image update requested\n"); 294 pr_alert("FLASH: Image update requested\n");
393 pr_alert("FLASH: Image will be updated during system reboot\n"); 295 pr_alert("FLASH: Image will be updated during system reboot\n");
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 6b614726baf2..d202f9bc3683 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -39,10 +39,11 @@ struct param_attr {
39 struct kobj_attribute kobj_attr; 39 struct kobj_attribute kobj_attr;
40}; 40};
41 41
42static int opal_get_sys_param(u32 param_id, u32 length, void *buffer) 42static ssize_t opal_get_sys_param(u32 param_id, u32 length, void *buffer)
43{ 43{
44 struct opal_msg msg; 44 struct opal_msg msg;
45 int ret, token; 45 ssize_t ret;
46 int token;
46 47
47 token = opal_async_get_token_interruptible(); 48 token = opal_async_get_token_interruptible();
48 if (token < 0) { 49 if (token < 0) {
@@ -59,7 +60,7 @@ static int opal_get_sys_param(u32 param_id, u32 length, void *buffer)
59 60
60 ret = opal_async_wait_response(token, &msg); 61 ret = opal_async_wait_response(token, &msg);
61 if (ret) { 62 if (ret) {
62 pr_err("%s: Failed to wait for the async response, %d\n", 63 pr_err("%s: Failed to wait for the async response, %zd\n",
63 __func__, ret); 64 __func__, ret);
64 goto out_token; 65 goto out_token;
65 } 66 }
@@ -111,7 +112,7 @@ static ssize_t sys_param_show(struct kobject *kobj,
111{ 112{
112 struct param_attr *attr = container_of(kobj_attr, struct param_attr, 113 struct param_attr *attr = container_of(kobj_attr, struct param_attr,
113 kobj_attr); 114 kobj_attr);
114 int ret; 115 ssize_t ret;
115 116
116 mutex_lock(&opal_sysparam_mutex); 117 mutex_lock(&opal_sysparam_mutex);
117 ret = opal_get_sys_param(attr->param_id, attr->param_size, 118 ret = opal_get_sys_param(attr->param_id, attr->param_size,
@@ -121,9 +122,10 @@ static ssize_t sys_param_show(struct kobject *kobj,
121 122
122 memcpy(buf, param_data_buf, attr->param_size); 123 memcpy(buf, param_data_buf, attr->param_size);
123 124
125 ret = attr->param_size;
124out: 126out:
125 mutex_unlock(&opal_sysparam_mutex); 127 mutex_unlock(&opal_sysparam_mutex);
126 return ret ? ret : attr->param_size; 128 return ret;
127} 129}
128 130
129static ssize_t sys_param_store(struct kobject *kobj, 131static ssize_t sys_param_store(struct kobject *kobj,
@@ -131,14 +133,20 @@ static ssize_t sys_param_store(struct kobject *kobj,
131{ 133{
132 struct param_attr *attr = container_of(kobj_attr, struct param_attr, 134 struct param_attr *attr = container_of(kobj_attr, struct param_attr,
133 kobj_attr); 135 kobj_attr);
134 int ret; 136 ssize_t ret;
137
138 /* MAX_PARAM_DATA_LEN is sizeof(param_data_buf) */
139 if (count > MAX_PARAM_DATA_LEN)
140 count = MAX_PARAM_DATA_LEN;
135 141
136 mutex_lock(&opal_sysparam_mutex); 142 mutex_lock(&opal_sysparam_mutex);
137 memcpy(param_data_buf, buf, count); 143 memcpy(param_data_buf, buf, count);
138 ret = opal_set_sys_param(attr->param_id, attr->param_size, 144 ret = opal_set_sys_param(attr->param_id, attr->param_size,
139 param_data_buf); 145 param_data_buf);
140 mutex_unlock(&opal_sysparam_mutex); 146 mutex_unlock(&opal_sysparam_mutex);
141 return ret ? ret : count; 147 if (!ret)
148 ret = count;
149 return ret;
142} 150}
143 151
144void __init opal_sys_param_init(void) 152void __init opal_sys_param_init(void)
@@ -214,13 +222,13 @@ void __init opal_sys_param_init(void)
214 } 222 }
215 223
216 if (of_property_read_u32_array(sysparam, "param-len", size, count)) { 224 if (of_property_read_u32_array(sysparam, "param-len", size, count)) {
217 pr_err("SYSPARAM: Missing propery param-len in the DT\n"); 225 pr_err("SYSPARAM: Missing property param-len in the DT\n");
218 goto out_free_perm; 226 goto out_free_perm;
219 } 227 }
220 228
221 229
222 if (of_property_read_u8_array(sysparam, "param-perm", perm, count)) { 230 if (of_property_read_u8_array(sysparam, "param-perm", perm, count)) {
223 pr_err("SYSPARAM: Missing propery param-perm in the DT\n"); 231 pr_err("SYSPARAM: Missing property param-perm in the DT\n");
224 goto out_free_perm; 232 goto out_free_perm;
225 } 233 }
226 234
@@ -233,6 +241,12 @@ void __init opal_sys_param_init(void)
233 241
234 /* For each of the parameters, populate the parameter attributes */ 242 /* For each of the parameters, populate the parameter attributes */
235 for (i = 0; i < count; i++) { 243 for (i = 0; i < count; i++) {
244 if (size[i] > MAX_PARAM_DATA_LEN) {
245 pr_warn("SYSPARAM: Not creating parameter %d as size "
246 "exceeds buffer length\n", i);
247 continue;
248 }
249
236 sysfs_attr_init(&attr[i].kobj_attr.attr); 250 sysfs_attr_init(&attr[i].kobj_attr.attr);
237 attr[i].param_id = id[i]; 251 attr[i].param_id = id[i];
238 attr[i].param_size = size[i]; 252 attr[i].param_size = size[i];
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 49d2f00019e5..360ad80c754c 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -242,14 +242,14 @@ void opal_notifier_update_evt(uint64_t evt_mask,
242void opal_notifier_enable(void) 242void opal_notifier_enable(void)
243{ 243{
244 int64_t rc; 244 int64_t rc;
245 uint64_t evt = 0; 245 __be64 evt = 0;
246 246
247 atomic_set(&opal_notifier_hold, 0); 247 atomic_set(&opal_notifier_hold, 0);
248 248
249 /* Process pending events */ 249 /* Process pending events */
250 rc = opal_poll_events(&evt); 250 rc = opal_poll_events(&evt);
251 if (rc == OPAL_SUCCESS && evt) 251 if (rc == OPAL_SUCCESS && evt)
252 opal_do_notifier(evt); 252 opal_do_notifier(be64_to_cpu(evt));
253} 253}
254 254
255void opal_notifier_disable(void) 255void opal_notifier_disable(void)
@@ -529,7 +529,7 @@ static irqreturn_t opal_interrupt(int irq, void *data)
529 529
530 opal_handle_interrupt(virq_to_hw(irq), &events); 530 opal_handle_interrupt(virq_to_hw(irq), &events);
531 531
532 opal_do_notifier(events); 532 opal_do_notifier(be64_to_cpu(events));
533 533
534 return IRQ_HANDLED; 534 return IRQ_HANDLED;
535} 535}
@@ -638,3 +638,66 @@ void opal_shutdown(void)
638 638
639/* Export this so that test modules can use it */ 639/* Export this so that test modules can use it */
640EXPORT_SYMBOL_GPL(opal_invalid_call); 640EXPORT_SYMBOL_GPL(opal_invalid_call);
641
642/* Convert a region of vmalloc memory to an opal sg list */
643struct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr,
644 unsigned long vmalloc_size)
645{
646 struct opal_sg_list *sg, *first = NULL;
647 unsigned long i = 0;
648
649 sg = kzalloc(PAGE_SIZE, GFP_KERNEL);
650 if (!sg)
651 goto nomem;
652
653 first = sg;
654
655 while (vmalloc_size > 0) {
656 uint64_t data = vmalloc_to_pfn(vmalloc_addr) << PAGE_SHIFT;
657 uint64_t length = min(vmalloc_size, PAGE_SIZE);
658
659 sg->entry[i].data = cpu_to_be64(data);
660 sg->entry[i].length = cpu_to_be64(length);
661 i++;
662
663 if (i >= SG_ENTRIES_PER_NODE) {
664 struct opal_sg_list *next;
665
666 next = kzalloc(PAGE_SIZE, GFP_KERNEL);
667 if (!next)
668 goto nomem;
669
670 sg->length = cpu_to_be64(
671 i * sizeof(struct opal_sg_entry) + 16);
672 i = 0;
673 sg->next = cpu_to_be64(__pa(next));
674 sg = next;
675 }
676
677 vmalloc_addr += length;
678 vmalloc_size -= length;
679 }
680
681 sg->length = cpu_to_be64(i * sizeof(struct opal_sg_entry) + 16);
682
683 return first;
684
685nomem:
686 pr_err("%s : Failed to allocate memory\n", __func__);
687 opal_free_sg_list(first);
688 return NULL;
689}
690
691void opal_free_sg_list(struct opal_sg_list *sg)
692{
693 while (sg) {
694 uint64_t next = be64_to_cpu(sg->next);
695
696 kfree(sg);
697
698 if (next)
699 sg = __va(next);
700 else
701 sg = NULL;
702 }
703}
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 3b2b4fb3585b..98824aa99173 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -343,7 +343,6 @@ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe)
343 pci_name(dev)); 343 pci_name(dev));
344 continue; 344 continue;
345 } 345 }
346 pci_dev_get(dev);
347 pdn->pcidev = dev; 346 pdn->pcidev = dev;
348 pdn->pe_number = pe->pe_number; 347 pdn->pe_number = pe->pe_number;
349 pe->dma_weight += pnv_ioda_dma_weight(dev); 348 pe->dma_weight += pnv_ioda_dma_weight(dev);
@@ -462,7 +461,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev
462 461
463 pe = &phb->ioda.pe_array[pdn->pe_number]; 462 pe = &phb->ioda.pe_array[pdn->pe_number];
464 WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops); 463 WARN_ON(get_dma_ops(&pdev->dev) != &dma_iommu_ops);
465 set_iommu_table_base_and_group(&pdev->dev, &pe->tce32_table); 464 set_iommu_table_base(&pdev->dev, &pe->tce32_table);
466} 465}
467 466
468static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb, 467static int pnv_pci_ioda_dma_set_mask(struct pnv_phb *phb,
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 61cf8fa9c61b..8723d32632f5 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -162,18 +162,62 @@ static void pnv_shutdown(void)
162} 162}
163 163
164#ifdef CONFIG_KEXEC 164#ifdef CONFIG_KEXEC
165static void pnv_kexec_wait_secondaries_down(void)
166{
167 int my_cpu, i, notified = -1;
168
169 my_cpu = get_cpu();
170
171 for_each_online_cpu(i) {
172 uint8_t status;
173 int64_t rc;
174
175 if (i == my_cpu)
176 continue;
177
178 for (;;) {
179 rc = opal_query_cpu_status(get_hard_smp_processor_id(i),
180 &status);
181 if (rc != OPAL_SUCCESS || status != OPAL_THREAD_STARTED)
182 break;
183 barrier();
184 if (i != notified) {
185 printk(KERN_INFO "kexec: waiting for cpu %d "
186 "(physical %d) to enter OPAL\n",
187 i, paca[i].hw_cpu_id);
188 notified = i;
189 }
190 }
191 }
192}
193
165static void pnv_kexec_cpu_down(int crash_shutdown, int secondary) 194static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
166{ 195{
167 xics_kexec_teardown_cpu(secondary); 196 xics_kexec_teardown_cpu(secondary);
168 197
169 /* Return secondary CPUs to firmware on OPAL v3 */ 198 /* On OPAL v3, we return all CPUs to firmware */
170 if (firmware_has_feature(FW_FEATURE_OPALv3) && secondary) { 199
200 if (!firmware_has_feature(FW_FEATURE_OPALv3))
201 return;
202
203 if (secondary) {
204 /* Return secondary CPUs to firmware on OPAL v3 */
171 mb(); 205 mb();
172 get_paca()->kexec_state = KEXEC_STATE_REAL_MODE; 206 get_paca()->kexec_state = KEXEC_STATE_REAL_MODE;
173 mb(); 207 mb();
174 208
175 /* Return the CPU to OPAL */ 209 /* Return the CPU to OPAL */
176 opal_return_cpu(); 210 opal_return_cpu();
211 } else if (crash_shutdown) {
212 /*
213 * On crash, we don't wait for secondaries to go
214 * down as they might be unreachable or hung, so
215 * instead we just wait a bit and move on.
216 */
217 mdelay(1);
218 } else {
219 /* Primary waits for the secondaries to have reached OPAL */
220 pnv_kexec_wait_secondaries_down();
177 } 221 }
178} 222}
179#endif /* CONFIG_KEXEC */ 223#endif /* CONFIG_KEXEC */
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 908672bdcea6..bf5fcd452168 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -30,6 +30,7 @@
30#include <asm/cputhreads.h> 30#include <asm/cputhreads.h>
31#include <asm/xics.h> 31#include <asm/xics.h>
32#include <asm/opal.h> 32#include <asm/opal.h>
33#include <asm/runlatch.h>
33 34
34#include "powernv.h" 35#include "powernv.h"
35 36
@@ -156,7 +157,9 @@ static void pnv_smp_cpu_kill_self(void)
156 */ 157 */
157 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1); 158 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1);
158 while (!generic_check_cpu_restart(cpu)) { 159 while (!generic_check_cpu_restart(cpu)) {
160 ppc64_runlatch_off();
159 power7_nap(); 161 power7_nap();
162 ppc64_runlatch_on();
160 if (!generic_check_cpu_restart(cpu)) { 163 if (!generic_check_cpu_restart(cpu)) {
161 DBG("CPU%d Unexpected exit while offline !\n", cpu); 164 DBG("CPU%d Unexpected exit while offline !\n", cpu);
162 /* We may be getting an IPI, so we re-enable 165 /* We may be getting an IPI, so we re-enable
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 9b8e05078a63..20d62975856f 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -88,13 +88,14 @@ void set_default_offline_state(int cpu)
88 88
89static void rtas_stop_self(void) 89static void rtas_stop_self(void)
90{ 90{
91 struct rtas_args args = { 91 static struct rtas_args args = {
92 .token = cpu_to_be32(rtas_stop_self_token),
93 .nargs = 0, 92 .nargs = 0,
94 .nret = 1, 93 .nret = 1,
95 .rets = &args.args[0], 94 .rets = &args.args[0],
96 }; 95 };
97 96
97 args.token = cpu_to_be32(rtas_stop_self_token);
98
98 local_irq_disable(); 99 local_irq_disable();
99 100
100 BUG_ON(rtas_stop_self_token == RTAS_UNKNOWN_SERVICE); 101 BUG_ON(rtas_stop_self_token == RTAS_UNKNOWN_SERVICE);
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 573b488fc48b..7f75c94af822 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -100,10 +100,10 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
100 100
101 start_pfn = base >> PAGE_SHIFT; 101 start_pfn = base >> PAGE_SHIFT;
102 102
103 if (!pfn_valid(start_pfn)) { 103 lock_device_hotplug();
104 memblock_remove(base, memblock_size); 104
105 return 0; 105 if (!pfn_valid(start_pfn))
106 } 106 goto out;
107 107
108 block_sz = memory_block_size_bytes(); 108 block_sz = memory_block_size_bytes();
109 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE; 109 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
@@ -114,8 +114,10 @@ static int pseries_remove_memblock(unsigned long base, unsigned int memblock_siz
114 base += MIN_MEMORY_BLOCK_SIZE; 114 base += MIN_MEMORY_BLOCK_SIZE;
115 } 115 }
116 116
117out:
117 /* Update memory regions for memory remove */ 118 /* Update memory regions for memory remove */
118 memblock_remove(base, memblock_size); 119 memblock_remove(base, memblock_size);
120 unlock_device_hotplug();
119 return 0; 121 return 0;
120} 122}
121 123
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index 64603a10b863..4914fd3f41ec 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -1058,7 +1058,7 @@ static int __init apm821xx_pciex_core_init(struct device_node *np)
1058 return 1; 1058 return 1;
1059} 1059}
1060 1060
1061static int apm821xx_pciex_init_port_hw(struct ppc4xx_pciex_port *port) 1061static int __init apm821xx_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
1062{ 1062{
1063 u32 val; 1063 u32 val;
1064 1064
diff --git a/arch/s390/include/asm/ccwgroup.h b/arch/s390/include/asm/ccwgroup.h
index 6e670f88d125..ebc2913f9ee0 100644
--- a/arch/s390/include/asm/ccwgroup.h
+++ b/arch/s390/include/asm/ccwgroup.h
@@ -22,8 +22,8 @@ struct ccwgroup_device {
22/* public: */ 22/* public: */
23 unsigned int count; 23 unsigned int count;
24 struct device dev; 24 struct device dev;
25 struct ccw_device *cdev[0];
26 struct work_struct ungroup_work; 25 struct work_struct ungroup_work;
26 struct ccw_device *cdev[0];
27}; 27};
28 28
29/** 29/**
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index c544b6f05d95..a25f09fbaf36 100644
--- a/arch/s390/include/asm/tlb.h
+++ b/arch/s390/include/asm/tlb.h
@@ -59,12 +59,23 @@ static inline void tlb_gather_mmu(struct mmu_gather *tlb,
59 tlb->batch = NULL; 59 tlb->batch = NULL;
60} 60}
61 61
62static inline void tlb_flush_mmu(struct mmu_gather *tlb) 62static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
63{ 63{
64 __tlb_flush_mm_lazy(tlb->mm); 64 __tlb_flush_mm_lazy(tlb->mm);
65}
66
67static inline void tlb_flush_mmu_free(struct mmu_gather *tlb)
68{
65 tlb_table_flush(tlb); 69 tlb_table_flush(tlb);
66} 70}
67 71
72
73static inline void tlb_flush_mmu(struct mmu_gather *tlb)
74{
75 tlb_flush_mmu_tlbonly(tlb);
76 tlb_flush_mmu_free(tlb);
77}
78
68static inline void tlb_finish_mmu(struct mmu_gather *tlb, 79static inline void tlb_finish_mmu(struct mmu_gather *tlb,
69 unsigned long start, unsigned long end) 80 unsigned long start, unsigned long end)
70{ 81{
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 9c36dc398f90..452d3ebd9d0f 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -276,7 +276,6 @@ static void bpf_jit_noleaks(struct bpf_jit *jit, struct sock_filter *filter)
276 case BPF_S_LD_W_IND: 276 case BPF_S_LD_W_IND:
277 case BPF_S_LD_H_IND: 277 case BPF_S_LD_H_IND:
278 case BPF_S_LD_B_IND: 278 case BPF_S_LD_B_IND:
279 case BPF_S_LDX_B_MSH:
280 case BPF_S_LD_IMM: 279 case BPF_S_LD_IMM:
281 case BPF_S_LD_MEM: 280 case BPF_S_LD_MEM:
282 case BPF_S_MISC_TXA: 281 case BPF_S_MISC_TXA:
diff --git a/arch/sh/include/asm/tlb.h b/arch/sh/include/asm/tlb.h
index 362192ed12fe..62f80d2a9df9 100644
--- a/arch/sh/include/asm/tlb.h
+++ b/arch/sh/include/asm/tlb.h
@@ -86,6 +86,14 @@ tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vma)
86 } 86 }
87} 87}
88 88
89static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
90{
91}
92
93static inline void tlb_flush_mmu_free(struct mmu_gather *tlb)
94{
95}
96
89static inline void tlb_flush_mmu(struct mmu_gather *tlb) 97static inline void tlb_flush_mmu(struct mmu_gather *tlb)
90{ 98{
91} 99}
diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h
index 29b0301c18aa..16eb63fac57d 100644
--- a/arch/um/include/asm/tlb.h
+++ b/arch/um/include/asm/tlb.h
@@ -59,13 +59,25 @@ extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
59 unsigned long end); 59 unsigned long end);
60 60
61static inline void 61static inline void
62tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
63{
64 flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end);
65}
66
67static inline void
68tlb_flush_mmu_free(struct mmu_gather *tlb)
69{
70 init_tlb_gather(tlb);
71}
72
73static inline void
62tlb_flush_mmu(struct mmu_gather *tlb) 74tlb_flush_mmu(struct mmu_gather *tlb)
63{ 75{
64 if (!tlb->need_flush) 76 if (!tlb->need_flush)
65 return; 77 return;
66 78
67 flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end); 79 tlb_flush_mmu_tlbonly(tlb);
68 init_tlb_gather(tlb); 80 tlb_flush_mmu_free(tlb);
69} 81}
70 82
71/* tlb_finish_mmu 83/* tlb_finish_mmu
diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 75298d3358e7..08eec0b691b0 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -136,6 +136,7 @@ extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
136extern int os_get_ifname(int fd, char *namebuf); 136extern int os_get_ifname(int fd, char *namebuf);
137extern int os_set_slip(int fd); 137extern int os_set_slip(int fd);
138extern int os_mode_fd(int fd, int mode); 138extern int os_mode_fd(int fd, int mode);
139extern int os_fsync_file(int fd);
139 140
140extern int os_seek_file(int fd, unsigned long long offset); 141extern int os_seek_file(int fd, unsigned long long offset);
141extern int os_open_file(const char *file, struct openflags flags, int mode); 142extern int os_open_file(const char *file, struct openflags flags, int mode);
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index f116db15d402..30fdd5d0067b 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -103,6 +103,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
103 */ 103 */
104 os_seek_file(physmem_fd, __pa(&__syscall_stub_start)); 104 os_seek_file(physmem_fd, __pa(&__syscall_stub_start));
105 os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE); 105 os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE);
106 os_fsync_file(physmem_fd);
106 107
107 bootmap_size = init_bootmem(pfn, pfn + delta); 108 bootmap_size = init_bootmem(pfn, pfn + delta);
108 free_bootmem(__pa(reserve_end) + bootmap_size, 109 free_bootmem(__pa(reserve_end) + bootmap_size,
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 07a750197bb0..08d90fba952c 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -237,6 +237,12 @@ void os_close_file(int fd)
237{ 237{
238 close(fd); 238 close(fd);
239} 239}
240int os_fsync_file(int fd)
241{
242 if (fsync(fd) < 0)
243 return -errno;
244 return 0;
245}
240 246
241int os_seek_file(int fd, unsigned long long offset) 247int os_seek_file(int fd, unsigned long long offset)
242{ 248{
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index e1704ff600ff..df9191acd926 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -151,6 +151,7 @@ int __init main(int argc, char **argv, char **envp)
151#endif 151#endif
152 152
153 do_uml_initcalls(); 153 do_uml_initcalls();
154 change_sig(SIGPIPE, 0);
154 ret = linux_main(argc, argv); 155 ret = linux_main(argc, argv);
155 156
156 /* 157 /*
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c
index 3c4af77e51a2..897e9ad0c108 100644
--- a/arch/um/os-Linux/mem.c
+++ b/arch/um/os-Linux/mem.c
@@ -12,337 +12,117 @@
12#include <string.h> 12#include <string.h>
13#include <sys/stat.h> 13#include <sys/stat.h>
14#include <sys/mman.h> 14#include <sys/mman.h>
15#include <sys/param.h> 15#include <sys/vfs.h>
16#include <linux/magic.h>
16#include <init.h> 17#include <init.h>
17#include <os.h> 18#include <os.h>
18 19
19/* Modified by which_tmpdir, which is called during early boot */ 20/* Set by make_tempfile() during early boot. */
20static char *default_tmpdir = "/tmp";
21
22/*
23 * Modified when creating the physical memory file and when checking
24 * the tmp filesystem for usability, both happening during early boot.
25 */
26static char *tempdir = NULL; 21static char *tempdir = NULL;
27 22
28static void __init find_tempdir(void) 23/* Check if dir is on tmpfs. Return 0 if yes, -1 if no or error. */
24static int __init check_tmpfs(const char *dir)
29{ 25{
30 const char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; 26 struct statfs st;
31 int i;
32 char *dir = NULL;
33
34 if (tempdir != NULL)
35 /* We've already been called */
36 return;
37 for (i = 0; dirs[i]; i++) {
38 dir = getenv(dirs[i]);
39 if ((dir != NULL) && (*dir != '\0'))
40 break;
41 }
42 if ((dir == NULL) || (*dir == '\0'))
43 dir = default_tmpdir;
44 27
45 tempdir = malloc(strlen(dir) + 2); 28 printf("Checking if %s is on tmpfs...", dir);
46 if (tempdir == NULL) { 29 if (statfs(dir, &st) < 0) {
47 fprintf(stderr, "Failed to malloc tempdir, " 30 printf("%s\n", strerror(errno));
48 "errno = %d\n", errno); 31 } else if (st.f_type != TMPFS_MAGIC) {
49 return; 32 printf("no\n");
50 } 33 } else {
51 strcpy(tempdir, dir); 34 printf("OK\n");
52 strcat(tempdir, "/"); 35 return 0;
53}
54
55/*
56 * Remove bytes from the front of the buffer and refill it so that if there's a
57 * partial string that we care about, it will be completed, and we can recognize
58 * it.
59 */
60static int pop(int fd, char *buf, size_t size, size_t npop)
61{
62 ssize_t n;
63 size_t len = strlen(&buf[npop]);
64
65 memmove(buf, &buf[npop], len + 1);
66 n = read(fd, &buf[len], size - len - 1);
67 if (n < 0)
68 return -errno;
69
70 buf[len + n] = '\0';
71 return 1;
72}
73
74/*
75 * This will return 1, with the first character in buf being the
76 * character following the next instance of c in the file. This will
77 * read the file as needed. If there's an error, -errno is returned;
78 * if the end of the file is reached, 0 is returned.
79 */
80static int next(int fd, char *buf, size_t size, char c)
81{
82 ssize_t n;
83 char *ptr;
84
85 while ((ptr = strchr(buf, c)) == NULL) {
86 n = read(fd, buf, size - 1);
87 if (n == 0)
88 return 0;
89 else if (n < 0)
90 return -errno;
91
92 buf[n] = '\0';
93 } 36 }
94 37 return -1;
95 return pop(fd, buf, size, ptr - buf + 1);
96} 38}
97 39
98/* 40/*
99 * Decode an octal-escaped and space-terminated path of the form used by 41 * Choose the tempdir to use. We want something on tmpfs so that our memory is
100 * /proc/mounts. May be used to decode a path in-place. "out" must be at least 42 * not subject to the host's vm.dirty_ratio. If a tempdir is specified in the
101 * as large as the input. The output is always null-terminated. "len" gets the 43 * environment, we use that even if it's not on tmpfs, but we warn the user.
102 * length of the output, excluding the trailing null. Returns 0 if a full path 44 * Otherwise, we try common tmpfs locations, and if no tmpfs directory is found
103 * was successfully decoded, otherwise an error. 45 * then we fall back to /tmp.
104 */ 46 */
105static int decode_path(const char *in, char *out, size_t *len) 47static char * __init choose_tempdir(void)
106{ 48{
107 char *first = out; 49 static const char * const vars[] = {
108 int c; 50 "TMPDIR",
51 "TMP",
52 "TEMP",
53 NULL
54 };
55 static const char fallback_dir[] = "/tmp";
56 static const char * const tmpfs_dirs[] = {
57 "/dev/shm",
58 fallback_dir,
59 NULL
60 };
109 int i; 61 int i;
110 int ret = -EINVAL; 62 const char *dir;
111 while (1) { 63
112 switch (*in) { 64 printf("Checking environment variables for a tempdir...");
113 case '\0': 65 for (i = 0; vars[i]; i++) {
114 goto out; 66 dir = getenv(vars[i]);
115 67 if ((dir != NULL) && (*dir != '\0')) {
116 case ' ': 68 printf("%s\n", dir);
117 ret = 0; 69 if (check_tmpfs(dir) >= 0)
118 goto out; 70 goto done;
119 71 else
120 case '\\': 72 goto warn;
121 in++;
122 c = 0;
123 for (i = 0; i < 3; i++) {
124 if (*in < '0' || *in > '7')
125 goto out;
126 c = (c << 3) | (*in++ - '0');
127 }
128 *(unsigned char *)out++ = (unsigned char) c;
129 break;
130
131 default:
132 *out++ = *in++;
133 break;
134 } 73 }
135 } 74 }
75 printf("none found\n");
136 76
137out: 77 for (i = 0; tmpfs_dirs[i]; i++) {
138 *out = '\0'; 78 dir = tmpfs_dirs[i];
139 *len = out - first; 79 if (check_tmpfs(dir) >= 0)
140 return ret; 80 goto done;
141}
142
143/*
144 * Computes the length of s when encoded with three-digit octal escape sequences
145 * for the characters in chars.
146 */
147static size_t octal_encoded_length(const char *s, const char *chars)
148{
149 size_t len = strlen(s);
150 while ((s = strpbrk(s, chars)) != NULL) {
151 len += 3;
152 s++;
153 }
154
155 return len;
156}
157
158enum {
159 OUTCOME_NOTHING_MOUNTED,
160 OUTCOME_TMPFS_MOUNT,
161 OUTCOME_NON_TMPFS_MOUNT,
162};
163
164/* Read a line of /proc/mounts data looking for a tmpfs mount at "path". */
165static int read_mount(int fd, char *buf, size_t bufsize, const char *path,
166 int *outcome)
167{
168 int found;
169 int match;
170 char *space;
171 size_t len;
172
173 enum {
174 MATCH_NONE,
175 MATCH_EXACT,
176 MATCH_PARENT,
177 };
178
179 found = next(fd, buf, bufsize, ' ');
180 if (found != 1)
181 return found;
182
183 /*
184 * If there's no following space in the buffer, then this path is
185 * truncated, so it can't be the one we're looking for.
186 */
187 space = strchr(buf, ' ');
188 if (space) {
189 match = MATCH_NONE;
190 if (!decode_path(buf, buf, &len)) {
191 if (!strcmp(buf, path))
192 match = MATCH_EXACT;
193 else if (!strncmp(buf, path, len)
194 && (path[len] == '/' || !strcmp(buf, "/")))
195 match = MATCH_PARENT;
196 }
197
198 found = pop(fd, buf, bufsize, space - buf + 1);
199 if (found != 1)
200 return found;
201
202 switch (match) {
203 case MATCH_EXACT:
204 if (!strncmp(buf, "tmpfs", strlen("tmpfs")))
205 *outcome = OUTCOME_TMPFS_MOUNT;
206 else
207 *outcome = OUTCOME_NON_TMPFS_MOUNT;
208 break;
209
210 case MATCH_PARENT:
211 /* This mount obscures any previous ones. */
212 *outcome = OUTCOME_NOTHING_MOUNTED;
213 break;
214 }
215 } 81 }
216 82
217 return next(fd, buf, bufsize, '\n'); 83 dir = fallback_dir;
84warn:
85 printf("Warning: tempdir %s is not on tmpfs\n", dir);
86done:
87 /* Make a copy since getenv results may not remain valid forever. */
88 return strdup(dir);
218} 89}
219 90
220/* which_tmpdir is called only during early boot */
221static int checked_tmpdir = 0;
222
223/* 91/*
224 * Look for a tmpfs mounted at /dev/shm. I couldn't find a cleaner 92 * Create an unlinked tempfile in a suitable tempdir. template must be the
225 * way to do this than to parse /proc/mounts. statfs will return the 93 * basename part of the template with a leading '/'.
226 * same filesystem magic number and fs id for both /dev and /dev/shm
227 * when they are both tmpfs, so you can't tell if they are different
228 * filesystems. Also, there seems to be no other way of finding the
229 * mount point of a filesystem from within it.
230 *
231 * If a /dev/shm tmpfs entry is found, then we switch to using it.
232 * Otherwise, we stay with the default /tmp.
233 */ 94 */
234static void which_tmpdir(void) 95static int __init make_tempfile(const char *template)
235{ 96{
97 char *tempname;
236 int fd; 98 int fd;
237 int found;
238 int outcome;
239 char *path;
240 char *buf;
241 size_t bufsize;
242 99
243 if (checked_tmpdir) 100 if (tempdir == NULL) {
244 return; 101 tempdir = choose_tempdir();
245 102 if (tempdir == NULL) {
246 checked_tmpdir = 1; 103 fprintf(stderr, "Failed to choose tempdir: %s\n",
247 104 strerror(errno));
248 printf("Checking for tmpfs mount on /dev/shm..."); 105 return -1;
249
250 path = realpath("/dev/shm", NULL);
251 if (!path) {
252 printf("failed to check real path, errno = %d\n", errno);
253 return;
254 }
255 printf("%s...", path);
256
257 /*
258 * The buffer needs to be able to fit the full octal-escaped path, a
259 * space, and a trailing null in order to successfully decode it.
260 */
261 bufsize = octal_encoded_length(path, " \t\n\\") + 2;
262
263 if (bufsize < 128)
264 bufsize = 128;
265
266 buf = malloc(bufsize);
267 if (!buf) {
268 printf("malloc failed, errno = %d\n", errno);
269 goto out;
270 }
271 buf[0] = '\0';
272
273 fd = open("/proc/mounts", O_RDONLY);
274 if (fd < 0) {
275 printf("failed to open /proc/mounts, errno = %d\n", errno);
276 goto out1;
277 }
278
279 outcome = OUTCOME_NOTHING_MOUNTED;
280 while (1) {
281 found = read_mount(fd, buf, bufsize, path, &outcome);
282 if (found != 1)
283 break;
284 }
285
286 if (found < 0) {
287 printf("read returned errno %d\n", -found);
288 } else {
289 switch (outcome) {
290 case OUTCOME_TMPFS_MOUNT:
291 printf("OK\n");
292 default_tmpdir = "/dev/shm";
293 break;
294
295 case OUTCOME_NON_TMPFS_MOUNT:
296 printf("not tmpfs\n");
297 break;
298
299 default:
300 printf("nothing mounted on /dev/shm\n");
301 break;
302 } 106 }
303 } 107 }
304 108
305 close(fd); 109 tempname = malloc(strlen(tempdir) + strlen(template) + 1);
306out1:
307 free(buf);
308out:
309 free(path);
310}
311
312static int __init make_tempfile(const char *template, char **out_tempname,
313 int do_unlink)
314{
315 char *tempname;
316 int fd;
317
318 which_tmpdir();
319 tempname = malloc(MAXPATHLEN);
320 if (tempname == NULL) 110 if (tempname == NULL)
321 return -1; 111 return -1;
322 112
323 find_tempdir(); 113 strcpy(tempname, tempdir);
324 if ((tempdir == NULL) || (strlen(tempdir) >= MAXPATHLEN)) 114 strcat(tempname, template);
325 goto out;
326
327 if (template[0] != '/')
328 strcpy(tempname, tempdir);
329 else
330 tempname[0] = '\0';
331 strncat(tempname, template, MAXPATHLEN-1-strlen(tempname));
332 fd = mkstemp(tempname); 115 fd = mkstemp(tempname);
333 if (fd < 0) { 116 if (fd < 0) {
334 fprintf(stderr, "open - cannot create %s: %s\n", tempname, 117 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
335 strerror(errno)); 118 strerror(errno));
336 goto out; 119 goto out;
337 } 120 }
338 if (do_unlink && (unlink(tempname) < 0)) { 121 if (unlink(tempname) < 0) {
339 perror("unlink"); 122 perror("unlink");
340 goto close; 123 goto close;
341 } 124 }
342 if (out_tempname) { 125 free(tempname);
343 *out_tempname = tempname;
344 } else
345 free(tempname);
346 return fd; 126 return fd;
347close: 127close:
348 close(fd); 128 close(fd);
@@ -351,14 +131,14 @@ out:
351 return -1; 131 return -1;
352} 132}
353 133
354#define TEMPNAME_TEMPLATE "vm_file-XXXXXX" 134#define TEMPNAME_TEMPLATE "/vm_file-XXXXXX"
355 135
356static int __init create_tmp_file(unsigned long long len) 136static int __init create_tmp_file(unsigned long long len)
357{ 137{
358 int fd, err; 138 int fd, err;
359 char zero; 139 char zero;
360 140
361 fd = make_tempfile(TEMPNAME_TEMPLATE, NULL, 1); 141 fd = make_tempfile(TEMPNAME_TEMPLATE);
362 if (fd < 0) 142 if (fd < 0)
363 exit(1); 143 exit(1);
364 144
@@ -402,7 +182,6 @@ int __init create_mem_file(unsigned long long len)
402 return fd; 182 return fd;
403} 183}
404 184
405
406void __init check_tmpexec(void) 185void __init check_tmpexec(void)
407{ 186{
408 void *addr; 187 void *addr;
@@ -410,14 +189,13 @@ void __init check_tmpexec(void)
410 189
411 addr = mmap(NULL, UM_KERN_PAGE_SIZE, 190 addr = mmap(NULL, UM_KERN_PAGE_SIZE,
412 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); 191 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
413 printf("Checking PROT_EXEC mmap in %s...",tempdir); 192 printf("Checking PROT_EXEC mmap in %s...", tempdir);
414 fflush(stdout);
415 if (addr == MAP_FAILED) { 193 if (addr == MAP_FAILED) {
416 err = errno; 194 err = errno;
417 perror("failed"); 195 printf("%s\n", strerror(err));
418 close(fd); 196 close(fd);
419 if (err == EPERM) 197 if (err == EPERM)
420 printf("%s must be not mounted noexec\n",tempdir); 198 printf("%s must be not mounted noexec\n", tempdir);
421 exit(1); 199 exit(1);
422 } 200 }
423 printf("OK\n"); 201 printf("OK\n");
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index d1b7c377a234..ce6ad7e6a7d7 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -83,7 +83,9 @@ else
83 KBUILD_CFLAGS += -m64 83 KBUILD_CFLAGS += -m64
84 84
85 # Don't autogenerate traditional x87, MMX or SSE instructions 85 # Don't autogenerate traditional x87, MMX or SSE instructions
86 KBUILD_CFLAGS += -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 86 KBUILD_CFLAGS += -mno-mmx -mno-sse
87 KBUILD_CFLAGS += $(call cc-option,-mno-80387)
88 KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387)
87 89
88 # Use -mpreferred-stack-boundary=3 if supported. 90 # Use -mpreferred-stack-boundary=3 if supported.
89 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3) 91 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 6ad4658de705..d23aa82e7a7b 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3425,6 +3425,11 @@ int get_nr_irqs_gsi(void)
3425 return nr_irqs_gsi; 3425 return nr_irqs_gsi;
3426} 3426}
3427 3427
3428unsigned int arch_dynirq_lower_bound(unsigned int from)
3429{
3430 return from < nr_irqs_gsi ? nr_irqs_gsi : from;
3431}
3432
3428int __init arch_probe_nr_irqs(void) 3433int __init arch_probe_nr_irqs(void)
3429{ 3434{
3430 int nr; 3435 int nr;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
index 7c87424d4140..619f7699487a 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c
@@ -543,7 +543,8 @@ static int rapl_cpu_prepare(int cpu)
543 if (phys_id < 0) 543 if (phys_id < 0)
544 return -1; 544 return -1;
545 545
546 if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits)) 546 /* protect rdmsrl() to handle virtualization */
547 if (rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
547 return -1; 548 return -1;
548 549
549 pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); 550 pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
diff --git a/arch/x86/kernel/vsmp_64.c b/arch/x86/kernel/vsmp_64.c
index f6584a90aba3..5edc34b5b951 100644
--- a/arch/x86/kernel/vsmp_64.c
+++ b/arch/x86/kernel/vsmp_64.c
@@ -26,6 +26,9 @@
26 26
27#define TOPOLOGY_REGISTER_OFFSET 0x10 27#define TOPOLOGY_REGISTER_OFFSET 0x10
28 28
29/* Flag below is initialized once during vSMP PCI initialization. */
30static int irq_routing_comply = 1;
31
29#if defined CONFIG_PCI && defined CONFIG_PARAVIRT 32#if defined CONFIG_PCI && defined CONFIG_PARAVIRT
30/* 33/*
31 * Interrupt control on vSMPowered systems: 34 * Interrupt control on vSMPowered systems:
@@ -101,6 +104,10 @@ static void __init set_vsmp_pv_ops(void)
101#ifdef CONFIG_SMP 104#ifdef CONFIG_SMP
102 if (cap & ctl & BIT(8)) { 105 if (cap & ctl & BIT(8)) {
103 ctl &= ~BIT(8); 106 ctl &= ~BIT(8);
107
108 /* Interrupt routing set to ignore */
109 irq_routing_comply = 0;
110
104#ifdef CONFIG_PROC_FS 111#ifdef CONFIG_PROC_FS
105 /* Don't let users change irq affinity via procfs */ 112 /* Don't let users change irq affinity via procfs */
106 no_irq_affinity = 1; 113 no_irq_affinity = 1;
@@ -218,7 +225,9 @@ static void vsmp_apic_post_init(void)
218{ 225{
219 /* need to update phys_pkg_id */ 226 /* need to update phys_pkg_id */
220 apic->phys_pkg_id = apicid_phys_pkg_id; 227 apic->phys_pkg_id = apicid_phys_pkg_id;
221 apic->vector_allocation_domain = fill_vector_allocation_domain; 228
229 if (!irq_routing_comply)
230 apic->vector_allocation_domain = fill_vector_allocation_domain;
222} 231}
223 232
224void __init vsmp_init(void) 233void __init vsmp_init(void)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1f68c5831924..33e8c028842f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -503,7 +503,7 @@ static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu)
503 [number##_HIGH] = VMCS12_OFFSET(name)+4 503 [number##_HIGH] = VMCS12_OFFSET(name)+4
504 504
505 505
506static const unsigned long shadow_read_only_fields[] = { 506static unsigned long shadow_read_only_fields[] = {
507 /* 507 /*
508 * We do NOT shadow fields that are modified when L0 508 * We do NOT shadow fields that are modified when L0
509 * traps and emulates any vmx instruction (e.g. VMPTRLD, 509 * traps and emulates any vmx instruction (e.g. VMPTRLD,
@@ -526,10 +526,10 @@ static const unsigned long shadow_read_only_fields[] = {
526 GUEST_LINEAR_ADDRESS, 526 GUEST_LINEAR_ADDRESS,
527 GUEST_PHYSICAL_ADDRESS 527 GUEST_PHYSICAL_ADDRESS
528}; 528};
529static const int max_shadow_read_only_fields = 529static int max_shadow_read_only_fields =
530 ARRAY_SIZE(shadow_read_only_fields); 530 ARRAY_SIZE(shadow_read_only_fields);
531 531
532static const unsigned long shadow_read_write_fields[] = { 532static unsigned long shadow_read_write_fields[] = {
533 GUEST_RIP, 533 GUEST_RIP,
534 GUEST_RSP, 534 GUEST_RSP,
535 GUEST_CR0, 535 GUEST_CR0,
@@ -558,7 +558,7 @@ static const unsigned long shadow_read_write_fields[] = {
558 HOST_FS_SELECTOR, 558 HOST_FS_SELECTOR,
559 HOST_GS_SELECTOR 559 HOST_GS_SELECTOR
560}; 560};
561static const int max_shadow_read_write_fields = 561static int max_shadow_read_write_fields =
562 ARRAY_SIZE(shadow_read_write_fields); 562 ARRAY_SIZE(shadow_read_write_fields);
563 563
564static const unsigned short vmcs_field_to_offset_table[] = { 564static const unsigned short vmcs_field_to_offset_table[] = {
@@ -3009,6 +3009,41 @@ static void free_kvm_area(void)
3009 } 3009 }
3010} 3010}
3011 3011
3012static void init_vmcs_shadow_fields(void)
3013{
3014 int i, j;
3015
3016 /* No checks for read only fields yet */
3017
3018 for (i = j = 0; i < max_shadow_read_write_fields; i++) {
3019 switch (shadow_read_write_fields[i]) {
3020 case GUEST_BNDCFGS:
3021 if (!vmx_mpx_supported())
3022 continue;
3023 break;
3024 default:
3025 break;
3026 }
3027
3028 if (j < i)
3029 shadow_read_write_fields[j] =
3030 shadow_read_write_fields[i];
3031 j++;
3032 }
3033 max_shadow_read_write_fields = j;
3034
3035 /* shadowed fields guest access without vmexit */
3036 for (i = 0; i < max_shadow_read_write_fields; i++) {
3037 clear_bit(shadow_read_write_fields[i],
3038 vmx_vmwrite_bitmap);
3039 clear_bit(shadow_read_write_fields[i],
3040 vmx_vmread_bitmap);
3041 }
3042 for (i = 0; i < max_shadow_read_only_fields; i++)
3043 clear_bit(shadow_read_only_fields[i],
3044 vmx_vmread_bitmap);
3045}
3046
3012static __init int alloc_kvm_area(void) 3047static __init int alloc_kvm_area(void)
3013{ 3048{
3014 int cpu; 3049 int cpu;
@@ -3039,6 +3074,8 @@ static __init int hardware_setup(void)
3039 enable_vpid = 0; 3074 enable_vpid = 0;
3040 if (!cpu_has_vmx_shadow_vmcs()) 3075 if (!cpu_has_vmx_shadow_vmcs())
3041 enable_shadow_vmcs = 0; 3076 enable_shadow_vmcs = 0;
3077 if (enable_shadow_vmcs)
3078 init_vmcs_shadow_fields();
3042 3079
3043 if (!cpu_has_vmx_ept() || 3080 if (!cpu_has_vmx_ept() ||
3044 !cpu_has_vmx_ept_4levels()) { 3081 !cpu_has_vmx_ept_4levels()) {
@@ -8803,14 +8840,6 @@ static int __init vmx_init(void)
8803 8840
8804 memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE); 8841 memset(vmx_vmread_bitmap, 0xff, PAGE_SIZE);
8805 memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE); 8842 memset(vmx_vmwrite_bitmap, 0xff, PAGE_SIZE);
8806 /* shadowed read/write fields */
8807 for (i = 0; i < max_shadow_read_write_fields; i++) {
8808 clear_bit(shadow_read_write_fields[i], vmx_vmwrite_bitmap);
8809 clear_bit(shadow_read_write_fields[i], vmx_vmread_bitmap);
8810 }
8811 /* shadowed read only fields */
8812 for (i = 0; i < max_shadow_read_only_fields; i++)
8813 clear_bit(shadow_read_only_fields[i], vmx_vmread_bitmap);
8814 8843
8815 /* 8844 /*
8816 * Allow direct access to the PC debug port (it is often used for I/O 8845 * Allow direct access to the PC debug port (it is often used for I/O
diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S
index 2e263f367b13..9df017ab2285 100644
--- a/arch/x86/vdso/vdso-layout.lds.S
+++ b/arch/x86/vdso/vdso-layout.lds.S
@@ -9,12 +9,9 @@ SECTIONS
9#ifdef BUILD_VDSO32 9#ifdef BUILD_VDSO32
10#include <asm/vdso32.h> 10#include <asm/vdso32.h>
11 11
12 .hpet_sect : { 12 hpet_page = . - VDSO_OFFSET(VDSO_HPET_PAGE);
13 hpet_page = . - VDSO_OFFSET(VDSO_HPET_PAGE);
14 } :text :hpet_sect
15 13
16 .vvar_sect : { 14 vvar = . - VDSO_OFFSET(VDSO_VVAR_PAGE);
17 vvar = . - VDSO_OFFSET(VDSO_VVAR_PAGE);
18 15
19 /* Place all vvars at the offsets in asm/vvar.h. */ 16 /* Place all vvars at the offsets in asm/vvar.h. */
20#define EMIT_VVAR(name, offset) vvar_ ## name = vvar + offset; 17#define EMIT_VVAR(name, offset) vvar_ ## name = vvar + offset;
@@ -22,7 +19,6 @@ SECTIONS
22#include <asm/vvar.h> 19#include <asm/vvar.h>
23#undef __VVAR_KERNEL_LDS 20#undef __VVAR_KERNEL_LDS
24#undef EMIT_VVAR 21#undef EMIT_VVAR
25 } :text :vvar_sect
26#endif 22#endif
27 . = SIZEOF_HEADERS; 23 . = SIZEOF_HEADERS;
28 24
@@ -61,7 +57,12 @@ SECTIONS
61 */ 57 */
62 . = ALIGN(0x100); 58 . = ALIGN(0x100);
63 59
64 .text : { *(.text*) } :text =0x90909090 60 .text : { *(.text*) } :text =0x90909090,
61
62 /*
63 * The comma above works around a bug in gold:
64 * https://sourceware.org/bugzilla/show_bug.cgi?id=16804
65 */
65 66
66 /DISCARD/ : { 67 /DISCARD/ : {
67 *(.discard) 68 *(.discard)
@@ -84,8 +85,4 @@ PHDRS
84 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 85 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
85 note PT_NOTE FLAGS(4); /* PF_R */ 86 note PT_NOTE FLAGS(4); /* PF_R */
86 eh_frame_hdr PT_GNU_EH_FRAME; 87 eh_frame_hdr PT_GNU_EH_FRAME;
87#ifdef BUILD_VDSO32
88 vvar_sect PT_NULL FLAGS(4); /* PF_R */
89 hpet_sect PT_NULL FLAGS(4); /* PF_R */
90#endif
91} 88}
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 02d6d29a63c1..3a617af60d46 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -14,6 +14,7 @@ config XTENSA
14 select GENERIC_PCI_IOMAP 14 select GENERIC_PCI_IOMAP
15 select ARCH_WANT_IPC_PARSE_VERSION 15 select ARCH_WANT_IPC_PARSE_VERSION
16 select ARCH_WANT_OPTIONAL_GPIOLIB 16 select ARCH_WANT_OPTIONAL_GPIOLIB
17 select BUILDTIME_EXTABLE_SORT
17 select CLONE_BACKWARDS 18 select CLONE_BACKWARDS
18 select IRQ_DOMAIN 19 select IRQ_DOMAIN
19 select HAVE_OPROFILE 20 select HAVE_OPROFILE
@@ -189,6 +190,24 @@ config INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX
189 190
190 If in doubt, say Y. 191 If in doubt, say Y.
191 192
193config HIGHMEM
194 bool "High Memory Support"
195 help
196 Linux can use the full amount of RAM in the system by
197 default. However, the default MMUv2 setup only maps the
198 lowermost 128 MB of memory linearly to the areas starting
199 at 0xd0000000 (cached) and 0xd8000000 (uncached).
200 When there are more than 128 MB memory in the system not
201 all of it can be "permanently mapped" by the kernel.
202 The physical memory that's not permanently mapped is called
203 "high memory".
204
205 If you are compiling a kernel which will never run on a
206 machine with more than 128 MB total physical RAM, answer
207 N here.
208
209 If unsure, say Y.
210
192endmenu 211endmenu
193 212
194config XTENSA_CALIBRATE_CCOUNT 213config XTENSA_CALIBRATE_CCOUNT
@@ -224,7 +243,6 @@ choice
224 243
225config XTENSA_PLATFORM_ISS 244config XTENSA_PLATFORM_ISS
226 bool "ISS" 245 bool "ISS"
227 depends on TTY
228 select XTENSA_CALIBRATE_CCOUNT 246 select XTENSA_CALIBRATE_CCOUNT
229 select SERIAL_CONSOLE 247 select SERIAL_CONSOLE
230 help 248 help
diff --git a/arch/xtensa/boot/dts/kc705.dts b/arch/xtensa/boot/dts/kc705.dts
new file mode 100644
index 000000000000..742a347be67a
--- /dev/null
+++ b/arch/xtensa/boot/dts/kc705.dts
@@ -0,0 +1,11 @@
1/dts-v1/;
2/include/ "xtfpga.dtsi"
3/include/ "xtfpga-flash-128m.dtsi"
4
5/ {
6 compatible = "cdns,xtensa-kc705";
7 memory@0 {
8 device_type = "memory";
9 reg = <0x00000000 0x08000000>;
10 };
11};
diff --git a/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
new file mode 100644
index 000000000000..d3a88e029873
--- /dev/null
+++ b/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
@@ -0,0 +1,28 @@
1/ {
2 soc {
3 flash: flash@00000000 {
4 #address-cells = <1>;
5 #size-cells = <1>;
6 compatible = "cfi-flash";
7 reg = <0x00000000 0x08000000>;
8 bank-width = <2>;
9 device-width = <2>;
10 partition@0x0 {
11 label = "data";
12 reg = <0x00000000 0x06000000>;
13 };
14 partition@0x6000000 {
15 label = "boot loader area";
16 reg = <0x06000000 0x00800000>;
17 };
18 partition@0x6800000 {
19 label = "kernel image";
20 reg = <0x06800000 0x017e0000>;
21 };
22 partition@0x7fe0000 {
23 label = "boot environment";
24 reg = <0x07fe0000 0x00020000>;
25 };
26 };
27 };
28};
diff --git a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
index e5703c7beeb6..1d97203c18e7 100644
--- a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
+++ b/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
@@ -1,26 +1,28 @@
1/ { 1/ {
2 flash: flash@f8000000 { 2 soc {
3 #address-cells = <1>; 3 flash: flash@08000000 {
4 #size-cells = <1>; 4 #address-cells = <1>;
5 compatible = "cfi-flash"; 5 #size-cells = <1>;
6 reg = <0xf8000000 0x01000000>; 6 compatible = "cfi-flash";
7 bank-width = <2>; 7 reg = <0x08000000 0x01000000>;
8 device-width = <2>; 8 bank-width = <2>;
9 partition@0x0 { 9 device-width = <2>;
10 label = "boot loader area"; 10 partition@0x0 {
11 reg = <0x00000000 0x00400000>; 11 label = "boot loader area";
12 reg = <0x00000000 0x00400000>;
13 };
14 partition@0x400000 {
15 label = "kernel image";
16 reg = <0x00400000 0x00600000>;
17 };
18 partition@0xa00000 {
19 label = "data";
20 reg = <0x00a00000 0x005e0000>;
21 };
22 partition@0xfe0000 {
23 label = "boot environment";
24 reg = <0x00fe0000 0x00020000>;
25 };
12 }; 26 };
13 partition@0x400000 { 27 };
14 label = "kernel image";
15 reg = <0x00400000 0x00600000>;
16 };
17 partition@0xa00000 {
18 label = "data";
19 reg = <0x00a00000 0x005e0000>;
20 };
21 partition@0xfe0000 {
22 label = "boot environment";
23 reg = <0x00fe0000 0x00020000>;
24 };
25 };
26}; 28};
diff --git a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
index 6f9c10d6b689..d1c621ca8be1 100644
--- a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
+++ b/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
@@ -1,18 +1,20 @@
1/ { 1/ {
2 flash: flash@f8000000 { 2 soc {
3 #address-cells = <1>; 3 flash: flash@08000000 {
4 #size-cells = <1>; 4 #address-cells = <1>;
5 compatible = "cfi-flash"; 5 #size-cells = <1>;
6 reg = <0xf8000000 0x00400000>; 6 compatible = "cfi-flash";
7 bank-width = <2>; 7 reg = <0x08000000 0x00400000>;
8 device-width = <2>; 8 bank-width = <2>;
9 partition@0x0 { 9 device-width = <2>;
10 label = "boot loader area"; 10 partition@0x0 {
11 reg = <0x00000000 0x003f0000>; 11 label = "boot loader area";
12 reg = <0x00000000 0x003f0000>;
13 };
14 partition@0x3f0000 {
15 label = "boot environment";
16 reg = <0x003f0000 0x00010000>;
17 };
12 }; 18 };
13 partition@0x3f0000 { 19 };
14 label = "boot environment";
15 reg = <0x003f0000 0x00010000>;
16 };
17 };
18}; 20};
diff --git a/arch/xtensa/boot/dts/xtfpga.dtsi b/arch/xtensa/boot/dts/xtfpga.dtsi
index e7370b11348e..dec9178840f6 100644
--- a/arch/xtensa/boot/dts/xtfpga.dtsi
+++ b/arch/xtensa/boot/dts/xtfpga.dtsi
@@ -42,21 +42,28 @@
42 }; 42 };
43 }; 43 };
44 44
45 serial0: serial@fd050020 { 45 soc {
46 device_type = "serial"; 46 #address-cells = <1>;
47 compatible = "ns16550a"; 47 #size-cells = <1>;
48 no-loopback-test; 48 compatible = "simple-bus";
49 reg = <0xfd050020 0x20>; 49 ranges = <0x00000000 0xf0000000 0x10000000>;
50 reg-shift = <2>;
51 interrupts = <0 1>; /* external irq 0 */
52 clocks = <&osc>;
53 };
54 50
55 enet0: ethoc@fd030000 { 51 serial0: serial@0d050020 {
56 compatible = "opencores,ethoc"; 52 device_type = "serial";
57 reg = <0xfd030000 0x4000 0xfd800000 0x4000>; 53 compatible = "ns16550a";
58 interrupts = <1 1>; /* external irq 1 */ 54 no-loopback-test;
59 local-mac-address = [00 50 c2 13 6f 00]; 55 reg = <0x0d050020 0x20>;
60 clocks = <&osc>; 56 reg-shift = <2>;
57 interrupts = <0 1>; /* external irq 0 */
58 clocks = <&osc>;
59 };
60
61 enet0: ethoc@0d030000 {
62 compatible = "opencores,ethoc";
63 reg = <0x0d030000 0x4000 0x0d800000 0x4000>;
64 interrupts = <1 1>; /* external irq 1 */
65 local-mac-address = [00 50 c2 13 6f 00];
66 clocks = <&osc>;
67 };
61 }; 68 };
62}; 69};
diff --git a/arch/xtensa/include/asm/bootparam.h b/arch/xtensa/include/asm/bootparam.h
index 23392c5630ce..892aab399ac8 100644
--- a/arch/xtensa/include/asm/bootparam.h
+++ b/arch/xtensa/include/asm/bootparam.h
@@ -37,23 +37,14 @@ typedef struct bp_tag {
37 unsigned long data[0]; /* data */ 37 unsigned long data[0]; /* data */
38} bp_tag_t; 38} bp_tag_t;
39 39
40typedef struct meminfo { 40struct bp_meminfo {
41 unsigned long type; 41 unsigned long type;
42 unsigned long start; 42 unsigned long start;
43 unsigned long end; 43 unsigned long end;
44} meminfo_t; 44};
45
46#define SYSMEM_BANKS_MAX 5
47 45
48#define MEMORY_TYPE_CONVENTIONAL 0x1000 46#define MEMORY_TYPE_CONVENTIONAL 0x1000
49#define MEMORY_TYPE_NONE 0x2000 47#define MEMORY_TYPE_NONE 0x2000
50 48
51typedef struct sysmem_info {
52 int nr_banks;
53 meminfo_t bank[SYSMEM_BANKS_MAX];
54} sysmem_info_t;
55
56extern sysmem_info_t sysmem;
57
58#endif 49#endif
59#endif 50#endif
diff --git a/arch/xtensa/include/asm/fixmap.h b/arch/xtensa/include/asm/fixmap.h
new file mode 100644
index 000000000000..9f6c33d0428a
--- /dev/null
+++ b/arch/xtensa/include/asm/fixmap.h
@@ -0,0 +1,58 @@
1/*
2 * fixmap.h: compile-time virtual memory allocation
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1998 Ingo Molnar
9 *
10 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
11 */
12
13#ifndef _ASM_FIXMAP_H
14#define _ASM_FIXMAP_H
15
16#include <asm/pgtable.h>
17#ifdef CONFIG_HIGHMEM
18#include <linux/threads.h>
19#include <asm/kmap_types.h>
20#endif
21
22/*
23 * Here we define all the compile-time 'special' virtual
24 * addresses. The point is to have a constant address at
25 * compile time, but to set the physical address only
26 * in the boot process. We allocate these special addresses
27 * from the end of the consistent memory region backwards.
28 * Also this lets us do fail-safe vmalloc(), we
29 * can guarantee that these special addresses and
30 * vmalloc()-ed addresses never overlap.
31 *
32 * these 'compile-time allocated' memory buffers are
33 * fixed-size 4k pages. (or larger if used with an increment
34 * higher than 1) use fixmap_set(idx,phys) to associate
35 * physical memory with fixmap indices.
36 */
37enum fixed_addresses {
38#ifdef CONFIG_HIGHMEM
39 /* reserved pte's for temporary kernel mappings */
40 FIX_KMAP_BEGIN,
41 FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * NR_CPUS) - 1,
42#endif
43 __end_of_fixed_addresses
44};
45
46#define FIXADDR_TOP (VMALLOC_START - PAGE_SIZE)
47#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
48#define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK)
49
50#include <asm-generic/fixmap.h>
51
52#define kmap_get_fixmap_pte(vaddr) \
53 pte_offset_kernel( \
54 pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), \
55 (vaddr) \
56 )
57
58#endif
diff --git a/arch/xtensa/include/asm/highmem.h b/arch/xtensa/include/asm/highmem.h
index 80be15124697..2653ef5d55f1 100644
--- a/arch/xtensa/include/asm/highmem.h
+++ b/arch/xtensa/include/asm/highmem.h
@@ -6,11 +6,54 @@
6 * this archive for more details. 6 * this archive for more details.
7 * 7 *
8 * Copyright (C) 2003 - 2005 Tensilica Inc. 8 * Copyright (C) 2003 - 2005 Tensilica Inc.
9 * Copyright (C) 2014 Cadence Design Systems Inc.
9 */ 10 */
10 11
11#ifndef _XTENSA_HIGHMEM_H 12#ifndef _XTENSA_HIGHMEM_H
12#define _XTENSA_HIGHMEM_H 13#define _XTENSA_HIGHMEM_H
13 14
14extern void flush_cache_kmaps(void); 15#include <asm/cacheflush.h>
16#include <asm/fixmap.h>
17#include <asm/kmap_types.h>
18#include <asm/pgtable.h>
19
20#define PKMAP_BASE (FIXADDR_START - PMD_SIZE)
21#define LAST_PKMAP PTRS_PER_PTE
22#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
23#define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT)
24#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
25
26#define kmap_prot PAGE_KERNEL
27
28extern pte_t *pkmap_page_table;
29
30void *kmap_high(struct page *page);
31void kunmap_high(struct page *page);
32
33static inline void *kmap(struct page *page)
34{
35 BUG_ON(in_interrupt());
36 if (!PageHighMem(page))
37 return page_address(page);
38 return kmap_high(page);
39}
40
41static inline void kunmap(struct page *page)
42{
43 BUG_ON(in_interrupt());
44 if (!PageHighMem(page))
45 return;
46 kunmap_high(page);
47}
48
49static inline void flush_cache_kmaps(void)
50{
51 flush_cache_all();
52}
53
54void *kmap_atomic(struct page *page);
55void __kunmap_atomic(void *kvaddr);
56
57void kmap_init(void);
15 58
16#endif 59#endif
diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
index 216446295ada..4b0ca35a93b1 100644
--- a/arch/xtensa/include/asm/pgtable.h
+++ b/arch/xtensa/include/asm/pgtable.h
@@ -310,6 +310,10 @@ set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval)
310 update_pte(ptep, pteval); 310 update_pte(ptep, pteval);
311} 311}
312 312
313static inline void set_pte(pte_t *ptep, pte_t pteval)
314{
315 update_pte(ptep, pteval);
316}
313 317
314static inline void 318static inline void
315set_pmd(pmd_t *pmdp, pmd_t pmdval) 319set_pmd(pmd_t *pmdp, pmd_t pmdval)
diff --git a/arch/xtensa/include/asm/sysmem.h b/arch/xtensa/include/asm/sysmem.h
new file mode 100644
index 000000000000..c015c5c8e3f7
--- /dev/null
+++ b/arch/xtensa/include/asm/sysmem.h
@@ -0,0 +1,38 @@
1/*
2 * sysmem-related prototypes.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2014 Cadence Design Systems Inc.
9 */
10
11#ifndef _XTENSA_SYSMEM_H
12#define _XTENSA_SYSMEM_H
13
14#define SYSMEM_BANKS_MAX 31
15
16struct meminfo {
17 unsigned long start;
18 unsigned long end;
19};
20
21/*
22 * Bank array is sorted by .start.
23 * Banks don't overlap and there's at least one page gap
24 * between adjacent bank entries.
25 */
26struct sysmem_info {
27 int nr_banks;
28 struct meminfo bank[SYSMEM_BANKS_MAX];
29};
30
31extern struct sysmem_info sysmem;
32
33int add_sysmem_bank(unsigned long start, unsigned long end);
34int mem_reserve(unsigned long, unsigned long, int);
35void bootmem_init(void);
36void zones_init(void);
37
38#endif /* _XTENSA_SYSMEM_H */
diff --git a/arch/xtensa/include/asm/tlbflush.h b/arch/xtensa/include/asm/tlbflush.h
index fc34274ce41b..06875feb27c2 100644
--- a/arch/xtensa/include/asm/tlbflush.h
+++ b/arch/xtensa/include/asm/tlbflush.h
@@ -36,6 +36,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma,
36 unsigned long page); 36 unsigned long page);
37void local_flush_tlb_range(struct vm_area_struct *vma, 37void local_flush_tlb_range(struct vm_area_struct *vma,
38 unsigned long start, unsigned long end); 38 unsigned long start, unsigned long end);
39void local_flush_tlb_kernel_range(unsigned long start, unsigned long end);
39 40
40#ifdef CONFIG_SMP 41#ifdef CONFIG_SMP
41 42
@@ -44,12 +45,7 @@ void flush_tlb_mm(struct mm_struct *);
44void flush_tlb_page(struct vm_area_struct *, unsigned long); 45void flush_tlb_page(struct vm_area_struct *, unsigned long);
45void flush_tlb_range(struct vm_area_struct *, unsigned long, 46void flush_tlb_range(struct vm_area_struct *, unsigned long,
46 unsigned long); 47 unsigned long);
47 48void flush_tlb_kernel_range(unsigned long start, unsigned long end);
48static inline void flush_tlb_kernel_range(unsigned long start,
49 unsigned long end)
50{
51 flush_tlb_all();
52}
53 49
54#else /* !CONFIG_SMP */ 50#else /* !CONFIG_SMP */
55 51
@@ -58,7 +54,8 @@ static inline void flush_tlb_kernel_range(unsigned long start,
58#define flush_tlb_page(vma, page) local_flush_tlb_page(vma, page) 54#define flush_tlb_page(vma, page) local_flush_tlb_page(vma, page)
59#define flush_tlb_range(vma, vmaddr, end) local_flush_tlb_range(vma, vmaddr, \ 55#define flush_tlb_range(vma, vmaddr, end) local_flush_tlb_range(vma, vmaddr, \
60 end) 56 end)
61#define flush_tlb_kernel_range(start, end) local_flush_tlb_all() 57#define flush_tlb_kernel_range(start, end) local_flush_tlb_kernel_range(start, \
58 end)
62 59
63#endif /* CONFIG_SMP */ 60#endif /* CONFIG_SMP */
64 61
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 84fe931bb60e..9757bb74e532 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -50,6 +50,7 @@
50#include <asm/param.h> 50#include <asm/param.h>
51#include <asm/traps.h> 51#include <asm/traps.h>
52#include <asm/smp.h> 52#include <asm/smp.h>
53#include <asm/sysmem.h>
53 54
54#include <platform/hardware.h> 55#include <platform/hardware.h>
55 56
@@ -88,12 +89,6 @@ static char __initdata command_line[COMMAND_LINE_SIZE];
88static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE; 89static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
89#endif 90#endif
90 91
91sysmem_info_t __initdata sysmem;
92
93extern int mem_reserve(unsigned long, unsigned long, int);
94extern void bootmem_init(void);
95extern void zones_init(void);
96
97/* 92/*
98 * Boot parameter parsing. 93 * Boot parameter parsing.
99 * 94 *
@@ -113,31 +108,14 @@ typedef struct tagtable {
113 108
114/* parse current tag */ 109/* parse current tag */
115 110
116static int __init add_sysmem_bank(unsigned long type, unsigned long start,
117 unsigned long end)
118{
119 if (sysmem.nr_banks >= SYSMEM_BANKS_MAX) {
120 printk(KERN_WARNING
121 "Ignoring memory bank 0x%08lx size %ldKB\n",
122 start, end - start);
123 return -EINVAL;
124 }
125 sysmem.bank[sysmem.nr_banks].type = type;
126 sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(start);
127 sysmem.bank[sysmem.nr_banks].end = end & PAGE_MASK;
128 sysmem.nr_banks++;
129
130 return 0;
131}
132
133static int __init parse_tag_mem(const bp_tag_t *tag) 111static int __init parse_tag_mem(const bp_tag_t *tag)
134{ 112{
135 meminfo_t *mi = (meminfo_t *)(tag->data); 113 struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);
136 114
137 if (mi->type != MEMORY_TYPE_CONVENTIONAL) 115 if (mi->type != MEMORY_TYPE_CONVENTIONAL)
138 return -1; 116 return -1;
139 117
140 return add_sysmem_bank(mi->type, mi->start, mi->end); 118 return add_sysmem_bank(mi->start, mi->end);
141} 119}
142 120
143__tagtable(BP_TAG_MEMORY, parse_tag_mem); 121__tagtable(BP_TAG_MEMORY, parse_tag_mem);
@@ -146,8 +124,8 @@ __tagtable(BP_TAG_MEMORY, parse_tag_mem);
146 124
147static int __init parse_tag_initrd(const bp_tag_t* tag) 125static int __init parse_tag_initrd(const bp_tag_t* tag)
148{ 126{
149 meminfo_t* mi; 127 struct bp_meminfo *mi = (struct bp_meminfo *)(tag->data);
150 mi = (meminfo_t*)(tag->data); 128
151 initrd_start = (unsigned long)__va(mi->start); 129 initrd_start = (unsigned long)__va(mi->start);
152 initrd_end = (unsigned long)__va(mi->end); 130 initrd_end = (unsigned long)__va(mi->end);
153 131
@@ -255,7 +233,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
255 return; 233 return;
256 234
257 size &= PAGE_MASK; 235 size &= PAGE_MASK;
258 add_sysmem_bank(MEMORY_TYPE_CONVENTIONAL, base, base + size); 236 add_sysmem_bank(base, base + size);
259} 237}
260 238
261void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 239void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
@@ -292,8 +270,6 @@ device_initcall(xtensa_device_probe);
292 270
293void __init init_arch(bp_tag_t *bp_start) 271void __init init_arch(bp_tag_t *bp_start)
294{ 272{
295 sysmem.nr_banks = 0;
296
297 /* Parse boot parameters */ 273 /* Parse boot parameters */
298 274
299 if (bp_start) 275 if (bp_start)
@@ -304,10 +280,9 @@ void __init init_arch(bp_tag_t *bp_start)
304#endif 280#endif
305 281
306 if (sysmem.nr_banks == 0) { 282 if (sysmem.nr_banks == 0) {
307 sysmem.nr_banks = 1; 283 add_sysmem_bank(PLATFORM_DEFAULT_MEM_START,
308 sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START; 284 PLATFORM_DEFAULT_MEM_START +
309 sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START 285 PLATFORM_DEFAULT_MEM_SIZE);
310 + PLATFORM_DEFAULT_MEM_SIZE;
311 } 286 }
312 287
313#ifdef CONFIG_CMDLINE_BOOL 288#ifdef CONFIG_CMDLINE_BOOL
@@ -487,7 +462,7 @@ void __init setup_arch(char **cmdline_p)
487#ifdef CONFIG_BLK_DEV_INITRD 462#ifdef CONFIG_BLK_DEV_INITRD
488 if (initrd_start < initrd_end) { 463 if (initrd_start < initrd_end) {
489 initrd_is_mapped = mem_reserve(__pa(initrd_start), 464 initrd_is_mapped = mem_reserve(__pa(initrd_start),
490 __pa(initrd_end), 0); 465 __pa(initrd_end), 0) == 0;
491 initrd_below_start_ok = 1; 466 initrd_below_start_ok = 1;
492 } else { 467 } else {
493 initrd_start = 0; 468 initrd_start = 0;
@@ -532,6 +507,7 @@ void __init setup_arch(char **cmdline_p)
532 __pa(&_Level6InterruptVector_text_end), 0); 507 __pa(&_Level6InterruptVector_text_end), 0);
533#endif 508#endif
534 509
510 parse_early_param();
535 bootmem_init(); 511 bootmem_init();
536 512
537 unflatten_and_copy_device_tree(); 513 unflatten_and_copy_device_tree();
diff --git a/arch/xtensa/kernel/smp.c b/arch/xtensa/kernel/smp.c
index aa8bd8717927..40b5a3771fb0 100644
--- a/arch/xtensa/kernel/smp.c
+++ b/arch/xtensa/kernel/smp.c
@@ -496,6 +496,21 @@ void flush_tlb_range(struct vm_area_struct *vma,
496 on_each_cpu(ipi_flush_tlb_range, &fd, 1); 496 on_each_cpu(ipi_flush_tlb_range, &fd, 1);
497} 497}
498 498
499static void ipi_flush_tlb_kernel_range(void *arg)
500{
501 struct flush_data *fd = arg;
502 local_flush_tlb_kernel_range(fd->addr1, fd->addr2);
503}
504
505void flush_tlb_kernel_range(unsigned long start, unsigned long end)
506{
507 struct flush_data fd = {
508 .addr1 = start,
509 .addr2 = end,
510 };
511 on_each_cpu(ipi_flush_tlb_kernel_range, &fd, 1);
512}
513
499/* Cache flush functions */ 514/* Cache flush functions */
500 515
501static void ipi_flush_cache_all(void *arg) 516static void ipi_flush_cache_all(void *arg)
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 80b33ed51f31..4d2872fd9bb5 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -20,6 +20,7 @@
20#include <linux/in6.h> 20#include <linux/in6.h>
21 21
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/cacheflush.h>
23#include <asm/checksum.h> 24#include <asm/checksum.h>
24#include <asm/dma.h> 25#include <asm/dma.h>
25#include <asm/io.h> 26#include <asm/io.h>
@@ -105,6 +106,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic);
105 * Architecture-specific symbols 106 * Architecture-specific symbols
106 */ 107 */
107EXPORT_SYMBOL(__xtensa_copy_user); 108EXPORT_SYMBOL(__xtensa_copy_user);
109EXPORT_SYMBOL(__invalidate_icache_range);
108 110
109/* 111/*
110 * Kernel hacking ... 112 * Kernel hacking ...
@@ -127,3 +129,8 @@ EXPORT_SYMBOL(common_exception_return);
127#ifdef CONFIG_FUNCTION_TRACER 129#ifdef CONFIG_FUNCTION_TRACER
128EXPORT_SYMBOL(_mcount); 130EXPORT_SYMBOL(_mcount);
129#endif 131#endif
132
133EXPORT_SYMBOL(__invalidate_dcache_range);
134#if XCHAL_DCACHE_IS_WRITEBACK
135EXPORT_SYMBOL(__flush_dcache_range);
136#endif
diff --git a/arch/xtensa/mm/Makefile b/arch/xtensa/mm/Makefile
index f0b646d2f843..f54f78e24d7b 100644
--- a/arch/xtensa/mm/Makefile
+++ b/arch/xtensa/mm/Makefile
@@ -4,3 +4,4 @@
4 4
5obj-y := init.o cache.o misc.o 5obj-y := init.o cache.o misc.o
6obj-$(CONFIG_MMU) += fault.o mmu.o tlb.o 6obj-$(CONFIG_MMU) += fault.o mmu.o tlb.o
7obj-$(CONFIG_HIGHMEM) += highmem.o
diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c
index ba4c47f291b1..63cbb867dadd 100644
--- a/arch/xtensa/mm/cache.c
+++ b/arch/xtensa/mm/cache.c
@@ -59,6 +59,10 @@
59 * 59 *
60 */ 60 */
61 61
62#if (DCACHE_WAY_SIZE > PAGE_SIZE) && defined(CONFIG_HIGHMEM)
63#error "HIGHMEM is not supported on cores with aliasing cache."
64#endif
65
62#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK 66#if (DCACHE_WAY_SIZE > PAGE_SIZE) && XCHAL_DCACHE_IS_WRITEBACK
63 67
64/* 68/*
@@ -179,10 +183,11 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)
179#else 183#else
180 if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags) 184 if (!PageReserved(page) && !test_bit(PG_arch_1, &page->flags)
181 && (vma->vm_flags & VM_EXEC) != 0) { 185 && (vma->vm_flags & VM_EXEC) != 0) {
182 unsigned long paddr = (unsigned long) page_address(page); 186 unsigned long paddr = (unsigned long)kmap_atomic(page);
183 __flush_dcache_page(paddr); 187 __flush_dcache_page(paddr);
184 __invalidate_icache_page(paddr); 188 __invalidate_icache_page(paddr);
185 set_bit(PG_arch_1, &page->flags); 189 set_bit(PG_arch_1, &page->flags);
190 kunmap_atomic((void *)paddr);
186 } 191 }
187#endif 192#endif
188} 193}
diff --git a/arch/xtensa/mm/highmem.c b/arch/xtensa/mm/highmem.c
new file mode 100644
index 000000000000..17a8c0d6fd17
--- /dev/null
+++ b/arch/xtensa/mm/highmem.c
@@ -0,0 +1,72 @@
1/*
2 * High memory support for Xtensa architecture
3 *
4 * This file is subject to the terms and conditions of the GNU General
5 * Public License. See the file "COPYING" in the main directory of
6 * this archive for more details.
7 *
8 * Copyright (C) 2014 Cadence Design Systems Inc.
9 */
10
11#include <linux/export.h>
12#include <linux/highmem.h>
13#include <asm/tlbflush.h>
14
15static pte_t *kmap_pte;
16
17void *kmap_atomic(struct page *page)
18{
19 enum fixed_addresses idx;
20 unsigned long vaddr;
21 int type;
22
23 pagefault_disable();
24 if (!PageHighMem(page))
25 return page_address(page);
26
27 type = kmap_atomic_idx_push();
28 idx = type + KM_TYPE_NR * smp_processor_id();
29 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30#ifdef CONFIG_DEBUG_HIGHMEM
31 BUG_ON(!pte_none(*(kmap_pte - idx)));
32#endif
33 set_pte(kmap_pte - idx, mk_pte(page, PAGE_KERNEL_EXEC));
34
35 return (void *)vaddr;
36}
37EXPORT_SYMBOL(kmap_atomic);
38
39void __kunmap_atomic(void *kvaddr)
40{
41 int idx, type;
42
43 if (kvaddr >= (void *)FIXADDR_START &&
44 kvaddr < (void *)FIXADDR_TOP) {
45 type = kmap_atomic_idx();
46 idx = type + KM_TYPE_NR * smp_processor_id();
47
48 /*
49 * Force other mappings to Oops if they'll try to access this
50 * pte without first remap it. Keeping stale mappings around
51 * is a bad idea also, in case the page changes cacheability
52 * attributes or becomes a protected page in a hypervisor.
53 */
54 pte_clear(&init_mm, kvaddr, kmap_pte - idx);
55 local_flush_tlb_kernel_range((unsigned long)kvaddr,
56 (unsigned long)kvaddr + PAGE_SIZE);
57
58 kmap_atomic_idx_pop();
59 }
60
61 pagefault_enable();
62}
63EXPORT_SYMBOL(__kunmap_atomic);
64
65void __init kmap_init(void)
66{
67 unsigned long kmap_vstart;
68
69 /* cache the first kmap pte */
70 kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
71 kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
72}
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index aff108df92d3..4224256bb215 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -8,6 +8,7 @@
8 * for more details. 8 * for more details.
9 * 9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc. 10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 * Copyright (C) 2014 Cadence Design Systems Inc.
11 * 12 *
12 * Chris Zankel <chris@zankel.net> 13 * Chris Zankel <chris@zankel.net>
13 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com> 14 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
@@ -19,6 +20,7 @@
19#include <linux/errno.h> 20#include <linux/errno.h>
20#include <linux/bootmem.h> 21#include <linux/bootmem.h>
21#include <linux/gfp.h> 22#include <linux/gfp.h>
23#include <linux/highmem.h>
22#include <linux/swap.h> 24#include <linux/swap.h>
23#include <linux/mman.h> 25#include <linux/mman.h>
24#include <linux/nodemask.h> 26#include <linux/nodemask.h>
@@ -27,11 +29,133 @@
27#include <asm/bootparam.h> 29#include <asm/bootparam.h>
28#include <asm/page.h> 30#include <asm/page.h>
29#include <asm/sections.h> 31#include <asm/sections.h>
32#include <asm/sysmem.h>
33
34struct sysmem_info sysmem __initdata;
35
36static void __init sysmem_dump(void)
37{
38 unsigned i;
39
40 pr_debug("Sysmem:\n");
41 for (i = 0; i < sysmem.nr_banks; ++i)
42 pr_debug(" 0x%08lx - 0x%08lx (%ldK)\n",
43 sysmem.bank[i].start, sysmem.bank[i].end,
44 (sysmem.bank[i].end - sysmem.bank[i].start) >> 10);
45}
46
47/*
48 * Find bank with maximal .start such that bank.start <= start
49 */
50static inline struct meminfo * __init find_bank(unsigned long start)
51{
52 unsigned i;
53 struct meminfo *it = NULL;
54
55 for (i = 0; i < sysmem.nr_banks; ++i)
56 if (sysmem.bank[i].start <= start)
57 it = sysmem.bank + i;
58 else
59 break;
60 return it;
61}
62
63/*
64 * Move all memory banks starting at 'from' to a new place at 'to',
65 * adjust nr_banks accordingly.
66 * Both 'from' and 'to' must be inside the sysmem.bank.
67 *
68 * Returns: 0 (success), -ENOMEM (not enough space in the sysmem.bank).
69 */
70static int __init move_banks(struct meminfo *to, struct meminfo *from)
71{
72 unsigned n = sysmem.nr_banks - (from - sysmem.bank);
73
74 if (to > from && to - from + sysmem.nr_banks > SYSMEM_BANKS_MAX)
75 return -ENOMEM;
76 if (to != from)
77 memmove(to, from, n * sizeof(struct meminfo));
78 sysmem.nr_banks += to - from;
79 return 0;
80}
81
82/*
83 * Add new bank to sysmem. Resulting sysmem is the union of bytes of the
84 * original sysmem and the new bank.
85 *
86 * Returns: 0 (success), < 0 (error)
87 */
88int __init add_sysmem_bank(unsigned long start, unsigned long end)
89{
90 unsigned i;
91 struct meminfo *it = NULL;
92 unsigned long sz;
93 unsigned long bank_sz = 0;
94
95 if (start == end ||
96 (start < end) != (PAGE_ALIGN(start) < (end & PAGE_MASK))) {
97 pr_warn("Ignoring small memory bank 0x%08lx size: %ld bytes\n",
98 start, end - start);
99 return -EINVAL;
100 }
101
102 start = PAGE_ALIGN(start);
103 end &= PAGE_MASK;
104 sz = end - start;
105
106 it = find_bank(start);
107
108 if (it)
109 bank_sz = it->end - it->start;
110
111 if (it && bank_sz >= start - it->start) {
112 if (end - it->start > bank_sz)
113 it->end = end;
114 else
115 return 0;
116 } else {
117 if (!it)
118 it = sysmem.bank;
119 else
120 ++it;
121
122 if (it - sysmem.bank < sysmem.nr_banks &&
123 it->start - start <= sz) {
124 it->start = start;
125 if (it->end - it->start < sz)
126 it->end = end;
127 else
128 return 0;
129 } else {
130 if (move_banks(it + 1, it) < 0) {
131 pr_warn("Ignoring memory bank 0x%08lx size %ld bytes\n",
132 start, end - start);
133 return -EINVAL;
134 }
135 it->start = start;
136 it->end = end;
137 return 0;
138 }
139 }
140 sz = it->end - it->start;
141 for (i = it + 1 - sysmem.bank; i < sysmem.nr_banks; ++i)
142 if (sysmem.bank[i].start - it->start <= sz) {
143 if (sz < sysmem.bank[i].end - it->start)
144 it->end = sysmem.bank[i].end;
145 } else {
146 break;
147 }
148
149 move_banks(it + 1, sysmem.bank + i);
150 return 0;
151}
30 152
31/* 153/*
32 * mem_reserve(start, end, must_exist) 154 * mem_reserve(start, end, must_exist)
33 * 155 *
34 * Reserve some memory from the memory pool. 156 * Reserve some memory from the memory pool.
157 * If must_exist is set and a part of the region being reserved does not exist
158 * memory map is not altered.
35 * 159 *
36 * Parameters: 160 * Parameters:
37 * start Start of region, 161 * start Start of region,
@@ -39,53 +163,69 @@
39 * must_exist Must exist in memory pool. 163 * must_exist Must exist in memory pool.
40 * 164 *
41 * Returns: 165 * Returns:
42 * 0 (memory area couldn't be mapped) 166 * 0 (success)
43 * -1 (success) 167 * < 0 (error)
44 */ 168 */
45 169
46int __init mem_reserve(unsigned long start, unsigned long end, int must_exist) 170int __init mem_reserve(unsigned long start, unsigned long end, int must_exist)
47{ 171{
48 int i; 172 struct meminfo *it;
49 173 struct meminfo *rm = NULL;
50 if (start == end) 174 unsigned long sz;
51 return 0; 175 unsigned long bank_sz = 0;
52 176
53 start = start & PAGE_MASK; 177 start = start & PAGE_MASK;
54 end = PAGE_ALIGN(end); 178 end = PAGE_ALIGN(end);
179 sz = end - start;
180 if (!sz)
181 return -EINVAL;
55 182
56 for (i = 0; i < sysmem.nr_banks; i++) 183 it = find_bank(start);
57 if (start < sysmem.bank[i].end 184
58 && end >= sysmem.bank[i].start) 185 if (it)
59 break; 186 bank_sz = it->end - it->start;
60 187
61 if (i == sysmem.nr_banks) { 188 if ((!it || end - it->start > bank_sz) && must_exist) {
62 if (must_exist) 189 pr_warn("mem_reserve: [0x%0lx, 0x%0lx) not in any region!\n",
63 printk (KERN_WARNING "mem_reserve: [0x%0lx, 0x%0lx) " 190 start, end);
64 "not in any region!\n", start, end); 191 return -EINVAL;
65 return 0;
66 } 192 }
67 193
68 if (start > sysmem.bank[i].start) { 194 if (it && start - it->start < bank_sz) {
69 if (end < sysmem.bank[i].end) { 195 if (start == it->start) {
70 /* split entry */ 196 if (end - it->start < bank_sz) {
71 if (sysmem.nr_banks >= SYSMEM_BANKS_MAX) 197 it->start = end;
72 panic("meminfo overflow\n"); 198 return 0;
73 sysmem.bank[sysmem.nr_banks].start = end; 199 } else {
74 sysmem.bank[sysmem.nr_banks].end = sysmem.bank[i].end; 200 rm = it;
75 sysmem.nr_banks++; 201 }
202 } else {
203 it->end = start;
204 if (end - it->start < bank_sz)
205 return add_sysmem_bank(end,
206 it->start + bank_sz);
207 ++it;
76 } 208 }
77 sysmem.bank[i].end = start; 209 }
78 210
79 } else if (end < sysmem.bank[i].end) { 211 if (!it)
80 sysmem.bank[i].start = end; 212 it = sysmem.bank;
81 213
82 } else { 214 for (; it < sysmem.bank + sysmem.nr_banks; ++it) {
83 /* remove entry */ 215 if (it->end - start <= sz) {
84 sysmem.nr_banks--; 216 if (!rm)
85 sysmem.bank[i].start = sysmem.bank[sysmem.nr_banks].start; 217 rm = it;
86 sysmem.bank[i].end = sysmem.bank[sysmem.nr_banks].end; 218 } else {
219 if (it->start - start < sz)
220 it->start = end;
221 break;
222 }
87 } 223 }
88 return -1; 224
225 if (rm)
226 move_banks(rm, it);
227
228 return 0;
89} 229}
90 230
91 231
@@ -99,6 +239,7 @@ void __init bootmem_init(void)
99 unsigned long bootmap_start, bootmap_size; 239 unsigned long bootmap_start, bootmap_size;
100 int i; 240 int i;
101 241
242 sysmem_dump();
102 max_low_pfn = max_pfn = 0; 243 max_low_pfn = max_pfn = 0;
103 min_low_pfn = ~0; 244 min_low_pfn = ~0;
104 245
@@ -156,19 +297,13 @@ void __init bootmem_init(void)
156 297
157void __init zones_init(void) 298void __init zones_init(void)
158{ 299{
159 unsigned long zones_size[MAX_NR_ZONES];
160 int i;
161
162 /* All pages are DMA-able, so we put them all in the DMA zone. */ 300 /* All pages are DMA-able, so we put them all in the DMA zone. */
163 301 unsigned long zones_size[MAX_NR_ZONES] = {
164 zones_size[ZONE_DMA] = max_low_pfn - ARCH_PFN_OFFSET; 302 [ZONE_DMA] = max_low_pfn - ARCH_PFN_OFFSET,
165 for (i = 1; i < MAX_NR_ZONES; i++)
166 zones_size[i] = 0;
167
168#ifdef CONFIG_HIGHMEM 303#ifdef CONFIG_HIGHMEM
169 zones_size[ZONE_HIGHMEM] = max_pfn - max_low_pfn; 304 [ZONE_HIGHMEM] = max_pfn - max_low_pfn,
170#endif 305#endif
171 306 };
172 free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL); 307 free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL);
173} 308}
174 309
@@ -178,16 +313,38 @@ void __init zones_init(void)
178 313
179void __init mem_init(void) 314void __init mem_init(void)
180{ 315{
181 max_mapnr = max_low_pfn - ARCH_PFN_OFFSET;
182 high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
183
184#ifdef CONFIG_HIGHMEM 316#ifdef CONFIG_HIGHMEM
185#error HIGHGMEM not implemented in init.c 317 unsigned long tmp;
318
319 reset_all_zones_managed_pages();
320 for (tmp = max_low_pfn; tmp < max_pfn; tmp++)
321 free_highmem_page(pfn_to_page(tmp));
186#endif 322#endif
187 323
324 max_mapnr = max_pfn - ARCH_PFN_OFFSET;
325 high_memory = (void *)__va(max_low_pfn << PAGE_SHIFT);
326
188 free_all_bootmem(); 327 free_all_bootmem();
189 328
190 mem_init_print_info(NULL); 329 mem_init_print_info(NULL);
330 pr_info("virtual kernel memory layout:\n"
331#ifdef CONFIG_HIGHMEM
332 " pkmap : 0x%08lx - 0x%08lx (%5lu kB)\n"
333 " fixmap : 0x%08lx - 0x%08lx (%5lu kB)\n"
334#endif
335 " vmalloc : 0x%08x - 0x%08x (%5u MB)\n"
336 " lowmem : 0x%08x - 0x%08lx (%5lu MB)\n",
337#ifdef CONFIG_HIGHMEM
338 PKMAP_BASE, PKMAP_BASE + LAST_PKMAP * PAGE_SIZE,
339 (LAST_PKMAP*PAGE_SIZE) >> 10,
340 FIXADDR_START, FIXADDR_TOP,
341 (FIXADDR_TOP - FIXADDR_START) >> 10,
342#endif
343 VMALLOC_START, VMALLOC_END,
344 (VMALLOC_END - VMALLOC_START) >> 20,
345 PAGE_OFFSET, PAGE_OFFSET +
346 (max_low_pfn - min_low_pfn) * PAGE_SIZE,
347 ((max_low_pfn - min_low_pfn) * PAGE_SIZE) >> 20);
191} 348}
192 349
193#ifdef CONFIG_BLK_DEV_INITRD 350#ifdef CONFIG_BLK_DEV_INITRD
@@ -204,3 +361,53 @@ void free_initmem(void)
204{ 361{
205 free_initmem_default(-1); 362 free_initmem_default(-1);
206} 363}
364
365static void __init parse_memmap_one(char *p)
366{
367 char *oldp;
368 unsigned long start_at, mem_size;
369
370 if (!p)
371 return;
372
373 oldp = p;
374 mem_size = memparse(p, &p);
375 if (p == oldp)
376 return;
377
378 switch (*p) {
379 case '@':
380 start_at = memparse(p + 1, &p);
381 add_sysmem_bank(start_at, start_at + mem_size);
382 break;
383
384 case '$':
385 start_at = memparse(p + 1, &p);
386 mem_reserve(start_at, start_at + mem_size, 0);
387 break;
388
389 case 0:
390 mem_reserve(mem_size, 0, 0);
391 break;
392
393 default:
394 pr_warn("Unrecognized memmap syntax: %s\n", p);
395 break;
396 }
397}
398
399static int __init parse_memmap_opt(char *str)
400{
401 while (str) {
402 char *k = strchr(str, ',');
403
404 if (k)
405 *k++ = 0;
406
407 parse_memmap_one(str);
408 str = k;
409 }
410
411 return 0;
412}
413early_param("memmap", parse_memmap_opt);
diff --git a/arch/xtensa/mm/mmu.c b/arch/xtensa/mm/mmu.c
index 861203e958da..3429b483d9f8 100644
--- a/arch/xtensa/mm/mmu.c
+++ b/arch/xtensa/mm/mmu.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Extracted from init.c 4 * Extracted from init.c
5 */ 5 */
6#include <linux/bootmem.h>
6#include <linux/percpu.h> 7#include <linux/percpu.h>
7#include <linux/init.h> 8#include <linux/init.h>
8#include <linux/string.h> 9#include <linux/string.h>
@@ -16,9 +17,44 @@
16#include <asm/initialize_mmu.h> 17#include <asm/initialize_mmu.h>
17#include <asm/io.h> 18#include <asm/io.h>
18 19
20#if defined(CONFIG_HIGHMEM)
21static void * __init init_pmd(unsigned long vaddr)
22{
23 pgd_t *pgd = pgd_offset_k(vaddr);
24 pmd_t *pmd = pmd_offset(pgd, vaddr);
25
26 if (pmd_none(*pmd)) {
27 unsigned i;
28 pte_t *pte = alloc_bootmem_low_pages(PAGE_SIZE);
29
30 for (i = 0; i < 1024; i++)
31 pte_clear(NULL, 0, pte + i);
32
33 set_pmd(pmd, __pmd(((unsigned long)pte) & PAGE_MASK));
34 BUG_ON(pte != pte_offset_kernel(pmd, 0));
35 pr_debug("%s: vaddr: 0x%08lx, pmd: 0x%p, pte: 0x%p\n",
36 __func__, vaddr, pmd, pte);
37 return pte;
38 } else {
39 return pte_offset_kernel(pmd, 0);
40 }
41}
42
43static void __init fixedrange_init(void)
44{
45 BUILD_BUG_ON(FIXADDR_SIZE > PMD_SIZE);
46 init_pmd(__fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK);
47}
48#endif
49
19void __init paging_init(void) 50void __init paging_init(void)
20{ 51{
21 memset(swapper_pg_dir, 0, PAGE_SIZE); 52 memset(swapper_pg_dir, 0, PAGE_SIZE);
53#ifdef CONFIG_HIGHMEM
54 fixedrange_init();
55 pkmap_page_table = init_pmd(PKMAP_BASE);
56 kmap_init();
57#endif
22} 58}
23 59
24/* 60/*
diff --git a/arch/xtensa/mm/tlb.c b/arch/xtensa/mm/tlb.c
index ade623826788..5ece856c5725 100644
--- a/arch/xtensa/mm/tlb.c
+++ b/arch/xtensa/mm/tlb.c
@@ -149,6 +149,21 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
149 local_irq_restore(flags); 149 local_irq_restore(flags);
150} 150}
151 151
152void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
153{
154 if (end > start && start >= TASK_SIZE && end <= PAGE_OFFSET &&
155 end - start < _TLB_ENTRIES << PAGE_SHIFT) {
156 start &= PAGE_MASK;
157 while (start < end) {
158 invalidate_itlb_mapping(start);
159 invalidate_dtlb_mapping(start);
160 start += PAGE_SIZE;
161 }
162 } else {
163 local_flush_tlb_all();
164 }
165}
166
152#ifdef CONFIG_DEBUG_TLB_SANITY 167#ifdef CONFIG_DEBUG_TLB_SANITY
153 168
154static unsigned get_pte_for_vaddr(unsigned vaddr) 169static unsigned get_pte_for_vaddr(unsigned vaddr)
diff --git a/arch/xtensa/platforms/iss/Makefile b/arch/xtensa/platforms/iss/Makefile
index d2369b799c50..b3e89291cfba 100644
--- a/arch/xtensa/platforms/iss/Makefile
+++ b/arch/xtensa/platforms/iss/Makefile
@@ -4,6 +4,7 @@
4# "prom monitor" library routines under Linux. 4# "prom monitor" library routines under Linux.
5# 5#
6 6
7obj-y = console.o setup.o 7obj-y = setup.o
8obj-$(CONFIG_TTY) += console.o
8obj-$(CONFIG_NET) += network.o 9obj-$(CONFIG_NET) += network.o
9obj-$(CONFIG_BLK_DEV_SIMDISK) += simdisk.o 10obj-$(CONFIG_BLK_DEV_SIMDISK) += simdisk.o
diff --git a/arch/xtensa/platforms/xt2000/setup.c b/arch/xtensa/platforms/xt2000/setup.c
index f9bc87966290..b90555cb8089 100644
--- a/arch/xtensa/platforms/xt2000/setup.c
+++ b/arch/xtensa/platforms/xt2000/setup.c
@@ -92,18 +92,8 @@ void __init platform_setup(char** cmdline)
92 92
93/* early initialization */ 93/* early initialization */
94 94
95extern sysmem_info_t __initdata sysmem; 95void __init platform_init(bp_tag_t *first)
96
97void platform_init(bp_tag_t* first)
98{ 96{
99 /* Set default memory block if not provided by the bootloader. */
100
101 if (sysmem.nr_banks == 0) {
102 sysmem.nr_banks = 1;
103 sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;
104 sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START
105 + PLATFORM_DEFAULT_MEM_SIZE;
106 }
107} 97}
108 98
109/* Heartbeat. Let the LED blink. */ 99/* Heartbeat. Let the LED blink. */
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 1512e41cd93d..43665d0d0905 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -466,7 +466,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
466 type -= CRYPTO_MSG_BASE; 466 type -= CRYPTO_MSG_BASE;
467 link = &crypto_dispatch[type]; 467 link = &crypto_dispatch[type];
468 468
469 if (!capable(CAP_NET_ADMIN)) 469 if (!netlink_capable(skb, CAP_NET_ADMIN))
470 return -EPERM; 470 return -EPERM;
471 471
472 if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) && 472 if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) &&
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index c29c2c3ec0ad..b06f5f55ada9 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,6 +170,9 @@ 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)
174 return -ENODEV;
175
173 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); 176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
174 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) 177 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
175 return -ENODEV; 178 return -ENODEV;
@@ -260,10 +263,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
260 } 263 }
261 264
262 apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id); 265 apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
263 if (apic_id < 0) { 266 if (apic_id < 0)
264 acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n"); 267 acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
265 return -ENODEV;
266 }
267 pr->apic_id = apic_id; 268 pr->apic_id = apic_id;
268 269
269 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id); 270 cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c
index 68d97441432c..12878e1982f7 100644
--- a/drivers/acpi/acpica/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -45,10 +45,71 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acdispat.h" 46#include "acdispat.h"
47#include "acinterp.h" 47#include "acinterp.h"
48#include "amlcode.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exfield") 51ACPI_MODULE_NAME("exfield")
51 52
53/* Local prototypes */
54static u32
55acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length);
56
57/*******************************************************************************
58 *
59 * FUNCTION: acpi_get_serial_access_bytes
60 *
61 * PARAMETERS: accessor_type - The type of the protocol indicated by region
62 * field access attributes
63 * access_length - The access length of the region field
64 *
65 * RETURN: Decoded access length
66 *
67 * DESCRIPTION: This routine returns the length of the generic_serial_bus
68 * protocol bytes
69 *
70 ******************************************************************************/
71
72static u32
73acpi_ex_get_serial_access_length(u32 accessor_type, u32 access_length)
74{
75 u32 length;
76
77 switch (accessor_type) {
78 case AML_FIELD_ATTRIB_QUICK:
79
80 length = 0;
81 break;
82
83 case AML_FIELD_ATTRIB_SEND_RCV:
84 case AML_FIELD_ATTRIB_BYTE:
85
86 length = 1;
87 break;
88
89 case AML_FIELD_ATTRIB_WORD:
90 case AML_FIELD_ATTRIB_WORD_CALL:
91
92 length = 2;
93 break;
94
95 case AML_FIELD_ATTRIB_MULTIBYTE:
96 case AML_FIELD_ATTRIB_RAW_BYTES:
97 case AML_FIELD_ATTRIB_RAW_PROCESS:
98
99 length = access_length;
100 break;
101
102 case AML_FIELD_ATTRIB_BLOCK:
103 case AML_FIELD_ATTRIB_BLOCK_CALL:
104 default:
105
106 length = ACPI_GSBUS_BUFFER_SIZE;
107 break;
108 }
109
110 return (length);
111}
112
52/******************************************************************************* 113/*******************************************************************************
53 * 114 *
54 * FUNCTION: acpi_ex_read_data_from_field 115 * FUNCTION: acpi_ex_read_data_from_field
@@ -63,8 +124,9 @@ ACPI_MODULE_NAME("exfield")
63 * Buffer, depending on the size of the field. 124 * Buffer, depending on the size of the field.
64 * 125 *
65 ******************************************************************************/ 126 ******************************************************************************/
127
66acpi_status 128acpi_status
67acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state, 129acpi_ex_read_data_from_field(struct acpi_walk_state * walk_state,
68 union acpi_operand_object *obj_desc, 130 union acpi_operand_object *obj_desc,
69 union acpi_operand_object **ret_buffer_desc) 131 union acpi_operand_object **ret_buffer_desc)
70{ 132{
@@ -73,6 +135,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
73 acpi_size length; 135 acpi_size length;
74 void *buffer; 136 void *buffer;
75 u32 function; 137 u32 function;
138 u16 accessor_type;
76 139
77 ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc); 140 ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
78 141
@@ -116,9 +179,22 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
116 ACPI_READ | (obj_desc->field.attribute << 16); 179 ACPI_READ | (obj_desc->field.attribute << 16);
117 } else if (obj_desc->field.region_obj->region.space_id == 180 } else if (obj_desc->field.region_obj->region.space_id ==
118 ACPI_ADR_SPACE_GSBUS) { 181 ACPI_ADR_SPACE_GSBUS) {
119 length = ACPI_GSBUS_BUFFER_SIZE; 182 accessor_type = obj_desc->field.attribute;
120 function = 183 length = acpi_ex_get_serial_access_length(accessor_type,
121 ACPI_READ | (obj_desc->field.attribute << 16); 184 obj_desc->
185 field.
186 access_length);
187
188 /*
189 * Add additional 2 bytes for modeled generic_serial_bus data buffer:
190 * typedef struct {
191 * BYTEStatus; // Byte 0 of the data buffer
192 * BYTELength; // Byte 1 of the data buffer
193 * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer,
194 * }
195 */
196 length += 2;
197 function = ACPI_READ | (accessor_type << 16);
122 } else { /* IPMI */ 198 } else { /* IPMI */
123 199
124 length = ACPI_IPMI_BUFFER_SIZE; 200 length = ACPI_IPMI_BUFFER_SIZE;
@@ -231,6 +307,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
231 void *buffer; 307 void *buffer;
232 union acpi_operand_object *buffer_desc; 308 union acpi_operand_object *buffer_desc;
233 u32 function; 309 u32 function;
310 u16 accessor_type;
234 311
235 ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc); 312 ACPI_FUNCTION_TRACE_PTR(ex_write_data_to_field, obj_desc);
236 313
@@ -284,9 +361,22 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
284 ACPI_WRITE | (obj_desc->field.attribute << 16); 361 ACPI_WRITE | (obj_desc->field.attribute << 16);
285 } else if (obj_desc->field.region_obj->region.space_id == 362 } else if (obj_desc->field.region_obj->region.space_id ==
286 ACPI_ADR_SPACE_GSBUS) { 363 ACPI_ADR_SPACE_GSBUS) {
287 length = ACPI_GSBUS_BUFFER_SIZE; 364 accessor_type = obj_desc->field.attribute;
288 function = 365 length = acpi_ex_get_serial_access_length(accessor_type,
289 ACPI_WRITE | (obj_desc->field.attribute << 16); 366 obj_desc->
367 field.
368 access_length);
369
370 /*
371 * Add additional 2 bytes for modeled generic_serial_bus data buffer:
372 * typedef struct {
373 * BYTEStatus; // Byte 0 of the data buffer
374 * BYTELength; // Byte 1 of the data buffer
375 * BYTE[x-1]Data; // Bytes 2-x of the arbitrary length data buffer,
376 * }
377 */
378 length += 2;
379 function = ACPI_WRITE | (accessor_type << 16);
290 } else { /* IPMI */ 380 } else { /* IPMI */
291 381
292 length = ACPI_IPMI_BUFFER_SIZE; 382 length = ACPI_IPMI_BUFFER_SIZE;
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e7e5844c87d0..cf925c4f36b7 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -380,9 +380,8 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
380 break; 380 break;
381 381
382 default: 382 default:
383 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type); 383 acpi_handle_debug(handle, "Unknown event type 0x%x\n", type);
384 ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY; 384 break;
385 goto err;
386 } 385 }
387 386
388 adev = acpi_bus_get_acpi_device(handle); 387 adev = acpi_bus_get_acpi_device(handle);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index d7d32c28829b..ad11ba4a412d 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -206,13 +206,13 @@ unlock:
206 spin_unlock_irqrestore(&ec->lock, flags); 206 spin_unlock_irqrestore(&ec->lock, flags);
207} 207}
208 208
209static int acpi_ec_sync_query(struct acpi_ec *ec); 209static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data);
210 210
211static int ec_check_sci_sync(struct acpi_ec *ec, u8 state) 211static int ec_check_sci_sync(struct acpi_ec *ec, u8 state)
212{ 212{
213 if (state & ACPI_EC_FLAG_SCI) { 213 if (state & ACPI_EC_FLAG_SCI) {
214 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) 214 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
215 return acpi_ec_sync_query(ec); 215 return acpi_ec_sync_query(ec, NULL);
216 } 216 }
217 return 0; 217 return 0;
218} 218}
@@ -443,10 +443,8 @@ acpi_handle ec_get_handle(void)
443 443
444EXPORT_SYMBOL(ec_get_handle); 444EXPORT_SYMBOL(ec_get_handle);
445 445
446static int acpi_ec_query_unlocked(struct acpi_ec *ec, u8 *data);
447
448/* 446/*
449 * Clears stale _Q events that might have accumulated in the EC. 447 * Process _Q events that might have accumulated in the EC.
450 * Run with locked ec mutex. 448 * Run with locked ec mutex.
451 */ 449 */
452static void acpi_ec_clear(struct acpi_ec *ec) 450static void acpi_ec_clear(struct acpi_ec *ec)
@@ -455,7 +453,7 @@ static void acpi_ec_clear(struct acpi_ec *ec)
455 u8 value = 0; 453 u8 value = 0;
456 454
457 for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) { 455 for (i = 0; i < ACPI_EC_CLEAR_MAX; i++) {
458 status = acpi_ec_query_unlocked(ec, &value); 456 status = acpi_ec_sync_query(ec, &value);
459 if (status || !value) 457 if (status || !value)
460 break; 458 break;
461 } 459 }
@@ -582,13 +580,18 @@ static void acpi_ec_run(void *cxt)
582 kfree(handler); 580 kfree(handler);
583} 581}
584 582
585static int acpi_ec_sync_query(struct acpi_ec *ec) 583static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data)
586{ 584{
587 u8 value = 0; 585 u8 value = 0;
588 int status; 586 int status;
589 struct acpi_ec_query_handler *handler, *copy; 587 struct acpi_ec_query_handler *handler, *copy;
590 if ((status = acpi_ec_query_unlocked(ec, &value))) 588
589 status = acpi_ec_query_unlocked(ec, &value);
590 if (data)
591 *data = value;
592 if (status)
591 return status; 593 return status;
594
592 list_for_each_entry(handler, &ec->list, node) { 595 list_for_each_entry(handler, &ec->list, node) {
593 if (value == handler->query_bit) { 596 if (value == handler->query_bit) {
594 /* have custom handler for this bit */ 597 /* have custom handler for this bit */
@@ -612,7 +615,7 @@ static void acpi_ec_gpe_query(void *ec_cxt)
612 if (!ec) 615 if (!ec)
613 return; 616 return;
614 mutex_lock(&ec->mutex); 617 mutex_lock(&ec->mutex);
615 acpi_ec_sync_query(ec); 618 acpi_ec_sync_query(ec, NULL);
616 mutex_unlock(&ec->mutex); 619 mutex_unlock(&ec->mutex);
617} 620}
618 621
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 20e03a7eb8b4..c2706047337f 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -116,7 +116,7 @@ config AHCI_ST
116 116
117config AHCI_IMX 117config AHCI_IMX
118 tristate "Freescale i.MX AHCI SATA support" 118 tristate "Freescale i.MX AHCI SATA support"
119 depends on MFD_SYSCON 119 depends on MFD_SYSCON && (ARCH_MXC || COMPILE_TEST)
120 help 120 help
121 This option enables support for the Freescale i.MX SoC's 121 This option enables support for the Freescale i.MX SoC's
122 onboard AHCI SATA. 122 onboard AHCI SATA.
@@ -134,8 +134,7 @@ config AHCI_SUNXI
134 134
135config AHCI_XGENE 135config AHCI_XGENE
136 tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support" 136 tristate "APM X-Gene 6.0Gbps AHCI SATA host controller support"
137 depends on ARM64 || COMPILE_TEST 137 depends on PHY_XGENE
138 select PHY_XGENE
139 help 138 help
140 This option enables support for APM X-Gene SoC SATA host controller. 139 This option enables support for APM X-Gene SoC SATA host controller.
141 140
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5a0bf8ed649b..71e15b73513d 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1164,9 +1164,9 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
1164#endif 1164#endif
1165 1165
1166static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports, 1166static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
1167 struct ahci_host_priv *hpriv) 1167 struct ahci_host_priv *hpriv)
1168{ 1168{
1169 int nvec; 1169 int rc, nvec;
1170 1170
1171 if (hpriv->flags & AHCI_HFLAG_NO_MSI) 1171 if (hpriv->flags & AHCI_HFLAG_NO_MSI)
1172 goto intx; 1172 goto intx;
@@ -1183,12 +1183,19 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
1183 if (nvec < n_ports) 1183 if (nvec < n_ports)
1184 goto single_msi; 1184 goto single_msi;
1185 1185
1186 nvec = pci_enable_msi_range(pdev, nvec, nvec); 1186 rc = pci_enable_msi_exact(pdev, nvec);
1187 if (nvec == -ENOSPC) 1187 if (rc == -ENOSPC)
1188 goto single_msi; 1188 goto single_msi;
1189 else if (nvec < 0) 1189 else if (rc < 0)
1190 goto intx; 1190 goto intx;
1191 1191
1192 /* fallback to single MSI mode if the controller enforced MRSM mode */
1193 if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) {
1194 pci_disable_msi(pdev);
1195 printk(KERN_INFO "ahci: MRSM is on, fallback to single MSI\n");
1196 goto single_msi;
1197 }
1198
1192 return nvec; 1199 return nvec;
1193 1200
1194single_msi: 1201single_msi:
@@ -1232,18 +1239,18 @@ int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
1232 return rc; 1239 return rc;
1233 1240
1234 for (i = 0; i < host->n_ports; i++) { 1241 for (i = 0; i < host->n_ports; i++) {
1235 const char* desc;
1236 struct ahci_port_priv *pp = host->ports[i]->private_data; 1242 struct ahci_port_priv *pp = host->ports[i]->private_data;
1237 1243
1238 /* pp is NULL for dummy ports */ 1244 /* Do not receive interrupts sent by dummy ports */
1239 if (pp) 1245 if (!pp) {
1240 desc = pp->irq_desc; 1246 disable_irq(irq + i);
1241 else 1247 continue;
1242 desc = dev_driver_string(host->dev); 1248 }
1243 1249
1244 rc = devm_request_threaded_irq(host->dev, 1250 rc = devm_request_threaded_irq(host->dev, irq + i,
1245 irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED, 1251 ahci_hw_interrupt,
1246 desc, host->ports[i]); 1252 ahci_thread_fn, IRQF_SHARED,
1253 pp->irq_desc, host->ports[i]);
1247 if (rc) 1254 if (rc)
1248 goto out_free_irqs; 1255 goto out_free_irqs;
1249 } 1256 }
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 51af275b3388..b5eb886da226 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -94,6 +94,7 @@ enum {
94 /* HOST_CTL bits */ 94 /* HOST_CTL bits */
95 HOST_RESET = (1 << 0), /* reset controller; self-clear */ 95 HOST_RESET = (1 << 0), /* reset controller; self-clear */
96 HOST_IRQ_EN = (1 << 1), /* global IRQ enable */ 96 HOST_IRQ_EN = (1 << 1), /* global IRQ enable */
97 HOST_MRSM = (1 << 2), /* MSI Revert to Single Message */
97 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ 98 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
98 99
99 /* HOST_CAP bits */ 100 /* HOST_CAP bits */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c19734d96d7e..943cc8b83e59 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4224,8 +4224,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4224 { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, 4224 { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },
4225 4225
4226 /* devices that don't properly handle queued TRIM commands */ 4226 /* devices that don't properly handle queued TRIM commands */
4227 { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, 4227 { "Micron_M500*", "MU0[1-4]*", ATA_HORKAGE_NO_NCQ_TRIM, },
4228 { "Crucial_CT???M500SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, }, 4228 { "Crucial_CT???M500SSD*", "MU0[1-4]*", ATA_HORKAGE_NO_NCQ_TRIM, },
4229 { "Micron_M550*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
4230 { "Crucial_CT???M550SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
4229 4231
4230 /* 4232 /*
4231 * Some WD SATA-I drives spin up and down erratically when the link 4233 * Some WD SATA-I drives spin up and down erratically when the link
@@ -4792,21 +4794,26 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
4792static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) 4794static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
4793{ 4795{
4794 struct ata_queued_cmd *qc = NULL; 4796 struct ata_queued_cmd *qc = NULL;
4795 unsigned int i; 4797 unsigned int i, tag;
4796 4798
4797 /* no command while frozen */ 4799 /* no command while frozen */
4798 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) 4800 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
4799 return NULL; 4801 return NULL;
4800 4802
4801 /* the last tag is reserved for internal command. */ 4803 for (i = 0; i < ATA_MAX_QUEUE; i++) {
4802 for (i = 0; i < ATA_MAX_QUEUE - 1; i++) 4804 tag = (i + ap->last_tag + 1) % ATA_MAX_QUEUE;
4803 if (!test_and_set_bit(i, &ap->qc_allocated)) { 4805
4804 qc = __ata_qc_from_tag(ap, i); 4806 /* the last tag is reserved for internal command. */
4807 if (tag == ATA_TAG_INTERNAL)
4808 continue;
4809
4810 if (!test_and_set_bit(tag, &ap->qc_allocated)) {
4811 qc = __ata_qc_from_tag(ap, tag);
4812 qc->tag = tag;
4813 ap->last_tag = tag;
4805 break; 4814 break;
4806 } 4815 }
4807 4816 }
4808 if (qc)
4809 qc->tag = i;
4810 4817
4811 return qc; 4818 return qc;
4812} 4819}
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 6fac524c2f50..4edb1a81f63f 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -898,9 +898,12 @@ static int arasan_cf_probe(struct platform_device *pdev)
898 898
899 cf_card_detect(acdev, 0); 899 cf_card_detect(acdev, 0);
900 900
901 return ata_host_activate(host, acdev->irq, irq_handler, 0, 901 ret = ata_host_activate(host, acdev->irq, irq_handler, 0,
902 &arasan_cf_sht); 902 &arasan_cf_sht);
903 if (!ret)
904 return 0;
903 905
906 cf_exit(acdev);
904free_clk: 907free_clk:
905 clk_put(acdev->clk); 908 clk_put(acdev->clk);
906 return ret; 909 return ret;
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index e9c87274a781..8a66f23af4c4 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -407,12 +407,13 @@ static int pata_at91_probe(struct platform_device *pdev)
407 407
408 host->private_data = info; 408 host->private_data = info;
409 409
410 return ata_host_activate(host, gpio_is_valid(irq) ? gpio_to_irq(irq) : 0, 410 ret = ata_host_activate(host, gpio_is_valid(irq) ? gpio_to_irq(irq) : 0,
411 gpio_is_valid(irq) ? ata_sff_interrupt : NULL, 411 gpio_is_valid(irq) ? ata_sff_interrupt : NULL,
412 irq_flags, &pata_at91_sht); 412 irq_flags, &pata_at91_sht);
413 if (ret)
414 goto err_put;
413 415
414 if (!ret) 416 return 0;
415 return 0;
416 417
417err_put: 418err_put:
418 clk_put(info->mck); 419 clk_put(info->mck);
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c
index a79566d05666..0610e78c8a2a 100644
--- a/drivers/ata/pata_samsung_cf.c
+++ b/drivers/ata/pata_samsung_cf.c
@@ -594,9 +594,13 @@ static int __init pata_s3c_probe(struct platform_device *pdev)
594 594
595 platform_set_drvdata(pdev, host); 595 platform_set_drvdata(pdev, host);
596 596
597 return ata_host_activate(host, info->irq, 597 ret = ata_host_activate(host, info->irq,
598 info->irq ? pata_s3c_irq : NULL, 598 info->irq ? pata_s3c_irq : NULL,
599 0, &pata_s3c_sht); 599 0, &pata_s3c_sht);
600 if (ret)
601 goto stop_clk;
602
603 return 0;
600 604
601stop_clk: 605stop_clk:
602 clk_disable(info->clk); 606 clk_disable(info->clk);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 8986b9f22781..62ec61e8f84a 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -52,6 +52,7 @@ static DEFINE_MUTEX(deferred_probe_mutex);
52static LIST_HEAD(deferred_probe_pending_list); 52static LIST_HEAD(deferred_probe_pending_list);
53static LIST_HEAD(deferred_probe_active_list); 53static LIST_HEAD(deferred_probe_active_list);
54static struct workqueue_struct *deferred_wq; 54static struct workqueue_struct *deferred_wq;
55static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
55 56
56/** 57/**
57 * deferred_probe_work_func() - Retry probing devices in the active list. 58 * deferred_probe_work_func() - Retry probing devices in the active list.
@@ -135,6 +136,17 @@ static bool driver_deferred_probe_enable = false;
135 * This functions moves all devices from the pending list to the active 136 * This functions moves all devices from the pending list to the active
136 * list and schedules the deferred probe workqueue to process them. It 137 * list and schedules the deferred probe workqueue to process them. It
137 * should be called anytime a driver is successfully bound to a device. 138 * should be called anytime a driver is successfully bound to a device.
139 *
140 * Note, there is a race condition in multi-threaded probe. In the case where
141 * more than one device is probing at the same time, it is possible for one
142 * probe to complete successfully while another is about to defer. If the second
143 * depends on the first, then it will get put on the pending list after the
144 * trigger event has already occured and will be stuck there.
145 *
146 * The atomic 'deferred_trigger_count' is used to determine if a successful
147 * trigger has occurred in the midst of probing a driver. If the trigger count
148 * changes in the midst of a probe, then deferred processing should be triggered
149 * again.
138 */ 150 */
139static void driver_deferred_probe_trigger(void) 151static void driver_deferred_probe_trigger(void)
140{ 152{
@@ -147,6 +159,7 @@ static void driver_deferred_probe_trigger(void)
147 * into the active list so they can be retried by the workqueue 159 * into the active list so they can be retried by the workqueue
148 */ 160 */
149 mutex_lock(&deferred_probe_mutex); 161 mutex_lock(&deferred_probe_mutex);
162 atomic_inc(&deferred_trigger_count);
150 list_splice_tail_init(&deferred_probe_pending_list, 163 list_splice_tail_init(&deferred_probe_pending_list,
151 &deferred_probe_active_list); 164 &deferred_probe_active_list);
152 mutex_unlock(&deferred_probe_mutex); 165 mutex_unlock(&deferred_probe_mutex);
@@ -265,6 +278,7 @@ static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue);
265static int really_probe(struct device *dev, struct device_driver *drv) 278static int really_probe(struct device *dev, struct device_driver *drv)
266{ 279{
267 int ret = 0; 280 int ret = 0;
281 int local_trigger_count = atomic_read(&deferred_trigger_count);
268 282
269 atomic_inc(&probe_count); 283 atomic_inc(&probe_count);
270 pr_debug("bus: '%s': %s: probing driver %s with device %s\n", 284 pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
@@ -310,6 +324,9 @@ probe_failed:
310 /* Driver requested deferred probing */ 324 /* Driver requested deferred probing */
311 dev_info(dev, "Driver %s requests probe deferral\n", drv->name); 325 dev_info(dev, "Driver %s requests probe deferral\n", drv->name);
312 driver_deferred_probe_add(dev); 326 driver_deferred_probe_add(dev);
327 /* Did a trigger occur while probing? Need to re-trigger if yes */
328 if (local_trigger_count != atomic_read(&deferred_trigger_count))
329 driver_deferred_probe_trigger();
313 } else if (ret != -ENODEV && ret != -ENXIO) { 330 } else if (ret != -ENODEV && ret != -ENXIO) {
314 /* driver matched but the probe failed */ 331 /* driver matched but the probe failed */
315 printk(KERN_WARNING 332 printk(KERN_WARNING
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index e714709704e4..5b47210889e0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -13,6 +13,7 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/of_device.h> 15#include <linux/of_device.h>
16#include <linux/of_irq.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
@@ -87,7 +88,11 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
87 return -ENXIO; 88 return -ENXIO;
88 return dev->archdata.irqs[num]; 89 return dev->archdata.irqs[num];
89#else 90#else
90 struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num); 91 struct resource *r;
92 if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node)
93 return of_irq_get(dev->dev.of_node, num);
94
95 r = platform_get_resource(dev, IORESOURCE_IRQ, num);
91 96
92 return r ? r->start : -ENXIO; 97 return r ? r->start : -ENXIO;
93#endif 98#endif
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 8f5565bf34cd..fa9bb742df6e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3067,7 +3067,10 @@ static int raw_cmd_copyout(int cmd, void __user *param,
3067 int ret; 3067 int ret;
3068 3068
3069 while (ptr) { 3069 while (ptr) {
3070 ret = copy_to_user(param, ptr, sizeof(*ptr)); 3070 struct floppy_raw_cmd cmd = *ptr;
3071 cmd.next = NULL;
3072 cmd.kernel_data = NULL;
3073 ret = copy_to_user(param, &cmd, sizeof(cmd));
3071 if (ret) 3074 if (ret)
3072 return -EFAULT; 3075 return -EFAULT;
3073 param += sizeof(struct floppy_raw_cmd); 3076 param += sizeof(struct floppy_raw_cmd);
@@ -3121,10 +3124,11 @@ loop:
3121 return -ENOMEM; 3124 return -ENOMEM;
3122 *rcmd = ptr; 3125 *rcmd = ptr;
3123 ret = copy_from_user(ptr, param, sizeof(*ptr)); 3126 ret = copy_from_user(ptr, param, sizeof(*ptr));
3124 if (ret)
3125 return -EFAULT;
3126 ptr->next = NULL; 3127 ptr->next = NULL;
3127 ptr->buffer_length = 0; 3128 ptr->buffer_length = 0;
3129 ptr->kernel_data = NULL;
3130 if (ret)
3131 return -EFAULT;
3128 param += sizeof(struct floppy_raw_cmd); 3132 param += sizeof(struct floppy_raw_cmd);
3129 if (ptr->cmd_count > 33) 3133 if (ptr->cmd_count > 33)
3130 /* the command may now also take up the space 3134 /* the command may now also take up the space
@@ -3140,7 +3144,6 @@ loop:
3140 for (i = 0; i < 16; i++) 3144 for (i = 0; i < 16; i++)
3141 ptr->reply[i] = 0; 3145 ptr->reply[i] = 0;
3142 ptr->resultcode = 0; 3146 ptr->resultcode = 0;
3143 ptr->kernel_data = NULL;
3144 3147
3145 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { 3148 if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) {
3146 if (ptr->length <= 0) 3149 if (ptr->length <= 0)
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index be571fef185d..a83b57e57b63 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -82,6 +82,7 @@ static const struct usb_device_id ath3k_table[] = {
82 { USB_DEVICE(0x04CA, 0x3004) }, 82 { USB_DEVICE(0x04CA, 0x3004) },
83 { USB_DEVICE(0x04CA, 0x3005) }, 83 { USB_DEVICE(0x04CA, 0x3005) },
84 { USB_DEVICE(0x04CA, 0x3006) }, 84 { USB_DEVICE(0x04CA, 0x3006) },
85 { USB_DEVICE(0x04CA, 0x3007) },
85 { USB_DEVICE(0x04CA, 0x3008) }, 86 { USB_DEVICE(0x04CA, 0x3008) },
86 { USB_DEVICE(0x04CA, 0x300b) }, 87 { USB_DEVICE(0x04CA, 0x300b) },
87 { USB_DEVICE(0x0930, 0x0219) }, 88 { USB_DEVICE(0x0930, 0x0219) },
@@ -131,6 +132,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = {
131 { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 }, 132 { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
132 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 133 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
133 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 }, 134 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
135 { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
134 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, 136 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
135 { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 }, 137 { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
136 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 138 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index f338b0c5a8de..a7dfbf9a3afb 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -152,6 +152,7 @@ static const struct usb_device_id blacklist_table[] = {
152 { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 }, 152 { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
153 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, 153 { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
154 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 }, 154 { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
155 { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
155 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 }, 156 { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
156 { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 }, 157 { USB_DEVICE(0x04ca, 0x300b), .driver_info = BTUSB_ATH3012 },
157 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, 158 { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
@@ -1485,10 +1486,8 @@ static int btusb_probe(struct usb_interface *intf,
1485 if (id->driver_info & BTUSB_BCM92035) 1486 if (id->driver_info & BTUSB_BCM92035)
1486 hdev->setup = btusb_setup_bcm92035; 1487 hdev->setup = btusb_setup_bcm92035;
1487 1488
1488 if (id->driver_info & BTUSB_INTEL) { 1489 if (id->driver_info & BTUSB_INTEL)
1489 usb_enable_autosuspend(data->udev);
1490 hdev->setup = btusb_setup_intel; 1490 hdev->setup = btusb_setup_intel;
1491 }
1492 1491
1493 /* Interface numbers are hardcoded in the specification */ 1492 /* Interface numbers are hardcoded in the specification */
1494 data->isoc = usb_ifnum_to_if(data->udev, 1); 1493 data->isoc = usb_ifnum_to_if(data->udev, 1);
diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
index 166e02f16c8a..cc37c342c4cb 100644
--- a/drivers/clk/tegra/clk-tegra124.c
+++ b/drivers/clk/tegra/clk-tegra124.c
@@ -764,7 +764,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
764 [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true }, 764 [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true },
765 [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true }, 765 [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true },
766 [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true }, 766 [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true },
767 [tegra_clk_ndflash] = { .dt_id = TEGRA124_CLK_NDFLASH, .present = true },
768 [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true }, 767 [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true },
769 [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true }, 768 [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true },
770 [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true }, 769 [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true },
@@ -809,7 +808,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
809 [tegra_clk_trace] = { .dt_id = TEGRA124_CLK_TRACE, .present = true }, 808 [tegra_clk_trace] = { .dt_id = TEGRA124_CLK_TRACE, .present = true },
810 [tegra_clk_soc_therm] = { .dt_id = TEGRA124_CLK_SOC_THERM, .present = true }, 809 [tegra_clk_soc_therm] = { .dt_id = TEGRA124_CLK_SOC_THERM, .present = true },
811 [tegra_clk_dtv] = { .dt_id = TEGRA124_CLK_DTV, .present = true }, 810 [tegra_clk_dtv] = { .dt_id = TEGRA124_CLK_DTV, .present = true },
812 [tegra_clk_ndspeed] = { .dt_id = TEGRA124_CLK_NDSPEED, .present = true },
813 [tegra_clk_i2cslow] = { .dt_id = TEGRA124_CLK_I2CSLOW, .present = true }, 811 [tegra_clk_i2cslow] = { .dt_id = TEGRA124_CLK_I2CSLOW, .present = true },
814 [tegra_clk_dsib] = { .dt_id = TEGRA124_CLK_DSIB, .present = true }, 812 [tegra_clk_dsib] = { .dt_id = TEGRA124_CLK_DSIB, .present = true },
815 [tegra_clk_tsec] = { .dt_id = TEGRA124_CLK_TSEC, .present = true }, 813 [tegra_clk_tsec] = { .dt_id = TEGRA124_CLK_TSEC, .present = true },
@@ -952,7 +950,6 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
952 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_3_MUX, .present = true }, 950 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_3_MUX, .present = true },
953 [tegra_clk_dsia_mux] = { .dt_id = TEGRA124_CLK_DSIA_MUX, .present = true }, 951 [tegra_clk_dsia_mux] = { .dt_id = TEGRA124_CLK_DSIA_MUX, .present = true },
954 [tegra_clk_dsib_mux] = { .dt_id = TEGRA124_CLK_DSIB_MUX, .present = true }, 952 [tegra_clk_dsib_mux] = { .dt_id = TEGRA124_CLK_DSIB_MUX, .present = true },
955 [tegra_clk_uarte] = { .dt_id = TEGRA124_CLK_UARTE, .present = true },
956}; 953};
957 954
958static struct tegra_devclk devclks[] __initdata = { 955static struct tegra_devclk devclks[] __initdata = {
diff --git a/drivers/clk/versatile/clk-vexpress-osc.c b/drivers/clk/versatile/clk-vexpress-osc.c
index 2dc8b41a339d..422391242b39 100644
--- a/drivers/clk/versatile/clk-vexpress-osc.c
+++ b/drivers/clk/versatile/clk-vexpress-osc.c
@@ -100,9 +100,11 @@ void __init vexpress_osc_of_setup(struct device_node *node)
100 struct clk *clk; 100 struct clk *clk;
101 u32 range[2]; 101 u32 range[2];
102 102
103 vexpress_sysreg_of_early_init();
104
103 osc = kzalloc(sizeof(*osc), GFP_KERNEL); 105 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
104 if (!osc) 106 if (!osc)
105 goto error; 107 return;
106 108
107 osc->func = vexpress_config_func_get_by_node(node); 109 osc->func = vexpress_config_func_get_by_node(node);
108 if (!osc->func) { 110 if (!osc->func) {
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 57e823c44d2a..5163ec13429d 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -66,6 +66,7 @@ static int arch_timer_ppi[MAX_TIMER_PPI];
66static struct clock_event_device __percpu *arch_timer_evt; 66static struct clock_event_device __percpu *arch_timer_evt;
67 67
68static bool arch_timer_use_virtual = true; 68static bool arch_timer_use_virtual = true;
69static bool arch_timer_c3stop;
69static bool arch_timer_mem_use_virtual; 70static bool arch_timer_mem_use_virtual;
70 71
71/* 72/*
@@ -263,7 +264,8 @@ static void __arch_timer_setup(unsigned type,
263 clk->features = CLOCK_EVT_FEAT_ONESHOT; 264 clk->features = CLOCK_EVT_FEAT_ONESHOT;
264 265
265 if (type == ARCH_CP15_TIMER) { 266 if (type == ARCH_CP15_TIMER) {
266 clk->features |= CLOCK_EVT_FEAT_C3STOP; 267 if (arch_timer_c3stop)
268 clk->features |= CLOCK_EVT_FEAT_C3STOP;
267 clk->name = "arch_sys_timer"; 269 clk->name = "arch_sys_timer";
268 clk->rating = 450; 270 clk->rating = 450;
269 clk->cpumask = cpumask_of(smp_processor_id()); 271 clk->cpumask = cpumask_of(smp_processor_id());
@@ -665,6 +667,8 @@ static void __init arch_timer_init(struct device_node *np)
665 } 667 }
666 } 668 }
667 669
670 arch_timer_c3stop = !of_property_read_bool(np, "always-on");
671
668 arch_timer_register(); 672 arch_timer_register();
669 arch_timer_common_init(); 673 arch_timer_common_init();
670} 674}
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index a6ee6d7cd63f..acf5a329d538 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -416,8 +416,6 @@ static int exynos4_local_timer_setup(struct clock_event_device *evt)
416 evt->set_mode = exynos4_tick_set_mode; 416 evt->set_mode = exynos4_tick_set_mode;
417 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; 417 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
418 evt->rating = 450; 418 evt->rating = 450;
419 clockevents_config_and_register(evt, clk_rate / (TICK_BASE_CNT + 1),
420 0xf, 0x7fffffff);
421 419
422 exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET); 420 exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET);
423 421
@@ -430,9 +428,12 @@ static int exynos4_local_timer_setup(struct clock_event_device *evt)
430 evt->irq); 428 evt->irq);
431 return -EIO; 429 return -EIO;
432 } 430 }
431 irq_force_affinity(mct_irqs[MCT_L0_IRQ + cpu], cpumask_of(cpu));
433 } else { 432 } else {
434 enable_percpu_irq(mct_irqs[MCT_L0_IRQ], 0); 433 enable_percpu_irq(mct_irqs[MCT_L0_IRQ], 0);
435 } 434 }
435 clockevents_config_and_register(evt, clk_rate / (TICK_BASE_CNT + 1),
436 0xf, 0x7fffffff);
436 437
437 return 0; 438 return 0;
438} 439}
@@ -450,7 +451,6 @@ static int exynos4_mct_cpu_notify(struct notifier_block *self,
450 unsigned long action, void *hcpu) 451 unsigned long action, void *hcpu)
451{ 452{
452 struct mct_clock_event_device *mevt; 453 struct mct_clock_event_device *mevt;
453 unsigned int cpu;
454 454
455 /* 455 /*
456 * Grab cpu pointer in each case to avoid spurious 456 * Grab cpu pointer in each case to avoid spurious
@@ -461,12 +461,6 @@ static int exynos4_mct_cpu_notify(struct notifier_block *self,
461 mevt = this_cpu_ptr(&percpu_mct_tick); 461 mevt = this_cpu_ptr(&percpu_mct_tick);
462 exynos4_local_timer_setup(&mevt->evt); 462 exynos4_local_timer_setup(&mevt->evt);
463 break; 463 break;
464 case CPU_ONLINE:
465 cpu = (unsigned long)hcpu;
466 if (mct_int_type == MCT_INT_SPI)
467 irq_set_affinity(mct_irqs[MCT_L0_IRQ + cpu],
468 cpumask_of(cpu));
469 break;
470 case CPU_DYING: 464 case CPU_DYING:
471 mevt = this_cpu_ptr(&percpu_mct_tick); 465 mevt = this_cpu_ptr(&percpu_mct_tick);
472 exynos4_local_timer_stop(&mevt->evt); 466 exynos4_local_timer_stop(&mevt->evt);
diff --git a/drivers/clocksource/zevio-timer.c b/drivers/clocksource/zevio-timer.c
index ca81809d159d..7ce442148c3f 100644
--- a/drivers/clocksource/zevio-timer.c
+++ b/drivers/clocksource/zevio-timer.c
@@ -212,4 +212,9 @@ error_free:
212 return ret; 212 return ret;
213} 213}
214 214
215CLOCKSOURCE_OF_DECLARE(zevio_timer, "lsi,zevio-timer", zevio_timer_add); 215static void __init zevio_timer_init(struct device_node *node)
216{
217 BUG_ON(zevio_timer_add(node));
218}
219
220CLOCKSOURCE_OF_DECLARE(zevio_timer, "lsi,zevio-timer", zevio_timer_init);
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 148d707a1d43..ccdd4c7e748b 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -369,7 +369,7 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
369 return; 369 return;
370 370
371 /* Can only change if privileged. */ 371 /* Can only change if privileged. */
372 if (!capable(CAP_NET_ADMIN)) { 372 if (!__netlink_ns_capable(nsp, &init_user_ns, CAP_NET_ADMIN)) {
373 err = EPERM; 373 err = EPERM;
374 goto out; 374 goto out;
375 } 375 }
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 0e9cce82844b..580503513f0f 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -92,11 +92,7 @@ config ARM_EXYNOS_CPU_FREQ_BOOST_SW
92 92
93config ARM_HIGHBANK_CPUFREQ 93config ARM_HIGHBANK_CPUFREQ
94 tristate "Calxeda Highbank-based" 94 tristate "Calxeda Highbank-based"
95 depends on ARCH_HIGHBANK 95 depends on ARCH_HIGHBANK && GENERIC_CPUFREQ_CPU0 && REGULATOR
96 select GENERIC_CPUFREQ_CPU0
97 select PM_OPP
98 select REGULATOR
99
100 default m 96 default m
101 help 97 help
102 This adds the CPUFreq driver for Calxeda Highbank SoC 98 This adds the CPUFreq driver for Calxeda Highbank SoC
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index d00e5d1abd25..5c4369b5d834 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -242,7 +242,7 @@ static void do_powersaver(int cx_address, unsigned int mults_index,
242 * Sets a new clock ratio. 242 * Sets a new clock ratio.
243 */ 243 */
244 244
245static void longhaul_setstate(struct cpufreq_policy *policy, 245static int longhaul_setstate(struct cpufreq_policy *policy,
246 unsigned int table_index) 246 unsigned int table_index)
247{ 247{
248 unsigned int mults_index; 248 unsigned int mults_index;
@@ -258,10 +258,12 @@ static void longhaul_setstate(struct cpufreq_policy *policy,
258 /* Safety precautions */ 258 /* Safety precautions */
259 mult = mults[mults_index & 0x1f]; 259 mult = mults[mults_index & 0x1f];
260 if (mult == -1) 260 if (mult == -1)
261 return; 261 return -EINVAL;
262
262 speed = calc_speed(mult); 263 speed = calc_speed(mult);
263 if ((speed > highest_speed) || (speed < lowest_speed)) 264 if ((speed > highest_speed) || (speed < lowest_speed))
264 return; 265 return -EINVAL;
266
265 /* Voltage transition before frequency transition? */ 267 /* Voltage transition before frequency transition? */
266 if (can_scale_voltage && longhaul_index < table_index) 268 if (can_scale_voltage && longhaul_index < table_index)
267 dir = 1; 269 dir = 1;
@@ -269,8 +271,6 @@ static void longhaul_setstate(struct cpufreq_policy *policy,
269 freqs.old = calc_speed(longhaul_get_cpu_mult()); 271 freqs.old = calc_speed(longhaul_get_cpu_mult());
270 freqs.new = speed; 272 freqs.new = speed;
271 273
272 cpufreq_freq_transition_begin(policy, &freqs);
273
274 pr_debug("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n", 274 pr_debug("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
275 fsb, mult/10, mult%10, print_speed(speed/1000)); 275 fsb, mult/10, mult%10, print_speed(speed/1000));
276retry_loop: 276retry_loop:
@@ -385,12 +385,14 @@ retry_loop:
385 goto retry_loop; 385 goto retry_loop;
386 } 386 }
387 } 387 }
388 /* Report true CPU frequency */
389 cpufreq_freq_transition_end(policy, &freqs, 0);
390 388
391 if (!bm_timeout) 389 if (!bm_timeout) {
392 printk(KERN_INFO PFX "Warning: Timeout while waiting for " 390 printk(KERN_INFO PFX "Warning: Timeout while waiting for "
393 "idle PCI bus.\n"); 391 "idle PCI bus.\n");
392 return -EBUSY;
393 }
394
395 return 0;
394} 396}
395 397
396/* 398/*
@@ -631,9 +633,10 @@ static int longhaul_target(struct cpufreq_policy *policy,
631 unsigned int i; 633 unsigned int i;
632 unsigned int dir = 0; 634 unsigned int dir = 0;
633 u8 vid, current_vid; 635 u8 vid, current_vid;
636 int retval = 0;
634 637
635 if (!can_scale_voltage) 638 if (!can_scale_voltage)
636 longhaul_setstate(policy, table_index); 639 retval = longhaul_setstate(policy, table_index);
637 else { 640 else {
638 /* On test system voltage transitions exceeding single 641 /* On test system voltage transitions exceeding single
639 * step up or down were turning motherboard off. Both 642 * step up or down were turning motherboard off. Both
@@ -648,7 +651,7 @@ static int longhaul_target(struct cpufreq_policy *policy,
648 while (i != table_index) { 651 while (i != table_index) {
649 vid = (longhaul_table[i].driver_data >> 8) & 0x1f; 652 vid = (longhaul_table[i].driver_data >> 8) & 0x1f;
650 if (vid != current_vid) { 653 if (vid != current_vid) {
651 longhaul_setstate(policy, i); 654 retval = longhaul_setstate(policy, i);
652 current_vid = vid; 655 current_vid = vid;
653 msleep(200); 656 msleep(200);
654 } 657 }
@@ -657,10 +660,11 @@ static int longhaul_target(struct cpufreq_policy *policy,
657 else 660 else
658 i--; 661 i--;
659 } 662 }
660 longhaul_setstate(policy, table_index); 663 retval = longhaul_setstate(policy, table_index);
661 } 664 }
665
662 longhaul_index = table_index; 666 longhaul_index = table_index;
663 return 0; 667 return retval;
664} 668}
665 669
666 670
@@ -968,7 +972,15 @@ static void __exit longhaul_exit(void)
968 972
969 for (i = 0; i < numscales; i++) { 973 for (i = 0; i < numscales; i++) {
970 if (mults[i] == maxmult) { 974 if (mults[i] == maxmult) {
975 struct cpufreq_freqs freqs;
976
977 freqs.old = policy->cur;
978 freqs.new = longhaul_table[i].frequency;
979 freqs.flags = 0;
980
981 cpufreq_freq_transition_begin(policy, &freqs);
971 longhaul_setstate(policy, i); 982 longhaul_setstate(policy, i);
983 cpufreq_freq_transition_end(policy, &freqs, 0);
972 break; 984 break;
973 } 985 }
974 } 986 }
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c
index 49f120e1bc7b..78904e6ca4a0 100644
--- a/drivers/cpufreq/powernow-k6.c
+++ b/drivers/cpufreq/powernow-k6.c
@@ -138,22 +138,14 @@ static void powernow_k6_set_cpu_multiplier(unsigned int best_i)
138static int powernow_k6_target(struct cpufreq_policy *policy, 138static int powernow_k6_target(struct cpufreq_policy *policy,
139 unsigned int best_i) 139 unsigned int best_i)
140{ 140{
141 struct cpufreq_freqs freqs;
142 141
143 if (clock_ratio[best_i].driver_data > max_multiplier) { 142 if (clock_ratio[best_i].driver_data > max_multiplier) {
144 printk(KERN_ERR PFX "invalid target frequency\n"); 143 printk(KERN_ERR PFX "invalid target frequency\n");
145 return -EINVAL; 144 return -EINVAL;
146 } 145 }
147 146
148 freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
149 freqs.new = busfreq * clock_ratio[best_i].driver_data;
150
151 cpufreq_freq_transition_begin(policy, &freqs);
152
153 powernow_k6_set_cpu_multiplier(best_i); 147 powernow_k6_set_cpu_multiplier(best_i);
154 148
155 cpufreq_freq_transition_end(policy, &freqs, 0);
156
157 return 0; 149 return 0;
158} 150}
159 151
@@ -227,9 +219,20 @@ have_busfreq:
227static int powernow_k6_cpu_exit(struct cpufreq_policy *policy) 219static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
228{ 220{
229 unsigned int i; 221 unsigned int i;
230 for (i = 0; i < 8; i++) { 222
231 if (i == max_multiplier) 223 for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
224 if (clock_ratio[i].driver_data == max_multiplier) {
225 struct cpufreq_freqs freqs;
226
227 freqs.old = policy->cur;
228 freqs.new = clock_ratio[i].frequency;
229 freqs.flags = 0;
230
231 cpufreq_freq_transition_begin(policy, &freqs);
232 powernow_k6_target(policy, i); 232 powernow_k6_target(policy, i);
233 cpufreq_freq_transition_end(policy, &freqs, 0);
234 break;
235 }
233 } 236 }
234 return 0; 237 return 0;
235} 238}
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c
index f911645c3f6d..e61e224475ad 100644
--- a/drivers/cpufreq/powernow-k7.c
+++ b/drivers/cpufreq/powernow-k7.c
@@ -269,8 +269,6 @@ static int powernow_target(struct cpufreq_policy *policy, unsigned int index)
269 269
270 freqs.new = powernow_table[index].frequency; 270 freqs.new = powernow_table[index].frequency;
271 271
272 cpufreq_freq_transition_begin(policy, &freqs);
273
274 /* Now do the magic poking into the MSRs. */ 272 /* Now do the magic poking into the MSRs. */
275 273
276 if (have_a0 == 1) /* A0 errata 5 */ 274 if (have_a0 == 1) /* A0 errata 5 */
@@ -290,8 +288,6 @@ static int powernow_target(struct cpufreq_policy *policy, unsigned int index)
290 if (have_a0 == 1) 288 if (have_a0 == 1)
291 local_irq_enable(); 289 local_irq_enable();
292 290
293 cpufreq_freq_transition_end(policy, &freqs, 0);
294
295 return 0; 291 return 0;
296} 292}
297 293
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 9edccc63245d..af4968813e76 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -29,6 +29,7 @@
29 29
30#include <asm/cputhreads.h> 30#include <asm/cputhreads.h>
31#include <asm/reg.h> 31#include <asm/reg.h>
32#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */
32 33
33#define POWERNV_MAX_PSTATES 256 34#define POWERNV_MAX_PSTATES 256
34 35
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c
index b7e677be1df0..0af618abebaf 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/ppc-corenet-cpufreq.c
@@ -138,6 +138,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
138 struct cpufreq_frequency_table *table; 138 struct cpufreq_frequency_table *table;
139 struct cpu_data *data; 139 struct cpu_data *data;
140 unsigned int cpu = policy->cpu; 140 unsigned int cpu = policy->cpu;
141 u64 transition_latency_hz;
141 142
142 np = of_get_cpu_node(cpu, NULL); 143 np = of_get_cpu_node(cpu, NULL);
143 if (!np) 144 if (!np)
@@ -205,8 +206,10 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
205 for_each_cpu(i, per_cpu(cpu_mask, cpu)) 206 for_each_cpu(i, per_cpu(cpu_mask, cpu))
206 per_cpu(cpu_data, i) = data; 207 per_cpu(cpu_data, i) = data;
207 208
209 transition_latency_hz = 12ULL * NSEC_PER_SEC;
208 policy->cpuinfo.transition_latency = 210 policy->cpuinfo.transition_latency =
209 (12 * NSEC_PER_SEC) / fsl_get_sys_freq(); 211 do_div(transition_latency_hz, fsl_get_sys_freq());
212
210 of_node_put(np); 213 of_node_put(np);
211 214
212 return 0; 215 return 0;
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c
index 8d045afa7fb4..6f9dfa80563a 100644
--- a/drivers/cpufreq/unicore2-cpufreq.c
+++ b/drivers/cpufreq/unicore2-cpufreq.c
@@ -60,9 +60,7 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
60 policy->max = policy->cpuinfo.max_freq = 1000000; 60 policy->max = policy->cpuinfo.max_freq = 1000000;
61 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; 61 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
62 policy->clk = clk_get(NULL, "MAIN_CLK"); 62 policy->clk = clk_get(NULL, "MAIN_CLK");
63 if (IS_ERR(policy->clk)) 63 return PTR_ERR_OR_ZERO(policy->clk);
64 return PTR_ERR(policy->clk);
65 return 0;
66} 64}
67 65
68static struct cpufreq_driver ucv2_driver = { 66static struct cpufreq_driver ucv2_driver = {
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index ba06d1d2f99e..5c5863842de9 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -197,7 +197,7 @@ config AMCC_PPC440SPE_ADMA
197 197
198config TIMB_DMA 198config TIMB_DMA
199 tristate "Timberdale FPGA DMA support" 199 tristate "Timberdale FPGA DMA support"
200 depends on MFD_TIMBERDALE || HAS_IOMEM 200 depends on MFD_TIMBERDALE
201 select DMA_ENGINE 201 select DMA_ENGINE
202 help 202 help
203 Enable support for the Timberdale FPGA DMA engine. 203 Enable support for the Timberdale FPGA DMA engine.
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index cd04eb7b182e..926360c2db6a 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -182,11 +182,13 @@ static void edma_execute(struct edma_chan *echan)
182 echan->ecc->dummy_slot); 182 echan->ecc->dummy_slot);
183 } 183 }
184 184
185 edma_resume(echan->ch_num);
186
187 if (edesc->processed <= MAX_NR_SG) { 185 if (edesc->processed <= MAX_NR_SG) {
188 dev_dbg(dev, "first transfer starting %d\n", echan->ch_num); 186 dev_dbg(dev, "first transfer starting %d\n", echan->ch_num);
189 edma_start(echan->ch_num); 187 edma_start(echan->ch_num);
188 } else {
189 dev_dbg(dev, "chan: %d: completed %d elements, resuming\n",
190 echan->ch_num, edesc->processed);
191 edma_resume(echan->ch_num);
190 } 192 }
191 193
192 /* 194 /*
diff --git a/drivers/dma/fsl-edma.c b/drivers/dma/fsl-edma.c
index 381e793184ba..b396a7fb53ab 100644
--- a/drivers/dma/fsl-edma.c
+++ b/drivers/dma/fsl-edma.c
@@ -968,7 +968,17 @@ static struct platform_driver fsl_edma_driver = {
968 .remove = fsl_edma_remove, 968 .remove = fsl_edma_remove,
969}; 969};
970 970
971module_platform_driver(fsl_edma_driver); 971static int __init fsl_edma_init(void)
972{
973 return platform_driver_register(&fsl_edma_driver);
974}
975subsys_initcall(fsl_edma_init);
976
977static void __exit fsl_edma_exit(void)
978{
979 platform_driver_unregister(&fsl_edma_driver);
980}
981module_exit(fsl_edma_exit);
972 982
973MODULE_ALIAS("platform:fsl-edma"); 983MODULE_ALIAS("platform:fsl-edma");
974MODULE_DESCRIPTION("Freescale eDMA engine driver"); 984MODULE_DESCRIPTION("Freescale eDMA engine driver");
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index a1bd8298d55f..03f7820fa333 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -666,7 +666,7 @@ static struct dma_chan *of_dma_sirfsoc_xlate(struct of_phandle_args *dma_spec,
666 struct sirfsoc_dma *sdma = ofdma->of_dma_data; 666 struct sirfsoc_dma *sdma = ofdma->of_dma_data;
667 unsigned int request = dma_spec->args[0]; 667 unsigned int request = dma_spec->args[0];
668 668
669 if (request > SIRFSOC_DMA_CHANNELS) 669 if (request >= SIRFSOC_DMA_CHANNELS)
670 return NULL; 670 return NULL;
671 671
672 return dma_get_slave_channel(&sdma->channels[request].chan); 672 return dma_get_slave_channel(&sdma->channels[request].chan);
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index bf0f8b476696..401add28933f 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -233,7 +233,7 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *acpi_gpio)
233{ 233{
234 struct gpio_chip *chip = acpi_gpio->chip; 234 struct gpio_chip *chip = acpi_gpio->chip;
235 235
236 if (!chip->dev || !chip->to_irq) 236 if (!chip->to_irq)
237 return; 237 return;
238 238
239 INIT_LIST_HEAD(&acpi_gpio->events); 239 INIT_LIST_HEAD(&acpi_gpio->events);
@@ -253,7 +253,7 @@ static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *acpi_gpio)
253 struct acpi_gpio_event *event, *ep; 253 struct acpi_gpio_event *event, *ep;
254 struct gpio_chip *chip = acpi_gpio->chip; 254 struct gpio_chip *chip = acpi_gpio->chip;
255 255
256 if (!chip->dev || !chip->to_irq) 256 if (!chip->to_irq)
257 return; 257 return;
258 258
259 list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { 259 list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) {
@@ -451,7 +451,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
451 if (function == ACPI_WRITE) 451 if (function == ACPI_WRITE)
452 gpiod_set_raw_value(desc, !!((1 << i) & *value)); 452 gpiod_set_raw_value(desc, !!((1 << i) & *value));
453 else 453 else
454 *value |= gpiod_get_raw_value(desc) << i; 454 *value |= (u64)gpiod_get_raw_value(desc) << i;
455 } 455 }
456 456
457out: 457out:
@@ -501,6 +501,9 @@ void acpi_gpiochip_add(struct gpio_chip *chip)
501 acpi_handle handle; 501 acpi_handle handle;
502 acpi_status status; 502 acpi_status status;
503 503
504 if (!chip || !chip->dev)
505 return;
506
504 handle = ACPI_HANDLE(chip->dev); 507 handle = ACPI_HANDLE(chip->dev);
505 if (!handle) 508 if (!handle)
506 return; 509 return;
@@ -531,6 +534,9 @@ void acpi_gpiochip_remove(struct gpio_chip *chip)
531 acpi_handle handle; 534 acpi_handle handle;
532 acpi_status status; 535 acpi_status status;
533 536
537 if (!chip || !chip->dev)
538 return;
539
534 handle = ACPI_HANDLE(chip->dev); 540 handle = ACPI_HANDLE(chip->dev);
535 if (!handle) 541 if (!handle)
536 return; 542 return;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 761013f8b82f..f48817d97480 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1387,8 +1387,8 @@ static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq,
1387{ 1387{
1388 struct gpio_chip *chip = d->host_data; 1388 struct gpio_chip *chip = d->host_data;
1389 1389
1390 irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler);
1391 irq_set_chip_data(irq, chip); 1390 irq_set_chip_data(irq, chip);
1391 irq_set_chip_and_handler(irq, chip->irqchip, chip->irq_handler);
1392#ifdef CONFIG_ARM 1392#ifdef CONFIG_ARM
1393 set_irq_flags(irq, IRQF_VALID); 1393 set_irq_flags(irq, IRQF_VALID);
1394#else 1394#else
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index e930d4fe29c7..1ef5ab9c9d51 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -145,6 +145,7 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
145 145
146 plane->crtc = crtc; 146 plane->crtc = crtc;
147 plane->fb = crtc->primary->fb; 147 plane->fb = crtc->primary->fb;
148 drm_framebuffer_reference(plane->fb);
148 149
149 return 0; 150 return 0;
150} 151}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index c786cd4f457b..2a3ad24276f8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -263,7 +263,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
263 buffer->sgt = sgt; 263 buffer->sgt = sgt;
264 exynos_gem_obj->base.import_attach = attach; 264 exynos_gem_obj->base.import_attach = attach;
265 265
266 DRM_DEBUG_PRIME("dma_addr = 0x%x, size = 0x%lx\n", buffer->dma_addr, 266 DRM_DEBUG_PRIME("dma_addr = %pad, size = 0x%lx\n", &buffer->dma_addr,
267 buffer->size); 267 buffer->size);
268 268
269 return &exynos_gem_obj->base; 269 return &exynos_gem_obj->base;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index eb73e3bf2a0c..4ac438187568 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1426,9 +1426,9 @@ static int exynos_dsi_probe(struct platform_device *pdev)
1426 1426
1427 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1427 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1428 dsi->reg_base = devm_ioremap_resource(&pdev->dev, res); 1428 dsi->reg_base = devm_ioremap_resource(&pdev->dev, res);
1429 if (!dsi->reg_base) { 1429 if (IS_ERR(dsi->reg_base)) {
1430 dev_err(&pdev->dev, "failed to remap io region\n"); 1430 dev_err(&pdev->dev, "failed to remap io region\n");
1431 return -EADDRNOTAVAIL; 1431 return PTR_ERR(dsi->reg_base);
1432 } 1432 }
1433 1433
1434 dsi->phy = devm_phy_get(&pdev->dev, "dsim"); 1434 dsi->phy = devm_phy_get(&pdev->dev, "dsim");
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 7afead9c3f30..852f2dadaebd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -220,7 +220,7 @@ static void vidi_win_commit(struct exynos_drm_manager *mgr, int zpos)
220 220
221 win_data->enabled = true; 221 win_data->enabled = true;
222 222
223 DRM_DEBUG_KMS("dma_addr = 0x%x\n", win_data->dma_addr); 223 DRM_DEBUG_KMS("dma_addr = %pad\n", &win_data->dma_addr);
224 224
225 if (ctx->vblank_on) 225 if (ctx->vblank_on)
226 schedule_work(&ctx->work); 226 schedule_work(&ctx->work);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index ab5e93c30aa2..62a5c3627b90 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -50,7 +50,7 @@ bool intel_enable_ppgtt(struct drm_device *dev, bool full)
50 50
51 /* Full ppgtt disabled by default for now due to issues. */ 51 /* Full ppgtt disabled by default for now due to issues. */
52 if (full) 52 if (full)
53 return false; /* HAS_PPGTT(dev) */ 53 return HAS_PPGTT(dev) && (i915.enable_ppgtt == 2);
54 else 54 else
55 return HAS_ALIASING_PPGTT(dev); 55 return HAS_ALIASING_PPGTT(dev);
56} 56}
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 7753249b3a95..f98ba4e6e70b 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1362,10 +1362,20 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev,
1362 spin_lock(&dev_priv->irq_lock); 1362 spin_lock(&dev_priv->irq_lock);
1363 for (i = 1; i < HPD_NUM_PINS; i++) { 1363 for (i = 1; i < HPD_NUM_PINS; i++) {
1364 1364
1365 WARN_ONCE(hpd[i] & hotplug_trigger && 1365 if (hpd[i] & hotplug_trigger &&
1366 dev_priv->hpd_stats[i].hpd_mark == HPD_DISABLED, 1366 dev_priv->hpd_stats[i].hpd_mark == HPD_DISABLED) {
1367 "Received HPD interrupt (0x%08x) on pin %d (0x%08x) although disabled\n", 1367 /*
1368 hotplug_trigger, i, hpd[i]); 1368 * On GMCH platforms the interrupt mask bits only
1369 * prevent irq generation, not the setting of the
1370 * hotplug bits itself. So only WARN about unexpected
1371 * interrupts on saner platforms.
1372 */
1373 WARN_ONCE(INTEL_INFO(dev)->gen >= 5 && !IS_VALLEYVIEW(dev),
1374 "Received HPD interrupt (0x%08x) on pin %d (0x%08x) although disabled\n",
1375 hotplug_trigger, i, hpd[i]);
1376
1377 continue;
1378 }
1369 1379
1370 if (!(hpd[i] & hotplug_trigger) || 1380 if (!(hpd[i] & hotplug_trigger) ||
1371 dev_priv->hpd_stats[i].hpd_mark != HPD_ENABLED) 1381 dev_priv->hpd_stats[i].hpd_mark != HPD_ENABLED)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 9f5b18d9d885..c77af69c2d8f 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -827,6 +827,7 @@ enum punit_power_well {
827# define MI_FLUSH_ENABLE (1 << 12) 827# define MI_FLUSH_ENABLE (1 << 12)
828# define ASYNC_FLIP_PERF_DISABLE (1 << 14) 828# define ASYNC_FLIP_PERF_DISABLE (1 << 14)
829# define MODE_IDLE (1 << 9) 829# define MODE_IDLE (1 << 9)
830# define STOP_RING (1 << 8)
830 831
831#define GEN6_GT_MODE 0x20d0 832#define GEN6_GT_MODE 0x20d0
832#define GEN7_GT_MODE 0x7008 833#define GEN7_GT_MODE 0x7008
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index dae976f51d83..69bcc42a0e44 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9654,11 +9654,22 @@ intel_pipe_config_compare(struct drm_device *dev,
9654 PIPE_CONF_CHECK_I(pipe_src_w); 9654 PIPE_CONF_CHECK_I(pipe_src_w);
9655 PIPE_CONF_CHECK_I(pipe_src_h); 9655 PIPE_CONF_CHECK_I(pipe_src_h);
9656 9656
9657 PIPE_CONF_CHECK_I(gmch_pfit.control); 9657 /*
9658 /* pfit ratios are autocomputed by the hw on gen4+ */ 9658 * FIXME: BIOS likes to set up a cloned config with lvds+external
9659 if (INTEL_INFO(dev)->gen < 4) 9659 * screen. Since we don't yet re-compute the pipe config when moving
9660 PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios); 9660 * just the lvds port away to another pipe the sw tracking won't match.
9661 PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits); 9661 *
9662 * Proper atomic modesets with recomputed global state will fix this.
9663 * Until then just don't check gmch state for inherited modes.
9664 */
9665 if (!PIPE_CONF_QUIRK(PIPE_CONFIG_QUIRK_INHERITED_MODE)) {
9666 PIPE_CONF_CHECK_I(gmch_pfit.control);
9667 /* pfit ratios are autocomputed by the hw on gen4+ */
9668 if (INTEL_INFO(dev)->gen < 4)
9669 PIPE_CONF_CHECK_I(gmch_pfit.pgm_ratios);
9670 PIPE_CONF_CHECK_I(gmch_pfit.lvds_border_bits);
9671 }
9672
9662 PIPE_CONF_CHECK_I(pch_pfit.enabled); 9673 PIPE_CONF_CHECK_I(pch_pfit.enabled);
9663 if (current_config->pch_pfit.enabled) { 9674 if (current_config->pch_pfit.enabled) {
9664 PIPE_CONF_CHECK_I(pch_pfit.pos); 9675 PIPE_CONF_CHECK_I(pch_pfit.pos);
@@ -11616,6 +11627,8 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
11616 base.head) { 11627 base.head) {
11617 memset(&crtc->config, 0, sizeof(crtc->config)); 11628 memset(&crtc->config, 0, sizeof(crtc->config));
11618 11629
11630 crtc->config.quirks |= PIPE_CONFIG_QUIRK_INHERITED_MODE;
11631
11619 crtc->active = dev_priv->display.get_pipe_config(crtc, 11632 crtc->active = dev_priv->display.get_pipe_config(crtc,
11620 &crtc->config); 11633 &crtc->config);
11621 11634
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d2a55884ad52..dfa85289f28f 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3619,7 +3619,8 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
3619{ 3619{
3620 struct drm_connector *connector = &intel_connector->base; 3620 struct drm_connector *connector = &intel_connector->base;
3621 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp); 3621 struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
3622 struct drm_device *dev = intel_dig_port->base.base.dev; 3622 struct intel_encoder *intel_encoder = &intel_dig_port->base;
3623 struct drm_device *dev = intel_encoder->base.dev;
3623 struct drm_i915_private *dev_priv = dev->dev_private; 3624 struct drm_i915_private *dev_priv = dev->dev_private;
3624 struct drm_display_mode *fixed_mode = NULL; 3625 struct drm_display_mode *fixed_mode = NULL;
3625 bool has_dpcd; 3626 bool has_dpcd;
@@ -3629,6 +3630,14 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
3629 if (!is_edp(intel_dp)) 3630 if (!is_edp(intel_dp))
3630 return true; 3631 return true;
3631 3632
3633 /* The VDD bit needs a power domain reference, so if the bit is already
3634 * enabled when we boot, grab this reference. */
3635 if (edp_have_panel_vdd(intel_dp)) {
3636 enum intel_display_power_domain power_domain;
3637 power_domain = intel_display_port_power_domain(intel_encoder);
3638 intel_display_power_get(dev_priv, power_domain);
3639 }
3640
3632 /* Cache DPCD and EDID for edp. */ 3641 /* Cache DPCD and EDID for edp. */
3633 intel_edp_panel_vdd_on(intel_dp); 3642 intel_edp_panel_vdd_on(intel_dp);
3634 has_dpcd = intel_dp_get_dpcd(intel_dp); 3643 has_dpcd = intel_dp_get_dpcd(intel_dp);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 0542de982260..328b1a70264b 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -236,7 +236,8 @@ struct intel_crtc_config {
236 * tracked with quirk flags so that fastboot and state checker can act 236 * tracked with quirk flags so that fastboot and state checker can act
237 * accordingly. 237 * accordingly.
238 */ 238 */
239#define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */ 239#define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
240#define PIPE_CONFIG_QUIRK_INHERITED_MODE (1<<1) /* mode inherited from firmware */
240 unsigned long quirks; 241 unsigned long quirks;
241 242
242 /* User requested mode, only valid as a starting point to 243 /* User requested mode, only valid as a starting point to
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index b4d44e62f0c7..fce4a0d93c0b 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -132,6 +132,16 @@ static int intelfb_create(struct drm_fb_helper *helper,
132 132
133 mutex_lock(&dev->struct_mutex); 133 mutex_lock(&dev->struct_mutex);
134 134
135 if (intel_fb &&
136 (sizes->fb_width > intel_fb->base.width ||
137 sizes->fb_height > intel_fb->base.height)) {
138 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
139 " releasing it\n",
140 intel_fb->base.width, intel_fb->base.height,
141 sizes->fb_width, sizes->fb_height);
142 drm_framebuffer_unreference(&intel_fb->base);
143 intel_fb = ifbdev->fb = NULL;
144 }
135 if (!intel_fb || WARN_ON(!intel_fb->obj)) { 145 if (!intel_fb || WARN_ON(!intel_fb->obj)) {
136 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); 146 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
137 ret = intelfb_alloc(helper, sizes); 147 ret = intelfb_alloc(helper, sizes);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index b0413e190625..157267aa3561 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -821,11 +821,11 @@ static void intel_disable_hdmi(struct intel_encoder *encoder)
821 } 821 }
822} 822}
823 823
824static int hdmi_portclock_limit(struct intel_hdmi *hdmi) 824static int hdmi_portclock_limit(struct intel_hdmi *hdmi, bool respect_dvi_limit)
825{ 825{
826 struct drm_device *dev = intel_hdmi_to_dev(hdmi); 826 struct drm_device *dev = intel_hdmi_to_dev(hdmi);
827 827
828 if (!hdmi->has_hdmi_sink || IS_G4X(dev)) 828 if ((respect_dvi_limit && !hdmi->has_hdmi_sink) || IS_G4X(dev))
829 return 165000; 829 return 165000;
830 else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8) 830 else if (IS_HASWELL(dev) || INTEL_INFO(dev)->gen >= 8)
831 return 300000; 831 return 300000;
@@ -837,7 +837,8 @@ static enum drm_mode_status
837intel_hdmi_mode_valid(struct drm_connector *connector, 837intel_hdmi_mode_valid(struct drm_connector *connector,
838 struct drm_display_mode *mode) 838 struct drm_display_mode *mode)
839{ 839{
840 if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector))) 840 if (mode->clock > hdmi_portclock_limit(intel_attached_hdmi(connector),
841 true))
841 return MODE_CLOCK_HIGH; 842 return MODE_CLOCK_HIGH;
842 if (mode->clock < 20000) 843 if (mode->clock < 20000)
843 return MODE_CLOCK_LOW; 844 return MODE_CLOCK_LOW;
@@ -879,7 +880,7 @@ bool intel_hdmi_compute_config(struct intel_encoder *encoder,
879 struct drm_device *dev = encoder->base.dev; 880 struct drm_device *dev = encoder->base.dev;
880 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; 881 struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode;
881 int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2; 882 int clock_12bpc = pipe_config->adjusted_mode.crtc_clock * 3 / 2;
882 int portclock_limit = hdmi_portclock_limit(intel_hdmi); 883 int portclock_limit = hdmi_portclock_limit(intel_hdmi, false);
883 int desired_bpp; 884 int desired_bpp;
884 885
885 if (intel_hdmi->color_range_auto) { 886 if (intel_hdmi->color_range_auto) {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 6bc68bdcf433..79fb4cc2137c 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -437,32 +437,41 @@ static void ring_setup_phys_status_page(struct intel_ring_buffer *ring)
437 I915_WRITE(HWS_PGA, addr); 437 I915_WRITE(HWS_PGA, addr);
438} 438}
439 439
440static int init_ring_common(struct intel_ring_buffer *ring) 440static bool stop_ring(struct intel_ring_buffer *ring)
441{ 441{
442 struct drm_device *dev = ring->dev; 442 struct drm_i915_private *dev_priv = to_i915(ring->dev);
443 struct drm_i915_private *dev_priv = dev->dev_private;
444 struct drm_i915_gem_object *obj = ring->obj;
445 int ret = 0;
446 u32 head;
447 443
448 gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL); 444 if (!IS_GEN2(ring->dev)) {
445 I915_WRITE_MODE(ring, _MASKED_BIT_ENABLE(STOP_RING));
446 if (wait_for_atomic((I915_READ_MODE(ring) & MODE_IDLE) != 0, 1000)) {
447 DRM_ERROR("%s :timed out trying to stop ring\n", ring->name);
448 return false;
449 }
450 }
449 451
450 /* Stop the ring if it's running. */
451 I915_WRITE_CTL(ring, 0); 452 I915_WRITE_CTL(ring, 0);
452 I915_WRITE_HEAD(ring, 0); 453 I915_WRITE_HEAD(ring, 0);
453 ring->write_tail(ring, 0); 454 ring->write_tail(ring, 0);
454 if (wait_for_atomic((I915_READ_MODE(ring) & MODE_IDLE) != 0, 1000))
455 DRM_ERROR("%s :timed out trying to stop ring\n", ring->name);
456 455
457 if (I915_NEED_GFX_HWS(dev)) 456 if (!IS_GEN2(ring->dev)) {
458 intel_ring_setup_status_page(ring); 457 (void)I915_READ_CTL(ring);
459 else 458 I915_WRITE_MODE(ring, _MASKED_BIT_DISABLE(STOP_RING));
460 ring_setup_phys_status_page(ring); 459 }
461 460
462 head = I915_READ_HEAD(ring) & HEAD_ADDR; 461 return (I915_READ_HEAD(ring) & HEAD_ADDR) == 0;
462}
463 463
464 /* G45 ring initialization fails to reset head to zero */ 464static int init_ring_common(struct intel_ring_buffer *ring)
465 if (head != 0) { 465{
466 struct drm_device *dev = ring->dev;
467 struct drm_i915_private *dev_priv = dev->dev_private;
468 struct drm_i915_gem_object *obj = ring->obj;
469 int ret = 0;
470
471 gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
472
473 if (!stop_ring(ring)) {
474 /* G45 ring initialization often fails to reset head to zero */
466 DRM_DEBUG_KMS("%s head not reset to zero " 475 DRM_DEBUG_KMS("%s head not reset to zero "
467 "ctl %08x head %08x tail %08x start %08x\n", 476 "ctl %08x head %08x tail %08x start %08x\n",
468 ring->name, 477 ring->name,
@@ -471,9 +480,7 @@ static int init_ring_common(struct intel_ring_buffer *ring)
471 I915_READ_TAIL(ring), 480 I915_READ_TAIL(ring),
472 I915_READ_START(ring)); 481 I915_READ_START(ring));
473 482
474 I915_WRITE_HEAD(ring, 0); 483 if (!stop_ring(ring)) {
475
476 if (I915_READ_HEAD(ring) & HEAD_ADDR) {
477 DRM_ERROR("failed to set %s head to zero " 484 DRM_ERROR("failed to set %s head to zero "
478 "ctl %08x head %08x tail %08x start %08x\n", 485 "ctl %08x head %08x tail %08x start %08x\n",
479 ring->name, 486 ring->name,
@@ -481,9 +488,16 @@ static int init_ring_common(struct intel_ring_buffer *ring)
481 I915_READ_HEAD(ring), 488 I915_READ_HEAD(ring),
482 I915_READ_TAIL(ring), 489 I915_READ_TAIL(ring),
483 I915_READ_START(ring)); 490 I915_READ_START(ring));
491 ret = -EIO;
492 goto out;
484 } 493 }
485 } 494 }
486 495
496 if (I915_NEED_GFX_HWS(dev))
497 intel_ring_setup_status_page(ring);
498 else
499 ring_setup_phys_status_page(ring);
500
487 /* Initialize the ring. This must happen _after_ we've cleared the ring 501 /* Initialize the ring. This must happen _after_ we've cleared the ring
488 * registers with the above sequence (the readback of the HEAD registers 502 * registers with the above sequence (the readback of the HEAD registers
489 * also enforces ordering), otherwise the hw might lose the new ring 503 * also enforces ordering), otherwise the hw might lose the new ring
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 270a6a973438..2b91c4b4d34b 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -34,6 +34,7 @@ struct intel_hw_status_page {
34#define I915_WRITE_IMR(ring, val) I915_WRITE(RING_IMR((ring)->mmio_base), val) 34#define I915_WRITE_IMR(ring, val) I915_WRITE(RING_IMR((ring)->mmio_base), val)
35 35
36#define I915_READ_MODE(ring) I915_READ(RING_MI_MODE((ring)->mmio_base)) 36#define I915_READ_MODE(ring) I915_READ(RING_MI_MODE((ring)->mmio_base))
37#define I915_WRITE_MODE(ring, val) I915_WRITE(RING_MI_MODE((ring)->mmio_base), val)
37 38
38enum intel_ring_hangcheck_action { 39enum intel_ring_hangcheck_action {
39 HANGCHECK_IDLE = 0, 40 HANGCHECK_IDLE = 0,
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 3e6c0f3ed592..ef9957dbac94 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -510,9 +510,8 @@ static void update_cursor(struct drm_crtc *crtc)
510 MDP4_DMA_CURSOR_BLEND_CONFIG_CURSOR_EN); 510 MDP4_DMA_CURSOR_BLEND_CONFIG_CURSOR_EN);
511 } else { 511 } else {
512 /* disable cursor: */ 512 /* disable cursor: */
513 mdp4_write(mdp4_kms, REG_MDP4_DMA_CURSOR_BASE(dma), 0); 513 mdp4_write(mdp4_kms, REG_MDP4_DMA_CURSOR_BASE(dma),
514 mdp4_write(mdp4_kms, REG_MDP4_DMA_CURSOR_BLEND_CONFIG(dma), 514 mdp4_kms->blank_cursor_iova);
515 MDP4_DMA_CURSOR_BLEND_CONFIG_FORMAT(CURSOR_ARGB));
516 } 515 }
517 516
518 /* and drop the iova ref + obj rev when done scanning out: */ 517 /* and drop the iova ref + obj rev when done scanning out: */
@@ -574,11 +573,9 @@ static int mdp4_crtc_cursor_set(struct drm_crtc *crtc,
574 573
575 if (old_bo) { 574 if (old_bo) {
576 /* drop our previous reference: */ 575 /* drop our previous reference: */
577 msm_gem_put_iova(old_bo, mdp4_kms->id); 576 drm_flip_work_queue(&mdp4_crtc->unref_cursor_work, old_bo);
578 drm_gem_object_unreference_unlocked(old_bo);
579 } 577 }
580 578
581 crtc_flush(crtc);
582 request_pending(crtc, PENDING_CURSOR); 579 request_pending(crtc, PENDING_CURSOR);
583 580
584 return 0; 581 return 0;
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_irq.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_irq.c
index c740ccd1cc67..8edd531cb621 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_irq.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_irq.c
@@ -70,12 +70,12 @@ irqreturn_t mdp4_irq(struct msm_kms *kms)
70 70
71 VERB("status=%08x", status); 71 VERB("status=%08x", status);
72 72
73 mdp_dispatch_irqs(mdp_kms, status);
74
73 for (id = 0; id < priv->num_crtcs; id++) 75 for (id = 0; id < priv->num_crtcs; id++)
74 if (status & mdp4_crtc_vblank(priv->crtcs[id])) 76 if (status & mdp4_crtc_vblank(priv->crtcs[id]))
75 drm_handle_vblank(dev, id); 77 drm_handle_vblank(dev, id);
76 78
77 mdp_dispatch_irqs(mdp_kms, status);
78
79 return IRQ_HANDLED; 79 return IRQ_HANDLED;
80} 80}
81 81
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
index 272e707c9487..0bb4faa17523 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
@@ -144,6 +144,10 @@ static void mdp4_preclose(struct msm_kms *kms, struct drm_file *file)
144static void mdp4_destroy(struct msm_kms *kms) 144static void mdp4_destroy(struct msm_kms *kms)
145{ 145{
146 struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms)); 146 struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
147 if (mdp4_kms->blank_cursor_iova)
148 msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id);
149 if (mdp4_kms->blank_cursor_bo)
150 drm_gem_object_unreference(mdp4_kms->blank_cursor_bo);
147 kfree(mdp4_kms); 151 kfree(mdp4_kms);
148} 152}
149 153
@@ -372,6 +376,23 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
372 goto fail; 376 goto fail;
373 } 377 }
374 378
379 mutex_lock(&dev->struct_mutex);
380 mdp4_kms->blank_cursor_bo = msm_gem_new(dev, SZ_16K, MSM_BO_WC);
381 mutex_unlock(&dev->struct_mutex);
382 if (IS_ERR(mdp4_kms->blank_cursor_bo)) {
383 ret = PTR_ERR(mdp4_kms->blank_cursor_bo);
384 dev_err(dev->dev, "could not allocate blank-cursor bo: %d\n", ret);
385 mdp4_kms->blank_cursor_bo = NULL;
386 goto fail;
387 }
388
389 ret = msm_gem_get_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id,
390 &mdp4_kms->blank_cursor_iova);
391 if (ret) {
392 dev_err(dev->dev, "could not pin blank-cursor bo: %d\n", ret);
393 goto fail;
394 }
395
375 return kms; 396 return kms;
376 397
377fail: 398fail:
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
index 66a4d31aec80..715520c54cde 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
@@ -44,6 +44,10 @@ struct mdp4_kms {
44 struct clk *lut_clk; 44 struct clk *lut_clk;
45 45
46 struct mdp_irq error_handler; 46 struct mdp_irq error_handler;
47
48 /* empty/blank cursor bo to use when cursor is "disabled" */
49 struct drm_gem_object *blank_cursor_bo;
50 uint32_t blank_cursor_iova;
47}; 51};
48#define to_mdp4_kms(x) container_of(x, struct mdp4_kms, base) 52#define to_mdp4_kms(x) container_of(x, struct mdp4_kms, base)
49 53
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c
index 353d494a497f..f2b985bc2adf 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_irq.c
@@ -71,11 +71,11 @@ static void mdp5_irq_mdp(struct mdp_kms *mdp_kms)
71 71
72 VERB("status=%08x", status); 72 VERB("status=%08x", status);
73 73
74 mdp_dispatch_irqs(mdp_kms, status);
75
74 for (id = 0; id < priv->num_crtcs; id++) 76 for (id = 0; id < priv->num_crtcs; id++)
75 if (status & mdp5_crtc_vblank(priv->crtcs[id])) 77 if (status & mdp5_crtc_vblank(priv->crtcs[id]))
76 drm_handle_vblank(dev, id); 78 drm_handle_vblank(dev, id);
77
78 mdp_dispatch_irqs(mdp_kms, status);
79} 79}
80 80
81irqreturn_t mdp5_irq(struct msm_kms *kms) 81irqreturn_t mdp5_irq(struct msm_kms *kms)
diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 6c6d7d4c9b4e..a752ab83b810 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -62,11 +62,8 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
62 dma_addr_t paddr; 62 dma_addr_t paddr;
63 int ret, size; 63 int ret, size;
64 64
65 /* only doing ARGB32 since this is what is needed to alpha-blend
66 * with video overlays:
67 */
68 sizes->surface_bpp = 32; 65 sizes->surface_bpp = 32;
69 sizes->surface_depth = 32; 66 sizes->surface_depth = 24;
70 67
71 DBG("create fbdev: %dx%d@%d (%dx%d)", sizes->surface_width, 68 DBG("create fbdev: %dx%d@%d (%dx%d)", sizes->surface_width,
72 sizes->surface_height, sizes->surface_bpp, 69 sizes->surface_height, sizes->surface_bpp,
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 3da8264d3039..bb8026daebc9 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -118,8 +118,10 @@ static void put_pages(struct drm_gem_object *obj)
118 118
119 if (iommu_present(&platform_bus_type)) 119 if (iommu_present(&platform_bus_type))
120 drm_gem_put_pages(obj, msm_obj->pages, true, false); 120 drm_gem_put_pages(obj, msm_obj->pages, true, false);
121 else 121 else {
122 drm_mm_remove_node(msm_obj->vram_node); 122 drm_mm_remove_node(msm_obj->vram_node);
123 drm_free_large(msm_obj->pages);
124 }
123 125
124 msm_obj->pages = NULL; 126 msm_obj->pages = NULL;
125 } 127 }
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 15936524f226..bc0119fb6c12 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -209,6 +209,7 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
209{ 209{
210 int ret; 210 int ret;
211 211
212 radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd;
212 radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 213 radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
213 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; 214 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer;
214 ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux); 215 ret = drm_dp_aux_register_i2c_bus(&radeon_connector->ddc_bus->aux);
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c
index 89b4afa5041c..f7e46cf682af 100644
--- a/drivers/gpu/drm/radeon/cik_sdma.c
+++ b/drivers/gpu/drm/radeon/cik_sdma.c
@@ -597,7 +597,7 @@ int cik_sdma_ring_test(struct radeon_device *rdev,
597 tmp = 0xCAFEDEAD; 597 tmp = 0xCAFEDEAD;
598 writel(tmp, ptr); 598 writel(tmp, ptr);
599 599
600 r = radeon_ring_lock(rdev, ring, 4); 600 r = radeon_ring_lock(rdev, ring, 5);
601 if (r) { 601 if (r) {
602 DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r); 602 DRM_ERROR("radeon: dma failed to lock ring %d (%d).\n", ring->idx, r);
603 return r; 603 return r;
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index cbf7e3269f84..9c61b74ef441 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -158,16 +158,18 @@ u32 r600_dpm_get_vblank_time(struct radeon_device *rdev)
158 u32 line_time_us, vblank_lines; 158 u32 line_time_us, vblank_lines;
159 u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */ 159 u32 vblank_time_us = 0xffffffff; /* if the displays are off, vblank time is max */
160 160
161 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 161 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
162 radeon_crtc = to_radeon_crtc(crtc); 162 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
163 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 163 radeon_crtc = to_radeon_crtc(crtc);
164 line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) / 164 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
165 radeon_crtc->hw_mode.clock; 165 line_time_us = (radeon_crtc->hw_mode.crtc_htotal * 1000) /
166 vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end - 166 radeon_crtc->hw_mode.clock;
167 radeon_crtc->hw_mode.crtc_vdisplay + 167 vblank_lines = radeon_crtc->hw_mode.crtc_vblank_end -
168 (radeon_crtc->v_border * 2); 168 radeon_crtc->hw_mode.crtc_vdisplay +
169 vblank_time_us = vblank_lines * line_time_us; 169 (radeon_crtc->v_border * 2);
170 break; 170 vblank_time_us = vblank_lines * line_time_us;
171 break;
172 }
171 } 173 }
172 } 174 }
173 175
@@ -181,14 +183,15 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev)
181 struct radeon_crtc *radeon_crtc; 183 struct radeon_crtc *radeon_crtc;
182 u32 vrefresh = 0; 184 u32 vrefresh = 0;
183 185
184 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 186 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
185 radeon_crtc = to_radeon_crtc(crtc); 187 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
186 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 188 radeon_crtc = to_radeon_crtc(crtc);
187 vrefresh = radeon_crtc->hw_mode.vrefresh; 189 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
188 break; 190 vrefresh = radeon_crtc->hw_mode.vrefresh;
191 break;
192 }
189 } 193 }
190 } 194 }
191
192 return vrefresh; 195 return vrefresh;
193} 196}
194 197
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index dedea72f48c4..a9fb0d016d38 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -528,6 +528,13 @@ static bool radeon_atpx_detect(void)
528 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true); 528 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
529 } 529 }
530 530
531 /* some newer PX laptops mark the dGPU as a non-VGA display device */
532 while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
533 vga_count++;
534
535 has_atpx |= (radeon_atpx_pci_probe_handle(pdev) == true);
536 }
537
531 if (has_atpx && vga_count == 2) { 538 if (has_atpx && vga_count == 2) {
532 acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer); 539 acpi_get_name(radeon_atpx_priv.atpx.handle, ACPI_FULL_PATHNAME, &buffer);
533 printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n", 540 printk(KERN_INFO "VGA switcheroo: detected switching method %s handle\n",
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 2f7cbb901fb1..8d99d5ee8014 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -840,6 +840,38 @@ static void avivo_reduce_ratio(unsigned *nom, unsigned *den,
840} 840}
841 841
842/** 842/**
843 * avivo_get_fb_ref_div - feedback and ref divider calculation
844 *
845 * @nom: nominator
846 * @den: denominator
847 * @post_div: post divider
848 * @fb_div_max: feedback divider maximum
849 * @ref_div_max: reference divider maximum
850 * @fb_div: resulting feedback divider
851 * @ref_div: resulting reference divider
852 *
853 * Calculate feedback and reference divider for a given post divider. Makes
854 * sure we stay within the limits.
855 */
856static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div,
857 unsigned fb_div_max, unsigned ref_div_max,
858 unsigned *fb_div, unsigned *ref_div)
859{
860 /* limit reference * post divider to a maximum */
861 ref_div_max = min(210 / post_div, ref_div_max);
862
863 /* get matching reference and feedback divider */
864 *ref_div = min(max(DIV_ROUND_CLOSEST(den, post_div), 1u), ref_div_max);
865 *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den);
866
867 /* limit fb divider to its maximum */
868 if (*fb_div > fb_div_max) {
869 *ref_div = DIV_ROUND_CLOSEST(*ref_div * fb_div_max, *fb_div);
870 *fb_div = fb_div_max;
871 }
872}
873
874/**
843 * radeon_compute_pll_avivo - compute PLL paramaters 875 * radeon_compute_pll_avivo - compute PLL paramaters
844 * 876 *
845 * @pll: information about the PLL 877 * @pll: information about the PLL
@@ -860,6 +892,9 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
860 u32 *ref_div_p, 892 u32 *ref_div_p,
861 u32 *post_div_p) 893 u32 *post_div_p)
862{ 894{
895 unsigned target_clock = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ?
896 freq : freq / 10;
897
863 unsigned fb_div_min, fb_div_max, fb_div; 898 unsigned fb_div_min, fb_div_max, fb_div;
864 unsigned post_div_min, post_div_max, post_div; 899 unsigned post_div_min, post_div_max, post_div;
865 unsigned ref_div_min, ref_div_max, ref_div; 900 unsigned ref_div_min, ref_div_max, ref_div;
@@ -880,14 +915,18 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
880 ref_div_min = pll->reference_div; 915 ref_div_min = pll->reference_div;
881 else 916 else
882 ref_div_min = pll->min_ref_div; 917 ref_div_min = pll->min_ref_div;
883 ref_div_max = pll->max_ref_div; 918
919 if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV &&
920 pll->flags & RADEON_PLL_USE_REF_DIV)
921 ref_div_max = pll->reference_div;
922 else
923 ref_div_max = pll->max_ref_div;
884 924
885 /* determine allowed post divider range */ 925 /* determine allowed post divider range */
886 if (pll->flags & RADEON_PLL_USE_POST_DIV) { 926 if (pll->flags & RADEON_PLL_USE_POST_DIV) {
887 post_div_min = pll->post_div; 927 post_div_min = pll->post_div;
888 post_div_max = pll->post_div; 928 post_div_max = pll->post_div;
889 } else { 929 } else {
890 unsigned target_clock = freq / 10;
891 unsigned vco_min, vco_max; 930 unsigned vco_min, vco_max;
892 931
893 if (pll->flags & RADEON_PLL_IS_LCD) { 932 if (pll->flags & RADEON_PLL_IS_LCD) {
@@ -898,6 +937,11 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
898 vco_max = pll->pll_out_max; 937 vco_max = pll->pll_out_max;
899 } 938 }
900 939
940 if (pll->flags & RADEON_PLL_USE_FRAC_FB_DIV) {
941 vco_min *= 10;
942 vco_max *= 10;
943 }
944
901 post_div_min = vco_min / target_clock; 945 post_div_min = vco_min / target_clock;
902 if ((target_clock * post_div_min) < vco_min) 946 if ((target_clock * post_div_min) < vco_min)
903 ++post_div_min; 947 ++post_div_min;
@@ -912,7 +956,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
912 } 956 }
913 957
914 /* represent the searched ratio as fractional number */ 958 /* represent the searched ratio as fractional number */
915 nom = pll->flags & RADEON_PLL_USE_FRAC_FB_DIV ? freq : freq / 10; 959 nom = target_clock;
916 den = pll->reference_freq; 960 den = pll->reference_freq;
917 961
918 /* reduce the numbers to a simpler ratio */ 962 /* reduce the numbers to a simpler ratio */
@@ -926,7 +970,12 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
926 diff_best = ~0; 970 diff_best = ~0;
927 971
928 for (post_div = post_div_min; post_div <= post_div_max; ++post_div) { 972 for (post_div = post_div_min; post_div <= post_div_max; ++post_div) {
929 unsigned diff = abs(den - den / post_div * post_div); 973 unsigned diff;
974 avivo_get_fb_ref_div(nom, den, post_div, fb_div_max,
975 ref_div_max, &fb_div, &ref_div);
976 diff = abs(target_clock - (pll->reference_freq * fb_div) /
977 (ref_div * post_div));
978
930 if (diff < diff_best || (diff == diff_best && 979 if (diff < diff_best || (diff == diff_best &&
931 !(pll->flags & RADEON_PLL_PREFER_MINM_OVER_MAXP))) { 980 !(pll->flags & RADEON_PLL_PREFER_MINM_OVER_MAXP))) {
932 981
@@ -936,28 +985,9 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
936 } 985 }
937 post_div = post_div_best; 986 post_div = post_div_best;
938 987
939 /* limit reference * post divider to a maximum */ 988 /* get the feedback and reference divider for the optimal value */
940 ref_div_max = min(210 / post_div, ref_div_max); 989 avivo_get_fb_ref_div(nom, den, post_div, fb_div_max, ref_div_max,
941 990 &fb_div, &ref_div);
942 /* get matching reference and feedback divider */
943 ref_div = max(DIV_ROUND_CLOSEST(den, post_div), 1u);
944 fb_div = DIV_ROUND_CLOSEST(nom * ref_div * post_div, den);
945
946 /* we're almost done, but reference and feedback
947 divider might be to large now */
948
949 nom = fb_div;
950 den = ref_div;
951
952 if (fb_div > fb_div_max) {
953 ref_div = DIV_ROUND_CLOSEST(den * fb_div_max, nom);
954 fb_div = fb_div_max;
955 }
956
957 if (ref_div > ref_div_max) {
958 ref_div = ref_div_max;
959 fb_div = DIV_ROUND_CLOSEST(nom * ref_div_max, den);
960 }
961 991
962 /* reduce the numbers to a simpler ratio once more */ 992 /* reduce the numbers to a simpler ratio once more */
963 /* this also makes sure that the reference divider is large enough */ 993 /* this also makes sure that the reference divider is large enough */
@@ -979,7 +1009,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
979 *post_div_p = post_div; 1009 *post_div_p = post_div;
980 1010
981 DRM_DEBUG_KMS("%d - %d, pll dividers - fb: %d.%d ref: %d, post %d\n", 1011 DRM_DEBUG_KMS("%d - %d, pll dividers - fb: %d.%d ref: %d, post %d\n",
982 freq, *dot_clock_p, *fb_div_p, *frac_fb_div_p, 1012 freq, *dot_clock_p * 10, *fb_div_p, *frac_fb_div_p,
983 ref_div, post_div); 1013 ref_div, post_div);
984} 1014}
985 1015
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index fb3d13f693dd..0cc47f12d995 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -107,11 +107,9 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
107 flags |= RADEON_IS_PCI; 107 flags |= RADEON_IS_PCI;
108 } 108 }
109 109
110 if (radeon_runtime_pm == 1) 110 if ((radeon_runtime_pm != 0) &&
111 flags |= RADEON_IS_PX; 111 radeon_has_atpx() &&
112 else if ((radeon_runtime_pm == -1) && 112 ((flags & RADEON_IS_IGP) == 0))
113 radeon_has_atpx() &&
114 ((flags & RADEON_IS_IGP) == 0))
115 flags |= RADEON_IS_PX; 113 flags |= RADEON_IS_PX;
116 114
117 /* radeon_device_init should report only fatal error 115 /* radeon_device_init should report only fatal error
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index ee738a524639..6fac8efe8340 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -603,7 +603,6 @@ static const struct attribute_group *hwmon_groups[] = {
603static int radeon_hwmon_init(struct radeon_device *rdev) 603static int radeon_hwmon_init(struct radeon_device *rdev)
604{ 604{
605 int err = 0; 605 int err = 0;
606 struct device *hwmon_dev;
607 606
608 switch (rdev->pm.int_thermal_type) { 607 switch (rdev->pm.int_thermal_type) {
609 case THERMAL_TYPE_RV6XX: 608 case THERMAL_TYPE_RV6XX:
@@ -616,11 +615,11 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
616 case THERMAL_TYPE_KV: 615 case THERMAL_TYPE_KV:
617 if (rdev->asic->pm.get_temperature == NULL) 616 if (rdev->asic->pm.get_temperature == NULL)
618 return err; 617 return err;
619 hwmon_dev = hwmon_device_register_with_groups(rdev->dev, 618 rdev->pm.int_hwmon_dev = hwmon_device_register_with_groups(rdev->dev,
620 "radeon", rdev, 619 "radeon", rdev,
621 hwmon_groups); 620 hwmon_groups);
622 if (IS_ERR(hwmon_dev)) { 621 if (IS_ERR(rdev->pm.int_hwmon_dev)) {
623 err = PTR_ERR(hwmon_dev); 622 err = PTR_ERR(rdev->pm.int_hwmon_dev);
624 dev_err(rdev->dev, 623 dev_err(rdev->dev,
625 "Unable to register hwmon device: %d\n", err); 624 "Unable to register hwmon device: %d\n", err);
626 } 625 }
@@ -632,6 +631,12 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
632 return err; 631 return err;
633} 632}
634 633
634static void radeon_hwmon_fini(struct radeon_device *rdev)
635{
636 if (rdev->pm.int_hwmon_dev)
637 hwmon_device_unregister(rdev->pm.int_hwmon_dev);
638}
639
635static void radeon_dpm_thermal_work_handler(struct work_struct *work) 640static void radeon_dpm_thermal_work_handler(struct work_struct *work)
636{ 641{
637 struct radeon_device *rdev = 642 struct radeon_device *rdev =
@@ -1257,6 +1262,7 @@ int radeon_pm_init(struct radeon_device *rdev)
1257 case CHIP_RV670: 1262 case CHIP_RV670:
1258 case CHIP_RS780: 1263 case CHIP_RS780:
1259 case CHIP_RS880: 1264 case CHIP_RS880:
1265 case CHIP_RV770:
1260 case CHIP_BARTS: 1266 case CHIP_BARTS:
1261 case CHIP_TURKS: 1267 case CHIP_TURKS:
1262 case CHIP_CAICOS: 1268 case CHIP_CAICOS:
@@ -1273,7 +1279,6 @@ int radeon_pm_init(struct radeon_device *rdev)
1273 else 1279 else
1274 rdev->pm.pm_method = PM_METHOD_PROFILE; 1280 rdev->pm.pm_method = PM_METHOD_PROFILE;
1275 break; 1281 break;
1276 case CHIP_RV770:
1277 case CHIP_RV730: 1282 case CHIP_RV730:
1278 case CHIP_RV710: 1283 case CHIP_RV710:
1279 case CHIP_RV740: 1284 case CHIP_RV740:
@@ -1353,6 +1358,8 @@ static void radeon_pm_fini_old(struct radeon_device *rdev)
1353 device_remove_file(rdev->dev, &dev_attr_power_method); 1358 device_remove_file(rdev->dev, &dev_attr_power_method);
1354 } 1359 }
1355 1360
1361 radeon_hwmon_fini(rdev);
1362
1356 if (rdev->pm.power_state) 1363 if (rdev->pm.power_state)
1357 kfree(rdev->pm.power_state); 1364 kfree(rdev->pm.power_state);
1358} 1365}
@@ -1372,6 +1379,8 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev)
1372 } 1379 }
1373 radeon_dpm_fini(rdev); 1380 radeon_dpm_fini(rdev);
1374 1381
1382 radeon_hwmon_fini(rdev);
1383
1375 if (rdev->pm.power_state) 1384 if (rdev->pm.power_state)
1376 kfree(rdev->pm.power_state); 1385 kfree(rdev->pm.power_state);
1377} 1386}
@@ -1397,12 +1406,14 @@ static void radeon_pm_compute_clocks_old(struct radeon_device *rdev)
1397 1406
1398 rdev->pm.active_crtcs = 0; 1407 rdev->pm.active_crtcs = 0;
1399 rdev->pm.active_crtc_count = 0; 1408 rdev->pm.active_crtc_count = 0;
1400 list_for_each_entry(crtc, 1409 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
1401 &ddev->mode_config.crtc_list, head) { 1410 list_for_each_entry(crtc,
1402 radeon_crtc = to_radeon_crtc(crtc); 1411 &ddev->mode_config.crtc_list, head) {
1403 if (radeon_crtc->enabled) { 1412 radeon_crtc = to_radeon_crtc(crtc);
1404 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id); 1413 if (radeon_crtc->enabled) {
1405 rdev->pm.active_crtc_count++; 1414 rdev->pm.active_crtcs |= (1 << radeon_crtc->crtc_id);
1415 rdev->pm.active_crtc_count++;
1416 }
1406 } 1417 }
1407 } 1418 }
1408 1419
@@ -1469,12 +1480,14 @@ static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev)
1469 /* update active crtc counts */ 1480 /* update active crtc counts */
1470 rdev->pm.dpm.new_active_crtcs = 0; 1481 rdev->pm.dpm.new_active_crtcs = 0;
1471 rdev->pm.dpm.new_active_crtc_count = 0; 1482 rdev->pm.dpm.new_active_crtc_count = 0;
1472 list_for_each_entry(crtc, 1483 if (rdev->num_crtc && rdev->mode_info.mode_config_initialized) {
1473 &ddev->mode_config.crtc_list, head) { 1484 list_for_each_entry(crtc,
1474 radeon_crtc = to_radeon_crtc(crtc); 1485 &ddev->mode_config.crtc_list, head) {
1475 if (crtc->enabled) { 1486 radeon_crtc = to_radeon_crtc(crtc);
1476 rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id); 1487 if (crtc->enabled) {
1477 rdev->pm.dpm.new_active_crtc_count++; 1488 rdev->pm.dpm.new_active_crtcs |= (1 << radeon_crtc->crtc_id);
1489 rdev->pm.dpm.new_active_crtc_count++;
1490 }
1478 } 1491 }
1479 } 1492 }
1480 1493
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 36c717af6cf9..edb871d7d395 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -312,7 +312,7 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
312 struct drm_device *drm = crtc->dev; 312 struct drm_device *drm = crtc->dev;
313 struct drm_plane *plane; 313 struct drm_plane *plane;
314 314
315 list_for_each_entry(plane, &drm->mode_config.plane_list, head) { 315 drm_for_each_legacy_plane(plane, &drm->mode_config.plane_list) {
316 if (plane->crtc == crtc) { 316 if (plane->crtc == crtc) {
317 tegra_plane_disable(plane); 317 tegra_plane_disable(plane);
318 plane->crtc = NULL; 318 plane->crtc = NULL;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 931490b9cfed..87df0b3674fd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -1214,14 +1214,36 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv,
1214 SVGA3dCmdSurfaceDMA dma; 1214 SVGA3dCmdSurfaceDMA dma;
1215 } *cmd; 1215 } *cmd;
1216 int ret; 1216 int ret;
1217 SVGA3dCmdSurfaceDMASuffix *suffix;
1218 uint32_t bo_size;
1217 1219
1218 cmd = container_of(header, struct vmw_dma_cmd, header); 1220 cmd = container_of(header, struct vmw_dma_cmd, header);
1221 suffix = (SVGA3dCmdSurfaceDMASuffix *)((unsigned long) &cmd->dma +
1222 header->size - sizeof(*suffix));
1223
1224 /* Make sure device and verifier stays in sync. */
1225 if (unlikely(suffix->suffixSize != sizeof(*suffix))) {
1226 DRM_ERROR("Invalid DMA suffix size.\n");
1227 return -EINVAL;
1228 }
1229
1219 ret = vmw_translate_guest_ptr(dev_priv, sw_context, 1230 ret = vmw_translate_guest_ptr(dev_priv, sw_context,
1220 &cmd->dma.guest.ptr, 1231 &cmd->dma.guest.ptr,
1221 &vmw_bo); 1232 &vmw_bo);
1222 if (unlikely(ret != 0)) 1233 if (unlikely(ret != 0))
1223 return ret; 1234 return ret;
1224 1235
1236 /* Make sure DMA doesn't cross BO boundaries. */
1237 bo_size = vmw_bo->base.num_pages * PAGE_SIZE;
1238 if (unlikely(cmd->dma.guest.ptr.offset > bo_size)) {
1239 DRM_ERROR("Invalid DMA offset.\n");
1240 return -EINVAL;
1241 }
1242
1243 bo_size -= cmd->dma.guest.ptr.offset;
1244 if (unlikely(suffix->maximumOffset > bo_size))
1245 suffix->maximumOffset = bo_size;
1246
1225 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, 1247 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
1226 user_surface_converter, &cmd->dma.host.sid, 1248 user_surface_converter, &cmd->dma.host.sid,
1227 NULL); 1249 NULL);
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 6d02e3b06375..d76f0b70c6e0 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -365,12 +365,12 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
365 if (cpu_has_tjmax(c)) 365 if (cpu_has_tjmax(c))
366 dev_warn(dev, "Unable to read TjMax from CPU %u\n", id); 366 dev_warn(dev, "Unable to read TjMax from CPU %u\n", id);
367 } else { 367 } else {
368 val = (eax >> 16) & 0x7f; 368 val = (eax >> 16) & 0xff;
369 /* 369 /*
370 * If the TjMax is not plausible, an assumption 370 * If the TjMax is not plausible, an assumption
371 * will be used 371 * will be used
372 */ 372 */
373 if (val >= 85) { 373 if (val) {
374 dev_dbg(dev, "TjMax is %d degrees C\n", val); 374 dev_dbg(dev, "TjMax is %d degrees C\n", val);
375 return val * 1000; 375 return val * 1000;
376 } 376 }
diff --git a/drivers/hwmon/ltc2945.c b/drivers/hwmon/ltc2945.c
index c104cc32989d..c9cddf5f056b 100644
--- a/drivers/hwmon/ltc2945.c
+++ b/drivers/hwmon/ltc2945.c
@@ -1,4 +1,4 @@
1/* 1 /*
2 * Driver for Linear Technology LTC2945 I2C Power Monitor 2 * Driver for Linear Technology LTC2945 I2C Power Monitor
3 * 3 *
4 * Copyright (c) 2014 Guenter Roeck 4 * Copyright (c) 2014 Guenter Roeck
@@ -314,8 +314,8 @@ static ssize_t ltc2945_reset_history(struct device *dev,
314 reg = LTC2945_MAX_ADIN_H; 314 reg = LTC2945_MAX_ADIN_H;
315 break; 315 break;
316 default: 316 default:
317 BUG(); 317 WARN_ONCE(1, "Bad register: 0x%x\n", reg);
318 break; 318 return -EINVAL;
319 } 319 }
320 /* Reset maximum */ 320 /* Reset maximum */
321 ret = regmap_bulk_write(regmap, reg, buf_max, num_regs); 321 ret = regmap_bulk_write(regmap, reg, buf_max, num_regs);
diff --git a/drivers/hwmon/vexpress.c b/drivers/hwmon/vexpress.c
index d867e6bb2be1..8242b75d96c8 100644
--- a/drivers/hwmon/vexpress.c
+++ b/drivers/hwmon/vexpress.c
@@ -27,15 +27,15 @@
27struct vexpress_hwmon_data { 27struct vexpress_hwmon_data {
28 struct device *hwmon_dev; 28 struct device *hwmon_dev;
29 struct vexpress_config_func *func; 29 struct vexpress_config_func *func;
30 const char *name;
30}; 31};
31 32
32static ssize_t vexpress_hwmon_name_show(struct device *dev, 33static ssize_t vexpress_hwmon_name_show(struct device *dev,
33 struct device_attribute *dev_attr, char *buffer) 34 struct device_attribute *dev_attr, char *buffer)
34{ 35{
35 const char *compatible = of_get_property(dev->of_node, "compatible", 36 struct vexpress_hwmon_data *data = dev_get_drvdata(dev);
36 NULL);
37 37
38 return sprintf(buffer, "%s\n", compatible); 38 return sprintf(buffer, "%s\n", data->name);
39} 39}
40 40
41static ssize_t vexpress_hwmon_label_show(struct device *dev, 41static ssize_t vexpress_hwmon_label_show(struct device *dev,
@@ -43,9 +43,6 @@ static ssize_t vexpress_hwmon_label_show(struct device *dev,
43{ 43{
44 const char *label = of_get_property(dev->of_node, "label", NULL); 44 const char *label = of_get_property(dev->of_node, "label", NULL);
45 45
46 if (!label)
47 return -ENOENT;
48
49 return snprintf(buffer, PAGE_SIZE, "%s\n", label); 46 return snprintf(buffer, PAGE_SIZE, "%s\n", label);
50} 47}
51 48
@@ -84,6 +81,20 @@ static ssize_t vexpress_hwmon_u64_show(struct device *dev,
84 to_sensor_dev_attr(dev_attr)->index)); 81 to_sensor_dev_attr(dev_attr)->index));
85} 82}
86 83
84static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
85 struct attribute *attr, int index)
86{
87 struct device *dev = kobj_to_dev(kobj);
88 struct device_attribute *dev_attr = container_of(attr,
89 struct device_attribute, attr);
90
91 if (dev_attr->show == vexpress_hwmon_label_show &&
92 !of_get_property(dev->of_node, "label", NULL))
93 return 0;
94
95 return attr->mode;
96}
97
87static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL); 98static DEVICE_ATTR(name, S_IRUGO, vexpress_hwmon_name_show, NULL);
88 99
89#define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr) \ 100#define VEXPRESS_HWMON_ATTRS(_name, _label_attr, _input_attr) \
@@ -94,14 +105,27 @@ struct attribute *vexpress_hwmon_attrs_##_name[] = { \
94 NULL \ 105 NULL \
95} 106}
96 107
108struct vexpress_hwmon_type {
109 const char *name;
110 const struct attribute_group **attr_groups;
111};
112
97#if !defined(CONFIG_REGULATOR_VEXPRESS) 113#if !defined(CONFIG_REGULATOR_VEXPRESS)
98static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 114static DEVICE_ATTR(in1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
99static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show, 115static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, vexpress_hwmon_u32_show,
100 NULL, 1000); 116 NULL, 1000);
101static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input); 117static VEXPRESS_HWMON_ATTRS(volt, in1_label, in1_input);
102static struct attribute_group vexpress_hwmon_group_volt = { 118static struct attribute_group vexpress_hwmon_group_volt = {
119 .is_visible = vexpress_hwmon_attr_is_visible,
103 .attrs = vexpress_hwmon_attrs_volt, 120 .attrs = vexpress_hwmon_attrs_volt,
104}; 121};
122static struct vexpress_hwmon_type vexpress_hwmon_volt = {
123 .name = "vexpress_volt",
124 .attr_groups = (const struct attribute_group *[]) {
125 &vexpress_hwmon_group_volt,
126 NULL,
127 },
128};
105#endif 129#endif
106 130
107static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 131static DEVICE_ATTR(curr1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
@@ -109,52 +133,84 @@ static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, vexpress_hwmon_u32_show,
109 NULL, 1000); 133 NULL, 1000);
110static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input); 134static VEXPRESS_HWMON_ATTRS(amp, curr1_label, curr1_input);
111static struct attribute_group vexpress_hwmon_group_amp = { 135static struct attribute_group vexpress_hwmon_group_amp = {
136 .is_visible = vexpress_hwmon_attr_is_visible,
112 .attrs = vexpress_hwmon_attrs_amp, 137 .attrs = vexpress_hwmon_attrs_amp,
113}; 138};
139static struct vexpress_hwmon_type vexpress_hwmon_amp = {
140 .name = "vexpress_amp",
141 .attr_groups = (const struct attribute_group *[]) {
142 &vexpress_hwmon_group_amp,
143 NULL
144 },
145};
114 146
115static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 147static DEVICE_ATTR(temp1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
116static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show, 148static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, vexpress_hwmon_u32_show,
117 NULL, 1000); 149 NULL, 1000);
118static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input); 150static VEXPRESS_HWMON_ATTRS(temp, temp1_label, temp1_input);
119static struct attribute_group vexpress_hwmon_group_temp = { 151static struct attribute_group vexpress_hwmon_group_temp = {
152 .is_visible = vexpress_hwmon_attr_is_visible,
120 .attrs = vexpress_hwmon_attrs_temp, 153 .attrs = vexpress_hwmon_attrs_temp,
121}; 154};
155static struct vexpress_hwmon_type vexpress_hwmon_temp = {
156 .name = "vexpress_temp",
157 .attr_groups = (const struct attribute_group *[]) {
158 &vexpress_hwmon_group_temp,
159 NULL
160 },
161};
122 162
123static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 163static DEVICE_ATTR(power1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
124static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show, 164static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, vexpress_hwmon_u32_show,
125 NULL, 1); 165 NULL, 1);
126static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input); 166static VEXPRESS_HWMON_ATTRS(power, power1_label, power1_input);
127static struct attribute_group vexpress_hwmon_group_power = { 167static struct attribute_group vexpress_hwmon_group_power = {
168 .is_visible = vexpress_hwmon_attr_is_visible,
128 .attrs = vexpress_hwmon_attrs_power, 169 .attrs = vexpress_hwmon_attrs_power,
129}; 170};
171static struct vexpress_hwmon_type vexpress_hwmon_power = {
172 .name = "vexpress_power",
173 .attr_groups = (const struct attribute_group *[]) {
174 &vexpress_hwmon_group_power,
175 NULL
176 },
177};
130 178
131static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL); 179static DEVICE_ATTR(energy1_label, S_IRUGO, vexpress_hwmon_label_show, NULL);
132static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show, 180static SENSOR_DEVICE_ATTR(energy1_input, S_IRUGO, vexpress_hwmon_u64_show,
133 NULL, 1); 181 NULL, 1);
134static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input); 182static VEXPRESS_HWMON_ATTRS(energy, energy1_label, energy1_input);
135static struct attribute_group vexpress_hwmon_group_energy = { 183static struct attribute_group vexpress_hwmon_group_energy = {
184 .is_visible = vexpress_hwmon_attr_is_visible,
136 .attrs = vexpress_hwmon_attrs_energy, 185 .attrs = vexpress_hwmon_attrs_energy,
137}; 186};
187static struct vexpress_hwmon_type vexpress_hwmon_energy = {
188 .name = "vexpress_energy",
189 .attr_groups = (const struct attribute_group *[]) {
190 &vexpress_hwmon_group_energy,
191 NULL
192 },
193};
138 194
139static struct of_device_id vexpress_hwmon_of_match[] = { 195static struct of_device_id vexpress_hwmon_of_match[] = {
140#if !defined(CONFIG_REGULATOR_VEXPRESS) 196#if !defined(CONFIG_REGULATOR_VEXPRESS)
141 { 197 {
142 .compatible = "arm,vexpress-volt", 198 .compatible = "arm,vexpress-volt",
143 .data = &vexpress_hwmon_group_volt, 199 .data = &vexpress_hwmon_volt,
144 }, 200 },
145#endif 201#endif
146 { 202 {
147 .compatible = "arm,vexpress-amp", 203 .compatible = "arm,vexpress-amp",
148 .data = &vexpress_hwmon_group_amp, 204 .data = &vexpress_hwmon_amp,
149 }, { 205 }, {
150 .compatible = "arm,vexpress-temp", 206 .compatible = "arm,vexpress-temp",
151 .data = &vexpress_hwmon_group_temp, 207 .data = &vexpress_hwmon_temp,
152 }, { 208 }, {
153 .compatible = "arm,vexpress-power", 209 .compatible = "arm,vexpress-power",
154 .data = &vexpress_hwmon_group_power, 210 .data = &vexpress_hwmon_power,
155 }, { 211 }, {
156 .compatible = "arm,vexpress-energy", 212 .compatible = "arm,vexpress-energy",
157 .data = &vexpress_hwmon_group_energy, 213 .data = &vexpress_hwmon_energy,
158 }, 214 },
159 {} 215 {}
160}; 216};
@@ -165,6 +221,7 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
165 int err; 221 int err;
166 const struct of_device_id *match; 222 const struct of_device_id *match;
167 struct vexpress_hwmon_data *data; 223 struct vexpress_hwmon_data *data;
224 const struct vexpress_hwmon_type *type;
168 225
169 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 226 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
170 if (!data) 227 if (!data)
@@ -174,12 +231,14 @@ static int vexpress_hwmon_probe(struct platform_device *pdev)
174 match = of_match_device(vexpress_hwmon_of_match, &pdev->dev); 231 match = of_match_device(vexpress_hwmon_of_match, &pdev->dev);
175 if (!match) 232 if (!match)
176 return -ENODEV; 233 return -ENODEV;
234 type = match->data;
235 data->name = type->name;
177 236
178 data->func = vexpress_config_func_get_by_dev(&pdev->dev); 237 data->func = vexpress_config_func_get_by_dev(&pdev->dev);
179 if (!data->func) 238 if (!data->func)
180 return -ENODEV; 239 return -ENODEV;
181 240
182 err = sysfs_create_group(&pdev->dev.kobj, match->data); 241 err = sysfs_create_groups(&pdev->dev.kobj, type->attr_groups);
183 if (err) 242 if (err)
184 goto error; 243 goto error;
185 244
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index a43220c2e3d9..4d140bbbe100 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -750,9 +750,10 @@ void intel_idle_state_table_update(void)
750 if (package_num + 1 > num_sockets) { 750 if (package_num + 1 > num_sockets) {
751 num_sockets = package_num + 1; 751 num_sockets = package_num + 1;
752 752
753 if (num_sockets > 4) 753 if (num_sockets > 4) {
754 cpuidle_state_table = ivt_cstates_8s; 754 cpuidle_state_table = ivt_cstates_8s;
755 return; 755 return;
756 }
756 } 757 }
757 } 758 }
758 759
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index d86196cfe4b4..24c28e3f93a3 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -106,7 +106,7 @@ config AT91_ADC
106 Say yes here to build support for Atmel AT91 ADC. 106 Say yes here to build support for Atmel AT91 ADC.
107 107
108config EXYNOS_ADC 108config EXYNOS_ADC
109 bool "Exynos ADC driver support" 109 tristate "Exynos ADC driver support"
110 depends on OF 110 depends on OF
111 help 111 help
112 Core support for the ADC block found in the Samsung EXYNOS series 112 Core support for the ADC block found in the Samsung EXYNOS series
@@ -114,7 +114,7 @@ config EXYNOS_ADC
114 this resource. 114 this resource.
115 115
116config LP8788_ADC 116config LP8788_ADC
117 bool "LP8788 ADC driver" 117 tristate "LP8788 ADC driver"
118 depends on MFD_LP8788 118 depends on MFD_LP8788
119 help 119 help
120 Say yes here to build support for TI LP8788 ADC. 120 Say yes here to build support for TI LP8788 ADC.
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5b1aa027c034..89777ed9abd8 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -765,14 +765,17 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st,
765 if (!pdata) 765 if (!pdata)
766 return -EINVAL; 766 return -EINVAL;
767 767
768 st->caps = (struct at91_adc_caps *)
769 platform_get_device_id(pdev)->driver_data;
770
768 st->use_external = pdata->use_external_triggers; 771 st->use_external = pdata->use_external_triggers;
769 st->vref_mv = pdata->vref; 772 st->vref_mv = pdata->vref;
770 st->channels_mask = pdata->channels_used; 773 st->channels_mask = pdata->channels_used;
771 st->num_channels = pdata->num_channels; 774 st->num_channels = st->caps->num_channels;
772 st->startup_time = pdata->startup_time; 775 st->startup_time = pdata->startup_time;
773 st->trigger_number = pdata->trigger_number; 776 st->trigger_number = pdata->trigger_number;
774 st->trigger_list = pdata->trigger_list; 777 st->trigger_list = pdata->trigger_list;
775 st->registers = pdata->registers; 778 st->registers = &st->caps->registers;
776 779
777 return 0; 780 return 0;
778} 781}
@@ -1004,8 +1007,11 @@ static int at91_adc_probe(struct platform_device *pdev)
1004 * the best converted final value between two channels selection 1007 * the best converted final value between two channels selection
1005 * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock 1008 * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock
1006 */ 1009 */
1007 shtim = round_up((st->sample_hold_time * adc_clk_khz / 1010 if (st->sample_hold_time > 0)
1008 1000) - 1, 1); 1011 shtim = round_up((st->sample_hold_time * adc_clk_khz / 1000)
1012 - 1, 1);
1013 else
1014 shtim = 0;
1009 1015
1010 reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; 1016 reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask;
1011 reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; 1017 reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask;
@@ -1101,7 +1107,6 @@ static int at91_adc_remove(struct platform_device *pdev)
1101 return 0; 1107 return 0;
1102} 1108}
1103 1109
1104#ifdef CONFIG_OF
1105static struct at91_adc_caps at91sam9260_caps = { 1110static struct at91_adc_caps at91sam9260_caps = {
1106 .calc_startup_ticks = calc_startup_ticks_9260, 1111 .calc_startup_ticks = calc_startup_ticks_9260,
1107 .num_channels = 4, 1112 .num_channels = 4,
@@ -1154,11 +1159,27 @@ static const struct of_device_id at91_adc_dt_ids[] = {
1154 {}, 1159 {},
1155}; 1160};
1156MODULE_DEVICE_TABLE(of, at91_adc_dt_ids); 1161MODULE_DEVICE_TABLE(of, at91_adc_dt_ids);
1157#endif 1162
1163static const struct platform_device_id at91_adc_ids[] = {
1164 {
1165 .name = "at91sam9260-adc",
1166 .driver_data = (unsigned long)&at91sam9260_caps,
1167 }, {
1168 .name = "at91sam9g45-adc",
1169 .driver_data = (unsigned long)&at91sam9g45_caps,
1170 }, {
1171 .name = "at91sam9x5-adc",
1172 .driver_data = (unsigned long)&at91sam9x5_caps,
1173 }, {
1174 /* terminator */
1175 }
1176};
1177MODULE_DEVICE_TABLE(platform, at91_adc_ids);
1158 1178
1159static struct platform_driver at91_adc_driver = { 1179static struct platform_driver at91_adc_driver = {
1160 .probe = at91_adc_probe, 1180 .probe = at91_adc_probe,
1161 .remove = at91_adc_remove, 1181 .remove = at91_adc_remove,
1182 .id_table = at91_adc_ids,
1162 .driver = { 1183 .driver = {
1163 .name = DRIVER_NAME, 1184 .name = DRIVER_NAME,
1164 .of_match_table = of_match_ptr(at91_adc_dt_ids), 1185 .of_match_table = of_match_ptr(at91_adc_dt_ids),
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index d25b262193a7..affa93f51789 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -344,7 +344,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
344 344
345 exynos_adc_hw_init(info); 345 exynos_adc_hw_init(info);
346 346
347 ret = of_platform_populate(np, exynos_adc_match, NULL, &pdev->dev); 347 ret = of_platform_populate(np, exynos_adc_match, NULL, &indio_dev->dev);
348 if (ret < 0) { 348 if (ret < 0) {
349 dev_err(&pdev->dev, "failed adding child nodes\n"); 349 dev_err(&pdev->dev, "failed adding child nodes\n");
350 goto err_of_populate; 350 goto err_of_populate;
@@ -353,7 +353,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
353 return 0; 353 return 0;
354 354
355err_of_populate: 355err_of_populate:
356 device_for_each_child(&pdev->dev, NULL, 356 device_for_each_child(&indio_dev->dev, NULL,
357 exynos_adc_remove_devices); 357 exynos_adc_remove_devices);
358 regulator_disable(info->vdd); 358 regulator_disable(info->vdd);
359 clk_disable_unprepare(info->clk); 359 clk_disable_unprepare(info->clk);
@@ -369,7 +369,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
369 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 369 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
370 struct exynos_adc *info = iio_priv(indio_dev); 370 struct exynos_adc *info = iio_priv(indio_dev);
371 371
372 device_for_each_child(&pdev->dev, NULL, 372 device_for_each_child(&indio_dev->dev, NULL,
373 exynos_adc_remove_devices); 373 exynos_adc_remove_devices);
374 regulator_disable(info->vdd); 374 regulator_disable(info->vdd);
375 clk_disable_unprepare(info->clk); 375 clk_disable_unprepare(info->clk);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index cb9f96b446a5..d8ad606c7cd0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -660,6 +660,7 @@ static int inv_mpu_probe(struct i2c_client *client,
660{ 660{
661 struct inv_mpu6050_state *st; 661 struct inv_mpu6050_state *st;
662 struct iio_dev *indio_dev; 662 struct iio_dev *indio_dev;
663 struct inv_mpu6050_platform_data *pdata;
663 int result; 664 int result;
664 665
665 if (!i2c_check_functionality(client->adapter, 666 if (!i2c_check_functionality(client->adapter,
@@ -672,8 +673,10 @@ static int inv_mpu_probe(struct i2c_client *client,
672 673
673 st = iio_priv(indio_dev); 674 st = iio_priv(indio_dev);
674 st->client = client; 675 st->client = client;
675 st->plat_data = *(struct inv_mpu6050_platform_data 676 pdata = (struct inv_mpu6050_platform_data
676 *)dev_get_platdata(&client->dev); 677 *)dev_get_platdata(&client->dev);
678 if (pdata)
679 st->plat_data = *pdata;
677 /* power is turned on inside check chip type*/ 680 /* power is turned on inside check chip type*/
678 result = inv_check_and_setup_chip(st, id); 681 result = inv_check_and_setup_chip(st, id);
679 if (result) 682 if (result)
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index e108f2a9d827..e472cff6eeae 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -165,7 +165,8 @@ static ssize_t iio_scan_el_show(struct device *dev,
165 int ret; 165 int ret;
166 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 166 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
167 167
168 ret = test_bit(to_iio_dev_attr(attr)->address, 168 /* Ensure ret is 0 or 1. */
169 ret = !!test_bit(to_iio_dev_attr(attr)->address,
169 indio_dev->buffer->scan_mask); 170 indio_dev->buffer->scan_mask);
170 171
171 return sprintf(buf, "%d\n", ret); 172 return sprintf(buf, "%d\n", ret);
@@ -862,7 +863,8 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
862 if (!buffer->scan_mask) 863 if (!buffer->scan_mask)
863 return 0; 864 return 0;
864 865
865 return test_bit(bit, buffer->scan_mask); 866 /* Ensure return value is 0 or 1. */
867 return !!test_bit(bit, buffer->scan_mask);
866}; 868};
867EXPORT_SYMBOL_GPL(iio_scan_mask_query); 869EXPORT_SYMBOL_GPL(iio_scan_mask_query);
868 870
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 47a6dbac2d0c..d976e6ce60db 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -221,6 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
221 *val = cm32181->calibscale; 221 *val = cm32181->calibscale;
222 return IIO_VAL_INT; 222 return IIO_VAL_INT;
223 case IIO_CHAN_INFO_INT_TIME: 223 case IIO_CHAN_INFO_INT_TIME:
224 *val = 0;
224 ret = cm32181_read_als_it(cm32181, val2); 225 ret = cm32181_read_als_it(cm32181, val2);
225 return ret; 226 return ret;
226 } 227 }
diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c
index a45e07492db3..39fc67e82138 100644
--- a/drivers/iio/light/cm36651.c
+++ b/drivers/iio/light/cm36651.c
@@ -652,7 +652,19 @@ static int cm36651_probe(struct i2c_client *client,
652 cm36651->client = client; 652 cm36651->client = client;
653 cm36651->ps_client = i2c_new_dummy(client->adapter, 653 cm36651->ps_client = i2c_new_dummy(client->adapter,
654 CM36651_I2C_ADDR_PS); 654 CM36651_I2C_ADDR_PS);
655 if (!cm36651->ps_client) {
656 dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
657 ret = -ENODEV;
658 goto error_disable_reg;
659 }
660
655 cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA); 661 cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA);
662 if (!cm36651->ara_client) {
663 dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
664 ret = -ENODEV;
665 goto error_i2c_unregister_ps;
666 }
667
656 mutex_init(&cm36651->lock); 668 mutex_init(&cm36651->lock);
657 indio_dev->dev.parent = &client->dev; 669 indio_dev->dev.parent = &client->dev;
658 indio_dev->channels = cm36651_channels; 670 indio_dev->channels = cm36651_channels;
@@ -664,7 +676,7 @@ static int cm36651_probe(struct i2c_client *client,
664 ret = cm36651_setup_reg(cm36651); 676 ret = cm36651_setup_reg(cm36651);
665 if (ret) { 677 if (ret) {
666 dev_err(&client->dev, "%s: register setup failed\n", __func__); 678 dev_err(&client->dev, "%s: register setup failed\n", __func__);
667 goto error_disable_reg; 679 goto error_i2c_unregister_ara;
668 } 680 }
669 681
670 ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler, 682 ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler,
@@ -672,7 +684,7 @@ static int cm36651_probe(struct i2c_client *client,
672 "cm36651", indio_dev); 684 "cm36651", indio_dev);
673 if (ret) { 685 if (ret) {
674 dev_err(&client->dev, "%s: request irq failed\n", __func__); 686 dev_err(&client->dev, "%s: request irq failed\n", __func__);
675 goto error_disable_reg; 687 goto error_i2c_unregister_ara;
676 } 688 }
677 689
678 ret = iio_device_register(indio_dev); 690 ret = iio_device_register(indio_dev);
@@ -685,6 +697,10 @@ static int cm36651_probe(struct i2c_client *client,
685 697
686error_free_irq: 698error_free_irq:
687 free_irq(client->irq, indio_dev); 699 free_irq(client->irq, indio_dev);
700error_i2c_unregister_ara:
701 i2c_unregister_device(cm36651->ara_client);
702error_i2c_unregister_ps:
703 i2c_unregister_device(cm36651->ps_client);
688error_disable_reg: 704error_disable_reg:
689 regulator_disable(cm36651->vled_reg); 705 regulator_disable(cm36651->vled_reg);
690 return ret; 706 return ret;
@@ -698,6 +714,8 @@ static int cm36651_remove(struct i2c_client *client)
698 iio_device_unregister(indio_dev); 714 iio_device_unregister(indio_dev);
699 regulator_disable(cm36651->vled_reg); 715 regulator_disable(cm36651->vled_reg);
700 free_irq(client->irq, indio_dev); 716 free_irq(client->irq, indio_dev);
717 i2c_unregister_device(cm36651->ps_client);
718 i2c_unregister_device(cm36651->ara_client);
701 719
702 return 0; 720 return 0;
703} 721}
diff --git a/drivers/infiniband/hw/cxgb4/Kconfig b/drivers/infiniband/hw/cxgb4/Kconfig
index d4e8983fba53..23f38cf2c5cd 100644
--- a/drivers/infiniband/hw/cxgb4/Kconfig
+++ b/drivers/infiniband/hw/cxgb4/Kconfig
@@ -1,10 +1,10 @@
1config INFINIBAND_CXGB4 1config INFINIBAND_CXGB4
2 tristate "Chelsio T4 RDMA Driver" 2 tristate "Chelsio T4/T5 RDMA Driver"
3 depends on CHELSIO_T4 && INET && (IPV6 || IPV6=n) 3 depends on CHELSIO_T4 && INET && (IPV6 || IPV6=n)
4 select GENERIC_ALLOCATOR 4 select GENERIC_ALLOCATOR
5 ---help--- 5 ---help---
6 This is an iWARP/RDMA driver for the Chelsio T4 1GbE and 6 This is an iWARP/RDMA driver for the Chelsio T4 and T5
7 10GbE adapters. 7 1GbE, 10GbE adapters and T5 40GbE adapter.
8 8
9 For general information about Chelsio and our products, visit 9 For general information about Chelsio and our products, visit
10 our website at <http://www.chelsio.com>. 10 our website at <http://www.chelsio.com>.
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 185452abf32c..1f863a96a480 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -587,6 +587,10 @@ static int send_connect(struct c4iw_ep *ep)
587 opt2 |= SACK_EN(1); 587 opt2 |= SACK_EN(1);
588 if (wscale && enable_tcp_window_scaling) 588 if (wscale && enable_tcp_window_scaling)
589 opt2 |= WND_SCALE_EN(1); 589 opt2 |= WND_SCALE_EN(1);
590 if (is_t5(ep->com.dev->rdev.lldi.adapter_type)) {
591 opt2 |= T5_OPT_2_VALID;
592 opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
593 }
590 t4_set_arp_err_handler(skb, NULL, act_open_req_arp_failure); 594 t4_set_arp_err_handler(skb, NULL, act_open_req_arp_failure);
591 595
592 if (is_t4(ep->com.dev->rdev.lldi.adapter_type)) { 596 if (is_t4(ep->com.dev->rdev.lldi.adapter_type)) {
@@ -996,7 +1000,7 @@ static void close_complete_upcall(struct c4iw_ep *ep, int status)
996static int abort_connection(struct c4iw_ep *ep, struct sk_buff *skb, gfp_t gfp) 1000static int abort_connection(struct c4iw_ep *ep, struct sk_buff *skb, gfp_t gfp)
997{ 1001{
998 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); 1002 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
999 state_set(&ep->com, ABORTING); 1003 __state_set(&ep->com, ABORTING);
1000 set_bit(ABORT_CONN, &ep->com.history); 1004 set_bit(ABORT_CONN, &ep->com.history);
1001 return send_abort(ep, skb, gfp); 1005 return send_abort(ep, skb, gfp);
1002} 1006}
@@ -1154,7 +1158,7 @@ static int update_rx_credits(struct c4iw_ep *ep, u32 credits)
1154 return credits; 1158 return credits;
1155} 1159}
1156 1160
1157static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb) 1161static int process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1158{ 1162{
1159 struct mpa_message *mpa; 1163 struct mpa_message *mpa;
1160 struct mpa_v2_conn_params *mpa_v2_params; 1164 struct mpa_v2_conn_params *mpa_v2_params;
@@ -1164,6 +1168,7 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1164 struct c4iw_qp_attributes attrs; 1168 struct c4iw_qp_attributes attrs;
1165 enum c4iw_qp_attr_mask mask; 1169 enum c4iw_qp_attr_mask mask;
1166 int err; 1170 int err;
1171 int disconnect = 0;
1167 1172
1168 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid); 1173 PDBG("%s ep %p tid %u\n", __func__, ep, ep->hwtid);
1169 1174
@@ -1173,7 +1178,7 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1173 * will abort the connection. 1178 * will abort the connection.
1174 */ 1179 */
1175 if (stop_ep_timer(ep)) 1180 if (stop_ep_timer(ep))
1176 return; 1181 return 0;
1177 1182
1178 /* 1183 /*
1179 * If we get more than the supported amount of private data 1184 * If we get more than the supported amount of private data
@@ -1195,7 +1200,7 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1195 * if we don't even have the mpa message, then bail. 1200 * if we don't even have the mpa message, then bail.
1196 */ 1201 */
1197 if (ep->mpa_pkt_len < sizeof(*mpa)) 1202 if (ep->mpa_pkt_len < sizeof(*mpa))
1198 return; 1203 return 0;
1199 mpa = (struct mpa_message *) ep->mpa_pkt; 1204 mpa = (struct mpa_message *) ep->mpa_pkt;
1200 1205
1201 /* Validate MPA header. */ 1206 /* Validate MPA header. */
@@ -1235,7 +1240,7 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1235 * We'll continue process when more data arrives. 1240 * We'll continue process when more data arrives.
1236 */ 1241 */
1237 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen)) 1242 if (ep->mpa_pkt_len < (sizeof(*mpa) + plen))
1238 return; 1243 return 0;
1239 1244
1240 if (mpa->flags & MPA_REJECT) { 1245 if (mpa->flags & MPA_REJECT) {
1241 err = -ECONNREFUSED; 1246 err = -ECONNREFUSED;
@@ -1337,9 +1342,11 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1337 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1342 attrs.layer_etype = LAYER_MPA | DDP_LLP;
1338 attrs.ecode = MPA_NOMATCH_RTR; 1343 attrs.ecode = MPA_NOMATCH_RTR;
1339 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1344 attrs.next_state = C4IW_QP_STATE_TERMINATE;
1345 attrs.send_term = 1;
1340 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1346 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
1341 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1347 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
1342 err = -ENOMEM; 1348 err = -ENOMEM;
1349 disconnect = 1;
1343 goto out; 1350 goto out;
1344 } 1351 }
1345 1352
@@ -1355,9 +1362,11 @@ static void process_mpa_reply(struct c4iw_ep *ep, struct sk_buff *skb)
1355 attrs.layer_etype = LAYER_MPA | DDP_LLP; 1362 attrs.layer_etype = LAYER_MPA | DDP_LLP;
1356 attrs.ecode = MPA_INSUFF_IRD; 1363 attrs.ecode = MPA_INSUFF_IRD;
1357 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1364 attrs.next_state = C4IW_QP_STATE_TERMINATE;
1365 attrs.send_term = 1;
1358 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1366 err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
1359 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1367 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
1360 err = -ENOMEM; 1368 err = -ENOMEM;
1369 disconnect = 1;
1361 goto out; 1370 goto out;
1362 } 1371 }
1363 goto out; 1372 goto out;
@@ -1366,7 +1375,7 @@ err:
1366 send_abort(ep, skb, GFP_KERNEL); 1375 send_abort(ep, skb, GFP_KERNEL);
1367out: 1376out:
1368 connect_reply_upcall(ep, err); 1377 connect_reply_upcall(ep, err);
1369 return; 1378 return disconnect;
1370} 1379}
1371 1380
1372static void process_mpa_request(struct c4iw_ep *ep, struct sk_buff *skb) 1381static void process_mpa_request(struct c4iw_ep *ep, struct sk_buff *skb)
@@ -1524,6 +1533,7 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)
1524 unsigned int tid = GET_TID(hdr); 1533 unsigned int tid = GET_TID(hdr);
1525 struct tid_info *t = dev->rdev.lldi.tids; 1534 struct tid_info *t = dev->rdev.lldi.tids;
1526 __u8 status = hdr->status; 1535 __u8 status = hdr->status;
1536 int disconnect = 0;
1527 1537
1528 ep = lookup_tid(t, tid); 1538 ep = lookup_tid(t, tid);
1529 if (!ep) 1539 if (!ep)
@@ -1539,7 +1549,7 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)
1539 switch (ep->com.state) { 1549 switch (ep->com.state) {
1540 case MPA_REQ_SENT: 1550 case MPA_REQ_SENT:
1541 ep->rcv_seq += dlen; 1551 ep->rcv_seq += dlen;
1542 process_mpa_reply(ep, skb); 1552 disconnect = process_mpa_reply(ep, skb);
1543 break; 1553 break;
1544 case MPA_REQ_WAIT: 1554 case MPA_REQ_WAIT:
1545 ep->rcv_seq += dlen; 1555 ep->rcv_seq += dlen;
@@ -1555,13 +1565,16 @@ static int rx_data(struct c4iw_dev *dev, struct sk_buff *skb)
1555 ep->com.state, ep->hwtid, status); 1565 ep->com.state, ep->hwtid, status);
1556 attrs.next_state = C4IW_QP_STATE_TERMINATE; 1566 attrs.next_state = C4IW_QP_STATE_TERMINATE;
1557 c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, 1567 c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
1558 C4IW_QP_ATTR_NEXT_STATE, &attrs, 0); 1568 C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
1569 disconnect = 1;
1559 break; 1570 break;
1560 } 1571 }
1561 default: 1572 default:
1562 break; 1573 break;
1563 } 1574 }
1564 mutex_unlock(&ep->com.mutex); 1575 mutex_unlock(&ep->com.mutex);
1576 if (disconnect)
1577 c4iw_ep_disconnect(ep, 0, GFP_KERNEL);
1565 return 0; 1578 return 0;
1566} 1579}
1567 1580
@@ -2009,6 +2022,10 @@ static void accept_cr(struct c4iw_ep *ep, struct sk_buff *skb,
2009 if (tcph->ece && tcph->cwr) 2022 if (tcph->ece && tcph->cwr)
2010 opt2 |= CCTRL_ECN(1); 2023 opt2 |= CCTRL_ECN(1);
2011 } 2024 }
2025 if (is_t5(ep->com.dev->rdev.lldi.adapter_type)) {
2026 opt2 |= T5_OPT_2_VALID;
2027 opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE);
2028 }
2012 2029
2013 rpl = cplhdr(skb); 2030 rpl = cplhdr(skb);
2014 INIT_TP_WR(rpl, ep->hwtid); 2031 INIT_TP_WR(rpl, ep->hwtid);
@@ -3482,9 +3499,9 @@ static void process_timeout(struct c4iw_ep *ep)
3482 __func__, ep, ep->hwtid, ep->com.state); 3499 __func__, ep, ep->hwtid, ep->com.state);
3483 abort = 0; 3500 abort = 0;
3484 } 3501 }
3485 mutex_unlock(&ep->com.mutex);
3486 if (abort) 3502 if (abort)
3487 abort_connection(ep, NULL, GFP_KERNEL); 3503 abort_connection(ep, NULL, GFP_KERNEL);
3504 mutex_unlock(&ep->com.mutex);
3488 c4iw_put_ep(&ep->com); 3505 c4iw_put_ep(&ep->com);
3489} 3506}
3490 3507
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
index 7b8c5806a09d..7474b490760a 100644
--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
@@ -435,6 +435,7 @@ struct c4iw_qp_attributes {
435 u8 ecode; 435 u8 ecode;
436 u16 sq_db_inc; 436 u16 sq_db_inc;
437 u16 rq_db_inc; 437 u16 rq_db_inc;
438 u8 send_term;
438}; 439};
439 440
440struct c4iw_qp { 441struct c4iw_qp {
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 7b5114cb486f..086f62f5dc9e 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -1388,11 +1388,12 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
1388 qhp->attr.layer_etype = attrs->layer_etype; 1388 qhp->attr.layer_etype = attrs->layer_etype;
1389 qhp->attr.ecode = attrs->ecode; 1389 qhp->attr.ecode = attrs->ecode;
1390 ep = qhp->ep; 1390 ep = qhp->ep;
1391 disconnect = 1; 1391 if (!internal) {
1392 c4iw_get_ep(&qhp->ep->com); 1392 c4iw_get_ep(&qhp->ep->com);
1393 if (!internal)
1394 terminate = 1; 1393 terminate = 1;
1395 else { 1394 disconnect = 1;
1395 } else {
1396 terminate = qhp->attr.send_term;
1396 ret = rdma_fini(rhp, qhp, ep); 1397 ret = rdma_fini(rhp, qhp, ep);
1397 if (ret) 1398 if (ret)
1398 goto err; 1399 goto err;
@@ -1776,11 +1777,15 @@ int c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1776 /* 1777 /*
1777 * Use SQ_PSN and RQ_PSN to pass in IDX_INC values for 1778 * Use SQ_PSN and RQ_PSN to pass in IDX_INC values for
1778 * ringing the queue db when we're in DB_FULL mode. 1779 * ringing the queue db when we're in DB_FULL mode.
1780 * Only allow this on T4 devices.
1779 */ 1781 */
1780 attrs.sq_db_inc = attr->sq_psn; 1782 attrs.sq_db_inc = attr->sq_psn;
1781 attrs.rq_db_inc = attr->rq_psn; 1783 attrs.rq_db_inc = attr->rq_psn;
1782 mask |= (attr_mask & IB_QP_SQ_PSN) ? C4IW_QP_ATTR_SQ_DB : 0; 1784 mask |= (attr_mask & IB_QP_SQ_PSN) ? C4IW_QP_ATTR_SQ_DB : 0;
1783 mask |= (attr_mask & IB_QP_RQ_PSN) ? C4IW_QP_ATTR_RQ_DB : 0; 1785 mask |= (attr_mask & IB_QP_RQ_PSN) ? C4IW_QP_ATTR_RQ_DB : 0;
1786 if (is_t5(to_c4iw_qp(ibqp)->rhp->rdev.lldi.adapter_type) &&
1787 (mask & (C4IW_QP_ATTR_SQ_DB|C4IW_QP_ATTR_RQ_DB)))
1788 return -EINVAL;
1784 1789
1785 return c4iw_modify_qp(rhp, qhp, mask, &attrs, 0); 1790 return c4iw_modify_qp(rhp, qhp, mask, &attrs, 0);
1786} 1791}
diff --git a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
index dc193c292671..6121ca08fe58 100644
--- a/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
+++ b/drivers/infiniband/hw/cxgb4/t4fw_ri_api.h
@@ -836,4 +836,18 @@ struct ulptx_idata {
836#define V_RX_DACK_CHANGE(x) ((x) << S_RX_DACK_CHANGE) 836#define V_RX_DACK_CHANGE(x) ((x) << S_RX_DACK_CHANGE)
837#define F_RX_DACK_CHANGE V_RX_DACK_CHANGE(1U) 837#define F_RX_DACK_CHANGE V_RX_DACK_CHANGE(1U)
838 838
839enum { /* TCP congestion control algorithms */
840 CONG_ALG_RENO,
841 CONG_ALG_TAHOE,
842 CONG_ALG_NEWRENO,
843 CONG_ALG_HIGHSPEED
844};
845
846#define S_CONG_CNTRL 14
847#define M_CONG_CNTRL 0x3
848#define V_CONG_CNTRL(x) ((x) << S_CONG_CNTRL)
849#define G_CONG_CNTRL(x) (((x) >> S_CONG_CNTRL) & M_CONG_CNTRL)
850
851#define T5_OPT_2_VALID (1 << 31)
852
839#endif /* _T4FW_RI_API_H_ */ 853#endif /* _T4FW_RI_API_H_ */
diff --git a/drivers/input/misc/da9055_onkey.c b/drivers/input/misc/da9055_onkey.c
index 4b11ede34950..4765799fef74 100644
--- a/drivers/input/misc/da9055_onkey.c
+++ b/drivers/input/misc/da9055_onkey.c
@@ -109,7 +109,6 @@ static int da9055_onkey_probe(struct platform_device *pdev)
109 109
110 INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work); 110 INIT_DELAYED_WORK(&onkey->work, da9055_onkey_work);
111 111
112 irq = regmap_irq_get_virq(da9055->irq_data, irq);
113 err = request_threaded_irq(irq, NULL, da9055_onkey_irq, 112 err = request_threaded_irq(irq, NULL, da9055_onkey_irq,
114 IRQF_TRIGGER_HIGH | IRQF_ONESHOT, 113 IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
115 "ONKEY", onkey); 114 "ONKEY", onkey);
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 08ead2aaede5..20c80f543d5e 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -169,6 +169,7 @@ static int soc_button_pnp_probe(struct pnp_dev *pdev,
169 soc_button_remove(pdev); 169 soc_button_remove(pdev);
170 return error; 170 return error;
171 } 171 }
172 continue;
172 } 173 }
173 174
174 priv->children[i] = pd; 175 priv->children[i] = pd;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index ef1cf52f8bb9..088d3541c7d3 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1353,6 +1353,7 @@ static int elantech_set_properties(struct elantech_data *etd)
1353 case 6: 1353 case 6:
1354 case 7: 1354 case 7:
1355 case 8: 1355 case 8:
1356 case 9:
1356 etd->hw_version = 4; 1357 etd->hw_version = 4;
1357 break; 1358 break;
1358 default: 1359 default:
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index d8d49d10f9bb..ef9f4913450d 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -117,6 +117,44 @@ void synaptics_reset(struct psmouse *psmouse)
117} 117}
118 118
119#ifdef CONFIG_MOUSE_PS2_SYNAPTICS 119#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
120/* This list has been kindly provided by Synaptics. */
121static const char * const topbuttonpad_pnp_ids[] = {
122 "LEN0017",
123 "LEN0018",
124 "LEN0019",
125 "LEN0023",
126 "LEN002A",
127 "LEN002B",
128 "LEN002C",
129 "LEN002D",
130 "LEN002E",
131 "LEN0033", /* Helix */
132 "LEN0034", /* T431s, T540, X1 Carbon 2nd */
133 "LEN0035", /* X240 */
134 "LEN0036", /* T440 */
135 "LEN0037",
136 "LEN0038",
137 "LEN0041",
138 "LEN0042", /* Yoga */
139 "LEN0045",
140 "LEN0046",
141 "LEN0047",
142 "LEN0048",
143 "LEN0049",
144 "LEN2000",
145 "LEN2001",
146 "LEN2002",
147 "LEN2003",
148 "LEN2004", /* L440 */
149 "LEN2005",
150 "LEN2006",
151 "LEN2007",
152 "LEN2008",
153 "LEN2009",
154 "LEN200A",
155 "LEN200B",
156 NULL
157};
120 158
121/***************************************************************************** 159/*****************************************************************************
122 * Synaptics communications functions 160 * Synaptics communications functions
@@ -1255,8 +1293,10 @@ static void set_abs_position_params(struct input_dev *dev,
1255 input_abs_set_res(dev, y_code, priv->y_res); 1293 input_abs_set_res(dev, y_code, priv->y_res);
1256} 1294}
1257 1295
1258static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) 1296static void set_input_params(struct psmouse *psmouse,
1297 struct synaptics_data *priv)
1259{ 1298{
1299 struct input_dev *dev = psmouse->dev;
1260 int i; 1300 int i;
1261 1301
1262 /* Things that apply to both modes */ 1302 /* Things that apply to both modes */
@@ -1325,6 +1365,17 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv)
1325 1365
1326 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { 1366 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
1327 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1367 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1368 /* See if this buttonpad has a top button area */
1369 if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4)) {
1370 for (i = 0; topbuttonpad_pnp_ids[i]; i++) {
1371 if (strstr(psmouse->ps2dev.serio->firmware_id,
1372 topbuttonpad_pnp_ids[i])) {
1373 __set_bit(INPUT_PROP_TOPBUTTONPAD,
1374 dev->propbit);
1375 break;
1376 }
1377 }
1378 }
1328 /* Clickpads report only left button */ 1379 /* Clickpads report only left button */
1329 __clear_bit(BTN_RIGHT, dev->keybit); 1380 __clear_bit(BTN_RIGHT, dev->keybit);
1330 __clear_bit(BTN_MIDDLE, dev->keybit); 1381 __clear_bit(BTN_MIDDLE, dev->keybit);
@@ -1515,6 +1566,14 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = {
1515 .driver_data = (int []){1232, 5710, 1156, 4696}, 1566 .driver_data = (int []){1232, 5710, 1156, 4696},
1516 }, 1567 },
1517 { 1568 {
1569 /* Lenovo ThinkPad T431s */
1570 .matches = {
1571 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1572 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T431"),
1573 },
1574 .driver_data = (int []){1024, 5112, 2024, 4832},
1575 },
1576 {
1518 /* Lenovo ThinkPad T440s */ 1577 /* Lenovo ThinkPad T440s */
1519 .matches = { 1578 .matches = {
1520 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 1579 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -1523,6 +1582,14 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = {
1523 .driver_data = (int []){1024, 5112, 2024, 4832}, 1582 .driver_data = (int []){1024, 5112, 2024, 4832},
1524 }, 1583 },
1525 { 1584 {
1585 /* Lenovo ThinkPad L440 */
1586 .matches = {
1587 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1588 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L440"),
1589 },
1590 .driver_data = (int []){1024, 5112, 2024, 4832},
1591 },
1592 {
1526 /* Lenovo ThinkPad T540p */ 1593 /* Lenovo ThinkPad T540p */
1527 .matches = { 1594 .matches = {
1528 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 1595 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -1530,6 +1597,32 @@ static const struct dmi_system_id min_max_dmi_table[] __initconst = {
1530 }, 1597 },
1531 .driver_data = (int []){1024, 5056, 2058, 4832}, 1598 .driver_data = (int []){1024, 5056, 2058, 4832},
1532 }, 1599 },
1600 {
1601 /* Lenovo ThinkPad L540 */
1602 .matches = {
1603 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1604 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L540"),
1605 },
1606 .driver_data = (int []){1024, 5112, 2024, 4832},
1607 },
1608 {
1609 /* Lenovo Yoga S1 */
1610 .matches = {
1611 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1612 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION,
1613 "ThinkPad S1 Yoga"),
1614 },
1615 .driver_data = (int []){1232, 5710, 1156, 4696},
1616 },
1617 {
1618 /* Lenovo ThinkPad X1 Carbon Haswell (3rd generation) */
1619 .matches = {
1620 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1621 DMI_MATCH(DMI_PRODUCT_VERSION,
1622 "ThinkPad X1 Carbon 2nd"),
1623 },
1624 .driver_data = (int []){1024, 5112, 2024, 4832},
1625 },
1533#endif 1626#endif
1534 { } 1627 { }
1535}; 1628};
@@ -1593,7 +1686,7 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1593 priv->capabilities, priv->ext_cap, priv->ext_cap_0c, 1686 priv->capabilities, priv->ext_cap, priv->ext_cap_0c,
1594 priv->board_id, priv->firmware_id); 1687 priv->board_id, priv->firmware_id);
1595 1688
1596 set_input_params(psmouse->dev, priv); 1689 set_input_params(psmouse, priv);
1597 1690
1598 /* 1691 /*
1599 * Encode touchpad model so that it can be used to set 1692 * Encode touchpad model so that it can be used to set
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 0ec9abbe31fe..381b20d4c561 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -702,6 +702,17 @@ static int i8042_pnp_aux_irq;
702static char i8042_pnp_kbd_name[32]; 702static char i8042_pnp_kbd_name[32];
703static char i8042_pnp_aux_name[32]; 703static char i8042_pnp_aux_name[32];
704 704
705static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
706{
707 strlcpy(dst, "PNP:", dst_size);
708
709 while (id) {
710 strlcat(dst, " ", dst_size);
711 strlcat(dst, id->id, dst_size);
712 id = id->next;
713 }
714}
715
705static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did) 716static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
706{ 717{
707 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1) 718 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
@@ -718,6 +729,8 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *
718 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name)); 729 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
719 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); 730 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
720 } 731 }
732 i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id,
733 sizeof(i8042_kbd_firmware_id));
721 734
722 /* Keyboard ports are always supposed to be wakeup-enabled */ 735 /* Keyboard ports are always supposed to be wakeup-enabled */
723 device_set_wakeup_enable(&dev->dev, true); 736 device_set_wakeup_enable(&dev->dev, true);
@@ -742,6 +755,8 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *
742 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name)); 755 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
743 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); 756 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
744 } 757 }
758 i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id,
759 sizeof(i8042_aux_firmware_id));
745 760
746 i8042_pnp_aux_devices++; 761 i8042_pnp_aux_devices++;
747 return 0; 762 return 0;
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 020053fa5aaa..3807c3e971cc 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -87,6 +87,8 @@ MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off");
87#endif 87#endif
88 88
89static bool i8042_bypass_aux_irq_test; 89static bool i8042_bypass_aux_irq_test;
90static char i8042_kbd_firmware_id[128];
91static char i8042_aux_firmware_id[128];
90 92
91#include "i8042.h" 93#include "i8042.h"
92 94
@@ -1218,6 +1220,8 @@ static int __init i8042_create_kbd_port(void)
1218 serio->dev.parent = &i8042_platform_device->dev; 1220 serio->dev.parent = &i8042_platform_device->dev;
1219 strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); 1221 strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name));
1220 strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); 1222 strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys));
1223 strlcpy(serio->firmware_id, i8042_kbd_firmware_id,
1224 sizeof(serio->firmware_id));
1221 1225
1222 port->serio = serio; 1226 port->serio = serio;
1223 port->irq = I8042_KBD_IRQ; 1227 port->irq = I8042_KBD_IRQ;
@@ -1244,6 +1248,8 @@ static int __init i8042_create_aux_port(int idx)
1244 if (idx < 0) { 1248 if (idx < 0) {
1245 strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); 1249 strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name));
1246 strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); 1250 strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys));
1251 strlcpy(serio->firmware_id, i8042_aux_firmware_id,
1252 sizeof(serio->firmware_id));
1247 serio->close = i8042_port_close; 1253 serio->close = i8042_port_close;
1248 } else { 1254 } else {
1249 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); 1255 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 8f4c4ab04bc2..b29134de983b 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -451,6 +451,13 @@ static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *
451 return retval; 451 return retval;
452} 452}
453 453
454static ssize_t firmware_id_show(struct device *dev, struct device_attribute *attr, char *buf)
455{
456 struct serio *serio = to_serio_port(dev);
457
458 return sprintf(buf, "%s\n", serio->firmware_id);
459}
460
454static DEVICE_ATTR_RO(type); 461static DEVICE_ATTR_RO(type);
455static DEVICE_ATTR_RO(proto); 462static DEVICE_ATTR_RO(proto);
456static DEVICE_ATTR_RO(id); 463static DEVICE_ATTR_RO(id);
@@ -473,12 +480,14 @@ static DEVICE_ATTR_RO(modalias);
473static DEVICE_ATTR_WO(drvctl); 480static DEVICE_ATTR_WO(drvctl);
474static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); 481static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL);
475static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); 482static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode);
483static DEVICE_ATTR_RO(firmware_id);
476 484
477static struct attribute *serio_device_attrs[] = { 485static struct attribute *serio_device_attrs[] = {
478 &dev_attr_modalias.attr, 486 &dev_attr_modalias.attr,
479 &dev_attr_description.attr, 487 &dev_attr_description.attr,
480 &dev_attr_drvctl.attr, 488 &dev_attr_drvctl.attr,
481 &dev_attr_bind_mode.attr, 489 &dev_attr_bind_mode.attr,
490 &dev_attr_firmware_id.attr,
482 NULL 491 NULL
483}; 492};
484 493
@@ -921,9 +930,14 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
921 SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto); 930 SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto);
922 SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id); 931 SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id);
923 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); 932 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra);
933
924 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", 934 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X",
925 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); 935 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
926 936
937 if (serio->firmware_id[0])
938 SERIO_ADD_UEVENT_VAR("SERIO_FIRMWARE_ID=%s",
939 serio->firmware_id);
940
927 return 0; 941 return 0;
928} 942}
929#undef SERIO_ADD_UEVENT_VAR 943#undef SERIO_ADD_UEVENT_VAR
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index b16ebef5b911..611fc3905d00 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -22,23 +22,18 @@
22#define HID_USAGE_PAGE_DIGITIZER 0x0d 22#define HID_USAGE_PAGE_DIGITIZER 0x0d
23#define HID_USAGE_PAGE_DESKTOP 0x01 23#define HID_USAGE_PAGE_DESKTOP 0x01
24#define HID_USAGE 0x09 24#define HID_USAGE 0x09
25#define HID_USAGE_X 0x30 25#define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30)
26#define HID_USAGE_Y 0x31 26#define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31)
27#define HID_USAGE_X_TILT 0x3d 27#define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30)
28#define HID_USAGE_Y_TILT 0x3e 28#define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d)
29#define HID_USAGE_FINGER 0x22 29#define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e)
30#define HID_USAGE_STYLUS 0x20 30#define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22)
31#define HID_USAGE_CONTACTMAX 0x55 31#define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20)
32#define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55)
32#define HID_COLLECTION 0xa1 33#define HID_COLLECTION 0xa1
33#define HID_COLLECTION_LOGICAL 0x02 34#define HID_COLLECTION_LOGICAL 0x02
34#define HID_COLLECTION_END 0xc0 35#define HID_COLLECTION_END 0xc0
35 36
36enum {
37 WCM_UNDEFINED = 0,
38 WCM_DESKTOP,
39 WCM_DIGITIZER,
40};
41
42struct hid_descriptor { 37struct hid_descriptor {
43 struct usb_descriptor_header header; 38 struct usb_descriptor_header header;
44 __le16 bcdHID; 39 __le16 bcdHID;
@@ -305,7 +300,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
305 char limit = 0; 300 char limit = 0;
306 /* result has to be defined as int for some devices */ 301 /* result has to be defined as int for some devices */
307 int result = 0, touch_max = 0; 302 int result = 0, touch_max = 0;
308 int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0; 303 int i = 0, page = 0, finger = 0, pen = 0;
309 unsigned char *report; 304 unsigned char *report;
310 305
311 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); 306 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
@@ -332,134 +327,121 @@ static int wacom_parse_hid(struct usb_interface *intf,
332 327
333 switch (report[i]) { 328 switch (report[i]) {
334 case HID_USAGE_PAGE: 329 case HID_USAGE_PAGE:
335 switch (report[i + 1]) { 330 page = report[i + 1];
336 case HID_USAGE_PAGE_DIGITIZER: 331 i++;
337 usage = WCM_DIGITIZER;
338 i++;
339 break;
340
341 case HID_USAGE_PAGE_DESKTOP:
342 usage = WCM_DESKTOP;
343 i++;
344 break;
345 }
346 break; 332 break;
347 333
348 case HID_USAGE: 334 case HID_USAGE:
349 switch (report[i + 1]) { 335 switch (page << 16 | report[i + 1]) {
350 case HID_USAGE_X: 336 case HID_USAGE_X:
351 if (usage == WCM_DESKTOP) { 337 if (finger) {
352 if (finger) { 338 features->device_type = BTN_TOOL_FINGER;
353 features->device_type = BTN_TOOL_FINGER; 339 /* touch device at least supports one touch point */
354 /* touch device at least supports one touch point */ 340 touch_max = 1;
355 touch_max = 1; 341 switch (features->type) {
356 switch (features->type) { 342 case TABLETPC2FG:
357 case TABLETPC2FG: 343 features->pktlen = WACOM_PKGLEN_TPC2FG;
358 features->pktlen = WACOM_PKGLEN_TPC2FG; 344 break;
359 break; 345
360 346 case MTSCREEN:
361 case MTSCREEN: 347 case WACOM_24HDT:
362 case WACOM_24HDT: 348 features->pktlen = WACOM_PKGLEN_MTOUCH;
363 features->pktlen = WACOM_PKGLEN_MTOUCH; 349 break;
364 break; 350
365 351 case MTTPC:
366 case MTTPC: 352 features->pktlen = WACOM_PKGLEN_MTTPC;
367 features->pktlen = WACOM_PKGLEN_MTTPC; 353 break;
368 break; 354
369 355 case BAMBOO_PT:
370 case BAMBOO_PT: 356 features->pktlen = WACOM_PKGLEN_BBTOUCH;
371 features->pktlen = WACOM_PKGLEN_BBTOUCH; 357 break;
372 break; 358
373 359 default:
374 default: 360 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
375 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 361 break;
376 break; 362 }
377 } 363
378 364 switch (features->type) {
379 switch (features->type) { 365 case BAMBOO_PT:
380 case BAMBOO_PT: 366 features->x_phy =
381 features->x_phy = 367 get_unaligned_le16(&report[i + 5]);
382 get_unaligned_le16(&report[i + 5]); 368 features->x_max =
383 features->x_max = 369 get_unaligned_le16(&report[i + 8]);
384 get_unaligned_le16(&report[i + 8]); 370 i += 15;
385 i += 15; 371 break;
386 break; 372
387 373 case WACOM_24HDT:
388 case WACOM_24HDT:
389 features->x_max =
390 get_unaligned_le16(&report[i + 3]);
391 features->x_phy =
392 get_unaligned_le16(&report[i + 8]);
393 features->unit = report[i - 1];
394 features->unitExpo = report[i - 3];
395 i += 12;
396 break;
397
398 default:
399 features->x_max =
400 get_unaligned_le16(&report[i + 3]);
401 features->x_phy =
402 get_unaligned_le16(&report[i + 6]);
403 features->unit = report[i + 9];
404 features->unitExpo = report[i + 11];
405 i += 12;
406 break;
407 }
408 } else if (pen) {
409 /* penabled only accepts exact bytes of data */
410 if (features->type >= TABLETPC)
411 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
412 features->device_type = BTN_TOOL_PEN;
413 features->x_max = 374 features->x_max =
414 get_unaligned_le16(&report[i + 3]); 375 get_unaligned_le16(&report[i + 3]);
415 i += 4; 376 features->x_phy =
377 get_unaligned_le16(&report[i + 8]);
378 features->unit = report[i - 1];
379 features->unitExpo = report[i - 3];
380 i += 12;
381 break;
382
383 default:
384 features->x_max =
385 get_unaligned_le16(&report[i + 3]);
386 features->x_phy =
387 get_unaligned_le16(&report[i + 6]);
388 features->unit = report[i + 9];
389 features->unitExpo = report[i + 11];
390 i += 12;
391 break;
416 } 392 }
393 } else if (pen) {
394 /* penabled only accepts exact bytes of data */
395 if (features->type >= TABLETPC)
396 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
397 features->device_type = BTN_TOOL_PEN;
398 features->x_max =
399 get_unaligned_le16(&report[i + 3]);
400 i += 4;
417 } 401 }
418 break; 402 break;
419 403
420 case HID_USAGE_Y: 404 case HID_USAGE_Y:
421 if (usage == WCM_DESKTOP) { 405 if (finger) {
422 if (finger) { 406 switch (features->type) {
423 switch (features->type) { 407 case TABLETPC2FG:
424 case TABLETPC2FG: 408 case MTSCREEN:
425 case MTSCREEN: 409 case MTTPC:
426 case MTTPC: 410 features->y_max =
427 features->y_max = 411 get_unaligned_le16(&report[i + 3]);
428 get_unaligned_le16(&report[i + 3]); 412 features->y_phy =
429 features->y_phy = 413 get_unaligned_le16(&report[i + 6]);
430 get_unaligned_le16(&report[i + 6]); 414 i += 7;
431 i += 7; 415 break;
432 break; 416
433 417 case WACOM_24HDT:
434 case WACOM_24HDT: 418 features->y_max =
435 features->y_max = 419 get_unaligned_le16(&report[i + 3]);
436 get_unaligned_le16(&report[i + 3]); 420 features->y_phy =
437 features->y_phy = 421 get_unaligned_le16(&report[i - 2]);
438 get_unaligned_le16(&report[i - 2]); 422 i += 7;
439 i += 7; 423 break;
440 break; 424
441 425 case BAMBOO_PT:
442 case BAMBOO_PT: 426 features->y_phy =
443 features->y_phy = 427 get_unaligned_le16(&report[i + 3]);
444 get_unaligned_le16(&report[i + 3]); 428 features->y_max =
445 features->y_max = 429 get_unaligned_le16(&report[i + 6]);
446 get_unaligned_le16(&report[i + 6]); 430 i += 12;
447 i += 12; 431 break;
448 break; 432
449 433 default:
450 default:
451 features->y_max =
452 features->x_max;
453 features->y_phy =
454 get_unaligned_le16(&report[i + 3]);
455 i += 4;
456 break;
457 }
458 } else if (pen) {
459 features->y_max = 434 features->y_max =
435 features->x_max;
436 features->y_phy =
460 get_unaligned_le16(&report[i + 3]); 437 get_unaligned_le16(&report[i + 3]);
461 i += 4; 438 i += 4;
439 break;
462 } 440 }
441 } else if (pen) {
442 features->y_max =
443 get_unaligned_le16(&report[i + 3]);
444 i += 4;
463 } 445 }
464 break; 446 break;
465 447
@@ -484,12 +466,20 @@ static int wacom_parse_hid(struct usb_interface *intf,
484 wacom_retrieve_report_data(intf, features); 466 wacom_retrieve_report_data(intf, features);
485 i++; 467 i++;
486 break; 468 break;
469
470 case HID_USAGE_PRESSURE:
471 if (pen) {
472 features->pressure_max =
473 get_unaligned_le16(&report[i + 3]);
474 i += 4;
475 }
476 break;
487 } 477 }
488 break; 478 break;
489 479
490 case HID_COLLECTION_END: 480 case HID_COLLECTION_END:
491 /* reset UsagePage and Finger */ 481 /* reset UsagePage and Finger */
492 finger = usage = 0; 482 finger = page = 0;
493 break; 483 break;
494 484
495 case HID_COLLECTION: 485 case HID_COLLECTION:
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 05f371df6c40..4822c57a3756 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -178,10 +178,9 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
178 178
179static int wacom_dtu_irq(struct wacom_wac *wacom) 179static int wacom_dtu_irq(struct wacom_wac *wacom)
180{ 180{
181 struct wacom_features *features = &wacom->features; 181 unsigned char *data = wacom->data;
182 char *data = wacom->data;
183 struct input_dev *input = wacom->input; 182 struct input_dev *input = wacom->input;
184 int prox = data[1] & 0x20, pressure; 183 int prox = data[1] & 0x20;
185 184
186 dev_dbg(input->dev.parent, 185 dev_dbg(input->dev.parent,
187 "%s: received report #%d", __func__, data[0]); 186 "%s: received report #%d", __func__, data[0]);
@@ -198,10 +197,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
198 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 197 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
199 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 198 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
200 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 199 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
201 pressure = ((data[7] & 0x01) << 8) | data[6]; 200 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
202 if (pressure < 0)
203 pressure = features->pressure_max + pressure + 1;
204 input_report_abs(input, ABS_PRESSURE, pressure);
205 input_report_key(input, BTN_TOUCH, data[1] & 0x05); 201 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
206 if (!prox) /* out-prox */ 202 if (!prox) /* out-prox */
207 wacom->id[0] = 0; 203 wacom->id[0] = 0;
@@ -906,7 +902,7 @@ static int int_dist(int x1, int y1, int x2, int y2)
906static int wacom_24hdt_irq(struct wacom_wac *wacom) 902static int wacom_24hdt_irq(struct wacom_wac *wacom)
907{ 903{
908 struct input_dev *input = wacom->input; 904 struct input_dev *input = wacom->input;
909 char *data = wacom->data; 905 unsigned char *data = wacom->data;
910 int i; 906 int i;
911 int current_num_contacts = data[61]; 907 int current_num_contacts = data[61];
912 int contacts_to_send = 0; 908 int contacts_to_send = 0;
@@ -959,7 +955,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
959static int wacom_mt_touch(struct wacom_wac *wacom) 955static int wacom_mt_touch(struct wacom_wac *wacom)
960{ 956{
961 struct input_dev *input = wacom->input; 957 struct input_dev *input = wacom->input;
962 char *data = wacom->data; 958 unsigned char *data = wacom->data;
963 int i; 959 int i;
964 int current_num_contacts = data[2]; 960 int current_num_contacts = data[2];
965 int contacts_to_send = 0; 961 int contacts_to_send = 0;
@@ -1038,7 +1034,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1038 1034
1039static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) 1035static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1040{ 1036{
1041 char *data = wacom->data; 1037 unsigned char *data = wacom->data;
1042 struct input_dev *input = wacom->input; 1038 struct input_dev *input = wacom->input;
1043 bool prox; 1039 bool prox;
1044 int x = 0, y = 0; 1040 int x = 0, y = 0;
@@ -1074,10 +1070,8 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1074 1070
1075static int wacom_tpc_pen(struct wacom_wac *wacom) 1071static int wacom_tpc_pen(struct wacom_wac *wacom)
1076{ 1072{
1077 struct wacom_features *features = &wacom->features; 1073 unsigned char *data = wacom->data;
1078 char *data = wacom->data;
1079 struct input_dev *input = wacom->input; 1074 struct input_dev *input = wacom->input;
1080 int pressure;
1081 bool prox = data[1] & 0x20; 1075 bool prox = data[1] & 0x20;
1082 1076
1083 if (!wacom->shared->stylus_in_proximity) /* first in prox */ 1077 if (!wacom->shared->stylus_in_proximity) /* first in prox */
@@ -1093,10 +1087,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom)
1093 input_report_key(input, BTN_STYLUS2, data[1] & 0x10); 1087 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
1094 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); 1088 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
1095 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); 1089 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
1096 pressure = ((data[7] & 0x01) << 8) | data[6]; 1090 input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x03) << 8) | data[6]);
1097 if (pressure < 0)
1098 pressure = features->pressure_max + pressure + 1;
1099 input_report_abs(input, ABS_PRESSURE, pressure);
1100 input_report_key(input, BTN_TOUCH, data[1] & 0x05); 1091 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
1101 input_report_key(input, wacom->tool[0], prox); 1092 input_report_key(input, wacom->tool[0], prox);
1102 return 1; 1093 return 1;
@@ -1107,7 +1098,7 @@ static int wacom_tpc_pen(struct wacom_wac *wacom)
1107 1098
1108static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) 1099static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1109{ 1100{
1110 char *data = wacom->data; 1101 unsigned char *data = wacom->data;
1111 1102
1112 dev_dbg(wacom->input->dev.parent, 1103 dev_dbg(wacom->input->dev.parent,
1113 "%s: received report #%d\n", __func__, data[0]); 1104 "%s: received report #%d\n", __func__, data[0]);
@@ -1838,7 +1829,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1838 case DTU: 1829 case DTU:
1839 if (features->type == DTUS) { 1830 if (features->type == DTUS) {
1840 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1831 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
1841 for (i = 0; i < 3; i++) 1832 for (i = 0; i < 4; i++)
1842 __set_bit(BTN_0 + i, input_dev->keybit); 1833 __set_bit(BTN_0 + i, input_dev->keybit);
1843 } 1834 }
1844 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1835 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 45a06e495ed2..7f8aa981500d 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -425,7 +425,7 @@ static int ads7845_read12_ser(struct device *dev, unsigned command)
425name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \ 425name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
426{ \ 426{ \
427 struct ads7846 *ts = dev_get_drvdata(dev); \ 427 struct ads7846 *ts = dev_get_drvdata(dev); \
428 ssize_t v = ads7846_read12_ser(dev, \ 428 ssize_t v = ads7846_read12_ser(&ts->spi->dev, \
429 READ_12BIT_SER(var)); \ 429 READ_12BIT_SER(var)); \
430 if (v < 0) \ 430 if (v < 0) \
431 return v; \ 431 return v; \
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 8b89e33a89fe..647c3c7fd742 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1381,7 +1381,7 @@ static int arm_smmu_alloc_init_pmd(struct arm_smmu_device *smmu, pud_t *pud,
1381 1381
1382 do { 1382 do {
1383 next = pmd_addr_end(addr, end); 1383 next = pmd_addr_end(addr, end);
1384 ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, end, pfn, 1384 ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, next, pfn,
1385 prot, stage); 1385 prot, stage);
1386 phys += next - addr; 1386 phys += next - addr;
1387 } while (pmd++, addr = next, addr < end); 1387 } while (pmd++, addr = next, addr < end);
@@ -1499,7 +1499,7 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
1499 1499
1500 ret = arm_smmu_handle_mapping(smmu_domain, iova, 0, size, 0); 1500 ret = arm_smmu_handle_mapping(smmu_domain, iova, 0, size, 0);
1501 arm_smmu_tlb_inv_context(&smmu_domain->root_cfg); 1501 arm_smmu_tlb_inv_context(&smmu_domain->root_cfg);
1502 return ret ? ret : size; 1502 return ret ? 0 : size;
1503} 1503}
1504 1504
1505static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, 1505static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index f445c10df8df..39f8b717fe84 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -152,7 +152,8 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)
152 info->seg = pci_domain_nr(dev->bus); 152 info->seg = pci_domain_nr(dev->bus);
153 info->level = level; 153 info->level = level;
154 if (event == BUS_NOTIFY_ADD_DEVICE) { 154 if (event == BUS_NOTIFY_ADD_DEVICE) {
155 for (tmp = dev, level--; tmp; tmp = tmp->bus->self) { 155 for (tmp = dev; tmp; tmp = tmp->bus->self) {
156 level--;
156 info->path[level].device = PCI_SLOT(tmp->devfn); 157 info->path[level].device = PCI_SLOT(tmp->devfn);
157 info->path[level].function = PCI_FUNC(tmp->devfn); 158 info->path[level].function = PCI_FUNC(tmp->devfn);
158 if (pci_is_root_bus(tmp->bus)) 159 if (pci_is_root_bus(tmp->bus))
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 69fa7da5e48b..f256ffc02e29 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1009,11 +1009,13 @@ static struct page *dma_pte_list_pagetables(struct dmar_domain *domain,
1009 if (level == 1) 1009 if (level == 1)
1010 return freelist; 1010 return freelist;
1011 1011
1012 for (pte = page_address(pg); !first_pte_in_page(pte); pte++) { 1012 pte = page_address(pg);
1013 do {
1013 if (dma_pte_present(pte) && !dma_pte_superpage(pte)) 1014 if (dma_pte_present(pte) && !dma_pte_superpage(pte))
1014 freelist = dma_pte_list_pagetables(domain, level - 1, 1015 freelist = dma_pte_list_pagetables(domain, level - 1,
1015 pte, freelist); 1016 pte, freelist);
1016 } 1017 pte++;
1018 } while (!first_pte_in_page(pte));
1017 1019
1018 return freelist; 1020 return freelist;
1019} 1021}
@@ -2235,7 +2237,9 @@ static struct dmar_domain *get_domain_for_dev(struct device *dev, int gaw)
2235 bridge_devfn = dev_tmp->devfn; 2237 bridge_devfn = dev_tmp->devfn;
2236 } 2238 }
2237 spin_lock_irqsave(&device_domain_lock, flags); 2239 spin_lock_irqsave(&device_domain_lock, flags);
2238 info = dmar_search_domain_by_dev_info(segment, bus, devfn); 2240 info = dmar_search_domain_by_dev_info(segment,
2241 bridge_bus,
2242 bridge_devfn);
2239 if (info) { 2243 if (info) {
2240 iommu = info->iommu; 2244 iommu = info->iommu;
2241 domain = info->domain; 2245 domain = info->domain;
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 41be897df8d5..3899ba7821c5 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -41,6 +41,7 @@
41#define ARMADA_370_XP_INT_SET_ENABLE_OFFS (0x30) 41#define ARMADA_370_XP_INT_SET_ENABLE_OFFS (0x30)
42#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34) 42#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34)
43#define ARMADA_370_XP_INT_SOURCE_CTL(irq) (0x100 + irq*4) 43#define ARMADA_370_XP_INT_SOURCE_CTL(irq) (0x100 + irq*4)
44#define ARMADA_370_XP_INT_SOURCE_CPU_MASK 0xF
44 45
45#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44) 46#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44)
46#define ARMADA_375_PPI_CAUSE (0x10) 47#define ARMADA_375_PPI_CAUSE (0x10)
@@ -132,8 +133,7 @@ static int armada_370_xp_setup_msi_irq(struct msi_chip *chip,
132 struct msi_desc *desc) 133 struct msi_desc *desc)
133{ 134{
134 struct msi_msg msg; 135 struct msi_msg msg;
135 irq_hw_number_t hwirq; 136 int virq, hwirq;
136 int virq;
137 137
138 hwirq = armada_370_xp_alloc_msi(); 138 hwirq = armada_370_xp_alloc_msi();
139 if (hwirq < 0) 139 if (hwirq < 0)
@@ -159,8 +159,19 @@ static void armada_370_xp_teardown_msi_irq(struct msi_chip *chip,
159 unsigned int irq) 159 unsigned int irq)
160{ 160{
161 struct irq_data *d = irq_get_irq_data(irq); 161 struct irq_data *d = irq_get_irq_data(irq);
162 unsigned long hwirq = d->hwirq;
163
162 irq_dispose_mapping(irq); 164 irq_dispose_mapping(irq);
163 armada_370_xp_free_msi(d->hwirq); 165 armada_370_xp_free_msi(hwirq);
166}
167
168static int armada_370_xp_check_msi_device(struct msi_chip *chip, struct pci_dev *dev,
169 int nvec, int type)
170{
171 /* We support MSI, but not MSI-X */
172 if (type == PCI_CAP_ID_MSI)
173 return 0;
174 return -EINVAL;
164} 175}
165 176
166static struct irq_chip armada_370_xp_msi_irq_chip = { 177static struct irq_chip armada_370_xp_msi_irq_chip = {
@@ -201,6 +212,7 @@ static int armada_370_xp_msi_init(struct device_node *node,
201 212
202 msi_chip->setup_irq = armada_370_xp_setup_msi_irq; 213 msi_chip->setup_irq = armada_370_xp_setup_msi_irq;
203 msi_chip->teardown_irq = armada_370_xp_teardown_msi_irq; 214 msi_chip->teardown_irq = armada_370_xp_teardown_msi_irq;
215 msi_chip->check_device = armada_370_xp_check_msi_device;
204 msi_chip->of_node = node; 216 msi_chip->of_node = node;
205 217
206 armada_370_xp_msi_domain = 218 armada_370_xp_msi_domain =
@@ -244,35 +256,18 @@ static DEFINE_RAW_SPINLOCK(irq_controller_lock);
244static int armada_xp_set_affinity(struct irq_data *d, 256static int armada_xp_set_affinity(struct irq_data *d,
245 const struct cpumask *mask_val, bool force) 257 const struct cpumask *mask_val, bool force)
246{ 258{
247 unsigned long reg;
248 unsigned long new_mask = 0;
249 unsigned long online_mask = 0;
250 unsigned long count = 0;
251 irq_hw_number_t hwirq = irqd_to_hwirq(d); 259 irq_hw_number_t hwirq = irqd_to_hwirq(d);
260 unsigned long reg, mask;
252 int cpu; 261 int cpu;
253 262
254 for_each_cpu(cpu, mask_val) { 263 /* Select a single core from the affinity mask which is online */
255 new_mask |= 1 << cpu_logical_map(cpu); 264 cpu = cpumask_any_and(mask_val, cpu_online_mask);
256 count++; 265 mask = 1UL << cpu_logical_map(cpu);
257 }
258
259 /*
260 * Forbid mutlicore interrupt affinity
261 * This is required since the MPIC HW doesn't limit
262 * several CPUs from acknowledging the same interrupt.
263 */
264 if (count > 1)
265 return -EINVAL;
266
267 for_each_cpu(cpu, cpu_online_mask)
268 online_mask |= 1 << cpu_logical_map(cpu);
269 266
270 raw_spin_lock(&irq_controller_lock); 267 raw_spin_lock(&irq_controller_lock);
271
272 reg = readl(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq)); 268 reg = readl(main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
273 reg = (reg & (~online_mask)) | new_mask; 269 reg = (reg & (~ARMADA_370_XP_INT_SOURCE_CPU_MASK)) | mask;
274 writel(reg, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq)); 270 writel(reg, main_int_base + ARMADA_370_XP_INT_SOURCE_CTL(hwirq));
275
276 raw_spin_unlock(&irq_controller_lock); 271 raw_spin_unlock(&irq_controller_lock);
277 272
278 return 0; 273 return 0;
@@ -494,15 +489,6 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
494 489
495#ifdef CONFIG_SMP 490#ifdef CONFIG_SMP
496 armada_xp_mpic_smp_cpu_init(); 491 armada_xp_mpic_smp_cpu_init();
497
498 /*
499 * Set the default affinity from all CPUs to the boot cpu.
500 * This is required since the MPIC doesn't limit several CPUs
501 * from acknowledging the same interrupt.
502 */
503 cpumask_clear(irq_default_affinity);
504 cpumask_set_cpu(smp_processor_id(), irq_default_affinity);
505
506#endif 492#endif
507 493
508 armada_370_xp_msi_init(node, main_int_res.start); 494 armada_370_xp_msi_init(node, main_int_res.start);
diff --git a/drivers/irqchip/irq-crossbar.c b/drivers/irqchip/irq-crossbar.c
index fc817d28d1fe..3d15d16a7088 100644
--- a/drivers/irqchip/irq-crossbar.c
+++ b/drivers/irqchip/irq-crossbar.c
@@ -107,7 +107,7 @@ static int __init crossbar_of_init(struct device_node *node)
107 int i, size, max, reserved = 0, entry; 107 int i, size, max, reserved = 0, entry;
108 const __be32 *irqsr; 108 const __be32 *irqsr;
109 109
110 cb = kzalloc(sizeof(struct cb_device *), GFP_KERNEL); 110 cb = kzalloc(sizeof(*cb), GFP_KERNEL);
111 111
112 if (!cb) 112 if (!cb)
113 return -ENOMEM; 113 return -ENOMEM;
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 4300b6606f5e..57d165e026f4 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -246,10 +246,14 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
246 bool force) 246 bool force)
247{ 247{
248 void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3); 248 void __iomem *reg = gic_dist_base(d) + GIC_DIST_TARGET + (gic_irq(d) & ~3);
249 unsigned int shift = (gic_irq(d) % 4) * 8; 249 unsigned int cpu, shift = (gic_irq(d) % 4) * 8;
250 unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask);
251 u32 val, mask, bit; 250 u32 val, mask, bit;
252 251
252 if (!force)
253 cpu = cpumask_any_and(mask_val, cpu_online_mask);
254 else
255 cpu = cpumask_first(mask_val);
256
253 if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids) 257 if (cpu >= NR_GIC_CPU_IF || cpu >= nr_cpu_ids)
254 return -EINVAL; 258 return -EINVAL;
255 259
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 1bf4a71919ec..9380be7b1895 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2488,6 +2488,7 @@ static int cache_map(struct dm_target *ti, struct bio *bio)
2488 2488
2489 } else { 2489 } else {
2490 inc_hit_counter(cache, bio); 2490 inc_hit_counter(cache, bio);
2491 pb->all_io_entry = dm_deferred_entry_inc(cache->all_io_ds);
2491 2492
2492 if (bio_data_dir(bio) == WRITE && writethrough_mode(&cache->features) && 2493 if (bio_data_dir(bio) == WRITE && writethrough_mode(&cache->features) &&
2493 !is_dirty(cache, lookup_result.cblock)) 2494 !is_dirty(cache, lookup_result.cblock))
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 53728be84dee..13abade76ad9 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -232,6 +232,13 @@ struct thin_c {
232 struct bio_list deferred_bio_list; 232 struct bio_list deferred_bio_list;
233 struct bio_list retry_on_resume_list; 233 struct bio_list retry_on_resume_list;
234 struct rb_root sort_bio_list; /* sorted list of deferred bios */ 234 struct rb_root sort_bio_list; /* sorted list of deferred bios */
235
236 /*
237 * Ensures the thin is not destroyed until the worker has finished
238 * iterating the active_thins list.
239 */
240 atomic_t refcount;
241 struct completion can_destroy;
235}; 242};
236 243
237/*----------------------------------------------------------------*/ 244/*----------------------------------------------------------------*/
@@ -1486,6 +1493,45 @@ static void process_thin_deferred_bios(struct thin_c *tc)
1486 blk_finish_plug(&plug); 1493 blk_finish_plug(&plug);
1487} 1494}
1488 1495
1496static void thin_get(struct thin_c *tc);
1497static void thin_put(struct thin_c *tc);
1498
1499/*
1500 * We can't hold rcu_read_lock() around code that can block. So we
1501 * find a thin with the rcu lock held; bump a refcount; then drop
1502 * the lock.
1503 */
1504static struct thin_c *get_first_thin(struct pool *pool)
1505{
1506 struct thin_c *tc = NULL;
1507
1508 rcu_read_lock();
1509 if (!list_empty(&pool->active_thins)) {
1510 tc = list_entry_rcu(pool->active_thins.next, struct thin_c, list);
1511 thin_get(tc);
1512 }
1513 rcu_read_unlock();
1514
1515 return tc;
1516}
1517
1518static struct thin_c *get_next_thin(struct pool *pool, struct thin_c *tc)
1519{
1520 struct thin_c *old_tc = tc;
1521
1522 rcu_read_lock();
1523 list_for_each_entry_continue_rcu(tc, &pool->active_thins, list) {
1524 thin_get(tc);
1525 thin_put(old_tc);
1526 rcu_read_unlock();
1527 return tc;
1528 }
1529 thin_put(old_tc);
1530 rcu_read_unlock();
1531
1532 return NULL;
1533}
1534
1489static void process_deferred_bios(struct pool *pool) 1535static void process_deferred_bios(struct pool *pool)
1490{ 1536{
1491 unsigned long flags; 1537 unsigned long flags;
@@ -1493,10 +1539,11 @@ static void process_deferred_bios(struct pool *pool)
1493 struct bio_list bios; 1539 struct bio_list bios;
1494 struct thin_c *tc; 1540 struct thin_c *tc;
1495 1541
1496 rcu_read_lock(); 1542 tc = get_first_thin(pool);
1497 list_for_each_entry_rcu(tc, &pool->active_thins, list) 1543 while (tc) {
1498 process_thin_deferred_bios(tc); 1544 process_thin_deferred_bios(tc);
1499 rcu_read_unlock(); 1545 tc = get_next_thin(pool, tc);
1546 }
1500 1547
1501 /* 1548 /*
1502 * If there are any deferred flush bios, we must commit 1549 * If there are any deferred flush bios, we must commit
@@ -1578,7 +1625,7 @@ static void noflush_work(struct thin_c *tc, void (*fn)(struct work_struct *))
1578{ 1625{
1579 struct noflush_work w; 1626 struct noflush_work w;
1580 1627
1581 INIT_WORK(&w.worker, fn); 1628 INIT_WORK_ONSTACK(&w.worker, fn);
1582 w.tc = tc; 1629 w.tc = tc;
1583 atomic_set(&w.complete, 0); 1630 atomic_set(&w.complete, 0);
1584 init_waitqueue_head(&w.wait); 1631 init_waitqueue_head(&w.wait);
@@ -3061,11 +3108,25 @@ static struct target_type pool_target = {
3061/*---------------------------------------------------------------- 3108/*----------------------------------------------------------------
3062 * Thin target methods 3109 * Thin target methods
3063 *--------------------------------------------------------------*/ 3110 *--------------------------------------------------------------*/
3111static void thin_get(struct thin_c *tc)
3112{
3113 atomic_inc(&tc->refcount);
3114}
3115
3116static void thin_put(struct thin_c *tc)
3117{
3118 if (atomic_dec_and_test(&tc->refcount))
3119 complete(&tc->can_destroy);
3120}
3121
3064static void thin_dtr(struct dm_target *ti) 3122static void thin_dtr(struct dm_target *ti)
3065{ 3123{
3066 struct thin_c *tc = ti->private; 3124 struct thin_c *tc = ti->private;
3067 unsigned long flags; 3125 unsigned long flags;
3068 3126
3127 thin_put(tc);
3128 wait_for_completion(&tc->can_destroy);
3129
3069 spin_lock_irqsave(&tc->pool->lock, flags); 3130 spin_lock_irqsave(&tc->pool->lock, flags);
3070 list_del_rcu(&tc->list); 3131 list_del_rcu(&tc->list);
3071 spin_unlock_irqrestore(&tc->pool->lock, flags); 3132 spin_unlock_irqrestore(&tc->pool->lock, flags);
@@ -3101,6 +3162,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
3101 struct thin_c *tc; 3162 struct thin_c *tc;
3102 struct dm_dev *pool_dev, *origin_dev; 3163 struct dm_dev *pool_dev, *origin_dev;
3103 struct mapped_device *pool_md; 3164 struct mapped_device *pool_md;
3165 unsigned long flags;
3104 3166
3105 mutex_lock(&dm_thin_pool_table.mutex); 3167 mutex_lock(&dm_thin_pool_table.mutex);
3106 3168
@@ -3191,9 +3253,12 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
3191 3253
3192 mutex_unlock(&dm_thin_pool_table.mutex); 3254 mutex_unlock(&dm_thin_pool_table.mutex);
3193 3255
3194 spin_lock(&tc->pool->lock); 3256 atomic_set(&tc->refcount, 1);
3257 init_completion(&tc->can_destroy);
3258
3259 spin_lock_irqsave(&tc->pool->lock, flags);
3195 list_add_tail_rcu(&tc->list, &tc->pool->active_thins); 3260 list_add_tail_rcu(&tc->list, &tc->pool->active_thins);
3196 spin_unlock(&tc->pool->lock); 3261 spin_unlock_irqrestore(&tc->pool->lock, flags);
3197 /* 3262 /*
3198 * This synchronize_rcu() call is needed here otherwise we risk a 3263 * This synchronize_rcu() call is needed here otherwise we risk a
3199 * wake_worker() call finding no bios to process (because the newly 3264 * wake_worker() call finding no bios to process (because the newly
diff --git a/drivers/md/dm-verity.c b/drivers/md/dm-verity.c
index 796007a5e0e1..7a7bab8947ae 100644
--- a/drivers/md/dm-verity.c
+++ b/drivers/md/dm-verity.c
@@ -330,15 +330,17 @@ test_block_hash:
330 return r; 330 return r;
331 } 331 }
332 } 332 }
333
334 todo = 1 << v->data_dev_block_bits; 333 todo = 1 << v->data_dev_block_bits;
335 while (io->iter.bi_size) { 334 do {
336 u8 *page; 335 u8 *page;
336 unsigned len;
337 struct bio_vec bv = bio_iter_iovec(bio, io->iter); 337 struct bio_vec bv = bio_iter_iovec(bio, io->iter);
338 338
339 page = kmap_atomic(bv.bv_page); 339 page = kmap_atomic(bv.bv_page);
340 r = crypto_shash_update(desc, page + bv.bv_offset, 340 len = bv.bv_len;
341 bv.bv_len); 341 if (likely(len >= todo))
342 len = todo;
343 r = crypto_shash_update(desc, page + bv.bv_offset, len);
342 kunmap_atomic(page); 344 kunmap_atomic(page);
343 345
344 if (r < 0) { 346 if (r < 0) {
@@ -346,8 +348,9 @@ test_block_hash:
346 return r; 348 return r;
347 } 349 }
348 350
349 bio_advance_iter(bio, &io->iter, bv.bv_len); 351 bio_advance_iter(bio, &io->iter, len);
350 } 352 todo -= len;
353 } while (todo);
351 354
352 if (!v->version) { 355 if (!v->version) {
353 r = crypto_shash_update(desc, v->salt, v->salt_size); 356 r = crypto_shash_update(desc, v->salt, v->salt_size);
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index c137abfa0c54..20f1655e6d75 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -56,7 +56,7 @@ config VIDEO_VIU
56 56
57config VIDEO_TIMBERDALE 57config VIDEO_TIMBERDALE
58 tristate "Support for timberdale Video In/LogiWIN" 58 tristate "Support for timberdale Video In/LogiWIN"
59 depends on VIDEO_V4L2 && I2C && DMADEVICES 59 depends on MFD_TIMBERDALE && VIDEO_V4L2 && I2C && DMADEVICES
60 select DMA_ENGINE 60 select DMA_ENGINE
61 select TIMB_DMA 61 select TIMB_DMA
62 select VIDEO_ADV7180 62 select VIDEO_ADV7180
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 7ff473c871a9..8d659e6a1b4c 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -431,7 +431,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
431 * Create one workqueue per volume (per registered block device). 431 * Create one workqueue per volume (per registered block device).
432 * Rembember workqueues are cheap, they're not threads. 432 * Rembember workqueues are cheap, they're not threads.
433 */ 433 */
434 dev->wq = alloc_workqueue(gd->disk_name, 0, 0); 434 dev->wq = alloc_workqueue("%s", 0, 0, gd->disk_name);
435 if (!dev->wq) 435 if (!dev->wq)
436 goto out_free_queue; 436 goto out_free_queue;
437 INIT_WORK(&dev->work, ubiblock_do_work); 437 INIT_WORK(&dev->work, ubiblock_do_work);
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 02317c1c0238..0f3425dac910 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -671,6 +671,8 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
671 671
672 e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF); 672 e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
673 self_check_in_wl_tree(ubi, e, &ubi->free); 673 self_check_in_wl_tree(ubi, e, &ubi->free);
674 ubi->free_count--;
675 ubi_assert(ubi->free_count >= 0);
674 rb_erase(&e->u.rb, &ubi->free); 676 rb_erase(&e->u.rb, &ubi->free);
675 677
676 return e; 678 return e;
@@ -684,6 +686,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
684 peb = __wl_get_peb(ubi); 686 peb = __wl_get_peb(ubi);
685 spin_unlock(&ubi->wl_lock); 687 spin_unlock(&ubi->wl_lock);
686 688
689 if (peb < 0)
690 return peb;
691
687 err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset, 692 err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
688 ubi->peb_size - ubi->vid_hdr_aloffset); 693 ubi->peb_size - ubi->vid_hdr_aloffset);
689 if (err) { 694 if (err) {
@@ -1068,6 +1073,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
1068 1073
1069 /* Give the unused PEB back */ 1074 /* Give the unused PEB back */
1070 wl_tree_add(e2, &ubi->free); 1075 wl_tree_add(e2, &ubi->free);
1076 ubi->free_count++;
1071 goto out_cancel; 1077 goto out_cancel;
1072 } 1078 }
1073 self_check_in_wl_tree(ubi, e1, &ubi->used); 1079 self_check_in_wl_tree(ubi, e1, &ubi->used);
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 5a59b85cdfc2..39c4d8d61074 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -362,7 +362,7 @@ static ssize_t bonding_show_min_links(struct device *d,
362{ 362{
363 struct bonding *bond = to_bond(d); 363 struct bonding *bond = to_bond(d);
364 364
365 return sprintf(buf, "%d\n", bond->params.min_links); 365 return sprintf(buf, "%u\n", bond->params.min_links);
366} 366}
367static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR, 367static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
368 bonding_show_min_links, bonding_sysfs_store_option); 368 bonding_show_min_links, bonding_sysfs_store_option);
diff --git a/drivers/net/can/c_can/Kconfig b/drivers/net/can/c_can/Kconfig
index 61ffc12d8fd8..8ab7103d4f44 100644
--- a/drivers/net/can/c_can/Kconfig
+++ b/drivers/net/can/c_can/Kconfig
@@ -14,6 +14,13 @@ config CAN_C_CAN_PLATFORM
14 SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com) 14 SPEAr1310 and SPEAr320 evaluation boards & TI (www.ti.com)
15 boards like am335x, dm814x, dm813x and dm811x. 15 boards like am335x, dm814x, dm813x and dm811x.
16 16
17config CAN_C_CAN_STRICT_FRAME_ORDERING
18 bool "Force a strict RX CAN frame order (may cause frame loss)"
19 ---help---
20 The RX split buffer prevents packet reordering but can cause packet
21 loss. Only enable this option when you accept to lose CAN frames
22 in favour of getting the received CAN frames in the correct order.
23
17config CAN_C_CAN_PCI 24config CAN_C_CAN_PCI
18 tristate "Generic PCI Bus based C_CAN/D_CAN driver" 25 tristate "Generic PCI Bus based C_CAN/D_CAN driver"
19 depends on PCI 26 depends on PCI
diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index a5c8dcfa8357..a2ca820b5373 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -60,6 +60,8 @@
60#define CONTROL_IE BIT(1) 60#define CONTROL_IE BIT(1)
61#define CONTROL_INIT BIT(0) 61#define CONTROL_INIT BIT(0)
62 62
63#define CONTROL_IRQMSK (CONTROL_EIE | CONTROL_IE | CONTROL_SIE)
64
63/* test register */ 65/* test register */
64#define TEST_RX BIT(7) 66#define TEST_RX BIT(7)
65#define TEST_TX1 BIT(6) 67#define TEST_TX1 BIT(6)
@@ -108,11 +110,14 @@
108#define IF_COMM_CONTROL BIT(4) 110#define IF_COMM_CONTROL BIT(4)
109#define IF_COMM_CLR_INT_PND BIT(3) 111#define IF_COMM_CLR_INT_PND BIT(3)
110#define IF_COMM_TXRQST BIT(2) 112#define IF_COMM_TXRQST BIT(2)
113#define IF_COMM_CLR_NEWDAT IF_COMM_TXRQST
111#define IF_COMM_DATAA BIT(1) 114#define IF_COMM_DATAA BIT(1)
112#define IF_COMM_DATAB BIT(0) 115#define IF_COMM_DATAB BIT(0)
113#define IF_COMM_ALL (IF_COMM_MASK | IF_COMM_ARB | \ 116
114 IF_COMM_CONTROL | IF_COMM_TXRQST | \ 117/* TX buffer setup */
115 IF_COMM_DATAA | IF_COMM_DATAB) 118#define IF_COMM_TX (IF_COMM_ARB | IF_COMM_CONTROL | \
119 IF_COMM_TXRQST | \
120 IF_COMM_DATAA | IF_COMM_DATAB)
116 121
117/* For the low buffers we clear the interrupt bit, but keep newdat */ 122/* For the low buffers we clear the interrupt bit, but keep newdat */
118#define IF_COMM_RCV_LOW (IF_COMM_MASK | IF_COMM_ARB | \ 123#define IF_COMM_RCV_LOW (IF_COMM_MASK | IF_COMM_ARB | \
@@ -120,12 +125,19 @@
120 IF_COMM_DATAA | IF_COMM_DATAB) 125 IF_COMM_DATAA | IF_COMM_DATAB)
121 126
122/* For the high buffers we clear the interrupt bit and newdat */ 127/* For the high buffers we clear the interrupt bit and newdat */
123#define IF_COMM_RCV_HIGH (IF_COMM_RCV_LOW | IF_COMM_TXRQST) 128#define IF_COMM_RCV_HIGH (IF_COMM_RCV_LOW | IF_COMM_CLR_NEWDAT)
129
130
131/* Receive setup of message objects */
132#define IF_COMM_RCV_SETUP (IF_COMM_MASK | IF_COMM_ARB | IF_COMM_CONTROL)
133
134/* Invalidation of message objects */
135#define IF_COMM_INVAL (IF_COMM_ARB | IF_COMM_CONTROL)
124 136
125/* IFx arbitration */ 137/* IFx arbitration */
126#define IF_ARB_MSGVAL BIT(15) 138#define IF_ARB_MSGVAL BIT(31)
127#define IF_ARB_MSGXTD BIT(14) 139#define IF_ARB_MSGXTD BIT(30)
128#define IF_ARB_TRANSMIT BIT(13) 140#define IF_ARB_TRANSMIT BIT(29)
129 141
130/* IFx message control */ 142/* IFx message control */
131#define IF_MCONT_NEWDAT BIT(15) 143#define IF_MCONT_NEWDAT BIT(15)
@@ -139,19 +151,17 @@
139#define IF_MCONT_EOB BIT(7) 151#define IF_MCONT_EOB BIT(7)
140#define IF_MCONT_DLC_MASK 0xf 152#define IF_MCONT_DLC_MASK 0xf
141 153
154#define IF_MCONT_RCV (IF_MCONT_RXIE | IF_MCONT_UMASK)
155#define IF_MCONT_RCV_EOB (IF_MCONT_RCV | IF_MCONT_EOB)
156
157#define IF_MCONT_TX (IF_MCONT_TXIE | IF_MCONT_EOB)
158
142/* 159/*
143 * Use IF1 for RX and IF2 for TX 160 * Use IF1 for RX and IF2 for TX
144 */ 161 */
145#define IF_RX 0 162#define IF_RX 0
146#define IF_TX 1 163#define IF_TX 1
147 164
148/* status interrupt */
149#define STATUS_INTERRUPT 0x8000
150
151/* global interrupt masks */
152#define ENABLE_ALL_INTERRUPTS 1
153#define DISABLE_ALL_INTERRUPTS 0
154
155/* minimum timeout for checking BUSY status */ 165/* minimum timeout for checking BUSY status */
156#define MIN_TIMEOUT_VALUE 6 166#define MIN_TIMEOUT_VALUE 6
157 167
@@ -171,6 +181,7 @@ enum c_can_lec_type {
171 LEC_BIT0_ERROR, 181 LEC_BIT0_ERROR,
172 LEC_CRC_ERROR, 182 LEC_CRC_ERROR,
173 LEC_UNUSED, 183 LEC_UNUSED,
184 LEC_MASK = LEC_UNUSED,
174}; 185};
175 186
176/* 187/*
@@ -226,143 +237,115 @@ static inline void c_can_reset_ram(const struct c_can_priv *priv, bool enable)
226 priv->raminit(priv, enable); 237 priv->raminit(priv, enable);
227} 238}
228 239
229static inline int get_tx_next_msg_obj(const struct c_can_priv *priv) 240static void c_can_irq_control(struct c_can_priv *priv, bool enable)
230{ 241{
231 return (priv->tx_next & C_CAN_NEXT_MSG_OBJ_MASK) + 242 u32 ctrl = priv->read_reg(priv, C_CAN_CTRL_REG) & ~CONTROL_IRQMSK;
232 C_CAN_MSG_OBJ_TX_FIRST;
233}
234
235static inline int get_tx_echo_msg_obj(int txecho)
236{
237 return (txecho & C_CAN_NEXT_MSG_OBJ_MASK) + C_CAN_MSG_OBJ_TX_FIRST;
238}
239
240static u32 c_can_read_reg32(struct c_can_priv *priv, enum reg index)
241{
242 u32 val = priv->read_reg(priv, index);
243 val |= ((u32) priv->read_reg(priv, index + 1)) << 16;
244 return val;
245}
246
247static void c_can_enable_all_interrupts(struct c_can_priv *priv,
248 int enable)
249{
250 unsigned int cntrl_save = priv->read_reg(priv,
251 C_CAN_CTRL_REG);
252 243
253 if (enable) 244 if (enable)
254 cntrl_save |= (CONTROL_SIE | CONTROL_EIE | CONTROL_IE); 245 ctrl |= CONTROL_IRQMSK;
255 else
256 cntrl_save &= ~(CONTROL_EIE | CONTROL_IE | CONTROL_SIE);
257 246
258 priv->write_reg(priv, C_CAN_CTRL_REG, cntrl_save); 247 priv->write_reg(priv, C_CAN_CTRL_REG, ctrl);
259} 248}
260 249
261static inline int c_can_msg_obj_is_busy(struct c_can_priv *priv, int iface) 250static void c_can_obj_update(struct net_device *dev, int iface, u32 cmd, u32 obj)
262{ 251{
263 int count = MIN_TIMEOUT_VALUE; 252 struct c_can_priv *priv = netdev_priv(dev);
253 int cnt, reg = C_CAN_IFACE(COMREQ_REG, iface);
254
255 priv->write_reg(priv, reg + 1, cmd);
256 priv->write_reg(priv, reg, obj);
264 257
265 while (count && priv->read_reg(priv, 258 for (cnt = MIN_TIMEOUT_VALUE; cnt; cnt--) {
266 C_CAN_IFACE(COMREQ_REG, iface)) & 259 if (!(priv->read_reg(priv, reg) & IF_COMR_BUSY))
267 IF_COMR_BUSY) { 260 return;
268 count--;
269 udelay(1); 261 udelay(1);
270 } 262 }
263 netdev_err(dev, "Updating object timed out\n");
271 264
272 if (!count) 265}
273 return 1;
274 266
275 return 0; 267static inline void c_can_object_get(struct net_device *dev, int iface,
268 u32 obj, u32 cmd)
269{
270 c_can_obj_update(dev, iface, cmd, obj);
276} 271}
277 272
278static inline void c_can_object_get(struct net_device *dev, 273static inline void c_can_object_put(struct net_device *dev, int iface,
279 int iface, int objno, int mask) 274 u32 obj, u32 cmd)
280{ 275{
281 struct c_can_priv *priv = netdev_priv(dev); 276 c_can_obj_update(dev, iface, cmd | IF_COMM_WR, obj);
277}
282 278
283 /* 279/*
284 * As per specs, after writting the message object number in the 280 * Note: According to documentation clearing TXIE while MSGVAL is set
285 * IF command request register the transfer b/w interface 281 * is not allowed, but works nicely on C/DCAN. And that lowers the I/O
286 * register and message RAM must be complete in 6 CAN-CLK 282 * load significantly.
287 * period. 283 */
288 */ 284static void c_can_inval_tx_object(struct net_device *dev, int iface, int obj)
289 priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface), 285{
290 IFX_WRITE_LOW_16BIT(mask)); 286 struct c_can_priv *priv = netdev_priv(dev);
291 priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface),
292 IFX_WRITE_LOW_16BIT(objno));
293 287
294 if (c_can_msg_obj_is_busy(priv, iface)) 288 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), 0);
295 netdev_err(dev, "timed out in object get\n"); 289 c_can_object_put(dev, iface, obj, IF_COMM_INVAL);
296} 290}
297 291
298static inline void c_can_object_put(struct net_device *dev, 292static void c_can_inval_msg_object(struct net_device *dev, int iface, int obj)
299 int iface, int objno, int mask)
300{ 293{
301 struct c_can_priv *priv = netdev_priv(dev); 294 struct c_can_priv *priv = netdev_priv(dev);
302 295
303 /* 296 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 0);
304 * As per specs, after writting the message object number in the 297 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), 0);
305 * IF command request register the transfer b/w interface 298 c_can_inval_tx_object(dev, iface, obj);
306 * register and message RAM must be complete in 6 CAN-CLK
307 * period.
308 */
309 priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface),
310 (IF_COMM_WR | IFX_WRITE_LOW_16BIT(mask)));
311 priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface),
312 IFX_WRITE_LOW_16BIT(objno));
313
314 if (c_can_msg_obj_is_busy(priv, iface))
315 netdev_err(dev, "timed out in object put\n");
316} 299}
317 300
318static void c_can_write_msg_object(struct net_device *dev, 301static void c_can_setup_tx_object(struct net_device *dev, int iface,
319 int iface, struct can_frame *frame, int objno) 302 struct can_frame *frame, int idx)
320{ 303{
321 int i;
322 u16 flags = 0;
323 unsigned int id;
324 struct c_can_priv *priv = netdev_priv(dev); 304 struct c_can_priv *priv = netdev_priv(dev);
325 305 u16 ctrl = IF_MCONT_TX | frame->can_dlc;
326 if (!(frame->can_id & CAN_RTR_FLAG)) 306 bool rtr = frame->can_id & CAN_RTR_FLAG;
327 flags |= IF_ARB_TRANSMIT; 307 u32 arb = IF_ARB_MSGVAL;
308 int i;
328 309
329 if (frame->can_id & CAN_EFF_FLAG) { 310 if (frame->can_id & CAN_EFF_FLAG) {
330 id = frame->can_id & CAN_EFF_MASK; 311 arb |= frame->can_id & CAN_EFF_MASK;
331 flags |= IF_ARB_MSGXTD; 312 arb |= IF_ARB_MSGXTD;
332 } else 313 } else {
333 id = ((frame->can_id & CAN_SFF_MASK) << 18); 314 arb |= (frame->can_id & CAN_SFF_MASK) << 18;
315 }
316
317 if (!rtr)
318 arb |= IF_ARB_TRANSMIT;
334 319
335 flags |= IF_ARB_MSGVAL; 320 /*
321 * If we change the DIR bit, we need to invalidate the buffer
322 * first, i.e. clear the MSGVAL flag in the arbiter.
323 */
324 if (rtr != (bool)test_bit(idx, &priv->tx_dir)) {
325 u32 obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
326
327 c_can_inval_msg_object(dev, iface, obj);
328 change_bit(idx, &priv->tx_dir);
329 }
330
331 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), arb);
332 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), arb >> 16);
336 333
337 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 334 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl);
338 IFX_WRITE_LOW_16BIT(id));
339 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), flags |
340 IFX_WRITE_HIGH_16BIT(id));
341 335
342 for (i = 0; i < frame->can_dlc; i += 2) { 336 for (i = 0; i < frame->can_dlc; i += 2) {
343 priv->write_reg(priv, C_CAN_IFACE(DATA1_REG, iface) + i / 2, 337 priv->write_reg(priv, C_CAN_IFACE(DATA1_REG, iface) + i / 2,
344 frame->data[i] | (frame->data[i + 1] << 8)); 338 frame->data[i] | (frame->data[i + 1] << 8));
345 } 339 }
346
347 /* enable interrupt for this message object */
348 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface),
349 IF_MCONT_TXIE | IF_MCONT_TXRQST | IF_MCONT_EOB |
350 frame->can_dlc);
351 c_can_object_put(dev, iface, objno, IF_COMM_ALL);
352} 340}
353 341
354static inline void c_can_activate_all_lower_rx_msg_obj(struct net_device *dev, 342static inline void c_can_activate_all_lower_rx_msg_obj(struct net_device *dev,
355 int iface, 343 int iface)
356 int ctrl_mask)
357{ 344{
358 int i; 345 int i;
359 struct c_can_priv *priv = netdev_priv(dev);
360 346
361 for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_MSG_RX_LOW_LAST; i++) { 347 for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_MSG_RX_LOW_LAST; i++)
362 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), 348 c_can_object_get(dev, iface, i, IF_COMM_CLR_NEWDAT);
363 ctrl_mask & ~IF_MCONT_NEWDAT);
364 c_can_object_put(dev, iface, i, IF_COMM_CONTROL);
365 }
366} 349}
367 350
368static int c_can_handle_lost_msg_obj(struct net_device *dev, 351static int c_can_handle_lost_msg_obj(struct net_device *dev,
@@ -377,6 +360,9 @@ static int c_can_handle_lost_msg_obj(struct net_device *dev,
377 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl); 360 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), ctrl);
378 c_can_object_put(dev, iface, objno, IF_COMM_CONTROL); 361 c_can_object_put(dev, iface, objno, IF_COMM_CONTROL);
379 362
363 stats->rx_errors++;
364 stats->rx_over_errors++;
365
380 /* create an error msg */ 366 /* create an error msg */
381 skb = alloc_can_err_skb(dev, &frame); 367 skb = alloc_can_err_skb(dev, &frame);
382 if (unlikely(!skb)) 368 if (unlikely(!skb))
@@ -384,22 +370,18 @@ static int c_can_handle_lost_msg_obj(struct net_device *dev,
384 370
385 frame->can_id |= CAN_ERR_CRTL; 371 frame->can_id |= CAN_ERR_CRTL;
386 frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; 372 frame->data[1] = CAN_ERR_CRTL_RX_OVERFLOW;
387 stats->rx_errors++;
388 stats->rx_over_errors++;
389 373
390 netif_receive_skb(skb); 374 netif_receive_skb(skb);
391 return 1; 375 return 1;
392} 376}
393 377
394static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl) 378static int c_can_read_msg_object(struct net_device *dev, int iface, u32 ctrl)
395{ 379{
396 u16 flags, data;
397 int i;
398 unsigned int val;
399 struct c_can_priv *priv = netdev_priv(dev);
400 struct net_device_stats *stats = &dev->stats; 380 struct net_device_stats *stats = &dev->stats;
401 struct sk_buff *skb; 381 struct c_can_priv *priv = netdev_priv(dev);
402 struct can_frame *frame; 382 struct can_frame *frame;
383 struct sk_buff *skb;
384 u32 arb, data;
403 385
404 skb = alloc_can_skb(dev, &frame); 386 skb = alloc_can_skb(dev, &frame);
405 if (!skb) { 387 if (!skb) {
@@ -409,115 +391,82 @@ static int c_can_read_msg_object(struct net_device *dev, int iface, int ctrl)
409 391
410 frame->can_dlc = get_can_dlc(ctrl & 0x0F); 392 frame->can_dlc = get_can_dlc(ctrl & 0x0F);
411 393
412 flags = priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)); 394 arb = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface));
413 val = priv->read_reg(priv, C_CAN_IFACE(ARB1_REG, iface)) | 395 arb |= priv->read_reg(priv, C_CAN_IFACE(ARB2_REG, iface)) << 16;
414 (flags << 16);
415 396
416 if (flags & IF_ARB_MSGXTD) 397 if (arb & IF_ARB_MSGXTD)
417 frame->can_id = (val & CAN_EFF_MASK) | CAN_EFF_FLAG; 398 frame->can_id = (arb & CAN_EFF_MASK) | CAN_EFF_FLAG;
418 else 399 else
419 frame->can_id = (val >> 18) & CAN_SFF_MASK; 400 frame->can_id = (arb >> 18) & CAN_SFF_MASK;
420 401
421 if (flags & IF_ARB_TRANSMIT) 402 if (arb & IF_ARB_TRANSMIT) {
422 frame->can_id |= CAN_RTR_FLAG; 403 frame->can_id |= CAN_RTR_FLAG;
423 else { 404 } else {
424 for (i = 0; i < frame->can_dlc; i += 2) { 405 int i, dreg = C_CAN_IFACE(DATA1_REG, iface);
425 data = priv->read_reg(priv, 406
426 C_CAN_IFACE(DATA1_REG, iface) + i / 2); 407 for (i = 0; i < frame->can_dlc; i += 2, dreg ++) {
408 data = priv->read_reg(priv, dreg);
427 frame->data[i] = data; 409 frame->data[i] = data;
428 frame->data[i + 1] = data >> 8; 410 frame->data[i + 1] = data >> 8;
429 } 411 }
430 } 412 }
431 413
432 netif_receive_skb(skb);
433
434 stats->rx_packets++; 414 stats->rx_packets++;
435 stats->rx_bytes += frame->can_dlc; 415 stats->rx_bytes += frame->can_dlc;
416
417 netif_receive_skb(skb);
436 return 0; 418 return 0;
437} 419}
438 420
439static void c_can_setup_receive_object(struct net_device *dev, int iface, 421static void c_can_setup_receive_object(struct net_device *dev, int iface,
440 int objno, unsigned int mask, 422 u32 obj, u32 mask, u32 id, u32 mcont)
441 unsigned int id, unsigned int mcont)
442{ 423{
443 struct c_can_priv *priv = netdev_priv(dev); 424 struct c_can_priv *priv = netdev_priv(dev);
444 425
445 priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), 426 mask |= BIT(29);
446 IFX_WRITE_LOW_16BIT(mask)); 427 priv->write_reg(priv, C_CAN_IFACE(MASK1_REG, iface), mask);
447 428 priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface), mask >> 16);
448 /* According to C_CAN documentation, the reserved bit
449 * in IFx_MASK2 register is fixed 1
450 */
451 priv->write_reg(priv, C_CAN_IFACE(MASK2_REG, iface),
452 IFX_WRITE_HIGH_16BIT(mask) | BIT(13));
453 429
454 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 430 id |= IF_ARB_MSGVAL;
455 IFX_WRITE_LOW_16BIT(id)); 431 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), id);
456 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), 432 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), id >> 16);
457 (IF_ARB_MSGVAL | IFX_WRITE_HIGH_16BIT(id)));
458 433
459 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont); 434 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), mcont);
460 c_can_object_put(dev, iface, objno, IF_COMM_ALL & ~IF_COMM_TXRQST); 435 c_can_object_put(dev, iface, obj, IF_COMM_RCV_SETUP);
461
462 netdev_dbg(dev, "obj no:%d, msgval:0x%08x\n", objno,
463 c_can_read_reg32(priv, C_CAN_MSGVAL1_REG));
464}
465
466static void c_can_inval_msg_object(struct net_device *dev, int iface, int objno)
467{
468 struct c_can_priv *priv = netdev_priv(dev);
469
470 priv->write_reg(priv, C_CAN_IFACE(ARB1_REG, iface), 0);
471 priv->write_reg(priv, C_CAN_IFACE(ARB2_REG, iface), 0);
472 priv->write_reg(priv, C_CAN_IFACE(MSGCTRL_REG, iface), 0);
473
474 c_can_object_put(dev, iface, objno, IF_COMM_ARB | IF_COMM_CONTROL);
475
476 netdev_dbg(dev, "obj no:%d, msgval:0x%08x\n", objno,
477 c_can_read_reg32(priv, C_CAN_MSGVAL1_REG));
478}
479
480static inline int c_can_is_next_tx_obj_busy(struct c_can_priv *priv, int objno)
481{
482 int val = c_can_read_reg32(priv, C_CAN_TXRQST1_REG);
483
484 /*
485 * as transmission request register's bit n-1 corresponds to
486 * message object n, we need to handle the same properly.
487 */
488 if (val & (1 << (objno - 1)))
489 return 1;
490
491 return 0;
492} 436}
493 437
494static netdev_tx_t c_can_start_xmit(struct sk_buff *skb, 438static netdev_tx_t c_can_start_xmit(struct sk_buff *skb,
495 struct net_device *dev) 439 struct net_device *dev)
496{ 440{
497 u32 msg_obj_no;
498 struct c_can_priv *priv = netdev_priv(dev);
499 struct can_frame *frame = (struct can_frame *)skb->data; 441 struct can_frame *frame = (struct can_frame *)skb->data;
442 struct c_can_priv *priv = netdev_priv(dev);
443 u32 idx, obj;
500 444
501 if (can_dropped_invalid_skb(dev, skb)) 445 if (can_dropped_invalid_skb(dev, skb))
502 return NETDEV_TX_OK; 446 return NETDEV_TX_OK;
503
504 spin_lock_bh(&priv->xmit_lock);
505 msg_obj_no = get_tx_next_msg_obj(priv);
506
507 /* prepare message object for transmission */
508 c_can_write_msg_object(dev, IF_TX, frame, msg_obj_no);
509 priv->dlc[msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST] = frame->can_dlc;
510 can_put_echo_skb(skb, dev, msg_obj_no - C_CAN_MSG_OBJ_TX_FIRST);
511
512 /* 447 /*
513 * we have to stop the queue in case of a wrap around or 448 * This is not a FIFO. C/D_CAN sends out the buffers
514 * if the next TX message object is still in use 449 * prioritized. The lowest buffer number wins.
515 */ 450 */
516 priv->tx_next++; 451 idx = fls(atomic_read(&priv->tx_active));
517 if (c_can_is_next_tx_obj_busy(priv, get_tx_next_msg_obj(priv)) || 452 obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
518 (priv->tx_next & C_CAN_NEXT_MSG_OBJ_MASK) == 0) 453
454 /* If this is the last buffer, stop the xmit queue */
455 if (idx == C_CAN_MSG_OBJ_TX_NUM - 1)
519 netif_stop_queue(dev); 456 netif_stop_queue(dev);
520 spin_unlock_bh(&priv->xmit_lock); 457 /*
458 * Store the message in the interface so we can call
459 * can_put_echo_skb(). We must do this before we enable
460 * transmit as we might race against do_tx().
461 */
462 c_can_setup_tx_object(dev, IF_TX, frame, idx);
463 priv->dlc[idx] = frame->can_dlc;
464 can_put_echo_skb(skb, dev, idx);
465
466 /* Update the active bits */
467 atomic_add((1 << idx), &priv->tx_active);
468 /* Start transmission */
469 c_can_object_put(dev, IF_TX, obj, IF_COMM_TX);
521 470
522 return NETDEV_TX_OK; 471 return NETDEV_TX_OK;
523} 472}
@@ -594,11 +543,10 @@ static void c_can_configure_msg_objects(struct net_device *dev)
594 543
595 /* setup receive message objects */ 544 /* setup receive message objects */
596 for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++) 545 for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++)
597 c_can_setup_receive_object(dev, IF_RX, i, 0, 0, 546 c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV);
598 (IF_MCONT_RXIE | IF_MCONT_UMASK) & ~IF_MCONT_EOB);
599 547
600 c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0, 548 c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0,
601 IF_MCONT_EOB | IF_MCONT_RXIE | IF_MCONT_UMASK); 549 IF_MCONT_RCV_EOB);
602} 550}
603 551
604/* 552/*
@@ -612,30 +560,22 @@ static int c_can_chip_config(struct net_device *dev)
612 struct c_can_priv *priv = netdev_priv(dev); 560 struct c_can_priv *priv = netdev_priv(dev);
613 561
614 /* enable automatic retransmission */ 562 /* enable automatic retransmission */
615 priv->write_reg(priv, C_CAN_CTRL_REG, 563 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_ENABLE_AR);
616 CONTROL_ENABLE_AR);
617 564
618 if ((priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) && 565 if ((priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) &&
619 (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)) { 566 (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)) {
620 /* loopback + silent mode : useful for hot self-test */ 567 /* loopback + silent mode : useful for hot self-test */
621 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE | 568 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
622 CONTROL_SIE | CONTROL_IE | CONTROL_TEST); 569 priv->write_reg(priv, C_CAN_TEST_REG, TEST_LBACK | TEST_SILENT);
623 priv->write_reg(priv, C_CAN_TEST_REG,
624 TEST_LBACK | TEST_SILENT);
625 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) { 570 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) {
626 /* loopback mode : useful for self-test function */ 571 /* loopback mode : useful for self-test function */
627 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE | 572 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
628 CONTROL_SIE | CONTROL_IE | CONTROL_TEST);
629 priv->write_reg(priv, C_CAN_TEST_REG, TEST_LBACK); 573 priv->write_reg(priv, C_CAN_TEST_REG, TEST_LBACK);
630 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) { 574 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
631 /* silent mode : bus-monitoring mode */ 575 /* silent mode : bus-monitoring mode */
632 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_EIE | 576 priv->write_reg(priv, C_CAN_CTRL_REG, CONTROL_TEST);
633 CONTROL_SIE | CONTROL_IE | CONTROL_TEST);
634 priv->write_reg(priv, C_CAN_TEST_REG, TEST_SILENT); 577 priv->write_reg(priv, C_CAN_TEST_REG, TEST_SILENT);
635 } else 578 }
636 /* normal mode*/
637 priv->write_reg(priv, C_CAN_CTRL_REG,
638 CONTROL_EIE | CONTROL_SIE | CONTROL_IE);
639 579
640 /* configure message objects */ 580 /* configure message objects */
641 c_can_configure_msg_objects(dev); 581 c_can_configure_msg_objects(dev);
@@ -643,6 +583,11 @@ static int c_can_chip_config(struct net_device *dev)
643 /* set a `lec` value so that we can check for updates later */ 583 /* set a `lec` value so that we can check for updates later */
644 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED); 584 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
645 585
586 /* Clear all internal status */
587 atomic_set(&priv->tx_active, 0);
588 priv->rxmasked = 0;
589 priv->tx_dir = 0;
590
646 /* set bittiming params */ 591 /* set bittiming params */
647 return c_can_set_bittiming(dev); 592 return c_can_set_bittiming(dev);
648} 593}
@@ -657,13 +602,11 @@ static int c_can_start(struct net_device *dev)
657 if (err) 602 if (err)
658 return err; 603 return err;
659 604
660 priv->can.state = CAN_STATE_ERROR_ACTIVE; 605 /* Setup the command for new messages */
661 606 priv->comm_rcv_high = priv->type != BOSCH_D_CAN ?
662 /* reset tx helper pointers */ 607 IF_COMM_RCV_LOW : IF_COMM_RCV_HIGH;
663 priv->tx_next = priv->tx_echo = 0;
664 608
665 /* enable status change, error and module interrupts */ 609 priv->can.state = CAN_STATE_ERROR_ACTIVE;
666 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
667 610
668 return 0; 611 return 0;
669} 612}
@@ -672,15 +615,13 @@ static void c_can_stop(struct net_device *dev)
672{ 615{
673 struct c_can_priv *priv = netdev_priv(dev); 616 struct c_can_priv *priv = netdev_priv(dev);
674 617
675 /* disable all interrupts */ 618 c_can_irq_control(priv, false);
676 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
677
678 /* set the state as STOPPED */
679 priv->can.state = CAN_STATE_STOPPED; 619 priv->can.state = CAN_STATE_STOPPED;
680} 620}
681 621
682static int c_can_set_mode(struct net_device *dev, enum can_mode mode) 622static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
683{ 623{
624 struct c_can_priv *priv = netdev_priv(dev);
684 int err; 625 int err;
685 626
686 switch (mode) { 627 switch (mode) {
@@ -689,6 +630,7 @@ static int c_can_set_mode(struct net_device *dev, enum can_mode mode)
689 if (err) 630 if (err)
690 return err; 631 return err;
691 netif_wake_queue(dev); 632 netif_wake_queue(dev);
633 c_can_irq_control(priv, true);
692 break; 634 break;
693 default: 635 default:
694 return -EOPNOTSUPP; 636 return -EOPNOTSUPP;
@@ -724,42 +666,29 @@ static int c_can_get_berr_counter(const struct net_device *dev,
724 return err; 666 return err;
725} 667}
726 668
727/*
728 * priv->tx_echo holds the number of the oldest can_frame put for
729 * transmission into the hardware, but not yet ACKed by the CAN tx
730 * complete IRQ.
731 *
732 * We iterate from priv->tx_echo to priv->tx_next and check if the
733 * packet has been transmitted, echo it back to the CAN framework.
734 * If we discover a not yet transmitted packet, stop looking for more.
735 */
736static void c_can_do_tx(struct net_device *dev) 669static void c_can_do_tx(struct net_device *dev)
737{ 670{
738 struct c_can_priv *priv = netdev_priv(dev); 671 struct c_can_priv *priv = netdev_priv(dev);
739 struct net_device_stats *stats = &dev->stats; 672 struct net_device_stats *stats = &dev->stats;
740 u32 val, obj, pkts = 0, bytes = 0; 673 u32 idx, obj, pkts = 0, bytes = 0, pend, clr;
741
742 spin_lock_bh(&priv->xmit_lock);
743 674
744 for (; (priv->tx_next - priv->tx_echo) > 0; priv->tx_echo++) { 675 clr = pend = priv->read_reg(priv, C_CAN_INTPND2_REG);
745 obj = get_tx_echo_msg_obj(priv->tx_echo);
746 val = c_can_read_reg32(priv, C_CAN_TXRQST1_REG);
747 676
748 if (val & (1 << (obj - 1))) 677 while ((idx = ffs(pend))) {
749 break; 678 idx--;
750 679 pend &= ~(1 << idx);
751 can_get_echo_skb(dev, obj - C_CAN_MSG_OBJ_TX_FIRST); 680 obj = idx + C_CAN_MSG_OBJ_TX_FIRST;
752 bytes += priv->dlc[obj - C_CAN_MSG_OBJ_TX_FIRST]; 681 c_can_inval_tx_object(dev, IF_RX, obj);
682 can_get_echo_skb(dev, idx);
683 bytes += priv->dlc[idx];
753 pkts++; 684 pkts++;
754 c_can_inval_msg_object(dev, IF_TX, obj);
755 } 685 }
756 686
757 /* restart queue if wrap-up or if queue stalled on last pkt */ 687 /* Clear the bits in the tx_active mask */
758 if (((priv->tx_next & C_CAN_NEXT_MSG_OBJ_MASK) != 0) || 688 atomic_sub(clr, &priv->tx_active);
759 ((priv->tx_echo & C_CAN_NEXT_MSG_OBJ_MASK) == 0))
760 netif_wake_queue(dev);
761 689
762 spin_unlock_bh(&priv->xmit_lock); 690 if (clr & (1 << (C_CAN_MSG_OBJ_TX_NUM - 1)))
691 netif_wake_queue(dev);
763 692
764 if (pkts) { 693 if (pkts) {
765 stats->tx_bytes += bytes; 694 stats->tx_bytes += bytes;
@@ -800,18 +729,42 @@ static u32 c_can_adjust_pending(u32 pend)
800 return pend & ~((1 << lasts) - 1); 729 return pend & ~((1 << lasts) - 1);
801} 730}
802 731
732static inline void c_can_rx_object_get(struct net_device *dev,
733 struct c_can_priv *priv, u32 obj)
734{
735#ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING
736 if (obj < C_CAN_MSG_RX_LOW_LAST)
737 c_can_object_get(dev, IF_RX, obj, IF_COMM_RCV_LOW);
738 else
739#endif
740 c_can_object_get(dev, IF_RX, obj, priv->comm_rcv_high);
741}
742
743static inline void c_can_rx_finalize(struct net_device *dev,
744 struct c_can_priv *priv, u32 obj)
745{
746#ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING
747 if (obj < C_CAN_MSG_RX_LOW_LAST)
748 priv->rxmasked |= BIT(obj - 1);
749 else if (obj == C_CAN_MSG_RX_LOW_LAST) {
750 priv->rxmasked = 0;
751 /* activate all lower message objects */
752 c_can_activate_all_lower_rx_msg_obj(dev, IF_RX);
753 }
754#endif
755 if (priv->type != BOSCH_D_CAN)
756 c_can_object_get(dev, IF_RX, obj, IF_COMM_CLR_NEWDAT);
757}
758
803static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv, 759static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
804 u32 pend, int quota) 760 u32 pend, int quota)
805{ 761{
806 u32 pkts = 0, ctrl, obj, mcmd; 762 u32 pkts = 0, ctrl, obj;
807 763
808 while ((obj = ffs(pend)) && quota > 0) { 764 while ((obj = ffs(pend)) && quota > 0) {
809 pend &= ~BIT(obj - 1); 765 pend &= ~BIT(obj - 1);
810 766
811 mcmd = obj < C_CAN_MSG_RX_LOW_LAST ? 767 c_can_rx_object_get(dev, priv, obj);
812 IF_COMM_RCV_LOW : IF_COMM_RCV_HIGH;
813
814 c_can_object_get(dev, IF_RX, obj, mcmd);
815 ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_RX)); 768 ctrl = priv->read_reg(priv, C_CAN_IFACE(MSGCTRL_REG, IF_RX));
816 769
817 if (ctrl & IF_MCONT_MSGLST) { 770 if (ctrl & IF_MCONT_MSGLST) {
@@ -833,9 +786,7 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
833 /* read the data from the message object */ 786 /* read the data from the message object */
834 c_can_read_msg_object(dev, IF_RX, ctrl); 787 c_can_read_msg_object(dev, IF_RX, ctrl);
835 788
836 if (obj == C_CAN_MSG_RX_LOW_LAST) 789 c_can_rx_finalize(dev, priv, obj);
837 /* activate all lower message objects */
838 c_can_activate_all_lower_rx_msg_obj(dev, IF_RX, ctrl);
839 790
840 pkts++; 791 pkts++;
841 quota--; 792 quota--;
@@ -844,6 +795,16 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
844 return pkts; 795 return pkts;
845} 796}
846 797
798static inline u32 c_can_get_pending(struct c_can_priv *priv)
799{
800 u32 pend = priv->read_reg(priv, C_CAN_NEWDAT1_REG);
801
802#ifdef CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING
803 pend &= ~priv->rxmasked;
804#endif
805 return pend;
806}
807
847/* 808/*
848 * theory of operation: 809 * theory of operation:
849 * 810 *
@@ -853,6 +814,8 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
853 * has arrived. To work-around this issue, we keep two groups of message 814 * has arrived. To work-around this issue, we keep two groups of message
854 * objects whose partitioning is defined by C_CAN_MSG_OBJ_RX_SPLIT. 815 * objects whose partitioning is defined by C_CAN_MSG_OBJ_RX_SPLIT.
855 * 816 *
817 * If CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING = y
818 *
856 * To ensure in-order frame reception we use the following 819 * To ensure in-order frame reception we use the following
857 * approach while re-activating a message object to receive further 820 * approach while re-activating a message object to receive further
858 * frames: 821 * frames:
@@ -865,6 +828,14 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
865 * - if the current message object number is greater than 828 * - if the current message object number is greater than
866 * C_CAN_MSG_RX_LOW_LAST then clear the NEWDAT bit of 829 * C_CAN_MSG_RX_LOW_LAST then clear the NEWDAT bit of
867 * only this message object. 830 * only this message object.
831 *
832 * This can cause packet loss!
833 *
834 * If CONFIG_CAN_C_CAN_STRICT_FRAME_ORDERING = n
835 *
836 * We clear the newdat bit right away.
837 *
838 * This can result in packet reordering when the readout is slow.
868 */ 839 */
869static int c_can_do_rx_poll(struct net_device *dev, int quota) 840static int c_can_do_rx_poll(struct net_device *dev, int quota)
870{ 841{
@@ -880,7 +851,7 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
880 851
881 while (quota > 0) { 852 while (quota > 0) {
882 if (!pend) { 853 if (!pend) {
883 pend = priv->read_reg(priv, C_CAN_INTPND1_REG); 854 pend = c_can_get_pending(priv);
884 if (!pend) 855 if (!pend)
885 break; 856 break;
886 /* 857 /*
@@ -905,12 +876,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
905 return pkts; 876 return pkts;
906} 877}
907 878
908static inline int c_can_has_and_handle_berr(struct c_can_priv *priv)
909{
910 return (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) &&
911 (priv->current_status & LEC_UNUSED);
912}
913
914static int c_can_handle_state_change(struct net_device *dev, 879static int c_can_handle_state_change(struct net_device *dev,
915 enum c_can_bus_error_types error_type) 880 enum c_can_bus_error_types error_type)
916{ 881{
@@ -922,6 +887,26 @@ static int c_can_handle_state_change(struct net_device *dev,
922 struct sk_buff *skb; 887 struct sk_buff *skb;
923 struct can_berr_counter bec; 888 struct can_berr_counter bec;
924 889
890 switch (error_type) {
891 case C_CAN_ERROR_WARNING:
892 /* error warning state */
893 priv->can.can_stats.error_warning++;
894 priv->can.state = CAN_STATE_ERROR_WARNING;
895 break;
896 case C_CAN_ERROR_PASSIVE:
897 /* error passive state */
898 priv->can.can_stats.error_passive++;
899 priv->can.state = CAN_STATE_ERROR_PASSIVE;
900 break;
901 case C_CAN_BUS_OFF:
902 /* bus-off state */
903 priv->can.state = CAN_STATE_BUS_OFF;
904 can_bus_off(dev);
905 break;
906 default:
907 break;
908 }
909
925 /* propagate the error condition to the CAN stack */ 910 /* propagate the error condition to the CAN stack */
926 skb = alloc_can_err_skb(dev, &cf); 911 skb = alloc_can_err_skb(dev, &cf);
927 if (unlikely(!skb)) 912 if (unlikely(!skb))
@@ -935,8 +920,6 @@ static int c_can_handle_state_change(struct net_device *dev,
935 switch (error_type) { 920 switch (error_type) {
936 case C_CAN_ERROR_WARNING: 921 case C_CAN_ERROR_WARNING:
937 /* error warning state */ 922 /* error warning state */
938 priv->can.can_stats.error_warning++;
939 priv->can.state = CAN_STATE_ERROR_WARNING;
940 cf->can_id |= CAN_ERR_CRTL; 923 cf->can_id |= CAN_ERR_CRTL;
941 cf->data[1] = (bec.txerr > bec.rxerr) ? 924 cf->data[1] = (bec.txerr > bec.rxerr) ?
942 CAN_ERR_CRTL_TX_WARNING : 925 CAN_ERR_CRTL_TX_WARNING :
@@ -947,8 +930,6 @@ static int c_can_handle_state_change(struct net_device *dev,
947 break; 930 break;
948 case C_CAN_ERROR_PASSIVE: 931 case C_CAN_ERROR_PASSIVE:
949 /* error passive state */ 932 /* error passive state */
950 priv->can.can_stats.error_passive++;
951 priv->can.state = CAN_STATE_ERROR_PASSIVE;
952 cf->can_id |= CAN_ERR_CRTL; 933 cf->can_id |= CAN_ERR_CRTL;
953 if (rx_err_passive) 934 if (rx_err_passive)
954 cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE; 935 cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
@@ -960,22 +941,16 @@ static int c_can_handle_state_change(struct net_device *dev,
960 break; 941 break;
961 case C_CAN_BUS_OFF: 942 case C_CAN_BUS_OFF:
962 /* bus-off state */ 943 /* bus-off state */
963 priv->can.state = CAN_STATE_BUS_OFF;
964 cf->can_id |= CAN_ERR_BUSOFF; 944 cf->can_id |= CAN_ERR_BUSOFF;
965 /*
966 * disable all interrupts in bus-off mode to ensure that
967 * the CPU is not hogged down
968 */
969 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS);
970 can_bus_off(dev); 945 can_bus_off(dev);
971 break; 946 break;
972 default: 947 default:
973 break; 948 break;
974 } 949 }
975 950
976 netif_receive_skb(skb);
977 stats->rx_packets++; 951 stats->rx_packets++;
978 stats->rx_bytes += cf->can_dlc; 952 stats->rx_bytes += cf->can_dlc;
953 netif_receive_skb(skb);
979 954
980 return 1; 955 return 1;
981} 956}
@@ -996,6 +971,13 @@ static int c_can_handle_bus_err(struct net_device *dev,
996 if (lec_type == LEC_UNUSED || lec_type == LEC_NO_ERROR) 971 if (lec_type == LEC_UNUSED || lec_type == LEC_NO_ERROR)
997 return 0; 972 return 0;
998 973
974 if (!(priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING))
975 return 0;
976
977 /* common for all type of bus errors */
978 priv->can.can_stats.bus_error++;
979 stats->rx_errors++;
980
999 /* propagate the error condition to the CAN stack */ 981 /* propagate the error condition to the CAN stack */
1000 skb = alloc_can_err_skb(dev, &cf); 982 skb = alloc_can_err_skb(dev, &cf);
1001 if (unlikely(!skb)) 983 if (unlikely(!skb))
@@ -1005,10 +987,6 @@ static int c_can_handle_bus_err(struct net_device *dev,
1005 * check for 'last error code' which tells us the 987 * check for 'last error code' which tells us the
1006 * type of the last error to occur on the CAN bus 988 * type of the last error to occur on the CAN bus
1007 */ 989 */
1008
1009 /* common for all type of bus errors */
1010 priv->can.can_stats.bus_error++;
1011 stats->rx_errors++;
1012 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; 990 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
1013 cf->data[2] |= CAN_ERR_PROT_UNSPEC; 991 cf->data[2] |= CAN_ERR_PROT_UNSPEC;
1014 992
@@ -1043,95 +1021,64 @@ static int c_can_handle_bus_err(struct net_device *dev,
1043 break; 1021 break;
1044 } 1022 }
1045 1023
1046 /* set a `lec` value so that we can check for updates later */
1047 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
1048
1049 netif_receive_skb(skb);
1050 stats->rx_packets++; 1024 stats->rx_packets++;
1051 stats->rx_bytes += cf->can_dlc; 1025 stats->rx_bytes += cf->can_dlc;
1052 1026 netif_receive_skb(skb);
1053 return 1; 1027 return 1;
1054} 1028}
1055 1029
1056static int c_can_poll(struct napi_struct *napi, int quota) 1030static int c_can_poll(struct napi_struct *napi, int quota)
1057{ 1031{
1058 u16 irqstatus;
1059 int lec_type = 0;
1060 int work_done = 0;
1061 struct net_device *dev = napi->dev; 1032 struct net_device *dev = napi->dev;
1062 struct c_can_priv *priv = netdev_priv(dev); 1033 struct c_can_priv *priv = netdev_priv(dev);
1034 u16 curr, last = priv->last_status;
1035 int work_done = 0;
1063 1036
1064 irqstatus = priv->irqstatus; 1037 priv->last_status = curr = priv->read_reg(priv, C_CAN_STS_REG);
1065 if (!irqstatus) 1038 /* Ack status on C_CAN. D_CAN is self clearing */
1066 goto end; 1039 if (priv->type != BOSCH_D_CAN)
1040 priv->write_reg(priv, C_CAN_STS_REG, LEC_UNUSED);
1067 1041
1068 /* status events have the highest priority */ 1042 /* handle state changes */
1069 if (irqstatus == STATUS_INTERRUPT) { 1043 if ((curr & STATUS_EWARN) && (!(last & STATUS_EWARN))) {
1070 priv->current_status = priv->read_reg(priv, 1044 netdev_dbg(dev, "entered error warning state\n");
1071 C_CAN_STS_REG); 1045 work_done += c_can_handle_state_change(dev, C_CAN_ERROR_WARNING);
1072 1046 }
1073 /* handle Tx/Rx events */
1074 if (priv->current_status & STATUS_TXOK)
1075 priv->write_reg(priv, C_CAN_STS_REG,
1076 priv->current_status & ~STATUS_TXOK);
1077
1078 if (priv->current_status & STATUS_RXOK)
1079 priv->write_reg(priv, C_CAN_STS_REG,
1080 priv->current_status & ~STATUS_RXOK);
1081
1082 /* handle state changes */
1083 if ((priv->current_status & STATUS_EWARN) &&
1084 (!(priv->last_status & STATUS_EWARN))) {
1085 netdev_dbg(dev, "entered error warning state\n");
1086 work_done += c_can_handle_state_change(dev,
1087 C_CAN_ERROR_WARNING);
1088 }
1089 if ((priv->current_status & STATUS_EPASS) &&
1090 (!(priv->last_status & STATUS_EPASS))) {
1091 netdev_dbg(dev, "entered error passive state\n");
1092 work_done += c_can_handle_state_change(dev,
1093 C_CAN_ERROR_PASSIVE);
1094 }
1095 if ((priv->current_status & STATUS_BOFF) &&
1096 (!(priv->last_status & STATUS_BOFF))) {
1097 netdev_dbg(dev, "entered bus off state\n");
1098 work_done += c_can_handle_state_change(dev,
1099 C_CAN_BUS_OFF);
1100 }
1101 1047
1102 /* handle bus recovery events */ 1048 if ((curr & STATUS_EPASS) && (!(last & STATUS_EPASS))) {
1103 if ((!(priv->current_status & STATUS_BOFF)) && 1049 netdev_dbg(dev, "entered error passive state\n");
1104 (priv->last_status & STATUS_BOFF)) { 1050 work_done += c_can_handle_state_change(dev, C_CAN_ERROR_PASSIVE);
1105 netdev_dbg(dev, "left bus off state\n"); 1051 }
1106 priv->can.state = CAN_STATE_ERROR_ACTIVE; 1052
1107 } 1053 if ((curr & STATUS_BOFF) && (!(last & STATUS_BOFF))) {
1108 if ((!(priv->current_status & STATUS_EPASS)) && 1054 netdev_dbg(dev, "entered bus off state\n");
1109 (priv->last_status & STATUS_EPASS)) { 1055 work_done += c_can_handle_state_change(dev, C_CAN_BUS_OFF);
1110 netdev_dbg(dev, "left error passive state\n"); 1056 goto end;
1111 priv->can.state = CAN_STATE_ERROR_ACTIVE; 1057 }
1112 }
1113 1058
1114 priv->last_status = priv->current_status; 1059 /* handle bus recovery events */
1115 1060 if ((!(curr & STATUS_BOFF)) && (last & STATUS_BOFF)) {
1116 /* handle lec errors on the bus */ 1061 netdev_dbg(dev, "left bus off state\n");
1117 lec_type = c_can_has_and_handle_berr(priv); 1062 priv->can.state = CAN_STATE_ERROR_ACTIVE;
1118 if (lec_type) 1063 }
1119 work_done += c_can_handle_bus_err(dev, lec_type); 1064 if ((!(curr & STATUS_EPASS)) && (last & STATUS_EPASS)) {
1120 } else if ((irqstatus >= C_CAN_MSG_OBJ_RX_FIRST) && 1065 netdev_dbg(dev, "left error passive state\n");
1121 (irqstatus <= C_CAN_MSG_OBJ_RX_LAST)) { 1066 priv->can.state = CAN_STATE_ERROR_ACTIVE;
1122 /* handle events corresponding to receive message objects */
1123 work_done += c_can_do_rx_poll(dev, (quota - work_done));
1124 } else if ((irqstatus >= C_CAN_MSG_OBJ_TX_FIRST) &&
1125 (irqstatus <= C_CAN_MSG_OBJ_TX_LAST)) {
1126 /* handle events corresponding to transmit message objects */
1127 c_can_do_tx(dev);
1128 } 1067 }
1129 1068
1069 /* handle lec errors on the bus */
1070 work_done += c_can_handle_bus_err(dev, curr & LEC_MASK);
1071
1072 /* Handle Tx/Rx events. We do this unconditionally */
1073 work_done += c_can_do_rx_poll(dev, (quota - work_done));
1074 c_can_do_tx(dev);
1075
1130end: 1076end:
1131 if (work_done < quota) { 1077 if (work_done < quota) {
1132 napi_complete(napi); 1078 napi_complete(napi);
1133 /* enable all IRQs */ 1079 /* enable all IRQs if we are not in bus off state */
1134 c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS); 1080 if (priv->can.state != CAN_STATE_BUS_OFF)
1081 c_can_irq_control(priv, true);
1135 } 1082 }
1136 1083
1137 return work_done; 1084 return work_done;
@@ -1142,12 +1089,11 @@ static irqreturn_t c_can_isr(int irq, void *dev_id)
1142 struct net_device *dev = (struct net_device *)dev_id; 1089 struct net_device *dev = (struct net_device *)dev_id;
1143 struct c_can_priv *priv = netdev_priv(dev); 1090 struct c_can_priv *priv = netdev_priv(dev);
1144 1091
1145 priv->irqstatus = priv->read_reg(priv, C_CAN_INT_REG); 1092 if (!priv->read_reg(priv, C_CAN_INT_REG))
1146 if (!priv->irqstatus)
1147 return IRQ_NONE; 1093 return IRQ_NONE;
1148 1094
1149 /* disable all interrupts and schedule the NAPI */ 1095 /* disable all interrupts and schedule the NAPI */
1150 c_can_enable_all_interrupts(priv, DISABLE_ALL_INTERRUPTS); 1096 c_can_irq_control(priv, false);
1151 napi_schedule(&priv->napi); 1097 napi_schedule(&priv->napi);
1152 1098
1153 return IRQ_HANDLED; 1099 return IRQ_HANDLED;
@@ -1184,6 +1130,8 @@ static int c_can_open(struct net_device *dev)
1184 can_led_event(dev, CAN_LED_EVENT_OPEN); 1130 can_led_event(dev, CAN_LED_EVENT_OPEN);
1185 1131
1186 napi_enable(&priv->napi); 1132 napi_enable(&priv->napi);
1133 /* enable status change, error and module interrupts */
1134 c_can_irq_control(priv, true);
1187 netif_start_queue(dev); 1135 netif_start_queue(dev);
1188 1136
1189 return 0; 1137 return 0;
@@ -1226,7 +1174,6 @@ struct net_device *alloc_c_can_dev(void)
1226 return NULL; 1174 return NULL;
1227 1175
1228 priv = netdev_priv(dev); 1176 priv = netdev_priv(dev);
1229 spin_lock_init(&priv->xmit_lock);
1230 netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT); 1177 netif_napi_add(dev, &priv->napi, c_can_poll, C_CAN_NAPI_WEIGHT);
1231 1178
1232 priv->dev = dev; 1179 priv->dev = dev;
@@ -1281,6 +1228,7 @@ int c_can_power_up(struct net_device *dev)
1281 u32 val; 1228 u32 val;
1282 unsigned long time_out; 1229 unsigned long time_out;
1283 struct c_can_priv *priv = netdev_priv(dev); 1230 struct c_can_priv *priv = netdev_priv(dev);
1231 int ret;
1284 1232
1285 if (!(dev->flags & IFF_UP)) 1233 if (!(dev->flags & IFF_UP))
1286 return 0; 1234 return 0;
@@ -1307,7 +1255,11 @@ int c_can_power_up(struct net_device *dev)
1307 if (time_after(jiffies, time_out)) 1255 if (time_after(jiffies, time_out))
1308 return -ETIMEDOUT; 1256 return -ETIMEDOUT;
1309 1257
1310 return c_can_start(dev); 1258 ret = c_can_start(dev);
1259 if (!ret)
1260 c_can_irq_control(priv, true);
1261
1262 return ret;
1311} 1263}
1312EXPORT_SYMBOL_GPL(c_can_power_up); 1264EXPORT_SYMBOL_GPL(c_can_power_up);
1313#endif 1265#endif
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index faa8404162b3..c56f1b1c11ca 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -22,14 +22,6 @@
22#ifndef C_CAN_H 22#ifndef C_CAN_H
23#define C_CAN_H 23#define C_CAN_H
24 24
25/*
26 * IFx register masks:
27 * allow easy operation on 16-bit registers when the
28 * argument is 32-bit instead
29 */
30#define IFX_WRITE_LOW_16BIT(x) ((x) & 0xFFFF)
31#define IFX_WRITE_HIGH_16BIT(x) (((x) & 0xFFFF0000) >> 16)
32
33/* message object split */ 25/* message object split */
34#define C_CAN_NO_OF_OBJECTS 32 26#define C_CAN_NO_OF_OBJECTS 32
35#define C_CAN_MSG_OBJ_RX_NUM 16 27#define C_CAN_MSG_OBJ_RX_NUM 16
@@ -45,8 +37,6 @@
45 37
46#define C_CAN_MSG_OBJ_RX_SPLIT 9 38#define C_CAN_MSG_OBJ_RX_SPLIT 9
47#define C_CAN_MSG_RX_LOW_LAST (C_CAN_MSG_OBJ_RX_SPLIT - 1) 39#define C_CAN_MSG_RX_LOW_LAST (C_CAN_MSG_OBJ_RX_SPLIT - 1)
48
49#define C_CAN_NEXT_MSG_OBJ_MASK (C_CAN_MSG_OBJ_TX_NUM - 1)
50#define RECEIVE_OBJECT_BITS 0x0000ffff 40#define RECEIVE_OBJECT_BITS 0x0000ffff
51 41
52enum reg { 42enum reg {
@@ -183,23 +173,20 @@ struct c_can_priv {
183 struct napi_struct napi; 173 struct napi_struct napi;
184 struct net_device *dev; 174 struct net_device *dev;
185 struct device *device; 175 struct device *device;
186 spinlock_t xmit_lock; 176 atomic_t tx_active;
187 int tx_object; 177 unsigned long tx_dir;
188 int current_status;
189 int last_status; 178 int last_status;
190 u16 (*read_reg) (struct c_can_priv *priv, enum reg index); 179 u16 (*read_reg) (struct c_can_priv *priv, enum reg index);
191 void (*write_reg) (struct c_can_priv *priv, enum reg index, u16 val); 180 void (*write_reg) (struct c_can_priv *priv, enum reg index, u16 val);
192 void __iomem *base; 181 void __iomem *base;
193 const u16 *regs; 182 const u16 *regs;
194 unsigned long irq_flags; /* for request_irq() */
195 unsigned int tx_next;
196 unsigned int tx_echo;
197 void *priv; /* for board-specific data */ 183 void *priv; /* for board-specific data */
198 u16 irqstatus;
199 enum c_can_dev_id type; 184 enum c_can_dev_id type;
200 u32 __iomem *raminit_ctrlreg; 185 u32 __iomem *raminit_ctrlreg;
201 unsigned int instance; 186 int instance;
202 void (*raminit) (const struct c_can_priv *priv, bool enable); 187 void (*raminit) (const struct c_can_priv *priv, bool enable);
188 u32 comm_rcv_high;
189 u32 rxmasked;
203 u32 dlc[C_CAN_MSG_OBJ_TX_NUM]; 190 u32 dlc[C_CAN_MSG_OBJ_TX_NUM];
204}; 191};
205 192
diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c
index 7ab384f59e7e..58f71e1fcc4e 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -115,8 +115,11 @@ static int c_can_pci_probe(struct pci_dev *pdev,
115 goto out_disable_device; 115 goto out_disable_device;
116 } 116 }
117 117
118 pci_set_master(pdev); 118 ret = pci_enable_msi(pdev);
119 pci_enable_msi(pdev); 119 if (!ret) {
120 dev_info(&pdev->dev, "MSI enabled\n");
121 pci_set_master(pdev);
122 }
120 123
121 addr = pci_iomap(pdev, c_can_pci_data->bar, 124 addr = pci_iomap(pdev, c_can_pci_data->bar,
122 pci_resource_len(pdev, c_can_pci_data->bar)); 125 pci_resource_len(pdev, c_can_pci_data->bar));
@@ -164,6 +167,8 @@ static int c_can_pci_probe(struct pci_dev *pdev,
164 goto out_free_c_can; 167 goto out_free_c_can;
165 } 168 }
166 169
170 priv->type = c_can_pci_data->type;
171
167 /* Configure access to registers */ 172 /* Configure access to registers */
168 switch (c_can_pci_data->reg_align) { 173 switch (c_can_pci_data->reg_align) {
169 case C_CAN_REG_ALIGN_32: 174 case C_CAN_REG_ALIGN_32:
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index 806d92753427..1df0b322d1e4 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -222,7 +222,7 @@ static int c_can_plat_probe(struct platform_device *pdev)
222 222
223 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 223 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
224 priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res); 224 priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res);
225 if (IS_ERR(priv->raminit_ctrlreg) || (int)priv->instance < 0) 225 if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0)
226 dev_info(&pdev->dev, "control memory is not used for raminit\n"); 226 dev_info(&pdev->dev, "control memory is not used for raminit\n");
227 else 227 else
228 priv->raminit = c_can_hw_raminit; 228 priv->raminit = c_can_hw_raminit;
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index c7a260478749..e318e87e2bfc 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -256,7 +256,7 @@ static int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,
256 256
257 /* Check if the CAN device has bit-timing parameters */ 257 /* Check if the CAN device has bit-timing parameters */
258 if (!btc) 258 if (!btc)
259 return -ENOTSUPP; 259 return -EOPNOTSUPP;
260 260
261 /* 261 /*
262 * Depending on the given can_bittiming parameter structure the CAN 262 * Depending on the given can_bittiming parameter structure the CAN
diff --git a/drivers/net/can/sja1000/sja1000_isa.c b/drivers/net/can/sja1000/sja1000_isa.c
index df136a2516c4..014695d7e6a3 100644
--- a/drivers/net/can/sja1000/sja1000_isa.c
+++ b/drivers/net/can/sja1000/sja1000_isa.c
@@ -46,6 +46,7 @@ static int clk[MAXDEV];
46static unsigned char cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff}; 46static unsigned char cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
47static unsigned char ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff}; 47static unsigned char ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
48static int indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1}; 48static int indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
49static spinlock_t indirect_lock[MAXDEV]; /* lock for indirect access mode */
49 50
50module_param_array(port, ulong, NULL, S_IRUGO); 51module_param_array(port, ulong, NULL, S_IRUGO);
51MODULE_PARM_DESC(port, "I/O port number"); 52MODULE_PARM_DESC(port, "I/O port number");
@@ -101,19 +102,26 @@ static void sja1000_isa_port_write_reg(const struct sja1000_priv *priv,
101static u8 sja1000_isa_port_read_reg_indirect(const struct sja1000_priv *priv, 102static u8 sja1000_isa_port_read_reg_indirect(const struct sja1000_priv *priv,
102 int reg) 103 int reg)
103{ 104{
104 unsigned long base = (unsigned long)priv->reg_base; 105 unsigned long flags, base = (unsigned long)priv->reg_base;
106 u8 readval;
105 107
108 spin_lock_irqsave(&indirect_lock[priv->dev->dev_id], flags);
106 outb(reg, base); 109 outb(reg, base);
107 return inb(base + 1); 110 readval = inb(base + 1);
111 spin_unlock_irqrestore(&indirect_lock[priv->dev->dev_id], flags);
112
113 return readval;
108} 114}
109 115
110static void sja1000_isa_port_write_reg_indirect(const struct sja1000_priv *priv, 116static void sja1000_isa_port_write_reg_indirect(const struct sja1000_priv *priv,
111 int reg, u8 val) 117 int reg, u8 val)
112{ 118{
113 unsigned long base = (unsigned long)priv->reg_base; 119 unsigned long flags, base = (unsigned long)priv->reg_base;
114 120
121 spin_lock_irqsave(&indirect_lock[priv->dev->dev_id], flags);
115 outb(reg, base); 122 outb(reg, base);
116 outb(val, base + 1); 123 outb(val, base + 1);
124 spin_unlock_irqrestore(&indirect_lock[priv->dev->dev_id], flags);
117} 125}
118 126
119static int sja1000_isa_probe(struct platform_device *pdev) 127static int sja1000_isa_probe(struct platform_device *pdev)
@@ -169,6 +177,7 @@ static int sja1000_isa_probe(struct platform_device *pdev)
169 if (iosize == SJA1000_IOSIZE_INDIRECT) { 177 if (iosize == SJA1000_IOSIZE_INDIRECT) {
170 priv->read_reg = sja1000_isa_port_read_reg_indirect; 178 priv->read_reg = sja1000_isa_port_read_reg_indirect;
171 priv->write_reg = sja1000_isa_port_write_reg_indirect; 179 priv->write_reg = sja1000_isa_port_write_reg_indirect;
180 spin_lock_init(&indirect_lock[idx]);
172 } else { 181 } else {
173 priv->read_reg = sja1000_isa_port_read_reg; 182 priv->read_reg = sja1000_isa_port_read_reg;
174 priv->write_reg = sja1000_isa_port_write_reg; 183 priv->write_reg = sja1000_isa_port_write_reg;
@@ -198,6 +207,7 @@ static int sja1000_isa_probe(struct platform_device *pdev)
198 207
199 platform_set_drvdata(pdev, dev); 208 platform_set_drvdata(pdev, dev);
200 SET_NETDEV_DEV(dev, &pdev->dev); 209 SET_NETDEV_DEV(dev, &pdev->dev);
210 dev->dev_id = idx;
201 211
202 err = register_sja1000dev(dev); 212 err = register_sja1000dev(dev);
203 if (err) { 213 if (err) {
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index f5b16e0e3a12..dcf9196f6316 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -322,13 +322,13 @@ static void slcan_write_wakeup(struct tty_struct *tty)
322 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) 322 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
323 return; 323 return;
324 324
325 spin_lock(&sl->lock); 325 spin_lock_bh(&sl->lock);
326 if (sl->xleft <= 0) { 326 if (sl->xleft <= 0) {
327 /* Now serial buffer is almost free & we can start 327 /* Now serial buffer is almost free & we can start
328 * transmission of another packet */ 328 * transmission of another packet */
329 sl->dev->stats.tx_packets++; 329 sl->dev->stats.tx_packets++;
330 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 330 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
331 spin_unlock(&sl->lock); 331 spin_unlock_bh(&sl->lock);
332 netif_wake_queue(sl->dev); 332 netif_wake_queue(sl->dev);
333 return; 333 return;
334 } 334 }
@@ -336,7 +336,7 @@ static void slcan_write_wakeup(struct tty_struct *tty)
336 actual = tty->ops->write(tty, sl->xhead, sl->xleft); 336 actual = tty->ops->write(tty, sl->xhead, sl->xleft);
337 sl->xleft -= actual; 337 sl->xleft -= actual;
338 sl->xhead += actual; 338 sl->xhead += actual;
339 spin_unlock(&sl->lock); 339 spin_unlock_bh(&sl->lock);
340} 340}
341 341
342/* Send a can_frame to a TTY queue. */ 342/* Send a can_frame to a TTY queue. */
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index 39b26fe28d10..d7401017a3f1 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -35,6 +35,18 @@ source "drivers/net/ethernet/calxeda/Kconfig"
35source "drivers/net/ethernet/chelsio/Kconfig" 35source "drivers/net/ethernet/chelsio/Kconfig"
36source "drivers/net/ethernet/cirrus/Kconfig" 36source "drivers/net/ethernet/cirrus/Kconfig"
37source "drivers/net/ethernet/cisco/Kconfig" 37source "drivers/net/ethernet/cisco/Kconfig"
38
39config CX_ECAT
40 tristate "Beckhoff CX5020 EtherCAT master support"
41 depends on PCI
42 ---help---
43 Driver for EtherCAT master module located on CCAT FPGA
44 that can be found on Beckhoff CX5020, and possibly other of CX
45 Beckhoff CX series industrial PCs.
46
47 To compile this driver as a module, choose M here. The module
48 will be called ec_bhf.
49
38source "drivers/net/ethernet/davicom/Kconfig" 50source "drivers/net/ethernet/davicom/Kconfig"
39 51
40config DNET 52config DNET
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index 545d0b3b9cb4..35190e36c456 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_NET_CALXEDA_XGMAC) += calxeda/
21obj-$(CONFIG_NET_VENDOR_CHELSIO) += chelsio/ 21obj-$(CONFIG_NET_VENDOR_CHELSIO) += chelsio/
22obj-$(CONFIG_NET_VENDOR_CIRRUS) += cirrus/ 22obj-$(CONFIG_NET_VENDOR_CIRRUS) += cirrus/
23obj-$(CONFIG_NET_VENDOR_CISCO) += cisco/ 23obj-$(CONFIG_NET_VENDOR_CISCO) += cisco/
24obj-$(CONFIG_CX_ECAT) += ec_bhf.o
24obj-$(CONFIG_DM9000) += davicom/ 25obj-$(CONFIG_DM9000) += davicom/
25obj-$(CONFIG_DNET) += dnet.o 26obj-$(CONFIG_DNET) += dnet.o
26obj-$(CONFIG_NET_VENDOR_DEC) += dec/ 27obj-$(CONFIG_NET_VENDOR_DEC) += dec/
diff --git a/drivers/net/ethernet/altera/Kconfig b/drivers/net/ethernet/altera/Kconfig
index 80c1ab74a4b8..fdddba51473e 100644
--- a/drivers/net/ethernet/altera/Kconfig
+++ b/drivers/net/ethernet/altera/Kconfig
@@ -1,5 +1,6 @@
1config ALTERA_TSE 1config ALTERA_TSE
2 tristate "Altera Triple-Speed Ethernet MAC support" 2 tristate "Altera Triple-Speed Ethernet MAC support"
3 depends on HAS_DMA
3 select PHYLIB 4 select PHYLIB
4 ---help--- 5 ---help---
5 This driver supports the Altera Triple-Speed (TSE) Ethernet MAC. 6 This driver supports the Altera Triple-Speed (TSE) Ethernet MAC.
diff --git a/drivers/net/ethernet/altera/altera_msgdma.c b/drivers/net/ethernet/altera/altera_msgdma.c
index 0e38a03b1542..38c500f95b9e 100644
--- a/drivers/net/ethernet/altera/altera_msgdma.c
+++ b/drivers/net/ethernet/altera/altera_msgdma.c
@@ -18,6 +18,7 @@
18#include "altera_utils.h" 18#include "altera_utils.h"
19#include "altera_tse.h" 19#include "altera_tse.h"
20#include "altera_msgdmahw.h" 20#include "altera_msgdmahw.h"
21#include "altera_msgdma.h"
21 22
22/* No initialization work to do for MSGDMA */ 23/* No initialization work to do for MSGDMA */
23int msgdma_initialize(struct altera_tse_private *priv) 24int msgdma_initialize(struct altera_tse_private *priv)
@@ -29,6 +30,10 @@ void msgdma_uninitialize(struct altera_tse_private *priv)
29{ 30{
30} 31}
31 32
33void msgdma_start_rxdma(struct altera_tse_private *priv)
34{
35}
36
32void msgdma_reset(struct altera_tse_private *priv) 37void msgdma_reset(struct altera_tse_private *priv)
33{ 38{
34 int counter; 39 int counter;
@@ -151,7 +156,7 @@ u32 msgdma_tx_completions(struct altera_tse_private *priv)
151 156
152/* Put buffer to the mSGDMA RX FIFO 157/* Put buffer to the mSGDMA RX FIFO
153 */ 158 */
154int msgdma_add_rx_desc(struct altera_tse_private *priv, 159void msgdma_add_rx_desc(struct altera_tse_private *priv,
155 struct tse_buffer *rxbuffer) 160 struct tse_buffer *rxbuffer)
156{ 161{
157 struct msgdma_extended_desc *desc = priv->rx_dma_desc; 162 struct msgdma_extended_desc *desc = priv->rx_dma_desc;
@@ -172,7 +177,6 @@ int msgdma_add_rx_desc(struct altera_tse_private *priv,
172 iowrite32(0, &desc->burst_seq_num); 177 iowrite32(0, &desc->burst_seq_num);
173 iowrite32(0x00010001, &desc->stride); 178 iowrite32(0x00010001, &desc->stride);
174 iowrite32(control, &desc->control); 179 iowrite32(control, &desc->control);
175 return 1;
176} 180}
177 181
178/* status is returned on upper 16 bits, 182/* status is returned on upper 16 bits,
diff --git a/drivers/net/ethernet/altera/altera_msgdma.h b/drivers/net/ethernet/altera/altera_msgdma.h
index 7f0f5bf2bba2..42cf61c81057 100644
--- a/drivers/net/ethernet/altera/altera_msgdma.h
+++ b/drivers/net/ethernet/altera/altera_msgdma.h
@@ -25,10 +25,11 @@ void msgdma_disable_txirq(struct altera_tse_private *);
25void msgdma_clear_rxirq(struct altera_tse_private *); 25void msgdma_clear_rxirq(struct altera_tse_private *);
26void msgdma_clear_txirq(struct altera_tse_private *); 26void msgdma_clear_txirq(struct altera_tse_private *);
27u32 msgdma_tx_completions(struct altera_tse_private *); 27u32 msgdma_tx_completions(struct altera_tse_private *);
28int msgdma_add_rx_desc(struct altera_tse_private *, struct tse_buffer *); 28void msgdma_add_rx_desc(struct altera_tse_private *, struct tse_buffer *);
29int msgdma_tx_buffer(struct altera_tse_private *, struct tse_buffer *); 29int msgdma_tx_buffer(struct altera_tse_private *, struct tse_buffer *);
30u32 msgdma_rx_status(struct altera_tse_private *); 30u32 msgdma_rx_status(struct altera_tse_private *);
31int msgdma_initialize(struct altera_tse_private *); 31int msgdma_initialize(struct altera_tse_private *);
32void msgdma_uninitialize(struct altera_tse_private *); 32void msgdma_uninitialize(struct altera_tse_private *);
33void msgdma_start_rxdma(struct altera_tse_private *);
33 34
34#endif /* __ALTERA_MSGDMA_H__ */ 35#endif /* __ALTERA_MSGDMA_H__ */
diff --git a/drivers/net/ethernet/altera/altera_sgdma.c b/drivers/net/ethernet/altera/altera_sgdma.c
index 519f0f0bacf0..dbd40e15b5cc 100644
--- a/drivers/net/ethernet/altera/altera_sgdma.c
+++ b/drivers/net/ethernet/altera/altera_sgdma.c
@@ -20,15 +20,15 @@
20#include "altera_sgdmahw.h" 20#include "altera_sgdmahw.h"
21#include "altera_sgdma.h" 21#include "altera_sgdma.h"
22 22
23static void sgdma_descrip(struct sgdma_descrip *desc, 23static void sgdma_setup_descrip(struct sgdma_descrip *desc,
24 struct sgdma_descrip *ndesc, 24 struct sgdma_descrip *ndesc,
25 dma_addr_t ndesc_phys, 25 dma_addr_t ndesc_phys,
26 dma_addr_t raddr, 26 dma_addr_t raddr,
27 dma_addr_t waddr, 27 dma_addr_t waddr,
28 u16 length, 28 u16 length,
29 int generate_eop, 29 int generate_eop,
30 int rfixed, 30 int rfixed,
31 int wfixed); 31 int wfixed);
32 32
33static int sgdma_async_write(struct altera_tse_private *priv, 33static int sgdma_async_write(struct altera_tse_private *priv,
34 struct sgdma_descrip *desc); 34 struct sgdma_descrip *desc);
@@ -64,11 +64,15 @@ queue_rx_peekhead(struct altera_tse_private *priv);
64 64
65int sgdma_initialize(struct altera_tse_private *priv) 65int sgdma_initialize(struct altera_tse_private *priv)
66{ 66{
67 priv->txctrlreg = SGDMA_CTRLREG_ILASTD; 67 priv->txctrlreg = SGDMA_CTRLREG_ILASTD |
68 SGDMA_CTRLREG_INTEN;
68 69
69 priv->rxctrlreg = SGDMA_CTRLREG_IDESCRIP | 70 priv->rxctrlreg = SGDMA_CTRLREG_IDESCRIP |
71 SGDMA_CTRLREG_INTEN |
70 SGDMA_CTRLREG_ILASTD; 72 SGDMA_CTRLREG_ILASTD;
71 73
74 priv->sgdmadesclen = sizeof(struct sgdma_descrip);
75
72 INIT_LIST_HEAD(&priv->txlisthd); 76 INIT_LIST_HEAD(&priv->txlisthd);
73 INIT_LIST_HEAD(&priv->rxlisthd); 77 INIT_LIST_HEAD(&priv->rxlisthd);
74 78
@@ -93,6 +97,16 @@ int sgdma_initialize(struct altera_tse_private *priv)
93 return -EINVAL; 97 return -EINVAL;
94 } 98 }
95 99
100 /* Initialize descriptor memory to all 0's, sync memory to cache */
101 memset(priv->tx_dma_desc, 0, priv->txdescmem);
102 memset(priv->rx_dma_desc, 0, priv->rxdescmem);
103
104 dma_sync_single_for_device(priv->device, priv->txdescphys,
105 priv->txdescmem, DMA_TO_DEVICE);
106
107 dma_sync_single_for_device(priv->device, priv->rxdescphys,
108 priv->rxdescmem, DMA_TO_DEVICE);
109
96 return 0; 110 return 0;
97} 111}
98 112
@@ -130,26 +144,23 @@ void sgdma_reset(struct altera_tse_private *priv)
130 iowrite32(0, &prxsgdma->control); 144 iowrite32(0, &prxsgdma->control);
131} 145}
132 146
147/* For SGDMA, interrupts remain enabled after initially enabling,
148 * so no need to provide implementations for abstract enable
149 * and disable
150 */
151
133void sgdma_enable_rxirq(struct altera_tse_private *priv) 152void sgdma_enable_rxirq(struct altera_tse_private *priv)
134{ 153{
135 struct sgdma_csr *csr = priv->rx_dma_csr;
136 priv->rxctrlreg |= SGDMA_CTRLREG_INTEN;
137 tse_set_bit(&csr->control, SGDMA_CTRLREG_INTEN);
138} 154}
139 155
140void sgdma_enable_txirq(struct altera_tse_private *priv) 156void sgdma_enable_txirq(struct altera_tse_private *priv)
141{ 157{
142 struct sgdma_csr *csr = priv->tx_dma_csr;
143 priv->txctrlreg |= SGDMA_CTRLREG_INTEN;
144 tse_set_bit(&csr->control, SGDMA_CTRLREG_INTEN);
145} 158}
146 159
147/* for SGDMA, RX interrupts remain enabled after enabling */
148void sgdma_disable_rxirq(struct altera_tse_private *priv) 160void sgdma_disable_rxirq(struct altera_tse_private *priv)
149{ 161{
150} 162}
151 163
152/* for SGDMA, TX interrupts remain enabled after enabling */
153void sgdma_disable_txirq(struct altera_tse_private *priv) 164void sgdma_disable_txirq(struct altera_tse_private *priv)
154{ 165{
155} 166}
@@ -183,15 +194,15 @@ int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *buffer)
183 if (sgdma_txbusy(priv)) 194 if (sgdma_txbusy(priv))
184 return 0; 195 return 0;
185 196
186 sgdma_descrip(cdesc, /* current descriptor */ 197 sgdma_setup_descrip(cdesc, /* current descriptor */
187 ndesc, /* next descriptor */ 198 ndesc, /* next descriptor */
188 sgdma_txphysaddr(priv, ndesc), 199 sgdma_txphysaddr(priv, ndesc),
189 buffer->dma_addr, /* address of packet to xmit */ 200 buffer->dma_addr, /* address of packet to xmit */
190 0, /* write addr 0 for tx dma */ 201 0, /* write addr 0 for tx dma */
191 buffer->len, /* length of packet */ 202 buffer->len, /* length of packet */
192 SGDMA_CONTROL_EOP, /* Generate EOP */ 203 SGDMA_CONTROL_EOP, /* Generate EOP */
193 0, /* read fixed */ 204 0, /* read fixed */
194 SGDMA_CONTROL_WR_FIXED); /* Generate SOP */ 205 SGDMA_CONTROL_WR_FIXED); /* Generate SOP */
195 206
196 pktstx = sgdma_async_write(priv, cdesc); 207 pktstx = sgdma_async_write(priv, cdesc);
197 208
@@ -218,11 +229,15 @@ u32 sgdma_tx_completions(struct altera_tse_private *priv)
218 return ready; 229 return ready;
219} 230}
220 231
221int sgdma_add_rx_desc(struct altera_tse_private *priv, 232void sgdma_start_rxdma(struct altera_tse_private *priv)
222 struct tse_buffer *rxbuffer) 233{
234 sgdma_async_read(priv);
235}
236
237void sgdma_add_rx_desc(struct altera_tse_private *priv,
238 struct tse_buffer *rxbuffer)
223{ 239{
224 queue_rx(priv, rxbuffer); 240 queue_rx(priv, rxbuffer);
225 return sgdma_async_read(priv);
226} 241}
227 242
228/* status is returned on upper 16 bits, 243/* status is returned on upper 16 bits,
@@ -239,28 +254,52 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)
239 unsigned int pktstatus = 0; 254 unsigned int pktstatus = 0;
240 struct tse_buffer *rxbuffer = NULL; 255 struct tse_buffer *rxbuffer = NULL;
241 256
242 dma_sync_single_for_cpu(priv->device, 257 u32 sts = ioread32(&csr->status);
243 priv->rxdescphys,
244 priv->rxdescmem,
245 DMA_BIDIRECTIONAL);
246 258
247 desc = &base[0]; 259 desc = &base[0];
248 if ((ioread32(&csr->status) & SGDMA_STSREG_EOP) || 260 if (sts & SGDMA_STSREG_EOP) {
249 (desc->status & SGDMA_STATUS_EOP)) { 261 dma_sync_single_for_cpu(priv->device,
262 priv->rxdescphys,
263 priv->sgdmadesclen,
264 DMA_FROM_DEVICE);
265
250 pktlength = desc->bytes_xferred; 266 pktlength = desc->bytes_xferred;
251 pktstatus = desc->status & 0x3f; 267 pktstatus = desc->status & 0x3f;
252 rxstatus = pktstatus; 268 rxstatus = pktstatus;
253 rxstatus = rxstatus << 16; 269 rxstatus = rxstatus << 16;
254 rxstatus |= (pktlength & 0xffff); 270 rxstatus |= (pktlength & 0xffff);
255 271
256 desc->status = 0; 272 if (rxstatus) {
273 desc->status = 0;
257 274
258 rxbuffer = dequeue_rx(priv); 275 rxbuffer = dequeue_rx(priv);
259 if (rxbuffer == NULL) 276 if (rxbuffer == NULL)
260 netdev_err(priv->dev, 277 netdev_info(priv->dev,
261 "sgdma rx and rx queue empty!\n"); 278 "sgdma rx and rx queue empty!\n");
279
280 /* Clear control */
281 iowrite32(0, &csr->control);
282 /* clear status */
283 iowrite32(0xf, &csr->status);
262 284
263 /* kick the rx sgdma after reaping this descriptor */ 285 /* kick the rx sgdma after reaping this descriptor */
286 pktsrx = sgdma_async_read(priv);
287
288 } else {
289 /* If the SGDMA indicated an end of packet on recv,
290 * then it's expected that the rxstatus from the
291 * descriptor is non-zero - meaning a valid packet
292 * with a nonzero length, or an error has been
293 * indicated. if not, then all we can do is signal
294 * an error and return no packet received. Most likely
295 * there is a system design error, or an error in the
296 * underlying kernel (cache or cache management problem)
297 */
298 netdev_err(priv->dev,
299 "SGDMA RX Error Info: %x, %x, %x\n",
300 sts, desc->status, rxstatus);
301 }
302 } else if (sts == 0) {
264 pktsrx = sgdma_async_read(priv); 303 pktsrx = sgdma_async_read(priv);
265 } 304 }
266 305
@@ -269,15 +308,15 @@ u32 sgdma_rx_status(struct altera_tse_private *priv)
269 308
270 309
271/* Private functions */ 310/* Private functions */
272static void sgdma_descrip(struct sgdma_descrip *desc, 311static void sgdma_setup_descrip(struct sgdma_descrip *desc,
273 struct sgdma_descrip *ndesc, 312 struct sgdma_descrip *ndesc,
274 dma_addr_t ndesc_phys, 313 dma_addr_t ndesc_phys,
275 dma_addr_t raddr, 314 dma_addr_t raddr,
276 dma_addr_t waddr, 315 dma_addr_t waddr,
277 u16 length, 316 u16 length,
278 int generate_eop, 317 int generate_eop,
279 int rfixed, 318 int rfixed,
280 int wfixed) 319 int wfixed)
281{ 320{
282 /* Clear the next descriptor as not owned by hardware */ 321 /* Clear the next descriptor as not owned by hardware */
283 u32 ctrl = ndesc->control; 322 u32 ctrl = ndesc->control;
@@ -316,35 +355,29 @@ static int sgdma_async_read(struct altera_tse_private *priv)
316 struct sgdma_descrip *cdesc = &descbase[0]; 355 struct sgdma_descrip *cdesc = &descbase[0];
317 struct sgdma_descrip *ndesc = &descbase[1]; 356 struct sgdma_descrip *ndesc = &descbase[1];
318 357
319 unsigned int sts = ioread32(&csr->status);
320 struct tse_buffer *rxbuffer = NULL; 358 struct tse_buffer *rxbuffer = NULL;
321 359
322 if (!sgdma_rxbusy(priv)) { 360 if (!sgdma_rxbusy(priv)) {
323 rxbuffer = queue_rx_peekhead(priv); 361 rxbuffer = queue_rx_peekhead(priv);
324 if (rxbuffer == NULL) 362 if (rxbuffer == NULL) {
363 netdev_err(priv->dev, "no rx buffers available\n");
325 return 0; 364 return 0;
326 365 }
327 sgdma_descrip(cdesc, /* current descriptor */ 366
328 ndesc, /* next descriptor */ 367 sgdma_setup_descrip(cdesc, /* current descriptor */
329 sgdma_rxphysaddr(priv, ndesc), 368 ndesc, /* next descriptor */
330 0, /* read addr 0 for rx dma */ 369 sgdma_rxphysaddr(priv, ndesc),
331 rxbuffer->dma_addr, /* write addr for rx dma */ 370 0, /* read addr 0 for rx dma */
332 0, /* read 'til EOP */ 371 rxbuffer->dma_addr, /* write addr for rx dma */
333 0, /* EOP: NA for rx dma */ 372 0, /* read 'til EOP */
334 0, /* read fixed: NA for rx dma */ 373 0, /* EOP: NA for rx dma */
335 0); /* SOP: NA for rx DMA */ 374 0, /* read fixed: NA for rx dma */
336 375 0); /* SOP: NA for rx DMA */
337 /* clear control and status */
338 iowrite32(0, &csr->control);
339
340 /* If status available, clear those bits */
341 if (sts & 0xf)
342 iowrite32(0xf, &csr->status);
343 376
344 dma_sync_single_for_device(priv->device, 377 dma_sync_single_for_device(priv->device,
345 priv->rxdescphys, 378 priv->rxdescphys,
346 priv->rxdescmem, 379 priv->sgdmadesclen,
347 DMA_BIDIRECTIONAL); 380 DMA_TO_DEVICE);
348 381
349 iowrite32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)), 382 iowrite32(lower_32_bits(sgdma_rxphysaddr(priv, cdesc)),
350 &csr->next_descrip); 383 &csr->next_descrip);
@@ -371,7 +404,7 @@ static int sgdma_async_write(struct altera_tse_private *priv,
371 iowrite32(0x1f, &csr->status); 404 iowrite32(0x1f, &csr->status);
372 405
373 dma_sync_single_for_device(priv->device, priv->txdescphys, 406 dma_sync_single_for_device(priv->device, priv->txdescphys,
374 priv->txdescmem, DMA_TO_DEVICE); 407 priv->sgdmadesclen, DMA_TO_DEVICE);
375 408
376 iowrite32(lower_32_bits(sgdma_txphysaddr(priv, desc)), 409 iowrite32(lower_32_bits(sgdma_txphysaddr(priv, desc)),
377 &csr->next_descrip); 410 &csr->next_descrip);
diff --git a/drivers/net/ethernet/altera/altera_sgdma.h b/drivers/net/ethernet/altera/altera_sgdma.h
index 07d471729dc4..584977e29ef9 100644
--- a/drivers/net/ethernet/altera/altera_sgdma.h
+++ b/drivers/net/ethernet/altera/altera_sgdma.h
@@ -26,10 +26,11 @@ void sgdma_clear_rxirq(struct altera_tse_private *);
26void sgdma_clear_txirq(struct altera_tse_private *); 26void sgdma_clear_txirq(struct altera_tse_private *);
27int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *); 27int sgdma_tx_buffer(struct altera_tse_private *priv, struct tse_buffer *);
28u32 sgdma_tx_completions(struct altera_tse_private *); 28u32 sgdma_tx_completions(struct altera_tse_private *);
29int sgdma_add_rx_desc(struct altera_tse_private *priv, struct tse_buffer *); 29void sgdma_add_rx_desc(struct altera_tse_private *priv, struct tse_buffer *);
30void sgdma_status(struct altera_tse_private *); 30void sgdma_status(struct altera_tse_private *);
31u32 sgdma_rx_status(struct altera_tse_private *); 31u32 sgdma_rx_status(struct altera_tse_private *);
32int sgdma_initialize(struct altera_tse_private *); 32int sgdma_initialize(struct altera_tse_private *);
33void sgdma_uninitialize(struct altera_tse_private *); 33void sgdma_uninitialize(struct altera_tse_private *);
34void sgdma_start_rxdma(struct altera_tse_private *);
34 35
35#endif /* __ALTERA_SGDMA_H__ */ 36#endif /* __ALTERA_SGDMA_H__ */
diff --git a/drivers/net/ethernet/altera/altera_tse.h b/drivers/net/ethernet/altera/altera_tse.h
index 8feeed05de0e..465c4aabebbd 100644
--- a/drivers/net/ethernet/altera/altera_tse.h
+++ b/drivers/net/ethernet/altera/altera_tse.h
@@ -58,6 +58,8 @@
58/* MAC function configuration default settings */ 58/* MAC function configuration default settings */
59#define ALTERA_TSE_TX_IPG_LENGTH 12 59#define ALTERA_TSE_TX_IPG_LENGTH 12
60 60
61#define ALTERA_TSE_PAUSE_QUANTA 0xffff
62
61#define GET_BIT_VALUE(v, bit) (((v) >> (bit)) & 0x1) 63#define GET_BIT_VALUE(v, bit) (((v) >> (bit)) & 0x1)
62 64
63/* MAC Command_Config Register Bit Definitions 65/* MAC Command_Config Register Bit Definitions
@@ -390,10 +392,11 @@ struct altera_dmaops {
390 void (*clear_rxirq)(struct altera_tse_private *); 392 void (*clear_rxirq)(struct altera_tse_private *);
391 int (*tx_buffer)(struct altera_tse_private *, struct tse_buffer *); 393 int (*tx_buffer)(struct altera_tse_private *, struct tse_buffer *);
392 u32 (*tx_completions)(struct altera_tse_private *); 394 u32 (*tx_completions)(struct altera_tse_private *);
393 int (*add_rx_desc)(struct altera_tse_private *, struct tse_buffer *); 395 void (*add_rx_desc)(struct altera_tse_private *, struct tse_buffer *);
394 u32 (*get_rx_status)(struct altera_tse_private *); 396 u32 (*get_rx_status)(struct altera_tse_private *);
395 int (*init_dma)(struct altera_tse_private *); 397 int (*init_dma)(struct altera_tse_private *);
396 void (*uninit_dma)(struct altera_tse_private *); 398 void (*uninit_dma)(struct altera_tse_private *);
399 void (*start_rxdma)(struct altera_tse_private *);
397}; 400};
398 401
399/* This structure is private to each device. 402/* This structure is private to each device.
@@ -453,6 +456,7 @@ struct altera_tse_private {
453 u32 rxctrlreg; 456 u32 rxctrlreg;
454 dma_addr_t rxdescphys; 457 dma_addr_t rxdescphys;
455 dma_addr_t txdescphys; 458 dma_addr_t txdescphys;
459 size_t sgdmadesclen;
456 460
457 struct list_head txlisthd; 461 struct list_head txlisthd;
458 struct list_head rxlisthd; 462 struct list_head rxlisthd;
diff --git a/drivers/net/ethernet/altera/altera_tse_ethtool.c b/drivers/net/ethernet/altera/altera_tse_ethtool.c
index 319ca74f5e74..76133caffa78 100644
--- a/drivers/net/ethernet/altera/altera_tse_ethtool.c
+++ b/drivers/net/ethernet/altera/altera_tse_ethtool.c
@@ -77,7 +77,7 @@ static void tse_get_drvinfo(struct net_device *dev,
77 struct altera_tse_private *priv = netdev_priv(dev); 77 struct altera_tse_private *priv = netdev_priv(dev);
78 u32 rev = ioread32(&priv->mac_dev->megacore_revision); 78 u32 rev = ioread32(&priv->mac_dev->megacore_revision);
79 79
80 strcpy(info->driver, "Altera TSE MAC IP Driver"); 80 strcpy(info->driver, "altera_tse");
81 strcpy(info->version, "v8.0"); 81 strcpy(info->version, "v8.0");
82 snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "v%d.%d", 82 snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "v%d.%d",
83 rev & 0xFFFF, (rev & 0xFFFF0000) >> 16); 83 rev & 0xFFFF, (rev & 0xFFFF0000) >> 16);
@@ -185,6 +185,12 @@ static void tse_get_regs(struct net_device *dev, struct ethtool_regs *regs,
185 * how to do any special formatting of this data. 185 * how to do any special formatting of this data.
186 * This version number will need to change if and 186 * This version number will need to change if and
187 * when this register table is changed. 187 * when this register table is changed.
188 *
189 * version[31:0] = 1: Dump the first 128 TSE Registers
190 * Upper bits are all 0 by default
191 *
192 * Upper 16-bits will indicate feature presence for
193 * Ethtool register decoding in future version.
188 */ 194 */
189 195
190 regs->version = 1; 196 regs->version = 1;
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index c70a29e0b9f7..e44a4aeb9701 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -224,6 +224,7 @@ static int tse_init_rx_buffer(struct altera_tse_private *priv,
224 dev_kfree_skb_any(rxbuffer->skb); 224 dev_kfree_skb_any(rxbuffer->skb);
225 return -EINVAL; 225 return -EINVAL;
226 } 226 }
227 rxbuffer->dma_addr &= (dma_addr_t)~3;
227 rxbuffer->len = len; 228 rxbuffer->len = len;
228 return 0; 229 return 0;
229} 230}
@@ -425,9 +426,10 @@ static int tse_rx(struct altera_tse_private *priv, int limit)
425 priv->dev->stats.rx_bytes += pktlength; 426 priv->dev->stats.rx_bytes += pktlength;
426 427
427 entry = next_entry; 428 entry = next_entry;
429
430 tse_rx_refill(priv);
428 } 431 }
429 432
430 tse_rx_refill(priv);
431 return count; 433 return count;
432} 434}
433 435
@@ -520,7 +522,6 @@ static irqreturn_t altera_isr(int irq, void *dev_id)
520 struct altera_tse_private *priv; 522 struct altera_tse_private *priv;
521 unsigned long int flags; 523 unsigned long int flags;
522 524
523
524 if (unlikely(!dev)) { 525 if (unlikely(!dev)) {
525 pr_err("%s: invalid dev pointer\n", __func__); 526 pr_err("%s: invalid dev pointer\n", __func__);
526 return IRQ_NONE; 527 return IRQ_NONE;
@@ -868,13 +869,13 @@ static int init_mac(struct altera_tse_private *priv)
868 /* Disable RX/TX shift 16 for alignment of all received frames on 16-bit 869 /* Disable RX/TX shift 16 for alignment of all received frames on 16-bit
869 * start address 870 * start address
870 */ 871 */
871 tse_clear_bit(&mac->rx_cmd_stat, ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16); 872 tse_set_bit(&mac->rx_cmd_stat, ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16);
872 tse_clear_bit(&mac->tx_cmd_stat, ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16 | 873 tse_clear_bit(&mac->tx_cmd_stat, ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16 |
873 ALTERA_TSE_TX_CMD_STAT_OMIT_CRC); 874 ALTERA_TSE_TX_CMD_STAT_OMIT_CRC);
874 875
875 /* Set the MAC options */ 876 /* Set the MAC options */
876 cmd = ioread32(&mac->command_config); 877 cmd = ioread32(&mac->command_config);
877 cmd |= MAC_CMDCFG_PAD_EN; /* Padding Removal on Receive */ 878 cmd &= ~MAC_CMDCFG_PAD_EN; /* No padding Removal on Receive */
878 cmd &= ~MAC_CMDCFG_CRC_FWD; /* CRC Removal */ 879 cmd &= ~MAC_CMDCFG_CRC_FWD; /* CRC Removal */
879 cmd |= MAC_CMDCFG_RX_ERR_DISC; /* Automatically discard frames 880 cmd |= MAC_CMDCFG_RX_ERR_DISC; /* Automatically discard frames
880 * with CRC errors 881 * with CRC errors
@@ -882,8 +883,16 @@ static int init_mac(struct altera_tse_private *priv)
882 cmd |= MAC_CMDCFG_CNTL_FRM_ENA; 883 cmd |= MAC_CMDCFG_CNTL_FRM_ENA;
883 cmd &= ~MAC_CMDCFG_TX_ENA; 884 cmd &= ~MAC_CMDCFG_TX_ENA;
884 cmd &= ~MAC_CMDCFG_RX_ENA; 885 cmd &= ~MAC_CMDCFG_RX_ENA;
886
887 /* Default speed and duplex setting, full/100 */
888 cmd &= ~MAC_CMDCFG_HD_ENA;
889 cmd &= ~MAC_CMDCFG_ETH_SPEED;
890 cmd &= ~MAC_CMDCFG_ENA_10;
891
885 iowrite32(cmd, &mac->command_config); 892 iowrite32(cmd, &mac->command_config);
886 893
894 iowrite32(ALTERA_TSE_PAUSE_QUANTA, &mac->pause_quanta);
895
887 if (netif_msg_hw(priv)) 896 if (netif_msg_hw(priv))
888 dev_dbg(priv->device, 897 dev_dbg(priv->device,
889 "MAC post-initialization: CMD_CONFIG = 0x%08x\n", cmd); 898 "MAC post-initialization: CMD_CONFIG = 0x%08x\n", cmd);
@@ -1085,17 +1094,19 @@ static int tse_open(struct net_device *dev)
1085 1094
1086 spin_unlock_irqrestore(&priv->rxdma_irq_lock, flags); 1095 spin_unlock_irqrestore(&priv->rxdma_irq_lock, flags);
1087 1096
1088 /* Start MAC Rx/Tx */
1089 spin_lock(&priv->mac_cfg_lock);
1090 tse_set_mac(priv, true);
1091 spin_unlock(&priv->mac_cfg_lock);
1092
1093 if (priv->phydev) 1097 if (priv->phydev)
1094 phy_start(priv->phydev); 1098 phy_start(priv->phydev);
1095 1099
1096 napi_enable(&priv->napi); 1100 napi_enable(&priv->napi);
1097 netif_start_queue(dev); 1101 netif_start_queue(dev);
1098 1102
1103 priv->dmaops->start_rxdma(priv);
1104
1105 /* Start MAC Rx/Tx */
1106 spin_lock(&priv->mac_cfg_lock);
1107 tse_set_mac(priv, true);
1108 spin_unlock(&priv->mac_cfg_lock);
1109
1099 return 0; 1110 return 0;
1100 1111
1101tx_request_irq_error: 1112tx_request_irq_error:
@@ -1167,7 +1178,6 @@ static struct net_device_ops altera_tse_netdev_ops = {
1167 .ndo_validate_addr = eth_validate_addr, 1178 .ndo_validate_addr = eth_validate_addr,
1168}; 1179};
1169 1180
1170
1171static int request_and_map(struct platform_device *pdev, const char *name, 1181static int request_and_map(struct platform_device *pdev, const char *name,
1172 struct resource **res, void __iomem **ptr) 1182 struct resource **res, void __iomem **ptr)
1173{ 1183{
@@ -1235,7 +1245,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1235 /* Get the mapped address to the SGDMA descriptor memory */ 1245 /* Get the mapped address to the SGDMA descriptor memory */
1236 ret = request_and_map(pdev, "s1", &dma_res, &descmap); 1246 ret = request_and_map(pdev, "s1", &dma_res, &descmap);
1237 if (ret) 1247 if (ret)
1238 goto out_free; 1248 goto err_free_netdev;
1239 1249
1240 /* Start of that memory is for transmit descriptors */ 1250 /* Start of that memory is for transmit descriptors */
1241 priv->tx_dma_desc = descmap; 1251 priv->tx_dma_desc = descmap;
@@ -1254,24 +1264,24 @@ static int altera_tse_probe(struct platform_device *pdev)
1254 if (upper_32_bits(priv->rxdescmem_busaddr)) { 1264 if (upper_32_bits(priv->rxdescmem_busaddr)) {
1255 dev_dbg(priv->device, 1265 dev_dbg(priv->device,
1256 "SGDMA bus addresses greater than 32-bits\n"); 1266 "SGDMA bus addresses greater than 32-bits\n");
1257 goto out_free; 1267 goto err_free_netdev;
1258 } 1268 }
1259 if (upper_32_bits(priv->txdescmem_busaddr)) { 1269 if (upper_32_bits(priv->txdescmem_busaddr)) {
1260 dev_dbg(priv->device, 1270 dev_dbg(priv->device,
1261 "SGDMA bus addresses greater than 32-bits\n"); 1271 "SGDMA bus addresses greater than 32-bits\n");
1262 goto out_free; 1272 goto err_free_netdev;
1263 } 1273 }
1264 } else if (priv->dmaops && 1274 } else if (priv->dmaops &&
1265 priv->dmaops->altera_dtype == ALTERA_DTYPE_MSGDMA) { 1275 priv->dmaops->altera_dtype == ALTERA_DTYPE_MSGDMA) {
1266 ret = request_and_map(pdev, "rx_resp", &dma_res, 1276 ret = request_and_map(pdev, "rx_resp", &dma_res,
1267 &priv->rx_dma_resp); 1277 &priv->rx_dma_resp);
1268 if (ret) 1278 if (ret)
1269 goto out_free; 1279 goto err_free_netdev;
1270 1280
1271 ret = request_and_map(pdev, "tx_desc", &dma_res, 1281 ret = request_and_map(pdev, "tx_desc", &dma_res,
1272 &priv->tx_dma_desc); 1282 &priv->tx_dma_desc);
1273 if (ret) 1283 if (ret)
1274 goto out_free; 1284 goto err_free_netdev;
1275 1285
1276 priv->txdescmem = resource_size(dma_res); 1286 priv->txdescmem = resource_size(dma_res);
1277 priv->txdescmem_busaddr = dma_res->start; 1287 priv->txdescmem_busaddr = dma_res->start;
@@ -1279,13 +1289,13 @@ static int altera_tse_probe(struct platform_device *pdev)
1279 ret = request_and_map(pdev, "rx_desc", &dma_res, 1289 ret = request_and_map(pdev, "rx_desc", &dma_res,
1280 &priv->rx_dma_desc); 1290 &priv->rx_dma_desc);
1281 if (ret) 1291 if (ret)
1282 goto out_free; 1292 goto err_free_netdev;
1283 1293
1284 priv->rxdescmem = resource_size(dma_res); 1294 priv->rxdescmem = resource_size(dma_res);
1285 priv->rxdescmem_busaddr = dma_res->start; 1295 priv->rxdescmem_busaddr = dma_res->start;
1286 1296
1287 } else { 1297 } else {
1288 goto out_free; 1298 goto err_free_netdev;
1289 } 1299 }
1290 1300
1291 if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) 1301 if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask)))
@@ -1294,26 +1304,26 @@ static int altera_tse_probe(struct platform_device *pdev)
1294 else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) 1304 else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32)))
1295 dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32)); 1305 dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
1296 else 1306 else
1297 goto out_free; 1307 goto err_free_netdev;
1298 1308
1299 /* MAC address space */ 1309 /* MAC address space */
1300 ret = request_and_map(pdev, "control_port", &control_port, 1310 ret = request_and_map(pdev, "control_port", &control_port,
1301 (void __iomem **)&priv->mac_dev); 1311 (void __iomem **)&priv->mac_dev);
1302 if (ret) 1312 if (ret)
1303 goto out_free; 1313 goto err_free_netdev;
1304 1314
1305 /* xSGDMA Rx Dispatcher address space */ 1315 /* xSGDMA Rx Dispatcher address space */
1306 ret = request_and_map(pdev, "rx_csr", &dma_res, 1316 ret = request_and_map(pdev, "rx_csr", &dma_res,
1307 &priv->rx_dma_csr); 1317 &priv->rx_dma_csr);
1308 if (ret) 1318 if (ret)
1309 goto out_free; 1319 goto err_free_netdev;
1310 1320
1311 1321
1312 /* xSGDMA Tx Dispatcher address space */ 1322 /* xSGDMA Tx Dispatcher address space */
1313 ret = request_and_map(pdev, "tx_csr", &dma_res, 1323 ret = request_and_map(pdev, "tx_csr", &dma_res,
1314 &priv->tx_dma_csr); 1324 &priv->tx_dma_csr);
1315 if (ret) 1325 if (ret)
1316 goto out_free; 1326 goto err_free_netdev;
1317 1327
1318 1328
1319 /* Rx IRQ */ 1329 /* Rx IRQ */
@@ -1321,7 +1331,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1321 if (priv->rx_irq == -ENXIO) { 1331 if (priv->rx_irq == -ENXIO) {
1322 dev_err(&pdev->dev, "cannot obtain Rx IRQ\n"); 1332 dev_err(&pdev->dev, "cannot obtain Rx IRQ\n");
1323 ret = -ENXIO; 1333 ret = -ENXIO;
1324 goto out_free; 1334 goto err_free_netdev;
1325 } 1335 }
1326 1336
1327 /* Tx IRQ */ 1337 /* Tx IRQ */
@@ -1329,7 +1339,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1329 if (priv->tx_irq == -ENXIO) { 1339 if (priv->tx_irq == -ENXIO) {
1330 dev_err(&pdev->dev, "cannot obtain Tx IRQ\n"); 1340 dev_err(&pdev->dev, "cannot obtain Tx IRQ\n");
1331 ret = -ENXIO; 1341 ret = -ENXIO;
1332 goto out_free; 1342 goto err_free_netdev;
1333 } 1343 }
1334 1344
1335 /* get FIFO depths from device tree */ 1345 /* get FIFO depths from device tree */
@@ -1337,14 +1347,14 @@ static int altera_tse_probe(struct platform_device *pdev)
1337 &priv->rx_fifo_depth)) { 1347 &priv->rx_fifo_depth)) {
1338 dev_err(&pdev->dev, "cannot obtain rx-fifo-depth\n"); 1348 dev_err(&pdev->dev, "cannot obtain rx-fifo-depth\n");
1339 ret = -ENXIO; 1349 ret = -ENXIO;
1340 goto out_free; 1350 goto err_free_netdev;
1341 } 1351 }
1342 1352
1343 if (of_property_read_u32(pdev->dev.of_node, "tx-fifo-depth", 1353 if (of_property_read_u32(pdev->dev.of_node, "tx-fifo-depth",
1344 &priv->rx_fifo_depth)) { 1354 &priv->rx_fifo_depth)) {
1345 dev_err(&pdev->dev, "cannot obtain tx-fifo-depth\n"); 1355 dev_err(&pdev->dev, "cannot obtain tx-fifo-depth\n");
1346 ret = -ENXIO; 1356 ret = -ENXIO;
1347 goto out_free; 1357 goto err_free_netdev;
1348 } 1358 }
1349 1359
1350 /* get hash filter settings for this instance */ 1360 /* get hash filter settings for this instance */
@@ -1393,7 +1403,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1393 ((priv->phy_addr >= 0) && (priv->phy_addr < PHY_MAX_ADDR)))) { 1403 ((priv->phy_addr >= 0) && (priv->phy_addr < PHY_MAX_ADDR)))) {
1394 dev_err(&pdev->dev, "invalid phy-addr specified %d\n", 1404 dev_err(&pdev->dev, "invalid phy-addr specified %d\n",
1395 priv->phy_addr); 1405 priv->phy_addr);
1396 goto out_free; 1406 goto err_free_netdev;
1397 } 1407 }
1398 1408
1399 /* Create/attach to MDIO bus */ 1409 /* Create/attach to MDIO bus */
@@ -1401,7 +1411,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1401 atomic_add_return(1, &instance_count)); 1411 atomic_add_return(1, &instance_count));
1402 1412
1403 if (ret) 1413 if (ret)
1404 goto out_free; 1414 goto err_free_netdev;
1405 1415
1406 /* initialize netdev */ 1416 /* initialize netdev */
1407 ether_setup(ndev); 1417 ether_setup(ndev);
@@ -1438,7 +1448,7 @@ static int altera_tse_probe(struct platform_device *pdev)
1438 ret = register_netdev(ndev); 1448 ret = register_netdev(ndev);
1439 if (ret) { 1449 if (ret) {
1440 dev_err(&pdev->dev, "failed to register TSE net device\n"); 1450 dev_err(&pdev->dev, "failed to register TSE net device\n");
1441 goto out_free_mdio; 1451 goto err_register_netdev;
1442 } 1452 }
1443 1453
1444 platform_set_drvdata(pdev, ndev); 1454 platform_set_drvdata(pdev, ndev);
@@ -1455,13 +1465,16 @@ static int altera_tse_probe(struct platform_device *pdev)
1455 ret = init_phy(ndev); 1465 ret = init_phy(ndev);
1456 if (ret != 0) { 1466 if (ret != 0) {
1457 netdev_err(ndev, "Cannot attach to PHY (error: %d)\n", ret); 1467 netdev_err(ndev, "Cannot attach to PHY (error: %d)\n", ret);
1458 goto out_free_mdio; 1468 goto err_init_phy;
1459 } 1469 }
1460 return 0; 1470 return 0;
1461 1471
1462out_free_mdio: 1472err_init_phy:
1473 unregister_netdev(ndev);
1474err_register_netdev:
1475 netif_napi_del(&priv->napi);
1463 altera_tse_mdio_destroy(ndev); 1476 altera_tse_mdio_destroy(ndev);
1464out_free: 1477err_free_netdev:
1465 free_netdev(ndev); 1478 free_netdev(ndev);
1466 return ret; 1479 return ret;
1467} 1480}
@@ -1496,6 +1509,7 @@ struct altera_dmaops altera_dtype_sgdma = {
1496 .get_rx_status = sgdma_rx_status, 1509 .get_rx_status = sgdma_rx_status,
1497 .init_dma = sgdma_initialize, 1510 .init_dma = sgdma_initialize,
1498 .uninit_dma = sgdma_uninitialize, 1511 .uninit_dma = sgdma_uninitialize,
1512 .start_rxdma = sgdma_start_rxdma,
1499}; 1513};
1500 1514
1501struct altera_dmaops altera_dtype_msgdma = { 1515struct altera_dmaops altera_dtype_msgdma = {
@@ -1514,6 +1528,7 @@ struct altera_dmaops altera_dtype_msgdma = {
1514 .get_rx_status = msgdma_rx_status, 1528 .get_rx_status = msgdma_rx_status,
1515 .init_dma = msgdma_initialize, 1529 .init_dma = msgdma_initialize,
1516 .uninit_dma = msgdma_uninitialize, 1530 .uninit_dma = msgdma_uninitialize,
1531 .start_rxdma = msgdma_start_rxdma,
1517}; 1532};
1518 1533
1519static struct of_device_id altera_tse_ids[] = { 1534static struct of_device_id altera_tse_ids[] = {
diff --git a/drivers/net/ethernet/arc/emac.h b/drivers/net/ethernet/arc/emac.h
index 928fac6dd10a..53f85bf71526 100644
--- a/drivers/net/ethernet/arc/emac.h
+++ b/drivers/net/ethernet/arc/emac.h
@@ -11,6 +11,7 @@
11#include <linux/dma-mapping.h> 11#include <linux/dma-mapping.h>
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13#include <linux/phy.h> 13#include <linux/phy.h>
14#include <linux/clk.h>
14 15
15/* STATUS and ENABLE Register bit masks */ 16/* STATUS and ENABLE Register bit masks */
16#define TXINT_MASK (1<<0) /* Transmit interrupt */ 17#define TXINT_MASK (1<<0) /* Transmit interrupt */
@@ -131,6 +132,7 @@ struct arc_emac_priv {
131 struct mii_bus *bus; 132 struct mii_bus *bus;
132 133
133 void __iomem *regs; 134 void __iomem *regs;
135 struct clk *clk;
134 136
135 struct napi_struct napi; 137 struct napi_struct napi;
136 struct net_device_stats stats; 138 struct net_device_stats stats;
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 9f45782819ec..d647a7d115ac 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -649,13 +649,6 @@ static int arc_emac_probe(struct platform_device *pdev)
649 return -ENODEV; 649 return -ENODEV;
650 } 650 }
651 651
652 /* Get CPU clock frequency from device tree */
653 if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
654 &clock_frequency)) {
655 dev_err(&pdev->dev, "failed to retrieve <clock-frequency> from device tree\n");
656 return -EINVAL;
657 }
658
659 /* Get IRQ from device tree */ 652 /* Get IRQ from device tree */
660 irq = irq_of_parse_and_map(pdev->dev.of_node, 0); 653 irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
661 if (!irq) { 654 if (!irq) {
@@ -683,17 +676,36 @@ static int arc_emac_probe(struct platform_device *pdev)
683 priv->regs = devm_ioremap_resource(&pdev->dev, &res_regs); 676 priv->regs = devm_ioremap_resource(&pdev->dev, &res_regs);
684 if (IS_ERR(priv->regs)) { 677 if (IS_ERR(priv->regs)) {
685 err = PTR_ERR(priv->regs); 678 err = PTR_ERR(priv->regs);
686 goto out; 679 goto out_netdev;
687 } 680 }
688 dev_dbg(&pdev->dev, "Registers base address is 0x%p\n", priv->regs); 681 dev_dbg(&pdev->dev, "Registers base address is 0x%p\n", priv->regs);
689 682
683 priv->clk = of_clk_get(pdev->dev.of_node, 0);
684 if (IS_ERR(priv->clk)) {
685 /* Get CPU clock frequency from device tree */
686 if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
687 &clock_frequency)) {
688 dev_err(&pdev->dev, "failed to retrieve <clock-frequency> from device tree\n");
689 err = -EINVAL;
690 goto out_netdev;
691 }
692 } else {
693 err = clk_prepare_enable(priv->clk);
694 if (err) {
695 dev_err(&pdev->dev, "failed to enable clock\n");
696 goto out_clkget;
697 }
698
699 clock_frequency = clk_get_rate(priv->clk);
700 }
701
690 id = arc_reg_get(priv, R_ID); 702 id = arc_reg_get(priv, R_ID);
691 703
692 /* Check for EMAC revision 5 or 7, magic number */ 704 /* Check for EMAC revision 5 or 7, magic number */
693 if (!(id == 0x0005fd02 || id == 0x0007fd02)) { 705 if (!(id == 0x0005fd02 || id == 0x0007fd02)) {
694 dev_err(&pdev->dev, "ARC EMAC not detected, id=0x%x\n", id); 706 dev_err(&pdev->dev, "ARC EMAC not detected, id=0x%x\n", id);
695 err = -ENODEV; 707 err = -ENODEV;
696 goto out; 708 goto out_clken;
697 } 709 }
698 dev_info(&pdev->dev, "ARC EMAC detected with id: 0x%x\n", id); 710 dev_info(&pdev->dev, "ARC EMAC detected with id: 0x%x\n", id);
699 711
@@ -708,7 +720,7 @@ static int arc_emac_probe(struct platform_device *pdev)
708 ndev->name, ndev); 720 ndev->name, ndev);
709 if (err) { 721 if (err) {
710 dev_err(&pdev->dev, "could not allocate IRQ\n"); 722 dev_err(&pdev->dev, "could not allocate IRQ\n");
711 goto out; 723 goto out_clken;
712 } 724 }
713 725
714 /* Get MAC address from device tree */ 726 /* Get MAC address from device tree */
@@ -729,7 +741,7 @@ static int arc_emac_probe(struct platform_device *pdev)
729 if (!priv->rxbd) { 741 if (!priv->rxbd) {
730 dev_err(&pdev->dev, "failed to allocate data buffers\n"); 742 dev_err(&pdev->dev, "failed to allocate data buffers\n");
731 err = -ENOMEM; 743 err = -ENOMEM;
732 goto out; 744 goto out_clken;
733 } 745 }
734 746
735 priv->txbd = priv->rxbd + RX_BD_NUM; 747 priv->txbd = priv->rxbd + RX_BD_NUM;
@@ -741,7 +753,7 @@ static int arc_emac_probe(struct platform_device *pdev)
741 err = arc_mdio_probe(pdev, priv); 753 err = arc_mdio_probe(pdev, priv);
742 if (err) { 754 if (err) {
743 dev_err(&pdev->dev, "failed to probe MII bus\n"); 755 dev_err(&pdev->dev, "failed to probe MII bus\n");
744 goto out; 756 goto out_clken;
745 } 757 }
746 758
747 priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, 759 priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
@@ -749,7 +761,7 @@ static int arc_emac_probe(struct platform_device *pdev)
749 if (!priv->phy_dev) { 761 if (!priv->phy_dev) {
750 dev_err(&pdev->dev, "of_phy_connect() failed\n"); 762 dev_err(&pdev->dev, "of_phy_connect() failed\n");
751 err = -ENODEV; 763 err = -ENODEV;
752 goto out; 764 goto out_mdio;
753 } 765 }
754 766
755 dev_info(&pdev->dev, "connected to %s phy with id 0x%x\n", 767 dev_info(&pdev->dev, "connected to %s phy with id 0x%x\n",
@@ -759,14 +771,25 @@ static int arc_emac_probe(struct platform_device *pdev)
759 771
760 err = register_netdev(ndev); 772 err = register_netdev(ndev);
761 if (err) { 773 if (err) {
762 netif_napi_del(&priv->napi);
763 dev_err(&pdev->dev, "failed to register network device\n"); 774 dev_err(&pdev->dev, "failed to register network device\n");
764 goto out; 775 goto out_netif_api;
765 } 776 }
766 777
767 return 0; 778 return 0;
768 779
769out: 780out_netif_api:
781 netif_napi_del(&priv->napi);
782 phy_disconnect(priv->phy_dev);
783 priv->phy_dev = NULL;
784out_mdio:
785 arc_mdio_remove(priv);
786out_clken:
787 if (!IS_ERR(priv->clk))
788 clk_disable_unprepare(priv->clk);
789out_clkget:
790 if (!IS_ERR(priv->clk))
791 clk_put(priv->clk);
792out_netdev:
770 free_netdev(ndev); 793 free_netdev(ndev);
771 return err; 794 return err;
772} 795}
@@ -781,6 +804,12 @@ static int arc_emac_remove(struct platform_device *pdev)
781 arc_mdio_remove(priv); 804 arc_mdio_remove(priv);
782 unregister_netdev(ndev); 805 unregister_netdev(ndev);
783 netif_napi_del(&priv->napi); 806 netif_napi_del(&priv->napi);
807
808 if (!IS_ERR(priv->clk)) {
809 clk_disable_unprepare(priv->clk);
810 clk_put(priv->clk);
811 }
812
784 free_netdev(ndev); 813 free_netdev(ndev);
785 814
786 return 0; 815 return 0;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index a78edaccceee..3b0d43154e67 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10051,8 +10051,8 @@ static void bnx2x_prev_unload_close_mac(struct bnx2x *bp,
10051#define BCM_5710_UNDI_FW_MF_MAJOR (0x07) 10051#define BCM_5710_UNDI_FW_MF_MAJOR (0x07)
10052#define BCM_5710_UNDI_FW_MF_MINOR (0x08) 10052#define BCM_5710_UNDI_FW_MF_MINOR (0x08)
10053#define BCM_5710_UNDI_FW_MF_VERS (0x05) 10053#define BCM_5710_UNDI_FW_MF_VERS (0x05)
10054#define BNX2X_PREV_UNDI_MF_PORT(p) (0x1a150c + ((p) << 4)) 10054#define BNX2X_PREV_UNDI_MF_PORT(p) (BAR_TSTRORM_INTMEM + 0x150c + ((p) << 4))
10055#define BNX2X_PREV_UNDI_MF_FUNC(f) (0x1a184c + ((f) << 4)) 10055#define BNX2X_PREV_UNDI_MF_FUNC(f) (BAR_TSTRORM_INTMEM + 0x184c + ((f) << 4))
10056static bool bnx2x_prev_unload_undi_fw_supports_mf(struct bnx2x *bp) 10056static bool bnx2x_prev_unload_undi_fw_supports_mf(struct bnx2x *bp)
10057{ 10057{
10058 u8 major, minor, version; 10058 u8 major, minor, version;
@@ -10352,6 +10352,7 @@ static int bnx2x_prev_unload_common(struct bnx2x *bp)
10352 /* Reset should be performed after BRB is emptied */ 10352 /* Reset should be performed after BRB is emptied */
10353 if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_BRB1) { 10353 if (reset_reg & MISC_REGISTERS_RESET_REG_1_RST_BRB1) {
10354 u32 timer_count = 1000; 10354 u32 timer_count = 1000;
10355 bool need_write = true;
10355 10356
10356 /* Close the MAC Rx to prevent BRB from filling up */ 10357 /* Close the MAC Rx to prevent BRB from filling up */
10357 bnx2x_prev_unload_close_mac(bp, &mac_vals); 10358 bnx2x_prev_unload_close_mac(bp, &mac_vals);
@@ -10398,7 +10399,10 @@ static int bnx2x_prev_unload_common(struct bnx2x *bp)
10398 * cleaning methods - might be redundant but harmless. 10399 * cleaning methods - might be redundant but harmless.
10399 */ 10400 */
10400 if (bnx2x_prev_unload_undi_fw_supports_mf(bp)) { 10401 if (bnx2x_prev_unload_undi_fw_supports_mf(bp)) {
10401 bnx2x_prev_unload_undi_mf(bp); 10402 if (need_write) {
10403 bnx2x_prev_unload_undi_mf(bp);
10404 need_write = false;
10405 }
10402 } else if (prev_undi) { 10406 } else if (prev_undi) {
10403 /* If UNDI resides in memory, 10407 /* If UNDI resides in memory,
10404 * manually increment it 10408 * manually increment it
@@ -13233,6 +13237,8 @@ static void __bnx2x_remove(struct pci_dev *pdev,
13233 iounmap(bp->doorbells); 13237 iounmap(bp->doorbells);
13234 13238
13235 bnx2x_release_firmware(bp); 13239 bnx2x_release_firmware(bp);
13240 } else {
13241 bnx2x_vf_pci_dealloc(bp);
13236 } 13242 }
13237 bnx2x_free_mem_bp(bp); 13243 bnx2x_free_mem_bp(bp);
13238 13244
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 5c523b32db70..81cc2d9831c2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -427,7 +427,9 @@ static int bnx2x_vf_mac_vlan_config(struct bnx2x *bp,
427 if (filter->add && filter->type == BNX2X_VF_FILTER_VLAN && 427 if (filter->add && filter->type == BNX2X_VF_FILTER_VLAN &&
428 (atomic_read(&bnx2x_vfq(vf, qid, vlan_count)) >= 428 (atomic_read(&bnx2x_vfq(vf, qid, vlan_count)) >=
429 vf_vlan_rules_cnt(vf))) { 429 vf_vlan_rules_cnt(vf))) {
430 BNX2X_ERR("No credits for vlan\n"); 430 BNX2X_ERR("No credits for vlan [%d >= %d]\n",
431 atomic_read(&bnx2x_vfq(vf, qid, vlan_count)),
432 vf_vlan_rules_cnt(vf));
431 return -ENOMEM; 433 return -ENOMEM;
432 } 434 }
433 435
@@ -610,6 +612,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
610 } 612 }
611 613
612 /* add new mcasts */ 614 /* add new mcasts */
615 mcast.mcast_list_len = mc_num;
613 rc = bnx2x_config_mcast(bp, &mcast, BNX2X_MCAST_CMD_ADD); 616 rc = bnx2x_config_mcast(bp, &mcast, BNX2X_MCAST_CMD_ADD);
614 if (rc) 617 if (rc)
615 BNX2X_ERR("Faled to add multicasts\n"); 618 BNX2X_ERR("Faled to add multicasts\n");
@@ -837,6 +840,29 @@ int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid)
837 return 0; 840 return 0;
838} 841}
839 842
843static void bnx2x_iov_re_set_vlan_filters(struct bnx2x *bp,
844 struct bnx2x_virtf *vf,
845 int new)
846{
847 int num = vf_vlan_rules_cnt(vf);
848 int diff = new - num;
849 bool rc = true;
850
851 DP(BNX2X_MSG_IOV, "vf[%d] - %d vlan filter credits [previously %d]\n",
852 vf->abs_vfid, new, num);
853
854 if (diff > 0)
855 rc = bp->vlans_pool.get(&bp->vlans_pool, diff);
856 else if (diff < 0)
857 rc = bp->vlans_pool.put(&bp->vlans_pool, -diff);
858
859 if (rc)
860 vf_vlan_rules_cnt(vf) = new;
861 else
862 DP(BNX2X_MSG_IOV, "vf[%d] - Failed to configure vlan filter credits change\n",
863 vf->abs_vfid);
864}
865
840/* must be called after the number of PF queues and the number of VFs are 866/* must be called after the number of PF queues and the number of VFs are
841 * both known 867 * both known
842 */ 868 */
@@ -854,9 +880,11 @@ bnx2x_iov_static_resc(struct bnx2x *bp, struct bnx2x_virtf *vf)
854 resc->num_mac_filters = 1; 880 resc->num_mac_filters = 1;
855 881
856 /* divvy up vlan rules */ 882 /* divvy up vlan rules */
883 bnx2x_iov_re_set_vlan_filters(bp, vf, 0);
857 vlan_count = bp->vlans_pool.check(&bp->vlans_pool); 884 vlan_count = bp->vlans_pool.check(&bp->vlans_pool);
858 vlan_count = 1 << ilog2(vlan_count); 885 vlan_count = 1 << ilog2(vlan_count);
859 resc->num_vlan_filters = vlan_count / BNX2X_NR_VIRTFN(bp); 886 bnx2x_iov_re_set_vlan_filters(bp, vf,
887 vlan_count / BNX2X_NR_VIRTFN(bp));
860 888
861 /* no real limitation */ 889 /* no real limitation */
862 resc->num_mc_filters = 0; 890 resc->num_mc_filters = 0;
@@ -1478,10 +1506,6 @@ int bnx2x_iov_nic_init(struct bnx2x *bp)
1478 bnx2x_iov_static_resc(bp, vf); 1506 bnx2x_iov_static_resc(bp, vf);
1479 1507
1480 /* queues are initialized during VF-ACQUIRE */ 1508 /* queues are initialized during VF-ACQUIRE */
1481
1482 /* reserve the vf vlan credit */
1483 bp->vlans_pool.get(&bp->vlans_pool, vf_vlan_rules_cnt(vf));
1484
1485 vf->filter_state = 0; 1509 vf->filter_state = 0;
1486 vf->sp_cl_id = bnx2x_fp(bp, 0, cl_id); 1510 vf->sp_cl_id = bnx2x_fp(bp, 0, cl_id);
1487 1511
@@ -1912,11 +1936,12 @@ int bnx2x_vf_chk_avail_resc(struct bnx2x *bp, struct bnx2x_virtf *vf,
1912 u8 rxq_cnt = vf_rxq_count(vf) ? : bnx2x_vf_max_queue_cnt(bp, vf); 1936 u8 rxq_cnt = vf_rxq_count(vf) ? : bnx2x_vf_max_queue_cnt(bp, vf);
1913 u8 txq_cnt = vf_txq_count(vf) ? : bnx2x_vf_max_queue_cnt(bp, vf); 1937 u8 txq_cnt = vf_txq_count(vf) ? : bnx2x_vf_max_queue_cnt(bp, vf);
1914 1938
1939 /* Save a vlan filter for the Hypervisor */
1915 return ((req_resc->num_rxqs <= rxq_cnt) && 1940 return ((req_resc->num_rxqs <= rxq_cnt) &&
1916 (req_resc->num_txqs <= txq_cnt) && 1941 (req_resc->num_txqs <= txq_cnt) &&
1917 (req_resc->num_sbs <= vf_sb_count(vf)) && 1942 (req_resc->num_sbs <= vf_sb_count(vf)) &&
1918 (req_resc->num_mac_filters <= vf_mac_rules_cnt(vf)) && 1943 (req_resc->num_mac_filters <= vf_mac_rules_cnt(vf)) &&
1919 (req_resc->num_vlan_filters <= vf_vlan_rules_cnt(vf))); 1944 (req_resc->num_vlan_filters <= vf_vlan_rules_visible_cnt(vf)));
1920} 1945}
1921 1946
1922/* CORE VF API */ 1947/* CORE VF API */
@@ -1972,14 +1997,14 @@ int bnx2x_vf_acquire(struct bnx2x *bp, struct bnx2x_virtf *vf,
1972 vf_txq_count(vf) = resc->num_txqs ? : bnx2x_vf_max_queue_cnt(bp, vf); 1997 vf_txq_count(vf) = resc->num_txqs ? : bnx2x_vf_max_queue_cnt(bp, vf);
1973 if (resc->num_mac_filters) 1998 if (resc->num_mac_filters)
1974 vf_mac_rules_cnt(vf) = resc->num_mac_filters; 1999 vf_mac_rules_cnt(vf) = resc->num_mac_filters;
1975 if (resc->num_vlan_filters) 2000 /* Add an additional vlan filter credit for the hypervisor */
1976 vf_vlan_rules_cnt(vf) = resc->num_vlan_filters; 2001 bnx2x_iov_re_set_vlan_filters(bp, vf, resc->num_vlan_filters + 1);
1977 2002
1978 DP(BNX2X_MSG_IOV, 2003 DP(BNX2X_MSG_IOV,
1979 "Fulfilling vf request: sb count %d, tx_count %d, rx_count %d, mac_rules_count %d, vlan_rules_count %d\n", 2004 "Fulfilling vf request: sb count %d, tx_count %d, rx_count %d, mac_rules_count %d, vlan_rules_count %d\n",
1980 vf_sb_count(vf), vf_rxq_count(vf), 2005 vf_sb_count(vf), vf_rxq_count(vf),
1981 vf_txq_count(vf), vf_mac_rules_cnt(vf), 2006 vf_txq_count(vf), vf_mac_rules_cnt(vf),
1982 vf_vlan_rules_cnt(vf)); 2007 vf_vlan_rules_visible_cnt(vf));
1983 2008
1984 /* Initialize the queues */ 2009 /* Initialize the queues */
1985 if (!vf->vfqs) { 2010 if (!vf->vfqs) {
@@ -2896,6 +2921,14 @@ void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
2896 return bp->regview + PXP_VF_ADDR_DB_START; 2921 return bp->regview + PXP_VF_ADDR_DB_START;
2897} 2922}
2898 2923
2924void bnx2x_vf_pci_dealloc(struct bnx2x *bp)
2925{
2926 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping,
2927 sizeof(struct bnx2x_vf_mbx_msg));
2928 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping,
2929 sizeof(union pf_vf_bulletin));
2930}
2931
2899int bnx2x_vf_pci_alloc(struct bnx2x *bp) 2932int bnx2x_vf_pci_alloc(struct bnx2x *bp)
2900{ 2933{
2901 mutex_init(&bp->vf2pf_mutex); 2934 mutex_init(&bp->vf2pf_mutex);
@@ -2915,10 +2948,7 @@ int bnx2x_vf_pci_alloc(struct bnx2x *bp)
2915 return 0; 2948 return 0;
2916 2949
2917alloc_mem_err: 2950alloc_mem_err:
2918 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, 2951 bnx2x_vf_pci_dealloc(bp);
2919 sizeof(struct bnx2x_vf_mbx_msg));
2920 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping,
2921 sizeof(union pf_vf_bulletin));
2922 return -ENOMEM; 2952 return -ENOMEM;
2923} 2953}
2924 2954
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
index 8bf764570eef..6929adba52f9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
@@ -159,6 +159,8 @@ struct bnx2x_virtf {
159#define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters) 159#define vf_mac_rules_cnt(vf) ((vf)->alloc_resc.num_mac_filters)
160#define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters) 160#define vf_vlan_rules_cnt(vf) ((vf)->alloc_resc.num_vlan_filters)
161#define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters) 161#define vf_mc_rules_cnt(vf) ((vf)->alloc_resc.num_mc_filters)
162 /* Hide a single vlan filter credit for the hypervisor */
163#define vf_vlan_rules_visible_cnt(vf) (vf_vlan_rules_cnt(vf) - 1)
162 164
163 u8 sb_count; /* actual number of SBs */ 165 u8 sb_count; /* actual number of SBs */
164 u8 igu_base_id; /* base igu status block id */ 166 u8 igu_base_id; /* base igu status block id */
@@ -502,6 +504,7 @@ static inline int bnx2x_vf_ustorm_prods_offset(struct bnx2x *bp,
502enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp); 504enum sample_bulletin_result bnx2x_sample_bulletin(struct bnx2x *bp);
503void bnx2x_timer_sriov(struct bnx2x *bp); 505void bnx2x_timer_sriov(struct bnx2x *bp);
504void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp); 506void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp);
507void bnx2x_vf_pci_dealloc(struct bnx2x *bp);
505int bnx2x_vf_pci_alloc(struct bnx2x *bp); 508int bnx2x_vf_pci_alloc(struct bnx2x *bp);
506int bnx2x_enable_sriov(struct bnx2x *bp); 509int bnx2x_enable_sriov(struct bnx2x *bp);
507void bnx2x_disable_sriov(struct bnx2x *bp); 510void bnx2x_disable_sriov(struct bnx2x *bp);
@@ -568,6 +571,7 @@ static inline void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)
568 return NULL; 571 return NULL;
569} 572}
570 573
574static inline void bnx2x_vf_pci_dealloc(struct bnx2 *bp) {return 0; }
571static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; } 575static inline int bnx2x_vf_pci_alloc(struct bnx2x *bp) {return 0; }
572static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {} 576static inline void bnx2x_pf_set_vfs_vlan(struct bnx2x *bp) {}
573static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; } 577static inline int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs) {return 0; }
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 0622884596b2..0c067e8564dd 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -1163,7 +1163,7 @@ static void bnx2x_vf_mbx_acquire_resp(struct bnx2x *bp, struct bnx2x_virtf *vf,
1163 bnx2x_vf_max_queue_cnt(bp, vf); 1163 bnx2x_vf_max_queue_cnt(bp, vf);
1164 resc->num_sbs = vf_sb_count(vf); 1164 resc->num_sbs = vf_sb_count(vf);
1165 resc->num_mac_filters = vf_mac_rules_cnt(vf); 1165 resc->num_mac_filters = vf_mac_rules_cnt(vf);
1166 resc->num_vlan_filters = vf_vlan_rules_cnt(vf); 1166 resc->num_vlan_filters = vf_vlan_rules_visible_cnt(vf);
1167 resc->num_mc_filters = 0; 1167 resc->num_mc_filters = 0;
1168 1168
1169 if (status == PFVF_STATUS_SUCCESS) { 1169 if (status == PFVF_STATUS_SUCCESS) {
diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index 7e49c43b7af3..9e089d24466e 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -4,7 +4,7 @@
4 4
5config NET_CADENCE 5config NET_CADENCE
6 bool "Cadence devices" 6 bool "Cadence devices"
7 depends on HAS_IOMEM && (ARM || AVR32 || COMPILE_TEST) 7 depends on HAS_IOMEM && (ARM || AVR32 || MICROBLAZE || COMPILE_TEST)
8 default y 8 default y
9 ---help--- 9 ---help---
10 If you have a network (Ethernet) card belonging to this class, say Y. 10 If you have a network (Ethernet) card belonging to this class, say Y.
@@ -30,7 +30,7 @@ config ARM_AT91_ETHER
30 30
31config MACB 31config MACB
32 tristate "Cadence MACB/GEM support" 32 tristate "Cadence MACB/GEM support"
33 depends on HAS_DMA && (PLATFORM_AT32AP || ARCH_AT91 || ARCH_PICOXCELL || ARCH_ZYNQ || COMPILE_TEST) 33 depends on HAS_DMA && (PLATFORM_AT32AP || ARCH_AT91 || ARCH_PICOXCELL || ARCH_ZYNQ || MICROBLAZE || COMPILE_TEST)
34 select PHYLIB 34 select PHYLIB
35 ---help--- 35 ---help---
36 The Cadence MACB ethernet interface is found on many Atmel AT32 and 36 The Cadence MACB ethernet interface is found on many Atmel AT32 and
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index ca97005e24b4..e9daa072ebb4 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -599,25 +599,16 @@ static void gem_rx_refill(struct macb *bp)
599{ 599{
600 unsigned int entry; 600 unsigned int entry;
601 struct sk_buff *skb; 601 struct sk_buff *skb;
602 struct macb_dma_desc *desc;
603 dma_addr_t paddr; 602 dma_addr_t paddr;
604 603
605 while (CIRC_SPACE(bp->rx_prepared_head, bp->rx_tail, RX_RING_SIZE) > 0) { 604 while (CIRC_SPACE(bp->rx_prepared_head, bp->rx_tail, RX_RING_SIZE) > 0) {
606 u32 addr, ctrl;
607
608 entry = macb_rx_ring_wrap(bp->rx_prepared_head); 605 entry = macb_rx_ring_wrap(bp->rx_prepared_head);
609 desc = &bp->rx_ring[entry];
610 606
611 /* Make hw descriptor updates visible to CPU */ 607 /* Make hw descriptor updates visible to CPU */
612 rmb(); 608 rmb();
613 609
614 addr = desc->addr;
615 ctrl = desc->ctrl;
616 bp->rx_prepared_head++; 610 bp->rx_prepared_head++;
617 611
618 if ((addr & MACB_BIT(RX_USED)))
619 continue;
620
621 if (bp->rx_skbuff[entry] == NULL) { 612 if (bp->rx_skbuff[entry] == NULL) {
622 /* allocate sk_buff for this free entry in ring */ 613 /* allocate sk_buff for this free entry in ring */
623 skb = netdev_alloc_skb(bp->dev, bp->rx_buffer_size); 614 skb = netdev_alloc_skb(bp->dev, bp->rx_buffer_size);
@@ -698,7 +689,6 @@ static int gem_rx(struct macb *bp, int budget)
698 if (!(addr & MACB_BIT(RX_USED))) 689 if (!(addr & MACB_BIT(RX_USED)))
699 break; 690 break;
700 691
701 desc->addr &= ~MACB_BIT(RX_USED);
702 bp->rx_tail++; 692 bp->rx_tail++;
703 count++; 693 count++;
704 694
@@ -891,16 +881,15 @@ static int macb_poll(struct napi_struct *napi, int budget)
891 if (work_done < budget) { 881 if (work_done < budget) {
892 napi_complete(napi); 882 napi_complete(napi);
893 883
894 /*
895 * We've done what we can to clean the buffers. Make sure we
896 * get notified when new packets arrive.
897 */
898 macb_writel(bp, IER, MACB_RX_INT_FLAGS);
899
900 /* Packets received while interrupts were disabled */ 884 /* Packets received while interrupts were disabled */
901 status = macb_readl(bp, RSR); 885 status = macb_readl(bp, RSR);
902 if (unlikely(status)) 886 if (status) {
887 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
888 macb_writel(bp, ISR, MACB_BIT(RCOMP));
903 napi_reschedule(napi); 889 napi_reschedule(napi);
890 } else {
891 macb_writel(bp, IER, MACB_RX_INT_FLAGS);
892 }
904 } 893 }
905 894
906 /* TODO: Handle errors */ 895 /* TODO: Handle errors */
@@ -951,6 +940,10 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
951 if (unlikely(status & (MACB_TX_ERR_FLAGS))) { 940 if (unlikely(status & (MACB_TX_ERR_FLAGS))) {
952 macb_writel(bp, IDR, MACB_TX_INT_FLAGS); 941 macb_writel(bp, IDR, MACB_TX_INT_FLAGS);
953 schedule_work(&bp->tx_error_task); 942 schedule_work(&bp->tx_error_task);
943
944 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
945 macb_writel(bp, ISR, MACB_TX_ERR_FLAGS);
946
954 break; 947 break;
955 } 948 }
956 949
@@ -968,6 +961,9 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
968 bp->hw_stats.gem.rx_overruns++; 961 bp->hw_stats.gem.rx_overruns++;
969 else 962 else
970 bp->hw_stats.macb.rx_overruns++; 963 bp->hw_stats.macb.rx_overruns++;
964
965 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
966 macb_writel(bp, ISR, MACB_BIT(ISR_ROVR));
971 } 967 }
972 968
973 if (status & MACB_BIT(HRESP)) { 969 if (status & MACB_BIT(HRESP)) {
@@ -977,6 +973,9 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
977 * (work queue?) 973 * (work queue?)
978 */ 974 */
979 netdev_err(dev, "DMA bus error: HRESP not OK\n"); 975 netdev_err(dev, "DMA bus error: HRESP not OK\n");
976
977 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
978 macb_writel(bp, ISR, MACB_BIT(HRESP));
980 } 979 }
981 980
982 status = macb_readl(bp, ISR); 981 status = macb_readl(bp, ISR);
@@ -1113,7 +1112,7 @@ static void gem_free_rx_buffers(struct macb *bp)
1113 1112
1114 desc = &bp->rx_ring[i]; 1113 desc = &bp->rx_ring[i];
1115 addr = MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, desc->addr)); 1114 addr = MACB_BF(RX_WADDR, MACB_BFEXT(RX_WADDR, desc->addr));
1116 dma_unmap_single(&bp->pdev->dev, addr, skb->len, 1115 dma_unmap_single(&bp->pdev->dev, addr, bp->rx_buffer_size,
1117 DMA_FROM_DEVICE); 1116 DMA_FROM_DEVICE);
1118 dev_kfree_skb_any(skb); 1117 dev_kfree_skb_any(skb);
1119 skb = NULL; 1118 skb = NULL;
diff --git a/drivers/net/ethernet/chelsio/Kconfig b/drivers/net/ethernet/chelsio/Kconfig
index d40c994a4f6a..570222c33410 100644
--- a/drivers/net/ethernet/chelsio/Kconfig
+++ b/drivers/net/ethernet/chelsio/Kconfig
@@ -67,13 +67,13 @@ config CHELSIO_T3
67 will be called cxgb3. 67 will be called cxgb3.
68 68
69config CHELSIO_T4 69config CHELSIO_T4
70 tristate "Chelsio Communications T4 Ethernet support" 70 tristate "Chelsio Communications T4/T5 Ethernet support"
71 depends on PCI 71 depends on PCI
72 select FW_LOADER 72 select FW_LOADER
73 select MDIO 73 select MDIO
74 ---help--- 74 ---help---
75 This driver supports Chelsio T4-based gigabit and 10Gb Ethernet 75 This driver supports Chelsio T4 and T5 based gigabit, 10Gb Ethernet
76 adapters. 76 adapter and T5 based 40Gb Ethernet adapter.
77 77
78 For general information about Chelsio and our products, visit 78 For general information about Chelsio and our products, visit
79 our website at <http://www.chelsio.com>. 79 our website at <http://www.chelsio.com>.
@@ -87,11 +87,12 @@ config CHELSIO_T4
87 will be called cxgb4. 87 will be called cxgb4.
88 88
89config CHELSIO_T4VF 89config CHELSIO_T4VF
90 tristate "Chelsio Communications T4 Virtual Function Ethernet support" 90 tristate "Chelsio Communications T4/T5 Virtual Function Ethernet support"
91 depends on PCI 91 depends on PCI
92 ---help--- 92 ---help---
93 This driver supports Chelsio T4-based gigabit and 10Gb Ethernet 93 This driver supports Chelsio T4 and T5 based gigabit, 10Gb Ethernet
94 adapters with PCI-E SR-IOV Virtual Functions. 94 adapters and T5 based 40Gb Ethernet adapters with PCI-E SR-IOV Virtual
95 Functions.
95 96
96 For general information about Chelsio and our products, visit 97 For general information about Chelsio and our products, visit
97 our website at <http://www.chelsio.com>. 98 our website at <http://www.chelsio.com>.
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index bf5eb3310b0e..8efeed3325b5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5877,6 +5877,8 @@ static void print_port_info(const struct net_device *dev)
5877 spd = " 2.5 GT/s"; 5877 spd = " 2.5 GT/s";
5878 else if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_5_0GB) 5878 else if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_5_0GB)
5879 spd = " 5 GT/s"; 5879 spd = " 5 GT/s";
5880 else if (adap->params.pci.speed == PCI_EXP_LNKSTA_CLS_8_0GB)
5881 spd = " 8 GT/s";
5880 5882
5881 if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M) 5883 if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100M)
5882 bufp += sprintf(bufp, "100/"); 5884 bufp += sprintf(bufp, "100/");
diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c
new file mode 100644
index 000000000000..4884205e56ee
--- /dev/null
+++ b/drivers/net/ethernet/ec_bhf.c
@@ -0,0 +1,706 @@
1 /*
2 * drivers/net/ethernet/beckhoff/ec_bhf.c
3 *
4 * Copyright (C) 2014 Darek Marcinkiewicz <reksio@newterm.pl>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17/* This is a driver for EtherCAT master module present on CCAT FPGA.
18 * Those can be found on Bechhoff CX50xx industrial PCs.
19 */
20
21#if 0
22#define DEBUG
23#endif
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/moduleparam.h>
27#include <linux/pci.h>
28#include <linux/init.h>
29
30#include <linux/netdevice.h>
31#include <linux/etherdevice.h>
32#include <linux/ip.h>
33#include <linux/skbuff.h>
34#include <linux/hrtimer.h>
35#include <linux/interrupt.h>
36#include <linux/stat.h>
37
38#define TIMER_INTERVAL_NSEC 20000
39
40#define INFO_BLOCK_SIZE 0x10
41#define INFO_BLOCK_TYPE 0x0
42#define INFO_BLOCK_REV 0x2
43#define INFO_BLOCK_BLK_CNT 0x4
44#define INFO_BLOCK_TX_CHAN 0x4
45#define INFO_BLOCK_RX_CHAN 0x5
46#define INFO_BLOCK_OFFSET 0x8
47
48#define EC_MII_OFFSET 0x4
49#define EC_FIFO_OFFSET 0x8
50#define EC_MAC_OFFSET 0xc
51
52#define MAC_FRAME_ERR_CNT 0x0
53#define MAC_RX_ERR_CNT 0x1
54#define MAC_CRC_ERR_CNT 0x2
55#define MAC_LNK_LST_ERR_CNT 0x3
56#define MAC_TX_FRAME_CNT 0x10
57#define MAC_RX_FRAME_CNT 0x14
58#define MAC_TX_FIFO_LVL 0x20
59#define MAC_DROPPED_FRMS 0x28
60#define MAC_CONNECTED_CCAT_FLAG 0x78
61
62#define MII_MAC_ADDR 0x8
63#define MII_MAC_FILT_FLAG 0xe
64#define MII_LINK_STATUS 0xf
65
66#define FIFO_TX_REG 0x0
67#define FIFO_TX_RESET 0x8
68#define FIFO_RX_REG 0x10
69#define FIFO_RX_ADDR_VALID (1u << 31)
70#define FIFO_RX_RESET 0x18
71
72#define DMA_CHAN_OFFSET 0x1000
73#define DMA_CHAN_SIZE 0x8
74
75#define DMA_WINDOW_SIZE_MASK 0xfffffffc
76
77static struct pci_device_id ids[] = {
78 { PCI_DEVICE(0x15ec, 0x5000), },
79 { 0, }
80};
81MODULE_DEVICE_TABLE(pci, ids);
82
83struct rx_header {
84#define RXHDR_NEXT_ADDR_MASK 0xffffffu
85#define RXHDR_NEXT_VALID (1u << 31)
86 __le32 next;
87#define RXHDR_NEXT_RECV_FLAG 0x1
88 __le32 recv;
89#define RXHDR_LEN_MASK 0xfffu
90 __le16 len;
91 __le16 port;
92 __le32 reserved;
93 u8 timestamp[8];
94} __packed;
95
96#define PKT_PAYLOAD_SIZE 0x7e8
97struct rx_desc {
98 struct rx_header header;
99 u8 data[PKT_PAYLOAD_SIZE];
100} __packed;
101
102struct tx_header {
103 __le16 len;
104#define TX_HDR_PORT_0 0x1
105#define TX_HDR_PORT_1 0x2
106 u8 port;
107 u8 ts_enable;
108#define TX_HDR_SENT 0x1
109 __le32 sent;
110 u8 timestamp[8];
111} __packed;
112
113struct tx_desc {
114 struct tx_header header;
115 u8 data[PKT_PAYLOAD_SIZE];
116} __packed;
117
118#define FIFO_SIZE 64
119
120static long polling_frequency = TIMER_INTERVAL_NSEC;
121
122struct bhf_dma {
123 u8 *buf;
124 size_t len;
125 dma_addr_t buf_phys;
126
127 u8 *alloc;
128 size_t alloc_len;
129 dma_addr_t alloc_phys;
130};
131
132struct ec_bhf_priv {
133 struct net_device *net_dev;
134
135 struct pci_dev *dev;
136
137 void * __iomem io;
138 void * __iomem dma_io;
139
140 struct hrtimer hrtimer;
141
142 int tx_dma_chan;
143 int rx_dma_chan;
144 void * __iomem ec_io;
145 void * __iomem fifo_io;
146 void * __iomem mii_io;
147 void * __iomem mac_io;
148
149 struct bhf_dma rx_buf;
150 struct rx_desc *rx_descs;
151 int rx_dnext;
152 int rx_dcount;
153
154 struct bhf_dma tx_buf;
155 struct tx_desc *tx_descs;
156 int tx_dcount;
157 int tx_dnext;
158
159 u64 stat_rx_bytes;
160 u64 stat_tx_bytes;
161};
162
163#define PRIV_TO_DEV(priv) (&(priv)->dev->dev)
164
165#define ETHERCAT_MASTER_ID 0x14
166
167static void ec_bhf_print_status(struct ec_bhf_priv *priv)
168{
169 struct device *dev = PRIV_TO_DEV(priv);
170
171 dev_dbg(dev, "Frame error counter: %d\n",
172 ioread8(priv->mac_io + MAC_FRAME_ERR_CNT));
173 dev_dbg(dev, "RX error counter: %d\n",
174 ioread8(priv->mac_io + MAC_RX_ERR_CNT));
175 dev_dbg(dev, "CRC error counter: %d\n",
176 ioread8(priv->mac_io + MAC_CRC_ERR_CNT));
177 dev_dbg(dev, "TX frame counter: %d\n",
178 ioread32(priv->mac_io + MAC_TX_FRAME_CNT));
179 dev_dbg(dev, "RX frame counter: %d\n",
180 ioread32(priv->mac_io + MAC_RX_FRAME_CNT));
181 dev_dbg(dev, "TX fifo level: %d\n",
182 ioread8(priv->mac_io + MAC_TX_FIFO_LVL));
183 dev_dbg(dev, "Dropped frames: %d\n",
184 ioread8(priv->mac_io + MAC_DROPPED_FRMS));
185 dev_dbg(dev, "Connected with CCAT slot: %d\n",
186 ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG));
187 dev_dbg(dev, "Link status: %d\n",
188 ioread8(priv->mii_io + MII_LINK_STATUS));
189}
190
191static void ec_bhf_reset(struct ec_bhf_priv *priv)
192{
193 iowrite8(0, priv->mac_io + MAC_FRAME_ERR_CNT);
194 iowrite8(0, priv->mac_io + MAC_RX_ERR_CNT);
195 iowrite8(0, priv->mac_io + MAC_CRC_ERR_CNT);
196 iowrite8(0, priv->mac_io + MAC_LNK_LST_ERR_CNT);
197 iowrite32(0, priv->mac_io + MAC_TX_FRAME_CNT);
198 iowrite32(0, priv->mac_io + MAC_RX_FRAME_CNT);
199 iowrite8(0, priv->mac_io + MAC_DROPPED_FRMS);
200
201 iowrite8(0, priv->fifo_io + FIFO_TX_RESET);
202 iowrite8(0, priv->fifo_io + FIFO_RX_RESET);
203
204 iowrite8(0, priv->mac_io + MAC_TX_FIFO_LVL);
205}
206
207static void ec_bhf_send_packet(struct ec_bhf_priv *priv, struct tx_desc *desc)
208{
209 u32 len = le16_to_cpu(desc->header.len) + sizeof(desc->header);
210 u32 addr = (u8 *)desc - priv->tx_buf.buf;
211
212 iowrite32((ALIGN(len, 8) << 24) | addr, priv->fifo_io + FIFO_TX_REG);
213
214 dev_dbg(PRIV_TO_DEV(priv), "Done sending packet\n");
215}
216
217static int ec_bhf_desc_sent(struct tx_desc *desc)
218{
219 return le32_to_cpu(desc->header.sent) & TX_HDR_SENT;
220}
221
222static void ec_bhf_process_tx(struct ec_bhf_priv *priv)
223{
224 if (unlikely(netif_queue_stopped(priv->net_dev))) {
225 /* Make sure that we perceive changes to tx_dnext. */
226 smp_rmb();
227
228 if (ec_bhf_desc_sent(&priv->tx_descs[priv->tx_dnext]))
229 netif_wake_queue(priv->net_dev);
230 }
231}
232
233static int ec_bhf_pkt_received(struct rx_desc *desc)
234{
235 return le32_to_cpu(desc->header.recv) & RXHDR_NEXT_RECV_FLAG;
236}
237
238static void ec_bhf_add_rx_desc(struct ec_bhf_priv *priv, struct rx_desc *desc)
239{
240 iowrite32(FIFO_RX_ADDR_VALID | ((u8 *)(desc) - priv->rx_buf.buf),
241 priv->fifo_io + FIFO_RX_REG);
242}
243
244static void ec_bhf_process_rx(struct ec_bhf_priv *priv)
245{
246 struct rx_desc *desc = &priv->rx_descs[priv->rx_dnext];
247 struct device *dev = PRIV_TO_DEV(priv);
248
249 while (ec_bhf_pkt_received(desc)) {
250 int pkt_size = (le16_to_cpu(desc->header.len) &
251 RXHDR_LEN_MASK) - sizeof(struct rx_header) - 4;
252 u8 *data = desc->data;
253 struct sk_buff *skb;
254
255 skb = netdev_alloc_skb_ip_align(priv->net_dev, pkt_size);
256 dev_dbg(dev, "Received packet, size: %d\n", pkt_size);
257
258 if (skb) {
259 memcpy(skb_put(skb, pkt_size), data, pkt_size);
260 skb->protocol = eth_type_trans(skb, priv->net_dev);
261 dev_dbg(dev, "Protocol type: %x\n", skb->protocol);
262
263 priv->stat_rx_bytes += pkt_size;
264
265 netif_rx(skb);
266 } else {
267 dev_err_ratelimited(dev,
268 "Couldn't allocate a skb_buff for a packet of size %u\n",
269 pkt_size);
270 }
271
272 desc->header.recv = 0;
273
274 ec_bhf_add_rx_desc(priv, desc);
275
276 priv->rx_dnext = (priv->rx_dnext + 1) % priv->rx_dcount;
277 desc = &priv->rx_descs[priv->rx_dnext];
278 }
279
280}
281
282static enum hrtimer_restart ec_bhf_timer_fun(struct hrtimer *timer)
283{
284 struct ec_bhf_priv *priv = container_of(timer, struct ec_bhf_priv,
285 hrtimer);
286 ec_bhf_process_rx(priv);
287 ec_bhf_process_tx(priv);
288
289 if (!netif_running(priv->net_dev))
290 return HRTIMER_NORESTART;
291
292 hrtimer_forward_now(timer, ktime_set(0, polling_frequency));
293 return HRTIMER_RESTART;
294}
295
296static int ec_bhf_setup_offsets(struct ec_bhf_priv *priv)
297{
298 struct device *dev = PRIV_TO_DEV(priv);
299 unsigned block_count, i;
300 void * __iomem ec_info;
301
302 dev_dbg(dev, "Info block:\n");
303 dev_dbg(dev, "Type of function: %x\n", (unsigned)ioread16(priv->io));
304 dev_dbg(dev, "Revision of function: %x\n",
305 (unsigned)ioread16(priv->io + INFO_BLOCK_REV));
306
307 block_count = ioread8(priv->io + INFO_BLOCK_BLK_CNT);
308 dev_dbg(dev, "Number of function blocks: %x\n", block_count);
309
310 for (i = 0; i < block_count; i++) {
311 u16 type = ioread16(priv->io + i * INFO_BLOCK_SIZE +
312 INFO_BLOCK_TYPE);
313 if (type == ETHERCAT_MASTER_ID)
314 break;
315 }
316 if (i == block_count) {
317 dev_err(dev, "EtherCAT master with DMA block not found\n");
318 return -ENODEV;
319 }
320 dev_dbg(dev, "EtherCAT master with DMA block found at pos: %d\n", i);
321
322 ec_info = priv->io + i * INFO_BLOCK_SIZE;
323 dev_dbg(dev, "EtherCAT master revision: %d\n",
324 ioread16(ec_info + INFO_BLOCK_REV));
325
326 priv->tx_dma_chan = ioread8(ec_info + INFO_BLOCK_TX_CHAN);
327 dev_dbg(dev, "EtherCAT master tx dma channel: %d\n",
328 priv->tx_dma_chan);
329
330 priv->rx_dma_chan = ioread8(ec_info + INFO_BLOCK_RX_CHAN);
331 dev_dbg(dev, "EtherCAT master rx dma channel: %d\n",
332 priv->rx_dma_chan);
333
334 priv->ec_io = priv->io + ioread32(ec_info + INFO_BLOCK_OFFSET);
335 priv->mii_io = priv->ec_io + ioread32(priv->ec_io + EC_MII_OFFSET);
336 priv->fifo_io = priv->ec_io + ioread32(priv->ec_io + EC_FIFO_OFFSET);
337 priv->mac_io = priv->ec_io + ioread32(priv->ec_io + EC_MAC_OFFSET);
338
339 dev_dbg(dev,
340 "EtherCAT block addres: %p, fifo address: %p, mii address: %p, mac address: %p\n",
341 priv->ec_io, priv->fifo_io, priv->mii_io, priv->mac_io);
342
343 return 0;
344}
345
346static netdev_tx_t ec_bhf_start_xmit(struct sk_buff *skb,
347 struct net_device *net_dev)
348{
349 struct ec_bhf_priv *priv = netdev_priv(net_dev);
350 struct tx_desc *desc;
351 unsigned len;
352
353 dev_dbg(PRIV_TO_DEV(priv), "Starting xmit\n");
354
355 desc = &priv->tx_descs[priv->tx_dnext];
356
357 skb_copy_and_csum_dev(skb, desc->data);
358 len = skb->len;
359
360 memset(&desc->header, 0, sizeof(desc->header));
361 desc->header.len = cpu_to_le16(len);
362 desc->header.port = TX_HDR_PORT_0;
363
364 ec_bhf_send_packet(priv, desc);
365
366 priv->tx_dnext = (priv->tx_dnext + 1) % priv->tx_dcount;
367
368 if (!ec_bhf_desc_sent(&priv->tx_descs[priv->tx_dnext])) {
369 /* Make sure that update updates to tx_dnext are perceived
370 * by timer routine.
371 */
372 smp_wmb();
373
374 netif_stop_queue(net_dev);
375
376 dev_dbg(PRIV_TO_DEV(priv), "Stopping netif queue\n");
377 ec_bhf_print_status(priv);
378 }
379
380 priv->stat_tx_bytes += len;
381
382 dev_kfree_skb(skb);
383
384 return NETDEV_TX_OK;
385}
386
387static int ec_bhf_alloc_dma_mem(struct ec_bhf_priv *priv,
388 struct bhf_dma *buf,
389 int channel,
390 int size)
391{
392 int offset = channel * DMA_CHAN_SIZE + DMA_CHAN_OFFSET;
393 struct device *dev = PRIV_TO_DEV(priv);
394 u32 mask;
395
396 iowrite32(0xffffffff, priv->dma_io + offset);
397
398 mask = ioread32(priv->dma_io + offset);
399 mask &= DMA_WINDOW_SIZE_MASK;
400 dev_dbg(dev, "Read mask %x for channel %d\n", mask, channel);
401
402 /* We want to allocate a chunk of memory that is:
403 * - aligned to the mask we just read
404 * - is of size 2^mask bytes (at most)
405 * In order to ensure that we will allocate buffer of
406 * 2 * 2^mask bytes.
407 */
408 buf->len = min_t(int, ~mask + 1, size);
409 buf->alloc_len = 2 * buf->len;
410
411 dev_dbg(dev, "Allocating %d bytes for channel %d",
412 (int)buf->alloc_len, channel);
413 buf->alloc = dma_alloc_coherent(dev, buf->alloc_len, &buf->alloc_phys,
414 GFP_KERNEL);
415 if (buf->alloc == NULL) {
416 dev_info(dev, "Failed to allocate buffer\n");
417 return -ENOMEM;
418 }
419
420 buf->buf_phys = (buf->alloc_phys + buf->len) & mask;
421 buf->buf = buf->alloc + (buf->buf_phys - buf->alloc_phys);
422
423 iowrite32(0, priv->dma_io + offset + 4);
424 iowrite32(buf->buf_phys, priv->dma_io + offset);
425 dev_dbg(dev, "Buffer: %x and read from dev: %x",
426 (unsigned)buf->buf_phys, ioread32(priv->dma_io + offset));
427
428 return 0;
429}
430
431static void ec_bhf_setup_tx_descs(struct ec_bhf_priv *priv)
432{
433 int i = 0;
434
435 priv->tx_dcount = priv->tx_buf.len / sizeof(struct tx_desc);
436 priv->tx_descs = (struct tx_desc *) priv->tx_buf.buf;
437 priv->tx_dnext = 0;
438
439 for (i = 0; i < priv->tx_dcount; i++)
440 priv->tx_descs[i].header.sent = cpu_to_le32(TX_HDR_SENT);
441}
442
443static void ec_bhf_setup_rx_descs(struct ec_bhf_priv *priv)
444{
445 int i;
446
447 priv->rx_dcount = priv->rx_buf.len / sizeof(struct rx_desc);
448 priv->rx_descs = (struct rx_desc *) priv->rx_buf.buf;
449 priv->rx_dnext = 0;
450
451 for (i = 0; i < priv->rx_dcount; i++) {
452 struct rx_desc *desc = &priv->rx_descs[i];
453 u32 next;
454
455 if (i != priv->rx_dcount - 1)
456 next = (u8 *)(desc + 1) - priv->rx_buf.buf;
457 else
458 next = 0;
459 next |= RXHDR_NEXT_VALID;
460 desc->header.next = cpu_to_le32(next);
461 desc->header.recv = 0;
462 ec_bhf_add_rx_desc(priv, desc);
463 }
464}
465
466static int ec_bhf_open(struct net_device *net_dev)
467{
468 struct ec_bhf_priv *priv = netdev_priv(net_dev);
469 struct device *dev = PRIV_TO_DEV(priv);
470 int err = 0;
471
472 dev_info(dev, "Opening device\n");
473
474 ec_bhf_reset(priv);
475
476 err = ec_bhf_alloc_dma_mem(priv, &priv->rx_buf, priv->rx_dma_chan,
477 FIFO_SIZE * sizeof(struct rx_desc));
478 if (err) {
479 dev_err(dev, "Failed to allocate rx buffer\n");
480 goto out;
481 }
482 ec_bhf_setup_rx_descs(priv);
483
484 dev_info(dev, "RX buffer allocated, address: %x\n",
485 (unsigned)priv->rx_buf.buf_phys);
486
487 err = ec_bhf_alloc_dma_mem(priv, &priv->tx_buf, priv->tx_dma_chan,
488 FIFO_SIZE * sizeof(struct tx_desc));
489 if (err) {
490 dev_err(dev, "Failed to allocate tx buffer\n");
491 goto error_rx_free;
492 }
493 dev_dbg(dev, "TX buffer allocated, addres: %x\n",
494 (unsigned)priv->tx_buf.buf_phys);
495
496 iowrite8(0, priv->mii_io + MII_MAC_FILT_FLAG);
497
498 ec_bhf_setup_tx_descs(priv);
499
500 netif_start_queue(net_dev);
501
502 hrtimer_init(&priv->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
503 priv->hrtimer.function = ec_bhf_timer_fun;
504 hrtimer_start(&priv->hrtimer, ktime_set(0, polling_frequency),
505 HRTIMER_MODE_REL);
506
507 dev_info(PRIV_TO_DEV(priv), "Device open\n");
508
509 ec_bhf_print_status(priv);
510
511 return 0;
512
513error_rx_free:
514 dma_free_coherent(dev, priv->rx_buf.alloc_len, priv->rx_buf.alloc,
515 priv->rx_buf.alloc_len);
516out:
517 return err;
518}
519
520static int ec_bhf_stop(struct net_device *net_dev)
521{
522 struct ec_bhf_priv *priv = netdev_priv(net_dev);
523 struct device *dev = PRIV_TO_DEV(priv);
524
525 hrtimer_cancel(&priv->hrtimer);
526
527 ec_bhf_reset(priv);
528
529 netif_tx_disable(net_dev);
530
531 dma_free_coherent(dev, priv->tx_buf.alloc_len,
532 priv->tx_buf.alloc, priv->tx_buf.alloc_phys);
533 dma_free_coherent(dev, priv->rx_buf.alloc_len,
534 priv->rx_buf.alloc, priv->rx_buf.alloc_phys);
535
536 return 0;
537}
538
539static struct rtnl_link_stats64 *
540ec_bhf_get_stats(struct net_device *net_dev,
541 struct rtnl_link_stats64 *stats)
542{
543 struct ec_bhf_priv *priv = netdev_priv(net_dev);
544
545 stats->rx_errors = ioread8(priv->mac_io + MAC_RX_ERR_CNT) +
546 ioread8(priv->mac_io + MAC_CRC_ERR_CNT) +
547 ioread8(priv->mac_io + MAC_FRAME_ERR_CNT);
548 stats->rx_packets = ioread32(priv->mac_io + MAC_RX_FRAME_CNT);
549 stats->tx_packets = ioread32(priv->mac_io + MAC_TX_FRAME_CNT);
550 stats->rx_dropped = ioread8(priv->mac_io + MAC_DROPPED_FRMS);
551
552 stats->tx_bytes = priv->stat_tx_bytes;
553 stats->rx_bytes = priv->stat_rx_bytes;
554
555 return stats;
556}
557
558static const struct net_device_ops ec_bhf_netdev_ops = {
559 .ndo_start_xmit = ec_bhf_start_xmit,
560 .ndo_open = ec_bhf_open,
561 .ndo_stop = ec_bhf_stop,
562 .ndo_get_stats64 = ec_bhf_get_stats,
563 .ndo_change_mtu = eth_change_mtu,
564 .ndo_validate_addr = eth_validate_addr,
565 .ndo_set_mac_address = eth_mac_addr
566};
567
568static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
569{
570 struct net_device *net_dev;
571 struct ec_bhf_priv *priv;
572 void * __iomem dma_io;
573 void * __iomem io;
574 int err = 0;
575
576 err = pci_enable_device(dev);
577 if (err)
578 return err;
579
580 pci_set_master(dev);
581
582 err = pci_set_dma_mask(dev, DMA_BIT_MASK(32));
583 if (err) {
584 dev_err(&dev->dev,
585 "Required dma mask not supported, failed to initialize device\n");
586 err = -EIO;
587 goto err_disable_dev;
588 }
589
590 err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(32));
591 if (err) {
592 dev_err(&dev->dev,
593 "Required dma mask not supported, failed to initialize device\n");
594 goto err_disable_dev;
595 }
596
597 err = pci_request_regions(dev, "ec_bhf");
598 if (err) {
599 dev_err(&dev->dev, "Failed to request pci memory regions\n");
600 goto err_disable_dev;
601 }
602
603 io = pci_iomap(dev, 0, 0);
604 if (!io) {
605 dev_err(&dev->dev, "Failed to map pci card memory bar 0");
606 err = -EIO;
607 goto err_release_regions;
608 }
609
610 dma_io = pci_iomap(dev, 2, 0);
611 if (!dma_io) {
612 dev_err(&dev->dev, "Failed to map pci card memory bar 2");
613 err = -EIO;
614 goto err_unmap;
615 }
616
617 net_dev = alloc_etherdev(sizeof(struct ec_bhf_priv));
618 if (net_dev == 0) {
619 err = -ENOMEM;
620 goto err_unmap_dma_io;
621 }
622
623 pci_set_drvdata(dev, net_dev);
624 SET_NETDEV_DEV(net_dev, &dev->dev);
625
626 net_dev->features = 0;
627 net_dev->flags |= IFF_NOARP;
628
629 net_dev->netdev_ops = &ec_bhf_netdev_ops;
630
631 priv = netdev_priv(net_dev);
632 priv->net_dev = net_dev;
633 priv->io = io;
634 priv->dma_io = dma_io;
635 priv->dev = dev;
636
637 err = ec_bhf_setup_offsets(priv);
638 if (err < 0)
639 goto err_free_net_dev;
640
641 memcpy_fromio(net_dev->dev_addr, priv->mii_io + MII_MAC_ADDR, 6);
642
643 dev_dbg(&dev->dev, "CX5020 Ethercat master address: %pM\n",
644 net_dev->dev_addr);
645
646 err = register_netdev(net_dev);
647 if (err < 0)
648 goto err_free_net_dev;
649
650 return 0;
651
652err_free_net_dev:
653 free_netdev(net_dev);
654err_unmap_dma_io:
655 pci_iounmap(dev, dma_io);
656err_unmap:
657 pci_iounmap(dev, io);
658err_release_regions:
659 pci_release_regions(dev);
660err_disable_dev:
661 pci_clear_master(dev);
662 pci_disable_device(dev);
663
664 return err;
665}
666
667static void ec_bhf_remove(struct pci_dev *dev)
668{
669 struct net_device *net_dev = pci_get_drvdata(dev);
670 struct ec_bhf_priv *priv = netdev_priv(net_dev);
671
672 unregister_netdev(net_dev);
673 free_netdev(net_dev);
674
675 pci_iounmap(dev, priv->dma_io);
676 pci_iounmap(dev, priv->io);
677 pci_release_regions(dev);
678 pci_clear_master(dev);
679 pci_disable_device(dev);
680}
681
682static struct pci_driver pci_driver = {
683 .name = "ec_bhf",
684 .id_table = ids,
685 .probe = ec_bhf_probe,
686 .remove = ec_bhf_remove,
687};
688
689static int __init ec_bhf_init(void)
690{
691 return pci_register_driver(&pci_driver);
692}
693
694static void __exit ec_bhf_exit(void)
695{
696 pci_unregister_driver(&pci_driver);
697}
698
699module_init(ec_bhf_init);
700module_exit(ec_bhf_exit);
701
702module_param(polling_frequency, long, S_IRUGO);
703MODULE_PARM_DESC(polling_frequency, "Polling timer frequency in ns");
704
705MODULE_LICENSE("GPL");
706MODULE_AUTHOR("Dariusz Marcinkiewicz <reksio@newterm.pl>");
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 9125d9abf099..e2d42475b006 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -121,6 +121,7 @@ static irqreturn_t gfar_error(int irq, void *dev_id);
121static irqreturn_t gfar_transmit(int irq, void *dev_id); 121static irqreturn_t gfar_transmit(int irq, void *dev_id);
122static irqreturn_t gfar_interrupt(int irq, void *dev_id); 122static irqreturn_t gfar_interrupt(int irq, void *dev_id);
123static void adjust_link(struct net_device *dev); 123static void adjust_link(struct net_device *dev);
124static noinline void gfar_update_link_state(struct gfar_private *priv);
124static int init_phy(struct net_device *dev); 125static int init_phy(struct net_device *dev);
125static int gfar_probe(struct platform_device *ofdev); 126static int gfar_probe(struct platform_device *ofdev);
126static int gfar_remove(struct platform_device *ofdev); 127static int gfar_remove(struct platform_device *ofdev);
@@ -3076,41 +3077,6 @@ static irqreturn_t gfar_interrupt(int irq, void *grp_id)
3076 return IRQ_HANDLED; 3077 return IRQ_HANDLED;
3077} 3078}
3078 3079
3079static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
3080{
3081 struct phy_device *phydev = priv->phydev;
3082 u32 val = 0;
3083
3084 if (!phydev->duplex)
3085 return val;
3086
3087 if (!priv->pause_aneg_en) {
3088 if (priv->tx_pause_en)
3089 val |= MACCFG1_TX_FLOW;
3090 if (priv->rx_pause_en)
3091 val |= MACCFG1_RX_FLOW;
3092 } else {
3093 u16 lcl_adv, rmt_adv;
3094 u8 flowctrl;
3095 /* get link partner capabilities */
3096 rmt_adv = 0;
3097 if (phydev->pause)
3098 rmt_adv = LPA_PAUSE_CAP;
3099 if (phydev->asym_pause)
3100 rmt_adv |= LPA_PAUSE_ASYM;
3101
3102 lcl_adv = mii_advertise_flowctrl(phydev->advertising);
3103
3104 flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
3105 if (flowctrl & FLOW_CTRL_TX)
3106 val |= MACCFG1_TX_FLOW;
3107 if (flowctrl & FLOW_CTRL_RX)
3108 val |= MACCFG1_RX_FLOW;
3109 }
3110
3111 return val;
3112}
3113
3114/* Called every time the controller might need to be made 3080/* Called every time the controller might need to be made
3115 * aware of new link state. The PHY code conveys this 3081 * aware of new link state. The PHY code conveys this
3116 * information through variables in the phydev structure, and this 3082 * information through variables in the phydev structure, and this
@@ -3120,83 +3086,12 @@ static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
3120static void adjust_link(struct net_device *dev) 3086static void adjust_link(struct net_device *dev)
3121{ 3087{
3122 struct gfar_private *priv = netdev_priv(dev); 3088 struct gfar_private *priv = netdev_priv(dev);
3123 struct gfar __iomem *regs = priv->gfargrp[0].regs;
3124 struct phy_device *phydev = priv->phydev; 3089 struct phy_device *phydev = priv->phydev;
3125 int new_state = 0;
3126 3090
3127 if (test_bit(GFAR_RESETTING, &priv->state)) 3091 if (unlikely(phydev->link != priv->oldlink ||
3128 return; 3092 phydev->duplex != priv->oldduplex ||
3129 3093 phydev->speed != priv->oldspeed))
3130 if (phydev->link) { 3094 gfar_update_link_state(priv);
3131 u32 tempval1 = gfar_read(&regs->maccfg1);
3132 u32 tempval = gfar_read(&regs->maccfg2);
3133 u32 ecntrl = gfar_read(&regs->ecntrl);
3134
3135 /* Now we make sure that we can be in full duplex mode.
3136 * If not, we operate in half-duplex mode.
3137 */
3138 if (phydev->duplex != priv->oldduplex) {
3139 new_state = 1;
3140 if (!(phydev->duplex))
3141 tempval &= ~(MACCFG2_FULL_DUPLEX);
3142 else
3143 tempval |= MACCFG2_FULL_DUPLEX;
3144
3145 priv->oldduplex = phydev->duplex;
3146 }
3147
3148 if (phydev->speed != priv->oldspeed) {
3149 new_state = 1;
3150 switch (phydev->speed) {
3151 case 1000:
3152 tempval =
3153 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
3154
3155 ecntrl &= ~(ECNTRL_R100);
3156 break;
3157 case 100:
3158 case 10:
3159 tempval =
3160 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII);
3161
3162 /* Reduced mode distinguishes
3163 * between 10 and 100
3164 */
3165 if (phydev->speed == SPEED_100)
3166 ecntrl |= ECNTRL_R100;
3167 else
3168 ecntrl &= ~(ECNTRL_R100);
3169 break;
3170 default:
3171 netif_warn(priv, link, dev,
3172 "Ack! Speed (%d) is not 10/100/1000!\n",
3173 phydev->speed);
3174 break;
3175 }
3176
3177 priv->oldspeed = phydev->speed;
3178 }
3179
3180 tempval1 &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
3181 tempval1 |= gfar_get_flowctrl_cfg(priv);
3182
3183 gfar_write(&regs->maccfg1, tempval1);
3184 gfar_write(&regs->maccfg2, tempval);
3185 gfar_write(&regs->ecntrl, ecntrl);
3186
3187 if (!priv->oldlink) {
3188 new_state = 1;
3189 priv->oldlink = 1;
3190 }
3191 } else if (priv->oldlink) {
3192 new_state = 1;
3193 priv->oldlink = 0;
3194 priv->oldspeed = 0;
3195 priv->oldduplex = -1;
3196 }
3197
3198 if (new_state && netif_msg_link(priv))
3199 phy_print_status(phydev);
3200} 3095}
3201 3096
3202/* Update the hash table based on the current list of multicast 3097/* Update the hash table based on the current list of multicast
@@ -3442,6 +3337,114 @@ static irqreturn_t gfar_error(int irq, void *grp_id)
3442 return IRQ_HANDLED; 3337 return IRQ_HANDLED;
3443} 3338}
3444 3339
3340static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
3341{
3342 struct phy_device *phydev = priv->phydev;
3343 u32 val = 0;
3344
3345 if (!phydev->duplex)
3346 return val;
3347
3348 if (!priv->pause_aneg_en) {
3349 if (priv->tx_pause_en)
3350 val |= MACCFG1_TX_FLOW;
3351 if (priv->rx_pause_en)
3352 val |= MACCFG1_RX_FLOW;
3353 } else {
3354 u16 lcl_adv, rmt_adv;
3355 u8 flowctrl;
3356 /* get link partner capabilities */
3357 rmt_adv = 0;
3358 if (phydev->pause)
3359 rmt_adv = LPA_PAUSE_CAP;
3360 if (phydev->asym_pause)
3361 rmt_adv |= LPA_PAUSE_ASYM;
3362
3363 lcl_adv = mii_advertise_flowctrl(phydev->advertising);
3364
3365 flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
3366 if (flowctrl & FLOW_CTRL_TX)
3367 val |= MACCFG1_TX_FLOW;
3368 if (flowctrl & FLOW_CTRL_RX)
3369 val |= MACCFG1_RX_FLOW;
3370 }
3371
3372 return val;
3373}
3374
3375static noinline void gfar_update_link_state(struct gfar_private *priv)
3376{
3377 struct gfar __iomem *regs = priv->gfargrp[0].regs;
3378 struct phy_device *phydev = priv->phydev;
3379
3380 if (unlikely(test_bit(GFAR_RESETTING, &priv->state)))
3381 return;
3382
3383 if (phydev->link) {
3384 u32 tempval1 = gfar_read(&regs->maccfg1);
3385 u32 tempval = gfar_read(&regs->maccfg2);
3386 u32 ecntrl = gfar_read(&regs->ecntrl);
3387
3388 if (phydev->duplex != priv->oldduplex) {
3389 if (!(phydev->duplex))
3390 tempval &= ~(MACCFG2_FULL_DUPLEX);
3391 else
3392 tempval |= MACCFG2_FULL_DUPLEX;
3393
3394 priv->oldduplex = phydev->duplex;
3395 }
3396
3397 if (phydev->speed != priv->oldspeed) {
3398 switch (phydev->speed) {
3399 case 1000:
3400 tempval =
3401 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
3402
3403 ecntrl &= ~(ECNTRL_R100);
3404 break;
3405 case 100:
3406 case 10:
3407 tempval =
3408 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII);
3409
3410 /* Reduced mode distinguishes
3411 * between 10 and 100
3412 */
3413 if (phydev->speed == SPEED_100)
3414 ecntrl |= ECNTRL_R100;
3415 else
3416 ecntrl &= ~(ECNTRL_R100);
3417 break;
3418 default:
3419 netif_warn(priv, link, priv->ndev,
3420 "Ack! Speed (%d) is not 10/100/1000!\n",
3421 phydev->speed);
3422 break;
3423 }
3424
3425 priv->oldspeed = phydev->speed;
3426 }
3427
3428 tempval1 &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
3429 tempval1 |= gfar_get_flowctrl_cfg(priv);
3430
3431 gfar_write(&regs->maccfg1, tempval1);
3432 gfar_write(&regs->maccfg2, tempval);
3433 gfar_write(&regs->ecntrl, ecntrl);
3434
3435 if (!priv->oldlink)
3436 priv->oldlink = 1;
3437
3438 } else if (priv->oldlink) {
3439 priv->oldlink = 0;
3440 priv->oldspeed = 0;
3441 priv->oldduplex = -1;
3442 }
3443
3444 if (netif_msg_link(priv))
3445 phy_print_status(phydev);
3446}
3447
3445static struct of_device_id gfar_match[] = 3448static struct of_device_id gfar_match[] =
3446{ 3449{
3447 { 3450 {
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 891dbee6e6c1..76d70708f864 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -533,6 +533,9 @@ static int gfar_spauseparam(struct net_device *dev,
533 struct gfar __iomem *regs = priv->gfargrp[0].regs; 533 struct gfar __iomem *regs = priv->gfargrp[0].regs;
534 u32 oldadv, newadv; 534 u32 oldadv, newadv;
535 535
536 if (!phydev)
537 return -ENODEV;
538
536 if (!(phydev->supported & SUPPORTED_Pause) || 539 if (!(phydev->supported & SUPPORTED_Pause) ||
537 (!(phydev->supported & SUPPORTED_Asym_Pause) && 540 (!(phydev->supported & SUPPORTED_Asym_Pause) &&
538 (epause->rx_pause != epause->tx_pause))) 541 (epause->rx_pause != epause->tx_pause)))
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index a2901139b209..5f5539561661 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -186,7 +186,7 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
186{ 186{
187 u16 phy_reg = 0; 187 u16 phy_reg = 0;
188 u32 phy_id = 0; 188 u32 phy_id = 0;
189 s32 ret_val; 189 s32 ret_val = 0;
190 u16 retry_count; 190 u16 retry_count;
191 u32 mac_reg = 0; 191 u32 mac_reg = 0;
192 192
@@ -217,11 +217,13 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
217 /* In case the PHY needs to be in mdio slow mode, 217 /* In case the PHY needs to be in mdio slow mode,
218 * set slow mode and try to get the PHY id again. 218 * set slow mode and try to get the PHY id again.
219 */ 219 */
220 hw->phy.ops.release(hw); 220 if (hw->mac.type < e1000_pch_lpt) {
221 ret_val = e1000_set_mdio_slow_mode_hv(hw); 221 hw->phy.ops.release(hw);
222 if (!ret_val) 222 ret_val = e1000_set_mdio_slow_mode_hv(hw);
223 ret_val = e1000e_get_phy_id(hw); 223 if (!ret_val)
224 hw->phy.ops.acquire(hw); 224 ret_val = e1000e_get_phy_id(hw);
225 hw->phy.ops.acquire(hw);
226 }
225 227
226 if (ret_val) 228 if (ret_val)
227 return false; 229 return false;
@@ -842,6 +844,17 @@ s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
842 } 844 }
843 } 845 }
844 846
847 if (hw->phy.type == e1000_phy_82579) {
848 ret_val = e1000_read_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
849 &data);
850 if (ret_val)
851 goto release;
852
853 data &= ~I82579_LPI_100_PLL_SHUT;
854 ret_val = e1000_write_emi_reg_locked(hw, I82579_LPI_PLL_SHUT,
855 data);
856 }
857
845 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */ 858 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
846 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data); 859 ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data);
847 if (ret_val) 860 if (ret_val)
@@ -1314,15 +1327,18 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1314 return ret_val; 1327 return ret_val;
1315 } 1328 }
1316 1329
1317 /* When connected at 10Mbps half-duplex, 82579 parts are excessively 1330 /* When connected at 10Mbps half-duplex, some parts are excessively
1318 * aggressive resulting in many collisions. To avoid this, increase 1331 * aggressive resulting in many collisions. To avoid this, increase
1319 * the IPG and reduce Rx latency in the PHY. 1332 * the IPG and reduce Rx latency in the PHY.
1320 */ 1333 */
1321 if ((hw->mac.type == e1000_pch2lan) && link) { 1334 if (((hw->mac.type == e1000_pch2lan) ||
1335 (hw->mac.type == e1000_pch_lpt)) && link) {
1322 u32 reg; 1336 u32 reg;
1323 1337
1324 reg = er32(STATUS); 1338 reg = er32(STATUS);
1325 if (!(reg & (E1000_STATUS_FD | E1000_STATUS_SPEED_MASK))) { 1339 if (!(reg & (E1000_STATUS_FD | E1000_STATUS_SPEED_MASK))) {
1340 u16 emi_addr;
1341
1326 reg = er32(TIPG); 1342 reg = er32(TIPG);
1327 reg &= ~E1000_TIPG_IPGT_MASK; 1343 reg &= ~E1000_TIPG_IPGT_MASK;
1328 reg |= 0xFF; 1344 reg |= 0xFF;
@@ -1333,8 +1349,12 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
1333 if (ret_val) 1349 if (ret_val)
1334 return ret_val; 1350 return ret_val;
1335 1351
1336 ret_val = 1352 if (hw->mac.type == e1000_pch2lan)
1337 e1000_write_emi_reg_locked(hw, I82579_RX_CONFIG, 0); 1353 emi_addr = I82579_RX_CONFIG;
1354 else
1355 emi_addr = I217_RX_CONFIG;
1356
1357 ret_val = e1000_write_emi_reg_locked(hw, emi_addr, 0);
1338 1358
1339 hw->phy.ops.release(hw); 1359 hw->phy.ops.release(hw);
1340 1360
@@ -2494,51 +2514,44 @@ release:
2494 * e1000_k1_gig_workaround_lv - K1 Si workaround 2514 * e1000_k1_gig_workaround_lv - K1 Si workaround
2495 * @hw: pointer to the HW structure 2515 * @hw: pointer to the HW structure
2496 * 2516 *
2497 * Workaround to set the K1 beacon duration for 82579 parts 2517 * Workaround to set the K1 beacon duration for 82579 parts in 10Mbps
2518 * Disable K1 in 1000Mbps and 100Mbps
2498 **/ 2519 **/
2499static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) 2520static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
2500{ 2521{
2501 s32 ret_val = 0; 2522 s32 ret_val = 0;
2502 u16 status_reg = 0; 2523 u16 status_reg = 0;
2503 u32 mac_reg;
2504 u16 phy_reg;
2505 2524
2506 if (hw->mac.type != e1000_pch2lan) 2525 if (hw->mac.type != e1000_pch2lan)
2507 return 0; 2526 return 0;
2508 2527
2509 /* Set K1 beacon duration based on 1Gbps speed or otherwise */ 2528 /* Set K1 beacon duration based on 10Mbs speed */
2510 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg); 2529 ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
2511 if (ret_val) 2530 if (ret_val)
2512 return ret_val; 2531 return ret_val;
2513 2532
2514 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) 2533 if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
2515 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) { 2534 == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
2516 mac_reg = er32(FEXTNVM4); 2535 if (status_reg &
2517 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK; 2536 (HV_M_STATUS_SPEED_1000 | HV_M_STATUS_SPEED_100)) {
2518
2519 ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
2520 if (ret_val)
2521 return ret_val;
2522
2523 if (status_reg & HV_M_STATUS_SPEED_1000) {
2524 u16 pm_phy_reg; 2537 u16 pm_phy_reg;
2525 2538
2526 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC; 2539 /* LV 1G/100 Packet drop issue wa */
2527 phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT;
2528 /* LV 1G Packet drop issue wa */
2529 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg); 2540 ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg);
2530 if (ret_val) 2541 if (ret_val)
2531 return ret_val; 2542 return ret_val;
2532 pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA; 2543 pm_phy_reg &= ~HV_PM_CTRL_K1_ENABLE;
2533 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg); 2544 ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg);
2534 if (ret_val) 2545 if (ret_val)
2535 return ret_val; 2546 return ret_val;
2536 } else { 2547 } else {
2548 u32 mac_reg;
2549
2550 mac_reg = er32(FEXTNVM4);
2551 mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
2537 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC; 2552 mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
2538 phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT; 2553 ew32(FEXTNVM4, mac_reg);
2539 } 2554 }
2540 ew32(FEXTNVM4, mac_reg);
2541 ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
2542 } 2555 }
2543 2556
2544 return ret_val; 2557 return ret_val;
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethernet/intel/e1000e/ich8lan.h
index bead50f9187b..5515126c81c1 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.h
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h
@@ -232,16 +232,19 @@
232#define I82577_MSE_THRESHOLD 0x0887 /* 82577 Mean Square Error Threshold */ 232#define I82577_MSE_THRESHOLD 0x0887 /* 82577 Mean Square Error Threshold */
233#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */ 233#define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */
234#define I82579_RX_CONFIG 0x3412 /* Receive configuration */ 234#define I82579_RX_CONFIG 0x3412 /* Receive configuration */
235#define I82579_LPI_PLL_SHUT 0x4412 /* LPI PLL Shut Enable */
235#define I82579_EEE_PCS_STATUS 0x182E /* IEEE MMD Register 3.1 >> 8 */ 236#define I82579_EEE_PCS_STATUS 0x182E /* IEEE MMD Register 3.1 >> 8 */
236#define I82579_EEE_CAPABILITY 0x0410 /* IEEE MMD Register 3.20 */ 237#define I82579_EEE_CAPABILITY 0x0410 /* IEEE MMD Register 3.20 */
237#define I82579_EEE_ADVERTISEMENT 0x040E /* IEEE MMD Register 7.60 */ 238#define I82579_EEE_ADVERTISEMENT 0x040E /* IEEE MMD Register 7.60 */
238#define I82579_EEE_LP_ABILITY 0x040F /* IEEE MMD Register 7.61 */ 239#define I82579_EEE_LP_ABILITY 0x040F /* IEEE MMD Register 7.61 */
239#define I82579_EEE_100_SUPPORTED (1 << 1) /* 100BaseTx EEE */ 240#define I82579_EEE_100_SUPPORTED (1 << 1) /* 100BaseTx EEE */
240#define I82579_EEE_1000_SUPPORTED (1 << 2) /* 1000BaseTx EEE */ 241#define I82579_EEE_1000_SUPPORTED (1 << 2) /* 1000BaseTx EEE */
242#define I82579_LPI_100_PLL_SHUT (1 << 2) /* 100M LPI PLL Shut Enabled */
241#define I217_EEE_PCS_STATUS 0x9401 /* IEEE MMD Register 3.1 */ 243#define I217_EEE_PCS_STATUS 0x9401 /* IEEE MMD Register 3.1 */
242#define I217_EEE_CAPABILITY 0x8000 /* IEEE MMD Register 3.20 */ 244#define I217_EEE_CAPABILITY 0x8000 /* IEEE MMD Register 3.20 */
243#define I217_EEE_ADVERTISEMENT 0x8001 /* IEEE MMD Register 7.60 */ 245#define I217_EEE_ADVERTISEMENT 0x8001 /* IEEE MMD Register 7.60 */
244#define I217_EEE_LP_ABILITY 0x8002 /* IEEE MMD Register 7.61 */ 246#define I217_EEE_LP_ABILITY 0x8002 /* IEEE MMD Register 7.61 */
247#define I217_RX_CONFIG 0xB20C /* Receive configuration */
245 248
246#define E1000_EEE_RX_LPI_RCVD 0x0400 /* Tx LP idle received */ 249#define E1000_EEE_RX_LPI_RCVD 0x0400 /* Tx LP idle received */
247#define E1000_EEE_TX_LPI_RCVD 0x0800 /* Rx LP idle received */ 250#define E1000_EEE_TX_LPI_RCVD 0x0800 /* Rx LP idle received */
diff --git a/drivers/net/ethernet/intel/e1000e/phy.h b/drivers/net/ethernet/intel/e1000e/phy.h
index 3841bccf058c..537d2780b408 100644
--- a/drivers/net/ethernet/intel/e1000e/phy.h
+++ b/drivers/net/ethernet/intel/e1000e/phy.h
@@ -164,6 +164,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw);
164#define HV_M_STATUS_AUTONEG_COMPLETE 0x1000 164#define HV_M_STATUS_AUTONEG_COMPLETE 0x1000
165#define HV_M_STATUS_SPEED_MASK 0x0300 165#define HV_M_STATUS_SPEED_MASK 0x0300
166#define HV_M_STATUS_SPEED_1000 0x0200 166#define HV_M_STATUS_SPEED_1000 0x0200
167#define HV_M_STATUS_SPEED_100 0x0100
167#define HV_M_STATUS_LINK_UP 0x0040 168#define HV_M_STATUS_LINK_UP 0x0040
168 169
169#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 170#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 109052a19bd9..e399f9b70777 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2899,12 +2899,9 @@ static irqreturn_t i40e_intr(int irq, void *data)
2899 u32 prttsyn_stat = rd32(hw, I40E_PRTTSYN_STAT_0); 2899 u32 prttsyn_stat = rd32(hw, I40E_PRTTSYN_STAT_0);
2900 2900
2901 if (prttsyn_stat & I40E_PRTTSYN_STAT_0_TXTIME_MASK) { 2901 if (prttsyn_stat & I40E_PRTTSYN_STAT_0_TXTIME_MASK) {
2902 ena_mask &= ~I40E_PFINT_ICR0_ENA_TIMESYNC_MASK; 2902 icr0 &= ~I40E_PFINT_ICR0_ENA_TIMESYNC_MASK;
2903 i40e_ptp_tx_hwtstamp(pf); 2903 i40e_ptp_tx_hwtstamp(pf);
2904 prttsyn_stat &= ~I40E_PRTTSYN_STAT_0_TXTIME_MASK;
2905 } 2904 }
2906
2907 wr32(hw, I40E_PRTTSYN_STAT_0, prttsyn_stat);
2908 } 2905 }
2909 2906
2910 /* If a critical error is pending we have no choice but to reset the 2907 /* If a critical error is pending we have no choice but to reset the
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index b0c6050479eb..6e664d9038d6 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1988,7 +1988,7 @@ jme_alloc_txdesc(struct jme_adapter *jme,
1988 return idx; 1988 return idx;
1989} 1989}
1990 1990
1991static void 1991static int
1992jme_fill_tx_map(struct pci_dev *pdev, 1992jme_fill_tx_map(struct pci_dev *pdev,
1993 struct txdesc *txdesc, 1993 struct txdesc *txdesc,
1994 struct jme_buffer_info *txbi, 1994 struct jme_buffer_info *txbi,
@@ -2005,6 +2005,9 @@ jme_fill_tx_map(struct pci_dev *pdev,
2005 len, 2005 len,
2006 PCI_DMA_TODEVICE); 2006 PCI_DMA_TODEVICE);
2007 2007
2008 if (unlikely(pci_dma_mapping_error(pdev, dmaaddr)))
2009 return -EINVAL;
2010
2008 pci_dma_sync_single_for_device(pdev, 2011 pci_dma_sync_single_for_device(pdev,
2009 dmaaddr, 2012 dmaaddr,
2010 len, 2013 len,
@@ -2021,9 +2024,30 @@ jme_fill_tx_map(struct pci_dev *pdev,
2021 2024
2022 txbi->mapping = dmaaddr; 2025 txbi->mapping = dmaaddr;
2023 txbi->len = len; 2026 txbi->len = len;
2027 return 0;
2024} 2028}
2025 2029
2026static void 2030static void jme_drop_tx_map(struct jme_adapter *jme, int startidx, int endidx)
2031{
2032 struct jme_ring *txring = &(jme->txring[0]);
2033 struct jme_buffer_info *txbi = txring->bufinf, *ctxbi;
2034 int mask = jme->tx_ring_mask;
2035 int j;
2036
2037 for (j = startidx ; j < endidx ; ++j) {
2038 ctxbi = txbi + ((startidx + j + 2) & (mask));
2039 pci_unmap_page(jme->pdev,
2040 ctxbi->mapping,
2041 ctxbi->len,
2042 PCI_DMA_TODEVICE);
2043
2044 ctxbi->mapping = 0;
2045 ctxbi->len = 0;
2046 }
2047
2048}
2049
2050static int
2027jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) 2051jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
2028{ 2052{
2029 struct jme_ring *txring = &(jme->txring[0]); 2053 struct jme_ring *txring = &(jme->txring[0]);
@@ -2034,25 +2058,37 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx)
2034 int mask = jme->tx_ring_mask; 2058 int mask = jme->tx_ring_mask;
2035 const struct skb_frag_struct *frag; 2059 const struct skb_frag_struct *frag;
2036 u32 len; 2060 u32 len;
2061 int ret = 0;
2037 2062
2038 for (i = 0 ; i < nr_frags ; ++i) { 2063 for (i = 0 ; i < nr_frags ; ++i) {
2039 frag = &skb_shinfo(skb)->frags[i]; 2064 frag = &skb_shinfo(skb)->frags[i];
2040 ctxdesc = txdesc + ((idx + i + 2) & (mask)); 2065 ctxdesc = txdesc + ((idx + i + 2) & (mask));
2041 ctxbi = txbi + ((idx + i + 2) & (mask)); 2066 ctxbi = txbi + ((idx + i + 2) & (mask));
2042 2067
2043 jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, 2068 ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi,
2044 skb_frag_page(frag), 2069 skb_frag_page(frag),
2045 frag->page_offset, skb_frag_size(frag), hidma); 2070 frag->page_offset, skb_frag_size(frag), hidma);
2071 if (ret) {
2072 jme_drop_tx_map(jme, idx, idx+i);
2073 goto out;
2074 }
2075
2046 } 2076 }
2047 2077
2048 len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len; 2078 len = skb_is_nonlinear(skb) ? skb_headlen(skb) : skb->len;
2049 ctxdesc = txdesc + ((idx + 1) & (mask)); 2079 ctxdesc = txdesc + ((idx + 1) & (mask));
2050 ctxbi = txbi + ((idx + 1) & (mask)); 2080 ctxbi = txbi + ((idx + 1) & (mask));
2051 jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, virt_to_page(skb->data), 2081 ret = jme_fill_tx_map(jme->pdev, ctxdesc, ctxbi, virt_to_page(skb->data),
2052 offset_in_page(skb->data), len, hidma); 2082 offset_in_page(skb->data), len, hidma);
2083 if (ret)
2084 jme_drop_tx_map(jme, idx, idx+i);
2085
2086out:
2087 return ret;
2053 2088
2054} 2089}
2055 2090
2091
2056static int 2092static int
2057jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags) 2093jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags)
2058{ 2094{
@@ -2131,6 +2167,7 @@ jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
2131 struct txdesc *txdesc; 2167 struct txdesc *txdesc;
2132 struct jme_buffer_info *txbi; 2168 struct jme_buffer_info *txbi;
2133 u8 flags; 2169 u8 flags;
2170 int ret = 0;
2134 2171
2135 txdesc = (struct txdesc *)txring->desc + idx; 2172 txdesc = (struct txdesc *)txring->desc + idx;
2136 txbi = txring->bufinf + idx; 2173 txbi = txring->bufinf + idx;
@@ -2155,7 +2192,10 @@ jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx)
2155 if (jme_tx_tso(skb, &txdesc->desc1.mss, &flags)) 2192 if (jme_tx_tso(skb, &txdesc->desc1.mss, &flags))
2156 jme_tx_csum(jme, skb, &flags); 2193 jme_tx_csum(jme, skb, &flags);
2157 jme_tx_vlan(skb, &txdesc->desc1.vlan, &flags); 2194 jme_tx_vlan(skb, &txdesc->desc1.vlan, &flags);
2158 jme_map_tx_skb(jme, skb, idx); 2195 ret = jme_map_tx_skb(jme, skb, idx);
2196 if (ret)
2197 return ret;
2198
2159 txdesc->desc1.flags = flags; 2199 txdesc->desc1.flags = flags;
2160 /* 2200 /*
2161 * Set tx buffer info after telling NIC to send 2201 * Set tx buffer info after telling NIC to send
@@ -2228,7 +2268,8 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev)
2228 return NETDEV_TX_BUSY; 2268 return NETDEV_TX_BUSY;
2229 } 2269 }
2230 2270
2231 jme_fill_tx_desc(jme, skb, idx); 2271 if (jme_fill_tx_desc(jme, skb, idx))
2272 return NETDEV_TX_BUSY;
2232 2273
2233 jwrite32(jme, JME_TXCS, jme->reg_txcs | 2274 jwrite32(jme, JME_TXCS, jme->reg_txcs |
2234 TXCS_SELECT_QUEUE0 | 2275 TXCS_SELECT_QUEUE0 |
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index b161a525fc5b..9d5ced263a5e 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -232,7 +232,7 @@ static int orion_mdio_probe(struct platform_device *pdev)
232 clk_prepare_enable(dev->clk); 232 clk_prepare_enable(dev->clk);
233 233
234 dev->err_interrupt = platform_get_irq(pdev, 0); 234 dev->err_interrupt = platform_get_irq(pdev, 0);
235 if (dev->err_interrupt != -ENXIO) { 235 if (dev->err_interrupt > 0) {
236 ret = devm_request_irq(&pdev->dev, dev->err_interrupt, 236 ret = devm_request_irq(&pdev->dev, dev->err_interrupt,
237 orion_mdio_err_irq, 237 orion_mdio_err_irq,
238 IRQF_SHARED, pdev->name, dev); 238 IRQF_SHARED, pdev->name, dev);
@@ -241,6 +241,9 @@ static int orion_mdio_probe(struct platform_device *pdev)
241 241
242 writel(MVMDIO_ERR_INT_SMI_DONE, 242 writel(MVMDIO_ERR_INT_SMI_DONE,
243 dev->regs + MVMDIO_ERR_INT_MASK); 243 dev->regs + MVMDIO_ERR_INT_MASK);
244
245 } else if (dev->err_interrupt == -EPROBE_DEFER) {
246 return -EPROBE_DEFER;
244 } 247 }
245 248
246 mutex_init(&dev->lock); 249 mutex_init(&dev->lock);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index df2c1fbf75ec..5db97a4fdc01 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -746,10 +746,10 @@ static void mlx4_request_modules(struct mlx4_dev *dev)
746 has_eth_port = true; 746 has_eth_port = true;
747 } 747 }
748 748
749 if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
750 request_module_nowait(IB_DRV_NAME);
751 if (has_eth_port) 749 if (has_eth_port)
752 request_module_nowait(EN_DRV_NAME); 750 request_module_nowait(EN_DRV_NAME);
751 if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE))
752 request_module_nowait(IB_DRV_NAME);
753} 753}
754 754
755/* 755/*
@@ -2406,7 +2406,8 @@ slave_start:
2406 * No return code for this call, just warn the user in case of PCI 2406 * No return code for this call, just warn the user in case of PCI
2407 * express device capabilities are under-satisfied by the bus. 2407 * express device capabilities are under-satisfied by the bus.
2408 */ 2408 */
2409 mlx4_check_pcie_caps(dev); 2409 if (!mlx4_is_slave(dev))
2410 mlx4_check_pcie_caps(dev);
2410 2411
2411 /* In master functions, the communication channel must be initialized 2412 /* In master functions, the communication channel must be initialized
2412 * after obtaining its address from fw */ 2413 * after obtaining its address from fw */
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
index 1f6d29183f1d..376f2f1d445e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/port.c
+++ b/drivers/net/ethernet/mellanox/mlx4/port.c
@@ -1104,6 +1104,9 @@ int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid,
1104 } 1104 }
1105 1105
1106 if (found_ix >= 0) { 1106 if (found_ix >= 0) {
1107 /* Calculate a slave_gid which is the slave number in the gid
1108 * table and not a globally unique slave number.
1109 */
1107 if (found_ix < MLX4_ROCE_PF_GIDS) 1110 if (found_ix < MLX4_ROCE_PF_GIDS)
1108 slave_gid = 0; 1111 slave_gid = 0;
1109 else if (found_ix < MLX4_ROCE_PF_GIDS + (vf_gids % num_vfs) * 1112 else if (found_ix < MLX4_ROCE_PF_GIDS + (vf_gids % num_vfs) *
@@ -1116,41 +1119,43 @@ int mlx4_get_slave_from_roce_gid(struct mlx4_dev *dev, int port, u8 *gid,
1116 ((vf_gids % num_vfs) * ((vf_gids / num_vfs + 1)))) / 1119 ((vf_gids % num_vfs) * ((vf_gids / num_vfs + 1)))) /
1117 (vf_gids / num_vfs)) + vf_gids % num_vfs + 1; 1120 (vf_gids / num_vfs)) + vf_gids % num_vfs + 1;
1118 1121
1122 /* Calculate the globally unique slave id */
1119 if (slave_gid) { 1123 if (slave_gid) {
1120 struct mlx4_active_ports exclusive_ports; 1124 struct mlx4_active_ports exclusive_ports;
1121 struct mlx4_active_ports actv_ports; 1125 struct mlx4_active_ports actv_ports;
1122 struct mlx4_slaves_pport slaves_pport_actv; 1126 struct mlx4_slaves_pport slaves_pport_actv;
1123 unsigned max_port_p_one; 1127 unsigned max_port_p_one;
1124 int num_slaves_before = 1; 1128 int num_vfs_before = 0;
1129 int candidate_slave_gid;
1125 1130
1131 /* Calculate how many VFs are on the previous port, if exists */
1126 for (i = 1; i < port; i++) { 1132 for (i = 1; i < port; i++) {
1127 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); 1133 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports);
1128 set_bit(i, exclusive_ports.ports); 1134 set_bit(i - 1, exclusive_ports.ports);
1129 slaves_pport_actv = 1135 slaves_pport_actv =
1130 mlx4_phys_to_slaves_pport_actv( 1136 mlx4_phys_to_slaves_pport_actv(
1131 dev, &exclusive_ports); 1137 dev, &exclusive_ports);
1132 num_slaves_before += bitmap_weight( 1138 num_vfs_before += bitmap_weight(
1133 slaves_pport_actv.slaves, 1139 slaves_pport_actv.slaves,
1134 dev->num_vfs + 1); 1140 dev->num_vfs + 1);
1135 } 1141 }
1136 1142
1137 if (slave_gid < num_slaves_before) { 1143 /* candidate_slave_gid isn't necessarily the correct slave, but
1138 bitmap_zero(exclusive_ports.ports, dev->caps.num_ports); 1144 * it has the same number of ports and is assigned to the same
1139 set_bit(port - 1, exclusive_ports.ports); 1145 * ports as the real slave we're looking for. On dual port VF,
1140 slaves_pport_actv = 1146 * slave_gid = [single port VFs on port <port>] +
1141 mlx4_phys_to_slaves_pport_actv( 1147 * [offset of the current slave from the first dual port VF] +
1142 dev, &exclusive_ports); 1148 * 1 (for the PF).
1143 slave_gid += bitmap_weight( 1149 */
1144 slaves_pport_actv.slaves, 1150 candidate_slave_gid = slave_gid + num_vfs_before;
1145 dev->num_vfs + 1) - 1151
1146 num_slaves_before; 1152 actv_ports = mlx4_get_active_ports(dev, candidate_slave_gid);
1147 }
1148 actv_ports = mlx4_get_active_ports(dev, slave_gid);
1149 max_port_p_one = find_first_bit( 1153 max_port_p_one = find_first_bit(
1150 actv_ports.ports, dev->caps.num_ports) + 1154 actv_ports.ports, dev->caps.num_ports) +
1151 bitmap_weight(actv_ports.ports, 1155 bitmap_weight(actv_ports.ports,
1152 dev->caps.num_ports) + 1; 1156 dev->caps.num_ports) + 1;
1153 1157
1158 /* Calculate the real slave number */
1154 for (i = 1; i < max_port_p_one; i++) { 1159 for (i = 1; i < max_port_p_one; i++) {
1155 if (i == port) 1160 if (i == port)
1156 continue; 1161 continue;
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 12fa515a7dd8..a95df9d2645d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -3733,6 +3733,25 @@ static int qp_detach(struct mlx4_dev *dev, struct mlx4_qp *qp,
3733 } 3733 }
3734} 3734}
3735 3735
3736static int mlx4_adjust_port(struct mlx4_dev *dev, int slave,
3737 u8 *gid, enum mlx4_protocol prot)
3738{
3739 int real_port;
3740
3741 if (prot != MLX4_PROT_ETH)
3742 return 0;
3743
3744 if (dev->caps.steering_mode == MLX4_STEERING_MODE_B0 ||
3745 dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) {
3746 real_port = mlx4_slave_convert_port(dev, slave, gid[5]);
3747 if (real_port < 0)
3748 return -EINVAL;
3749 gid[5] = real_port;
3750 }
3751
3752 return 0;
3753}
3754
3736int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, 3755int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
3737 struct mlx4_vhcr *vhcr, 3756 struct mlx4_vhcr *vhcr,
3738 struct mlx4_cmd_mailbox *inbox, 3757 struct mlx4_cmd_mailbox *inbox,
@@ -3768,6 +3787,10 @@ int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
3768 if (err) 3787 if (err)
3769 goto ex_detach; 3788 goto ex_detach;
3770 } else { 3789 } else {
3790 err = mlx4_adjust_port(dev, slave, gid, prot);
3791 if (err)
3792 goto ex_put;
3793
3771 err = rem_mcg_res(dev, slave, rqp, gid, prot, type, &reg_id); 3794 err = rem_mcg_res(dev, slave, rqp, gid, prot, type, &reg_id);
3772 if (err) 3795 if (err)
3773 goto ex_put; 3796 goto ex_put;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
index 6cb24dc864ba..6e7527e2b595 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h
@@ -1722,22 +1722,6 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring)
1722 tx_ring->producer; 1722 tx_ring->producer;
1723} 1723}
1724 1724
1725static inline int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter,
1726 struct net_device *netdev)
1727{
1728 int err;
1729
1730 netdev->num_tx_queues = adapter->drv_tx_rings;
1731 netdev->real_num_tx_queues = adapter->drv_tx_rings;
1732
1733 err = netif_set_real_num_tx_queues(netdev, adapter->drv_tx_rings);
1734 if (err)
1735 netdev_err(netdev, "failed to set %d Tx queues\n",
1736 adapter->drv_tx_rings);
1737
1738 return err;
1739}
1740
1741struct qlcnic_nic_template { 1725struct qlcnic_nic_template {
1742 int (*config_bridged_mode) (struct qlcnic_adapter *, u32); 1726 int (*config_bridged_mode) (struct qlcnic_adapter *, u32);
1743 int (*config_led) (struct qlcnic_adapter *, u32, u32); 1727 int (*config_led) (struct qlcnic_adapter *, u32, u32);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 8a570fa3542b..d2e18b52caba 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -2224,6 +2224,31 @@ static void qlcnic_82xx_set_mac_filter_count(struct qlcnic_adapter *adapter)
2224 ahw->max_uc_count = count; 2224 ahw->max_uc_count = count;
2225} 2225}
2226 2226
2227static int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter,
2228 u8 tx_queues, u8 rx_queues)
2229{
2230 struct net_device *netdev = adapter->netdev;
2231 int err = 0;
2232
2233 if (tx_queues) {
2234 err = netif_set_real_num_tx_queues(netdev, tx_queues);
2235 if (err) {
2236 netdev_err(netdev, "failed to set %d Tx queues\n",
2237 tx_queues);
2238 return err;
2239 }
2240 }
2241
2242 if (rx_queues) {
2243 err = netif_set_real_num_rx_queues(netdev, rx_queues);
2244 if (err)
2245 netdev_err(netdev, "failed to set %d Rx queues\n",
2246 rx_queues);
2247 }
2248
2249 return err;
2250}
2251
2227int 2252int
2228qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev, 2253qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev,
2229 int pci_using_dac) 2254 int pci_using_dac)
@@ -2287,7 +2312,8 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev,
2287 netdev->priv_flags |= IFF_UNICAST_FLT; 2312 netdev->priv_flags |= IFF_UNICAST_FLT;
2288 netdev->irq = adapter->msix_entries[0].vector; 2313 netdev->irq = adapter->msix_entries[0].vector;
2289 2314
2290 err = qlcnic_set_real_num_queues(adapter, netdev); 2315 err = qlcnic_set_real_num_queues(adapter, adapter->drv_tx_rings,
2316 adapter->drv_sds_rings);
2291 if (err) 2317 if (err)
2292 return err; 2318 return err;
2293 2319
@@ -2392,6 +2418,14 @@ void qlcnic_set_drv_version(struct qlcnic_adapter *adapter)
2392 qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd); 2418 qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd);
2393} 2419}
2394 2420
2421/* Reset firmware API lock */
2422static void qlcnic_reset_api_lock(struct qlcnic_adapter *adapter)
2423{
2424 qlcnic_api_lock(adapter);
2425 qlcnic_api_unlock(adapter);
2426}
2427
2428
2395static int 2429static int
2396qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 2430qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2397{ 2431{
@@ -2491,6 +2525,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2491 if (qlcnic_82xx_check(adapter)) { 2525 if (qlcnic_82xx_check(adapter)) {
2492 qlcnic_check_vf(adapter, ent); 2526 qlcnic_check_vf(adapter, ent);
2493 adapter->portnum = adapter->ahw->pci_func; 2527 adapter->portnum = adapter->ahw->pci_func;
2528 qlcnic_reset_api_lock(adapter);
2494 err = qlcnic_start_firmware(adapter); 2529 err = qlcnic_start_firmware(adapter);
2495 if (err) { 2530 if (err) {
2496 dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n" 2531 dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n"
@@ -2958,9 +2993,13 @@ static void qlcnic_dump_tx_rings(struct qlcnic_adapter *adapter)
2958 tx_ring->tx_stats.xmit_called, 2993 tx_ring->tx_stats.xmit_called,
2959 tx_ring->tx_stats.xmit_on, 2994 tx_ring->tx_stats.xmit_on,
2960 tx_ring->tx_stats.xmit_off); 2995 tx_ring->tx_stats.xmit_off);
2996
2997 if (tx_ring->crb_intr_mask)
2998 netdev_info(netdev, "crb_intr_mask=%d\n",
2999 readl(tx_ring->crb_intr_mask));
3000
2961 netdev_info(netdev, 3001 netdev_info(netdev,
2962 "crb_intr_mask=%d, hw_producer=%d, sw_producer=%d sw_consumer=%d, hw_consumer=%d\n", 3002 "hw_producer=%d, sw_producer=%d sw_consumer=%d, hw_consumer=%d\n",
2963 readl(tx_ring->crb_intr_mask),
2964 readl(tx_ring->crb_cmd_producer), 3003 readl(tx_ring->crb_cmd_producer),
2965 tx_ring->producer, tx_ring->sw_consumer, 3004 tx_ring->producer, tx_ring->sw_consumer,
2966 le32_to_cpu(*(tx_ring->hw_consumer))); 3005 le32_to_cpu(*(tx_ring->hw_consumer)));
@@ -3993,12 +4032,21 @@ int qlcnic_validate_rings(struct qlcnic_adapter *adapter, __u32 ring_cnt,
3993int qlcnic_setup_rings(struct qlcnic_adapter *adapter) 4032int qlcnic_setup_rings(struct qlcnic_adapter *adapter)
3994{ 4033{
3995 struct net_device *netdev = adapter->netdev; 4034 struct net_device *netdev = adapter->netdev;
4035 u8 tx_rings, rx_rings;
3996 int err; 4036 int err;
3997 4037
3998 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) 4038 if (test_bit(__QLCNIC_RESETTING, &adapter->state))
3999 return -EBUSY; 4039 return -EBUSY;
4000 4040
4041 tx_rings = adapter->drv_tss_rings;
4042 rx_rings = adapter->drv_rss_rings;
4043
4001 netif_device_detach(netdev); 4044 netif_device_detach(netdev);
4045
4046 err = qlcnic_set_real_num_queues(adapter, tx_rings, rx_rings);
4047 if (err)
4048 goto done;
4049
4002 if (netif_running(netdev)) 4050 if (netif_running(netdev))
4003 __qlcnic_down(adapter, netdev); 4051 __qlcnic_down(adapter, netdev);
4004 4052
@@ -4018,7 +4066,17 @@ int qlcnic_setup_rings(struct qlcnic_adapter *adapter)
4018 return err; 4066 return err;
4019 } 4067 }
4020 4068
4021 netif_set_real_num_tx_queues(netdev, adapter->drv_tx_rings); 4069 /* Check if we need to update real_num_{tx|rx}_queues because
4070 * qlcnic_setup_intr() may change Tx/Rx rings size
4071 */
4072 if ((tx_rings != adapter->drv_tx_rings) ||
4073 (rx_rings != adapter->drv_sds_rings)) {
4074 err = qlcnic_set_real_num_queues(adapter,
4075 adapter->drv_tx_rings,
4076 adapter->drv_sds_rings);
4077 if (err)
4078 goto done;
4079 }
4022 4080
4023 if (qlcnic_83xx_check(adapter)) { 4081 if (qlcnic_83xx_check(adapter)) {
4024 qlcnic_83xx_initialize_nic(adapter, 1); 4082 qlcnic_83xx_initialize_nic(adapter, 1);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
index 3b39ab2ad5e9..498fa6350c8d 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
@@ -1376,7 +1376,7 @@ static int __qlcnic_sriov_issue_cmd(struct qlcnic_adapter *adapter,
1376 1376
1377 rsp = qlcnic_sriov_alloc_bc_trans(&trans); 1377 rsp = qlcnic_sriov_alloc_bc_trans(&trans);
1378 if (rsp) 1378 if (rsp)
1379 return rsp; 1379 goto free_cmd;
1380 1380
1381 rsp = qlcnic_sriov_prepare_bc_hdr(trans, cmd, seq, QLC_BC_COMMAND); 1381 rsp = qlcnic_sriov_prepare_bc_hdr(trans, cmd, seq, QLC_BC_COMMAND);
1382 if (rsp) 1382 if (rsp)
@@ -1436,6 +1436,13 @@ err_out:
1436 1436
1437cleanup_transaction: 1437cleanup_transaction:
1438 qlcnic_sriov_cleanup_transaction(trans); 1438 qlcnic_sriov_cleanup_transaction(trans);
1439
1440free_cmd:
1441 if (cmd->type == QLC_83XX_MBX_CMD_NO_WAIT) {
1442 qlcnic_free_mbx_args(cmd);
1443 kfree(cmd);
1444 }
1445
1439 return rsp; 1446 return rsp;
1440} 1447}
1441 1448
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
index 6203c7d8550f..45019649bbbd 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_common.h
@@ -358,6 +358,8 @@ struct sxgbe_core_ops {
358 /* Enable disable checksum offload operations */ 358 /* Enable disable checksum offload operations */
359 void (*enable_rx_csum)(void __iomem *ioaddr); 359 void (*enable_rx_csum)(void __iomem *ioaddr);
360 void (*disable_rx_csum)(void __iomem *ioaddr); 360 void (*disable_rx_csum)(void __iomem *ioaddr);
361 void (*enable_rxqueue)(void __iomem *ioaddr, int queue_num);
362 void (*disable_rxqueue)(void __iomem *ioaddr, int queue_num);
361}; 363};
362 364
363const struct sxgbe_core_ops *sxgbe_get_core_ops(void); 365const struct sxgbe_core_ops *sxgbe_get_core_ops(void);
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c
index c4da7a2b002a..58c35692560e 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_core.c
@@ -165,6 +165,26 @@ static void sxgbe_core_set_speed(void __iomem *ioaddr, unsigned char speed)
165 writel(tx_cfg, ioaddr + SXGBE_CORE_TX_CONFIG_REG); 165 writel(tx_cfg, ioaddr + SXGBE_CORE_TX_CONFIG_REG);
166} 166}
167 167
168static void sxgbe_core_enable_rxqueue(void __iomem *ioaddr, int queue_num)
169{
170 u32 reg_val;
171
172 reg_val = readl(ioaddr + SXGBE_CORE_RX_CTL0_REG);
173 reg_val &= ~(SXGBE_CORE_RXQ_ENABLE_MASK << queue_num);
174 reg_val |= SXGBE_CORE_RXQ_ENABLE;
175 writel(reg_val, ioaddr + SXGBE_CORE_RX_CTL0_REG);
176}
177
178static void sxgbe_core_disable_rxqueue(void __iomem *ioaddr, int queue_num)
179{
180 u32 reg_val;
181
182 reg_val = readl(ioaddr + SXGBE_CORE_RX_CTL0_REG);
183 reg_val &= ~(SXGBE_CORE_RXQ_ENABLE_MASK << queue_num);
184 reg_val |= SXGBE_CORE_RXQ_DISABLE;
185 writel(reg_val, ioaddr + SXGBE_CORE_RX_CTL0_REG);
186}
187
168static void sxgbe_set_eee_mode(void __iomem *ioaddr) 188static void sxgbe_set_eee_mode(void __iomem *ioaddr)
169{ 189{
170 u32 ctrl; 190 u32 ctrl;
@@ -254,6 +274,8 @@ static const struct sxgbe_core_ops core_ops = {
254 .set_eee_pls = sxgbe_set_eee_pls, 274 .set_eee_pls = sxgbe_set_eee_pls,
255 .enable_rx_csum = sxgbe_enable_rx_csum, 275 .enable_rx_csum = sxgbe_enable_rx_csum,
256 .disable_rx_csum = sxgbe_disable_rx_csum, 276 .disable_rx_csum = sxgbe_disable_rx_csum,
277 .enable_rxqueue = sxgbe_core_enable_rxqueue,
278 .disable_rxqueue = sxgbe_core_disable_rxqueue,
257}; 279};
258 280
259const struct sxgbe_core_ops *sxgbe_get_core_ops(void) 281const struct sxgbe_core_ops *sxgbe_get_core_ops(void)
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
index d71691be4136..2686bb5b6765 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.c
@@ -233,6 +233,12 @@ static void sxgbe_set_rx_owner(struct sxgbe_rx_norm_desc *p)
233 p->rdes23.rx_rd_des23.own_bit = 1; 233 p->rdes23.rx_rd_des23.own_bit = 1;
234} 234}
235 235
236/* Set Interrupt on completion bit */
237static void sxgbe_set_rx_int_on_com(struct sxgbe_rx_norm_desc *p)
238{
239 p->rdes23.rx_rd_des23.int_on_com = 1;
240}
241
236/* Get the receive frame size */ 242/* Get the receive frame size */
237static int sxgbe_get_rx_frame_len(struct sxgbe_rx_norm_desc *p) 243static int sxgbe_get_rx_frame_len(struct sxgbe_rx_norm_desc *p)
238{ 244{
@@ -498,6 +504,7 @@ static const struct sxgbe_desc_ops desc_ops = {
498 .init_rx_desc = sxgbe_init_rx_desc, 504 .init_rx_desc = sxgbe_init_rx_desc,
499 .get_rx_owner = sxgbe_get_rx_owner, 505 .get_rx_owner = sxgbe_get_rx_owner,
500 .set_rx_owner = sxgbe_set_rx_owner, 506 .set_rx_owner = sxgbe_set_rx_owner,
507 .set_rx_int_on_com = sxgbe_set_rx_int_on_com,
501 .get_rx_frame_len = sxgbe_get_rx_frame_len, 508 .get_rx_frame_len = sxgbe_get_rx_frame_len,
502 .get_rx_fd_status = sxgbe_get_rx_fd_status, 509 .get_rx_fd_status = sxgbe_get_rx_fd_status,
503 .get_rx_ld_status = sxgbe_get_rx_ld_status, 510 .get_rx_ld_status = sxgbe_get_rx_ld_status,
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h
index 022630098aea..18609324db72 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_desc.h
@@ -258,6 +258,9 @@ struct sxgbe_desc_ops {
258 /* Set own bit */ 258 /* Set own bit */
259 void (*set_rx_owner)(struct sxgbe_rx_norm_desc *p); 259 void (*set_rx_owner)(struct sxgbe_rx_norm_desc *p);
260 260
261 /* Set Interrupt on completion bit */
262 void (*set_rx_int_on_com)(struct sxgbe_rx_norm_desc *p);
263
261 /* Get the receive frame size */ 264 /* Get the receive frame size */
262 int (*get_rx_frame_len)(struct sxgbe_rx_norm_desc *p); 265 int (*get_rx_frame_len)(struct sxgbe_rx_norm_desc *p);
263 266
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c
index 4d989ff6c978..bb9b5b8afc5f 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_dma.c
@@ -23,21 +23,8 @@
23/* DMA core initialization */ 23/* DMA core initialization */
24static int sxgbe_dma_init(void __iomem *ioaddr, int fix_burst, int burst_map) 24static int sxgbe_dma_init(void __iomem *ioaddr, int fix_burst, int burst_map)
25{ 25{
26 int retry_count = 10;
27 u32 reg_val; 26 u32 reg_val;
28 27
29 /* reset the DMA */
30 writel(SXGBE_DMA_SOFT_RESET, ioaddr + SXGBE_DMA_MODE_REG);
31 while (retry_count--) {
32 if (!(readl(ioaddr + SXGBE_DMA_MODE_REG) &
33 SXGBE_DMA_SOFT_RESET))
34 break;
35 mdelay(10);
36 }
37
38 if (retry_count < 0)
39 return -EBUSY;
40
41 reg_val = readl(ioaddr + SXGBE_DMA_SYSBUS_MODE_REG); 28 reg_val = readl(ioaddr + SXGBE_DMA_SYSBUS_MODE_REG);
42 29
43 /* if fix_burst = 0, Set UNDEF = 1 of DMA_Sys_Mode Register. 30 /* if fix_burst = 0, Set UNDEF = 1 of DMA_Sys_Mode Register.
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 137f366ec7e4..698494481d18 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -1076,6 +1076,9 @@ static int sxgbe_open(struct net_device *dev)
1076 1076
1077 /* Initialize the MAC Core */ 1077 /* Initialize the MAC Core */
1078 priv->hw->mac->core_init(priv->ioaddr); 1078 priv->hw->mac->core_init(priv->ioaddr);
1079 SXGBE_FOR_EACH_QUEUE(SXGBE_RX_QUEUES, queue_num) {
1080 priv->hw->mac->enable_rxqueue(priv->ioaddr, queue_num);
1081 }
1079 1082
1080 /* Request the IRQ lines */ 1083 /* Request the IRQ lines */
1081 ret = devm_request_irq(priv->device, priv->irq, sxgbe_common_interrupt, 1084 ret = devm_request_irq(priv->device, priv->irq, sxgbe_common_interrupt,
@@ -1452,6 +1455,7 @@ static void sxgbe_rx_refill(struct sxgbe_priv_data *priv)
1452 /* Added memory barrier for RX descriptor modification */ 1455 /* Added memory barrier for RX descriptor modification */
1453 wmb(); 1456 wmb();
1454 priv->hw->desc->set_rx_owner(p); 1457 priv->hw->desc->set_rx_owner(p);
1458 priv->hw->desc->set_rx_int_on_com(p);
1455 /* Added memory barrier for RX descriptor modification */ 1459 /* Added memory barrier for RX descriptor modification */
1456 wmb(); 1460 wmb();
1457 } 1461 }
@@ -2034,6 +2038,24 @@ static int sxgbe_hw_init(struct sxgbe_priv_data * const priv)
2034 return 0; 2038 return 0;
2035} 2039}
2036 2040
2041static int sxgbe_sw_reset(void __iomem *addr)
2042{
2043 int retry_count = 10;
2044
2045 writel(SXGBE_DMA_SOFT_RESET, addr + SXGBE_DMA_MODE_REG);
2046 while (retry_count--) {
2047 if (!(readl(addr + SXGBE_DMA_MODE_REG) &
2048 SXGBE_DMA_SOFT_RESET))
2049 break;
2050 mdelay(10);
2051 }
2052
2053 if (retry_count < 0)
2054 return -EBUSY;
2055
2056 return 0;
2057}
2058
2037/** 2059/**
2038 * sxgbe_drv_probe 2060 * sxgbe_drv_probe
2039 * @device: device pointer 2061 * @device: device pointer
@@ -2066,6 +2088,10 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
2066 priv->plat = plat_dat; 2088 priv->plat = plat_dat;
2067 priv->ioaddr = addr; 2089 priv->ioaddr = addr;
2068 2090
2091 ret = sxgbe_sw_reset(priv->ioaddr);
2092 if (ret)
2093 goto error_free_netdev;
2094
2069 /* Verify driver arguments */ 2095 /* Verify driver arguments */
2070 sxgbe_verify_args(); 2096 sxgbe_verify_args();
2071 2097
@@ -2182,9 +2208,14 @@ error_free_netdev:
2182int sxgbe_drv_remove(struct net_device *ndev) 2208int sxgbe_drv_remove(struct net_device *ndev)
2183{ 2209{
2184 struct sxgbe_priv_data *priv = netdev_priv(ndev); 2210 struct sxgbe_priv_data *priv = netdev_priv(ndev);
2211 u8 queue_num;
2185 2212
2186 netdev_info(ndev, "%s: removing driver\n", __func__); 2213 netdev_info(ndev, "%s: removing driver\n", __func__);
2187 2214
2215 SXGBE_FOR_EACH_QUEUE(SXGBE_RX_QUEUES, queue_num) {
2216 priv->hw->mac->disable_rxqueue(priv->ioaddr, queue_num);
2217 }
2218
2188 priv->hw->dma->stop_rx(priv->ioaddr, SXGBE_RX_QUEUES); 2219 priv->hw->dma->stop_rx(priv->ioaddr, SXGBE_RX_QUEUES);
2189 priv->hw->dma->stop_tx(priv->ioaddr, SXGBE_TX_QUEUES); 2220 priv->hw->dma->stop_tx(priv->ioaddr, SXGBE_TX_QUEUES);
2190 2221
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h b/drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h
index 5a89acb4c505..56f8bf5a3f1b 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_reg.h
@@ -52,6 +52,10 @@
52#define SXGBE_CORE_RX_CTL2_REG 0x00A8 52#define SXGBE_CORE_RX_CTL2_REG 0x00A8
53#define SXGBE_CORE_RX_CTL3_REG 0x00AC 53#define SXGBE_CORE_RX_CTL3_REG 0x00AC
54 54
55#define SXGBE_CORE_RXQ_ENABLE_MASK 0x0003
56#define SXGBE_CORE_RXQ_ENABLE 0x0002
57#define SXGBE_CORE_RXQ_DISABLE 0x0000
58
55/* Interrupt Registers */ 59/* Interrupt Registers */
56#define SXGBE_CORE_INT_STATUS_REG 0x00B0 60#define SXGBE_CORE_INT_STATUS_REG 0x00B0
57#define SXGBE_CORE_INT_ENABLE_REG 0x00B4 61#define SXGBE_CORE_INT_ENABLE_REG 0x00B4
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index df8d383acf48..b9ac20f42651 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -246,7 +246,7 @@ static inline void cas_lock_tx(struct cas *cp)
246 int i; 246 int i;
247 247
248 for (i = 0; i < N_TX_RINGS; i++) 248 for (i = 0; i < N_TX_RINGS; i++)
249 spin_lock(&cp->tx_lock[i]); 249 spin_lock_nested(&cp->tx_lock[i], i);
250} 250}
251 251
252static inline void cas_lock_all(struct cas *cp) 252static inline void cas_lock_all(struct cas *cp)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index d14c8da53160..91499be03c6f 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1899,18 +1899,13 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1899 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 1899 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
1900 phyid = be32_to_cpup(parp+1); 1900 phyid = be32_to_cpup(parp+1);
1901 mdio = of_find_device_by_node(mdio_node); 1901 mdio = of_find_device_by_node(mdio_node);
1902 1902 of_node_put(mdio_node);
1903 if (strncmp(mdio->name, "gpio", 4) == 0) { 1903 if (!mdio) {
1904 /* GPIO bitbang MDIO driver attached */ 1904 pr_err("Missing mdio platform device\n");
1905 struct mii_bus *bus = dev_get_drvdata(&mdio->dev); 1905 return -EINVAL;
1906
1907 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1908 PHY_ID_FMT, bus->id, phyid);
1909 } else {
1910 /* davinci MDIO driver attached */
1911 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1912 PHY_ID_FMT, mdio->name, phyid);
1913 } 1906 }
1907 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1908 PHY_ID_FMT, mdio->name, phyid);
1914 1909
1915 mac_addr = of_get_mac_address(slave_node); 1910 mac_addr = of_get_mac_address(slave_node);
1916 if (mac_addr) 1911 if (mac_addr)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 083d084396d3..1de3ef5dd5d2 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -467,6 +467,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
467 if (skb_is_gso(skb)) 467 if (skb_is_gso(skb))
468 goto do_lso; 468 goto do_lso;
469 469
470 if ((skb->ip_summed == CHECKSUM_NONE) ||
471 (skb->ip_summed == CHECKSUM_UNNECESSARY))
472 goto do_send;
473
470 rndis_msg_size += NDIS_CSUM_PPI_SIZE; 474 rndis_msg_size += NDIS_CSUM_PPI_SIZE;
471 ppi = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE, 475 ppi = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE,
472 TCPIP_CHKSUM_PKTINFO); 476 TCPIP_CHKSUM_PKTINFO);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index cfb27c865417..f0118d1a3e46 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -332,11 +332,9 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
332 const struct macvlan_dev *vlan = netdev_priv(dev); 332 const struct macvlan_dev *vlan = netdev_priv(dev);
333 const struct macvlan_port *port = vlan->port; 333 const struct macvlan_port *port = vlan->port;
334 const struct macvlan_dev *dest; 334 const struct macvlan_dev *dest;
335 __u8 ip_summed = skb->ip_summed;
336 335
337 if (vlan->mode == MACVLAN_MODE_BRIDGE) { 336 if (vlan->mode == MACVLAN_MODE_BRIDGE) {
338 const struct ethhdr *eth = (void *)skb->data; 337 const struct ethhdr *eth = (void *)skb->data;
339 skb->ip_summed = CHECKSUM_UNNECESSARY;
340 338
341 /* send to other bridge ports directly */ 339 /* send to other bridge ports directly */
342 if (is_multicast_ether_addr(eth->h_dest)) { 340 if (is_multicast_ether_addr(eth->h_dest)) {
@@ -354,7 +352,6 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
354 } 352 }
355 353
356xmit_world: 354xmit_world:
357 skb->ip_summed = ip_summed;
358 skb->dev = vlan->lowerdev; 355 skb->dev = vlan->lowerdev;
359 return dev_queue_xmit(skb); 356 return dev_queue_xmit(skb);
360} 357}
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index ff111a89e17f..3381c4f91a8c 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -322,6 +322,15 @@ static rx_handler_result_t macvtap_handle_frame(struct sk_buff **pskb)
322 segs = nskb; 322 segs = nskb;
323 } 323 }
324 } else { 324 } else {
325 /* If we receive a partial checksum and the tap side
326 * doesn't support checksum offload, compute the checksum.
327 * Note: it doesn't matter which checksum feature to
328 * check, we either support them all or none.
329 */
330 if (skb->ip_summed == CHECKSUM_PARTIAL &&
331 !(features & NETIF_F_ALL_CSUM) &&
332 skb_checksum_help(skb))
333 goto drop;
325 skb_queue_tail(&q->sk.sk_receive_queue, skb); 334 skb_queue_tail(&q->sk.sk_receive_queue, skb);
326 } 335 }
327 336
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 9c4defdec67b..5f1a2250018f 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -215,6 +215,10 @@ static int mdio_gpio_probe(struct platform_device *pdev)
215 if (pdev->dev.of_node) { 215 if (pdev->dev.of_node) {
216 pdata = mdio_gpio_of_get_data(pdev); 216 pdata = mdio_gpio_of_get_data(pdev);
217 bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio"); 217 bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio");
218 if (bus_id < 0) {
219 dev_warn(&pdev->dev, "failed to get alias id\n");
220 bus_id = 0;
221 }
218 } else { 222 } else {
219 pdata = dev_get_platdata(&pdev->dev); 223 pdata = dev_get_platdata(&pdev->dev);
220 bus_id = pdev->id; 224 bus_id = pdev->id;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1b6d09aef427..a972056b2249 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -765,6 +765,17 @@ void phy_state_machine(struct work_struct *work)
765 break; 765 break;
766 766
767 if (phydev->link) { 767 if (phydev->link) {
768 if (AUTONEG_ENABLE == phydev->autoneg) {
769 err = phy_aneg_done(phydev);
770 if (err < 0)
771 break;
772
773 if (!err) {
774 phydev->state = PHY_AN;
775 phydev->link_timeout = PHY_AN_TIMEOUT;
776 break;
777 }
778 }
768 phydev->state = PHY_RUNNING; 779 phydev->state = PHY_RUNNING;
769 netif_carrier_on(phydev->attached_dev); 780 netif_carrier_on(phydev->attached_dev);
770 phydev->adjust_link(phydev->attached_dev); 781 phydev->adjust_link(phydev->attached_dev);
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index cc70ecfc7062..ad4a94e9ff57 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -429,13 +429,13 @@ static void slip_write_wakeup(struct tty_struct *tty)
429 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) 429 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
430 return; 430 return;
431 431
432 spin_lock(&sl->lock); 432 spin_lock_bh(&sl->lock);
433 if (sl->xleft <= 0) { 433 if (sl->xleft <= 0) {
434 /* Now serial buffer is almost free & we can start 434 /* Now serial buffer is almost free & we can start
435 * transmission of another packet */ 435 * transmission of another packet */
436 sl->dev->stats.tx_packets++; 436 sl->dev->stats.tx_packets++;
437 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 437 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
438 spin_unlock(&sl->lock); 438 spin_unlock_bh(&sl->lock);
439 sl_unlock(sl); 439 sl_unlock(sl);
440 return; 440 return;
441 } 441 }
@@ -443,7 +443,7 @@ static void slip_write_wakeup(struct tty_struct *tty)
443 actual = tty->ops->write(tty, sl->xhead, sl->xleft); 443 actual = tty->ops->write(tty, sl->xhead, sl->xleft);
444 sl->xleft -= actual; 444 sl->xleft -= actual;
445 sl->xhead += actual; 445 sl->xhead += actual;
446 spin_unlock(&sl->lock); 446 spin_unlock_bh(&sl->lock);
447} 447}
448 448
449static void sl_tx_timeout(struct net_device *dev) 449static void sl_tx_timeout(struct net_device *dev)
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 33008c1d1d67..767fe61b5ac9 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2834,8 +2834,10 @@ static int team_device_event(struct notifier_block *unused,
2834 case NETDEV_UP: 2834 case NETDEV_UP:
2835 if (netif_carrier_ok(dev)) 2835 if (netif_carrier_ok(dev))
2836 team_port_change_check(port, true); 2836 team_port_change_check(port, true);
2837 break;
2837 case NETDEV_DOWN: 2838 case NETDEV_DOWN:
2838 team_port_change_check(port, false); 2839 team_port_change_check(port, false);
2840 break;
2839 case NETDEV_CHANGE: 2841 case NETDEV_CHANGE:
2840 if (netif_running(port->dev)) 2842 if (netif_running(port->dev))
2841 team_port_change_check(port, 2843 team_port_change_check(port,
diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
index c9f3281506af..2e025ddcef21 100644
--- a/drivers/net/usb/cdc_mbim.c
+++ b/drivers/net/usb/cdc_mbim.c
@@ -120,6 +120,16 @@ static void cdc_mbim_unbind(struct usbnet *dev, struct usb_interface *intf)
120 cdc_ncm_unbind(dev, intf); 120 cdc_ncm_unbind(dev, intf);
121} 121}
122 122
123/* verify that the ethernet protocol is IPv4 or IPv6 */
124static bool is_ip_proto(__be16 proto)
125{
126 switch (proto) {
127 case htons(ETH_P_IP):
128 case htons(ETH_P_IPV6):
129 return true;
130 }
131 return false;
132}
123 133
124static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 134static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
125{ 135{
@@ -128,6 +138,7 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb
128 struct cdc_ncm_ctx *ctx = info->ctx; 138 struct cdc_ncm_ctx *ctx = info->ctx;
129 __le32 sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN); 139 __le32 sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN);
130 u16 tci = 0; 140 u16 tci = 0;
141 bool is_ip;
131 u8 *c; 142 u8 *c;
132 143
133 if (!ctx) 144 if (!ctx)
@@ -137,25 +148,32 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb
137 if (skb->len <= ETH_HLEN) 148 if (skb->len <= ETH_HLEN)
138 goto error; 149 goto error;
139 150
151 /* Some applications using e.g. packet sockets will
152 * bypass the VLAN acceleration and create tagged
153 * ethernet frames directly. We primarily look for
154 * the accelerated out-of-band tag, but fall back if
155 * required
156 */
157 skb_reset_mac_header(skb);
158 if (vlan_get_tag(skb, &tci) < 0 && skb->len > VLAN_ETH_HLEN &&
159 __vlan_get_tag(skb, &tci) == 0) {
160 is_ip = is_ip_proto(vlan_eth_hdr(skb)->h_vlan_encapsulated_proto);
161 skb_pull(skb, VLAN_ETH_HLEN);
162 } else {
163 is_ip = is_ip_proto(eth_hdr(skb)->h_proto);
164 skb_pull(skb, ETH_HLEN);
165 }
166
140 /* mapping VLANs to MBIM sessions: 167 /* mapping VLANs to MBIM sessions:
141 * no tag => IPS session <0> 168 * no tag => IPS session <0>
142 * 1 - 255 => IPS session <vlanid> 169 * 1 - 255 => IPS session <vlanid>
143 * 256 - 511 => DSS session <vlanid - 256> 170 * 256 - 511 => DSS session <vlanid - 256>
144 * 512 - 4095 => unsupported, drop 171 * 512 - 4095 => unsupported, drop
145 */ 172 */
146 vlan_get_tag(skb, &tci);
147
148 switch (tci & 0x0f00) { 173 switch (tci & 0x0f00) {
149 case 0x0000: /* VLAN ID 0 - 255 */ 174 case 0x0000: /* VLAN ID 0 - 255 */
150 /* verify that datagram is IPv4 or IPv6 */ 175 if (!is_ip)
151 skb_reset_mac_header(skb);
152 switch (eth_hdr(skb)->h_proto) {
153 case htons(ETH_P_IP):
154 case htons(ETH_P_IPV6):
155 break;
156 default:
157 goto error; 176 goto error;
158 }
159 c = (u8 *)&sign; 177 c = (u8 *)&sign;
160 c[3] = tci; 178 c[3] = tci;
161 break; 179 break;
@@ -169,7 +187,6 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb
169 "unsupported tci=0x%04x\n", tci); 187 "unsupported tci=0x%04x\n", tci);
170 goto error; 188 goto error;
171 } 189 }
172 skb_pull(skb, ETH_HLEN);
173 } 190 }
174 191
175 spin_lock_bh(&ctx->mtx); 192 spin_lock_bh(&ctx->mtx);
@@ -204,17 +221,23 @@ static void do_neigh_solicit(struct usbnet *dev, u8 *buf, u16 tci)
204 return; 221 return;
205 222
206 /* need to send the NA on the VLAN dev, if any */ 223 /* need to send the NA on the VLAN dev, if any */
207 if (tci) 224 rcu_read_lock();
225 if (tci) {
208 netdev = __vlan_find_dev_deep(dev->net, htons(ETH_P_8021Q), 226 netdev = __vlan_find_dev_deep(dev->net, htons(ETH_P_8021Q),
209 tci); 227 tci);
210 else 228 if (!netdev) {
229 rcu_read_unlock();
230 return;
231 }
232 } else {
211 netdev = dev->net; 233 netdev = dev->net;
212 if (!netdev) 234 }
213 return; 235 dev_hold(netdev);
236 rcu_read_unlock();
214 237
215 in6_dev = in6_dev_get(netdev); 238 in6_dev = in6_dev_get(netdev);
216 if (!in6_dev) 239 if (!in6_dev)
217 return; 240 goto out;
218 is_router = !!in6_dev->cnf.forwarding; 241 is_router = !!in6_dev->cnf.forwarding;
219 in6_dev_put(in6_dev); 242 in6_dev_put(in6_dev);
220 243
@@ -224,6 +247,8 @@ static void do_neigh_solicit(struct usbnet *dev, u8 *buf, u16 tci)
224 true /* solicited */, 247 true /* solicited */,
225 false /* override */, 248 false /* override */,
226 true /* inc_opt */); 249 true /* inc_opt */);
250out:
251 dev_put(netdev);
227} 252}
228 253
229static bool is_neigh_solicit(u8 *buf, size_t len) 254static bool is_neigh_solicit(u8 *buf, size_t len)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 549dbac710ed..9a2bd11943eb 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -785,7 +785,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
785 skb_out->len > CDC_NCM_MIN_TX_PKT) 785 skb_out->len > CDC_NCM_MIN_TX_PKT)
786 memset(skb_put(skb_out, ctx->tx_max - skb_out->len), 0, 786 memset(skb_put(skb_out, ctx->tx_max - skb_out->len), 0,
787 ctx->tx_max - skb_out->len); 787 ctx->tx_max - skb_out->len);
788 else if ((skb_out->len % dev->maxpacket) == 0) 788 else if (skb_out->len < ctx->tx_max && (skb_out->len % dev->maxpacket) == 0)
789 *skb_put(skb_out, 1) = 0; /* force short packet */ 789 *skb_put(skb_out, 1) = 0; /* force short packet */
790 790
791 /* set final frame length */ 791 /* set final frame length */
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index e3458e3c44f1..83208d4fdc59 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -669,6 +669,22 @@ static const struct usb_device_id products[] = {
669 {QMI_FIXED_INTF(0x05c6, 0x920d, 5)}, 669 {QMI_FIXED_INTF(0x05c6, 0x920d, 5)},
670 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ 670 {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */
671 {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */ 671 {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */
672 {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */
673 {QMI_FIXED_INTF(0x16d8, 0x6007, 0)}, /* CMOTech CHE-628S */
674 {QMI_FIXED_INTF(0x16d8, 0x6008, 0)}, /* CMOTech CMU-301 */
675 {QMI_FIXED_INTF(0x16d8, 0x6280, 0)}, /* CMOTech CHU-628 */
676 {QMI_FIXED_INTF(0x16d8, 0x7001, 0)}, /* CMOTech CHU-720S */
677 {QMI_FIXED_INTF(0x16d8, 0x7002, 0)}, /* CMOTech 7002 */
678 {QMI_FIXED_INTF(0x16d8, 0x7003, 4)}, /* CMOTech CHU-629K */
679 {QMI_FIXED_INTF(0x16d8, 0x7004, 3)}, /* CMOTech 7004 */
680 {QMI_FIXED_INTF(0x16d8, 0x7006, 5)}, /* CMOTech CGU-629 */
681 {QMI_FIXED_INTF(0x16d8, 0x700a, 4)}, /* CMOTech CHU-629S */
682 {QMI_FIXED_INTF(0x16d8, 0x7211, 0)}, /* CMOTech CHU-720I */
683 {QMI_FIXED_INTF(0x16d8, 0x7212, 0)}, /* CMOTech 7212 */
684 {QMI_FIXED_INTF(0x16d8, 0x7213, 0)}, /* CMOTech 7213 */
685 {QMI_FIXED_INTF(0x16d8, 0x7251, 1)}, /* CMOTech 7251 */
686 {QMI_FIXED_INTF(0x16d8, 0x7252, 1)}, /* CMOTech 7252 */
687 {QMI_FIXED_INTF(0x16d8, 0x7253, 1)}, /* CMOTech 7253 */
672 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)}, 688 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
673 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)}, 689 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
674 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)}, 690 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
@@ -730,16 +746,28 @@ static const struct usb_device_id products[] = {
730 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ 746 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
731 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */ 747 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
732 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */ 748 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
749 {QMI_FIXED_INTF(0x1199, 0x68c0, 8)}, /* Sierra Wireless MC73xx */
750 {QMI_FIXED_INTF(0x1199, 0x68c0, 10)}, /* Sierra Wireless MC73xx */
751 {QMI_FIXED_INTF(0x1199, 0x68c0, 11)}, /* Sierra Wireless MC73xx */
733 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */ 752 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
753 {QMI_FIXED_INTF(0x1199, 0x901f, 8)}, /* Sierra Wireless EM7355 */
754 {QMI_FIXED_INTF(0x1199, 0x9041, 8)}, /* Sierra Wireless MC7305/MC7355 */
734 {QMI_FIXED_INTF(0x1199, 0x9051, 8)}, /* Netgear AirCard 340U */ 755 {QMI_FIXED_INTF(0x1199, 0x9051, 8)}, /* Netgear AirCard 340U */
735 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 756 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
757 {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */
736 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ 758 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
737 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ 759 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
738 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */ 760 {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)}, /* Telit LE920 */
739 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ 761 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
740 {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */ 762 {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */
763 {QMI_FIXED_INTF(0x0b3c, 0xc00b, 4)}, /* Olivetti Olicard 500 */
741 {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ 764 {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */
742 {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */ 765 {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */
766 {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
767 {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
768 {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
769 {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
770 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
743 771
744 /* 4. Gobi 1000 devices */ 772 /* 4. Gobi 1000 devices */
745 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 773 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c
index a0398fe3eb28..be3eb2a8d602 100644
--- a/drivers/net/wireless/ath/ath9k/ahb.c
+++ b/drivers/net/wireless/ath/ath9k/ahb.c
@@ -86,7 +86,6 @@ static int ath_ahb_probe(struct platform_device *pdev)
86 int irq; 86 int irq;
87 int ret = 0; 87 int ret = 0;
88 struct ath_hw *ah; 88 struct ath_hw *ah;
89 struct ath_common *common;
90 char hw_name[64]; 89 char hw_name[64];
91 90
92 if (!dev_get_platdata(&pdev->dev)) { 91 if (!dev_get_platdata(&pdev->dev)) {
@@ -146,9 +145,6 @@ static int ath_ahb_probe(struct platform_device *pdev)
146 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n", 145 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
147 hw_name, (unsigned long)mem, irq); 146 hw_name, (unsigned long)mem, irq);
148 147
149 common = ath9k_hw_common(sc->sc_ah);
150 /* Will be cleared in ath9k_start() */
151 set_bit(ATH_OP_INVALID, &common->op_flags);
152 return 0; 148 return 0;
153 149
154 err_irq: 150 err_irq:
diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c
index 6d47783f2e5b..ba502a2d199b 100644
--- a/drivers/net/wireless/ath/ath9k/ani.c
+++ b/drivers/net/wireless/ath/ath9k/ani.c
@@ -155,6 +155,9 @@ static void ath9k_hw_set_ofdm_nil(struct ath_hw *ah, u8 immunityLevel,
155 ATH9K_ANI_RSSI_THR_LOW, 155 ATH9K_ANI_RSSI_THR_LOW,
156 ATH9K_ANI_RSSI_THR_HIGH); 156 ATH9K_ANI_RSSI_THR_HIGH);
157 157
158 if (AR_SREV_9100(ah) && immunityLevel < ATH9K_ANI_OFDM_DEF_LEVEL)
159 immunityLevel = ATH9K_ANI_OFDM_DEF_LEVEL;
160
158 if (!scan) 161 if (!scan)
159 aniState->ofdmNoiseImmunityLevel = immunityLevel; 162 aniState->ofdmNoiseImmunityLevel = immunityLevel;
160 163
@@ -235,6 +238,9 @@ static void ath9k_hw_set_cck_nil(struct ath_hw *ah, u_int8_t immunityLevel,
235 BEACON_RSSI(ah), ATH9K_ANI_RSSI_THR_LOW, 238 BEACON_RSSI(ah), ATH9K_ANI_RSSI_THR_LOW,
236 ATH9K_ANI_RSSI_THR_HIGH); 239 ATH9K_ANI_RSSI_THR_HIGH);
237 240
241 if (AR_SREV_9100(ah) && immunityLevel < ATH9K_ANI_CCK_DEF_LEVEL)
242 immunityLevel = ATH9K_ANI_CCK_DEF_LEVEL;
243
238 if (ah->opmode == NL80211_IFTYPE_STATION && 244 if (ah->opmode == NL80211_IFTYPE_STATION &&
239 BEACON_RSSI(ah) <= ATH9K_ANI_RSSI_THR_LOW && 245 BEACON_RSSI(ah) <= ATH9K_ANI_RSSI_THR_LOW &&
240 immunityLevel > ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI) 246 immunityLevel > ATH9K_ANI_CCK_MAX_LEVEL_LOW_RSSI)
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 05935f638525..33a2ae77b595 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -254,7 +254,6 @@ struct ath_atx_tid {
254 254
255 s8 bar_index; 255 s8 bar_index;
256 bool sched; 256 bool sched;
257 bool paused;
258 bool active; 257 bool active;
259}; 258};
260 259
diff --git a/drivers/net/wireless/ath/ath9k/debug_sta.c b/drivers/net/wireless/ath/ath9k/debug_sta.c
index d76e6e0120d2..ffca918ff16a 100644
--- a/drivers/net/wireless/ath/ath9k/debug_sta.c
+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
@@ -72,7 +72,7 @@ static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
72 ath_txq_lock(sc, txq); 72 ath_txq_lock(sc, txq);
73 if (tid->active) { 73 if (tid->active) {
74 len += scnprintf(buf + len, size - len, 74 len += scnprintf(buf + len, size - len,
75 "%3d%11d%10d%10d%10d%10d%9d%6d%8d\n", 75 "%3d%11d%10d%10d%10d%10d%9d%6d\n",
76 tid->tidno, 76 tid->tidno,
77 tid->seq_start, 77 tid->seq_start,
78 tid->seq_next, 78 tid->seq_next,
@@ -80,8 +80,7 @@ static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
80 tid->baw_head, 80 tid->baw_head,
81 tid->baw_tail, 81 tid->baw_tail,
82 tid->bar_index, 82 tid->bar_index,
83 tid->sched, 83 tid->sched);
84 tid->paused);
85 } 84 }
86 ath_txq_unlock(sc, txq); 85 ath_txq_unlock(sc, txq);
87 } 86 }
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 21e174cfc909..4243509616bd 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -786,6 +786,9 @@ int ath9k_init_device(u16 devid, struct ath_softc *sc,
786 common = ath9k_hw_common(ah); 786 common = ath9k_hw_common(ah);
787 ath9k_set_hw_capab(sc, hw); 787 ath9k_set_hw_capab(sc, hw);
788 788
789 /* Will be cleared in ath9k_start() */
790 set_bit(ATH_OP_INVALID, &common->op_flags);
791
789 /* Initialize regulatory */ 792 /* Initialize regulatory */
790 error = ath_regd_init(&common->regulatory, sc->hw->wiphy, 793 error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
791 ath9k_reg_notifier); 794 ath9k_reg_notifier);
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 25304adece57..914dbc6b1720 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -784,7 +784,6 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
784{ 784{
785 struct ath_softc *sc; 785 struct ath_softc *sc;
786 struct ieee80211_hw *hw; 786 struct ieee80211_hw *hw;
787 struct ath_common *common;
788 u8 csz; 787 u8 csz;
789 u32 val; 788 u32 val;
790 int ret = 0; 789 int ret = 0;
@@ -877,10 +876,6 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
877 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n", 876 wiphy_info(hw->wiphy, "%s mem=0x%lx, irq=%d\n",
878 hw_name, (unsigned long)sc->mem, pdev->irq); 877 hw_name, (unsigned long)sc->mem, pdev->irq);
879 878
880 /* Will be cleared in ath9k_start() */
881 common = ath9k_hw_common(sc->sc_ah);
882 set_bit(ATH_OP_INVALID, &common->op_flags);
883
884 return 0; 879 return 0;
885 880
886err_init: 881err_init:
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index a01efd3e741e..441c71448e4c 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -978,6 +978,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
978 u64 tsf = 0; 978 u64 tsf = 0;
979 unsigned long flags; 979 unsigned long flags;
980 dma_addr_t new_buf_addr; 980 dma_addr_t new_buf_addr;
981 unsigned int budget = 512;
981 982
982 if (edma) 983 if (edma)
983 dma_type = DMA_BIDIRECTIONAL; 984 dma_type = DMA_BIDIRECTIONAL;
@@ -1116,15 +1117,17 @@ requeue_drop_frag:
1116 } 1117 }
1117requeue: 1118requeue:
1118 list_add_tail(&bf->list, &sc->rx.rxbuf); 1119 list_add_tail(&bf->list, &sc->rx.rxbuf);
1119 if (flush)
1120 continue;
1121 1120
1122 if (edma) { 1121 if (edma) {
1123 ath_rx_edma_buf_link(sc, qtype); 1122 ath_rx_edma_buf_link(sc, qtype);
1124 } else { 1123 } else {
1125 ath_rx_buf_relink(sc, bf); 1124 ath_rx_buf_relink(sc, bf);
1126 ath9k_hw_rxena(ah); 1125 if (!flush)
1126 ath9k_hw_rxena(ah);
1127 } 1127 }
1128
1129 if (!budget--)
1130 break;
1128 } while (1); 1131 } while (1);
1129 1132
1130 if (!(ah->imask & ATH9K_INT_RXEOL)) { 1133 if (!(ah->imask & ATH9K_INT_RXEOL)) {
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 87cbec47fb48..66acb2cbd9df 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -107,9 +107,6 @@ static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid)
107{ 107{
108 struct ath_atx_ac *ac = tid->ac; 108 struct ath_atx_ac *ac = tid->ac;
109 109
110 if (tid->paused)
111 return;
112
113 if (tid->sched) 110 if (tid->sched)
114 return; 111 return;
115 112
@@ -1407,7 +1404,6 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
1407 ath_tx_tid_change_state(sc, txtid); 1404 ath_tx_tid_change_state(sc, txtid);
1408 1405
1409 txtid->active = true; 1406 txtid->active = true;
1410 txtid->paused = true;
1411 *ssn = txtid->seq_start = txtid->seq_next; 1407 *ssn = txtid->seq_start = txtid->seq_next;
1412 txtid->bar_index = -1; 1408 txtid->bar_index = -1;
1413 1409
@@ -1427,7 +1423,6 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid)
1427 1423
1428 ath_txq_lock(sc, txq); 1424 ath_txq_lock(sc, txq);
1429 txtid->active = false; 1425 txtid->active = false;
1430 txtid->paused = false;
1431 ath_tx_flush_tid(sc, txtid); 1426 ath_tx_flush_tid(sc, txtid);
1432 ath_tx_tid_change_state(sc, txtid); 1427 ath_tx_tid_change_state(sc, txtid);
1433 ath_txq_unlock_complete(sc, txq); 1428 ath_txq_unlock_complete(sc, txq);
@@ -1487,7 +1482,7 @@ void ath_tx_aggr_wakeup(struct ath_softc *sc, struct ath_node *an)
1487 ath_txq_lock(sc, txq); 1482 ath_txq_lock(sc, txq);
1488 ac->clear_ps_filter = true; 1483 ac->clear_ps_filter = true;
1489 1484
1490 if (!tid->paused && ath_tid_has_buffered(tid)) { 1485 if (ath_tid_has_buffered(tid)) {
1491 ath_tx_queue_tid(txq, tid); 1486 ath_tx_queue_tid(txq, tid);
1492 ath_txq_schedule(sc, txq); 1487 ath_txq_schedule(sc, txq);
1493 } 1488 }
@@ -1510,7 +1505,6 @@ void ath_tx_aggr_resume(struct ath_softc *sc, struct ieee80211_sta *sta,
1510 ath_txq_lock(sc, txq); 1505 ath_txq_lock(sc, txq);
1511 1506
1512 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor; 1507 tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
1513 tid->paused = false;
1514 1508
1515 if (ath_tid_has_buffered(tid)) { 1509 if (ath_tid_has_buffered(tid)) {
1516 ath_tx_queue_tid(txq, tid); 1510 ath_tx_queue_tid(txq, tid);
@@ -1544,8 +1538,6 @@ void ath9k_release_buffered_frames(struct ieee80211_hw *hw,
1544 continue; 1538 continue;
1545 1539
1546 tid = ATH_AN_2_TID(an, i); 1540 tid = ATH_AN_2_TID(an, i);
1547 if (tid->paused)
1548 continue;
1549 1541
1550 ath_txq_lock(sc, tid->ac->txq); 1542 ath_txq_lock(sc, tid->ac->txq);
1551 while (nframes > 0) { 1543 while (nframes > 0) {
@@ -1844,9 +1836,6 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq)
1844 list_del(&tid->list); 1836 list_del(&tid->list);
1845 tid->sched = false; 1837 tid->sched = false;
1846 1838
1847 if (tid->paused)
1848 continue;
1849
1850 if (ath_tx_sched_aggr(sc, txq, tid, &stop)) 1839 if (ath_tx_sched_aggr(sc, txq, tid, &stop))
1851 sent = true; 1840 sent = true;
1852 1841
@@ -2698,7 +2687,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
2698 tid->baw_size = WME_MAX_BA; 2687 tid->baw_size = WME_MAX_BA;
2699 tid->baw_head = tid->baw_tail = 0; 2688 tid->baw_head = tid->baw_tail = 0;
2700 tid->sched = false; 2689 tid->sched = false;
2701 tid->paused = false;
2702 tid->active = false; 2690 tid->active = false;
2703 __skb_queue_head_init(&tid->buf_q); 2691 __skb_queue_head_init(&tid->buf_q);
2704 __skb_queue_head_init(&tid->retry_q); 2692 __skb_queue_head_init(&tid->retry_q);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/brcm80211/brcmfmac/chip.c
index df130ef53d1c..c7c9f15c0fe0 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/chip.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/chip.c
@@ -303,10 +303,10 @@ static void brcmf_chip_ai_coredisable(struct brcmf_core_priv *core,
303 303
304 ci = core->chip; 304 ci = core->chip;
305 305
306 /* if core is already in reset, just return */ 306 /* if core is already in reset, skip reset */
307 regdata = ci->ops->read32(ci->ctx, core->wrapbase + BCMA_RESET_CTL); 307 regdata = ci->ops->read32(ci->ctx, core->wrapbase + BCMA_RESET_CTL);
308 if ((regdata & BCMA_RESET_CTL_RESET) != 0) 308 if ((regdata & BCMA_RESET_CTL_RESET) != 0)
309 return; 309 goto in_reset_configure;
310 310
311 /* configure reset */ 311 /* configure reset */
312 ci->ops->write32(ci->ctx, core->wrapbase + BCMA_IOCTL, 312 ci->ops->write32(ci->ctx, core->wrapbase + BCMA_IOCTL,
@@ -322,6 +322,7 @@ static void brcmf_chip_ai_coredisable(struct brcmf_core_priv *core,
322 SPINWAIT(ci->ops->read32(ci->ctx, core->wrapbase + BCMA_RESET_CTL) != 322 SPINWAIT(ci->ops->read32(ci->ctx, core->wrapbase + BCMA_RESET_CTL) !=
323 BCMA_RESET_CTL_RESET, 300); 323 BCMA_RESET_CTL_RESET, 300);
324 324
325in_reset_configure:
325 /* in-reset configure */ 326 /* in-reset configure */
326 ci->ops->write32(ci->ctx, core->wrapbase + BCMA_IOCTL, 327 ci->ops->write32(ci->ctx, core->wrapbase + BCMA_IOCTL,
327 reset | BCMA_IOCTL_FGC | BCMA_IOCTL_CLK); 328 reset | BCMA_IOCTL_FGC | BCMA_IOCTL_CLK);
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 30a2367ba8d6..212ac4842c16 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -621,20 +621,18 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
621 bss_conf->bssid); 621 bss_conf->bssid);
622 622
623 /* 623 /*
624 * Update the beacon. This is only required on USB devices. PCI
625 * devices fetch beacons periodically.
626 */
627 if (changes & BSS_CHANGED_BEACON && rt2x00_is_usb(rt2x00dev))
628 rt2x00queue_update_beacon(rt2x00dev, vif);
629
630 /*
631 * Start/stop beaconing. 624 * Start/stop beaconing.
632 */ 625 */
633 if (changes & BSS_CHANGED_BEACON_ENABLED) { 626 if (changes & BSS_CHANGED_BEACON_ENABLED) {
634 if (!bss_conf->enable_beacon && intf->enable_beacon) { 627 if (!bss_conf->enable_beacon && intf->enable_beacon) {
635 rt2x00queue_clear_beacon(rt2x00dev, vif);
636 rt2x00dev->intf_beaconing--; 628 rt2x00dev->intf_beaconing--;
637 intf->enable_beacon = false; 629 intf->enable_beacon = false;
630 /*
631 * Clear beacon in the H/W for this vif. This is needed
632 * to disable beaconing on this particular interface
633 * and keep it running on other interfaces.
634 */
635 rt2x00queue_clear_beacon(rt2x00dev, vif);
638 636
639 if (rt2x00dev->intf_beaconing == 0) { 637 if (rt2x00dev->intf_beaconing == 0) {
640 /* 638 /*
@@ -645,11 +643,15 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
645 rt2x00queue_stop_queue(rt2x00dev->bcn); 643 rt2x00queue_stop_queue(rt2x00dev->bcn);
646 mutex_unlock(&intf->beacon_skb_mutex); 644 mutex_unlock(&intf->beacon_skb_mutex);
647 } 645 }
648
649
650 } else if (bss_conf->enable_beacon && !intf->enable_beacon) { 646 } else if (bss_conf->enable_beacon && !intf->enable_beacon) {
651 rt2x00dev->intf_beaconing++; 647 rt2x00dev->intf_beaconing++;
652 intf->enable_beacon = true; 648 intf->enable_beacon = true;
649 /*
650 * Upload beacon to the H/W. This is only required on
651 * USB devices. PCI devices fetch beacons periodically.
652 */
653 if (rt2x00_is_usb(rt2x00dev))
654 rt2x00queue_update_beacon(rt2x00dev, vif);
653 655
654 if (rt2x00dev->intf_beaconing == 1) { 656 if (rt2x00dev->intf_beaconing == 1) {
655 /* 657 /*
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
index 06ef47cd6203..5b4c225396f2 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
@@ -293,7 +293,7 @@ static void _rtl88ee_translate_rx_signal_stuff(struct ieee80211_hw *hw,
293 u8 *psaddr; 293 u8 *psaddr;
294 __le16 fc; 294 __le16 fc;
295 u16 type, ufc; 295 u16 type, ufc;
296 bool match_bssid, packet_toself, packet_beacon, addr; 296 bool match_bssid, packet_toself, packet_beacon = false, addr;
297 297
298 tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift; 298 tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift;
299 299
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 68b5c7e92cfb..07cb06da6729 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -1001,7 +1001,7 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
1001 err = _rtl92cu_init_mac(hw); 1001 err = _rtl92cu_init_mac(hw);
1002 if (err) { 1002 if (err) {
1003 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "init mac failed!\n"); 1003 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "init mac failed!\n");
1004 return err; 1004 goto exit;
1005 } 1005 }
1006 err = rtl92c_download_fw(hw); 1006 err = rtl92c_download_fw(hw);
1007 if (err) { 1007 if (err) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 36b48be8329c..2b3c78baa9f8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -49,6 +49,12 @@ static u8 _rtl92se_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 skb_queue)
49 if (ieee80211_is_nullfunc(fc)) 49 if (ieee80211_is_nullfunc(fc))
50 return QSLT_HIGH; 50 return QSLT_HIGH;
51 51
52 /* Kernel commit 1bf4bbb4024dcdab changed EAPOL packets to use
53 * queue V0 at priority 7; however, the RTL8192SE appears to have
54 * that queue at priority 6
55 */
56 if (skb->priority == 7)
57 return QSLT_VO;
52 return skb->priority; 58 return skb->priority;
53} 59}
54 60
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 9bcf2cf19357..5aeb89411350 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -364,7 +364,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
364 364
365 memset(r, 0, sizeof(*r)); 365 memset(r, 0, sizeof(*r));
366 /* 366 /*
367 * Get optional "interrupts-names" property to add a name 367 * Get optional "interrupt-names" property to add a name
368 * to the resource. 368 * to the resource.
369 */ 369 */
370 of_property_read_string_index(dev, "interrupt-names", index, 370 of_property_read_string_index(dev, "interrupt-names", index,
@@ -380,6 +380,32 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
380EXPORT_SYMBOL_GPL(of_irq_to_resource); 380EXPORT_SYMBOL_GPL(of_irq_to_resource);
381 381
382/** 382/**
383 * of_irq_get - Decode a node's IRQ and return it as a Linux irq number
384 * @dev: pointer to device tree node
385 * @index: zero-based index of the irq
386 *
387 * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
388 * is not yet created.
389 *
390 */
391int of_irq_get(struct device_node *dev, int index)
392{
393 int rc;
394 struct of_phandle_args oirq;
395 struct irq_domain *domain;
396
397 rc = of_irq_parse_one(dev, index, &oirq);
398 if (rc)
399 return rc;
400
401 domain = irq_find_host(oirq.np);
402 if (!domain)
403 return -EPROBE_DEFER;
404
405 return irq_create_of_mapping(&oirq);
406}
407
408/**
383 * of_irq_count - Count the number of IRQs a node uses 409 * of_irq_count - Count the number of IRQs a node uses
384 * @dev: pointer to device tree node 410 * @dev: pointer to device tree node
385 */ 411 */
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 404d1daebefa..bd47fbc53dc9 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -168,7 +168,9 @@ struct platform_device *of_device_alloc(struct device_node *np,
168 rc = of_address_to_resource(np, i, res); 168 rc = of_address_to_resource(np, i, res);
169 WARN_ON(rc); 169 WARN_ON(rc);
170 } 170 }
171 WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq); 171 if (of_irq_to_resource_table(np, res, num_irq) != num_irq)
172 pr_debug("not all legacy IRQ resources mapped for %s\n",
173 np->name);
172 } 174 }
173 175
174 dev->dev.of_node = of_node_get(np); 176 dev->dev.of_node = of_node_get(np);
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index ae4450070503..fe70b86bcffb 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -10,6 +10,7 @@
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/of.h> 11#include <linux/of.h>
12#include <linux/of_irq.h> 12#include <linux/of_irq.h>
13#include <linux/of_platform.h>
13#include <linux/list.h> 14#include <linux/list.h>
14#include <linux/mutex.h> 15#include <linux/mutex.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
@@ -427,6 +428,36 @@ static void __init of_selftest_match_node(void)
427 } 428 }
428} 429}
429 430
431static void __init of_selftest_platform_populate(void)
432{
433 int irq;
434 struct device_node *np;
435 struct platform_device *pdev;
436
437 np = of_find_node_by_path("/testcase-data");
438 of_platform_populate(np, of_default_bus_match_table, NULL, NULL);
439
440 /* Test that a missing irq domain returns -EPROBE_DEFER */
441 np = of_find_node_by_path("/testcase-data/testcase-device1");
442 pdev = of_find_device_by_node(np);
443 if (!pdev)
444 selftest(0, "device 1 creation failed\n");
445 irq = platform_get_irq(pdev, 0);
446 if (irq != -EPROBE_DEFER)
447 selftest(0, "device deferred probe failed - %d\n", irq);
448
449 /* Test that a parsing failure does not return -EPROBE_DEFER */
450 np = of_find_node_by_path("/testcase-data/testcase-device2");
451 pdev = of_find_device_by_node(np);
452 if (!pdev)
453 selftest(0, "device 2 creation failed\n");
454 irq = platform_get_irq(pdev, 0);
455 if (irq >= 0 || irq == -EPROBE_DEFER)
456 selftest(0, "device parsing error failed - %d\n", irq);
457
458 selftest(1, "passed");
459}
460
430static int __init of_selftest(void) 461static int __init of_selftest(void)
431{ 462{
432 struct device_node *np; 463 struct device_node *np;
@@ -445,6 +476,7 @@ static int __init of_selftest(void)
445 of_selftest_parse_interrupts(); 476 of_selftest_parse_interrupts();
446 of_selftest_parse_interrupts_extended(); 477 of_selftest_parse_interrupts_extended();
447 of_selftest_match_node(); 478 of_selftest_match_node();
479 of_selftest_platform_populate();
448 pr_info("end of selftest - %i passed, %i failed\n", 480 pr_info("end of selftest - %i passed, %i failed\n",
449 selftest_results.passed, selftest_results.failed); 481 selftest_results.passed, selftest_results.failed);
450 return 0; 482 return 0;
diff --git a/drivers/of/testcase-data/tests-interrupts.dtsi b/drivers/of/testcase-data/tests-interrupts.dtsi
index c843720bd3e5..da4695f60351 100644
--- a/drivers/of/testcase-data/tests-interrupts.dtsi
+++ b/drivers/of/testcase-data/tests-interrupts.dtsi
@@ -54,5 +54,18 @@
54 <&test_intmap1 1 2>; 54 <&test_intmap1 1 2>;
55 }; 55 };
56 }; 56 };
57
58 testcase-device1 {
59 compatible = "testcase-device";
60 interrupt-parent = <&test_intc0>;
61 interrupts = <1>;
62 };
63
64 testcase-device2 {
65 compatible = "testcase-device";
66 interrupt-parent = <&test_intc2>;
67 interrupts = <1>; /* invalid specifier - too short */
68 };
57 }; 69 };
70
58}; 71};
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 3bb05f17b9b4..4906c27fa3bd 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -33,6 +33,7 @@ config PHY_MVEBU_SATA
33 33
34config OMAP_CONTROL_PHY 34config OMAP_CONTROL_PHY
35 tristate "OMAP CONTROL PHY Driver" 35 tristate "OMAP CONTROL PHY Driver"
36 depends on ARCH_OMAP2PLUS || COMPILE_TEST
36 help 37 help
37 Enable this to add support for the PHY part present in the control 38 Enable this to add support for the PHY part present in the control
38 module. This driver has API to power on the USB2 PHY and to write to 39 module. This driver has API to power on the USB2 PHY and to write to
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 2faf78edc864..7728518572a4 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -13,8 +13,9 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o
13obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o 13obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
14obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o 14obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o
15obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o 15obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o
16obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-samsung-usb2.o 16obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o
17obj-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o 17phy-exynos-usb2-y += phy-samsung-usb2.o
18obj-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o 18phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4210_USB2) += phy-exynos4210-usb2.o
19obj-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o 19phy-exynos-usb2-$(CONFIG_PHY_EXYNOS4X12_USB2) += phy-exynos4x12-usb2.o
20phy-exynos-usb2-$(CONFIG_PHY_EXYNOS5250_USB2) += phy-exynos5250-usb2.o
20obj-$(CONFIG_PHY_XGENE) += phy-xgene.o 21obj-$(CONFIG_PHY_XGENE) += phy-xgene.o
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 623b71c54b3e..c64a2f3b2d62 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -64,6 +64,9 @@ static struct phy *phy_lookup(struct device *device, const char *port)
64 class_dev_iter_init(&iter, phy_class, NULL, NULL); 64 class_dev_iter_init(&iter, phy_class, NULL, NULL);
65 while ((dev = class_dev_iter_next(&iter))) { 65 while ((dev = class_dev_iter_next(&iter))) {
66 phy = to_phy(dev); 66 phy = to_phy(dev);
67
68 if (!phy->init_data)
69 continue;
67 count = phy->init_data->num_consumers; 70 count = phy->init_data->num_consumers;
68 consumers = phy->init_data->consumers; 71 consumers = phy->init_data->consumers;
69 while (count--) { 72 while (count--) {
diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c
index 92ed4b2e3c07..c862f9c0e9ce 100644
--- a/drivers/pinctrl/pinctrl-as3722.c
+++ b/drivers/pinctrl/pinctrl-as3722.c
@@ -64,7 +64,6 @@ struct as3722_pin_function {
64}; 64};
65 65
66struct as3722_gpio_pin_control { 66struct as3722_gpio_pin_control {
67 bool enable_gpio_invert;
68 unsigned mode_prop; 67 unsigned mode_prop;
69 int io_function; 68 int io_function;
70}; 69};
@@ -320,10 +319,8 @@ static int as3722_pinctrl_gpio_set_direction(struct pinctrl_dev *pctldev,
320 return mode; 319 return mode;
321 } 320 }
322 321
323 if (as_pci->gpio_control[offset].enable_gpio_invert) 322 return as3722_update_bits(as3722, AS3722_GPIOn_CONTROL_REG(offset),
324 mode |= AS3722_GPIO_INV; 323 AS3722_GPIO_MODE_MASK, mode);
325
326 return as3722_write(as3722, AS3722_GPIOn_CONTROL_REG(offset), mode);
327} 324}
328 325
329static const struct pinmux_ops as3722_pinmux_ops = { 326static const struct pinmux_ops as3722_pinmux_ops = {
@@ -496,10 +493,18 @@ static void as3722_gpio_set(struct gpio_chip *chip, unsigned offset,
496{ 493{
497 struct as3722_pctrl_info *as_pci = to_as_pci(chip); 494 struct as3722_pctrl_info *as_pci = to_as_pci(chip);
498 struct as3722 *as3722 = as_pci->as3722; 495 struct as3722 *as3722 = as_pci->as3722;
499 int en_invert = as_pci->gpio_control[offset].enable_gpio_invert; 496 int en_invert;
500 u32 val; 497 u32 val;
501 int ret; 498 int ret;
502 499
500 ret = as3722_read(as3722, AS3722_GPIOn_CONTROL_REG(offset), &val);
501 if (ret < 0) {
502 dev_err(as_pci->dev,
503 "GPIO_CONTROL%d_REG read failed: %d\n", offset, ret);
504 return;
505 }
506 en_invert = !!(val & AS3722_GPIO_INV);
507
503 if (value) 508 if (value)
504 val = (en_invert) ? 0 : AS3722_GPIOn_SIGNAL(offset); 509 val = (en_invert) ? 0 : AS3722_GPIOn_SIGNAL(offset);
505 else 510 else
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 81075f2a1d3f..2960557bfed9 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -810,6 +810,7 @@ static const struct pinconf_ops pcs_pinconf_ops = {
810static int pcs_add_pin(struct pcs_device *pcs, unsigned offset, 810static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
811 unsigned pin_pos) 811 unsigned pin_pos)
812{ 812{
813 struct pcs_soc_data *pcs_soc = &pcs->socdata;
813 struct pinctrl_pin_desc *pin; 814 struct pinctrl_pin_desc *pin;
814 struct pcs_name *pn; 815 struct pcs_name *pn;
815 int i; 816 int i;
@@ -821,6 +822,18 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset,
821 return -ENOMEM; 822 return -ENOMEM;
822 } 823 }
823 824
825 if (pcs_soc->irq_enable_mask) {
826 unsigned val;
827
828 val = pcs->read(pcs->base + offset);
829 if (val & pcs_soc->irq_enable_mask) {
830 dev_dbg(pcs->dev, "irq enabled at boot for pin at %lx (%x), clearing\n",
831 (unsigned long)pcs->res->start + offset, val);
832 val &= ~pcs_soc->irq_enable_mask;
833 pcs->write(val, pcs->base + offset);
834 }
835 }
836
824 pin = &pcs->pins.pa[i]; 837 pin = &pcs->pins.pa[i];
825 pn = &pcs->names[i]; 838 pn = &pcs->names[i];
826 sprintf(pn->name, "%lx.%d", 839 sprintf(pn->name, "%lx.%d",
diff --git a/drivers/pinctrl/pinctrl-tb10x.c b/drivers/pinctrl/pinctrl-tb10x.c
index c5e0f6973a3b..26ca6855f478 100644
--- a/drivers/pinctrl/pinctrl-tb10x.c
+++ b/drivers/pinctrl/pinctrl-tb10x.c
@@ -629,9 +629,8 @@ static int tb10x_gpio_request_enable(struct pinctrl_dev *pctl,
629 */ 629 */
630 for (i = 0; i < state->pinfuncgrpcnt; i++) { 630 for (i = 0; i < state->pinfuncgrpcnt; i++) {
631 const struct tb10x_pinfuncgrp *pfg = &state->pingroups[i]; 631 const struct tb10x_pinfuncgrp *pfg = &state->pingroups[i];
632 unsigned int port = pfg->port;
633 unsigned int mode = pfg->mode; 632 unsigned int mode = pfg->mode;
634 int j; 633 int j, port = pfg->port;
635 634
636 /* 635 /*
637 * Skip pin groups which are always mapped and don't need 636 * Skip pin groups which are always mapped and don't need
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
index 48093719167a..f5cd3f961808 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7790.c
@@ -4794,8 +4794,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
4794 FN_MSIOF0_SCK_B, 0, 4794 FN_MSIOF0_SCK_B, 0,
4795 /* IP5_23_21 [3] */ 4795 /* IP5_23_21 [3] */
4796 FN_WE1_N, FN_IERX, FN_CAN1_RX, FN_VI1_G4, 4796 FN_WE1_N, FN_IERX, FN_CAN1_RX, FN_VI1_G4,
4797 FN_VI1_G4_B, FN_VI2_R6, FN_SCIFA0_CTS_N_B, 4797 FN_VI1_G4_B, FN_VI2_R6, FN_SCIFA0_CTS_N_B, FN_IERX_C,
4798 FN_IERX_C, 0,
4799 /* IP5_20_18 [3] */ 4798 /* IP5_20_18 [3] */
4800 FN_WE0_N, FN_IECLK, FN_CAN_CLK, 4799 FN_WE0_N, FN_IECLK, FN_CAN_CLK,
4801 FN_VI2_VSYNC_N, FN_SCIFA0_TXD_B, FN_VI2_VSYNC_N_B, 0, 0, 4800 FN_VI2_VSYNC_N, FN_SCIFA0_TXD_B, FN_VI2_VSYNC_N_B, 0, 0,
diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
index 5186d70c49d4..7868bf3a0f91 100644
--- a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
+++ b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c
@@ -5288,7 +5288,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
5288 /* SEL_SCIF3 [2] */ 5288 /* SEL_SCIF3 [2] */
5289 FN_SEL_SCIF3_0, FN_SEL_SCIF3_1, FN_SEL_SCIF3_2, FN_SEL_SCIF3_3, 5289 FN_SEL_SCIF3_0, FN_SEL_SCIF3_1, FN_SEL_SCIF3_2, FN_SEL_SCIF3_3,
5290 /* SEL_IEB [2] */ 5290 /* SEL_IEB [2] */
5291 FN_SEL_IEB_0, FN_SEL_IEB_1, FN_SEL_IEB_2, 5291 FN_SEL_IEB_0, FN_SEL_IEB_1, FN_SEL_IEB_2, 0,
5292 /* SEL_MMC [1] */ 5292 /* SEL_MMC [1] */
5293 FN_SEL_MMC_0, FN_SEL_MMC_1, 5293 FN_SEL_MMC_0, FN_SEL_MMC_1,
5294 /* SEL_SCIF5 [1] */ 5294 /* SEL_SCIF5 [1] */
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 9f611cbbc294..c31aa07b3ba5 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -83,8 +83,7 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
83{ 83{
84 struct acpi_device *acpi_dev; 84 struct acpi_device *acpi_dev;
85 acpi_handle handle; 85 acpi_handle handle;
86 struct acpi_buffer buffer; 86 int ret = 0;
87 int ret;
88 87
89 pnp_dbg(&dev->dev, "set resources\n"); 88 pnp_dbg(&dev->dev, "set resources\n");
90 89
@@ -97,19 +96,26 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
97 if (WARN_ON_ONCE(acpi_dev != dev->data)) 96 if (WARN_ON_ONCE(acpi_dev != dev->data))
98 dev->data = acpi_dev; 97 dev->data = acpi_dev;
99 98
100 ret = pnpacpi_build_resource_template(dev, &buffer); 99 if (acpi_has_method(handle, METHOD_NAME__SRS)) {
101 if (ret) 100 struct acpi_buffer buffer;
102 return ret; 101
103 ret = pnpacpi_encode_resources(dev, &buffer); 102 ret = pnpacpi_build_resource_template(dev, &buffer);
104 if (ret) { 103 if (ret)
104 return ret;
105
106 ret = pnpacpi_encode_resources(dev, &buffer);
107 if (!ret) {
108 acpi_status status;
109
110 status = acpi_set_current_resources(handle, &buffer);
111 if (ACPI_FAILURE(status))
112 ret = -EIO;
113 }
105 kfree(buffer.pointer); 114 kfree(buffer.pointer);
106 return ret;
107 } 115 }
108 if (ACPI_FAILURE(acpi_set_current_resources(handle, &buffer))) 116 if (!ret && acpi_bus_power_manageable(handle))
109 ret = -EINVAL;
110 else if (acpi_bus_power_manageable(handle))
111 ret = acpi_bus_set_power(handle, ACPI_STATE_D0); 117 ret = acpi_bus_set_power(handle, ACPI_STATE_D0);
112 kfree(buffer.pointer); 118
113 return ret; 119 return ret;
114} 120}
115 121
@@ -117,7 +123,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
117{ 123{
118 struct acpi_device *acpi_dev; 124 struct acpi_device *acpi_dev;
119 acpi_handle handle; 125 acpi_handle handle;
120 int ret; 126 acpi_status status;
121 127
122 dev_dbg(&dev->dev, "disable resources\n"); 128 dev_dbg(&dev->dev, "disable resources\n");
123 129
@@ -128,13 +134,15 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
128 } 134 }
129 135
130 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 136 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
131 ret = 0;
132 if (acpi_bus_power_manageable(handle)) 137 if (acpi_bus_power_manageable(handle))
133 acpi_bus_set_power(handle, ACPI_STATE_D3_COLD); 138 acpi_bus_set_power(handle, ACPI_STATE_D3_COLD);
134 /* continue even if acpi_bus_set_power() fails */ 139
135 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL))) 140 /* continue even if acpi_bus_set_power() fails */
136 ret = -ENODEV; 141 status = acpi_evaluate_object(handle, "_DIS", NULL, NULL);
137 return ret; 142 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
143 return -ENODEV;
144
145 return 0;
138} 146}
139 147
140#ifdef CONFIG_ACPI_SLEEP 148#ifdef CONFIG_ACPI_SLEEP
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index 258fef272ea7..ebf0d6710b5a 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/pci.h>
18#include <linux/string.h> 19#include <linux/string.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
20#include <linux/pnp.h> 21#include <linux/pnp.h>
@@ -334,6 +335,81 @@ static void quirk_amd_mmconfig_area(struct pnp_dev *dev)
334} 335}
335#endif 336#endif
336 337
338#ifdef CONFIG_PCI
339/* Device IDs of parts that have 32KB MCH space */
340static const unsigned int mch_quirk_devices[] = {
341 0x0154, /* Ivy Bridge */
342 0x0c00, /* Haswell */
343};
344
345static struct pci_dev *get_intel_host(void)
346{
347 int i;
348 struct pci_dev *host;
349
350 for (i = 0; i < ARRAY_SIZE(mch_quirk_devices); i++) {
351 host = pci_get_device(PCI_VENDOR_ID_INTEL, mch_quirk_devices[i],
352 NULL);
353 if (host)
354 return host;
355 }
356 return NULL;
357}
358
359static void quirk_intel_mch(struct pnp_dev *dev)
360{
361 struct pci_dev *host;
362 u32 addr_lo, addr_hi;
363 struct pci_bus_region region;
364 struct resource mch;
365 struct pnp_resource *pnp_res;
366 struct resource *res;
367
368 host = get_intel_host();
369 if (!host)
370 return;
371
372 /*
373 * MCHBAR is not an architected PCI BAR, so MCH space is usually
374 * reported as a PNP0C02 resource. The MCH space was originally
375 * 16KB, but is 32KB in newer parts. Some BIOSes still report a
376 * PNP0C02 resource that is only 16KB, which means the rest of the
377 * MCH space is consumed but unreported.
378 */
379
380 /*
381 * Read MCHBAR for Host Member Mapped Register Range Base
382 * https://www-ssl.intel.com/content/www/us/en/processors/core/4th-gen-core-family-desktop-vol-2-datasheet
383 * Sec 3.1.12.
384 */
385 pci_read_config_dword(host, 0x48, &addr_lo);
386 region.start = addr_lo & ~0x7fff;
387 pci_read_config_dword(host, 0x4c, &addr_hi);
388 region.start |= (u64) addr_hi << 32;
389 region.end = region.start + 32*1024 - 1;
390
391 memset(&mch, 0, sizeof(mch));
392 mch.flags = IORESOURCE_MEM;
393 pcibios_bus_to_resource(host->bus, &mch, &region);
394
395 list_for_each_entry(pnp_res, &dev->resources, list) {
396 res = &pnp_res->res;
397 if (res->end < mch.start || res->start > mch.end)
398 continue; /* no overlap */
399 if (res->start == mch.start && res->end == mch.end)
400 continue; /* exact match */
401
402 dev_info(&dev->dev, FW_BUG "PNP resource %pR covers only part of %s Intel MCH; extending to %pR\n",
403 res, pci_name(host), &mch);
404 res->start = mch.start;
405 res->end = mch.end;
406 break;
407 }
408
409 pci_dev_put(host);
410}
411#endif
412
337/* 413/*
338 * PnP Quirks 414 * PnP Quirks
339 * Cards or devices that need some tweaking due to incomplete resource info 415 * Cards or devices that need some tweaking due to incomplete resource info
@@ -364,6 +440,9 @@ static struct pnp_fixup pnp_fixups[] = {
364#ifdef CONFIG_AMD_NB 440#ifdef CONFIG_AMD_NB
365 {"PNP0c01", quirk_amd_mmconfig_area}, 441 {"PNP0c01", quirk_amd_mmconfig_area},
366#endif 442#endif
443#ifdef CONFIG_PCI
444 {"PNP0c02", quirk_intel_mch},
445#endif
367 {""} 446 {""}
368}; 447};
369 448
diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
index 476aa495c110..b95cf71ed695 100644
--- a/drivers/power/reset/vexpress-poweroff.c
+++ b/drivers/power/reset/vexpress-poweroff.c
@@ -11,7 +11,7 @@
11 * Copyright (C) 2012 ARM Limited 11 * Copyright (C) 2012 ARM Limited
12 */ 12 */
13 13
14#include <linux/jiffies.h> 14#include <linux/delay.h>
15#include <linux/of.h> 15#include <linux/of.h>
16#include <linux/of_device.h> 16#include <linux/of_device.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
@@ -23,17 +23,12 @@
23static void vexpress_reset_do(struct device *dev, const char *what) 23static void vexpress_reset_do(struct device *dev, const char *what)
24{ 24{
25 int err = -ENOENT; 25 int err = -ENOENT;
26 struct vexpress_config_func *func = 26 struct vexpress_config_func *func = dev_get_drvdata(dev);
27 vexpress_config_func_get_by_dev(dev);
28 27
29 if (func) { 28 if (func) {
30 unsigned long timeout;
31
32 err = vexpress_config_write(func, 0, 0); 29 err = vexpress_config_write(func, 0, 0);
33 30 if (!err)
34 timeout = jiffies + HZ; 31 mdelay(1000);
35 while (time_before(jiffies, timeout))
36 cpu_relax();
37 } 32 }
38 33
39 dev_emerg(dev, "Unable to %s (%d)\n", what, err); 34 dev_emerg(dev, "Unable to %s (%d)\n", what, err);
@@ -96,12 +91,18 @@ static int vexpress_reset_probe(struct platform_device *pdev)
96 enum vexpress_reset_func func; 91 enum vexpress_reset_func func;
97 const struct of_device_id *match = 92 const struct of_device_id *match =
98 of_match_device(vexpress_reset_of_match, &pdev->dev); 93 of_match_device(vexpress_reset_of_match, &pdev->dev);
94 struct vexpress_config_func *config_func;
99 95
100 if (match) 96 if (match)
101 func = (enum vexpress_reset_func)match->data; 97 func = (enum vexpress_reset_func)match->data;
102 else 98 else
103 func = pdev->id_entry->driver_data; 99 func = pdev->id_entry->driver_data;
104 100
101 config_func = vexpress_config_func_get_by_dev(&pdev->dev);
102 if (!config_func)
103 return -EINVAL;
104 dev_set_drvdata(&pdev->dev, config_func);
105
105 switch (func) { 106 switch (func) {
106 case FUNC_SHUTDOWN: 107 case FUNC_SHUTDOWN:
107 vexpress_power_off_device = &pdev->dev; 108 vexpress_power_off_device = &pdev->dev;
diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index 6963bdf54175..6aea373547f6 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -6,6 +6,7 @@ menu "PTP clock support"
6 6
7config PTP_1588_CLOCK 7config PTP_1588_CLOCK
8 tristate "PTP clock support" 8 tristate "PTP clock support"
9 depends on NET
9 select PPS 10 select PPS
10 select NET_PTP_CLASSIFY 11 select NET_PTP_CLASSIFY
11 help 12 help
@@ -74,7 +75,7 @@ config DP83640_PHY
74config PTP_1588_CLOCK_PCH 75config PTP_1588_CLOCK_PCH
75 tristate "Intel PCH EG20T as PTP clock" 76 tristate "Intel PCH EG20T as PTP clock"
76 depends on X86 || COMPILE_TEST 77 depends on X86 || COMPILE_TEST
77 depends on HAS_IOMEM 78 depends on HAS_IOMEM && NET
78 select PTP_1588_CLOCK 79 select PTP_1588_CLOCK
79 help 80 help
80 This driver adds support for using the PCH EG20T as a PTP 81 This driver adds support for using the PCH EG20T as a PTP
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c
index ded3b3574209..6d38be3d970c 100644
--- a/drivers/regulator/pbias-regulator.c
+++ b/drivers/regulator/pbias-regulator.c
@@ -38,66 +38,24 @@ struct pbias_reg_info {
38struct pbias_regulator_data { 38struct pbias_regulator_data {
39 struct regulator_desc desc; 39 struct regulator_desc desc;
40 void __iomem *pbias_addr; 40 void __iomem *pbias_addr;
41 unsigned int pbias_reg;
42 struct regulator_dev *dev; 41 struct regulator_dev *dev;
43 struct regmap *syscon; 42 struct regmap *syscon;
44 const struct pbias_reg_info *info; 43 const struct pbias_reg_info *info;
45 int voltage; 44 int voltage;
46}; 45};
47 46
48static int pbias_regulator_set_voltage(struct regulator_dev *dev, 47static const unsigned int pbias_volt_table[] = {
49 int min_uV, int max_uV, unsigned *selector) 48 1800000,
50{ 49 3000000
51 struct pbias_regulator_data *data = rdev_get_drvdata(dev); 50};
52 const struct pbias_reg_info *info = data->info;
53 int ret, vmode;
54
55 if (min_uV <= 1800000)
56 vmode = 0;
57 else if (min_uV > 1800000)
58 vmode = info->vmode;
59
60 ret = regmap_update_bits(data->syscon, data->pbias_reg,
61 info->vmode, vmode);
62
63 return ret;
64}
65
66static int pbias_regulator_get_voltage(struct regulator_dev *rdev)
67{
68 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
69 const struct pbias_reg_info *info = data->info;
70 int value, voltage;
71
72 regmap_read(data->syscon, data->pbias_reg, &value);
73 value &= info->vmode;
74
75 voltage = value ? 3000000 : 1800000;
76
77 return voltage;
78}
79 51
80static int pbias_regulator_enable(struct regulator_dev *rdev) 52static int pbias_regulator_enable(struct regulator_dev *rdev)
81{ 53{
82 struct pbias_regulator_data *data = rdev_get_drvdata(rdev); 54 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
83 const struct pbias_reg_info *info = data->info; 55 const struct pbias_reg_info *info = data->info;
84 int ret;
85
86 ret = regmap_update_bits(data->syscon, data->pbias_reg,
87 info->enable_mask, info->enable);
88
89 return ret;
90}
91
92static int pbias_regulator_disable(struct regulator_dev *rdev)
93{
94 struct pbias_regulator_data *data = rdev_get_drvdata(rdev);
95 const struct pbias_reg_info *info = data->info;
96 int ret;
97 56
98 ret = regmap_update_bits(data->syscon, data->pbias_reg, 57 return regmap_update_bits(data->syscon, rdev->desc->enable_reg,
99 info->enable_mask, 0); 58 info->enable_mask, info->enable);
100 return ret;
101} 59}
102 60
103static int pbias_regulator_is_enable(struct regulator_dev *rdev) 61static int pbias_regulator_is_enable(struct regulator_dev *rdev)
@@ -106,17 +64,18 @@ static int pbias_regulator_is_enable(struct regulator_dev *rdev)
106 const struct pbias_reg_info *info = data->info; 64 const struct pbias_reg_info *info = data->info;
107 int value; 65 int value;
108 66
109 regmap_read(data->syscon, data->pbias_reg, &value); 67 regmap_read(data->syscon, rdev->desc->enable_reg, &value);
110 68
111 return (value & info->enable_mask) == info->enable_mask; 69 return (value & info->enable_mask) == info->enable;
112} 70}
113 71
114static struct regulator_ops pbias_regulator_voltage_ops = { 72static struct regulator_ops pbias_regulator_voltage_ops = {
115 .set_voltage = pbias_regulator_set_voltage, 73 .list_voltage = regulator_list_voltage_table,
116 .get_voltage = pbias_regulator_get_voltage, 74 .get_voltage_sel = regulator_get_voltage_sel_regmap,
117 .enable = pbias_regulator_enable, 75 .set_voltage_sel = regulator_set_voltage_sel_regmap,
118 .disable = pbias_regulator_disable, 76 .enable = pbias_regulator_enable,
119 .is_enabled = pbias_regulator_is_enable, 77 .disable = regulator_disable_regmap,
78 .is_enabled = pbias_regulator_is_enable,
120}; 79};
121 80
122static const struct pbias_reg_info pbias_mmc_omap2430 = { 81static const struct pbias_reg_info pbias_mmc_omap2430 = {
@@ -192,6 +151,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
192 if (IS_ERR(syscon)) 151 if (IS_ERR(syscon))
193 return PTR_ERR(syscon); 152 return PTR_ERR(syscon);
194 153
154 cfg.regmap = syscon;
195 cfg.dev = &pdev->dev; 155 cfg.dev = &pdev->dev;
196 156
197 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { 157 for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) {
@@ -207,15 +167,19 @@ static int pbias_regulator_probe(struct platform_device *pdev)
207 if (!res) 167 if (!res)
208 return -EINVAL; 168 return -EINVAL;
209 169
210 drvdata[data_idx].pbias_reg = res->start;
211 drvdata[data_idx].syscon = syscon; 170 drvdata[data_idx].syscon = syscon;
212 drvdata[data_idx].info = info; 171 drvdata[data_idx].info = info;
213 drvdata[data_idx].desc.name = info->name; 172 drvdata[data_idx].desc.name = info->name;
214 drvdata[data_idx].desc.owner = THIS_MODULE; 173 drvdata[data_idx].desc.owner = THIS_MODULE;
215 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; 174 drvdata[data_idx].desc.type = REGULATOR_VOLTAGE;
216 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; 175 drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops;
176 drvdata[data_idx].desc.volt_table = pbias_volt_table;
217 drvdata[data_idx].desc.n_voltages = 2; 177 drvdata[data_idx].desc.n_voltages = 2;
218 drvdata[data_idx].desc.enable_time = info->enable_time; 178 drvdata[data_idx].desc.enable_time = info->enable_time;
179 drvdata[data_idx].desc.vsel_reg = res->start;
180 drvdata[data_idx].desc.vsel_mask = info->vmode;
181 drvdata[data_idx].desc.enable_reg = res->start;
182 drvdata[data_idx].desc.enable_mask = info->enable_mask;
219 183
220 cfg.init_data = pbias_matches[idx].init_data; 184 cfg.init_data = pbias_matches[idx].init_data;
221 cfg.driver_data = &drvdata[data_idx]; 185 cfg.driver_data = &drvdata[data_idx];
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 9f0ea6cb6922..e3bf885f4a6c 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -541,18 +541,27 @@ static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area)
541 541
542static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm) 542static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm)
543{ 543{
544 do { 544 static int ntsm_unsupported;
545
546 while (true) {
545 memset(sei, 0, sizeof(*sei)); 547 memset(sei, 0, sizeof(*sei));
546 sei->request.length = 0x0010; 548 sei->request.length = 0x0010;
547 sei->request.code = 0x000e; 549 sei->request.code = 0x000e;
548 sei->ntsm = ntsm; 550 if (!ntsm_unsupported)
551 sei->ntsm = ntsm;
549 552
550 if (chsc(sei)) 553 if (chsc(sei))
551 break; 554 break;
552 555
553 if (sei->response.code != 0x0001) { 556 if (sei->response.code != 0x0001) {
554 CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x)\n", 557 CIO_CRW_EVENT(2, "chsc: sei failed (rc=%04x, ntsm=%llx)\n",
555 sei->response.code); 558 sei->response.code, sei->ntsm);
559
560 if (sei->response.code == 3 && sei->ntsm) {
561 /* Fallback for old firmware. */
562 ntsm_unsupported = 1;
563 continue;
564 }
556 break; 565 break;
557 } 566 }
558 567
@@ -568,7 +577,10 @@ static void chsc_process_event_information(struct chsc_sei *sei, u64 ntsm)
568 CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei->nt); 577 CIO_CRW_EVENT(2, "chsc: unhandled nt: %d\n", sei->nt);
569 break; 578 break;
570 } 579 }
571 } while (sei->u.nt0_area.flags & 0x80); 580
581 if (!(sei->u.nt0_area.flags & 0x80))
582 break;
583 }
572} 584}
573 585
574/* 586/*
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 8cf4a0c69baf..9a6e4a2cd072 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -7463,6 +7463,10 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h)
7463 if (hpsa_simple_mode) 7463 if (hpsa_simple_mode)
7464 return; 7464 return;
7465 7465
7466 trans_support = readl(&(h->cfgtable->TransportSupport));
7467 if (!(trans_support & PERFORMANT_MODE))
7468 return;
7469
7466 /* Check for I/O accelerator mode support */ 7470 /* Check for I/O accelerator mode support */
7467 if (trans_support & CFGTBL_Trans_io_accel1) { 7471 if (trans_support & CFGTBL_Trans_io_accel1) {
7468 transMethod |= CFGTBL_Trans_io_accel1 | 7472 transMethod |= CFGTBL_Trans_io_accel1 |
@@ -7479,10 +7483,6 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h)
7479 } 7483 }
7480 7484
7481 /* TODO, check that this next line h->nreply_queues is correct */ 7485 /* TODO, check that this next line h->nreply_queues is correct */
7482 trans_support = readl(&(h->cfgtable->TransportSupport));
7483 if (!(trans_support & PERFORMANT_MODE))
7484 return;
7485
7486 h->nreply_queues = h->msix_vector > 0 ? h->msix_vector : 1; 7486 h->nreply_queues = h->msix_vector > 0 ? h->msix_vector : 1;
7487 hpsa_get_max_perf_mode_cmds(h); 7487 hpsa_get_max_perf_mode_cmds(h);
7488 /* Performant mode ring buffer and supporting data structures */ 7488 /* Performant mode ring buffer and supporting data structures */
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 7f0af4fcc001..6fd7d40b2c4d 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -8293,7 +8293,6 @@ _scsih_suspend(struct pci_dev *pdev, pm_message_t state)
8293 8293
8294 mpt2sas_base_free_resources(ioc); 8294 mpt2sas_base_free_resources(ioc);
8295 pci_save_state(pdev); 8295 pci_save_state(pdev);
8296 pci_disable_device(pdev);
8297 pci_set_power_state(pdev, device_state); 8296 pci_set_power_state(pdev, device_state);
8298 return 0; 8297 return 0;
8299} 8298}
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 771c16bfdbac..f17aa7aa7879 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -189,6 +189,7 @@ scsi_abort_command(struct scsi_cmnd *scmd)
189 /* 189 /*
190 * Retry after abort failed, escalate to next level. 190 * Retry after abort failed, escalate to next level.
191 */ 191 */
192 scmd->eh_eflags &= ~SCSI_EH_ABORT_SCHEDULED;
192 SCSI_LOG_ERROR_RECOVERY(3, 193 SCSI_LOG_ERROR_RECOVERY(3,
193 scmd_printk(KERN_INFO, scmd, 194 scmd_printk(KERN_INFO, scmd,
194 "scmd %p previous abort failed\n", scmd)); 195 "scmd %p previous abort failed\n", scmd));
@@ -920,10 +921,12 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
920 ses->prot_op = scmd->prot_op; 921 ses->prot_op = scmd->prot_op;
921 922
922 scmd->prot_op = SCSI_PROT_NORMAL; 923 scmd->prot_op = SCSI_PROT_NORMAL;
924 scmd->eh_eflags = 0;
923 scmd->cmnd = ses->eh_cmnd; 925 scmd->cmnd = ses->eh_cmnd;
924 memset(scmd->cmnd, 0, BLK_MAX_CDB); 926 memset(scmd->cmnd, 0, BLK_MAX_CDB);
925 memset(&scmd->sdb, 0, sizeof(scmd->sdb)); 927 memset(&scmd->sdb, 0, sizeof(scmd->sdb));
926 scmd->request->next_rq = NULL; 928 scmd->request->next_rq = NULL;
929 scmd->result = 0;
927 930
928 if (sense_bytes) { 931 if (sense_bytes) {
929 scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE, 932 scmd->sdb.length = min_t(unsigned, SCSI_SENSE_BUFFERSIZE,
@@ -1157,6 +1160,15 @@ int scsi_eh_get_sense(struct list_head *work_q,
1157 __func__)); 1160 __func__));
1158 break; 1161 break;
1159 } 1162 }
1163 if (status_byte(scmd->result) != CHECK_CONDITION)
1164 /*
1165 * don't request sense if there's no check condition
1166 * status because the error we're processing isn't one
1167 * that has a sense code (and some devices get
1168 * confused by sense requests out of the blue)
1169 */
1170 continue;
1171
1160 SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd, 1172 SCSI_LOG_ERROR_RECOVERY(2, scmd_printk(KERN_INFO, scmd,
1161 "%s: requesting sense\n", 1173 "%s: requesting sense\n",
1162 current->comm)); 1174 current->comm));
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 65a123d9c676..9db097a28a74 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -137,6 +137,7 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
137 * lock such that the kblockd_schedule_work() call happens 137 * lock such that the kblockd_schedule_work() call happens
138 * before blk_cleanup_queue() finishes. 138 * before blk_cleanup_queue() finishes.
139 */ 139 */
140 cmd->result = 0;
140 spin_lock_irqsave(q->queue_lock, flags); 141 spin_lock_irqsave(q->queue_lock, flags);
141 blk_requeue_request(q, cmd->request); 142 blk_requeue_request(q, cmd->request);
142 kblockd_schedule_work(q, &device->requeue_work); 143 kblockd_schedule_work(q, &device->requeue_work);
@@ -1044,6 +1045,7 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb,
1044 */ 1045 */
1045int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask) 1046int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask)
1046{ 1047{
1048 struct scsi_device *sdev = cmd->device;
1047 struct request *rq = cmd->request; 1049 struct request *rq = cmd->request;
1048 1050
1049 int error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask); 1051 int error = scsi_init_sgtable(rq, &cmd->sdb, gfp_mask);
@@ -1091,7 +1093,7 @@ err_exit:
1091 scsi_release_buffers(cmd); 1093 scsi_release_buffers(cmd);
1092 cmd->request->special = NULL; 1094 cmd->request->special = NULL;
1093 scsi_put_command(cmd); 1095 scsi_put_command(cmd);
1094 put_device(&cmd->device->sdev_gendev); 1096 put_device(&sdev->sdev_gendev);
1095 return error; 1097 return error;
1096} 1098}
1097EXPORT_SYMBOL(scsi_init_io); 1099EXPORT_SYMBOL(scsi_init_io);
@@ -1273,7 +1275,7 @@ int scsi_prep_return(struct request_queue *q, struct request *req, int ret)
1273 struct scsi_cmnd *cmd = req->special; 1275 struct scsi_cmnd *cmd = req->special;
1274 scsi_release_buffers(cmd); 1276 scsi_release_buffers(cmd);
1275 scsi_put_command(cmd); 1277 scsi_put_command(cmd);
1276 put_device(&cmd->device->sdev_gendev); 1278 put_device(&sdev->sdev_gendev);
1277 req->special = NULL; 1279 req->special = NULL;
1278 } 1280 }
1279 break; 1281 break;
diff --git a/drivers/scsi/scsi_netlink.c b/drivers/scsi/scsi_netlink.c
index fe30ea94ffe6..109802f776ed 100644
--- a/drivers/scsi/scsi_netlink.c
+++ b/drivers/scsi/scsi_netlink.c
@@ -77,7 +77,7 @@ scsi_nl_rcv_msg(struct sk_buff *skb)
77 goto next_msg; 77 goto next_msg;
78 } 78 }
79 79
80 if (!capable(CAP_SYS_ADMIN)) { 80 if (!netlink_capable(skb, CAP_SYS_ADMIN)) {
81 err = -EPERM; 81 err = -EPERM;
82 goto next_msg; 82 goto next_msg;
83 } 83 }
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 16bfd50cd3fe..db3b494e5926 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -750,8 +750,12 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
750 750
751 vscsi->affinity_hint_set = true; 751 vscsi->affinity_hint_set = true;
752 } else { 752 } else {
753 for (i = 0; i < vscsi->num_queues; i++) 753 for (i = 0; i < vscsi->num_queues; i++) {
754 if (!vscsi->req_vqs[i].vq)
755 continue;
756
754 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1); 757 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1);
758 }
755 759
756 vscsi->affinity_hint_set = false; 760 vscsi->affinity_hint_set = false;
757 } 761 }
diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 8005f9869481..079e6b1b0cdb 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1115,8 +1115,11 @@ static int atmel_spi_one_transfer(struct spi_master *master,
1115 atmel_spi_next_xfer_pio(master, xfer); 1115 atmel_spi_next_xfer_pio(master, xfer);
1116 } 1116 }
1117 1117
1118 /* interrupts are disabled, so free the lock for schedule */
1119 atmel_spi_unlock(as);
1118 ret = wait_for_completion_timeout(&as->xfer_completion, 1120 ret = wait_for_completion_timeout(&as->xfer_completion,
1119 SPI_DMA_TIMEOUT); 1121 SPI_DMA_TIMEOUT);
1122 atmel_spi_lock(as);
1120 if (WARN_ON(ret == 0)) { 1123 if (WARN_ON(ret == 0)) {
1121 dev_err(&spi->dev, 1124 dev_err(&spi->dev,
1122 "spi trasfer timeout, err %d\n", ret); 1125 "spi trasfer timeout, err %d\n", ret);
diff --git a/drivers/spi/spi-bfin5xx.c b/drivers/spi/spi-bfin5xx.c
index 55e57c3eb9bd..ebf720b88a2a 100644
--- a/drivers/spi/spi-bfin5xx.c
+++ b/drivers/spi/spi-bfin5xx.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/delay.h> 13#include <linux/delay.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/gpio.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
16#include <linux/io.h> 17#include <linux/io.h>
17#include <linux/ioport.h> 18#include <linux/ioport.h>
diff --git a/drivers/spi/spi-sh-hspi.c b/drivers/spi/spi-sh-hspi.c
index 9009456bdf4d..c8e795ef2e13 100644
--- a/drivers/spi/spi-sh-hspi.c
+++ b/drivers/spi/spi-sh-hspi.c
@@ -244,9 +244,9 @@ static int hspi_probe(struct platform_device *pdev)
244 return -ENOMEM; 244 return -ENOMEM;
245 } 245 }
246 246
247 clk = clk_get(NULL, "shyway_clk"); 247 clk = clk_get(&pdev->dev, NULL);
248 if (IS_ERR(clk)) { 248 if (IS_ERR(clk)) {
249 dev_err(&pdev->dev, "shyway_clk is required\n"); 249 dev_err(&pdev->dev, "couldn't get clock\n");
250 ret = -EINVAL; 250 ret = -EINVAL;
251 goto error0; 251 goto error0;
252 } 252 }
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 1a77ad52812f..67d8909dcf39 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -287,8 +287,8 @@ static irqreturn_t spi_sirfsoc_irq(int irq, void *dev_id)
287 sspi->left_rx_word) 287 sspi->left_rx_word)
288 sspi->rx_word(sspi); 288 sspi->rx_word(sspi);
289 289
290 if (spi_stat & (SIRFSOC_SPI_FIFO_EMPTY 290 if (spi_stat & (SIRFSOC_SPI_TXFIFO_EMPTY |
291 | SIRFSOC_SPI_TXFIFO_THD_REACH)) 291 SIRFSOC_SPI_TXFIFO_THD_REACH))
292 while (!((readl(sspi->base + SIRFSOC_SPI_TXFIFO_STATUS) 292 while (!((readl(sspi->base + SIRFSOC_SPI_TXFIFO_STATUS)
293 & SIRFSOC_SPI_FIFO_FULL)) && 293 & SIRFSOC_SPI_FIFO_FULL)) &&
294 sspi->left_tx_word) 294 sspi->left_tx_word)
@@ -470,7 +470,16 @@ static void spi_sirfsoc_chipselect(struct spi_device *spi, int value)
470 writel(regval, sspi->base + SIRFSOC_SPI_CTRL); 470 writel(regval, sspi->base + SIRFSOC_SPI_CTRL);
471 } else { 471 } else {
472 int gpio = sspi->chipselect[spi->chip_select]; 472 int gpio = sspi->chipselect[spi->chip_select];
473 gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); 473 switch (value) {
474 case BITBANG_CS_ACTIVE:
475 gpio_direction_output(gpio,
476 spi->mode & SPI_CS_HIGH ? 1 : 0);
477 break;
478 case BITBANG_CS_INACTIVE:
479 gpio_direction_output(gpio,
480 spi->mode & SPI_CS_HIGH ? 0 : 1);
481 break;
482 }
474 } 483 }
475} 484}
476 485
@@ -559,6 +568,11 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
559 regval &= ~SIRFSOC_SPI_CMD_MODE; 568 regval &= ~SIRFSOC_SPI_CMD_MODE;
560 sspi->tx_by_cmd = false; 569 sspi->tx_by_cmd = false;
561 } 570 }
571 /*
572 * set spi controller in RISC chipselect mode, we are controlling CS by
573 * software BITBANG_CS_ACTIVE and BITBANG_CS_INACTIVE.
574 */
575 regval |= SIRFSOC_SPI_CS_IO_MODE;
562 writel(regval, sspi->base + SIRFSOC_SPI_CTRL); 576 writel(regval, sspi->base + SIRFSOC_SPI_CTRL);
563 577
564 if (IS_DMA_VALID(t)) { 578 if (IS_DMA_VALID(t)) {
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 71db683098d6..b59af0303581 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -493,7 +493,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
493 /* pointer to the DA */ 493 /* pointer to the DA */
494 *datap++ = val & 0xff; 494 *datap++ = val & 0xff;
495 *datap++ = (val >> 8) & 0xff; 495 *datap++ = (val >> 8) & 0xff;
496 *datap++ = chan; 496 *datap++ = chan << 6;
497 devpriv->ao_readback[chan] = val; 497 devpriv->ao_readback[chan] = val;
498 498
499 s->async->events |= COMEDI_CB_BLOCK; 499 s->async->events |= COMEDI_CB_BLOCK;
@@ -1040,11 +1040,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
1040 /* set current channel of the running acquisition to zero */ 1040 /* set current channel of the running acquisition to zero */
1041 s->async->cur_chan = 0; 1041 s->async->cur_chan = 0;
1042 1042
1043 for (i = 0; i < cmd->chanlist_len; ++i) { 1043 for (i = 0; i < cmd->chanlist_len; ++i)
1044 unsigned int chan = CR_CHAN(cmd->chanlist[i]); 1044 devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
1045
1046 devpriv->ao_chanlist[i] = chan << 6;
1047 }
1048 1045
1049 /* we count in steps of 1ms (125us) */ 1046 /* we count in steps of 1ms (125us) */
1050 /* 125us mode not used yet */ 1047 /* 125us mode not used yet */
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 11fb95201545..dae8d1a9038e 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -1526,7 +1526,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
1526 struct resource *iores; 1526 struct resource *iores;
1527 int ret = 0, touch_ret; 1527 int ret = 0, touch_ret;
1528 int i, s; 1528 int i, s;
1529 unsigned int scale_uv; 1529 uint64_t scale_uv;
1530 1530
1531 /* Allocate the IIO device. */ 1531 /* Allocate the IIO device. */
1532 iio = devm_iio_device_alloc(dev, sizeof(*lradc)); 1532 iio = devm_iio_device_alloc(dev, sizeof(*lradc));
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c
index 36eedd8a0ea9..017d2f8379b7 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -70,6 +70,7 @@ static int ad2s1200_read_raw(struct iio_dev *indio_dev,
70 vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); 70 vel = (((s16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4);
71 vel = (vel << 4) >> 4; 71 vel = (vel << 4) >> 4;
72 *val = vel; 72 *val = vel;
73 break;
73 default: 74 default:
74 mutex_unlock(&st->lock); 75 mutex_unlock(&st->lock);
75 return -EINVAL; 76 return -EINVAL;
@@ -106,7 +107,7 @@ static int ad2s1200_probe(struct spi_device *spi)
106 int pn, ret = 0; 107 int pn, ret = 0;
107 unsigned short *pins = spi->dev.platform_data; 108 unsigned short *pins = spi->dev.platform_data;
108 109
109 for (pn = 0; pn < AD2S1200_PN; pn++) 110 for (pn = 0; pn < AD2S1200_PN; pn++) {
110 ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT, 111 ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT,
111 DRV_NAME); 112 DRV_NAME);
112 if (ret) { 113 if (ret) {
@@ -114,6 +115,7 @@ static int ad2s1200_probe(struct spi_device *spi)
114 pins[pn]); 115 pins[pn]);
115 return ret; 116 return ret;
116 } 117 }
118 }
117 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 119 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
118 if (!indio_dev) 120 if (!indio_dev)
119 return -ENOMEM; 121 return -ENOMEM;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 94f9e3a38412..0ff7fda0742f 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -190,7 +190,7 @@ static struct tty_driver *hvc_console_device(struct console *c, int *index)
190 return hvc_driver; 190 return hvc_driver;
191} 191}
192 192
193static int __init hvc_console_setup(struct console *co, char *options) 193static int hvc_console_setup(struct console *co, char *options)
194{ 194{
195 if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES) 195 if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES)
196 return -ENODEV; 196 return -ENODEV;
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 41fe8a047d37..fe9d129c8735 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2353,8 +2353,12 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
2353 if (tty->ops->flush_chars) 2353 if (tty->ops->flush_chars)
2354 tty->ops->flush_chars(tty); 2354 tty->ops->flush_chars(tty);
2355 } else { 2355 } else {
2356 struct n_tty_data *ldata = tty->disc_data;
2357
2356 while (nr > 0) { 2358 while (nr > 0) {
2359 mutex_lock(&ldata->output_lock);
2357 c = tty->ops->write(tty, b, nr); 2360 c = tty->ops->write(tty, b, nr);
2361 mutex_unlock(&ldata->output_lock);
2358 if (c < 0) { 2362 if (c < 0) {
2359 retval = c; 2363 retval = c;
2360 goto break_out; 2364 goto break_out;
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 81f909c2101f..2d4bd3929e50 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -555,7 +555,7 @@ static void serial8250_set_sleep(struct uart_8250_port *p, int sleep)
555 */ 555 */
556 if ((p->port.type == PORT_XR17V35X) || 556 if ((p->port.type == PORT_XR17V35X) ||
557 (p->port.type == PORT_XR17D15X)) { 557 (p->port.type == PORT_XR17D15X)) {
558 serial_out(p, UART_EXAR_SLEEP, 0xff); 558 serial_out(p, UART_EXAR_SLEEP, sleep ? 0xff : 0);
559 return; 559 return;
560 } 560 }
561 561
@@ -1520,7 +1520,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1520 status = serial8250_rx_chars(up, status); 1520 status = serial8250_rx_chars(up, status);
1521 } 1521 }
1522 serial8250_modem_status(up); 1522 serial8250_modem_status(up);
1523 if (status & UART_LSR_THRE) 1523 if (!up->dma && (status & UART_LSR_THRE))
1524 serial8250_tx_chars(up); 1524 serial8250_tx_chars(up);
1525 1525
1526 spin_unlock_irqrestore(&port->lock, flags); 1526 spin_unlock_irqrestore(&port->lock, flags);
diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 7046769608d4..ab9096dc3849 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -20,12 +20,15 @@ static void __dma_tx_complete(void *param)
20 struct uart_8250_port *p = param; 20 struct uart_8250_port *p = param;
21 struct uart_8250_dma *dma = p->dma; 21 struct uart_8250_dma *dma = p->dma;
22 struct circ_buf *xmit = &p->port.state->xmit; 22 struct circ_buf *xmit = &p->port.state->xmit;
23 23 unsigned long flags;
24 dma->tx_running = 0;
25 24
26 dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr, 25 dma_sync_single_for_cpu(dma->txchan->device->dev, dma->tx_addr,
27 UART_XMIT_SIZE, DMA_TO_DEVICE); 26 UART_XMIT_SIZE, DMA_TO_DEVICE);
28 27
28 spin_lock_irqsave(&p->port.lock, flags);
29
30 dma->tx_running = 0;
31
29 xmit->tail += dma->tx_size; 32 xmit->tail += dma->tx_size;
30 xmit->tail &= UART_XMIT_SIZE - 1; 33 xmit->tail &= UART_XMIT_SIZE - 1;
31 p->port.icount.tx += dma->tx_size; 34 p->port.icount.tx += dma->tx_size;
@@ -35,6 +38,8 @@ static void __dma_tx_complete(void *param)
35 38
36 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port)) 39 if (!uart_circ_empty(xmit) && !uart_tx_stopped(&p->port))
37 serial8250_tx_dma(p); 40 serial8250_tx_dma(p);
41
42 spin_unlock_irqrestore(&p->port.lock, flags);
38} 43}
39 44
40static void __dma_rx_complete(void *param) 45static void __dma_rx_complete(void *param)
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 23f459600738..1f5505e7f90d 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -1446,8 +1446,8 @@ static int s3c24xx_serial_get_poll_char(struct uart_port *port)
1446static void s3c24xx_serial_put_poll_char(struct uart_port *port, 1446static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1447 unsigned char c) 1447 unsigned char c)
1448{ 1448{
1449 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1449 unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
1450 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON); 1450 unsigned int ucon = rd_regl(port, S3C2410_UCON);
1451 1451
1452 /* not possible to xmit on unconfigured port */ 1452 /* not possible to xmit on unconfigured port */
1453 if (!s3c24xx_port_configured(ucon)) 1453 if (!s3c24xx_port_configured(ucon))
@@ -1455,7 +1455,7 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1455 1455
1456 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1456 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1457 cpu_relax(); 1457 cpu_relax();
1458 wr_regb(cons_uart, S3C2410_UTXH, c); 1458 wr_regb(port, S3C2410_UTXH, c);
1459} 1459}
1460 1460
1461#endif /* CONFIG_CONSOLE_POLL */ 1461#endif /* CONFIG_CONSOLE_POLL */
@@ -1463,22 +1463,23 @@ static void s3c24xx_serial_put_poll_char(struct uart_port *port,
1463static void 1463static void
1464s3c24xx_serial_console_putchar(struct uart_port *port, int ch) 1464s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
1465{ 1465{
1466 unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON); 1466 unsigned int ufcon = rd_regl(port, S3C2410_UFCON);
1467 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1468
1469 /* not possible to xmit on unconfigured port */
1470 if (!s3c24xx_port_configured(ucon))
1471 return;
1472 1467
1473 while (!s3c24xx_serial_console_txrdy(port, ufcon)) 1468 while (!s3c24xx_serial_console_txrdy(port, ufcon))
1474 barrier(); 1469 cpu_relax();
1475 wr_regb(cons_uart, S3C2410_UTXH, ch); 1470 wr_regb(port, S3C2410_UTXH, ch);
1476} 1471}
1477 1472
1478static void 1473static void
1479s3c24xx_serial_console_write(struct console *co, const char *s, 1474s3c24xx_serial_console_write(struct console *co, const char *s,
1480 unsigned int count) 1475 unsigned int count)
1481{ 1476{
1477 unsigned int ucon = rd_regl(cons_uart, S3C2410_UCON);
1478
1479 /* not possible to xmit on unconfigured port */
1480 if (!s3c24xx_port_configured(ucon))
1481 return;
1482
1482 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar); 1483 uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
1483} 1484}
1484 1485
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index f26834d262b3..b68550d95a40 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -137,6 +137,11 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
137 return 1; 137 return 1;
138 138
139 /* 139 /*
140 * Make sure the device is in D0 state.
141 */
142 uart_change_pm(state, UART_PM_STATE_ON);
143
144 /*
140 * Initialise and allocate the transmit and temporary 145 * Initialise and allocate the transmit and temporary
141 * buffer. 146 * buffer.
142 */ 147 */
@@ -825,25 +830,29 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
825 * If we fail to request resources for the 830 * If we fail to request resources for the
826 * new port, try to restore the old settings. 831 * new port, try to restore the old settings.
827 */ 832 */
828 if (retval && old_type != PORT_UNKNOWN) { 833 if (retval) {
829 uport->iobase = old_iobase; 834 uport->iobase = old_iobase;
830 uport->type = old_type; 835 uport->type = old_type;
831 uport->hub6 = old_hub6; 836 uport->hub6 = old_hub6;
832 uport->iotype = old_iotype; 837 uport->iotype = old_iotype;
833 uport->regshift = old_shift; 838 uport->regshift = old_shift;
834 uport->mapbase = old_mapbase; 839 uport->mapbase = old_mapbase;
835 retval = uport->ops->request_port(uport);
836 /*
837 * If we failed to restore the old settings,
838 * we fail like this.
839 */
840 if (retval)
841 uport->type = PORT_UNKNOWN;
842 840
843 /* 841 if (old_type != PORT_UNKNOWN) {
844 * We failed anyway. 842 retval = uport->ops->request_port(uport);
845 */ 843 /*
846 retval = -EBUSY; 844 * If we failed to restore the old settings,
845 * we fail like this.
846 */
847 if (retval)
848 uport->type = PORT_UNKNOWN;
849
850 /*
851 * We failed anyway.
852 */
853 retval = -EBUSY;
854 }
855
847 /* Added to return the correct error -Ram Gupta */ 856 /* Added to return the correct error -Ram Gupta */
848 goto exit; 857 goto exit;
849 } 858 }
@@ -1571,12 +1580,6 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
1571 } 1580 }
1572 1581
1573 /* 1582 /*
1574 * Make sure the device is in D0 state.
1575 */
1576 if (port->count == 1)
1577 uart_change_pm(state, UART_PM_STATE_ON);
1578
1579 /*
1580 * Start up the serial port. 1583 * Start up the serial port.
1581 */ 1584 */
1582 retval = uart_startup(tty, state, 0); 1585 retval = uart_startup(tty, state, 0);
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 8ebd9f88a6f6..cf78d1985cd8 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -258,7 +258,11 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
258 n->flags = flags; 258 n->flags = flags;
259 buf->tail = n; 259 buf->tail = n;
260 b->commit = b->used; 260 b->commit = b->used;
261 smp_mb(); 261 /* paired w/ barrier in flush_to_ldisc(); ensures the
262 * latest commit value can be read before the head is
263 * advanced to the next buffer
264 */
265 smp_wmb();
262 b->next = n; 266 b->next = n;
263 } else if (change) 267 } else if (change)
264 size = 0; 268 size = 0;
@@ -444,17 +448,24 @@ static void flush_to_ldisc(struct work_struct *work)
444 448
445 while (1) { 449 while (1) {
446 struct tty_buffer *head = buf->head; 450 struct tty_buffer *head = buf->head;
451 struct tty_buffer *next;
447 int count; 452 int count;
448 453
449 /* Ldisc or user is trying to gain exclusive access */ 454 /* Ldisc or user is trying to gain exclusive access */
450 if (atomic_read(&buf->priority)) 455 if (atomic_read(&buf->priority))
451 break; 456 break;
452 457
458 next = head->next;
459 /* paired w/ barrier in __tty_buffer_request_room();
460 * ensures commit value read is not stale if the head
461 * is advancing to the next buffer
462 */
463 smp_rmb();
453 count = head->commit - head->read; 464 count = head->commit - head->read;
454 if (!count) { 465 if (!count) {
455 if (head->next == NULL) 466 if (next == NULL)
456 break; 467 break;
457 buf->head = head->next; 468 buf->head = next;
458 tty_buffer_free(port, head); 469 tty_buffer_free(port, head);
459 continue; 470 continue;
460 } 471 }
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ca6831c5b763..1cd5d0ba587c 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -277,6 +277,39 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
277} 277}
278 278
279/** 279/**
280 * ci_usb_phy_init: initialize phy according to different phy type
281 * @ci: the controller
282 *
283 * This function returns an error code if usb_phy_init has failed
284 */
285static int ci_usb_phy_init(struct ci_hdrc *ci)
286{
287 int ret;
288
289 switch (ci->platdata->phy_mode) {
290 case USBPHY_INTERFACE_MODE_UTMI:
291 case USBPHY_INTERFACE_MODE_UTMIW:
292 case USBPHY_INTERFACE_MODE_HSIC:
293 ret = usb_phy_init(ci->transceiver);
294 if (ret)
295 return ret;
296 hw_phymode_configure(ci);
297 break;
298 case USBPHY_INTERFACE_MODE_ULPI:
299 case USBPHY_INTERFACE_MODE_SERIAL:
300 hw_phymode_configure(ci);
301 ret = usb_phy_init(ci->transceiver);
302 if (ret)
303 return ret;
304 break;
305 default:
306 ret = usb_phy_init(ci->transceiver);
307 }
308
309 return ret;
310}
311
312/**
280 * hw_device_reset: resets chip (execute without interruption) 313 * hw_device_reset: resets chip (execute without interruption)
281 * @ci: the controller 314 * @ci: the controller
282 * 315 *
@@ -543,8 +576,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
543 return -ENODEV; 576 return -ENODEV;
544 } 577 }
545 578
546 hw_phymode_configure(ci);
547
548 if (ci->platdata->phy) 579 if (ci->platdata->phy)
549 ci->transceiver = ci->platdata->phy; 580 ci->transceiver = ci->platdata->phy;
550 else 581 else
@@ -564,7 +595,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
564 return -EPROBE_DEFER; 595 return -EPROBE_DEFER;
565 } 596 }
566 597
567 ret = usb_phy_init(ci->transceiver); 598 ret = ci_usb_phy_init(ci);
568 if (ret) { 599 if (ret) {
569 dev_err(dev, "unable to init phy: %d\n", ret); 600 dev_err(dev, "unable to init phy: %d\n", ret);
570 return ret; 601 return ret;
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d001417e8e37..10aaaae9af25 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -821,6 +821,7 @@ static void dwc3_complete(struct device *dev)
821 821
822 spin_lock_irqsave(&dwc->lock, flags); 822 spin_lock_irqsave(&dwc->lock, flags);
823 823
824 dwc3_event_buffers_setup(dwc);
824 switch (dwc->dr_mode) { 825 switch (dwc->dr_mode) {
825 case USB_DR_MODE_PERIPHERAL: 826 case USB_DR_MODE_PERIPHERAL:
826 case USB_DR_MODE_OTG: 827 case USB_DR_MODE_OTG:
@@ -828,7 +829,6 @@ static void dwc3_complete(struct device *dev)
828 /* FALLTHROUGH */ 829 /* FALLTHROUGH */
829 case USB_DR_MODE_HOST: 830 case USB_DR_MODE_HOST:
830 default: 831 default:
831 dwc3_event_buffers_setup(dwc);
832 break; 832 break;
833 } 833 }
834 834
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a740eac74d56..70715eeededd 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -187,15 +187,12 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
187 * improve this algorithm so that we better use the internal 187 * improve this algorithm so that we better use the internal
188 * FIFO space 188 * FIFO space
189 */ 189 */
190 for (num = 0; num < DWC3_ENDPOINTS_NUM; num++) { 190 for (num = 0; num < dwc->num_in_eps; num++) {
191 struct dwc3_ep *dep = dwc->eps[num]; 191 /* bit0 indicates direction; 1 means IN ep */
192 int fifo_number = dep->number >> 1; 192 struct dwc3_ep *dep = dwc->eps[(num << 1) | 1];
193 int mult = 1; 193 int mult = 1;
194 int tmp; 194 int tmp;
195 195
196 if (!(dep->number & 1))
197 continue;
198
199 if (!(dep->flags & DWC3_EP_ENABLED)) 196 if (!(dep->flags & DWC3_EP_ENABLED))
200 continue; 197 continue;
201 198
@@ -224,8 +221,7 @@ int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc)
224 dev_vdbg(dwc->dev, "%s: Fifo Addr %04x Size %d\n", 221 dev_vdbg(dwc->dev, "%s: Fifo Addr %04x Size %d\n",
225 dep->name, last_fifo_depth, fifo_size & 0xffff); 222 dep->name, last_fifo_depth, fifo_size & 0xffff);
226 223
227 dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(fifo_number), 224 dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(num), fifo_size);
228 fifo_size);
229 225
230 last_fifo_depth += (fifo_size & 0xffff); 226 last_fifo_depth += (fifo_size & 0xffff);
231 } 227 }
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index f605ad8c1902..cfd18bcca723 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1709,16 +1709,6 @@ static int at91udc_probe(struct platform_device *pdev)
1709 return -ENODEV; 1709 return -ENODEV;
1710 } 1710 }
1711 1711
1712 if (pdev->num_resources != 2) {
1713 DBG("invalid num_resources\n");
1714 return -ENODEV;
1715 }
1716 if ((pdev->resource[0].flags != IORESOURCE_MEM)
1717 || (pdev->resource[1].flags != IORESOURCE_IRQ)) {
1718 DBG("invalid resource type\n");
1719 return -ENODEV;
1720 }
1721
1722 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1712 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1723 if (!res) 1713 if (!res)
1724 return -ENXIO; 1714 return -ENXIO;
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 2e164dca08e8..1e12b3ee56fd 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -745,6 +745,12 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
745 */ 745 */
746 struct usb_gadget *gadget = epfile->ffs->gadget; 746 struct usb_gadget *gadget = epfile->ffs->gadget;
747 747
748 spin_lock_irq(&epfile->ffs->eps_lock);
749 /* In the meantime, endpoint got disabled or changed. */
750 if (epfile->ep != ep) {
751 spin_unlock_irq(&epfile->ffs->eps_lock);
752 return -ESHUTDOWN;
753 }
748 /* 754 /*
749 * Controller may require buffer size to be aligned to 755 * Controller may require buffer size to be aligned to
750 * maxpacketsize of an out endpoint. 756 * maxpacketsize of an out endpoint.
@@ -752,6 +758,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
752 data_len = io_data->read ? 758 data_len = io_data->read ?
753 usb_ep_align_maybe(gadget, ep->ep, io_data->len) : 759 usb_ep_align_maybe(gadget, ep->ep, io_data->len) :
754 io_data->len; 760 io_data->len;
761 spin_unlock_irq(&epfile->ffs->eps_lock);
755 762
756 data = kmalloc(data_len, GFP_KERNEL); 763 data = kmalloc(data_len, GFP_KERNEL);
757 if (unlikely(!data)) 764 if (unlikely(!data))
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index c11761ce5113..9a4f49dc6ac4 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -377,7 +377,7 @@ static struct sk_buff *rndis_add_header(struct gether *port,
377 if (skb2) 377 if (skb2)
378 rndis_add_hdr(skb2); 378 rndis_add_hdr(skb2);
379 379
380 dev_kfree_skb_any(skb); 380 dev_kfree_skb(skb);
381 return skb2; 381 return skb2;
382} 382}
383 383
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 15960af0f67e..a2f26cdb56fe 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1219,6 +1219,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
1219 struct fsl_udc *udc; 1219 struct fsl_udc *udc;
1220 1220
1221 udc = container_of(gadget, struct fsl_udc, gadget); 1221 udc = container_of(gadget, struct fsl_udc, gadget);
1222
1223 if (!udc->vbus_active)
1224 return -EOPNOTSUPP;
1225
1222 udc->softconnect = (is_on != 0); 1226 udc->softconnect = (is_on != 0);
1223 if (can_pullup(udc)) 1227 if (can_pullup(udc))
1224 fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP), 1228 fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),
@@ -2532,8 +2536,8 @@ static int __exit fsl_udc_remove(struct platform_device *pdev)
2532 if (!udc_controller) 2536 if (!udc_controller)
2533 return -ENODEV; 2537 return -ENODEV;
2534 2538
2535 usb_del_gadget_udc(&udc_controller->gadget);
2536 udc_controller->done = &done; 2539 udc_controller->done = &done;
2540 usb_del_gadget_udc(&udc_controller->gadget);
2537 2541
2538 fsl_udc_clk_release(); 2542 fsl_udc_clk_release();
2539 2543
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index b5be6f0308c2..a925d0cbcd41 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -2043,6 +2043,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
2043 return -ESRCH; 2043 return -ESRCH;
2044 2044
2045 /* fake probe to determine $CHIP */ 2045 /* fake probe to determine $CHIP */
2046 CHIP = NULL;
2046 usb_gadget_probe_driver(&probe_driver); 2047 usb_gadget_probe_driver(&probe_driver);
2047 if (!CHIP) 2048 if (!CHIP)
2048 return -ENODEV; 2049 return -ENODEV;
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index d822d822efb3..7ed452d90f4d 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -35,6 +35,7 @@
35#include <asm/byteorder.h> 35#include <asm/byteorder.h>
36#include <asm/unaligned.h> 36#include <asm/unaligned.h>
37 37
38#include "u_rndis.h"
38 39
39#undef VERBOSE_DEBUG 40#undef VERBOSE_DEBUG
40 41
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 50d09c289137..b7d4f82872b7 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -48,8 +48,6 @@
48 48
49#define UETH__VERSION "29-May-2008" 49#define UETH__VERSION "29-May-2008"
50 50
51#define GETHER_NAPI_WEIGHT 32
52
53struct eth_dev { 51struct eth_dev {
54 /* lock is held while accessing port_usb 52 /* lock is held while accessing port_usb
55 */ 53 */
@@ -74,7 +72,6 @@ struct eth_dev {
74 struct sk_buff_head *list); 72 struct sk_buff_head *list);
75 73
76 struct work_struct work; 74 struct work_struct work;
77 struct napi_struct rx_napi;
78 75
79 unsigned long todo; 76 unsigned long todo;
80#define WORK_RX_MEMORY 0 77#define WORK_RX_MEMORY 0
@@ -256,16 +253,18 @@ enomem:
256 DBG(dev, "rx submit --> %d\n", retval); 253 DBG(dev, "rx submit --> %d\n", retval);
257 if (skb) 254 if (skb)
258 dev_kfree_skb_any(skb); 255 dev_kfree_skb_any(skb);
256 spin_lock_irqsave(&dev->req_lock, flags);
257 list_add(&req->list, &dev->rx_reqs);
258 spin_unlock_irqrestore(&dev->req_lock, flags);
259 } 259 }
260 return retval; 260 return retval;
261} 261}
262 262
263static void rx_complete(struct usb_ep *ep, struct usb_request *req) 263static void rx_complete(struct usb_ep *ep, struct usb_request *req)
264{ 264{
265 struct sk_buff *skb = req->context; 265 struct sk_buff *skb = req->context, *skb2;
266 struct eth_dev *dev = ep->driver_data; 266 struct eth_dev *dev = ep->driver_data;
267 int status = req->status; 267 int status = req->status;
268 bool rx_queue = 0;
269 268
270 switch (status) { 269 switch (status) {
271 270
@@ -289,8 +288,30 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req)
289 } else { 288 } else {
290 skb_queue_tail(&dev->rx_frames, skb); 289 skb_queue_tail(&dev->rx_frames, skb);
291 } 290 }
292 if (!status) 291 skb = NULL;
293 rx_queue = 1; 292
293 skb2 = skb_dequeue(&dev->rx_frames);
294 while (skb2) {
295 if (status < 0
296 || ETH_HLEN > skb2->len
297 || skb2->len > VLAN_ETH_FRAME_LEN) {
298 dev->net->stats.rx_errors++;
299 dev->net->stats.rx_length_errors++;
300 DBG(dev, "rx length %d\n", skb2->len);
301 dev_kfree_skb_any(skb2);
302 goto next_frame;
303 }
304 skb2->protocol = eth_type_trans(skb2, dev->net);
305 dev->net->stats.rx_packets++;
306 dev->net->stats.rx_bytes += skb2->len;
307
308 /* no buffer copies needed, unless hardware can't
309 * use skb buffers.
310 */
311 status = netif_rx(skb2);
312next_frame:
313 skb2 = skb_dequeue(&dev->rx_frames);
314 }
294 break; 315 break;
295 316
296 /* software-driven interface shutdown */ 317 /* software-driven interface shutdown */
@@ -313,20 +334,22 @@ quiesce:
313 /* FALLTHROUGH */ 334 /* FALLTHROUGH */
314 335
315 default: 336 default:
316 rx_queue = 1;
317 dev_kfree_skb_any(skb);
318 dev->net->stats.rx_errors++; 337 dev->net->stats.rx_errors++;
319 DBG(dev, "rx status %d\n", status); 338 DBG(dev, "rx status %d\n", status);
320 break; 339 break;
321 } 340 }
322 341
342 if (skb)
343 dev_kfree_skb_any(skb);
344 if (!netif_running(dev->net)) {
323clean: 345clean:
324 spin_lock(&dev->req_lock); 346 spin_lock(&dev->req_lock);
325 list_add(&req->list, &dev->rx_reqs); 347 list_add(&req->list, &dev->rx_reqs);
326 spin_unlock(&dev->req_lock); 348 spin_unlock(&dev->req_lock);
327 349 req = NULL;
328 if (rx_queue && likely(napi_schedule_prep(&dev->rx_napi))) 350 }
329 __napi_schedule(&dev->rx_napi); 351 if (req)
352 rx_submit(dev, req, GFP_ATOMIC);
330} 353}
331 354
332static int prealloc(struct list_head *list, struct usb_ep *ep, unsigned n) 355static int prealloc(struct list_head *list, struct usb_ep *ep, unsigned n)
@@ -391,24 +414,16 @@ static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
391{ 414{
392 struct usb_request *req; 415 struct usb_request *req;
393 unsigned long flags; 416 unsigned long flags;
394 int rx_counts = 0;
395 417
396 /* fill unused rxq slots with some skb */ 418 /* fill unused rxq slots with some skb */
397 spin_lock_irqsave(&dev->req_lock, flags); 419 spin_lock_irqsave(&dev->req_lock, flags);
398 while (!list_empty(&dev->rx_reqs)) { 420 while (!list_empty(&dev->rx_reqs)) {
399
400 if (++rx_counts > qlen(dev->gadget, dev->qmult))
401 break;
402
403 req = container_of(dev->rx_reqs.next, 421 req = container_of(dev->rx_reqs.next,
404 struct usb_request, list); 422 struct usb_request, list);
405 list_del_init(&req->list); 423 list_del_init(&req->list);
406 spin_unlock_irqrestore(&dev->req_lock, flags); 424 spin_unlock_irqrestore(&dev->req_lock, flags);
407 425
408 if (rx_submit(dev, req, gfp_flags) < 0) { 426 if (rx_submit(dev, req, gfp_flags) < 0) {
409 spin_lock_irqsave(&dev->req_lock, flags);
410 list_add(&req->list, &dev->rx_reqs);
411 spin_unlock_irqrestore(&dev->req_lock, flags);
412 defer_kevent(dev, WORK_RX_MEMORY); 427 defer_kevent(dev, WORK_RX_MEMORY);
413 return; 428 return;
414 } 429 }
@@ -418,41 +433,6 @@ static void rx_fill(struct eth_dev *dev, gfp_t gfp_flags)
418 spin_unlock_irqrestore(&dev->req_lock, flags); 433 spin_unlock_irqrestore(&dev->req_lock, flags);
419} 434}
420 435
421static int gether_poll(struct napi_struct *napi, int budget)
422{
423 struct eth_dev *dev = container_of(napi, struct eth_dev, rx_napi);
424 struct sk_buff *skb;
425 unsigned int work_done = 0;
426 int status = 0;
427
428 while ((skb = skb_dequeue(&dev->rx_frames))) {
429 if (status < 0
430 || ETH_HLEN > skb->len
431 || skb->len > VLAN_ETH_FRAME_LEN) {
432 dev->net->stats.rx_errors++;
433 dev->net->stats.rx_length_errors++;
434 DBG(dev, "rx length %d\n", skb->len);
435 dev_kfree_skb_any(skb);
436 continue;
437 }
438 skb->protocol = eth_type_trans(skb, dev->net);
439 dev->net->stats.rx_packets++;
440 dev->net->stats.rx_bytes += skb->len;
441
442 status = netif_rx_ni(skb);
443 }
444
445 if (netif_running(dev->net)) {
446 rx_fill(dev, GFP_KERNEL);
447 work_done++;
448 }
449
450 if (work_done < budget)
451 napi_complete(&dev->rx_napi);
452
453 return work_done;
454}
455
456static void eth_work(struct work_struct *work) 436static void eth_work(struct work_struct *work)
457{ 437{
458 struct eth_dev *dev = container_of(work, struct eth_dev, work); 438 struct eth_dev *dev = container_of(work, struct eth_dev, work);
@@ -645,7 +625,6 @@ static void eth_start(struct eth_dev *dev, gfp_t gfp_flags)
645 /* and open the tx floodgates */ 625 /* and open the tx floodgates */
646 atomic_set(&dev->tx_qlen, 0); 626 atomic_set(&dev->tx_qlen, 0);
647 netif_wake_queue(dev->net); 627 netif_wake_queue(dev->net);
648 napi_enable(&dev->rx_napi);
649} 628}
650 629
651static int eth_open(struct net_device *net) 630static int eth_open(struct net_device *net)
@@ -672,7 +651,6 @@ static int eth_stop(struct net_device *net)
672 unsigned long flags; 651 unsigned long flags;
673 652
674 VDBG(dev, "%s\n", __func__); 653 VDBG(dev, "%s\n", __func__);
675 napi_disable(&dev->rx_napi);
676 netif_stop_queue(net); 654 netif_stop_queue(net);
677 655
678 DBG(dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n", 656 DBG(dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld\n",
@@ -790,7 +768,6 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g,
790 return ERR_PTR(-ENOMEM); 768 return ERR_PTR(-ENOMEM);
791 769
792 dev = netdev_priv(net); 770 dev = netdev_priv(net);
793 netif_napi_add(net, &dev->rx_napi, gether_poll, GETHER_NAPI_WEIGHT);
794 spin_lock_init(&dev->lock); 771 spin_lock_init(&dev->lock);
795 spin_lock_init(&dev->req_lock); 772 spin_lock_init(&dev->req_lock);
796 INIT_WORK(&dev->work, eth_work); 773 INIT_WORK(&dev->work, eth_work);
@@ -853,7 +830,6 @@ struct net_device *gether_setup_name_default(const char *netname)
853 return ERR_PTR(-ENOMEM); 830 return ERR_PTR(-ENOMEM);
854 831
855 dev = netdev_priv(net); 832 dev = netdev_priv(net);
856 netif_napi_add(net, &dev->rx_napi, gether_poll, GETHER_NAPI_WEIGHT);
857 spin_lock_init(&dev->lock); 833 spin_lock_init(&dev->lock);
858 spin_lock_init(&dev->req_lock); 834 spin_lock_init(&dev->req_lock);
859 INIT_WORK(&dev->work, eth_work); 835 INIT_WORK(&dev->work, eth_work);
@@ -1137,7 +1113,6 @@ void gether_disconnect(struct gether *link)
1137{ 1113{
1138 struct eth_dev *dev = link->ioport; 1114 struct eth_dev *dev = link->ioport;
1139 struct usb_request *req; 1115 struct usb_request *req;
1140 struct sk_buff *skb;
1141 1116
1142 WARN_ON(!dev); 1117 WARN_ON(!dev);
1143 if (!dev) 1118 if (!dev)
@@ -1164,12 +1139,6 @@ void gether_disconnect(struct gether *link)
1164 spin_lock(&dev->req_lock); 1139 spin_lock(&dev->req_lock);
1165 } 1140 }
1166 spin_unlock(&dev->req_lock); 1141 spin_unlock(&dev->req_lock);
1167
1168 spin_lock(&dev->rx_frames.lock);
1169 while ((skb = __skb_dequeue(&dev->rx_frames)))
1170 dev_kfree_skb_any(skb);
1171 spin_unlock(&dev->rx_frames.lock);
1172
1173 link->in_ep->driver_data = NULL; 1142 link->in_ep->driver_data = NULL;
1174 link->in_ep->desc = NULL; 1143 link->in_ep->desc = NULL;
1175 1144
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 9f170c53e3d9..134f354ede62 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -300,7 +300,7 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
300 ss_opts->isoc_interval = gzero_options.isoc_interval; 300 ss_opts->isoc_interval = gzero_options.isoc_interval;
301 ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket; 301 ss_opts->isoc_maxpacket = gzero_options.isoc_maxpacket;
302 ss_opts->isoc_mult = gzero_options.isoc_mult; 302 ss_opts->isoc_mult = gzero_options.isoc_mult;
303 ss_opts->isoc_maxburst = gzero_options.isoc_maxpacket; 303 ss_opts->isoc_maxburst = gzero_options.isoc_maxburst;
304 ss_opts->bulk_buflen = gzero_options.bulk_buflen; 304 ss_opts->bulk_buflen = gzero_options.bulk_buflen;
305 305
306 func_ss = usb_get_function(func_inst_ss); 306 func_ss = usb_get_function(func_inst_ss);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6f2c8d3899d2..cf2734b532a7 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -248,7 +248,8 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
248 break; 248 break;
249 } 249 }
250 250
251 if (pdata->have_sysif_regs && pdata->controller_ver && 251 if (pdata->have_sysif_regs &&
252 pdata->controller_ver > FSL_USB_VER_1_6 &&
252 (phy_mode == FSL_USB2_PHY_ULPI)) { 253 (phy_mode == FSL_USB2_PHY_ULPI)) {
253 /* check PHY_CLK_VALID to get phy clk valid */ 254 /* check PHY_CLK_VALID to get phy clk valid */
254 if (!(spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & 255 if (!(spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) &
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index c81c8721cc5a..cd871b895013 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -90,6 +90,24 @@ __acquires(ohci->lock)
90 dl_done_list (ohci); 90 dl_done_list (ohci);
91 finish_unlinks (ohci, ohci_frame_no(ohci)); 91 finish_unlinks (ohci, ohci_frame_no(ohci));
92 92
93 /*
94 * Some controllers don't handle "global" suspend properly if
95 * there are unsuspended ports. For these controllers, put all
96 * the enabled ports into suspend before suspending the root hub.
97 */
98 if (ohci->flags & OHCI_QUIRK_GLOBAL_SUSPEND) {
99 __hc32 __iomem *portstat = ohci->regs->roothub.portstatus;
100 int i;
101 unsigned temp;
102
103 for (i = 0; i < ohci->num_ports; (++i, ++portstat)) {
104 temp = ohci_readl(ohci, portstat);
105 if ((temp & (RH_PS_PES | RH_PS_PSS)) ==
106 RH_PS_PES)
107 ohci_writel(ohci, RH_PS_PSS, portstat);
108 }
109 }
110
93 /* maybe resume can wake root hub */ 111 /* maybe resume can wake root hub */
94 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) { 112 if (ohci_to_hcd(ohci)->self.root_hub->do_remote_wakeup || autostop) {
95 ohci->hc_control |= OHCI_CTRL_RWE; 113 ohci->hc_control |= OHCI_CTRL_RWE;
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 90879e9ccbec..bb1509675727 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -160,6 +160,7 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
160 ohci_dbg(ohci, "enabled AMD prefetch quirk\n"); 160 ohci_dbg(ohci, "enabled AMD prefetch quirk\n");
161 } 161 }
162 162
163 ohci->flags |= OHCI_QUIRK_GLOBAL_SUSPEND;
163 return 0; 164 return 0;
164} 165}
165 166
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 9250cada13f0..4550ce05af7f 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -405,6 +405,8 @@ struct ohci_hcd {
405#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */ 405#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */
406#define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/ 406#define OHCI_QUIRK_AMD_PLL 0x200 /* AMD PLL quirk*/
407#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */ 407#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
408#define OHCI_QUIRK_GLOBAL_SUSPEND 0x800 /* must suspend ports */
409
408 // there are also chip quirks/bugs in init logic 410 // there are also chip quirks/bugs in init logic
409 411
410 struct work_struct nec_work; /* Worker for NEC quirk */ 412 struct work_struct nec_work; /* Worker for NEC quirk */
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 47390e369cd4..35d447780707 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -134,6 +134,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
134 */ 134 */
135 if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP) 135 if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)
136 xhci->quirks |= XHCI_SPURIOUS_WAKEUP; 136 xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
137
138 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
137 } 139 }
138 if (pdev->vendor == PCI_VENDOR_ID_ETRON && 140 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
139 pdev->device == PCI_DEVICE_ID_ASROCK_P67) { 141 pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
@@ -143,9 +145,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
143 xhci->quirks |= XHCI_TRUST_TX_LENGTH; 145 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
144 } 146 }
145 if (pdev->vendor == PCI_VENDOR_ID_RENESAS && 147 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
146 pdev->device == 0x0015 && 148 pdev->device == 0x0015)
147 pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG &&
148 pdev->subsystem_device == 0xc0cd)
149 xhci->quirks |= XHCI_RESET_ON_RESUME; 149 xhci->quirks |= XHCI_RESET_ON_RESUME;
150 if (pdev->vendor == PCI_VENDOR_ID_VIA) 150 if (pdev->vendor == PCI_VENDOR_ID_VIA)
151 xhci->quirks |= XHCI_RESET_ON_RESUME; 151 xhci->quirks |= XHCI_RESET_ON_RESUME;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 5f926bea5ab1..7a0e3c720c00 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -550,6 +550,7 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
550 struct xhci_ring *ep_ring; 550 struct xhci_ring *ep_ring;
551 struct xhci_generic_trb *trb; 551 struct xhci_generic_trb *trb;
552 dma_addr_t addr; 552 dma_addr_t addr;
553 u64 hw_dequeue;
553 554
554 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, 555 ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id,
555 ep_index, stream_id); 556 ep_index, stream_id);
@@ -559,16 +560,6 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
559 stream_id); 560 stream_id);
560 return; 561 return;
561 } 562 }
562 state->new_cycle_state = 0;
563 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
564 "Finding segment containing stopped TRB.");
565 state->new_deq_seg = find_trb_seg(cur_td->start_seg,
566 dev->eps[ep_index].stopped_trb,
567 &state->new_cycle_state);
568 if (!state->new_deq_seg) {
569 WARN_ON(1);
570 return;
571 }
572 563
573 /* Dig out the cycle state saved by the xHC during the stop ep cmd */ 564 /* Dig out the cycle state saved by the xHC during the stop ep cmd */
574 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 565 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
@@ -577,46 +568,57 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci,
577 if (ep->ep_state & EP_HAS_STREAMS) { 568 if (ep->ep_state & EP_HAS_STREAMS) {
578 struct xhci_stream_ctx *ctx = 569 struct xhci_stream_ctx *ctx =
579 &ep->stream_info->stream_ctx_array[stream_id]; 570 &ep->stream_info->stream_ctx_array[stream_id];
580 state->new_cycle_state = 0x1 & le64_to_cpu(ctx->stream_ring); 571 hw_dequeue = le64_to_cpu(ctx->stream_ring);
581 } else { 572 } else {
582 struct xhci_ep_ctx *ep_ctx 573 struct xhci_ep_ctx *ep_ctx
583 = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); 574 = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
584 state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq); 575 hw_dequeue = le64_to_cpu(ep_ctx->deq);
585 } 576 }
586 577
578 /* Find virtual address and segment of hardware dequeue pointer */
579 state->new_deq_seg = ep_ring->deq_seg;
580 state->new_deq_ptr = ep_ring->dequeue;
581 while (xhci_trb_virt_to_dma(state->new_deq_seg, state->new_deq_ptr)
582 != (dma_addr_t)(hw_dequeue & ~0xf)) {
583 next_trb(xhci, ep_ring, &state->new_deq_seg,
584 &state->new_deq_ptr);
585 if (state->new_deq_ptr == ep_ring->dequeue) {
586 WARN_ON(1);
587 return;
588 }
589 }
590 /*
591 * Find cycle state for last_trb, starting at old cycle state of
592 * hw_dequeue. If there is only one segment ring, find_trb_seg() will
593 * return immediately and cannot toggle the cycle state if this search
594 * wraps around, so add one more toggle manually in that case.
595 */
596 state->new_cycle_state = hw_dequeue & 0x1;
597 if (ep_ring->first_seg == ep_ring->first_seg->next &&
598 cur_td->last_trb < state->new_deq_ptr)
599 state->new_cycle_state ^= 0x1;
600
587 state->new_deq_ptr = cur_td->last_trb; 601 state->new_deq_ptr = cur_td->last_trb;
588 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 602 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
589 "Finding segment containing last TRB in TD."); 603 "Finding segment containing last TRB in TD.");
590 state->new_deq_seg = find_trb_seg(state->new_deq_seg, 604 state->new_deq_seg = find_trb_seg(state->new_deq_seg,
591 state->new_deq_ptr, 605 state->new_deq_ptr, &state->new_cycle_state);
592 &state->new_cycle_state);
593 if (!state->new_deq_seg) { 606 if (!state->new_deq_seg) {
594 WARN_ON(1); 607 WARN_ON(1);
595 return; 608 return;
596 } 609 }
597 610
611 /* Increment to find next TRB after last_trb. Cycle if appropriate. */
598 trb = &state->new_deq_ptr->generic; 612 trb = &state->new_deq_ptr->generic;
599 if (TRB_TYPE_LINK_LE32(trb->field[3]) && 613 if (TRB_TYPE_LINK_LE32(trb->field[3]) &&
600 (trb->field[3] & cpu_to_le32(LINK_TOGGLE))) 614 (trb->field[3] & cpu_to_le32(LINK_TOGGLE)))
601 state->new_cycle_state ^= 0x1; 615 state->new_cycle_state ^= 0x1;
602 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr); 616 next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr);
603 617
604 /* 618 /* Don't update the ring cycle state for the producer (us). */
605 * If there is only one segment in a ring, find_trb_seg()'s while loop
606 * will not run, and it will return before it has a chance to see if it
607 * needs to toggle the cycle bit. It can't tell if the stalled transfer
608 * ended just before the link TRB on a one-segment ring, or if the TD
609 * wrapped around the top of the ring, because it doesn't have the TD in
610 * question. Look for the one-segment case where stalled TRB's address
611 * is greater than the new dequeue pointer address.
612 */
613 if (ep_ring->first_seg == ep_ring->first_seg->next &&
614 state->new_deq_ptr < dev->eps[ep_index].stopped_trb)
615 state->new_cycle_state ^= 0x1;
616 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 619 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
617 "Cycle state = 0x%x", state->new_cycle_state); 620 "Cycle state = 0x%x", state->new_cycle_state);
618 621
619 /* Don't update the ring cycle state for the producer (us). */
620 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, 622 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
621 "New dequeue segment = %p (virtual)", 623 "New dequeue segment = %p (virtual)",
622 state->new_deq_seg); 624 state->new_deq_seg);
@@ -799,7 +801,6 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,
799 if (list_empty(&ep->cancelled_td_list)) { 801 if (list_empty(&ep->cancelled_td_list)) {
800 xhci_stop_watchdog_timer_in_irq(xhci, ep); 802 xhci_stop_watchdog_timer_in_irq(xhci, ep);
801 ep->stopped_td = NULL; 803 ep->stopped_td = NULL;
802 ep->stopped_trb = NULL;
803 ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 804 ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
804 return; 805 return;
805 } 806 }
@@ -867,11 +868,9 @@ remove_finished_td:
867 ring_doorbell_for_active_rings(xhci, slot_id, ep_index); 868 ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
868 } 869 }
869 870
870 /* Clear stopped_td and stopped_trb if endpoint is not halted */ 871 /* Clear stopped_td if endpoint is not halted */
871 if (!(ep->ep_state & EP_HALTED)) { 872 if (!(ep->ep_state & EP_HALTED))
872 ep->stopped_td = NULL; 873 ep->stopped_td = NULL;
873 ep->stopped_trb = NULL;
874 }
875 874
876 /* 875 /*
877 * Drop the lock and complete the URBs in the cancelled TD list. 876 * Drop the lock and complete the URBs in the cancelled TD list.
@@ -1941,14 +1940,12 @@ static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci,
1941 struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index]; 1940 struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
1942 ep->ep_state |= EP_HALTED; 1941 ep->ep_state |= EP_HALTED;
1943 ep->stopped_td = td; 1942 ep->stopped_td = td;
1944 ep->stopped_trb = event_trb;
1945 ep->stopped_stream = stream_id; 1943 ep->stopped_stream = stream_id;
1946 1944
1947 xhci_queue_reset_ep(xhci, slot_id, ep_index); 1945 xhci_queue_reset_ep(xhci, slot_id, ep_index);
1948 xhci_cleanup_stalled_ring(xhci, td->urb->dev, ep_index); 1946 xhci_cleanup_stalled_ring(xhci, td->urb->dev, ep_index);
1949 1947
1950 ep->stopped_td = NULL; 1948 ep->stopped_td = NULL;
1951 ep->stopped_trb = NULL;
1952 ep->stopped_stream = 0; 1949 ep->stopped_stream = 0;
1953 1950
1954 xhci_ring_cmd_db(xhci); 1951 xhci_ring_cmd_db(xhci);
@@ -2030,7 +2027,6 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
2030 * the ring dequeue pointer or take this TD off any lists yet. 2027 * the ring dequeue pointer or take this TD off any lists yet.
2031 */ 2028 */
2032 ep->stopped_td = td; 2029 ep->stopped_td = td;
2033 ep->stopped_trb = event_trb;
2034 return 0; 2030 return 0;
2035 } else { 2031 } else {
2036 if (trb_comp_code == COMP_STALL) { 2032 if (trb_comp_code == COMP_STALL) {
@@ -2042,7 +2038,6 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
2042 * USB class driver clear the stall later. 2038 * USB class driver clear the stall later.
2043 */ 2039 */
2044 ep->stopped_td = td; 2040 ep->stopped_td = td;
2045 ep->stopped_trb = event_trb;
2046 ep->stopped_stream = ep_ring->stream_id; 2041 ep->stopped_stream = ep_ring->stream_id;
2047 } else if (xhci_requires_manual_halt_cleanup(xhci, 2042 } else if (xhci_requires_manual_halt_cleanup(xhci,
2048 ep_ctx, trb_comp_code)) { 2043 ep_ctx, trb_comp_code)) {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8fe4e124ddd4..300836972faa 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -408,16 +408,16 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
408 408
409#else 409#else
410 410
411static int xhci_try_enable_msi(struct usb_hcd *hcd) 411static inline int xhci_try_enable_msi(struct usb_hcd *hcd)
412{ 412{
413 return 0; 413 return 0;
414} 414}
415 415
416static void xhci_cleanup_msix(struct xhci_hcd *xhci) 416static inline void xhci_cleanup_msix(struct xhci_hcd *xhci)
417{ 417{
418} 418}
419 419
420static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) 420static inline void xhci_msix_sync_irqs(struct xhci_hcd *xhci)
421{ 421{
422} 422}
423 423
@@ -2954,7 +2954,6 @@ void xhci_endpoint_reset(struct usb_hcd *hcd,
2954 xhci_ring_cmd_db(xhci); 2954 xhci_ring_cmd_db(xhci);
2955 } 2955 }
2956 virt_ep->stopped_td = NULL; 2956 virt_ep->stopped_td = NULL;
2957 virt_ep->stopped_trb = NULL;
2958 virt_ep->stopped_stream = 0; 2957 virt_ep->stopped_stream = 0;
2959 spin_unlock_irqrestore(&xhci->lock, flags); 2958 spin_unlock_irqrestore(&xhci->lock, flags);
2960 2959
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index d280e9213d08..4746816aed3e 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -865,8 +865,6 @@ struct xhci_virt_ep {
865#define EP_GETTING_NO_STREAMS (1 << 5) 865#define EP_GETTING_NO_STREAMS (1 << 5)
866 /* ---- Related to URB cancellation ---- */ 866 /* ---- Related to URB cancellation ---- */
867 struct list_head cancelled_td_list; 867 struct list_head cancelled_td_list;
868 /* The TRB that was last reported in a stopped endpoint ring */
869 union xhci_trb *stopped_trb;
870 struct xhci_td *stopped_td; 868 struct xhci_td *stopped_td;
871 unsigned int stopped_stream; 869 unsigned int stopped_stream;
872 /* Watchdog timer for stop endpoint command to cancel URBs */ 870 /* Watchdog timer for stop endpoint command to cancel URBs */
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 3372ded5def7..e2fd263585de 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -470,8 +470,9 @@ static int dsps_musb_exit(struct musb *musb)
470 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 470 struct dsps_glue *glue = dev_get_drvdata(dev->parent);
471 471
472 del_timer_sync(&glue->timer); 472 del_timer_sync(&glue->timer);
473
474 usb_phy_shutdown(musb->xceiv); 473 usb_phy_shutdown(musb->xceiv);
474 debugfs_remove_recursive(glue->dbgfs_root);
475
475 return 0; 476 return 0;
476} 477}
477 478
@@ -708,8 +709,6 @@ static int dsps_remove(struct platform_device *pdev)
708 pm_runtime_put(&pdev->dev); 709 pm_runtime_put(&pdev->dev);
709 pm_runtime_disable(&pdev->dev); 710 pm_runtime_disable(&pdev->dev);
710 711
711 debugfs_remove_recursive(glue->dbgfs_root);
712
713 return 0; 712 return 0;
714} 713}
715 714
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index d341c149a2f9..d369bf1f3936 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -316,7 +316,13 @@ static void omap_musb_mailbox_work(struct work_struct *mailbox_work)
316{ 316{
317 struct omap2430_glue *glue = container_of(mailbox_work, 317 struct omap2430_glue *glue = container_of(mailbox_work,
318 struct omap2430_glue, omap_musb_mailbox_work); 318 struct omap2430_glue, omap_musb_mailbox_work);
319 struct musb *musb = glue_to_musb(glue);
320 struct device *dev = musb->controller;
321
322 pm_runtime_get_sync(dev);
319 omap_musb_set_mailbox(glue); 323 omap_musb_set_mailbox(glue);
324 pm_runtime_mark_last_busy(dev);
325 pm_runtime_put_autosuspend(dev);
320} 326}
321 327
322static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci) 328static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci)
@@ -416,6 +422,7 @@ static int omap2430_musb_init(struct musb *musb)
416 omap_musb_set_mailbox(glue); 422 omap_musb_set_mailbox(glue);
417 423
418 phy_init(musb->phy); 424 phy_init(musb->phy);
425 phy_power_on(musb->phy);
419 426
420 pm_runtime_put_noidle(musb->controller); 427 pm_runtime_put_noidle(musb->controller);
421 return 0; 428 return 0;
@@ -478,6 +485,7 @@ static int omap2430_musb_exit(struct musb *musb)
478 del_timer_sync(&musb_idle_timer); 485 del_timer_sync(&musb_idle_timer);
479 486
480 omap2430_low_level_exit(musb); 487 omap2430_low_level_exit(musb);
488 phy_power_off(musb->phy);
481 phy_exit(musb->phy); 489 phy_exit(musb->phy);
482 490
483 return 0; 491 return 0;
diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index d75196ad5f2f..35b6083b7999 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -3,6 +3,7 @@
3#include <linux/err.h> 3#include <linux/err.h>
4#include <linux/of.h> 4#include <linux/of.h>
5#include <linux/io.h> 5#include <linux/io.h>
6#include <linux/delay.h>
6#include "am35x-phy-control.h" 7#include "am35x-phy-control.h"
7 8
8struct am335x_control_usb { 9struct am335x_control_usb {
@@ -86,6 +87,14 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on)
86 } 87 }
87 88
88 writel(val, usb_ctrl->phy_reg + reg); 89 writel(val, usb_ctrl->phy_reg + reg);
90
91 /*
92 * Give the PHY ~1ms to complete the power up operation.
93 * Tests have shown unstable behaviour if other USB PHY related
94 * registers are written too shortly after such a transition.
95 */
96 if (on)
97 mdelay(1);
89} 98}
90 99
91static const struct phy_control ctrl_am335x = { 100static const struct phy_control ctrl_am335x = {
diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c
index c47e5a6edde2..d03fadd2629f 100644
--- a/drivers/usb/phy/phy-fsm-usb.c
+++ b/drivers/usb/phy/phy-fsm-usb.c
@@ -303,17 +303,18 @@ int otg_statemachine(struct otg_fsm *fsm)
303 otg_set_state(fsm, OTG_STATE_A_WAIT_VRISE); 303 otg_set_state(fsm, OTG_STATE_A_WAIT_VRISE);
304 break; 304 break;
305 case OTG_STATE_A_WAIT_VRISE: 305 case OTG_STATE_A_WAIT_VRISE:
306 if (fsm->id || fsm->a_bus_drop || fsm->a_vbus_vld || 306 if (fsm->a_vbus_vld)
307 fsm->a_wait_vrise_tmout) {
308 otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); 307 otg_set_state(fsm, OTG_STATE_A_WAIT_BCON);
309 } 308 else if (fsm->id || fsm->a_bus_drop ||
309 fsm->a_wait_vrise_tmout)
310 otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
310 break; 311 break;
311 case OTG_STATE_A_WAIT_BCON: 312 case OTG_STATE_A_WAIT_BCON:
312 if (!fsm->a_vbus_vld) 313 if (!fsm->a_vbus_vld)
313 otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); 314 otg_set_state(fsm, OTG_STATE_A_VBUS_ERR);
314 else if (fsm->b_conn) 315 else if (fsm->b_conn)
315 otg_set_state(fsm, OTG_STATE_A_HOST); 316 otg_set_state(fsm, OTG_STATE_A_HOST);
316 else if (fsm->id | fsm->a_bus_drop | fsm->a_wait_bcon_tmout) 317 else if (fsm->id || fsm->a_bus_drop || fsm->a_wait_bcon_tmout)
317 otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL); 318 otg_set_state(fsm, OTG_STATE_A_WAIT_VFALL);
318 break; 319 break;
319 case OTG_STATE_A_HOST: 320 case OTG_STATE_A_HOST:
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 8afa813d690b..36b6bce33b20 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -132,6 +132,9 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type)
132 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { 132 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) {
133 pr_debug("PHY: unable to find transceiver of type %s\n", 133 pr_debug("PHY: unable to find transceiver of type %s\n",
134 usb_phy_type_string(type)); 134 usb_phy_type_string(type));
135 if (!IS_ERR(phy))
136 phy = ERR_PTR(-ENODEV);
137
135 goto err0; 138 goto err0;
136 } 139 }
137 140
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index a2db5be9c305..df90dae53eb9 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -28,6 +28,7 @@
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/serial.h> 30#include <linux/serial.h>
31#include <linux/swab.h>
31#include <linux/kfifo.h> 32#include <linux/kfifo.h>
32#include <linux/ioctl.h> 33#include <linux/ioctl.h>
33#include <linux/firmware.h> 34#include <linux/firmware.h>
@@ -280,7 +281,7 @@ static int read_download_mem(struct usb_device *dev, int start_address,
280{ 281{
281 int status = 0; 282 int status = 0;
282 __u8 read_length; 283 __u8 read_length;
283 __be16 be_start_address; 284 u16 be_start_address;
284 285
285 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length); 286 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length);
286 287
@@ -296,10 +297,14 @@ static int read_download_mem(struct usb_device *dev, int start_address,
296 if (read_length > 1) { 297 if (read_length > 1) {
297 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length); 298 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length);
298 } 299 }
299 be_start_address = cpu_to_be16(start_address); 300 /*
301 * NOTE: Must use swab as wIndex is sent in little-endian
302 * byte order regardless of host byte order.
303 */
304 be_start_address = swab16((u16)start_address);
300 status = ti_vread_sync(dev, UMPC_MEMORY_READ, 305 status = ti_vread_sync(dev, UMPC_MEMORY_READ,
301 (__u16)address_type, 306 (__u16)address_type,
302 (__force __u16)be_start_address, 307 be_start_address,
303 buffer, read_length); 308 buffer, read_length);
304 309
305 if (status) { 310 if (status) {
@@ -394,7 +399,7 @@ static int write_i2c_mem(struct edgeport_serial *serial,
394 struct device *dev = &serial->serial->dev->dev; 399 struct device *dev = &serial->serial->dev->dev;
395 int status = 0; 400 int status = 0;
396 int write_length; 401 int write_length;
397 __be16 be_start_address; 402 u16 be_start_address;
398 403
399 /* We can only send a maximum of 1 aligned byte page at a time */ 404 /* We can only send a maximum of 1 aligned byte page at a time */
400 405
@@ -409,11 +414,16 @@ static int write_i2c_mem(struct edgeport_serial *serial,
409 __func__, start_address, write_length); 414 __func__, start_address, write_length);
410 usb_serial_debug_data(dev, __func__, write_length, buffer); 415 usb_serial_debug_data(dev, __func__, write_length, buffer);
411 416
412 /* Write first page */ 417 /*
413 be_start_address = cpu_to_be16(start_address); 418 * Write first page.
419 *
420 * NOTE: Must use swab as wIndex is sent in little-endian byte order
421 * regardless of host byte order.
422 */
423 be_start_address = swab16((u16)start_address);
414 status = ti_vsend_sync(serial->serial->dev, 424 status = ti_vsend_sync(serial->serial->dev,
415 UMPC_MEMORY_WRITE, (__u16)address_type, 425 UMPC_MEMORY_WRITE, (__u16)address_type,
416 (__force __u16)be_start_address, 426 be_start_address,
417 buffer, write_length); 427 buffer, write_length);
418 if (status) { 428 if (status) {
419 dev_dbg(dev, "%s - ERROR %d\n", __func__, status); 429 dev_dbg(dev, "%s - ERROR %d\n", __func__, status);
@@ -436,11 +446,16 @@ static int write_i2c_mem(struct edgeport_serial *serial,
436 __func__, start_address, write_length); 446 __func__, start_address, write_length);
437 usb_serial_debug_data(dev, __func__, write_length, buffer); 447 usb_serial_debug_data(dev, __func__, write_length, buffer);
438 448
439 /* Write next page */ 449 /*
440 be_start_address = cpu_to_be16(start_address); 450 * Write next page.
451 *
452 * NOTE: Must use swab as wIndex is sent in little-endian byte
453 * order regardless of host byte order.
454 */
455 be_start_address = swab16((u16)start_address);
441 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE, 456 status = ti_vsend_sync(serial->serial->dev, UMPC_MEMORY_WRITE,
442 (__u16)address_type, 457 (__u16)address_type,
443 (__force __u16)be_start_address, 458 be_start_address,
444 buffer, write_length); 459 buffer, write_length);
445 if (status) { 460 if (status) {
446 dev_err(dev, "%s - ERROR %d\n", __func__, status); 461 dev_err(dev, "%s - ERROR %d\n", __func__, status);
@@ -585,8 +600,8 @@ static int get_descriptor_addr(struct edgeport_serial *serial,
585 if (rom_desc->Type == desc_type) 600 if (rom_desc->Type == desc_type)
586 return start_address; 601 return start_address;
587 602
588 start_address = start_address + sizeof(struct ti_i2c_desc) 603 start_address = start_address + sizeof(struct ti_i2c_desc) +
589 + rom_desc->Size; 604 le16_to_cpu(rom_desc->Size);
590 605
591 } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type); 606 } while ((start_address < TI_MAX_I2C_SIZE) && rom_desc->Type);
592 607
@@ -599,7 +614,7 @@ static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer)
599 __u16 i; 614 __u16 i;
600 __u8 cs = 0; 615 __u8 cs = 0;
601 616
602 for (i = 0; i < rom_desc->Size; i++) 617 for (i = 0; i < le16_to_cpu(rom_desc->Size); i++)
603 cs = (__u8)(cs + buffer[i]); 618 cs = (__u8)(cs + buffer[i]);
604 619
605 if (cs != rom_desc->CheckSum) { 620 if (cs != rom_desc->CheckSum) {
@@ -650,7 +665,7 @@ static int check_i2c_image(struct edgeport_serial *serial)
650 break; 665 break;
651 666
652 if ((start_address + sizeof(struct ti_i2c_desc) + 667 if ((start_address + sizeof(struct ti_i2c_desc) +
653 rom_desc->Size) > TI_MAX_I2C_SIZE) { 668 le16_to_cpu(rom_desc->Size)) > TI_MAX_I2C_SIZE) {
654 status = -ENODEV; 669 status = -ENODEV;
655 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__); 670 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__);
656 break; 671 break;
@@ -665,7 +680,8 @@ static int check_i2c_image(struct edgeport_serial *serial)
665 /* Read the descriptor data */ 680 /* Read the descriptor data */
666 status = read_rom(serial, start_address + 681 status = read_rom(serial, start_address +
667 sizeof(struct ti_i2c_desc), 682 sizeof(struct ti_i2c_desc),
668 rom_desc->Size, buffer); 683 le16_to_cpu(rom_desc->Size),
684 buffer);
669 if (status) 685 if (status)
670 break; 686 break;
671 687
@@ -674,7 +690,7 @@ static int check_i2c_image(struct edgeport_serial *serial)
674 break; 690 break;
675 } 691 }
676 start_address = start_address + sizeof(struct ti_i2c_desc) + 692 start_address = start_address + sizeof(struct ti_i2c_desc) +
677 rom_desc->Size; 693 le16_to_cpu(rom_desc->Size);
678 694
679 } while ((rom_desc->Type != I2C_DESC_TYPE_ION) && 695 } while ((rom_desc->Type != I2C_DESC_TYPE_ION) &&
680 (start_address < TI_MAX_I2C_SIZE)); 696 (start_address < TI_MAX_I2C_SIZE));
@@ -712,7 +728,7 @@ static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer)
712 728
713 /* Read the descriptor data */ 729 /* Read the descriptor data */
714 status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc), 730 status = read_rom(serial, start_address+sizeof(struct ti_i2c_desc),
715 rom_desc->Size, buffer); 731 le16_to_cpu(rom_desc->Size), buffer);
716 if (status) 732 if (status)
717 goto exit; 733 goto exit;
718 734
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 367c7f08b27c..f213ee978516 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -234,8 +234,31 @@ static void option_instat_callback(struct urb *urb);
234#define QUALCOMM_VENDOR_ID 0x05C6 234#define QUALCOMM_VENDOR_ID 0x05C6
235 235
236#define CMOTECH_VENDOR_ID 0x16d8 236#define CMOTECH_VENDOR_ID 0x16d8
237#define CMOTECH_PRODUCT_6008 0x6008 237#define CMOTECH_PRODUCT_6001 0x6001
238#define CMOTECH_PRODUCT_6280 0x6280 238#define CMOTECH_PRODUCT_CMU_300 0x6002
239#define CMOTECH_PRODUCT_6003 0x6003
240#define CMOTECH_PRODUCT_6004 0x6004
241#define CMOTECH_PRODUCT_6005 0x6005
242#define CMOTECH_PRODUCT_CGU_628A 0x6006
243#define CMOTECH_PRODUCT_CHE_628S 0x6007
244#define CMOTECH_PRODUCT_CMU_301 0x6008
245#define CMOTECH_PRODUCT_CHU_628 0x6280
246#define CMOTECH_PRODUCT_CHU_628S 0x6281
247#define CMOTECH_PRODUCT_CDU_680 0x6803
248#define CMOTECH_PRODUCT_CDU_685A 0x6804
249#define CMOTECH_PRODUCT_CHU_720S 0x7001
250#define CMOTECH_PRODUCT_7002 0x7002
251#define CMOTECH_PRODUCT_CHU_629K 0x7003
252#define CMOTECH_PRODUCT_7004 0x7004
253#define CMOTECH_PRODUCT_7005 0x7005
254#define CMOTECH_PRODUCT_CGU_629 0x7006
255#define CMOTECH_PRODUCT_CHU_629S 0x700a
256#define CMOTECH_PRODUCT_CHU_720I 0x7211
257#define CMOTECH_PRODUCT_7212 0x7212
258#define CMOTECH_PRODUCT_7213 0x7213
259#define CMOTECH_PRODUCT_7251 0x7251
260#define CMOTECH_PRODUCT_7252 0x7252
261#define CMOTECH_PRODUCT_7253 0x7253
239 262
240#define TELIT_VENDOR_ID 0x1bc7 263#define TELIT_VENDOR_ID 0x1bc7
241#define TELIT_PRODUCT_UC864E 0x1003 264#define TELIT_PRODUCT_UC864E 0x1003
@@ -287,6 +310,7 @@ static void option_instat_callback(struct urb *urb);
287#define ALCATEL_PRODUCT_X060S_X200 0x0000 310#define ALCATEL_PRODUCT_X060S_X200 0x0000
288#define ALCATEL_PRODUCT_X220_X500D 0x0017 311#define ALCATEL_PRODUCT_X220_X500D 0x0017
289#define ALCATEL_PRODUCT_L100V 0x011e 312#define ALCATEL_PRODUCT_L100V 0x011e
313#define ALCATEL_PRODUCT_L800MA 0x0203
290 314
291#define PIRELLI_VENDOR_ID 0x1266 315#define PIRELLI_VENDOR_ID 0x1266
292#define PIRELLI_PRODUCT_C100_1 0x1002 316#define PIRELLI_PRODUCT_C100_1 0x1002
@@ -349,6 +373,7 @@ static void option_instat_callback(struct urb *urb);
349#define OLIVETTI_PRODUCT_OLICARD100 0xc000 373#define OLIVETTI_PRODUCT_OLICARD100 0xc000
350#define OLIVETTI_PRODUCT_OLICARD145 0xc003 374#define OLIVETTI_PRODUCT_OLICARD145 0xc003
351#define OLIVETTI_PRODUCT_OLICARD200 0xc005 375#define OLIVETTI_PRODUCT_OLICARD200 0xc005
376#define OLIVETTI_PRODUCT_OLICARD500 0xc00b
352 377
353/* Celot products */ 378/* Celot products */
354#define CELOT_VENDOR_ID 0x211f 379#define CELOT_VENDOR_ID 0x211f
@@ -502,6 +527,10 @@ static const struct option_blacklist_info huawei_cdc12_blacklist = {
502 .reserved = BIT(1) | BIT(2), 527 .reserved = BIT(1) | BIT(2),
503}; 528};
504 529
530static const struct option_blacklist_info net_intf0_blacklist = {
531 .reserved = BIT(0),
532};
533
505static const struct option_blacklist_info net_intf1_blacklist = { 534static const struct option_blacklist_info net_intf1_blacklist = {
506 .reserved = BIT(1), 535 .reserved = BIT(1),
507}; 536};
@@ -1035,8 +1064,47 @@ static const struct usb_device_id option_ids[] = {
1035 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 1064 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
1036 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */ 1065 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
1037 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */ 1066 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
1038 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6280) }, /* BP3-USB & BP3-EXT HSDPA */ 1067 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
1039 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, 1068 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
1069 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
1070 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1071 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6004) },
1072 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6005) },
1073 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_628A) },
1074 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHE_628S),
1075 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1076 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_301),
1077 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1078 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628),
1079 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1080 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_628S) },
1081 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_680) },
1082 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CDU_685A) },
1083 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720S),
1084 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1085 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7002),
1086 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1087 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629K),
1088 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1089 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7004),
1090 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1091 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7005) },
1092 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CGU_629),
1093 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1094 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_629S),
1095 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1096 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CHU_720I),
1097 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1098 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7212),
1099 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1100 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7213),
1101 .driver_info = (kernel_ulong_t)&net_intf0_blacklist },
1102 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7251),
1103 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1104 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7252),
1105 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1106 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_7253),
1107 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1040 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 1108 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
1041 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, 1109 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
1042 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) }, 1110 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) },
@@ -1500,6 +1568,8 @@ static const struct usb_device_id option_ids[] = {
1500 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 1568 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1501 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V), 1569 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V),
1502 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1570 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1571 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L800MA),
1572 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1503 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 1573 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
1504 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 1574 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
1505 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), 1575 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
@@ -1545,6 +1615,9 @@ static const struct usb_device_id option_ids[] = {
1545 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200), 1615 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200),
1546 .driver_info = (kernel_ulong_t)&net_intf6_blacklist 1616 .driver_info = (kernel_ulong_t)&net_intf6_blacklist
1547 }, 1617 },
1618 { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD500),
1619 .driver_info = (kernel_ulong_t)&net_intf4_blacklist
1620 },
1548 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ 1621 { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
1549 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ 1622 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
1550 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, 1623 { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) },
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 968a40201e5f..6c0a542e8ec1 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -136,12 +136,36 @@ static const struct usb_device_id id_table[] = {
136 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 0)}, /* Sierra Wireless MC7710 Device Management */ 136 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 0)}, /* Sierra Wireless MC7710 Device Management */
137 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 2)}, /* Sierra Wireless MC7710 NMEA */ 137 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 2)}, /* Sierra Wireless MC7710 NMEA */
138 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 3)}, /* Sierra Wireless MC7710 Modem */ 138 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68a2, 3)}, /* Sierra Wireless MC7710 Modem */
139 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 0)}, /* Sierra Wireless MC73xx Device Management */
140 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 2)}, /* Sierra Wireless MC73xx NMEA */
141 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x68c0, 3)}, /* Sierra Wireless MC73xx Modem */
139 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 0)}, /* Sierra Wireless EM7700 Device Management */ 142 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 0)}, /* Sierra Wireless EM7700 Device Management */
140 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 2)}, /* Sierra Wireless EM7700 NMEA */ 143 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 2)}, /* Sierra Wireless EM7700 NMEA */
141 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 3)}, /* Sierra Wireless EM7700 Modem */ 144 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901c, 3)}, /* Sierra Wireless EM7700 Modem */
145 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 0)}, /* Sierra Wireless EM7355 Device Management */
146 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 2)}, /* Sierra Wireless EM7355 NMEA */
147 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x901f, 3)}, /* Sierra Wireless EM7355 Modem */
148 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 0)}, /* Sierra Wireless MC7305/MC7355 Device Management */
149 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 2)}, /* Sierra Wireless MC7305/MC7355 NMEA */
150 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9041, 3)}, /* Sierra Wireless MC7305/MC7355 Modem */
142 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)}, /* Netgear AirCard 340U Device Management */ 151 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 0)}, /* Netgear AirCard 340U Device Management */
143 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)}, /* Netgear AirCard 340U NMEA */ 152 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 2)}, /* Netgear AirCard 340U NMEA */
144 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)}, /* Netgear AirCard 340U Modem */ 153 {USB_DEVICE_INTERFACE_NUMBER(0x1199, 0x9051, 3)}, /* Netgear AirCard 340U Modem */
154 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 0)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */
155 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */
156 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a2, 3)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card Modem */
157 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 0)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card Device Management */
158 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 2)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card NMEA */
159 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a3, 3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card Modem */
160 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 0)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card Device Management */
161 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 2)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card NMEA */
162 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a4, 3)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card Modem */
163 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 0)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card Device Management */
164 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 2)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card NMEA */
165 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a8, 3)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card Modem */
166 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 0)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card Device Management */
167 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 2)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card NMEA */
168 {USB_DEVICE_INTERFACE_NUMBER(0x413c, 0x81a9, 3)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card Modem */
145 169
146 { } /* Terminating entry */ 170 { } /* Terminating entry */
147}; 171};
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 81fc0dfcfdcf..6d40d56378d7 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1347,10 +1347,12 @@ static int usb_serial_register(struct usb_serial_driver *driver)
1347static void usb_serial_deregister(struct usb_serial_driver *device) 1347static void usb_serial_deregister(struct usb_serial_driver *device)
1348{ 1348{
1349 pr_info("USB Serial deregistering driver %s\n", device->description); 1349 pr_info("USB Serial deregistering driver %s\n", device->description);
1350
1350 mutex_lock(&table_lock); 1351 mutex_lock(&table_lock);
1351 list_del(&device->driver_list); 1352 list_del(&device->driver_list);
1352 usb_serial_bus_deregister(device);
1353 mutex_unlock(&table_lock); 1353 mutex_unlock(&table_lock);
1354
1355 usb_serial_bus_deregister(device);
1354} 1356}
1355 1357
1356/** 1358/**
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 4ef2a80728f7..008d805c3d21 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1851,7 +1851,7 @@ static int usbat_probe(struct usb_interface *intf,
1851 us->transport_name = "Shuttle USBAT"; 1851 us->transport_name = "Shuttle USBAT";
1852 us->transport = usbat_flash_transport; 1852 us->transport = usbat_flash_transport;
1853 us->transport_reset = usb_stor_CB_reset; 1853 us->transport_reset = usb_stor_CB_reset;
1854 us->max_lun = 1; 1854 us->max_lun = 0;
1855 1855
1856 result = usb_stor_probe2(us); 1856 result = usb_stor_probe2(us);
1857 return result; 1857 return result;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index f4a82291894a..174a447868cd 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -234,6 +234,20 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
234 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 234 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
235 US_FL_MAX_SECTORS_64 ), 235 US_FL_MAX_SECTORS_64 ),
236 236
237/* Reported by Daniele Forsi <dforsi@gmail.com> */
238UNUSUAL_DEV( 0x0421, 0x04b9, 0x0350, 0x0350,
239 "Nokia",
240 "5300",
241 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
242 US_FL_MAX_SECTORS_64 ),
243
244/* Patch submitted by Victor A. Santos <victoraur.santos@gmail.com> */
245UNUSUAL_DEV( 0x0421, 0x05af, 0x0742, 0x0742,
246 "Nokia",
247 "305",
248 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
249 US_FL_MAX_SECTORS_64),
250
237/* Patch submitted by Mikhail Zolotaryov <lebon@lebon.org.ua> */ 251/* Patch submitted by Mikhail Zolotaryov <lebon@lebon.org.ua> */
238UNUSUAL_DEV( 0x0421, 0x06aa, 0x1110, 0x1110, 252UNUSUAL_DEV( 0x0421, 0x06aa, 0x1110, 0x1110,
239 "Nokia", 253 "Nokia",
diff --git a/drivers/usb/wusbcore/mmc.c b/drivers/usb/wusbcore/mmc.c
index 44741267c917..3f485df96226 100644
--- a/drivers/usb/wusbcore/mmc.c
+++ b/drivers/usb/wusbcore/mmc.c
@@ -301,7 +301,7 @@ int wusbhc_chid_set(struct wusbhc *wusbhc, const struct wusb_ckhdid *chid)
301 301
302 if (chid) 302 if (chid)
303 result = uwb_radio_start(&wusbhc->pal); 303 result = uwb_radio_start(&wusbhc->pal);
304 else 304 else if (wusbhc->uwb_rc)
305 uwb_radio_stop(&wusbhc->pal); 305 uwb_radio_stop(&wusbhc->pal);
306 306
307 return result; 307 return result;
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index c8e2a47d62a7..3e2e4ed20157 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -2390,10 +2390,10 @@ error_complete:
2390 done) { 2390 done) {
2391 2391
2392 dev_info(dev, "Control EP stall. Queue delayed work.\n"); 2392 dev_info(dev, "Control EP stall. Queue delayed work.\n");
2393 spin_lock_irq(&wa->xfer_list_lock); 2393 spin_lock(&wa->xfer_list_lock);
2394 /* move xfer from xfer_list to xfer_errored_list. */ 2394 /* move xfer from xfer_list to xfer_errored_list. */
2395 list_move_tail(&xfer->list_node, &wa->xfer_errored_list); 2395 list_move_tail(&xfer->list_node, &wa->xfer_errored_list);
2396 spin_unlock_irq(&wa->xfer_list_lock); 2396 spin_unlock(&wa->xfer_list_lock);
2397 spin_unlock_irqrestore(&xfer->lock, flags); 2397 spin_unlock_irqrestore(&xfer->lock, flags);
2398 queue_work(wusbd, &wa->xfer_error_work); 2398 queue_work(wusbd, &wa->xfer_error_work);
2399 } else { 2399 } else {
diff --git a/drivers/uwb/drp.c b/drivers/uwb/drp.c
index 1a2fd9795367..468c89fb6a16 100644
--- a/drivers/uwb/drp.c
+++ b/drivers/uwb/drp.c
@@ -59,6 +59,7 @@ static void uwb_rc_set_drp_cmd_done(struct uwb_rc *rc, void *arg,
59 struct uwb_rceb *reply, ssize_t reply_size) 59 struct uwb_rceb *reply, ssize_t reply_size)
60{ 60{
61 struct uwb_rc_evt_set_drp_ie *r = (struct uwb_rc_evt_set_drp_ie *)reply; 61 struct uwb_rc_evt_set_drp_ie *r = (struct uwb_rc_evt_set_drp_ie *)reply;
62 unsigned long flags;
62 63
63 if (r != NULL) { 64 if (r != NULL) {
64 if (r->bResultCode != UWB_RC_RES_SUCCESS) 65 if (r->bResultCode != UWB_RC_RES_SUCCESS)
@@ -67,14 +68,14 @@ static void uwb_rc_set_drp_cmd_done(struct uwb_rc *rc, void *arg,
67 } else 68 } else
68 dev_err(&rc->uwb_dev.dev, "SET-DRP-IE: timeout\n"); 69 dev_err(&rc->uwb_dev.dev, "SET-DRP-IE: timeout\n");
69 70
70 spin_lock_irq(&rc->rsvs_lock); 71 spin_lock_irqsave(&rc->rsvs_lock, flags);
71 if (rc->set_drp_ie_pending > 1) { 72 if (rc->set_drp_ie_pending > 1) {
72 rc->set_drp_ie_pending = 0; 73 rc->set_drp_ie_pending = 0;
73 uwb_rsv_queue_update(rc); 74 uwb_rsv_queue_update(rc);
74 } else { 75 } else {
75 rc->set_drp_ie_pending = 0; 76 rc->set_drp_ie_pending = 0;
76 } 77 }
77 spin_unlock_irq(&rc->rsvs_lock); 78 spin_unlock_irqrestore(&rc->rsvs_lock, flags);
78} 79}
79 80
80/** 81/**
diff --git a/fs/aio.c b/fs/aio.c
index 12a3de0ee6da..a0ed6c7d2cd2 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -112,6 +112,11 @@ struct kioctx {
112 112
113 struct work_struct free_work; 113 struct work_struct free_work;
114 114
115 /*
116 * signals when all in-flight requests are done
117 */
118 struct completion *requests_done;
119
115 struct { 120 struct {
116 /* 121 /*
117 * This counts the number of available slots in the ringbuffer, 122 * This counts the number of available slots in the ringbuffer,
@@ -508,6 +513,10 @@ static void free_ioctx_reqs(struct percpu_ref *ref)
508{ 513{
509 struct kioctx *ctx = container_of(ref, struct kioctx, reqs); 514 struct kioctx *ctx = container_of(ref, struct kioctx, reqs);
510 515
516 /* At this point we know that there are no any in-flight requests */
517 if (ctx->requests_done)
518 complete(ctx->requests_done);
519
511 INIT_WORK(&ctx->free_work, free_ioctx); 520 INIT_WORK(&ctx->free_work, free_ioctx);
512 schedule_work(&ctx->free_work); 521 schedule_work(&ctx->free_work);
513} 522}
@@ -718,7 +727,8 @@ err:
718 * when the processes owning a context have all exited to encourage 727 * when the processes owning a context have all exited to encourage
719 * the rapid destruction of the kioctx. 728 * the rapid destruction of the kioctx.
720 */ 729 */
721static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx) 730static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
731 struct completion *requests_done)
722{ 732{
723 if (!atomic_xchg(&ctx->dead, 1)) { 733 if (!atomic_xchg(&ctx->dead, 1)) {
724 struct kioctx_table *table; 734 struct kioctx_table *table;
@@ -747,7 +757,11 @@ static void kill_ioctx(struct mm_struct *mm, struct kioctx *ctx)
747 if (ctx->mmap_size) 757 if (ctx->mmap_size)
748 vm_munmap(ctx->mmap_base, ctx->mmap_size); 758 vm_munmap(ctx->mmap_base, ctx->mmap_size);
749 759
760 ctx->requests_done = requests_done;
750 percpu_ref_kill(&ctx->users); 761 percpu_ref_kill(&ctx->users);
762 } else {
763 if (requests_done)
764 complete(requests_done);
751 } 765 }
752} 766}
753 767
@@ -809,7 +823,7 @@ void exit_aio(struct mm_struct *mm)
809 */ 823 */
810 ctx->mmap_size = 0; 824 ctx->mmap_size = 0;
811 825
812 kill_ioctx(mm, ctx); 826 kill_ioctx(mm, ctx, NULL);
813 } 827 }
814} 828}
815 829
@@ -1185,7 +1199,7 @@ SYSCALL_DEFINE2(io_setup, unsigned, nr_events, aio_context_t __user *, ctxp)
1185 if (!IS_ERR(ioctx)) { 1199 if (!IS_ERR(ioctx)) {
1186 ret = put_user(ioctx->user_id, ctxp); 1200 ret = put_user(ioctx->user_id, ctxp);
1187 if (ret) 1201 if (ret)
1188 kill_ioctx(current->mm, ioctx); 1202 kill_ioctx(current->mm, ioctx, NULL);
1189 percpu_ref_put(&ioctx->users); 1203 percpu_ref_put(&ioctx->users);
1190 } 1204 }
1191 1205
@@ -1203,8 +1217,22 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx)
1203{ 1217{
1204 struct kioctx *ioctx = lookup_ioctx(ctx); 1218 struct kioctx *ioctx = lookup_ioctx(ctx);
1205 if (likely(NULL != ioctx)) { 1219 if (likely(NULL != ioctx)) {
1206 kill_ioctx(current->mm, ioctx); 1220 struct completion requests_done =
1221 COMPLETION_INITIALIZER_ONSTACK(requests_done);
1222
1223 /* Pass requests_done to kill_ioctx() where it can be set
1224 * in a thread-safe way. If we try to set it here then we have
1225 * a race condition if two io_destroy() called simultaneously.
1226 */
1227 kill_ioctx(current->mm, ioctx, &requests_done);
1207 percpu_ref_put(&ioctx->users); 1228 percpu_ref_put(&ioctx->users);
1229
1230 /* Wait until all IO for the context are done. Otherwise kernel
1231 * keep using user-space buffers even if user thinks the context
1232 * is destroyed.
1233 */
1234 wait_for_completion(&requests_done);
1235
1208 return 0; 1236 return 0;
1209 } 1237 }
1210 pr_debug("EINVAL: io_destroy: invalid context id\n"); 1238 pr_debug("EINVAL: io_destroy: invalid context id\n");
@@ -1299,10 +1327,8 @@ rw_common:
1299 &iovec, compat) 1327 &iovec, compat)
1300 : aio_setup_single_vector(req, rw, buf, &nr_segs, 1328 : aio_setup_single_vector(req, rw, buf, &nr_segs,
1301 iovec); 1329 iovec);
1302 if (ret) 1330 if (!ret)
1303 return ret; 1331 ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
1304
1305 ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
1306 if (ret < 0) { 1332 if (ret < 0) {
1307 if (iovec != &inline_vec) 1333 if (iovec != &inline_vec)
1308 kfree(iovec); 1334 kfree(iovec);
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 4c48df572bd6..ba6b88528dc7 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2058,6 +2058,20 @@ struct btrfs_ioctl_defrag_range_args {
2058#define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) 2058#define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt)
2059#define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ 2059#define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
2060 BTRFS_MOUNT_##opt) 2060 BTRFS_MOUNT_##opt)
2061#define btrfs_set_and_info(root, opt, fmt, args...) \
2062{ \
2063 if (!btrfs_test_opt(root, opt)) \
2064 btrfs_info(root->fs_info, fmt, ##args); \
2065 btrfs_set_opt(root->fs_info->mount_opt, opt); \
2066}
2067
2068#define btrfs_clear_and_info(root, opt, fmt, args...) \
2069{ \
2070 if (btrfs_test_opt(root, opt)) \
2071 btrfs_info(root->fs_info, fmt, ##args); \
2072 btrfs_clear_opt(root->fs_info->mount_opt, opt); \
2073}
2074
2061/* 2075/*
2062 * Inode flags 2076 * Inode flags
2063 */ 2077 */
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 029d46c2e170..983314932af3 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2861,7 +2861,7 @@ retry_root_backup:
2861 printk(KERN_ERR "BTRFS: failed to read log tree\n"); 2861 printk(KERN_ERR "BTRFS: failed to read log tree\n");
2862 free_extent_buffer(log_tree_root->node); 2862 free_extent_buffer(log_tree_root->node);
2863 kfree(log_tree_root); 2863 kfree(log_tree_root);
2864 goto fail_trans_kthread; 2864 goto fail_qgroup;
2865 } 2865 }
2866 /* returns with log_tree_root freed on success */ 2866 /* returns with log_tree_root freed on success */
2867 ret = btrfs_recover_log_trees(log_tree_root); 2867 ret = btrfs_recover_log_trees(log_tree_root);
@@ -2870,24 +2870,24 @@ retry_root_backup:
2870 "Failed to recover log tree"); 2870 "Failed to recover log tree");
2871 free_extent_buffer(log_tree_root->node); 2871 free_extent_buffer(log_tree_root->node);
2872 kfree(log_tree_root); 2872 kfree(log_tree_root);
2873 goto fail_trans_kthread; 2873 goto fail_qgroup;
2874 } 2874 }
2875 2875
2876 if (sb->s_flags & MS_RDONLY) { 2876 if (sb->s_flags & MS_RDONLY) {
2877 ret = btrfs_commit_super(tree_root); 2877 ret = btrfs_commit_super(tree_root);
2878 if (ret) 2878 if (ret)
2879 goto fail_trans_kthread; 2879 goto fail_qgroup;
2880 } 2880 }
2881 } 2881 }
2882 2882
2883 ret = btrfs_find_orphan_roots(tree_root); 2883 ret = btrfs_find_orphan_roots(tree_root);
2884 if (ret) 2884 if (ret)
2885 goto fail_trans_kthread; 2885 goto fail_qgroup;
2886 2886
2887 if (!(sb->s_flags & MS_RDONLY)) { 2887 if (!(sb->s_flags & MS_RDONLY)) {
2888 ret = btrfs_cleanup_fs_roots(fs_info); 2888 ret = btrfs_cleanup_fs_roots(fs_info);
2889 if (ret) 2889 if (ret)
2890 goto fail_trans_kthread; 2890 goto fail_qgroup;
2891 2891
2892 ret = btrfs_recover_relocation(tree_root); 2892 ret = btrfs_recover_relocation(tree_root);
2893 if (ret < 0) { 2893 if (ret < 0) {
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 1306487c82cf..5590af92094b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1542,6 +1542,7 @@ again:
1542 ret = 0; 1542 ret = 0;
1543 } 1543 }
1544 if (ret) { 1544 if (ret) {
1545 key.objectid = bytenr;
1545 key.type = BTRFS_EXTENT_ITEM_KEY; 1546 key.type = BTRFS_EXTENT_ITEM_KEY;
1546 key.offset = num_bytes; 1547 key.offset = num_bytes;
1547 btrfs_release_path(path); 1548 btrfs_release_path(path);
@@ -3542,11 +3543,13 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)
3542 return extended_to_chunk(flags | tmp); 3543 return extended_to_chunk(flags | tmp);
3543} 3544}
3544 3545
3545static u64 get_alloc_profile(struct btrfs_root *root, u64 flags) 3546static u64 get_alloc_profile(struct btrfs_root *root, u64 orig_flags)
3546{ 3547{
3547 unsigned seq; 3548 unsigned seq;
3549 u64 flags;
3548 3550
3549 do { 3551 do {
3552 flags = orig_flags;
3550 seq = read_seqbegin(&root->fs_info->profiles_lock); 3553 seq = read_seqbegin(&root->fs_info->profiles_lock);
3551 3554
3552 if (flags & BTRFS_BLOCK_GROUP_DATA) 3555 if (flags & BTRFS_BLOCK_GROUP_DATA)
@@ -5719,6 +5722,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
5719 5722
5720 if (ret > 0 && skinny_metadata) { 5723 if (ret > 0 && skinny_metadata) {
5721 skinny_metadata = false; 5724 skinny_metadata = false;
5725 key.objectid = bytenr;
5722 key.type = BTRFS_EXTENT_ITEM_KEY; 5726 key.type = BTRFS_EXTENT_ITEM_KEY;
5723 key.offset = num_bytes; 5727 key.offset = num_bytes;
5724 btrfs_release_path(path); 5728 btrfs_release_path(path);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index eb742c07e7a4..ae6af072b635 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -800,7 +800,7 @@ next_slot:
800 if (start > key.offset && end < extent_end) { 800 if (start > key.offset && end < extent_end) {
801 BUG_ON(del_nr > 0); 801 BUG_ON(del_nr > 0);
802 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 802 if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
803 ret = -EINVAL; 803 ret = -EOPNOTSUPP;
804 break; 804 break;
805 } 805 }
806 806
@@ -846,7 +846,7 @@ next_slot:
846 */ 846 */
847 if (start <= key.offset && end < extent_end) { 847 if (start <= key.offset && end < extent_end) {
848 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 848 if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
849 ret = -EINVAL; 849 ret = -EOPNOTSUPP;
850 break; 850 break;
851 } 851 }
852 852
@@ -872,7 +872,7 @@ next_slot:
872 if (start > key.offset && end >= extent_end) { 872 if (start > key.offset && end >= extent_end) {
873 BUG_ON(del_nr > 0); 873 BUG_ON(del_nr > 0);
874 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 874 if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
875 ret = -EINVAL; 875 ret = -EOPNOTSUPP;
876 break; 876 break;
877 } 877 }
878 878
@@ -1777,7 +1777,7 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
1777 start_pos = round_down(pos, root->sectorsize); 1777 start_pos = round_down(pos, root->sectorsize);
1778 if (start_pos > i_size_read(inode)) { 1778 if (start_pos > i_size_read(inode)) {
1779 /* Expand hole size to cover write data, preventing empty gap */ 1779 /* Expand hole size to cover write data, preventing empty gap */
1780 end_pos = round_up(pos + iov->iov_len, root->sectorsize); 1780 end_pos = round_up(pos + count, root->sectorsize);
1781 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); 1781 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos);
1782 if (err) { 1782 if (err) {
1783 mutex_unlock(&inode->i_mutex); 1783 mutex_unlock(&inode->i_mutex);
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index cc8ca193d830..86935f5ae291 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -176,7 +176,11 @@ static void start_caching(struct btrfs_root *root)
176 176
177 tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", 177 tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n",
178 root->root_key.objectid); 178 root->root_key.objectid);
179 BUG_ON(IS_ERR(tsk)); /* -ENOMEM */ 179 if (IS_ERR(tsk)) {
180 btrfs_warn(root->fs_info, "failed to start inode caching task");
181 btrfs_clear_and_info(root, CHANGE_INODE_CACHE,
182 "disabling inode map caching");
183 }
180} 184}
181 185
182int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) 186int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)
@@ -205,24 +209,14 @@ again:
205 209
206void btrfs_return_ino(struct btrfs_root *root, u64 objectid) 210void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
207{ 211{
208 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;
209 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; 212 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned;
210 213
211 if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 214 if (!btrfs_test_opt(root, INODE_MAP_CACHE))
212 return; 215 return;
213
214again: 216again:
215 if (root->cached == BTRFS_CACHE_FINISHED) { 217 if (root->cached == BTRFS_CACHE_FINISHED) {
216 __btrfs_add_free_space(ctl, objectid, 1); 218 __btrfs_add_free_space(pinned, objectid, 1);
217 } else { 219 } else {
218 /*
219 * If we are in the process of caching free ino chunks,
220 * to avoid adding the same inode number to the free_ino
221 * tree twice due to cross transaction, we'll leave it
222 * in the pinned tree until a transaction is committed
223 * or the caching work is done.
224 */
225
226 down_write(&root->fs_info->commit_root_sem); 220 down_write(&root->fs_info->commit_root_sem);
227 spin_lock(&root->cache_lock); 221 spin_lock(&root->cache_lock);
228 if (root->cached == BTRFS_CACHE_FINISHED) { 222 if (root->cached == BTRFS_CACHE_FINISHED) {
@@ -234,11 +228,7 @@ again:
234 228
235 start_caching(root); 229 start_caching(root);
236 230
237 if (objectid <= root->cache_progress || 231 __btrfs_add_free_space(pinned, objectid, 1);
238 objectid >= root->highest_objectid)
239 __btrfs_add_free_space(ctl, objectid, 1);
240 else
241 __btrfs_add_free_space(pinned, objectid, 1);
242 232
243 up_write(&root->fs_info->commit_root_sem); 233 up_write(&root->fs_info->commit_root_sem);
244 } 234 }
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e79ff6b90cb7..2ad7de94efef 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3066,7 +3066,7 @@ process_slot:
3066 new_key.offset + datal, 3066 new_key.offset + datal,
3067 1); 3067 1);
3068 if (ret) { 3068 if (ret) {
3069 if (ret != -EINVAL) 3069 if (ret != -EOPNOTSUPP)
3070 btrfs_abort_transaction(trans, 3070 btrfs_abort_transaction(trans,
3071 root, ret); 3071 root, ret);
3072 btrfs_end_transaction(trans, root); 3072 btrfs_end_transaction(trans, root);
@@ -3141,7 +3141,7 @@ process_slot:
3141 new_key.offset + datal, 3141 new_key.offset + datal,
3142 1); 3142 1);
3143 if (ret) { 3143 if (ret) {
3144 if (ret != -EINVAL) 3144 if (ret != -EOPNOTSUPP)
3145 btrfs_abort_transaction(trans, 3145 btrfs_abort_transaction(trans,
3146 root, ret); 3146 root, ret);
3147 btrfs_end_transaction(trans, root); 3147 btrfs_end_transaction(trans, root);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 1ac3ca98c429..eb6537a08c1b 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -349,6 +349,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
349 if (p->buf_len >= len) 349 if (p->buf_len >= len)
350 return 0; 350 return 0;
351 351
352 if (len > PATH_MAX) {
353 WARN_ON(1);
354 return -ENOMEM;
355 }
356
352 path_len = p->end - p->start; 357 path_len = p->end - p->start;
353 old_buf_len = p->buf_len; 358 old_buf_len = p->buf_len;
354 359
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 5011aadacab8..9601d25a4607 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -385,20 +385,6 @@ static match_table_t tokens = {
385 {Opt_err, NULL}, 385 {Opt_err, NULL},
386}; 386};
387 387
388#define btrfs_set_and_info(root, opt, fmt, args...) \
389{ \
390 if (!btrfs_test_opt(root, opt)) \
391 btrfs_info(root->fs_info, fmt, ##args); \
392 btrfs_set_opt(root->fs_info->mount_opt, opt); \
393}
394
395#define btrfs_clear_and_info(root, opt, fmt, args...) \
396{ \
397 if (btrfs_test_opt(root, opt)) \
398 btrfs_info(root->fs_info, fmt, ##args); \
399 btrfs_clear_opt(root->fs_info->mount_opt, opt); \
400}
401
402/* 388/*
403 * Regular mount options parser. Everything that is needed only when 389 * Regular mount options parser. Everything that is needed only when
404 * reading in a new superblock is parsed here. 390 * reading in a new superblock is parsed here.
@@ -1186,7 +1172,6 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
1186 return ERR_PTR(-ENOMEM); 1172 return ERR_PTR(-ENOMEM);
1187 mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, 1173 mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
1188 newargs); 1174 newargs);
1189 kfree(newargs);
1190 1175
1191 if (PTR_RET(mnt) == -EBUSY) { 1176 if (PTR_RET(mnt) == -EBUSY) {
1192 if (flags & MS_RDONLY) { 1177 if (flags & MS_RDONLY) {
@@ -1196,17 +1181,22 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags,
1196 int r; 1181 int r;
1197 mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, 1182 mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
1198 newargs); 1183 newargs);
1199 if (IS_ERR(mnt)) 1184 if (IS_ERR(mnt)) {
1185 kfree(newargs);
1200 return ERR_CAST(mnt); 1186 return ERR_CAST(mnt);
1187 }
1201 1188
1202 r = btrfs_remount(mnt->mnt_sb, &flags, NULL); 1189 r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
1203 if (r < 0) { 1190 if (r < 0) {
1204 /* FIXME: release vfsmount mnt ??*/ 1191 /* FIXME: release vfsmount mnt ??*/
1192 kfree(newargs);
1205 return ERR_PTR(r); 1193 return ERR_PTR(r);
1206 } 1194 }
1207 } 1195 }
1208 } 1196 }
1209 1197
1198 kfree(newargs);
1199
1210 if (IS_ERR(mnt)) 1200 if (IS_ERR(mnt))
1211 return ERR_CAST(mnt); 1201 return ERR_CAST(mnt);
1212 1202
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 2e5e648eb5c3..c561b628ebce 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3261,7 +3261,7 @@ int ceph_encode_inode_release(void **p, struct inode *inode,
3261 rel->seq = cpu_to_le32(cap->seq); 3261 rel->seq = cpu_to_le32(cap->seq);
3262 rel->issue_seq = cpu_to_le32(cap->issue_seq), 3262 rel->issue_seq = cpu_to_le32(cap->issue_seq),
3263 rel->mseq = cpu_to_le32(cap->mseq); 3263 rel->mseq = cpu_to_le32(cap->mseq);
3264 rel->caps = cpu_to_le32(cap->issued); 3264 rel->caps = cpu_to_le32(cap->implemented);
3265 rel->wanted = cpu_to_le32(cap->mds_wanted); 3265 rel->wanted = cpu_to_le32(cap->mds_wanted);
3266 rel->dname_len = 0; 3266 rel->dname_len = 0;
3267 rel->dname_seq = 0; 3267 rel->dname_seq = 0;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 766410a12c2c..c29d6ae68874 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -141,7 +141,7 @@ static int __dcache_readdir(struct file *file, struct dir_context *ctx,
141 141
142 /* start at beginning? */ 142 /* start at beginning? */
143 if (ctx->pos == 2 || last == NULL || 143 if (ctx->pos == 2 || last == NULL ||
144 ctx->pos < ceph_dentry(last)->offset) { 144 fpos_cmp(ctx->pos, ceph_dentry(last)->offset) < 0) {
145 if (list_empty(&parent->d_subdirs)) 145 if (list_empty(&parent->d_subdirs))
146 goto out_unlock; 146 goto out_unlock;
147 p = parent->d_subdirs.prev; 147 p = parent->d_subdirs.prev;
@@ -182,9 +182,16 @@ more:
182 spin_unlock(&dentry->d_lock); 182 spin_unlock(&dentry->d_lock);
183 spin_unlock(&parent->d_lock); 183 spin_unlock(&parent->d_lock);
184 184
185 /* make sure a dentry wasn't dropped while we didn't have parent lock */
186 if (!ceph_dir_is_complete(dir)) {
187 dout(" lost dir complete on %p; falling back to mds\n", dir);
188 dput(dentry);
189 err = -EAGAIN;
190 goto out;
191 }
192
185 dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, ctx->pos, 193 dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, ctx->pos,
186 dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode); 194 dentry, dentry->d_name.len, dentry->d_name.name, dentry->d_inode);
187 ctx->pos = di->offset;
188 if (!dir_emit(ctx, dentry->d_name.name, 195 if (!dir_emit(ctx, dentry->d_name.name,
189 dentry->d_name.len, 196 dentry->d_name.len,
190 ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino), 197 ceph_translate_ino(dentry->d_sb, dentry->d_inode->i_ino),
@@ -198,19 +205,12 @@ more:
198 return 0; 205 return 0;
199 } 206 }
200 207
208 ctx->pos = di->offset + 1;
209
201 if (last) 210 if (last)
202 dput(last); 211 dput(last);
203 last = dentry; 212 last = dentry;
204 213
205 ctx->pos++;
206
207 /* make sure a dentry wasn't dropped while we didn't have parent lock */
208 if (!ceph_dir_is_complete(dir)) {
209 dout(" lost dir complete on %p; falling back to mds\n", dir);
210 err = -EAGAIN;
211 goto out;
212 }
213
214 spin_lock(&parent->d_lock); 214 spin_lock(&parent->d_lock);
215 p = p->prev; /* advance to next dentry */ 215 p = p->prev; /* advance to next dentry */
216 goto more; 216 goto more;
@@ -296,6 +296,8 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
296 err = __dcache_readdir(file, ctx, shared_gen); 296 err = __dcache_readdir(file, ctx, shared_gen);
297 if (err != -EAGAIN) 297 if (err != -EAGAIN)
298 return err; 298 return err;
299 frag = fpos_frag(ctx->pos);
300 off = fpos_off(ctx->pos);
299 } else { 301 } else {
300 spin_unlock(&ci->i_ceph_lock); 302 spin_unlock(&ci->i_ceph_lock);
301 } 303 }
@@ -446,7 +448,6 @@ more:
446 if (atomic_read(&ci->i_release_count) == fi->dir_release_count) { 448 if (atomic_read(&ci->i_release_count) == fi->dir_release_count) {
447 dout(" marking %p complete\n", inode); 449 dout(" marking %p complete\n", inode);
448 __ceph_dir_set_complete(ci, fi->dir_release_count); 450 __ceph_dir_set_complete(ci, fi->dir_release_count);
449 ci->i_max_offset = ctx->pos;
450 } 451 }
451 spin_unlock(&ci->i_ceph_lock); 452 spin_unlock(&ci->i_ceph_lock);
452 453
@@ -935,14 +936,16 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
935 * to do it here. 936 * to do it here.
936 */ 937 */
937 938
938 /* d_move screws up d_subdirs order */
939 ceph_dir_clear_complete(new_dir);
940
941 d_move(old_dentry, new_dentry); 939 d_move(old_dentry, new_dentry);
942 940
943 /* ensure target dentry is invalidated, despite 941 /* ensure target dentry is invalidated, despite
944 rehashing bug in vfs_rename_dir */ 942 rehashing bug in vfs_rename_dir */
945 ceph_invalidate_dentry_lease(new_dentry); 943 ceph_invalidate_dentry_lease(new_dentry);
944
945 /* d_move screws up sibling dentries' offsets */
946 ceph_dir_clear_complete(old_dir);
947 ceph_dir_clear_complete(new_dir);
948
946 } 949 }
947 ceph_mdsc_put_request(req); 950 ceph_mdsc_put_request(req);
948 return err; 951 return err;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 39da1c2efa50..88a6df4cbe6d 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1221,9 +1221,6 @@ static long ceph_fallocate(struct file *file, int mode,
1221 if (!S_ISREG(inode->i_mode)) 1221 if (!S_ISREG(inode->i_mode))
1222 return -EOPNOTSUPP; 1222 return -EOPNOTSUPP;
1223 1223
1224 if (IS_SWAPFILE(inode))
1225 return -ETXTBSY;
1226
1227 mutex_lock(&inode->i_mutex); 1224 mutex_lock(&inode->i_mutex);
1228 1225
1229 if (ceph_snap(inode) != CEPH_NOSNAP) { 1226 if (ceph_snap(inode) != CEPH_NOSNAP) {
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 0b0728e5be2d..233c6f96910a 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -744,7 +744,6 @@ static int fill_inode(struct inode *inode,
744 !__ceph_dir_is_complete(ci)) { 744 !__ceph_dir_is_complete(ci)) {
745 dout(" marking %p complete (empty)\n", inode); 745 dout(" marking %p complete (empty)\n", inode);
746 __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count)); 746 __ceph_dir_set_complete(ci, atomic_read(&ci->i_release_count));
747 ci->i_max_offset = 2;
748 } 747 }
749no_change: 748no_change:
750 /* only update max_size on auth cap */ 749 /* only update max_size on auth cap */
@@ -890,41 +889,6 @@ out_unlock:
890} 889}
891 890
892/* 891/*
893 * Set dentry's directory position based on the current dir's max, and
894 * order it in d_subdirs, so that dcache_readdir behaves.
895 *
896 * Always called under directory's i_mutex.
897 */
898static void ceph_set_dentry_offset(struct dentry *dn)
899{
900 struct dentry *dir = dn->d_parent;
901 struct inode *inode = dir->d_inode;
902 struct ceph_inode_info *ci;
903 struct ceph_dentry_info *di;
904
905 BUG_ON(!inode);
906
907 ci = ceph_inode(inode);
908 di = ceph_dentry(dn);
909
910 spin_lock(&ci->i_ceph_lock);
911 if (!__ceph_dir_is_complete(ci)) {
912 spin_unlock(&ci->i_ceph_lock);
913 return;
914 }
915 di->offset = ceph_inode(inode)->i_max_offset++;
916 spin_unlock(&ci->i_ceph_lock);
917
918 spin_lock(&dir->d_lock);
919 spin_lock_nested(&dn->d_lock, DENTRY_D_LOCK_NESTED);
920 list_move(&dn->d_u.d_child, &dir->d_subdirs);
921 dout("set_dentry_offset %p %lld (%p %p)\n", dn, di->offset,
922 dn->d_u.d_child.prev, dn->d_u.d_child.next);
923 spin_unlock(&dn->d_lock);
924 spin_unlock(&dir->d_lock);
925}
926
927/*
928 * splice a dentry to an inode. 892 * splice a dentry to an inode.
929 * caller must hold directory i_mutex for this to be safe. 893 * caller must hold directory i_mutex for this to be safe.
930 * 894 *
@@ -933,7 +897,7 @@ static void ceph_set_dentry_offset(struct dentry *dn)
933 * the caller) if we fail. 897 * the caller) if we fail.
934 */ 898 */
935static struct dentry *splice_dentry(struct dentry *dn, struct inode *in, 899static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
936 bool *prehash, bool set_offset) 900 bool *prehash)
937{ 901{
938 struct dentry *realdn; 902 struct dentry *realdn;
939 903
@@ -965,8 +929,6 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
965 } 929 }
966 if ((!prehash || *prehash) && d_unhashed(dn)) 930 if ((!prehash || *prehash) && d_unhashed(dn))
967 d_rehash(dn); 931 d_rehash(dn);
968 if (set_offset)
969 ceph_set_dentry_offset(dn);
970out: 932out:
971 return dn; 933 return dn;
972} 934}
@@ -987,7 +949,6 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
987{ 949{
988 struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info; 950 struct ceph_mds_reply_info_parsed *rinfo = &req->r_reply_info;
989 struct inode *in = NULL; 951 struct inode *in = NULL;
990 struct ceph_mds_reply_inode *ininfo;
991 struct ceph_vino vino; 952 struct ceph_vino vino;
992 struct ceph_fs_client *fsc = ceph_sb_to_client(sb); 953 struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
993 int err = 0; 954 int err = 0;
@@ -1161,6 +1122,9 @@ retry_lookup:
1161 1122
1162 /* rename? */ 1123 /* rename? */
1163 if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) { 1124 if (req->r_old_dentry && req->r_op == CEPH_MDS_OP_RENAME) {
1125 struct inode *olddir = req->r_old_dentry_dir;
1126 BUG_ON(!olddir);
1127
1164 dout(" src %p '%.*s' dst %p '%.*s'\n", 1128 dout(" src %p '%.*s' dst %p '%.*s'\n",
1165 req->r_old_dentry, 1129 req->r_old_dentry,
1166 req->r_old_dentry->d_name.len, 1130 req->r_old_dentry->d_name.len,
@@ -1180,13 +1144,10 @@ retry_lookup:
1180 rehashing bug in vfs_rename_dir */ 1144 rehashing bug in vfs_rename_dir */
1181 ceph_invalidate_dentry_lease(dn); 1145 ceph_invalidate_dentry_lease(dn);
1182 1146
1183 /* 1147 /* d_move screws up sibling dentries' offsets */
1184 * d_move() puts the renamed dentry at the end of 1148 ceph_dir_clear_complete(dir);
1185 * d_subdirs. We need to assign it an appropriate 1149 ceph_dir_clear_complete(olddir);
1186 * directory offset so we can behave when dir is 1150
1187 * complete.
1188 */
1189 ceph_set_dentry_offset(req->r_old_dentry);
1190 dout("dn %p gets new offset %lld\n", req->r_old_dentry, 1151 dout("dn %p gets new offset %lld\n", req->r_old_dentry,
1191 ceph_dentry(req->r_old_dentry)->offset); 1152 ceph_dentry(req->r_old_dentry)->offset);
1192 1153
@@ -1213,8 +1174,9 @@ retry_lookup:
1213 1174
1214 /* attach proper inode */ 1175 /* attach proper inode */
1215 if (!dn->d_inode) { 1176 if (!dn->d_inode) {
1177 ceph_dir_clear_complete(dir);
1216 ihold(in); 1178 ihold(in);
1217 dn = splice_dentry(dn, in, &have_lease, true); 1179 dn = splice_dentry(dn, in, &have_lease);
1218 if (IS_ERR(dn)) { 1180 if (IS_ERR(dn)) {
1219 err = PTR_ERR(dn); 1181 err = PTR_ERR(dn);
1220 goto done; 1182 goto done;
@@ -1235,17 +1197,16 @@ retry_lookup:
1235 (req->r_op == CEPH_MDS_OP_LOOKUPSNAP || 1197 (req->r_op == CEPH_MDS_OP_LOOKUPSNAP ||
1236 req->r_op == CEPH_MDS_OP_MKSNAP)) { 1198 req->r_op == CEPH_MDS_OP_MKSNAP)) {
1237 struct dentry *dn = req->r_dentry; 1199 struct dentry *dn = req->r_dentry;
1200 struct inode *dir = req->r_locked_dir;
1238 1201
1239 /* fill out a snapdir LOOKUPSNAP dentry */ 1202 /* fill out a snapdir LOOKUPSNAP dentry */
1240 BUG_ON(!dn); 1203 BUG_ON(!dn);
1241 BUG_ON(!req->r_locked_dir); 1204 BUG_ON(!dir);
1242 BUG_ON(ceph_snap(req->r_locked_dir) != CEPH_SNAPDIR); 1205 BUG_ON(ceph_snap(dir) != CEPH_SNAPDIR);
1243 ininfo = rinfo->targeti.in;
1244 vino.ino = le64_to_cpu(ininfo->ino);
1245 vino.snap = le64_to_cpu(ininfo->snapid);
1246 dout(" linking snapped dir %p to dn %p\n", in, dn); 1206 dout(" linking snapped dir %p to dn %p\n", in, dn);
1207 ceph_dir_clear_complete(dir);
1247 ihold(in); 1208 ihold(in);
1248 dn = splice_dentry(dn, in, NULL, true); 1209 dn = splice_dentry(dn, in, NULL);
1249 if (IS_ERR(dn)) { 1210 if (IS_ERR(dn)) {
1250 err = PTR_ERR(dn); 1211 err = PTR_ERR(dn);
1251 goto done; 1212 goto done;
@@ -1407,7 +1368,7 @@ retry_lookup:
1407 } 1368 }
1408 1369
1409 if (!dn->d_inode) { 1370 if (!dn->d_inode) {
1410 dn = splice_dentry(dn, in, NULL, false); 1371 dn = splice_dentry(dn, in, NULL);
1411 if (IS_ERR(dn)) { 1372 if (IS_ERR(dn)) {
1412 err = PTR_ERR(dn); 1373 err = PTR_ERR(dn);
1413 dn = NULL; 1374 dn = NULL;
diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c
index fdf941b44ff1..a822a6e58290 100644
--- a/fs/ceph/ioctl.c
+++ b/fs/ceph/ioctl.c
@@ -109,6 +109,8 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
109 return PTR_ERR(req); 109 return PTR_ERR(req);
110 req->r_inode = inode; 110 req->r_inode = inode;
111 ihold(inode); 111 ihold(inode);
112 req->r_num_caps = 1;
113
112 req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; 114 req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL;
113 115
114 req->r_args.setlayout.layout.fl_stripe_unit = 116 req->r_args.setlayout.layout.fl_stripe_unit =
@@ -153,6 +155,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)
153 return PTR_ERR(req); 155 return PTR_ERR(req);
154 req->r_inode = inode; 156 req->r_inode = inode;
155 ihold(inode); 157 ihold(inode);
158 req->r_num_caps = 1;
156 159
157 req->r_args.setlayout.layout.fl_stripe_unit = 160 req->r_args.setlayout.layout.fl_stripe_unit =
158 cpu_to_le32(l.stripe_unit); 161 cpu_to_le32(l.stripe_unit);
diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c
index d94ba0df9f4d..191398852a2e 100644
--- a/fs/ceph/locks.c
+++ b/fs/ceph/locks.c
@@ -45,6 +45,7 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct file *file,
45 return PTR_ERR(req); 45 return PTR_ERR(req);
46 req->r_inode = inode; 46 req->r_inode = inode;
47 ihold(inode); 47 ihold(inode);
48 req->r_num_caps = 1;
48 49
49 /* mds requires start and length rather than start and end */ 50 /* mds requires start and length rather than start and end */
50 if (LLONG_MAX == fl->fl_end) 51 if (LLONG_MAX == fl->fl_end)
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 7866cd05a6bb..ead05cc1f447 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -266,7 +266,6 @@ struct ceph_inode_info {
266 struct timespec i_rctime; 266 struct timespec i_rctime;
267 u64 i_rbytes, i_rfiles, i_rsubdirs; 267 u64 i_rbytes, i_rfiles, i_rsubdirs;
268 u64 i_files, i_subdirs; 268 u64 i_files, i_subdirs;
269 u64 i_max_offset; /* largest readdir offset, set with complete dir */
270 269
271 struct rb_root i_fragtree; 270 struct rb_root i_fragtree;
272 struct mutex i_fragtree_mutex; 271 struct mutex i_fragtree_mutex;
diff --git a/fs/compat.c b/fs/compat.c
index ca926ad0430c..66d3d3c6b4b2 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
457 case F_GETLK64: 457 case F_GETLK64:
458 case F_SETLK64: 458 case F_SETLK64:
459 case F_SETLKW64: 459 case F_SETLKW64:
460 case F_GETLKP: 460 case F_OFD_GETLK:
461 case F_SETLKP: 461 case F_OFD_SETLK:
462 case F_SETLKPW: 462 case F_OFD_SETLKW:
463 ret = get_compat_flock64(&f, compat_ptr(arg)); 463 ret = get_compat_flock64(&f, compat_ptr(arg));
464 if (ret != 0) 464 if (ret != 0)
465 break; 465 break;
@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
468 conv_cmd = convert_fcntl_cmd(cmd); 468 conv_cmd = convert_fcntl_cmd(cmd);
469 ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); 469 ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f);
470 set_fs(old_fs); 470 set_fs(old_fs);
471 if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) { 471 if ((conv_cmd == F_GETLK || conv_cmd == F_OFD_GETLK) && ret == 0) {
472 /* need to return lock information - see above for commentary */ 472 /* need to return lock information - see above for commentary */
473 if (f.l_start > COMPAT_LOFF_T_MAX) 473 if (f.l_start > COMPAT_LOFF_T_MAX)
474 ret = -EOVERFLOW; 474 ret = -EOVERFLOW;
@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
493 case F_GETLK64: 493 case F_GETLK64:
494 case F_SETLK64: 494 case F_SETLK64:
495 case F_SETLKW64: 495 case F_SETLKW64:
496 case F_GETLKP: 496 case F_OFD_GETLK:
497 case F_SETLKP: 497 case F_OFD_SETLK:
498 case F_SETLKPW: 498 case F_OFD_SETLKW:
499 return -EINVAL; 499 return -EINVAL;
500 } 500 }
501 return compat_sys_fcntl64(fd, cmd, arg); 501 return compat_sys_fcntl64(fd, cmd, arg);
diff --git a/fs/coredump.c b/fs/coredump.c
index e3ad709a4232..0b2528fb640e 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -73,10 +73,15 @@ static int expand_corename(struct core_name *cn, int size)
73static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg) 73static int cn_vprintf(struct core_name *cn, const char *fmt, va_list arg)
74{ 74{
75 int free, need; 75 int free, need;
76 va_list arg_copy;
76 77
77again: 78again:
78 free = cn->size - cn->used; 79 free = cn->size - cn->used;
79 need = vsnprintf(cn->corename + cn->used, free, fmt, arg); 80
81 va_copy(arg_copy, arg);
82 need = vsnprintf(cn->corename + cn->used, free, fmt, arg_copy);
83 va_end(arg_copy);
84
80 if (need < free) { 85 if (need < free) {
81 cn->used += need; 86 cn->used += need;
82 return 0; 87 return 0;
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 6ea7b1436bbc..5c56785007e0 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -667,7 +667,7 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb)
667 continue; 667 continue;
668 668
669 x = ext4_count_free(bitmap_bh->b_data, 669 x = ext4_count_free(bitmap_bh->b_data,
670 EXT4_BLOCKS_PER_GROUP(sb) / 8); 670 EXT4_CLUSTERS_PER_GROUP(sb) / 8);
671 printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n", 671 printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n",
672 i, ext4_free_group_clusters(sb, gdp), x); 672 i, ext4_free_group_clusters(sb, gdp), x);
673 bitmap_count += x; 673 bitmap_count += x;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index f1c65dc7cc0a..66946aa62127 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2466,23 +2466,6 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
2466 up_write(&EXT4_I(inode)->i_data_sem); 2466 up_write(&EXT4_I(inode)->i_data_sem);
2467} 2467}
2468 2468
2469/*
2470 * Update i_disksize after writeback has been started. Races with truncate
2471 * are avoided by checking i_size under i_data_sem.
2472 */
2473static inline void ext4_wb_update_i_disksize(struct inode *inode, loff_t newsize)
2474{
2475 loff_t i_size;
2476
2477 down_write(&EXT4_I(inode)->i_data_sem);
2478 i_size = i_size_read(inode);
2479 if (newsize > i_size)
2480 newsize = i_size;
2481 if (newsize > EXT4_I(inode)->i_disksize)
2482 EXT4_I(inode)->i_disksize = newsize;
2483 up_write(&EXT4_I(inode)->i_data_sem);
2484}
2485
2486struct ext4_group_info { 2469struct ext4_group_info {
2487 unsigned long bb_state; 2470 unsigned long bb_state;
2488 struct rb_root bb_free_root; 2471 struct rb_root bb_free_root;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 82df3ce9874a..01b0c208f625 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3313,6 +3313,11 @@ static int ext4_split_extent(handle_t *handle,
3313 return PTR_ERR(path); 3313 return PTR_ERR(path);
3314 depth = ext_depth(inode); 3314 depth = ext_depth(inode);
3315 ex = path[depth].p_ext; 3315 ex = path[depth].p_ext;
3316 if (!ex) {
3317 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3318 (unsigned long) map->m_lblk);
3319 return -EIO;
3320 }
3316 uninitialized = ext4_ext_is_uninitialized(ex); 3321 uninitialized = ext4_ext_is_uninitialized(ex);
3317 split_flag1 = 0; 3322 split_flag1 = 0;
3318 3323
@@ -3694,6 +3699,12 @@ static int ext4_convert_initialized_extents(handle_t *handle,
3694 } 3699 }
3695 depth = ext_depth(inode); 3700 depth = ext_depth(inode);
3696 ex = path[depth].p_ext; 3701 ex = path[depth].p_ext;
3702 if (!ex) {
3703 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
3704 (unsigned long) map->m_lblk);
3705 err = -EIO;
3706 goto out;
3707 }
3697 } 3708 }
3698 3709
3699 err = ext4_ext_get_access(handle, inode, path + depth); 3710 err = ext4_ext_get_access(handle, inode, path + depth);
@@ -4730,6 +4741,9 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4730 4741
4731 trace_ext4_zero_range(inode, offset, len, mode); 4742 trace_ext4_zero_range(inode, offset, len, mode);
4732 4743
4744 if (!S_ISREG(inode->i_mode))
4745 return -EINVAL;
4746
4733 /* 4747 /*
4734 * Write out all dirty pages to avoid race conditions 4748 * Write out all dirty pages to avoid race conditions
4735 * Then release them. 4749 * Then release them.
@@ -4878,9 +4892,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4878 if (mode & FALLOC_FL_PUNCH_HOLE) 4892 if (mode & FALLOC_FL_PUNCH_HOLE)
4879 return ext4_punch_hole(inode, offset, len); 4893 return ext4_punch_hole(inode, offset, len);
4880 4894
4881 if (mode & FALLOC_FL_COLLAPSE_RANGE)
4882 return ext4_collapse_range(inode, offset, len);
4883
4884 ret = ext4_convert_inline_data(inode); 4895 ret = ext4_convert_inline_data(inode);
4885 if (ret) 4896 if (ret)
4886 return ret; 4897 return ret;
@@ -4892,6 +4903,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4892 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) 4903 if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
4893 return -EOPNOTSUPP; 4904 return -EOPNOTSUPP;
4894 4905
4906 if (mode & FALLOC_FL_COLLAPSE_RANGE)
4907 return ext4_collapse_range(inode, offset, len);
4908
4895 if (mode & FALLOC_FL_ZERO_RANGE) 4909 if (mode & FALLOC_FL_ZERO_RANGE)
4896 return ext4_zero_range(file, offset, len, mode); 4910 return ext4_zero_range(file, offset, len, mode);
4897 4911
@@ -5229,18 +5243,19 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
5229 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) 5243 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr))
5230 update = 1; 5244 update = 1;
5231 5245
5232 *start = ex_last->ee_block + 5246 *start = le32_to_cpu(ex_last->ee_block) +
5233 ext4_ext_get_actual_len(ex_last); 5247 ext4_ext_get_actual_len(ex_last);
5234 5248
5235 while (ex_start <= ex_last) { 5249 while (ex_start <= ex_last) {
5236 ex_start->ee_block -= shift; 5250 le32_add_cpu(&ex_start->ee_block, -shift);
5237 if (ex_start > 5251 /* Try to merge to the left. */
5238 EXT_FIRST_EXTENT(path[depth].p_hdr)) { 5252 if ((ex_start >
5239 if (ext4_ext_try_to_merge_right(inode, 5253 EXT_FIRST_EXTENT(path[depth].p_hdr)) &&
5240 path, ex_start - 1)) 5254 ext4_ext_try_to_merge_right(inode,
5241 ex_last--; 5255 path, ex_start - 1))
5242 } 5256 ex_last--;
5243 ex_start++; 5257 else
5258 ex_start++;
5244 } 5259 }
5245 err = ext4_ext_dirty(handle, inode, path + depth); 5260 err = ext4_ext_dirty(handle, inode, path + depth);
5246 if (err) 5261 if (err)
@@ -5255,7 +5270,7 @@ ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift,
5255 if (err) 5270 if (err)
5256 goto out; 5271 goto out;
5257 5272
5258 path[depth].p_idx->ei_block -= shift; 5273 le32_add_cpu(&path[depth].p_idx->ei_block, -shift);
5259 err = ext4_ext_dirty(handle, inode, path + depth); 5274 err = ext4_ext_dirty(handle, inode, path + depth);
5260 if (err) 5275 if (err)
5261 goto out; 5276 goto out;
@@ -5300,7 +5315,8 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5300 return ret; 5315 return ret;
5301 } 5316 }
5302 5317
5303 stop_block = extent->ee_block + ext4_ext_get_actual_len(extent); 5318 stop_block = le32_to_cpu(extent->ee_block) +
5319 ext4_ext_get_actual_len(extent);
5304 ext4_ext_drop_refs(path); 5320 ext4_ext_drop_refs(path);
5305 kfree(path); 5321 kfree(path);
5306 5322
@@ -5313,10 +5329,18 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5313 * enough to accomodate the shift. 5329 * enough to accomodate the shift.
5314 */ 5330 */
5315 path = ext4_ext_find_extent(inode, start - 1, NULL, 0); 5331 path = ext4_ext_find_extent(inode, start - 1, NULL, 0);
5332 if (IS_ERR(path))
5333 return PTR_ERR(path);
5316 depth = path->p_depth; 5334 depth = path->p_depth;
5317 extent = path[depth].p_ext; 5335 extent = path[depth].p_ext;
5318 ex_start = extent->ee_block; 5336 if (extent) {
5319 ex_end = extent->ee_block + ext4_ext_get_actual_len(extent); 5337 ex_start = le32_to_cpu(extent->ee_block);
5338 ex_end = le32_to_cpu(extent->ee_block) +
5339 ext4_ext_get_actual_len(extent);
5340 } else {
5341 ex_start = 0;
5342 ex_end = 0;
5343 }
5320 ext4_ext_drop_refs(path); 5344 ext4_ext_drop_refs(path);
5321 kfree(path); 5345 kfree(path);
5322 5346
@@ -5331,7 +5355,13 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5331 return PTR_ERR(path); 5355 return PTR_ERR(path);
5332 depth = path->p_depth; 5356 depth = path->p_depth;
5333 extent = path[depth].p_ext; 5357 extent = path[depth].p_ext;
5334 current_block = extent->ee_block; 5358 if (!extent) {
5359 EXT4_ERROR_INODE(inode, "unexpected hole at %lu",
5360 (unsigned long) start);
5361 return -EIO;
5362 }
5363
5364 current_block = le32_to_cpu(extent->ee_block);
5335 if (start > current_block) { 5365 if (start > current_block) {
5336 /* Hole, move to the next extent */ 5366 /* Hole, move to the next extent */
5337 ret = mext_next_extent(inode, path, &extent); 5367 ret = mext_next_extent(inode, path, &extent);
@@ -5365,17 +5395,18 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5365 ext4_lblk_t punch_start, punch_stop; 5395 ext4_lblk_t punch_start, punch_stop;
5366 handle_t *handle; 5396 handle_t *handle;
5367 unsigned int credits; 5397 unsigned int credits;
5368 loff_t new_size; 5398 loff_t new_size, ioffset;
5369 int ret; 5399 int ret;
5370 5400
5371 BUG_ON(offset + len > i_size_read(inode));
5372
5373 /* Collapse range works only on fs block size aligned offsets. */ 5401 /* Collapse range works only on fs block size aligned offsets. */
5374 if (offset & (EXT4_BLOCK_SIZE(sb) - 1) || 5402 if (offset & (EXT4_BLOCK_SIZE(sb) - 1) ||
5375 len & (EXT4_BLOCK_SIZE(sb) - 1)) 5403 len & (EXT4_BLOCK_SIZE(sb) - 1))
5376 return -EINVAL; 5404 return -EINVAL;
5377 5405
5378 if (!S_ISREG(inode->i_mode)) 5406 if (!S_ISREG(inode->i_mode))
5407 return -EINVAL;
5408
5409 if (EXT4_SB(inode->i_sb)->s_cluster_ratio > 1)
5379 return -EOPNOTSUPP; 5410 return -EOPNOTSUPP;
5380 5411
5381 trace_ext4_collapse_range(inode, offset, len); 5412 trace_ext4_collapse_range(inode, offset, len);
@@ -5383,22 +5414,34 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5383 punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb); 5414 punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb);
5384 punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb); 5415 punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb);
5385 5416
5417 /* Call ext4_force_commit to flush all data in case of data=journal. */
5418 if (ext4_should_journal_data(inode)) {
5419 ret = ext4_force_commit(inode->i_sb);
5420 if (ret)
5421 return ret;
5422 }
5423
5424 /*
5425 * Need to round down offset to be aligned with page size boundary
5426 * for page size > block size.
5427 */
5428 ioffset = round_down(offset, PAGE_SIZE);
5429
5386 /* Write out all dirty pages */ 5430 /* Write out all dirty pages */
5387 ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1); 5431 ret = filemap_write_and_wait_range(inode->i_mapping, ioffset,
5432 LLONG_MAX);
5388 if (ret) 5433 if (ret)
5389 return ret; 5434 return ret;
5390 5435
5391 /* Take mutex lock */ 5436 /* Take mutex lock */
5392 mutex_lock(&inode->i_mutex); 5437 mutex_lock(&inode->i_mutex);
5393 5438
5394 /* It's not possible punch hole on append only file */ 5439 /*
5395 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) { 5440 * There is no need to overlap collapse range with EOF, in which case
5396 ret = -EPERM; 5441 * it is effectively a truncate operation
5397 goto out_mutex; 5442 */
5398 } 5443 if (offset + len >= i_size_read(inode)) {
5399 5444 ret = -EINVAL;
5400 if (IS_SWAPFILE(inode)) {
5401 ret = -ETXTBSY;
5402 goto out_mutex; 5445 goto out_mutex;
5403 } 5446 }
5404 5447
@@ -5408,7 +5451,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5408 goto out_mutex; 5451 goto out_mutex;
5409 } 5452 }
5410 5453
5411 truncate_pagecache_range(inode, offset, -1); 5454 truncate_pagecache(inode, ioffset);
5412 5455
5413 /* Wait for existing dio to complete */ 5456 /* Wait for existing dio to complete */
5414 ext4_inode_block_unlocked_dio(inode); 5457 ext4_inode_block_unlocked_dio(inode);
@@ -5425,7 +5468,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5425 ext4_discard_preallocations(inode); 5468 ext4_discard_preallocations(inode);
5426 5469
5427 ret = ext4_es_remove_extent(inode, punch_start, 5470 ret = ext4_es_remove_extent(inode, punch_start,
5428 EXT_MAX_BLOCKS - punch_start - 1); 5471 EXT_MAX_BLOCKS - punch_start);
5429 if (ret) { 5472 if (ret) {
5430 up_write(&EXT4_I(inode)->i_data_sem); 5473 up_write(&EXT4_I(inode)->i_data_sem);
5431 goto out_stop; 5474 goto out_stop;
@@ -5436,6 +5479,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5436 up_write(&EXT4_I(inode)->i_data_sem); 5479 up_write(&EXT4_I(inode)->i_data_sem);
5437 goto out_stop; 5480 goto out_stop;
5438 } 5481 }
5482 ext4_discard_preallocations(inode);
5439 5483
5440 ret = ext4_ext_shift_extents(inode, handle, punch_stop, 5484 ret = ext4_ext_shift_extents(inode, handle, punch_stop,
5441 punch_stop - punch_start); 5485 punch_stop - punch_start);
@@ -5445,10 +5489,9 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5445 } 5489 }
5446 5490
5447 new_size = i_size_read(inode) - len; 5491 new_size = i_size_read(inode) - len;
5448 truncate_setsize(inode, new_size); 5492 i_size_write(inode, new_size);
5449 EXT4_I(inode)->i_disksize = new_size; 5493 EXT4_I(inode)->i_disksize = new_size;
5450 5494
5451 ext4_discard_preallocations(inode);
5452 up_write(&EXT4_I(inode)->i_data_sem); 5495 up_write(&EXT4_I(inode)->i_data_sem);
5453 if (IS_SYNC(inode)) 5496 if (IS_SYNC(inode))
5454 ext4_handle_sync(handle); 5497 ext4_handle_sync(handle);
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 0a014a7194b2..0ebc21204b51 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -810,7 +810,7 @@ retry:
810 810
811 newes.es_lblk = end + 1; 811 newes.es_lblk = end + 1;
812 newes.es_len = len2; 812 newes.es_len = len2;
813 block = 0x7FDEADBEEF; 813 block = 0x7FDEADBEEFULL;
814 if (ext4_es_is_written(&orig_es) || 814 if (ext4_es_is_written(&orig_es) ||
815 ext4_es_is_unwritten(&orig_es)) 815 ext4_es_is_unwritten(&orig_es))
816 block = ext4_es_pblock(&orig_es) + 816 block = ext4_es_pblock(&orig_es) +
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index ca7502d89fde..063fc1538355 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -82,7 +82,7 @@ ext4_unaligned_aio(struct inode *inode, const struct iovec *iov,
82 size_t count = iov_length(iov, nr_segs); 82 size_t count = iov_length(iov, nr_segs);
83 loff_t final_size = pos + count; 83 loff_t final_size = pos + count;
84 84
85 if (pos >= inode->i_size) 85 if (pos >= i_size_read(inode))
86 return 0; 86 return 0;
87 87
88 if ((pos & blockmask) || (final_size & blockmask)) 88 if ((pos & blockmask) || (final_size & blockmask))
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5b0d2c7d5408..d7b7462a0e13 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -522,6 +522,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
522 if (unlikely(map->m_len > INT_MAX)) 522 if (unlikely(map->m_len > INT_MAX))
523 map->m_len = INT_MAX; 523 map->m_len = INT_MAX;
524 524
525 /* We can handle the block number less than EXT_MAX_BLOCKS */
526 if (unlikely(map->m_lblk >= EXT_MAX_BLOCKS))
527 return -EIO;
528
525 /* Lookup extent status tree firstly */ 529 /* Lookup extent status tree firstly */
526 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) { 530 if (ext4_es_lookup_extent(inode, map->m_lblk, &es)) {
527 ext4_es_lru_add(inode); 531 ext4_es_lru_add(inode);
@@ -2243,13 +2247,23 @@ static int mpage_map_and_submit_extent(handle_t *handle,
2243 return err; 2247 return err;
2244 } while (map->m_len); 2248 } while (map->m_len);
2245 2249
2246 /* Update on-disk size after IO is submitted */ 2250 /*
2251 * Update on-disk size after IO is submitted. Races with
2252 * truncate are avoided by checking i_size under i_data_sem.
2253 */
2247 disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT; 2254 disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT;
2248 if (disksize > EXT4_I(inode)->i_disksize) { 2255 if (disksize > EXT4_I(inode)->i_disksize) {
2249 int err2; 2256 int err2;
2250 2257 loff_t i_size;
2251 ext4_wb_update_i_disksize(inode, disksize); 2258
2259 down_write(&EXT4_I(inode)->i_data_sem);
2260 i_size = i_size_read(inode);
2261 if (disksize > i_size)
2262 disksize = i_size;
2263 if (disksize > EXT4_I(inode)->i_disksize)
2264 EXT4_I(inode)->i_disksize = disksize;
2252 err2 = ext4_mark_inode_dirty(handle, inode); 2265 err2 = ext4_mark_inode_dirty(handle, inode);
2266 up_write(&EXT4_I(inode)->i_data_sem);
2253 if (err2) 2267 if (err2)
2254 ext4_error(inode->i_sb, 2268 ext4_error(inode->i_sb,
2255 "Failed to mark inode %lu dirty", 2269 "Failed to mark inode %lu dirty",
@@ -3527,15 +3541,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
3527 } 3541 }
3528 3542
3529 mutex_lock(&inode->i_mutex); 3543 mutex_lock(&inode->i_mutex);
3530 /* It's not possible punch hole on append only file */
3531 if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) {
3532 ret = -EPERM;
3533 goto out_mutex;
3534 }
3535 if (IS_SWAPFILE(inode)) {
3536 ret = -ETXTBSY;
3537 goto out_mutex;
3538 }
3539 3544
3540 /* No need to punch hole beyond i_size */ 3545 /* No need to punch hole beyond i_size */
3541 if (offset >= inode->i_size) 3546 if (offset >= inode->i_size)
@@ -3616,7 +3621,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
3616 ret = ext4_free_hole_blocks(handle, inode, first_block, 3621 ret = ext4_free_hole_blocks(handle, inode, first_block,
3617 stop_block); 3622 stop_block);
3618 3623
3619 ext4_discard_preallocations(inode);
3620 up_write(&EXT4_I(inode)->i_data_sem); 3624 up_write(&EXT4_I(inode)->i_data_sem);
3621 if (IS_SYNC(inode)) 3625 if (IS_SYNC(inode))
3622 ext4_handle_sync(handle); 3626 ext4_handle_sync(handle);
@@ -4423,21 +4427,20 @@ out_brelse:
4423 * 4427 *
4424 * We are called from a few places: 4428 * We are called from a few places:
4425 * 4429 *
4426 * - Within generic_file_write() for O_SYNC files. 4430 * - Within generic_file_aio_write() -> generic_write_sync() for O_SYNC files.
4427 * Here, there will be no transaction running. We wait for any running 4431 * Here, there will be no transaction running. We wait for any running
4428 * transaction to commit. 4432 * transaction to commit.
4429 * 4433 *
4430 * - Within sys_sync(), kupdate and such. 4434 * - Within flush work (sys_sync(), kupdate and such).
4431 * We wait on commit, if tol to. 4435 * We wait on commit, if told to.
4432 * 4436 *
4433 * - Within prune_icache() (PF_MEMALLOC == true) 4437 * - Within iput_final() -> write_inode_now()
4434 * Here we simply return. We can't afford to block kswapd on the 4438 * We wait on commit, if told to.
4435 * journal commit.
4436 * 4439 *
4437 * In all cases it is actually safe for us to return without doing anything, 4440 * In all cases it is actually safe for us to return without doing anything,
4438 * because the inode has been copied into a raw inode buffer in 4441 * because the inode has been copied into a raw inode buffer in
4439 * ext4_mark_inode_dirty(). This is a correctness thing for O_SYNC and for 4442 * ext4_mark_inode_dirty(). This is a correctness thing for WB_SYNC_ALL
4440 * knfsd. 4443 * writeback.
4441 * 4444 *
4442 * Note that we are absolutely dependent upon all inode dirtiers doing the 4445 * Note that we are absolutely dependent upon all inode dirtiers doing the
4443 * right thing: they *must* call mark_inode_dirty() after dirtying info in 4446 * right thing: they *must* call mark_inode_dirty() after dirtying info in
@@ -4449,15 +4452,15 @@ out_brelse:
4449 * stuff(); 4452 * stuff();
4450 * inode->i_size = expr; 4453 * inode->i_size = expr;
4451 * 4454 *
4452 * is in error because a kswapd-driven write_inode() could occur while 4455 * is in error because write_inode() could occur while `stuff()' is running,
4453 * `stuff()' is running, and the new i_size will be lost. Plus the inode 4456 * and the new i_size will be lost. Plus the inode will no longer be on the
4454 * will no longer be on the superblock's dirty inode list. 4457 * superblock's dirty inode list.
4455 */ 4458 */
4456int ext4_write_inode(struct inode *inode, struct writeback_control *wbc) 4459int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
4457{ 4460{
4458 int err; 4461 int err;
4459 4462
4460 if (current->flags & PF_MEMALLOC) 4463 if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
4461 return 0; 4464 return 0;
4462 4465
4463 if (EXT4_SB(inode->i_sb)->s_journal) { 4466 if (EXT4_SB(inode->i_sb)->s_journal) {
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index a888cac76e9c..c8238a26818c 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -989,7 +989,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
989 poff = block % blocks_per_page; 989 poff = block % blocks_per_page;
990 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); 990 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
991 if (!page) 991 if (!page)
992 return -EIO; 992 return -ENOMEM;
993 BUG_ON(page->mapping != inode->i_mapping); 993 BUG_ON(page->mapping != inode->i_mapping);
994 e4b->bd_bitmap_page = page; 994 e4b->bd_bitmap_page = page;
995 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); 995 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
@@ -1003,7 +1003,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
1003 pnum = block / blocks_per_page; 1003 pnum = block / blocks_per_page;
1004 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); 1004 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
1005 if (!page) 1005 if (!page)
1006 return -EIO; 1006 return -ENOMEM;
1007 BUG_ON(page->mapping != inode->i_mapping); 1007 BUG_ON(page->mapping != inode->i_mapping);
1008 e4b->bd_buddy_page = page; 1008 e4b->bd_buddy_page = page;
1009 return 0; 1009 return 0;
@@ -1168,7 +1168,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
1168 unlock_page(page); 1168 unlock_page(page);
1169 } 1169 }
1170 } 1170 }
1171 if (page == NULL || !PageUptodate(page)) { 1171 if (page == NULL) {
1172 ret = -ENOMEM;
1173 goto err;
1174 }
1175 if (!PageUptodate(page)) {
1172 ret = -EIO; 1176 ret = -EIO;
1173 goto err; 1177 goto err;
1174 } 1178 }
@@ -1197,7 +1201,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
1197 unlock_page(page); 1201 unlock_page(page);
1198 } 1202 }
1199 } 1203 }
1200 if (page == NULL || !PageUptodate(page)) { 1204 if (page == NULL) {
1205 ret = -ENOMEM;
1206 goto err;
1207 }
1208 if (!PageUptodate(page)) {
1201 ret = -EIO; 1209 ret = -EIO;
1202 goto err; 1210 goto err;
1203 } 1211 }
@@ -5008,6 +5016,8 @@ error_return:
5008 */ 5016 */
5009static int ext4_trim_extent(struct super_block *sb, int start, int count, 5017static int ext4_trim_extent(struct super_block *sb, int start, int count,
5010 ext4_group_t group, struct ext4_buddy *e4b) 5018 ext4_group_t group, struct ext4_buddy *e4b)
5019__releases(bitlock)
5020__acquires(bitlock)
5011{ 5021{
5012 struct ext4_free_extent ex; 5022 struct ext4_free_extent ex;
5013 int ret = 0; 5023 int ret = 0;
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index ab95508e3d40..c18d95b50540 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -308,13 +308,14 @@ static void ext4_end_bio(struct bio *bio, int error)
308 if (error) { 308 if (error) {
309 struct inode *inode = io_end->inode; 309 struct inode *inode = io_end->inode;
310 310
311 ext4_warning(inode->i_sb, "I/O error writing to inode %lu " 311 ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu "
312 "(offset %llu size %ld starting block %llu)", 312 "(offset %llu size %ld starting block %llu)",
313 inode->i_ino, 313 error, inode->i_ino,
314 (unsigned long long) io_end->offset, 314 (unsigned long long) io_end->offset,
315 (long) io_end->size, 315 (long) io_end->size,
316 (unsigned long long) 316 (unsigned long long)
317 bi_sector >> (inode->i_blkbits - 9)); 317 bi_sector >> (inode->i_blkbits - 9));
318 mapping_set_error(inode->i_mapping, error);
318 } 319 }
319 320
320 if (io_end->flag & EXT4_IO_END_UNWRITTEN) { 321 if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index f3c667091618..6f9e6fadac04 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3869,19 +3869,38 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3869 goto failed_mount2; 3869 goto failed_mount2;
3870 } 3870 }
3871 } 3871 }
3872
3873 /*
3874 * set up enough so that it can read an inode,
3875 * and create new inode for buddy allocator
3876 */
3877 sbi->s_gdb_count = db_count;
3878 if (!test_opt(sb, NOLOAD) &&
3879 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
3880 sb->s_op = &ext4_sops;
3881 else
3882 sb->s_op = &ext4_nojournal_sops;
3883
3884 ext4_ext_init(sb);
3885 err = ext4_mb_init(sb);
3886 if (err) {
3887 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
3888 err);
3889 goto failed_mount2;
3890 }
3891
3872 if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3892 if (!ext4_check_descriptors(sb, &first_not_zeroed)) {
3873 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3893 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
3874 goto failed_mount2; 3894 goto failed_mount2a;
3875 } 3895 }
3876 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) 3896 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
3877 if (!ext4_fill_flex_info(sb)) { 3897 if (!ext4_fill_flex_info(sb)) {
3878 ext4_msg(sb, KERN_ERR, 3898 ext4_msg(sb, KERN_ERR,
3879 "unable to initialize " 3899 "unable to initialize "
3880 "flex_bg meta info!"); 3900 "flex_bg meta info!");
3881 goto failed_mount2; 3901 goto failed_mount2a;
3882 } 3902 }
3883 3903
3884 sbi->s_gdb_count = db_count;
3885 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 3904 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
3886 spin_lock_init(&sbi->s_next_gen_lock); 3905 spin_lock_init(&sbi->s_next_gen_lock);
3887 3906
@@ -3916,14 +3935,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3916 sbi->s_stripe = ext4_get_stripe_size(sbi); 3935 sbi->s_stripe = ext4_get_stripe_size(sbi);
3917 sbi->s_extent_max_zeroout_kb = 32; 3936 sbi->s_extent_max_zeroout_kb = 32;
3918 3937
3919 /*
3920 * set up enough so that it can read an inode
3921 */
3922 if (!test_opt(sb, NOLOAD) &&
3923 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
3924 sb->s_op = &ext4_sops;
3925 else
3926 sb->s_op = &ext4_nojournal_sops;
3927 sb->s_export_op = &ext4_export_ops; 3938 sb->s_export_op = &ext4_export_ops;
3928 sb->s_xattr = ext4_xattr_handlers; 3939 sb->s_xattr = ext4_xattr_handlers;
3929#ifdef CONFIG_QUOTA 3940#ifdef CONFIG_QUOTA
@@ -4113,21 +4124,13 @@ no_journal:
4113 if (err) { 4124 if (err) {
4114 ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " 4125 ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for "
4115 "reserved pool", ext4_calculate_resv_clusters(sb)); 4126 "reserved pool", ext4_calculate_resv_clusters(sb));
4116 goto failed_mount4a; 4127 goto failed_mount5;
4117 } 4128 }
4118 4129
4119 err = ext4_setup_system_zone(sb); 4130 err = ext4_setup_system_zone(sb);
4120 if (err) { 4131 if (err) {
4121 ext4_msg(sb, KERN_ERR, "failed to initialize system " 4132 ext4_msg(sb, KERN_ERR, "failed to initialize system "
4122 "zone (%d)", err); 4133 "zone (%d)", err);
4123 goto failed_mount4a;
4124 }
4125
4126 ext4_ext_init(sb);
4127 err = ext4_mb_init(sb);
4128 if (err) {
4129 ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
4130 err);
4131 goto failed_mount5; 4134 goto failed_mount5;
4132 } 4135 }
4133 4136
@@ -4204,11 +4207,8 @@ failed_mount8:
4204failed_mount7: 4207failed_mount7:
4205 ext4_unregister_li_request(sb); 4208 ext4_unregister_li_request(sb);
4206failed_mount6: 4209failed_mount6:
4207 ext4_mb_release(sb);
4208failed_mount5:
4209 ext4_ext_release(sb);
4210 ext4_release_system_zone(sb); 4210 ext4_release_system_zone(sb);
4211failed_mount4a: 4211failed_mount5:
4212 dput(sb->s_root); 4212 dput(sb->s_root);
4213 sb->s_root = NULL; 4213 sb->s_root = NULL;
4214failed_mount4: 4214failed_mount4:
@@ -4232,11 +4232,14 @@ failed_mount3:
4232 percpu_counter_destroy(&sbi->s_extent_cache_cnt); 4232 percpu_counter_destroy(&sbi->s_extent_cache_cnt);
4233 if (sbi->s_mmp_tsk) 4233 if (sbi->s_mmp_tsk)
4234 kthread_stop(sbi->s_mmp_tsk); 4234 kthread_stop(sbi->s_mmp_tsk);
4235failed_mount2a:
4236 ext4_mb_release(sb);
4235failed_mount2: 4237failed_mount2:
4236 for (i = 0; i < db_count; i++) 4238 for (i = 0; i < db_count; i++)
4237 brelse(sbi->s_group_desc[i]); 4239 brelse(sbi->s_group_desc[i]);
4238 ext4_kvfree(sbi->s_group_desc); 4240 ext4_kvfree(sbi->s_group_desc);
4239failed_mount: 4241failed_mount:
4242 ext4_ext_release(sb);
4240 if (sbi->s_chksum_driver) 4243 if (sbi->s_chksum_driver)
4241 crypto_free_shash(sbi->s_chksum_driver); 4244 crypto_free_shash(sbi->s_chksum_driver);
4242 if (sbi->s_proc) { 4245 if (sbi->s_proc) {
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 1f5cf5880718..4eec399ec807 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -520,8 +520,8 @@ static void ext4_xattr_update_super_block(handle_t *handle,
520} 520}
521 521
522/* 522/*
523 * Release the xattr block BH: If the reference count is > 1, decrement 523 * Release the xattr block BH: If the reference count is > 1, decrement it;
524 * it; otherwise free the block. 524 * otherwise free the block.
525 */ 525 */
526static void 526static void
527ext4_xattr_release_block(handle_t *handle, struct inode *inode, 527ext4_xattr_release_block(handle_t *handle, struct inode *inode,
@@ -542,16 +542,31 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
542 if (ce) 542 if (ce)
543 mb_cache_entry_free(ce); 543 mb_cache_entry_free(ce);
544 get_bh(bh); 544 get_bh(bh);
545 unlock_buffer(bh);
545 ext4_free_blocks(handle, inode, bh, 0, 1, 546 ext4_free_blocks(handle, inode, bh, 0, 1,
546 EXT4_FREE_BLOCKS_METADATA | 547 EXT4_FREE_BLOCKS_METADATA |
547 EXT4_FREE_BLOCKS_FORGET); 548 EXT4_FREE_BLOCKS_FORGET);
548 unlock_buffer(bh);
549 } else { 549 } else {
550 le32_add_cpu(&BHDR(bh)->h_refcount, -1); 550 le32_add_cpu(&BHDR(bh)->h_refcount, -1);
551 if (ce) 551 if (ce)
552 mb_cache_entry_release(ce); 552 mb_cache_entry_release(ce);
553 /*
554 * Beware of this ugliness: Releasing of xattr block references
555 * from different inodes can race and so we have to protect
556 * from a race where someone else frees the block (and releases
557 * its journal_head) before we are done dirtying the buffer. In
558 * nojournal mode this race is harmless and we actually cannot
559 * call ext4_handle_dirty_xattr_block() with locked buffer as
560 * that function can call sync_dirty_buffer() so for that case
561 * we handle the dirtying after unlocking the buffer.
562 */
563 if (ext4_handle_valid(handle))
564 error = ext4_handle_dirty_xattr_block(handle, inode,
565 bh);
553 unlock_buffer(bh); 566 unlock_buffer(bh);
554 error = ext4_handle_dirty_xattr_block(handle, inode, bh); 567 if (!ext4_handle_valid(handle))
568 error = ext4_handle_dirty_xattr_block(handle, inode,
569 bh);
555 if (IS_SYNC(inode)) 570 if (IS_SYNC(inode))
556 ext4_handle_sync(handle); 571 ext4_handle_sync(handle);
557 dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1)); 572 dquot_free_block(inode, EXT4_C2B(EXT4_SB(inode->i_sb), 1));
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 9ead1596399a..72c82f69b01b 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
274 break; 274 break;
275#if BITS_PER_LONG != 32 275#if BITS_PER_LONG != 32
276 /* 32-bit arches must use fcntl64() */ 276 /* 32-bit arches must use fcntl64() */
277 case F_GETLKP: 277 case F_OFD_GETLK:
278#endif 278#endif
279 case F_GETLK: 279 case F_GETLK:
280 err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); 280 err = fcntl_getlk(filp, cmd, (struct flock __user *) arg);
281 break; 281 break;
282#if BITS_PER_LONG != 32 282#if BITS_PER_LONG != 32
283 /* 32-bit arches must use fcntl64() */ 283 /* 32-bit arches must use fcntl64() */
284 case F_SETLKP: 284 case F_OFD_SETLK:
285 case F_SETLKPW: 285 case F_OFD_SETLKW:
286#endif 286#endif
287 /* Fallthrough */ 287 /* Fallthrough */
288 case F_SETLK: 288 case F_SETLK:
@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
399 399
400 switch (cmd) { 400 switch (cmd) {
401 case F_GETLK64: 401 case F_GETLK64:
402 case F_GETLKP: 402 case F_OFD_GETLK:
403 err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); 403 err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg);
404 break; 404 break;
405 case F_SETLK64: 405 case F_SETLK64:
406 case F_SETLKW64: 406 case F_SETLKW64:
407 case F_SETLKP: 407 case F_OFD_SETLK:
408 case F_SETLKPW: 408 case F_OFD_SETLKW:
409 err = fcntl_setlk64(fd, f.file, cmd, 409 err = fcntl_setlk64(fd, f.file, cmd,
410 (struct flock64 __user *) arg); 410 (struct flock64 __user *) arg);
411 break; 411 break;
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 78f3403300af..ac127cd008bf 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -232,9 +232,6 @@ static int kernfs_link_sibling(struct kernfs_node *kn)
232 struct rb_node **node = &kn->parent->dir.children.rb_node; 232 struct rb_node **node = &kn->parent->dir.children.rb_node;
233 struct rb_node *parent = NULL; 233 struct rb_node *parent = NULL;
234 234
235 if (kernfs_type(kn) == KERNFS_DIR)
236 kn->parent->dir.subdirs++;
237
238 while (*node) { 235 while (*node) {
239 struct kernfs_node *pos; 236 struct kernfs_node *pos;
240 int result; 237 int result;
@@ -249,9 +246,15 @@ static int kernfs_link_sibling(struct kernfs_node *kn)
249 else 246 else
250 return -EEXIST; 247 return -EEXIST;
251 } 248 }
249
252 /* add new node and rebalance the tree */ 250 /* add new node and rebalance the tree */
253 rb_link_node(&kn->rb, parent, node); 251 rb_link_node(&kn->rb, parent, node);
254 rb_insert_color(&kn->rb, &kn->parent->dir.children); 252 rb_insert_color(&kn->rb, &kn->parent->dir.children);
253
254 /* successfully added, account subdir number */
255 if (kernfs_type(kn) == KERNFS_DIR)
256 kn->parent->dir.subdirs++;
257
255 return 0; 258 return 0;
256} 259}
257 260
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 8034706a7af8..e01ea4a14a01 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -484,6 +484,8 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
484 484
485 ops = kernfs_ops(of->kn); 485 ops = kernfs_ops(of->kn);
486 rc = ops->mmap(of, vma); 486 rc = ops->mmap(of, vma);
487 if (rc)
488 goto out_put;
487 489
488 /* 490 /*
489 * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() 491 * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup()
diff --git a/fs/locks.c b/fs/locks.c
index 13fc7a6d380a..e663aeac579e 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -135,7 +135,7 @@
135#define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) 135#define IS_POSIX(fl) (fl->fl_flags & FL_POSIX)
136#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) 136#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
137#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG)) 137#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG))
138#define IS_FILE_PVT(fl) (fl->fl_flags & FL_FILE_PVT) 138#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
139 139
140static bool lease_breaking(struct file_lock *fl) 140static bool lease_breaking(struct file_lock *fl)
141{ 141{
@@ -564,7 +564,7 @@ static void __locks_insert_block(struct file_lock *blocker,
564 BUG_ON(!list_empty(&waiter->fl_block)); 564 BUG_ON(!list_empty(&waiter->fl_block));
565 waiter->fl_next = blocker; 565 waiter->fl_next = blocker;
566 list_add_tail(&waiter->fl_block, &blocker->fl_block); 566 list_add_tail(&waiter->fl_block, &blocker->fl_block);
567 if (IS_POSIX(blocker) && !IS_FILE_PVT(blocker)) 567 if (IS_POSIX(blocker) && !IS_OFDLCK(blocker))
568 locks_insert_global_blocked(waiter); 568 locks_insert_global_blocked(waiter);
569} 569}
570 570
@@ -759,12 +759,12 @@ EXPORT_SYMBOL(posix_test_lock);
759 * of tasks (such as posix threads) sharing the same open file table. 759 * of tasks (such as posix threads) sharing the same open file table.
760 * To handle those cases, we just bail out after a few iterations. 760 * To handle those cases, we just bail out after a few iterations.
761 * 761 *
762 * For FL_FILE_PVT locks, the owner is the filp, not the files_struct. 762 * For FL_OFDLCK locks, the owner is the filp, not the files_struct.
763 * Because the owner is not even nominally tied to a thread of 763 * Because the owner is not even nominally tied to a thread of
764 * execution, the deadlock detection below can't reasonably work well. Just 764 * execution, the deadlock detection below can't reasonably work well. Just
765 * skip it for those. 765 * skip it for those.
766 * 766 *
767 * In principle, we could do a more limited deadlock detection on FL_FILE_PVT 767 * In principle, we could do a more limited deadlock detection on FL_OFDLCK
768 * locks that just checks for the case where two tasks are attempting to 768 * locks that just checks for the case where two tasks are attempting to
769 * upgrade from read to write locks on the same inode. 769 * upgrade from read to write locks on the same inode.
770 */ 770 */
@@ -791,9 +791,9 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
791 791
792 /* 792 /*
793 * This deadlock detector can't reasonably detect deadlocks with 793 * This deadlock detector can't reasonably detect deadlocks with
794 * FL_FILE_PVT locks, since they aren't owned by a process, per-se. 794 * FL_OFDLCK locks, since they aren't owned by a process, per-se.
795 */ 795 */
796 if (IS_FILE_PVT(caller_fl)) 796 if (IS_OFDLCK(caller_fl))
797 return 0; 797 return 0;
798 798
799 while ((block_fl = what_owner_is_waiting_for(block_fl))) { 799 while ((block_fl = what_owner_is_waiting_for(block_fl))) {
@@ -1391,11 +1391,10 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
1391 1391
1392restart: 1392restart:
1393 break_time = flock->fl_break_time; 1393 break_time = flock->fl_break_time;
1394 if (break_time != 0) { 1394 if (break_time != 0)
1395 break_time -= jiffies; 1395 break_time -= jiffies;
1396 if (break_time == 0) 1396 if (break_time == 0)
1397 break_time++; 1397 break_time++;
1398 }
1399 locks_insert_block(flock, new_fl); 1398 locks_insert_block(flock, new_fl);
1400 spin_unlock(&inode->i_lock); 1399 spin_unlock(&inode->i_lock);
1401 error = wait_event_interruptible_timeout(new_fl->fl_wait, 1400 error = wait_event_interruptible_timeout(new_fl->fl_wait,
@@ -1891,7 +1890,7 @@ EXPORT_SYMBOL_GPL(vfs_test_lock);
1891 1890
1892static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) 1891static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
1893{ 1892{
1894 flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; 1893 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid;
1895#if BITS_PER_LONG == 32 1894#if BITS_PER_LONG == 32
1896 /* 1895 /*
1897 * Make sure we can represent the posix lock via 1896 * Make sure we can represent the posix lock via
@@ -1913,7 +1912,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
1913#if BITS_PER_LONG == 32 1912#if BITS_PER_LONG == 32
1914static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) 1913static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl)
1915{ 1914{
1916 flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid; 1915 flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid;
1917 flock->l_start = fl->fl_start; 1916 flock->l_start = fl->fl_start;
1918 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : 1917 flock->l_len = fl->fl_end == OFFSET_MAX ? 0 :
1919 fl->fl_end - fl->fl_start + 1; 1918 fl->fl_end - fl->fl_start + 1;
@@ -1942,13 +1941,13 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l)
1942 if (error) 1941 if (error)
1943 goto out; 1942 goto out;
1944 1943
1945 if (cmd == F_GETLKP) { 1944 if (cmd == F_OFD_GETLK) {
1946 error = -EINVAL; 1945 error = -EINVAL;
1947 if (flock.l_pid != 0) 1946 if (flock.l_pid != 0)
1948 goto out; 1947 goto out;
1949 1948
1950 cmd = F_GETLK; 1949 cmd = F_GETLK;
1951 file_lock.fl_flags |= FL_FILE_PVT; 1950 file_lock.fl_flags |= FL_OFDLCK;
1952 file_lock.fl_owner = (fl_owner_t)filp; 1951 file_lock.fl_owner = (fl_owner_t)filp;
1953 } 1952 }
1954 1953
@@ -2074,25 +2073,25 @@ again:
2074 2073
2075 /* 2074 /*
2076 * If the cmd is requesting file-private locks, then set the 2075 * If the cmd is requesting file-private locks, then set the
2077 * FL_FILE_PVT flag and override the owner. 2076 * FL_OFDLCK flag and override the owner.
2078 */ 2077 */
2079 switch (cmd) { 2078 switch (cmd) {
2080 case F_SETLKP: 2079 case F_OFD_SETLK:
2081 error = -EINVAL; 2080 error = -EINVAL;
2082 if (flock.l_pid != 0) 2081 if (flock.l_pid != 0)
2083 goto out; 2082 goto out;
2084 2083
2085 cmd = F_SETLK; 2084 cmd = F_SETLK;
2086 file_lock->fl_flags |= FL_FILE_PVT; 2085 file_lock->fl_flags |= FL_OFDLCK;
2087 file_lock->fl_owner = (fl_owner_t)filp; 2086 file_lock->fl_owner = (fl_owner_t)filp;
2088 break; 2087 break;
2089 case F_SETLKPW: 2088 case F_OFD_SETLKW:
2090 error = -EINVAL; 2089 error = -EINVAL;
2091 if (flock.l_pid != 0) 2090 if (flock.l_pid != 0)
2092 goto out; 2091 goto out;
2093 2092
2094 cmd = F_SETLKW; 2093 cmd = F_SETLKW;
2095 file_lock->fl_flags |= FL_FILE_PVT; 2094 file_lock->fl_flags |= FL_OFDLCK;
2096 file_lock->fl_owner = (fl_owner_t)filp; 2095 file_lock->fl_owner = (fl_owner_t)filp;
2097 /* Fallthrough */ 2096 /* Fallthrough */
2098 case F_SETLKW: 2097 case F_SETLKW:
@@ -2144,13 +2143,13 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
2144 if (error) 2143 if (error)
2145 goto out; 2144 goto out;
2146 2145
2147 if (cmd == F_GETLKP) { 2146 if (cmd == F_OFD_GETLK) {
2148 error = -EINVAL; 2147 error = -EINVAL;
2149 if (flock.l_pid != 0) 2148 if (flock.l_pid != 0)
2150 goto out; 2149 goto out;
2151 2150
2152 cmd = F_GETLK64; 2151 cmd = F_GETLK64;
2153 file_lock.fl_flags |= FL_FILE_PVT; 2152 file_lock.fl_flags |= FL_OFDLCK;
2154 file_lock.fl_owner = (fl_owner_t)filp; 2153 file_lock.fl_owner = (fl_owner_t)filp;
2155 } 2154 }
2156 2155
@@ -2209,25 +2208,25 @@ again:
2209 2208
2210 /* 2209 /*
2211 * If the cmd is requesting file-private locks, then set the 2210 * If the cmd is requesting file-private locks, then set the
2212 * FL_FILE_PVT flag and override the owner. 2211 * FL_OFDLCK flag and override the owner.
2213 */ 2212 */
2214 switch (cmd) { 2213 switch (cmd) {
2215 case F_SETLKP: 2214 case F_OFD_SETLK:
2216 error = -EINVAL; 2215 error = -EINVAL;
2217 if (flock.l_pid != 0) 2216 if (flock.l_pid != 0)
2218 goto out; 2217 goto out;
2219 2218
2220 cmd = F_SETLK64; 2219 cmd = F_SETLK64;
2221 file_lock->fl_flags |= FL_FILE_PVT; 2220 file_lock->fl_flags |= FL_OFDLCK;
2222 file_lock->fl_owner = (fl_owner_t)filp; 2221 file_lock->fl_owner = (fl_owner_t)filp;
2223 break; 2222 break;
2224 case F_SETLKPW: 2223 case F_OFD_SETLKW:
2225 error = -EINVAL; 2224 error = -EINVAL;
2226 if (flock.l_pid != 0) 2225 if (flock.l_pid != 0)
2227 goto out; 2226 goto out;
2228 2227
2229 cmd = F_SETLKW64; 2228 cmd = F_SETLKW64;
2230 file_lock->fl_flags |= FL_FILE_PVT; 2229 file_lock->fl_flags |= FL_OFDLCK;
2231 file_lock->fl_owner = (fl_owner_t)filp; 2230 file_lock->fl_owner = (fl_owner_t)filp;
2232 /* Fallthrough */ 2231 /* Fallthrough */
2233 case F_SETLKW64: 2232 case F_SETLKW64:
@@ -2413,8 +2412,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2413 if (IS_POSIX(fl)) { 2412 if (IS_POSIX(fl)) {
2414 if (fl->fl_flags & FL_ACCESS) 2413 if (fl->fl_flags & FL_ACCESS)
2415 seq_printf(f, "ACCESS"); 2414 seq_printf(f, "ACCESS");
2416 else if (IS_FILE_PVT(fl)) 2415 else if (IS_OFDLCK(fl))
2417 seq_printf(f, "FLPVT "); 2416 seq_printf(f, "OFDLCK");
2418 else 2417 else
2419 seq_printf(f, "POSIX "); 2418 seq_printf(f, "POSIX ");
2420 2419
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 39c8ef875f91..2c73cae9899d 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -654,9 +654,11 @@ static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
654 654
655static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) 655static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
656{ 656{
657 int maxtime = max_cb_time(clp->net);
657 struct rpc_timeout timeparms = { 658 struct rpc_timeout timeparms = {
658 .to_initval = max_cb_time(clp->net), 659 .to_initval = maxtime,
659 .to_retries = 0, 660 .to_retries = 0,
661 .to_maxval = maxtime,
660 }; 662 };
661 struct rpc_create_args args = { 663 struct rpc_create_args args = {
662 .net = clp->net, 664 .net = clp->net,
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2723c1badd01..18881f34737a 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3627,14 +3627,6 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
3627 /* nfsd4_check_resp_size guarantees enough room for error status */ 3627 /* nfsd4_check_resp_size guarantees enough room for error status */
3628 if (!op->status) 3628 if (!op->status)
3629 op->status = nfsd4_check_resp_size(resp, 0); 3629 op->status = nfsd4_check_resp_size(resp, 0);
3630 if (op->status == nfserr_resource && nfsd4_has_session(&resp->cstate)) {
3631 struct nfsd4_slot *slot = resp->cstate.slot;
3632
3633 if (slot->sl_flags & NFSD4_SLOT_CACHETHIS)
3634 op->status = nfserr_rep_too_big_to_cache;
3635 else
3636 op->status = nfserr_rep_too_big;
3637 }
3638 if (so) { 3630 if (so) {
3639 so->so_replay.rp_status = op->status; 3631 so->so_replay.rp_status = op->status;
3640 so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); 3632 so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1);
diff --git a/fs/open.c b/fs/open.c
index 3d30eb1fc95e..9d64679cec73 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -254,17 +254,22 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
254 return -EBADF; 254 return -EBADF;
255 255
256 /* 256 /*
257 * It's not possible to punch hole or perform collapse range 257 * We can only allow pure fallocate on append only files
258 * on append only file
259 */ 258 */
260 if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE) 259 if ((mode & ~FALLOC_FL_KEEP_SIZE) && IS_APPEND(inode))
261 && IS_APPEND(inode))
262 return -EPERM; 260 return -EPERM;
263 261
264 if (IS_IMMUTABLE(inode)) 262 if (IS_IMMUTABLE(inode))
265 return -EPERM; 263 return -EPERM;
266 264
267 /* 265 /*
266 * We can not allow to do any fallocate operation on an active
267 * swapfile
268 */
269 if (IS_SWAPFILE(inode))
270 ret = -ETXTBSY;
271
272 /*
268 * Revalidate the write permissions, in case security policy has 273 * Revalidate the write permissions, in case security policy has
269 * changed since the files were opened. 274 * changed since the files were opened.
270 */ 275 */
@@ -286,14 +291,6 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
286 if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) 291 if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
287 return -EFBIG; 292 return -EFBIG;
288 293
289 /*
290 * There is no need to overlap collapse range with EOF, in which case
291 * it is effectively a truncate operation
292 */
293 if ((mode & FALLOC_FL_COLLAPSE_RANGE) &&
294 (offset + len >= i_size_read(inode)))
295 return -EINVAL;
296
297 if (!file->f_op->fallocate) 294 if (!file->f_op->fallocate)
298 return -EOPNOTSUPP; 295 return -EOPNOTSUPP;
299 296
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index a1266089eca1..a81c7b556896 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1556,7 +1556,7 @@ static int ubifs_remount_rw(struct ubifs_info *c)
1556 if (c->space_fixup) { 1556 if (c->space_fixup) {
1557 err = ubifs_fixup_free_space(c); 1557 err = ubifs_fixup_free_space(c);
1558 if (err) 1558 if (err)
1559 return err; 1559 goto out;
1560 } 1560 }
1561 1561
1562 err = check_free_space(c); 1562 err = check_free_space(c);
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 82afdcb33183..951a2321ee01 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -841,7 +841,15 @@ xfs_file_fallocate(
841 goto out_unlock; 841 goto out_unlock;
842 } 842 }
843 843
844 ASSERT(offset + len < i_size_read(inode)); 844 /*
845 * There is no need to overlap collapse range with EOF,
846 * in which case it is effectively a truncate operation
847 */
848 if (offset + len >= i_size_read(inode)) {
849 error = -EINVAL;
850 goto out_unlock;
851 }
852
845 new_size = i_size_read(inode) - len; 853 new_size = i_size_read(inode) - len;
846 854
847 error = xfs_collapse_file_space(ip, offset, len); 855 error = xfs_collapse_file_space(ip, offset, len);
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 5a64ca4621f3..f23174fb9ec4 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -93,5 +93,8 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
93#define set_fixmap_io(idx, phys) \ 93#define set_fixmap_io(idx, phys) \
94 __set_fixmap(idx, phys, FIXMAP_PAGE_IO) 94 __set_fixmap(idx, phys, FIXMAP_PAGE_IO)
95 95
96#define set_fixmap_offset_io(idx, phys) \
97 __set_fixmap_offset(idx, phys, FIXMAP_PAGE_IO)
98
96#endif /* __ASSEMBLY__ */ 99#endif /* __ASSEMBLY__ */
97#endif /* __ASM_GENERIC_FIXMAP_H */ 100#endif /* __ASM_GENERIC_FIXMAP_H */
diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
index d3909effd725..94f9ea8abcae 100644
--- a/include/asm-generic/word-at-a-time.h
+++ b/include/asm-generic/word-at-a-time.h
@@ -50,11 +50,7 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
50} 50}
51 51
52#ifndef zero_bytemask 52#ifndef zero_bytemask
53#ifdef CONFIG_64BIT 53#define zero_bytemask(mask) (~1ul << __fls(mask))
54#define zero_bytemask(mask) (~0ul << fls64(mask)) 54#endif
55#else
56#define zero_bytemask(mask) (~0ul << fls(mask))
57#endif /* CONFIG_64BIT */
58#endif /* zero_bytemask */
59 55
60#endif /* _ASM_WORD_AT_A_TIME_H */ 56#endif /* _ASM_WORD_AT_A_TIME_H */
diff --git a/include/dt-bindings/clock/tegra124-car.h b/include/dt-bindings/clock/tegra124-car.h
index 8c1603b10665..433528ab5161 100644
--- a/include/dt-bindings/clock/tegra124-car.h
+++ b/include/dt-bindings/clock/tegra124-car.h
@@ -29,7 +29,7 @@
29/* 10 (register bit affects spdif_in and spdif_out) */ 29/* 10 (register bit affects spdif_in and spdif_out) */
30#define TEGRA124_CLK_I2S1 11 30#define TEGRA124_CLK_I2S1 11
31#define TEGRA124_CLK_I2C1 12 31#define TEGRA124_CLK_I2C1 12
32#define TEGRA124_CLK_NDFLASH 13 32/* 13 */
33#define TEGRA124_CLK_SDMMC1 14 33#define TEGRA124_CLK_SDMMC1 14
34#define TEGRA124_CLK_SDMMC4 15 34#define TEGRA124_CLK_SDMMC4 15
35/* 16 */ 35/* 16 */
@@ -83,7 +83,7 @@
83 83
84/* 64 */ 84/* 64 */
85#define TEGRA124_CLK_UARTD 65 85#define TEGRA124_CLK_UARTD 65
86#define TEGRA124_CLK_UARTE 66 86/* 66 */
87#define TEGRA124_CLK_I2C3 67 87#define TEGRA124_CLK_I2C3 67
88#define TEGRA124_CLK_SBC4 68 88#define TEGRA124_CLK_SBC4 68
89#define TEGRA124_CLK_SDMMC3 69 89#define TEGRA124_CLK_SDMMC3 69
@@ -97,7 +97,7 @@
97#define TEGRA124_CLK_TRACE 77 97#define TEGRA124_CLK_TRACE 77
98#define TEGRA124_CLK_SOC_THERM 78 98#define TEGRA124_CLK_SOC_THERM 78
99#define TEGRA124_CLK_DTV 79 99#define TEGRA124_CLK_DTV 79
100#define TEGRA124_CLK_NDSPEED 80 100/* 80 */
101#define TEGRA124_CLK_I2CSLOW 81 101#define TEGRA124_CLK_I2CSLOW 81
102#define TEGRA124_CLK_DSIB 82 102#define TEGRA124_CLK_DSIB 82
103#define TEGRA124_CLK_TSEC 83 103#define TEGRA124_CLK_TSEC 83
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7a9c5bca2b76..878031227c57 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -815,7 +815,7 @@ static inline struct file *get_file(struct file *f)
815#define FL_SLEEP 128 /* A blocking lock */ 815#define FL_SLEEP 128 /* A blocking lock */
816#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ 816#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
817#define FL_UNLOCK_PENDING 512 /* Lease is being broken */ 817#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
818#define FL_FILE_PVT 1024 /* lock is private to the file */ 818#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
819 819
820/* 820/*
821 * Special return value from posix_lock_file() and vfs_lock_file() for 821 * Special return value from posix_lock_file() and vfs_lock_file() for
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 9212b017bc72..ae9504b4b67d 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -535,6 +535,7 @@ static inline int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_a
535extern int ftrace_arch_read_dyn_info(char *buf, int size); 535extern int ftrace_arch_read_dyn_info(char *buf, int size);
536 536
537extern int skip_trace(unsigned long ip); 537extern int skip_trace(unsigned long ip);
538extern void ftrace_module_init(struct module *mod);
538 539
539extern void ftrace_disable_daemon(void); 540extern void ftrace_disable_daemon(void);
540extern void ftrace_enable_daemon(void); 541extern void ftrace_enable_daemon(void);
@@ -544,6 +545,7 @@ static inline int ftrace_force_update(void) { return 0; }
544static inline void ftrace_disable_daemon(void) { } 545static inline void ftrace_disable_daemon(void) { }
545static inline void ftrace_enable_daemon(void) { } 546static inline void ftrace_enable_daemon(void) { }
546static inline void ftrace_release_mod(struct module *mod) {} 547static inline void ftrace_release_mod(struct module *mod) {}
548static inline void ftrace_module_init(struct module *mod) {}
547static inline __init int register_ftrace_command(struct ftrace_func_command *cmd) 549static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
548{ 550{
549 return -EINVAL; 551 return -EINVAL;
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index c7bfac1c4a7b..97ac926c78a7 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -203,7 +203,40 @@ static inline int check_wakeup_irqs(void) { return 0; }
203 203
204extern cpumask_var_t irq_default_affinity; 204extern cpumask_var_t irq_default_affinity;
205 205
206extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); 206/* Internal implementation. Use the helpers below */
207extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask,
208 bool force);
209
210/**
211 * irq_set_affinity - Set the irq affinity of a given irq
212 * @irq: Interrupt to set affinity
213 * @cpumask: cpumask
214 *
215 * Fails if cpumask does not contain an online CPU
216 */
217static inline int
218irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
219{
220 return __irq_set_affinity(irq, cpumask, false);
221}
222
223/**
224 * irq_force_affinity - Force the irq affinity of a given irq
225 * @irq: Interrupt to set affinity
226 * @cpumask: cpumask
227 *
228 * Same as irq_set_affinity, but without checking the mask against
229 * online cpus.
230 *
231 * Solely for low level cpu hotplug code, where we need to make per
232 * cpu interrupts affine before the cpu becomes online.
233 */
234static inline int
235irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
236{
237 return __irq_set_affinity(irq, cpumask, true);
238}
239
207extern int irq_can_set_affinity(unsigned int irq); 240extern int irq_can_set_affinity(unsigned int irq);
208extern int irq_select_affinity(unsigned int irq); 241extern int irq_select_affinity(unsigned int irq);
209 242
diff --git a/include/linux/irq.h b/include/linux/irq.h
index d278838908cb..5c57efb863d0 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -394,7 +394,8 @@ extern void remove_percpu_irq(unsigned int irq, struct irqaction *act);
394 394
395extern void irq_cpu_online(void); 395extern void irq_cpu_online(void);
396extern void irq_cpu_offline(void); 396extern void irq_cpu_offline(void);
397extern int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *cpumask); 397extern int irq_set_affinity_locked(struct irq_data *data,
398 const struct cpumask *cpumask, bool force);
398 399
399#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ) 400#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_PENDING_IRQ)
400void irq_move_irq(struct irq_data *data); 401void irq_move_irq(struct irq_data *data);
@@ -602,6 +603,8 @@ static inline u32 irq_get_trigger_type(unsigned int irq)
602 return d ? irqd_get_trigger_type(d) : 0; 603 return d ? irqd_get_trigger_type(d) : 0;
603} 604}
604 605
606unsigned int arch_dynirq_lower_bound(unsigned int from);
607
605int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, 608int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
606 struct module *owner); 609 struct module *owner);
607 610
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 1de36be64df4..5ab4e3a76721 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -822,6 +822,7 @@ struct ata_port {
822 unsigned long qc_allocated; 822 unsigned long qc_allocated;
823 unsigned int qc_active; 823 unsigned int qc_active;
824 int nr_active_links; /* #links with active qcs */ 824 int nr_active_links; /* #links with active qcs */
825 unsigned int last_tag; /* track next tag hw expects */
825 826
826 struct ata_link link; /* host default link */ 827 struct ata_link link; /* host default link */
827 struct ata_link *slave_link; /* see ata_slave_link_init() */ 828 struct ata_link *slave_link; /* see ata_slave_link_init() */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a803d792df1e..adc4658e9873 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3181,12 +3181,7 @@ void netdev_change_features(struct net_device *dev);
3181void netif_stacked_transfer_operstate(const struct net_device *rootdev, 3181void netif_stacked_transfer_operstate(const struct net_device *rootdev,
3182 struct net_device *dev); 3182 struct net_device *dev);
3183 3183
3184netdev_features_t netif_skb_dev_features(struct sk_buff *skb, 3184netdev_features_t netif_skb_features(struct sk_buff *skb);
3185 const struct net_device *dev);
3186static inline netdev_features_t netif_skb_features(struct sk_buff *skb)
3187{
3188 return netif_skb_dev_features(skb, skb->dev);
3189}
3190 3185
3191static inline bool net_gso_ok(netdev_features_t features, int gso_type) 3186static inline bool net_gso_ok(netdev_features_t features, int gso_type)
3192{ 3187{
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 5146ce066498..7a28115dd396 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -170,4 +170,11 @@ struct netlink_tap {
170extern int netlink_add_tap(struct netlink_tap *nt); 170extern int netlink_add_tap(struct netlink_tap *nt);
171extern int netlink_remove_tap(struct netlink_tap *nt); 171extern int netlink_remove_tap(struct netlink_tap *nt);
172 172
173bool __netlink_ns_capable(const struct netlink_skb_parms *nsp,
174 struct user_namespace *ns, int cap);
175bool netlink_ns_capable(const struct sk_buff *skb,
176 struct user_namespace *ns, int cap);
177bool netlink_capable(const struct sk_buff *skb, int cap);
178bool netlink_net_capable(const struct sk_buff *skb, int cap);
179
173#endif /* __LINUX_NETLINK_H */ 180#endif /* __LINUX_NETLINK_H */
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index 3f23b4472c31..6404253d810d 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -44,11 +44,16 @@ extern void of_irq_init(const struct of_device_id *matches);
44 44
45#ifdef CONFIG_OF_IRQ 45#ifdef CONFIG_OF_IRQ
46extern int of_irq_count(struct device_node *dev); 46extern int of_irq_count(struct device_node *dev);
47extern int of_irq_get(struct device_node *dev, int index);
47#else 48#else
48static inline int of_irq_count(struct device_node *dev) 49static inline int of_irq_count(struct device_node *dev)
49{ 50{
50 return 0; 51 return 0;
51} 52}
53static inline int of_irq_get(struct device_node *dev, int index)
54{
55 return 0;
56}
52#endif 57#endif
53 58
54#if defined(CONFIG_OF) 59#if defined(CONFIG_OF)
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 6fe8464ed767..881a7c3571f4 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -31,7 +31,12 @@ extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
31#else /* CONFIG_OF */ 31#else /* CONFIG_OF */
32static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) 32static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
33{ 33{
34 return -ENOSYS; 34 /*
35 * Fall back to the non-DT function to register a bus.
36 * This way, we don't have to keep compat bits around in drivers.
37 */
38
39 return mdiobus_register(mdio);
35} 40}
36 41
37static inline struct phy_device *of_phy_find_device(struct device_node *phy_np) 42static inline struct phy_device *of_phy_find_device(struct device_node *phy_np)
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index e2f5ca96cddc..2760744cb2a7 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -174,21 +174,29 @@ void devm_of_phy_provider_unregister(struct device *dev,
174#else 174#else
175static inline int phy_pm_runtime_get(struct phy *phy) 175static inline int phy_pm_runtime_get(struct phy *phy)
176{ 176{
177 if (!phy)
178 return 0;
177 return -ENOSYS; 179 return -ENOSYS;
178} 180}
179 181
180static inline int phy_pm_runtime_get_sync(struct phy *phy) 182static inline int phy_pm_runtime_get_sync(struct phy *phy)
181{ 183{
184 if (!phy)
185 return 0;
182 return -ENOSYS; 186 return -ENOSYS;
183} 187}
184 188
185static inline int phy_pm_runtime_put(struct phy *phy) 189static inline int phy_pm_runtime_put(struct phy *phy)
186{ 190{
191 if (!phy)
192 return 0;
187 return -ENOSYS; 193 return -ENOSYS;
188} 194}
189 195
190static inline int phy_pm_runtime_put_sync(struct phy *phy) 196static inline int phy_pm_runtime_put_sync(struct phy *phy)
191{ 197{
198 if (!phy)
199 return 0;
192 return -ENOSYS; 200 return -ENOSYS;
193} 201}
194 202
@@ -204,21 +212,29 @@ static inline void phy_pm_runtime_forbid(struct phy *phy)
204 212
205static inline int phy_init(struct phy *phy) 213static inline int phy_init(struct phy *phy)
206{ 214{
215 if (!phy)
216 return 0;
207 return -ENOSYS; 217 return -ENOSYS;
208} 218}
209 219
210static inline int phy_exit(struct phy *phy) 220static inline int phy_exit(struct phy *phy)
211{ 221{
222 if (!phy)
223 return 0;
212 return -ENOSYS; 224 return -ENOSYS;
213} 225}
214 226
215static inline int phy_power_on(struct phy *phy) 227static inline int phy_power_on(struct phy *phy)
216{ 228{
229 if (!phy)
230 return 0;
217 return -ENOSYS; 231 return -ENOSYS;
218} 232}
219 233
220static inline int phy_power_off(struct phy *phy) 234static inline int phy_power_off(struct phy *phy)
221{ 235{
236 if (!phy)
237 return 0;
222 return -ENOSYS; 238 return -ENOSYS;
223} 239}
224 240
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index e530681bea70..1a4a8c157b31 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -258,14 +258,14 @@ regulator_get_exclusive(struct device *dev, const char *id)
258static inline struct regulator *__must_check 258static inline struct regulator *__must_check
259regulator_get_optional(struct device *dev, const char *id) 259regulator_get_optional(struct device *dev, const char *id)
260{ 260{
261 return NULL; 261 return ERR_PTR(-ENODEV);
262} 262}
263 263
264 264
265static inline struct regulator *__must_check 265static inline struct regulator *__must_check
266devm_regulator_get_optional(struct device *dev, const char *id) 266devm_regulator_get_optional(struct device *dev, const char *id)
267{ 267{
268 return NULL; 268 return ERR_PTR(-ENODEV);
269} 269}
270 270
271static inline void regulator_put(struct regulator *regulator) 271static inline void regulator_put(struct regulator *regulator)
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 36aac733840a..9f779c7a2da4 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -23,6 +23,7 @@ struct serio {
23 23
24 char name[32]; 24 char name[32];
25 char phys[32]; 25 char phys[32];
26 char firmware_id[128];
26 27
27 bool manual_bind; 28 bool manual_bind;
28 29
diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
index 302ab805b0bb..46cca4c06848 100644
--- a/include/linux/sock_diag.h
+++ b/include/linux/sock_diag.h
@@ -23,7 +23,7 @@ int sock_diag_check_cookie(void *sk, __u32 *cookie);
23void sock_diag_save_cookie(void *sk, __u32 *cookie); 23void sock_diag_save_cookie(void *sk, __u32 *cookie);
24 24
25int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr); 25int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attr);
26int sock_diag_put_filterinfo(struct sock *sk, 26int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
27 struct sk_buff *skb, int attrtype); 27 struct sk_buff *skb, int attrtype);
28 28
29#endif 29#endif
diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index 7d64d3609ec9..428277869400 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -155,7 +155,11 @@ struct vsock_transport {
155 155
156/**** CORE ****/ 156/**** CORE ****/
157 157
158int vsock_core_init(const struct vsock_transport *t); 158int __vsock_core_init(const struct vsock_transport *t, struct module *owner);
159static inline int vsock_core_init(const struct vsock_transport *t)
160{
161 return __vsock_core_init(t, THIS_MODULE);
162}
159void vsock_core_exit(void); 163void vsock_core_exit(void);
160 164
161/**** UTILS ****/ 165/**** UTILS ****/
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7eae46ccec01..f2c318655519 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3692,6 +3692,18 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy);
3692void cfg80211_sched_scan_stopped(struct wiphy *wiphy); 3692void cfg80211_sched_scan_stopped(struct wiphy *wiphy);
3693 3693
3694/** 3694/**
3695 * cfg80211_sched_scan_stopped_rtnl - notify that the scheduled scan has stopped
3696 *
3697 * @wiphy: the wiphy on which the scheduled scan stopped
3698 *
3699 * The driver can call this function to inform cfg80211 that the
3700 * scheduled scan had to be stopped, for whatever reason. The driver
3701 * is then called back via the sched_scan_stop operation when done.
3702 * This function should be called with rtnl locked.
3703 */
3704void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy);
3705
3706/**
3695 * cfg80211_inform_bss_width_frame - inform cfg80211 of a received BSS frame 3707 * cfg80211_inform_bss_width_frame - inform cfg80211 of a received BSS frame
3696 * 3708 *
3697 * @wiphy: the wiphy reporting the BSS 3709 * @wiphy: the wiphy reporting the BSS
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 80f500a29498..b2704fd0ec80 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -20,6 +20,11 @@ struct local_ports {
20 int range[2]; 20 int range[2];
21}; 21};
22 22
23struct ping_group_range {
24 seqlock_t lock;
25 kgid_t range[2];
26};
27
23struct netns_ipv4 { 28struct netns_ipv4 {
24#ifdef CONFIG_SYSCTL 29#ifdef CONFIG_SYSCTL
25 struct ctl_table_header *forw_hdr; 30 struct ctl_table_header *forw_hdr;
@@ -66,13 +71,13 @@ struct netns_ipv4 {
66 int sysctl_icmp_ratemask; 71 int sysctl_icmp_ratemask;
67 int sysctl_icmp_errors_use_inbound_ifaddr; 72 int sysctl_icmp_errors_use_inbound_ifaddr;
68 73
69 struct local_ports sysctl_local_ports; 74 struct local_ports ip_local_ports;
70 75
71 int sysctl_tcp_ecn; 76 int sysctl_tcp_ecn;
72 int sysctl_ip_no_pmtu_disc; 77 int sysctl_ip_no_pmtu_disc;
73 int sysctl_ip_fwd_use_pmtu; 78 int sysctl_ip_fwd_use_pmtu;
74 79
75 kgid_t sysctl_ping_group_range[2]; 80 struct ping_group_range ping_group_range;
76 81
77 atomic_t dev_addr_genid; 82 atomic_t dev_addr_genid;
78 83
diff --git a/include/net/sock.h b/include/net/sock.h
index 8338a14e4805..21569cf456ed 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2255,6 +2255,11 @@ int sock_get_timestampns(struct sock *, struct timespec __user *);
2255int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len, int level, 2255int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len, int level,
2256 int type); 2256 int type);
2257 2257
2258bool sk_ns_capable(const struct sock *sk,
2259 struct user_namespace *user_ns, int cap);
2260bool sk_capable(const struct sock *sk, int cap);
2261bool sk_net_capable(const struct sock *sk, int cap);
2262
2258/* 2263/*
2259 * Enable debug/info messages 2264 * Enable debug/info messages
2260 */ 2265 */
diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
index 010ea89eeb0e..6a1a0245474f 100644
--- a/include/trace/events/ext4.h
+++ b/include/trace/events/ext4.h
@@ -16,15 +16,6 @@ struct mpage_da_data;
16struct ext4_map_blocks; 16struct ext4_map_blocks;
17struct extent_status; 17struct extent_status;
18 18
19/* shim until we merge in the xfs_collapse_range branch */
20#ifndef FALLOC_FL_COLLAPSE_RANGE
21#define FALLOC_FL_COLLAPSE_RANGE 0x08
22#endif
23
24#ifndef FALLOC_FL_ZERO_RANGE
25#define FALLOC_FL_ZERO_RANGE 0x10
26#endif
27
28#define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) 19#define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode))
29 20
30#define show_mballoc_flags(flags) __print_flags(flags, "|", \ 21#define show_mballoc_flags(flags) __print_flags(flags, "|", \
diff --git a/include/trace/events/module.h b/include/trace/events/module.h
index 11fd51b413de..ed0b2c599a64 100644
--- a/include/trace/events/module.h
+++ b/include/trace/events/module.h
@@ -25,7 +25,7 @@ struct module;
25 { (1UL << TAINT_OOT_MODULE), "O" }, \ 25 { (1UL << TAINT_OOT_MODULE), "O" }, \
26 { (1UL << TAINT_FORCED_MODULE), "F" }, \ 26 { (1UL << TAINT_FORCED_MODULE), "F" }, \
27 { (1UL << TAINT_CRAP), "C" }, \ 27 { (1UL << TAINT_CRAP), "C" }, \
28 { (1UL << TAINT_UNSIGNED_MODULE), "X" }) 28 { (1UL << TAINT_UNSIGNED_MODULE), "E" })
29 29
30TRACE_EVENT(module_load, 30TRACE_EVENT(module_load,
31 31
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index a9b13f8b3595..7543b3e51331 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -133,20 +133,20 @@
133#endif 133#endif
134 134
135/* 135/*
136 * fd "private" POSIX locks. 136 * Open File Description Locks
137 * 137 *
138 * Usually POSIX locks held by a process are released on *any* close and are 138 * Usually record locks held by a process are released on *any* close and are
139 * not inherited across a fork(). 139 * not inherited across a fork().
140 * 140 *
141 * These cmd values will set locks that conflict with normal POSIX locks, but 141 * These cmd values will set locks that conflict with process-associated
142 * are "owned" by the opened file, not the process. This means that they are 142 * record locks, but are "owned" by the open file description, not the
143 * inherited across fork() like BSD (flock) locks, and they are only released 143 * process. This means that they are inherited across fork() like BSD (flock)
144 * automatically when the last reference to the the open file against which 144 * locks, and they are only released automatically when the last reference to
145 * they were acquired is put. 145 * the the open file against which they were acquired is put.
146 */ 146 */
147#define F_GETLKP 36 147#define F_OFD_GETLK 36
148#define F_SETLKP 37 148#define F_OFD_SETLK 37
149#define F_SETLKPW 38 149#define F_OFD_SETLKW 38
150 150
151#define F_OWNER_TID 0 151#define F_OWNER_TID 0
152#define F_OWNER_PID 1 152#define F_OWNER_PID 1
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index bd24470d24a2..f4849525519c 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -164,6 +164,7 @@ struct input_keymap_entry {
164#define INPUT_PROP_DIRECT 0x01 /* direct input devices */ 164#define INPUT_PROP_DIRECT 0x01 /* direct input devices */
165#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ 165#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */
166#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ 166#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */
167#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */
167 168
168#define INPUT_PROP_MAX 0x1f 169#define INPUT_PROP_MAX 0x1f
169#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) 170#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
diff --git a/kernel/audit.c b/kernel/audit.c
index 33531d72e4a2..81f5f49479da 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -675,13 +675,13 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type)
675 if ((task_active_pid_ns(current) != &init_pid_ns)) 675 if ((task_active_pid_ns(current) != &init_pid_ns))
676 return -EPERM; 676 return -EPERM;
677 677
678 if (!capable(CAP_AUDIT_CONTROL)) 678 if (!netlink_capable(skb, CAP_AUDIT_CONTROL))
679 err = -EPERM; 679 err = -EPERM;
680 break; 680 break;
681 case AUDIT_USER: 681 case AUDIT_USER:
682 case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG: 682 case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG:
683 case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: 683 case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2:
684 if (!capable(CAP_AUDIT_WRITE)) 684 if (!netlink_capable(skb, CAP_AUDIT_WRITE))
685 err = -EPERM; 685 err = -EPERM;
686 break; 686 break;
687 default: /* bad msg */ 687 default: /* bad msg */
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index d55092ceee29..6b715c0af1b1 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -234,6 +234,11 @@ again:
234 goto again; 234 goto again;
235 } 235 }
236 timer->base = new_base; 236 timer->base = new_base;
237 } else {
238 if (cpu != this_cpu && hrtimer_check_target(timer, new_base)) {
239 cpu = this_cpu;
240 goto again;
241 }
237 } 242 }
238 return new_base; 243 return new_base;
239} 244}
@@ -569,6 +574,23 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
569 574
570 cpu_base->expires_next.tv64 = expires_next.tv64; 575 cpu_base->expires_next.tv64 = expires_next.tv64;
571 576
577 /*
578 * If a hang was detected in the last timer interrupt then we
579 * leave the hang delay active in the hardware. We want the
580 * system to make progress. That also prevents the following
581 * scenario:
582 * T1 expires 50ms from now
583 * T2 expires 5s from now
584 *
585 * T1 is removed, so this code is called and would reprogram
586 * the hardware to 5s from now. Any hrtimer_start after that
587 * will not reprogram the hardware due to hang_detected being
588 * set. So we'd effectivly block all timers until the T2 event
589 * fires.
590 */
591 if (cpu_base->hang_detected)
592 return;
593
572 if (cpu_base->expires_next.tv64 != KTIME_MAX) 594 if (cpu_base->expires_next.tv64 != KTIME_MAX)
573 tick_program_event(cpu_base->expires_next, 1); 595 tick_program_event(cpu_base->expires_next, 1);
574} 596}
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index a7174617616b..bb07f2928f4b 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -363,6 +363,13 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
363 if (from > irq) 363 if (from > irq)
364 return -EINVAL; 364 return -EINVAL;
365 from = irq; 365 from = irq;
366 } else {
367 /*
368 * For interrupts which are freely allocated the
369 * architecture can force a lower bound to the @from
370 * argument. x86 uses this to exclude the GSI space.
371 */
372 from = arch_dynirq_lower_bound(from);
366 } 373 }
367 374
368 mutex_lock(&sparse_irq_lock); 375 mutex_lock(&sparse_irq_lock);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 2486a4c1a710..d34131ca372b 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -180,7 +180,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
180 struct irq_chip *chip = irq_data_get_irq_chip(data); 180 struct irq_chip *chip = irq_data_get_irq_chip(data);
181 int ret; 181 int ret;
182 182
183 ret = chip->irq_set_affinity(data, mask, false); 183 ret = chip->irq_set_affinity(data, mask, force);
184 switch (ret) { 184 switch (ret) {
185 case IRQ_SET_MASK_OK: 185 case IRQ_SET_MASK_OK:
186 cpumask_copy(data->affinity, mask); 186 cpumask_copy(data->affinity, mask);
@@ -192,7 +192,8 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
192 return ret; 192 return ret;
193} 193}
194 194
195int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask) 195int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
196 bool force)
196{ 197{
197 struct irq_chip *chip = irq_data_get_irq_chip(data); 198 struct irq_chip *chip = irq_data_get_irq_chip(data);
198 struct irq_desc *desc = irq_data_to_desc(data); 199 struct irq_desc *desc = irq_data_to_desc(data);
@@ -202,7 +203,7 @@ int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
202 return -EINVAL; 203 return -EINVAL;
203 204
204 if (irq_can_move_pcntxt(data)) { 205 if (irq_can_move_pcntxt(data)) {
205 ret = irq_do_set_affinity(data, mask, false); 206 ret = irq_do_set_affinity(data, mask, force);
206 } else { 207 } else {
207 irqd_set_move_pending(data); 208 irqd_set_move_pending(data);
208 irq_copy_pending(desc, mask); 209 irq_copy_pending(desc, mask);
@@ -217,13 +218,7 @@ int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
217 return ret; 218 return ret;
218} 219}
219 220
220/** 221int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
221 * irq_set_affinity - Set the irq affinity of a given irq
222 * @irq: Interrupt to set affinity
223 * @mask: cpumask
224 *
225 */
226int irq_set_affinity(unsigned int irq, const struct cpumask *mask)
227{ 222{
228 struct irq_desc *desc = irq_to_desc(irq); 223 struct irq_desc *desc = irq_to_desc(irq);
229 unsigned long flags; 224 unsigned long flags;
@@ -233,7 +228,7 @@ int irq_set_affinity(unsigned int irq, const struct cpumask *mask)
233 return -EINVAL; 228 return -EINVAL;
234 229
235 raw_spin_lock_irqsave(&desc->lock, flags); 230 raw_spin_lock_irqsave(&desc->lock, flags);
236 ret = __irq_set_affinity_locked(irq_desc_get_irq_data(desc), mask); 231 ret = irq_set_affinity_locked(irq_desc_get_irq_data(desc), mask, force);
237 raw_spin_unlock_irqrestore(&desc->lock, flags); 232 raw_spin_unlock_irqrestore(&desc->lock, flags);
238 return ret; 233 return ret;
239} 234}
diff --git a/kernel/module.c b/kernel/module.c
index 11869408f79b..079c4615607d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -815,9 +815,6 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
815 return -EFAULT; 815 return -EFAULT;
816 name[MODULE_NAME_LEN-1] = '\0'; 816 name[MODULE_NAME_LEN-1] = '\0';
817 817
818 if (!(flags & O_NONBLOCK))
819 pr_warn("waiting module removal not supported: please upgrade\n");
820
821 if (mutex_lock_interruptible(&module_mutex) != 0) 818 if (mutex_lock_interruptible(&module_mutex) != 0)
822 return -EINTR; 819 return -EINTR;
823 820
@@ -3271,6 +3268,9 @@ static int load_module(struct load_info *info, const char __user *uargs,
3271 3268
3272 dynamic_debug_setup(info->debug, info->num_debug); 3269 dynamic_debug_setup(info->debug, info->num_debug);
3273 3270
3271 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
3272 ftrace_module_init(mod);
3273
3274 /* Finally it's fully formed, ready to start executing. */ 3274 /* Finally it's fully formed, ready to start executing. */
3275 err = complete_formation(mod, info); 3275 err = complete_formation(mod, info);
3276 if (err) 3276 if (err)
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index c3ad9cafe930..8233cd4047d7 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/console.h> 15#include <linux/console.h>
16#include <linux/cpu.h> 16#include <linux/cpu.h>
17#include <linux/cpuidle.h>
17#include <linux/syscalls.h> 18#include <linux/syscalls.h>
18#include <linux/gfp.h> 19#include <linux/gfp.h>
19#include <linux/io.h> 20#include <linux/io.h>
@@ -53,7 +54,9 @@ static void freeze_begin(void)
53 54
54static void freeze_enter(void) 55static void freeze_enter(void)
55{ 56{
57 cpuidle_resume();
56 wait_event(suspend_freeze_wait_head, suspend_freeze_wake); 58 wait_event(suspend_freeze_wait_head, suspend_freeze_wake);
59 cpuidle_pause();
57} 60}
58 61
59void freeze_wake(void) 62void freeze_wake(void)
diff --git a/kernel/softirq.c b/kernel/softirq.c
index b50990a5bea0..33e4648ae0e7 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -779,3 +779,8 @@ int __init __weak arch_early_irq_init(void)
779{ 779{
780 return 0; 780 return 0;
781} 781}
782
783unsigned int __weak arch_dynirq_lower_bound(unsigned int from)
784{
785 return from;
786}
diff --git a/kernel/timer.c b/kernel/timer.c
index 87bd529879c2..3bb01a323b2a 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -838,7 +838,7 @@ unsigned long apply_slack(struct timer_list *timer, unsigned long expires)
838 838
839 bit = find_last_bit(&mask, BITS_PER_LONG); 839 bit = find_last_bit(&mask, BITS_PER_LONG);
840 840
841 mask = (1 << bit) - 1; 841 mask = (1UL << bit) - 1;
842 842
843 expires_limit = expires_limit & ~(mask); 843 expires_limit = expires_limit & ~(mask);
844 844
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1fd4b9479210..4a54a25afa2f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4330,16 +4330,11 @@ static void ftrace_init_module(struct module *mod,
4330 ftrace_process_locs(mod, start, end); 4330 ftrace_process_locs(mod, start, end);
4331} 4331}
4332 4332
4333static int ftrace_module_notify_enter(struct notifier_block *self, 4333void ftrace_module_init(struct module *mod)
4334 unsigned long val, void *data)
4335{ 4334{
4336 struct module *mod = data; 4335 ftrace_init_module(mod, mod->ftrace_callsites,
4337 4336 mod->ftrace_callsites +
4338 if (val == MODULE_STATE_COMING) 4337 mod->num_ftrace_callsites);
4339 ftrace_init_module(mod, mod->ftrace_callsites,
4340 mod->ftrace_callsites +
4341 mod->num_ftrace_callsites);
4342 return 0;
4343} 4338}
4344 4339
4345static int ftrace_module_notify_exit(struct notifier_block *self, 4340static int ftrace_module_notify_exit(struct notifier_block *self,
@@ -4353,11 +4348,6 @@ static int ftrace_module_notify_exit(struct notifier_block *self,
4353 return 0; 4348 return 0;
4354} 4349}
4355#else 4350#else
4356static int ftrace_module_notify_enter(struct notifier_block *self,
4357 unsigned long val, void *data)
4358{
4359 return 0;
4360}
4361static int ftrace_module_notify_exit(struct notifier_block *self, 4351static int ftrace_module_notify_exit(struct notifier_block *self,
4362 unsigned long val, void *data) 4352 unsigned long val, void *data)
4363{ 4353{
@@ -4365,11 +4355,6 @@ static int ftrace_module_notify_exit(struct notifier_block *self,
4365} 4355}
4366#endif /* CONFIG_MODULES */ 4356#endif /* CONFIG_MODULES */
4367 4357
4368struct notifier_block ftrace_module_enter_nb = {
4369 .notifier_call = ftrace_module_notify_enter,
4370 .priority = INT_MAX, /* Run before anything that can use kprobes */
4371};
4372
4373struct notifier_block ftrace_module_exit_nb = { 4358struct notifier_block ftrace_module_exit_nb = {
4374 .notifier_call = ftrace_module_notify_exit, 4359 .notifier_call = ftrace_module_notify_exit,
4375 .priority = INT_MIN, /* Run after anything that can remove kprobes */ 4360 .priority = INT_MIN, /* Run after anything that can remove kprobes */
@@ -4403,10 +4388,6 @@ void __init ftrace_init(void)
4403 __start_mcount_loc, 4388 __start_mcount_loc,
4404 __stop_mcount_loc); 4389 __stop_mcount_loc);
4405 4390
4406 ret = register_module_notifier(&ftrace_module_enter_nb);
4407 if (ret)
4408 pr_warning("Failed to register trace ftrace module enter notifier\n");
4409
4410 ret = register_module_notifier(&ftrace_module_exit_nb); 4391 ret = register_module_notifier(&ftrace_module_exit_nb);
4411 if (ret) 4392 if (ret)
4412 pr_warning("Failed to register trace ftrace module exit notifier\n"); 4393 pr_warning("Failed to register trace ftrace module exit notifier\n");
diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c
index 925f537f07d1..4747b476a030 100644
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -77,7 +77,7 @@ event_triggers_call(struct ftrace_event_file *file, void *rec)
77 data->ops->func(data); 77 data->ops->func(data);
78 continue; 78 continue;
79 } 79 }
80 filter = rcu_dereference(data->filter); 80 filter = rcu_dereference_sched(data->filter);
81 if (filter && !filter_match_preds(filter, rec)) 81 if (filter && !filter_match_preds(filter, rec))
82 continue; 82 continue;
83 if (data->cmd_ops->post_trigger) { 83 if (data->cmd_ops->post_trigger) {
diff --git a/mm/memory.c b/mm/memory.c
index d0f0bef3be48..037b812a9531 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -232,17 +232,18 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long
232#endif 232#endif
233} 233}
234 234
235void tlb_flush_mmu(struct mmu_gather *tlb) 235static void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb)
236{ 236{
237 struct mmu_gather_batch *batch;
238
239 if (!tlb->need_flush)
240 return;
241 tlb->need_flush = 0; 237 tlb->need_flush = 0;
242 tlb_flush(tlb); 238 tlb_flush(tlb);
243#ifdef CONFIG_HAVE_RCU_TABLE_FREE 239#ifdef CONFIG_HAVE_RCU_TABLE_FREE
244 tlb_table_flush(tlb); 240 tlb_table_flush(tlb);
245#endif 241#endif
242}
243
244static void tlb_flush_mmu_free(struct mmu_gather *tlb)
245{
246 struct mmu_gather_batch *batch;
246 247
247 for (batch = &tlb->local; batch; batch = batch->next) { 248 for (batch = &tlb->local; batch; batch = batch->next) {
248 free_pages_and_swap_cache(batch->pages, batch->nr); 249 free_pages_and_swap_cache(batch->pages, batch->nr);
@@ -251,6 +252,14 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
251 tlb->active = &tlb->local; 252 tlb->active = &tlb->local;
252} 253}
253 254
255void tlb_flush_mmu(struct mmu_gather *tlb)
256{
257 if (!tlb->need_flush)
258 return;
259 tlb_flush_mmu_tlbonly(tlb);
260 tlb_flush_mmu_free(tlb);
261}
262
254/* tlb_finish_mmu 263/* tlb_finish_mmu
255 * Called at the end of the shootdown operation to free up any resources 264 * Called at the end of the shootdown operation to free up any resources
256 * that were required. 265 * that were required.
@@ -1127,8 +1136,10 @@ again:
1127 if (PageAnon(page)) 1136 if (PageAnon(page))
1128 rss[MM_ANONPAGES]--; 1137 rss[MM_ANONPAGES]--;
1129 else { 1138 else {
1130 if (pte_dirty(ptent)) 1139 if (pte_dirty(ptent)) {
1140 force_flush = 1;
1131 set_page_dirty(page); 1141 set_page_dirty(page);
1142 }
1132 if (pte_young(ptent) && 1143 if (pte_young(ptent) &&
1133 likely(!(vma->vm_flags & VM_SEQ_READ))) 1144 likely(!(vma->vm_flags & VM_SEQ_READ)))
1134 mark_page_accessed(page); 1145 mark_page_accessed(page);
@@ -1137,9 +1148,10 @@ again:
1137 page_remove_rmap(page); 1148 page_remove_rmap(page);
1138 if (unlikely(page_mapcount(page) < 0)) 1149 if (unlikely(page_mapcount(page) < 0))
1139 print_bad_pte(vma, addr, ptent, page); 1150 print_bad_pte(vma, addr, ptent, page);
1140 force_flush = !__tlb_remove_page(tlb, page); 1151 if (unlikely(!__tlb_remove_page(tlb, page))) {
1141 if (force_flush) 1152 force_flush = 1;
1142 break; 1153 break;
1154 }
1143 continue; 1155 continue;
1144 } 1156 }
1145 /* 1157 /*
@@ -1174,18 +1186,11 @@ again:
1174 1186
1175 add_mm_rss_vec(mm, rss); 1187 add_mm_rss_vec(mm, rss);
1176 arch_leave_lazy_mmu_mode(); 1188 arch_leave_lazy_mmu_mode();
1177 pte_unmap_unlock(start_pte, ptl);
1178 1189
1179 /* 1190 /* Do the actual TLB flush before dropping ptl */
1180 * mmu_gather ran out of room to batch pages, we break out of
1181 * the PTE lock to avoid doing the potential expensive TLB invalidate
1182 * and page-free while holding it.
1183 */
1184 if (force_flush) { 1191 if (force_flush) {
1185 unsigned long old_end; 1192 unsigned long old_end;
1186 1193
1187 force_flush = 0;
1188
1189 /* 1194 /*
1190 * Flush the TLB just for the previous segment, 1195 * Flush the TLB just for the previous segment,
1191 * then update the range to be the remaining 1196 * then update the range to be the remaining
@@ -1193,11 +1198,21 @@ again:
1193 */ 1198 */
1194 old_end = tlb->end; 1199 old_end = tlb->end;
1195 tlb->end = addr; 1200 tlb->end = addr;
1196 1201 tlb_flush_mmu_tlbonly(tlb);
1197 tlb_flush_mmu(tlb);
1198
1199 tlb->start = addr; 1202 tlb->start = addr;
1200 tlb->end = old_end; 1203 tlb->end = old_end;
1204 }
1205 pte_unmap_unlock(start_pte, ptl);
1206
1207 /*
1208 * If we forced a TLB flush (either due to running out of
1209 * batch buffers or because we needed to flush dirty TLB
1210 * entries before releasing the ptl), free the batched
1211 * memory too. Restart if we didn't do everything.
1212 */
1213 if (force_flush) {
1214 force_flush = 0;
1215 tlb_flush_mmu_free(tlb);
1201 1216
1202 if (addr != end) 1217 if (addr != end)
1203 goto again; 1218 goto again;
@@ -1955,12 +1970,17 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
1955 unsigned long address, unsigned int fault_flags) 1970 unsigned long address, unsigned int fault_flags)
1956{ 1971{
1957 struct vm_area_struct *vma; 1972 struct vm_area_struct *vma;
1973 vm_flags_t vm_flags;
1958 int ret; 1974 int ret;
1959 1975
1960 vma = find_extend_vma(mm, address); 1976 vma = find_extend_vma(mm, address);
1961 if (!vma || address < vma->vm_start) 1977 if (!vma || address < vma->vm_start)
1962 return -EFAULT; 1978 return -EFAULT;
1963 1979
1980 vm_flags = (fault_flags & FAULT_FLAG_WRITE) ? VM_WRITE : VM_READ;
1981 if (!(vm_flags & vma->vm_flags))
1982 return -EFAULT;
1983
1964 ret = handle_mm_fault(mm, vma, address, fault_flags); 1984 ret = handle_mm_fault(mm, vma, address, fault_flags);
1965 if (ret & VM_FAULT_ERROR) { 1985 if (ret & VM_FAULT_ERROR) {
1966 if (ret & VM_FAULT_OOM) 1986 if (ret & VM_FAULT_OOM)
diff --git a/mm/vmacache.c b/mm/vmacache.c
index d4224b397c0e..1037a3bab505 100644
--- a/mm/vmacache.c
+++ b/mm/vmacache.c
@@ -81,10 +81,12 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
81 for (i = 0; i < VMACACHE_SIZE; i++) { 81 for (i = 0; i < VMACACHE_SIZE; i++) {
82 struct vm_area_struct *vma = current->vmacache[i]; 82 struct vm_area_struct *vma = current->vmacache[i];
83 83
84 if (vma && vma->vm_start <= addr && vma->vm_end > addr) { 84 if (!vma)
85 BUG_ON(vma->vm_mm != mm); 85 continue;
86 if (WARN_ON_ONCE(vma->vm_mm != mm))
87 break;
88 if (vma->vm_start <= addr && vma->vm_end > addr)
86 return vma; 89 return vma;
87 }
88 } 90 }
89 91
90 return NULL; 92 return NULL;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 55a174317925..095943c02d6e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -884,14 +884,17 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
884 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { 884 if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
885 struct hci_cp_auth_requested cp; 885 struct hci_cp_auth_requested cp;
886 886
887 /* encrypt must be pending if auth is also pending */
888 set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
889
890 cp.handle = cpu_to_le16(conn->handle); 887 cp.handle = cpu_to_le16(conn->handle);
891 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED, 888 hci_send_cmd(conn->hdev, HCI_OP_AUTH_REQUESTED,
892 sizeof(cp), &cp); 889 sizeof(cp), &cp);
890
891 /* If we're already encrypted set the REAUTH_PEND flag,
892 * otherwise set the ENCRYPT_PEND.
893 */
893 if (conn->key_type != 0xff) 894 if (conn->key_type != 0xff)
894 set_bit(HCI_CONN_REAUTH_PEND, &conn->flags); 895 set_bit(HCI_CONN_REAUTH_PEND, &conn->flags);
896 else
897 set_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
895 } 898 }
896 899
897 return 0; 900 return 0;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 07c37d0cecb2..ca19fd4bbb8f 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3388,6 +3388,12 @@ static void hci_key_refresh_complete_evt(struct hci_dev *hdev,
3388 if (!conn) 3388 if (!conn)
3389 goto unlock; 3389 goto unlock;
3390 3390
3391 /* For BR/EDR the necessary steps are taken through the
3392 * auth_complete event.
3393 */
3394 if (conn->type != LE_LINK)
3395 goto unlock;
3396
3391 if (!ev->status) 3397 if (!ev->status)
3392 conn->sec_level = conn->pending_sec_level; 3398 conn->sec_level = conn->pending_sec_level;
3393 3399
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 80e1b0f60a30..2acf7fa1fec6 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -859,12 +859,12 @@ static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
859 return NF_STOLEN; 859 return NF_STOLEN;
860} 860}
861 861
862#if IS_ENABLED(CONFIG_NF_CONNTRACK_IPV4) 862#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
863static int br_nf_dev_queue_xmit(struct sk_buff *skb) 863static int br_nf_dev_queue_xmit(struct sk_buff *skb)
864{ 864{
865 int ret; 865 int ret;
866 866
867 if (skb->nfct != NULL && skb->protocol == htons(ETH_P_IP) && 867 if (skb->protocol == htons(ETH_P_IP) &&
868 skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu && 868 skb->len + nf_bridge_mtu_reduction(skb) > skb->dev->mtu &&
869 !skb_is_gso(skb)) { 869 !skb_is_gso(skb)) {
870 if (br_parse_ip_options(skb)) 870 if (br_parse_ip_options(skb))
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index e74b6d530cb6..e8844d975b32 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -445,6 +445,20 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[])
445 return 0; 445 return 0;
446} 446}
447 447
448static int br_dev_newlink(struct net *src_net, struct net_device *dev,
449 struct nlattr *tb[], struct nlattr *data[])
450{
451 struct net_bridge *br = netdev_priv(dev);
452
453 if (tb[IFLA_ADDRESS]) {
454 spin_lock_bh(&br->lock);
455 br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS]));
456 spin_unlock_bh(&br->lock);
457 }
458
459 return register_netdevice(dev);
460}
461
448static size_t br_get_link_af_size(const struct net_device *dev) 462static size_t br_get_link_af_size(const struct net_device *dev)
449{ 463{
450 struct net_port_vlans *pv; 464 struct net_port_vlans *pv;
@@ -473,6 +487,7 @@ struct rtnl_link_ops br_link_ops __read_mostly = {
473 .priv_size = sizeof(struct net_bridge), 487 .priv_size = sizeof(struct net_bridge),
474 .setup = br_dev_setup, 488 .setup = br_dev_setup,
475 .validate = br_validate, 489 .validate = br_validate,
490 .newlink = br_dev_newlink,
476 .dellink = br_dev_delete, 491 .dellink = br_dev_delete,
477}; 492};
478 493
diff --git a/net/can/gw.c b/net/can/gw.c
index ac31891967da..050a2110d43f 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -804,7 +804,7 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh)
804 u8 limhops = 0; 804 u8 limhops = 0;
805 int err = 0; 805 int err = 0;
806 806
807 if (!capable(CAP_NET_ADMIN)) 807 if (!netlink_capable(skb, CAP_NET_ADMIN))
808 return -EPERM; 808 return -EPERM;
809 809
810 if (nlmsg_len(nlh) < sizeof(*r)) 810 if (nlmsg_len(nlh) < sizeof(*r))
@@ -893,7 +893,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
893 u8 limhops = 0; 893 u8 limhops = 0;
894 int err = 0; 894 int err = 0;
895 895
896 if (!capable(CAP_NET_ADMIN)) 896 if (!netlink_capable(skb, CAP_NET_ADMIN))
897 return -EPERM; 897 return -EPERM;
898 898
899 if (nlmsg_len(nlh) < sizeof(*r)) 899 if (nlmsg_len(nlh) < sizeof(*r))
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index e632b5a52f5b..8b8a5a24b223 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1548,8 +1548,10 @@ static void apply_primary_affinity(struct ceph_osdmap *osdmap, u32 pps,
1548 return; 1548 return;
1549 1549
1550 for (i = 0; i < len; i++) { 1550 for (i = 0; i < len; i++) {
1551 if (osds[i] != CRUSH_ITEM_NONE && 1551 int osd = osds[i];
1552 osdmap->osd_primary_affinity[i] != 1552
1553 if (osd != CRUSH_ITEM_NONE &&
1554 osdmap->osd_primary_affinity[osd] !=
1553 CEPH_OSD_DEFAULT_PRIMARY_AFFINITY) { 1555 CEPH_OSD_DEFAULT_PRIMARY_AFFINITY) {
1554 break; 1556 break;
1555 } 1557 }
@@ -1563,10 +1565,9 @@ static void apply_primary_affinity(struct ceph_osdmap *osdmap, u32 pps,
1563 * osd's pgs get rejected as primary. 1565 * osd's pgs get rejected as primary.
1564 */ 1566 */
1565 for (i = 0; i < len; i++) { 1567 for (i = 0; i < len; i++) {
1566 int osd; 1568 int osd = osds[i];
1567 u32 aff; 1569 u32 aff;
1568 1570
1569 osd = osds[i];
1570 if (osd == CRUSH_ITEM_NONE) 1571 if (osd == CRUSH_ITEM_NONE)
1571 continue; 1572 continue;
1572 1573
diff --git a/net/core/dev.c b/net/core/dev.c
index fe0b9cd69cb6..867adb25b5b8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2424,7 +2424,7 @@ EXPORT_SYMBOL(netdev_rx_csum_fault);
2424 * 2. No high memory really exists on this machine. 2424 * 2. No high memory really exists on this machine.
2425 */ 2425 */
2426 2426
2427static int illegal_highdma(const struct net_device *dev, struct sk_buff *skb) 2427static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
2428{ 2428{
2429#ifdef CONFIG_HIGHMEM 2429#ifdef CONFIG_HIGHMEM
2430 int i; 2430 int i;
@@ -2499,38 +2499,36 @@ static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features)
2499} 2499}
2500 2500
2501static netdev_features_t harmonize_features(struct sk_buff *skb, 2501static netdev_features_t harmonize_features(struct sk_buff *skb,
2502 const struct net_device *dev, 2502 netdev_features_t features)
2503 netdev_features_t features)
2504{ 2503{
2505 int tmp; 2504 int tmp;
2506 2505
2507 if (skb->ip_summed != CHECKSUM_NONE && 2506 if (skb->ip_summed != CHECKSUM_NONE &&
2508 !can_checksum_protocol(features, skb_network_protocol(skb, &tmp))) { 2507 !can_checksum_protocol(features, skb_network_protocol(skb, &tmp))) {
2509 features &= ~NETIF_F_ALL_CSUM; 2508 features &= ~NETIF_F_ALL_CSUM;
2510 } else if (illegal_highdma(dev, skb)) { 2509 } else if (illegal_highdma(skb->dev, skb)) {
2511 features &= ~NETIF_F_SG; 2510 features &= ~NETIF_F_SG;
2512 } 2511 }
2513 2512
2514 return features; 2513 return features;
2515} 2514}
2516 2515
2517netdev_features_t netif_skb_dev_features(struct sk_buff *skb, 2516netdev_features_t netif_skb_features(struct sk_buff *skb)
2518 const struct net_device *dev)
2519{ 2517{
2520 __be16 protocol = skb->protocol; 2518 __be16 protocol = skb->protocol;
2521 netdev_features_t features = dev->features; 2519 netdev_features_t features = skb->dev->features;
2522 2520
2523 if (skb_shinfo(skb)->gso_segs > dev->gso_max_segs) 2521 if (skb_shinfo(skb)->gso_segs > skb->dev->gso_max_segs)
2524 features &= ~NETIF_F_GSO_MASK; 2522 features &= ~NETIF_F_GSO_MASK;
2525 2523
2526 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { 2524 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) {
2527 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2525 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
2528 protocol = veh->h_vlan_encapsulated_proto; 2526 protocol = veh->h_vlan_encapsulated_proto;
2529 } else if (!vlan_tx_tag_present(skb)) { 2527 } else if (!vlan_tx_tag_present(skb)) {
2530 return harmonize_features(skb, dev, features); 2528 return harmonize_features(skb, features);
2531 } 2529 }
2532 2530
2533 features &= (dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | 2531 features &= (skb->dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX |
2534 NETIF_F_HW_VLAN_STAG_TX); 2532 NETIF_F_HW_VLAN_STAG_TX);
2535 2533
2536 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) 2534 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD))
@@ -2538,9 +2536,9 @@ netdev_features_t netif_skb_dev_features(struct sk_buff *skb,
2538 NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | 2536 NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX |
2539 NETIF_F_HW_VLAN_STAG_TX; 2537 NETIF_F_HW_VLAN_STAG_TX;
2540 2538
2541 return harmonize_features(skb, dev, features); 2539 return harmonize_features(skb, features);
2542} 2540}
2543EXPORT_SYMBOL(netif_skb_dev_features); 2541EXPORT_SYMBOL(netif_skb_features);
2544 2542
2545int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2543int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2546 struct netdev_queue *txq) 2544 struct netdev_queue *txq)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d4ff41739b0f..9837bebf93ce 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -774,7 +774,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
774 return 0; 774 return 0;
775} 775}
776 776
777static size_t rtnl_port_size(const struct net_device *dev) 777static size_t rtnl_port_size(const struct net_device *dev,
778 u32 ext_filter_mask)
778{ 779{
779 size_t port_size = nla_total_size(4) /* PORT_VF */ 780 size_t port_size = nla_total_size(4) /* PORT_VF */
780 + nla_total_size(PORT_PROFILE_MAX) /* PORT_PROFILE */ 781 + nla_total_size(PORT_PROFILE_MAX) /* PORT_PROFILE */
@@ -790,7 +791,8 @@ static size_t rtnl_port_size(const struct net_device *dev)
790 size_t port_self_size = nla_total_size(sizeof(struct nlattr)) 791 size_t port_self_size = nla_total_size(sizeof(struct nlattr))
791 + port_size; 792 + port_size;
792 793
793 if (!dev->netdev_ops->ndo_get_vf_port || !dev->dev.parent) 794 if (!dev->netdev_ops->ndo_get_vf_port || !dev->dev.parent ||
795 !(ext_filter_mask & RTEXT_FILTER_VF))
794 return 0; 796 return 0;
795 if (dev_num_vf(dev->dev.parent)) 797 if (dev_num_vf(dev->dev.parent))
796 return port_self_size + vf_ports_size + 798 return port_self_size + vf_ports_size +
@@ -826,7 +828,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
826 + nla_total_size(ext_filter_mask 828 + nla_total_size(ext_filter_mask
827 & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */ 829 & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */
828 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */ 830 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
829 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ 831 + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
830 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ 832 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
831 + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */ 833 + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
832 + nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */ 834 + nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */
@@ -888,11 +890,13 @@ static int rtnl_port_self_fill(struct sk_buff *skb, struct net_device *dev)
888 return 0; 890 return 0;
889} 891}
890 892
891static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev) 893static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev,
894 u32 ext_filter_mask)
892{ 895{
893 int err; 896 int err;
894 897
895 if (!dev->netdev_ops->ndo_get_vf_port || !dev->dev.parent) 898 if (!dev->netdev_ops->ndo_get_vf_port || !dev->dev.parent ||
899 !(ext_filter_mask & RTEXT_FILTER_VF))
896 return 0; 900 return 0;
897 901
898 err = rtnl_port_self_fill(skb, dev); 902 err = rtnl_port_self_fill(skb, dev);
@@ -1079,7 +1083,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
1079 nla_nest_end(skb, vfinfo); 1083 nla_nest_end(skb, vfinfo);
1080 } 1084 }
1081 1085
1082 if (rtnl_port_fill(skb, dev)) 1086 if (rtnl_port_fill(skb, dev, ext_filter_mask))
1083 goto nla_put_failure; 1087 goto nla_put_failure;
1084 1088
1085 if (dev->rtnl_link_ops || rtnl_have_link_slave_info(dev)) { 1089 if (dev->rtnl_link_ops || rtnl_have_link_slave_info(dev)) {
@@ -1198,6 +1202,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1198 struct hlist_head *head; 1202 struct hlist_head *head;
1199 struct nlattr *tb[IFLA_MAX+1]; 1203 struct nlattr *tb[IFLA_MAX+1];
1200 u32 ext_filter_mask = 0; 1204 u32 ext_filter_mask = 0;
1205 int err;
1201 1206
1202 s_h = cb->args[0]; 1207 s_h = cb->args[0];
1203 s_idx = cb->args[1]; 1208 s_idx = cb->args[1];
@@ -1218,11 +1223,17 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
1218 hlist_for_each_entry_rcu(dev, head, index_hlist) { 1223 hlist_for_each_entry_rcu(dev, head, index_hlist) {
1219 if (idx < s_idx) 1224 if (idx < s_idx)
1220 goto cont; 1225 goto cont;
1221 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK, 1226 err = rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
1222 NETLINK_CB(cb->skb).portid, 1227 NETLINK_CB(cb->skb).portid,
1223 cb->nlh->nlmsg_seq, 0, 1228 cb->nlh->nlmsg_seq, 0,
1224 NLM_F_MULTI, 1229 NLM_F_MULTI,
1225 ext_filter_mask) <= 0) 1230 ext_filter_mask);
1231 /* If we ran out of room on the first message,
1232 * we're in trouble
1233 */
1234 WARN_ON((err == -EMSGSIZE) && (skb->len == 0));
1235
1236 if (err <= 0)
1226 goto out; 1237 goto out;
1227 1238
1228 nl_dump_check_consistent(cb, nlmsg_hdr(skb)); 1239 nl_dump_check_consistent(cb, nlmsg_hdr(skb));
@@ -1395,7 +1406,8 @@ static int do_set_master(struct net_device *dev, int ifindex)
1395 return 0; 1406 return 0;
1396} 1407}
1397 1408
1398static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, 1409static int do_setlink(const struct sk_buff *skb,
1410 struct net_device *dev, struct ifinfomsg *ifm,
1399 struct nlattr **tb, char *ifname, int modified) 1411 struct nlattr **tb, char *ifname, int modified)
1400{ 1412{
1401 const struct net_device_ops *ops = dev->netdev_ops; 1413 const struct net_device_ops *ops = dev->netdev_ops;
@@ -1407,7 +1419,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
1407 err = PTR_ERR(net); 1419 err = PTR_ERR(net);
1408 goto errout; 1420 goto errout;
1409 } 1421 }
1410 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) { 1422 if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) {
1411 err = -EPERM; 1423 err = -EPERM;
1412 goto errout; 1424 goto errout;
1413 } 1425 }
@@ -1661,7 +1673,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
1661 if (err < 0) 1673 if (err < 0)
1662 goto errout; 1674 goto errout;
1663 1675
1664 err = do_setlink(dev, ifm, tb, ifname, 0); 1676 err = do_setlink(skb, dev, ifm, tb, ifname, 0);
1665errout: 1677errout:
1666 return err; 1678 return err;
1667} 1679}
@@ -1778,7 +1790,8 @@ err:
1778} 1790}
1779EXPORT_SYMBOL(rtnl_create_link); 1791EXPORT_SYMBOL(rtnl_create_link);
1780 1792
1781static int rtnl_group_changelink(struct net *net, int group, 1793static int rtnl_group_changelink(const struct sk_buff *skb,
1794 struct net *net, int group,
1782 struct ifinfomsg *ifm, 1795 struct ifinfomsg *ifm,
1783 struct nlattr **tb) 1796 struct nlattr **tb)
1784{ 1797{
@@ -1787,7 +1800,7 @@ static int rtnl_group_changelink(struct net *net, int group,
1787 1800
1788 for_each_netdev(net, dev) { 1801 for_each_netdev(net, dev) {
1789 if (dev->group == group) { 1802 if (dev->group == group) {
1790 err = do_setlink(dev, ifm, tb, NULL, 0); 1803 err = do_setlink(skb, dev, ifm, tb, NULL, 0);
1791 if (err < 0) 1804 if (err < 0)
1792 return err; 1805 return err;
1793 } 1806 }
@@ -1929,12 +1942,12 @@ replay:
1929 modified = 1; 1942 modified = 1;
1930 } 1943 }
1931 1944
1932 return do_setlink(dev, ifm, tb, ifname, modified); 1945 return do_setlink(skb, dev, ifm, tb, ifname, modified);
1933 } 1946 }
1934 1947
1935 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) { 1948 if (!(nlh->nlmsg_flags & NLM_F_CREATE)) {
1936 if (ifm->ifi_index == 0 && tb[IFLA_GROUP]) 1949 if (ifm->ifi_index == 0 && tb[IFLA_GROUP])
1937 return rtnl_group_changelink(net, 1950 return rtnl_group_changelink(skb, net,
1938 nla_get_u32(tb[IFLA_GROUP]), 1951 nla_get_u32(tb[IFLA_GROUP]),
1939 ifm, tb); 1952 ifm, tb);
1940 return -ENODEV; 1953 return -ENODEV;
@@ -2321,7 +2334,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh)
2321 int err = -EINVAL; 2334 int err = -EINVAL;
2322 __u8 *addr; 2335 __u8 *addr;
2323 2336
2324 if (!capable(CAP_NET_ADMIN)) 2337 if (!netlink_capable(skb, CAP_NET_ADMIN))
2325 return -EPERM; 2338 return -EPERM;
2326 2339
2327 err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL); 2340 err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL);
@@ -2773,7 +2786,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
2773 sz_idx = type>>2; 2786 sz_idx = type>>2;
2774 kind = type&3; 2787 kind = type&3;
2775 2788
2776 if (kind != 2 && !ns_capable(net->user_ns, CAP_NET_ADMIN)) 2789 if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
2777 return -EPERM; 2790 return -EPERM;
2778 2791
2779 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) { 2792 if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
diff --git a/net/core/sock.c b/net/core/sock.c
index b4fff008136f..664ee4295b6f 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -145,6 +145,55 @@
145static DEFINE_MUTEX(proto_list_mutex); 145static DEFINE_MUTEX(proto_list_mutex);
146static LIST_HEAD(proto_list); 146static LIST_HEAD(proto_list);
147 147
148/**
149 * sk_ns_capable - General socket capability test
150 * @sk: Socket to use a capability on or through
151 * @user_ns: The user namespace of the capability to use
152 * @cap: The capability to use
153 *
154 * Test to see if the opener of the socket had when the socket was
155 * created and the current process has the capability @cap in the user
156 * namespace @user_ns.
157 */
158bool sk_ns_capable(const struct sock *sk,
159 struct user_namespace *user_ns, int cap)
160{
161 return file_ns_capable(sk->sk_socket->file, user_ns, cap) &&
162 ns_capable(user_ns, cap);
163}
164EXPORT_SYMBOL(sk_ns_capable);
165
166/**
167 * sk_capable - Socket global capability test
168 * @sk: Socket to use a capability on or through
169 * @cap: The global capbility to use
170 *
171 * Test to see if the opener of the socket had when the socket was
172 * created and the current process has the capability @cap in all user
173 * namespaces.
174 */
175bool sk_capable(const struct sock *sk, int cap)
176{
177 return sk_ns_capable(sk, &init_user_ns, cap);
178}
179EXPORT_SYMBOL(sk_capable);
180
181/**
182 * sk_net_capable - Network namespace socket capability test
183 * @sk: Socket to use a capability on or through
184 * @cap: The capability to use
185 *
186 * Test to see if the opener of the socket had when the socke was created
187 * and the current process has the capability @cap over the network namespace
188 * the socket is a member of.
189 */
190bool sk_net_capable(const struct sock *sk, int cap)
191{
192 return sk_ns_capable(sk, sock_net(sk)->user_ns, cap);
193}
194EXPORT_SYMBOL(sk_net_capable);
195
196
148#ifdef CONFIG_MEMCG_KMEM 197#ifdef CONFIG_MEMCG_KMEM
149int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss) 198int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
150{ 199{
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index 9deb6abd6cf6..a4216a4c9572 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -49,7 +49,7 @@ int sock_diag_put_meminfo(struct sock *sk, struct sk_buff *skb, int attrtype)
49} 49}
50EXPORT_SYMBOL_GPL(sock_diag_put_meminfo); 50EXPORT_SYMBOL_GPL(sock_diag_put_meminfo);
51 51
52int sock_diag_put_filterinfo(struct sock *sk, 52int sock_diag_put_filterinfo(bool may_report_filterinfo, struct sock *sk,
53 struct sk_buff *skb, int attrtype) 53 struct sk_buff *skb, int attrtype)
54{ 54{
55 struct sock_fprog_kern *fprog; 55 struct sock_fprog_kern *fprog;
@@ -58,7 +58,7 @@ int sock_diag_put_filterinfo(struct sock *sk,
58 unsigned int flen; 58 unsigned int flen;
59 int err = 0; 59 int err = 0;
60 60
61 if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) { 61 if (!may_report_filterinfo) {
62 nla_reserve(skb, attrtype, 0); 62 nla_reserve(skb, attrtype, 0);
63 return 0; 63 return 0;
64 } 64 }
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 553644402670..f8b98d89c285 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1669,7 +1669,7 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
1669 struct nlmsghdr *reply_nlh = NULL; 1669 struct nlmsghdr *reply_nlh = NULL;
1670 const struct reply_func *fn; 1670 const struct reply_func *fn;
1671 1671
1672 if ((nlh->nlmsg_type == RTM_SETDCB) && !capable(CAP_NET_ADMIN)) 1672 if ((nlh->nlmsg_type == RTM_SETDCB) && !netlink_capable(skb, CAP_NET_ADMIN))
1673 return -EPERM; 1673 return -EPERM;
1674 1674
1675 ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX, 1675 ret = nlmsg_parse(nlh, sizeof(*dcb), tb, DCB_ATTR_MAX,
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index a603823a3e27..3b726f31c64c 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -574,7 +574,7 @@ static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
574 struct dn_ifaddr __rcu **ifap; 574 struct dn_ifaddr __rcu **ifap;
575 int err = -EINVAL; 575 int err = -EINVAL;
576 576
577 if (!capable(CAP_NET_ADMIN)) 577 if (!netlink_capable(skb, CAP_NET_ADMIN))
578 return -EPERM; 578 return -EPERM;
579 579
580 if (!net_eq(net, &init_net)) 580 if (!net_eq(net, &init_net))
@@ -618,7 +618,7 @@ static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh)
618 struct dn_ifaddr *ifa; 618 struct dn_ifaddr *ifa;
619 int err; 619 int err;
620 620
621 if (!capable(CAP_NET_ADMIN)) 621 if (!netlink_capable(skb, CAP_NET_ADMIN))
622 return -EPERM; 622 return -EPERM;
623 623
624 if (!net_eq(net, &init_net)) 624 if (!net_eq(net, &init_net))
diff --git a/net/decnet/dn_fib.c b/net/decnet/dn_fib.c
index 57dc159245ec..d332aefb0846 100644
--- a/net/decnet/dn_fib.c
+++ b/net/decnet/dn_fib.c
@@ -505,7 +505,7 @@ static int dn_fib_rtm_delroute(struct sk_buff *skb, struct nlmsghdr *nlh)
505 struct nlattr *attrs[RTA_MAX+1]; 505 struct nlattr *attrs[RTA_MAX+1];
506 int err; 506 int err;
507 507
508 if (!capable(CAP_NET_ADMIN)) 508 if (!netlink_capable(skb, CAP_NET_ADMIN))
509 return -EPERM; 509 return -EPERM;
510 510
511 if (!net_eq(net, &init_net)) 511 if (!net_eq(net, &init_net))
@@ -530,7 +530,7 @@ static int dn_fib_rtm_newroute(struct sk_buff *skb, struct nlmsghdr *nlh)
530 struct nlattr *attrs[RTA_MAX+1]; 530 struct nlattr *attrs[RTA_MAX+1];
531 int err; 531 int err;
532 532
533 if (!capable(CAP_NET_ADMIN)) 533 if (!netlink_capable(skb, CAP_NET_ADMIN))
534 return -EPERM; 534 return -EPERM;
535 535
536 if (!net_eq(net, &init_net)) 536 if (!net_eq(net, &init_net))
diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
index e83015cecfa7..e4d9560a910b 100644
--- a/net/decnet/netfilter/dn_rtmsg.c
+++ b/net/decnet/netfilter/dn_rtmsg.c
@@ -107,7 +107,7 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
107 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len) 107 if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
108 return; 108 return;
109 109
110 if (!capable(CAP_NET_ADMIN)) 110 if (!netlink_capable(skb, CAP_NET_ADMIN))
111 RCV_SKB_FAIL(-EPERM); 111 RCV_SKB_FAIL(-EPERM);
112 112
113 /* Eventually we might send routing messages too */ 113 /* Eventually we might send routing messages too */
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 6765d91b8e75..211c0cc6c3d3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1619,6 +1619,39 @@ static int __init init_ipv4_mibs(void)
1619 return register_pernet_subsys(&ipv4_mib_ops); 1619 return register_pernet_subsys(&ipv4_mib_ops);
1620} 1620}
1621 1621
1622static __net_init int inet_init_net(struct net *net)
1623{
1624 /*
1625 * Set defaults for local port range
1626 */
1627 seqlock_init(&net->ipv4.ip_local_ports.lock);
1628 net->ipv4.ip_local_ports.range[0] = 32768;
1629 net->ipv4.ip_local_ports.range[1] = 61000;
1630
1631 seqlock_init(&net->ipv4.ping_group_range.lock);
1632 /*
1633 * Sane defaults - nobody may create ping sockets.
1634 * Boot scripts should set this to distro-specific group.
1635 */
1636 net->ipv4.ping_group_range.range[0] = make_kgid(&init_user_ns, 1);
1637 net->ipv4.ping_group_range.range[1] = make_kgid(&init_user_ns, 0);
1638 return 0;
1639}
1640
1641static __net_exit void inet_exit_net(struct net *net)
1642{
1643}
1644
1645static __net_initdata struct pernet_operations af_inet_ops = {
1646 .init = inet_init_net,
1647 .exit = inet_exit_net,
1648};
1649
1650static int __init init_inet_pernet_ops(void)
1651{
1652 return register_pernet_subsys(&af_inet_ops);
1653}
1654
1622static int ipv4_proc_init(void); 1655static int ipv4_proc_init(void);
1623 1656
1624/* 1657/*
@@ -1763,6 +1796,9 @@ static int __init inet_init(void)
1763 if (ip_mr_init()) 1796 if (ip_mr_init())
1764 pr_crit("%s: Cannot init ipv4 mroute\n", __func__); 1797 pr_crit("%s: Cannot init ipv4 mroute\n", __func__);
1765#endif 1798#endif
1799
1800 if (init_inet_pernet_ops())
1801 pr_crit("%s: Cannot init ipv4 inet pernet ops\n", __func__);
1766 /* 1802 /*
1767 * Initialise per-cpu ipv4 mibs 1803 * Initialise per-cpu ipv4 mibs
1768 */ 1804 */
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 8a043f03c88e..b10cd43a4722 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -821,13 +821,13 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
821 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); 821 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
822 if (fi == NULL) 822 if (fi == NULL)
823 goto failure; 823 goto failure;
824 fib_info_cnt++;
824 if (cfg->fc_mx) { 825 if (cfg->fc_mx) {
825 fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL); 826 fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
826 if (!fi->fib_metrics) 827 if (!fi->fib_metrics)
827 goto failure; 828 goto failure;
828 } else 829 } else
829 fi->fib_metrics = (u32 *) dst_default_metrics; 830 fi->fib_metrics = (u32 *) dst_default_metrics;
830 fib_info_cnt++;
831 831
832 fi->fib_net = hold_net(net); 832 fi->fib_net = hold_net(net);
833 fi->fib_protocol = cfg->fc_protocol; 833 fi->fib_protocol = cfg->fc_protocol;
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 0d1e2cb877ec..a56b8e6e866a 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -37,11 +37,11 @@ void inet_get_local_port_range(struct net *net, int *low, int *high)
37 unsigned int seq; 37 unsigned int seq;
38 38
39 do { 39 do {
40 seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 40 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
41 41
42 *low = net->ipv4.sysctl_local_ports.range[0]; 42 *low = net->ipv4.ip_local_ports.range[0];
43 *high = net->ipv4.sysctl_local_ports.range[1]; 43 *high = net->ipv4.ip_local_ports.range[1];
44 } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 44 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
45} 45}
46EXPORT_SYMBOL(inet_get_local_port_range); 46EXPORT_SYMBOL(inet_get_local_port_range);
47 47
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index be8abe73bb9f..6f111e48e11c 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -42,12 +42,12 @@
42static bool ip_may_fragment(const struct sk_buff *skb) 42static bool ip_may_fragment(const struct sk_buff *skb)
43{ 43{
44 return unlikely((ip_hdr(skb)->frag_off & htons(IP_DF)) == 0) || 44 return unlikely((ip_hdr(skb)->frag_off & htons(IP_DF)) == 0) ||
45 !skb->local_df; 45 skb->local_df;
46} 46}
47 47
48static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu) 48static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
49{ 49{
50 if (skb->len <= mtu || skb->local_df) 50 if (skb->len <= mtu)
51 return false; 51 return false;
52 52
53 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu) 53 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu)
@@ -56,53 +56,6 @@ static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
56 return true; 56 return true;
57} 57}
58 58
59static bool ip_gso_exceeds_dst_mtu(const struct sk_buff *skb)
60{
61 unsigned int mtu;
62
63 if (skb->local_df || !skb_is_gso(skb))
64 return false;
65
66 mtu = ip_dst_mtu_maybe_forward(skb_dst(skb), true);
67
68 /* if seglen > mtu, do software segmentation for IP fragmentation on
69 * output. DF bit cannot be set since ip_forward would have sent
70 * icmp error.
71 */
72 return skb_gso_network_seglen(skb) > mtu;
73}
74
75/* called if GSO skb needs to be fragmented on forward */
76static int ip_forward_finish_gso(struct sk_buff *skb)
77{
78 struct dst_entry *dst = skb_dst(skb);
79 netdev_features_t features;
80 struct sk_buff *segs;
81 int ret = 0;
82
83 features = netif_skb_dev_features(skb, dst->dev);
84 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
85 if (IS_ERR(segs)) {
86 kfree_skb(skb);
87 return -ENOMEM;
88 }
89
90 consume_skb(skb);
91
92 do {
93 struct sk_buff *nskb = segs->next;
94 int err;
95
96 segs->next = NULL;
97 err = dst_output(segs);
98
99 if (err && ret == 0)
100 ret = err;
101 segs = nskb;
102 } while (segs);
103
104 return ret;
105}
106 59
107static int ip_forward_finish(struct sk_buff *skb) 60static int ip_forward_finish(struct sk_buff *skb)
108{ 61{
@@ -114,9 +67,6 @@ static int ip_forward_finish(struct sk_buff *skb)
114 if (unlikely(opt->optlen)) 67 if (unlikely(opt->optlen))
115 ip_forward_options(skb); 68 ip_forward_options(skb);
116 69
117 if (ip_gso_exceeds_dst_mtu(skb))
118 return ip_forward_finish_gso(skb);
119
120 return dst_output(skb); 70 return dst_output(skb);
121} 71}
122 72
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index c10a3ce5cbff..ed32313e307c 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -232,8 +232,9 @@ static void ip_expire(unsigned long arg)
232 * "Fragment Reassembly Timeout" message, per RFC792. 232 * "Fragment Reassembly Timeout" message, per RFC792.
233 */ 233 */
234 if (qp->user == IP_DEFRAG_AF_PACKET || 234 if (qp->user == IP_DEFRAG_AF_PACKET ||
235 (qp->user == IP_DEFRAG_CONNTRACK_IN && 235 ((qp->user >= IP_DEFRAG_CONNTRACK_IN) &&
236 skb_rtable(head)->rt_type != RTN_LOCAL)) 236 (qp->user <= __IP_DEFRAG_CONNTRACK_IN_END) &&
237 (skb_rtable(head)->rt_type != RTN_LOCAL)))
237 goto out_rcu_unlock; 238 goto out_rcu_unlock;
238 239
239 240
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1cbeba5edff9..a52f50187b54 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -211,6 +211,48 @@ static inline int ip_finish_output2(struct sk_buff *skb)
211 return -EINVAL; 211 return -EINVAL;
212} 212}
213 213
214static int ip_finish_output_gso(struct sk_buff *skb)
215{
216 netdev_features_t features;
217 struct sk_buff *segs;
218 int ret = 0;
219
220 /* common case: locally created skb or seglen is <= mtu */
221 if (((IPCB(skb)->flags & IPSKB_FORWARDED) == 0) ||
222 skb_gso_network_seglen(skb) <= ip_skb_dst_mtu(skb))
223 return ip_finish_output2(skb);
224
225 /* Slowpath - GSO segment length is exceeding the dst MTU.
226 *
227 * This can happen in two cases:
228 * 1) TCP GRO packet, DF bit not set
229 * 2) skb arrived via virtio-net, we thus get TSO/GSO skbs directly
230 * from host network stack.
231 */
232 features = netif_skb_features(skb);
233 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
234 if (IS_ERR(segs)) {
235 kfree_skb(skb);
236 return -ENOMEM;
237 }
238
239 consume_skb(skb);
240
241 do {
242 struct sk_buff *nskb = segs->next;
243 int err;
244
245 segs->next = NULL;
246 err = ip_fragment(segs, ip_finish_output2);
247
248 if (err && ret == 0)
249 ret = err;
250 segs = nskb;
251 } while (segs);
252
253 return ret;
254}
255
214static int ip_finish_output(struct sk_buff *skb) 256static int ip_finish_output(struct sk_buff *skb)
215{ 257{
216#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) 258#if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM)
@@ -220,10 +262,13 @@ static int ip_finish_output(struct sk_buff *skb)
220 return dst_output(skb); 262 return dst_output(skb);
221 } 263 }
222#endif 264#endif
223 if (skb->len > ip_skb_dst_mtu(skb) && !skb_is_gso(skb)) 265 if (skb_is_gso(skb))
266 return ip_finish_output_gso(skb);
267
268 if (skb->len > ip_skb_dst_mtu(skb))
224 return ip_fragment(skb, ip_finish_output2); 269 return ip_fragment(skb, ip_finish_output2);
225 else 270
226 return ip_finish_output2(skb); 271 return ip_finish_output2(skb);
227} 272}
228 273
229int ip_mc_output(struct sock *sk, struct sk_buff *skb) 274int ip_mc_output(struct sock *sk, struct sk_buff *skb)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index fa5b7519765f..b3f859731c60 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -442,6 +442,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
442 tunnel->i_seqno = ntohl(tpi->seq) + 1; 442 tunnel->i_seqno = ntohl(tpi->seq) + 1;
443 } 443 }
444 444
445 skb_reset_network_header(skb);
446
445 err = IP_ECN_decapsulate(iph, skb); 447 err = IP_ECN_decapsulate(iph, skb);
446 if (unlikely(err)) { 448 if (unlikely(err)) {
447 if (log_ecn_error) 449 if (log_ecn_error)
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index 12e13bd82b5b..f40f321b41fc 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -22,7 +22,6 @@
22#endif 22#endif
23#include <net/netfilter/nf_conntrack_zones.h> 23#include <net/netfilter/nf_conntrack_zones.h>
24 24
25/* Returns new sk_buff, or NULL */
26static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user) 25static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
27{ 26{
28 int err; 27 int err;
@@ -33,8 +32,10 @@ static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
33 err = ip_defrag(skb, user); 32 err = ip_defrag(skb, user);
34 local_bh_enable(); 33 local_bh_enable();
35 34
36 if (!err) 35 if (!err) {
37 ip_send_check(ip_hdr(skb)); 36 ip_send_check(ip_hdr(skb));
37 skb->local_df = 1;
38 }
38 39
39 return err; 40 return err;
40} 41}
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 8210964a9f19..044a0ddf6a79 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -236,15 +236,15 @@ exit:
236static void inet_get_ping_group_range_net(struct net *net, kgid_t *low, 236static void inet_get_ping_group_range_net(struct net *net, kgid_t *low,
237 kgid_t *high) 237 kgid_t *high)
238{ 238{
239 kgid_t *data = net->ipv4.sysctl_ping_group_range; 239 kgid_t *data = net->ipv4.ping_group_range.range;
240 unsigned int seq; 240 unsigned int seq;
241 241
242 do { 242 do {
243 seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 243 seq = read_seqbegin(&net->ipv4.ping_group_range.lock);
244 244
245 *low = data[0]; 245 *low = data[0];
246 *high = data[1]; 246 *high = data[1];
247 } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 247 } while (read_seqretry(&net->ipv4.ping_group_range.lock, seq));
248} 248}
249 249
250 250
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 44eba052b43d..5cde8f263d40 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -45,10 +45,10 @@ static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
45/* Update system visible IP port range */ 45/* Update system visible IP port range */
46static void set_local_port_range(struct net *net, int range[2]) 46static void set_local_port_range(struct net *net, int range[2])
47{ 47{
48 write_seqlock(&net->ipv4.sysctl_local_ports.lock); 48 write_seqlock(&net->ipv4.ip_local_ports.lock);
49 net->ipv4.sysctl_local_ports.range[0] = range[0]; 49 net->ipv4.ip_local_ports.range[0] = range[0];
50 net->ipv4.sysctl_local_ports.range[1] = range[1]; 50 net->ipv4.ip_local_ports.range[1] = range[1];
51 write_sequnlock(&net->ipv4.sysctl_local_ports.lock); 51 write_sequnlock(&net->ipv4.ip_local_ports.lock);
52} 52}
53 53
54/* Validate changes from /proc interface. */ 54/* Validate changes from /proc interface. */
@@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
57 size_t *lenp, loff_t *ppos) 57 size_t *lenp, loff_t *ppos)
58{ 58{
59 struct net *net = 59 struct net *net =
60 container_of(table->data, struct net, ipv4.sysctl_local_ports.range); 60 container_of(table->data, struct net, ipv4.ip_local_ports.range);
61 int ret; 61 int ret;
62 int range[2]; 62 int range[2];
63 struct ctl_table tmp = { 63 struct ctl_table tmp = {
@@ -87,14 +87,14 @@ static void inet_get_ping_group_range_table(struct ctl_table *table, kgid_t *low
87{ 87{
88 kgid_t *data = table->data; 88 kgid_t *data = table->data;
89 struct net *net = 89 struct net *net =
90 container_of(table->data, struct net, ipv4.sysctl_ping_group_range); 90 container_of(table->data, struct net, ipv4.ping_group_range.range);
91 unsigned int seq; 91 unsigned int seq;
92 do { 92 do {
93 seq = read_seqbegin(&net->ipv4.sysctl_local_ports.lock); 93 seq = read_seqbegin(&net->ipv4.ip_local_ports.lock);
94 94
95 *low = data[0]; 95 *low = data[0];
96 *high = data[1]; 96 *high = data[1];
97 } while (read_seqretry(&net->ipv4.sysctl_local_ports.lock, seq)); 97 } while (read_seqretry(&net->ipv4.ip_local_ports.lock, seq));
98} 98}
99 99
100/* Update system visible IP port range */ 100/* Update system visible IP port range */
@@ -102,11 +102,11 @@ static void set_ping_group_range(struct ctl_table *table, kgid_t low, kgid_t hig
102{ 102{
103 kgid_t *data = table->data; 103 kgid_t *data = table->data;
104 struct net *net = 104 struct net *net =
105 container_of(table->data, struct net, ipv4.sysctl_ping_group_range); 105 container_of(table->data, struct net, ipv4.ping_group_range.range);
106 write_seqlock(&net->ipv4.sysctl_local_ports.lock); 106 write_seqlock(&net->ipv4.ip_local_ports.lock);
107 data[0] = low; 107 data[0] = low;
108 data[1] = high; 108 data[1] = high;
109 write_sequnlock(&net->ipv4.sysctl_local_ports.lock); 109 write_sequnlock(&net->ipv4.ip_local_ports.lock);
110} 110}
111 111
112/* Validate changes from /proc interface. */ 112/* Validate changes from /proc interface. */
@@ -805,7 +805,7 @@ static struct ctl_table ipv4_net_table[] = {
805 }, 805 },
806 { 806 {
807 .procname = "ping_group_range", 807 .procname = "ping_group_range",
808 .data = &init_net.ipv4.sysctl_ping_group_range, 808 .data = &init_net.ipv4.ping_group_range.range,
809 .maxlen = sizeof(gid_t)*2, 809 .maxlen = sizeof(gid_t)*2,
810 .mode = 0644, 810 .mode = 0644,
811 .proc_handler = ipv4_ping_group_range, 811 .proc_handler = ipv4_ping_group_range,
@@ -819,8 +819,8 @@ static struct ctl_table ipv4_net_table[] = {
819 }, 819 },
820 { 820 {
821 .procname = "ip_local_port_range", 821 .procname = "ip_local_port_range",
822 .maxlen = sizeof(init_net.ipv4.sysctl_local_ports.range), 822 .maxlen = sizeof(init_net.ipv4.ip_local_ports.range),
823 .data = &init_net.ipv4.sysctl_local_ports.range, 823 .data = &init_net.ipv4.ip_local_ports.range,
824 .mode = 0644, 824 .mode = 0644,
825 .proc_handler = ipv4_local_port_range, 825 .proc_handler = ipv4_local_port_range,
826 }, 826 },
@@ -858,20 +858,6 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
858 table[i].data += (void *)net - (void *)&init_net; 858 table[i].data += (void *)net - (void *)&init_net;
859 } 859 }
860 860
861 /*
862 * Sane defaults - nobody may create ping sockets.
863 * Boot scripts should set this to distro-specific group.
864 */
865 net->ipv4.sysctl_ping_group_range[0] = make_kgid(&init_user_ns, 1);
866 net->ipv4.sysctl_ping_group_range[1] = make_kgid(&init_user_ns, 0);
867
868 /*
869 * Set defaults for local port range
870 */
871 seqlock_init(&net->ipv4.sysctl_local_ports.lock);
872 net->ipv4.sysctl_local_ports.range[0] = 32768;
873 net->ipv4.sysctl_local_ports.range[1] = 61000;
874
875 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); 861 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
876 if (net->ipv4.ipv4_hdr == NULL) 862 if (net->ipv4.ipv4_hdr == NULL)
877 goto err_reg; 863 goto err_reg;
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index ba2a4f3a6a1e..a9bd8a4828a9 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -408,7 +408,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
408 ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT; 408 ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT;
409 ratio += cnt; 409 ratio += cnt;
410 410
411 ca->delayed_ack = min(ratio, ACK_RATIO_LIMIT); 411 ca->delayed_ack = clamp(ratio, 1U, ACK_RATIO_LIMIT);
412 } 412 }
413 413
414 /* Some calls are for duplicates without timetamps */ 414 /* Some calls are for duplicates without timetamps */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 89277a34f2c9..694711a140d4 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2488,8 +2488,14 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2488 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); 2488 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
2489 } 2489 }
2490 2490
2491 if (likely(!err)) 2491 if (likely(!err)) {
2492 TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS; 2492 TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS;
2493 /* Update global TCP statistics. */
2494 TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
2495 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
2496 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
2497 tp->total_retrans++;
2498 }
2493 return err; 2499 return err;
2494} 2500}
2495 2501
@@ -2499,12 +2505,6 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2499 int err = __tcp_retransmit_skb(sk, skb); 2505 int err = __tcp_retransmit_skb(sk, skb);
2500 2506
2501 if (err == 0) { 2507 if (err == 0) {
2502 /* Update global TCP statistics. */
2503 TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
2504 if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
2505 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
2506 tp->total_retrans++;
2507
2508#if FASTRETRANS_DEBUG > 0 2508#if FASTRETRANS_DEBUG > 0
2509 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) { 2509 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) {
2510 net_dbg_ratelimited("retrans_out leaked\n"); 2510 net_dbg_ratelimited("retrans_out leaked\n");
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 6fefd44abbf5..cb4459bd1d29 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1458,7 +1458,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
1458 1458
1459 if (w->skip) { 1459 if (w->skip) {
1460 w->skip--; 1460 w->skip--;
1461 continue; 1461 goto skip;
1462 } 1462 }
1463 1463
1464 err = w->func(w); 1464 err = w->func(w);
@@ -1468,6 +1468,7 @@ static int fib6_walk_continue(struct fib6_walker_t *w)
1468 w->count++; 1468 w->count++;
1469 continue; 1469 continue;
1470 } 1470 }
1471skip:
1471 w->state = FWS_U; 1472 w->state = FWS_U;
1472 case FWS_U: 1473 case FWS_U:
1473 if (fn == w->root) 1474 if (fn == w->root)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 40e7581374f7..31a38bde69ef 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -344,12 +344,16 @@ static unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
344 344
345static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu) 345static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
346{ 346{
347 if (skb->len <= mtu || skb->local_df) 347 if (skb->len <= mtu)
348 return false; 348 return false;
349 349
350 /* ipv6 conntrack defrag sets max_frag_size + local_df */
350 if (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu) 351 if (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu)
351 return true; 352 return true;
352 353
354 if (skb->local_df)
355 return false;
356
353 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu) 357 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu)
354 return false; 358 return false;
355 359
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 8659067da28e..8250474ab7dc 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1633,7 +1633,7 @@ struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
1633{ 1633{
1634 struct mr6_table *mrt; 1634 struct mr6_table *mrt;
1635 struct flowi6 fl6 = { 1635 struct flowi6 fl6 = {
1636 .flowi6_iif = skb->skb_iif, 1636 .flowi6_iif = skb->skb_iif ? : LOOPBACK_IFINDEX,
1637 .flowi6_oif = skb->dev->ifindex, 1637 .flowi6_oif = skb->dev->ifindex,
1638 .flowi6_mark = skb->mark, 1638 .flowi6_mark = skb->mark,
1639 }; 1639 };
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index 95f3f1da0d7f..d38e6a8d8b9f 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -30,13 +30,15 @@ int ip6_route_me_harder(struct sk_buff *skb)
30 .daddr = iph->daddr, 30 .daddr = iph->daddr,
31 .saddr = iph->saddr, 31 .saddr = iph->saddr,
32 }; 32 };
33 int err;
33 34
34 dst = ip6_route_output(net, skb->sk, &fl6); 35 dst = ip6_route_output(net, skb->sk, &fl6);
35 if (dst->error) { 36 err = dst->error;
37 if (err) {
36 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); 38 IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
37 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n"); 39 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
38 dst_release(dst); 40 dst_release(dst);
39 return dst->error; 41 return err;
40 } 42 }
41 43
42 /* Drop old route. */ 44 /* Drop old route. */
diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index e0983f3648a6..790e0c6b19e1 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -33,6 +33,7 @@ static bool rpfilter_lookup_reverse6(const struct sk_buff *skb,
33 struct ipv6hdr *iph = ipv6_hdr(skb); 33 struct ipv6hdr *iph = ipv6_hdr(skb);
34 bool ret = false; 34 bool ret = false;
35 struct flowi6 fl6 = { 35 struct flowi6 fl6 = {
36 .flowi6_iif = LOOPBACK_IFINDEX,
36 .flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK, 37 .flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK,
37 .flowi6_proto = iph->nexthdr, 38 .flowi6_proto = iph->nexthdr,
38 .daddr = iph->saddr, 39 .daddr = iph->saddr,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4011617cca68..004fffb6c221 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1273,6 +1273,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
1273 struct flowi6 fl6; 1273 struct flowi6 fl6;
1274 1274
1275 memset(&fl6, 0, sizeof(fl6)); 1275 memset(&fl6, 0, sizeof(fl6));
1276 fl6.flowi6_iif = LOOPBACK_IFINDEX;
1276 fl6.flowi6_oif = oif; 1277 fl6.flowi6_oif = oif;
1277 fl6.flowi6_mark = mark; 1278 fl6.flowi6_mark = mark;
1278 fl6.daddr = iph->daddr; 1279 fl6.daddr = iph->daddr;
@@ -1294,6 +1295,7 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
1294 struct flowi6 fl6; 1295 struct flowi6 fl6;
1295 1296
1296 memset(&fl6, 0, sizeof(fl6)); 1297 memset(&fl6, 0, sizeof(fl6));
1298 fl6.flowi6_iif = LOOPBACK_IFINDEX;
1297 fl6.flowi6_oif = oif; 1299 fl6.flowi6_oif = oif;
1298 fl6.flowi6_mark = mark; 1300 fl6.flowi6_mark = mark;
1299 fl6.daddr = msg->dest; 1301 fl6.daddr = msg->dest;
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 0e5b67015650..394e201cde6d 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1232,7 +1232,8 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
1232 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) && 1232 if (ether_addr_equal(bssid, rx->sdata->u.ibss.bssid) &&
1233 test_sta_flag(sta, WLAN_STA_AUTHORIZED)) { 1233 test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
1234 sta->last_rx = jiffies; 1234 sta->last_rx = jiffies;
1235 if (ieee80211_is_data(hdr->frame_control)) { 1235 if (ieee80211_is_data(hdr->frame_control) &&
1236 !is_multicast_ether_addr(hdr->addr1)) {
1236 sta->last_rx_rate_idx = status->rate_idx; 1237 sta->last_rx_rate_idx = status->rate_idx;
1237 sta->last_rx_rate_flag = status->flag; 1238 sta->last_rx_rate_flag = status->flag;
1238 sta->last_rx_rate_vht_flag = status->vht_flag; 1239 sta->last_rx_rate_vht_flag = status->vht_flag;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index c34a5f97abc7..632d372bb511 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1147,7 +1147,8 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1147 atomic_dec(&ps->num_sta_ps); 1147 atomic_dec(&ps->num_sta_ps);
1148 1148
1149 /* This station just woke up and isn't aware of our SMPS state */ 1149 /* This station just woke up and isn't aware of our SMPS state */
1150 if (!ieee80211_smps_is_restrictive(sta->known_smps_mode, 1150 if (!ieee80211_vif_is_mesh(&sdata->vif) &&
1151 !ieee80211_smps_is_restrictive(sta->known_smps_mode,
1151 sdata->smps_mode) && 1152 sdata->smps_mode) &&
1152 sta->known_smps_mode != sdata->bss->req_smps && 1153 sta->known_smps_mode != sdata->bss->req_smps &&
1153 sta_info_tx_streams(sta) != 1) { 1154 sta_info_tx_streams(sta) != 1) {
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 00ba90b02ab2..60cb7a665976 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -314,10 +314,9 @@ ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
314 !is_multicast_ether_addr(hdr->addr1)) 314 !is_multicast_ether_addr(hdr->addr1))
315 txflags |= IEEE80211_RADIOTAP_F_TX_FAIL; 315 txflags |= IEEE80211_RADIOTAP_F_TX_FAIL;
316 316
317 if ((info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) || 317 if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
318 (info->status.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT))
319 txflags |= IEEE80211_RADIOTAP_F_TX_CTS; 318 txflags |= IEEE80211_RADIOTAP_F_TX_CTS;
320 else if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) 319 if (info->status.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)
321 txflags |= IEEE80211_RADIOTAP_F_TX_RTS; 320 txflags |= IEEE80211_RADIOTAP_F_TX_RTS;
322 321
323 put_unaligned_le16(txflags, pos); 322 put_unaligned_le16(txflags, pos);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index ad058759e85e..c08bd4aca6bb 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1777,7 +1777,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1777 mutex_unlock(&local->mtx); 1777 mutex_unlock(&local->mtx);
1778 1778
1779 if (sched_scan_stopped) 1779 if (sched_scan_stopped)
1780 cfg80211_sched_scan_stopped(local->hw.wiphy); 1780 cfg80211_sched_scan_stopped_rtnl(local->hw.wiphy);
1781 1781
1782 /* 1782 /*
1783 * If this is for hw restart things are still running. 1783 * If this is for hw restart things are still running.
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ccc46fa5edbc..58579634427d 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1336,6 +1336,9 @@ ctnetlink_setup_nat(struct nf_conn *ct, const struct nlattr * const cda[])
1336#ifdef CONFIG_NF_NAT_NEEDED 1336#ifdef CONFIG_NF_NAT_NEEDED
1337 int ret; 1337 int ret;
1338 1338
1339 if (!cda[CTA_NAT_DST] && !cda[CTA_NAT_SRC])
1340 return 0;
1341
1339 ret = ctnetlink_parse_nat_setup(ct, NF_NAT_MANIP_DST, 1342 ret = ctnetlink_parse_nat_setup(ct, NF_NAT_MANIP_DST,
1340 cda[CTA_NAT_DST]); 1343 cda[CTA_NAT_DST]);
1341 if (ret < 0) 1344 if (ret < 0)
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 6e42dcfad40a..c138b8fbe280 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -256,15 +256,15 @@ replay:
256#endif 256#endif
257 { 257 {
258 nfnl_unlock(subsys_id); 258 nfnl_unlock(subsys_id);
259 kfree_skb(nskb); 259 netlink_ack(skb, nlh, -EOPNOTSUPP);
260 return netlink_ack(skb, nlh, -EOPNOTSUPP); 260 return kfree_skb(nskb);
261 } 261 }
262 } 262 }
263 263
264 if (!ss->commit || !ss->abort) { 264 if (!ss->commit || !ss->abort) {
265 nfnl_unlock(subsys_id); 265 nfnl_unlock(subsys_id);
266 kfree_skb(nskb); 266 netlink_ack(skb, nlh, -EOPNOTSUPP);
267 return netlink_ack(skb, nlh, -EOPNOTSUPP); 267 return kfree_skb(skb);
268 } 268 }
269 269
270 while (skb->len >= nlmsg_total_size(0)) { 270 while (skb->len >= nlmsg_total_size(0)) {
@@ -368,14 +368,13 @@ done:
368static void nfnetlink_rcv(struct sk_buff *skb) 368static void nfnetlink_rcv(struct sk_buff *skb)
369{ 369{
370 struct nlmsghdr *nlh = nlmsg_hdr(skb); 370 struct nlmsghdr *nlh = nlmsg_hdr(skb);
371 struct net *net = sock_net(skb->sk);
372 int msglen; 371 int msglen;
373 372
374 if (nlh->nlmsg_len < NLMSG_HDRLEN || 373 if (nlh->nlmsg_len < NLMSG_HDRLEN ||
375 skb->len < nlh->nlmsg_len) 374 skb->len < nlh->nlmsg_len)
376 return; 375 return;
377 376
378 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) { 377 if (!netlink_net_capable(skb, CAP_NET_ADMIN)) {
379 netlink_ack(skb, nlh, -EPERM); 378 netlink_ack(skb, nlh, -EPERM);
380 return; 379 return;
381 } 380 }
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 92f4b6915e89..e0ccd84d4d67 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1364,7 +1364,72 @@ retry:
1364 return err; 1364 return err;
1365} 1365}
1366 1366
1367static inline int netlink_capable(const struct socket *sock, unsigned int flag) 1367/**
1368 * __netlink_ns_capable - General netlink message capability test
1369 * @nsp: NETLINK_CB of the socket buffer holding a netlink command from userspace.
1370 * @user_ns: The user namespace of the capability to use
1371 * @cap: The capability to use
1372 *
1373 * Test to see if the opener of the socket we received the message
1374 * from had when the netlink socket was created and the sender of the
1375 * message has has the capability @cap in the user namespace @user_ns.
1376 */
1377bool __netlink_ns_capable(const struct netlink_skb_parms *nsp,
1378 struct user_namespace *user_ns, int cap)
1379{
1380 return sk_ns_capable(nsp->sk, user_ns, cap);
1381}
1382EXPORT_SYMBOL(__netlink_ns_capable);
1383
1384/**
1385 * netlink_ns_capable - General netlink message capability test
1386 * @skb: socket buffer holding a netlink command from userspace
1387 * @user_ns: The user namespace of the capability to use
1388 * @cap: The capability to use
1389 *
1390 * Test to see if the opener of the socket we received the message
1391 * from had when the netlink socket was created and the sender of the
1392 * message has has the capability @cap in the user namespace @user_ns.
1393 */
1394bool netlink_ns_capable(const struct sk_buff *skb,
1395 struct user_namespace *user_ns, int cap)
1396{
1397 return __netlink_ns_capable(&NETLINK_CB(skb), user_ns, cap);
1398}
1399EXPORT_SYMBOL(netlink_ns_capable);
1400
1401/**
1402 * netlink_capable - Netlink global message capability test
1403 * @skb: socket buffer holding a netlink command from userspace
1404 * @cap: The capability to use
1405 *
1406 * Test to see if the opener of the socket we received the message
1407 * from had when the netlink socket was created and the sender of the
1408 * message has has the capability @cap in all user namespaces.
1409 */
1410bool netlink_capable(const struct sk_buff *skb, int cap)
1411{
1412 return netlink_ns_capable(skb, &init_user_ns, cap);
1413}
1414EXPORT_SYMBOL(netlink_capable);
1415
1416/**
1417 * netlink_net_capable - Netlink network namespace message capability test
1418 * @skb: socket buffer holding a netlink command from userspace
1419 * @cap: The capability to use
1420 *
1421 * Test to see if the opener of the socket we received the message
1422 * from had when the netlink socket was created and the sender of the
1423 * message has has the capability @cap over the network namespace of
1424 * the socket we received the message from.
1425 */
1426bool netlink_net_capable(const struct sk_buff *skb, int cap)
1427{
1428 return netlink_ns_capable(skb, sock_net(skb->sk)->user_ns, cap);
1429}
1430EXPORT_SYMBOL(netlink_net_capable);
1431
1432static inline int netlink_allowed(const struct socket *sock, unsigned int flag)
1368{ 1433{
1369 return (nl_table[sock->sk->sk_protocol].flags & flag) || 1434 return (nl_table[sock->sk->sk_protocol].flags & flag) ||
1370 ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN); 1435 ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN);
@@ -1446,7 +1511,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1446 1511
1447 /* Only superuser is allowed to listen multicasts */ 1512 /* Only superuser is allowed to listen multicasts */
1448 if (groups) { 1513 if (groups) {
1449 if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV)) 1514 if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
1450 return -EPERM; 1515 return -EPERM;
1451 err = netlink_realloc_groups(sk); 1516 err = netlink_realloc_groups(sk);
1452 if (err) 1517 if (err)
@@ -1516,7 +1581,7 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
1516 return -EINVAL; 1581 return -EINVAL;
1517 1582
1518 if ((nladdr->nl_groups || nladdr->nl_pid) && 1583 if ((nladdr->nl_groups || nladdr->nl_pid) &&
1519 !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) 1584 !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
1520 return -EPERM; 1585 return -EPERM;
1521 1586
1522 if (!nlk->portid) 1587 if (!nlk->portid)
@@ -2122,7 +2187,7 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
2122 break; 2187 break;
2123 case NETLINK_ADD_MEMBERSHIP: 2188 case NETLINK_ADD_MEMBERSHIP:
2124 case NETLINK_DROP_MEMBERSHIP: { 2189 case NETLINK_DROP_MEMBERSHIP: {
2125 if (!netlink_capable(sock, NL_CFG_F_NONROOT_RECV)) 2190 if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
2126 return -EPERM; 2191 return -EPERM;
2127 err = netlink_realloc_groups(sk); 2192 err = netlink_realloc_groups(sk);
2128 if (err) 2193 if (err)
@@ -2277,7 +2342,7 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
2277 dst_group = ffs(addr->nl_groups); 2342 dst_group = ffs(addr->nl_groups);
2278 err = -EPERM; 2343 err = -EPERM;
2279 if ((dst_group || dst_portid) && 2344 if ((dst_group || dst_portid) &&
2280 !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) 2345 !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
2281 goto out; 2346 goto out;
2282 } else { 2347 } else {
2283 dst_portid = nlk->dst_portid; 2348 dst_portid = nlk->dst_portid;
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index b1dcdb932a86..a3ba3ca0ff92 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -561,7 +561,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
561 return -EOPNOTSUPP; 561 return -EOPNOTSUPP;
562 562
563 if ((ops->flags & GENL_ADMIN_PERM) && 563 if ((ops->flags & GENL_ADMIN_PERM) &&
564 !capable(CAP_NET_ADMIN)) 564 !netlink_capable(skb, CAP_NET_ADMIN))
565 return -EPERM; 565 return -EPERM;
566 566
567 if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) { 567 if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
diff --git a/net/packet/diag.c b/net/packet/diag.c
index 435ff99ba8c7..92f2c7107eec 100644
--- a/net/packet/diag.c
+++ b/net/packet/diag.c
@@ -128,6 +128,7 @@ static int pdiag_put_fanout(struct packet_sock *po, struct sk_buff *nlskb)
128 128
129static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, 129static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
130 struct packet_diag_req *req, 130 struct packet_diag_req *req,
131 bool may_report_filterinfo,
131 struct user_namespace *user_ns, 132 struct user_namespace *user_ns,
132 u32 portid, u32 seq, u32 flags, int sk_ino) 133 u32 portid, u32 seq, u32 flags, int sk_ino)
133{ 134{
@@ -172,7 +173,8 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
172 goto out_nlmsg_trim; 173 goto out_nlmsg_trim;
173 174
174 if ((req->pdiag_show & PACKET_SHOW_FILTER) && 175 if ((req->pdiag_show & PACKET_SHOW_FILTER) &&
175 sock_diag_put_filterinfo(sk, skb, PACKET_DIAG_FILTER)) 176 sock_diag_put_filterinfo(may_report_filterinfo, sk, skb,
177 PACKET_DIAG_FILTER))
176 goto out_nlmsg_trim; 178 goto out_nlmsg_trim;
177 179
178 return nlmsg_end(skb, nlh); 180 return nlmsg_end(skb, nlh);
@@ -188,9 +190,11 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
188 struct packet_diag_req *req; 190 struct packet_diag_req *req;
189 struct net *net; 191 struct net *net;
190 struct sock *sk; 192 struct sock *sk;
193 bool may_report_filterinfo;
191 194
192 net = sock_net(skb->sk); 195 net = sock_net(skb->sk);
193 req = nlmsg_data(cb->nlh); 196 req = nlmsg_data(cb->nlh);
197 may_report_filterinfo = netlink_net_capable(cb->skb, CAP_NET_ADMIN);
194 198
195 mutex_lock(&net->packet.sklist_lock); 199 mutex_lock(&net->packet.sklist_lock);
196 sk_for_each(sk, &net->packet.sklist) { 200 sk_for_each(sk, &net->packet.sklist) {
@@ -200,6 +204,7 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
200 goto next; 204 goto next;
201 205
202 if (sk_diag_fill(sk, skb, req, 206 if (sk_diag_fill(sk, skb, req,
207 may_report_filterinfo,
203 sk_user_ns(NETLINK_CB(cb->skb).sk), 208 sk_user_ns(NETLINK_CB(cb->skb).sk),
204 NETLINK_CB(cb->skb).portid, 209 NETLINK_CB(cb->skb).portid,
205 cb->nlh->nlmsg_seq, NLM_F_MULTI, 210 cb->nlh->nlmsg_seq, NLM_F_MULTI,
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index dc15f4300808..b64151ade6b3 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -70,10 +70,10 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
70 int err; 70 int err;
71 u8 pnaddr; 71 u8 pnaddr;
72 72
73 if (!capable(CAP_NET_ADMIN)) 73 if (!netlink_capable(skb, CAP_NET_ADMIN))
74 return -EPERM; 74 return -EPERM;
75 75
76 if (!capable(CAP_SYS_ADMIN)) 76 if (!netlink_capable(skb, CAP_SYS_ADMIN))
77 return -EPERM; 77 return -EPERM;
78 78
79 ASSERT_RTNL(); 79 ASSERT_RTNL();
@@ -233,10 +233,10 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh)
233 int err; 233 int err;
234 u8 dst; 234 u8 dst;
235 235
236 if (!capable(CAP_NET_ADMIN)) 236 if (!netlink_capable(skb, CAP_NET_ADMIN))
237 return -EPERM; 237 return -EPERM;
238 238
239 if (!capable(CAP_SYS_ADMIN)) 239 if (!netlink_capable(skb, CAP_SYS_ADMIN))
240 return -EPERM; 240 return -EPERM;
241 241
242 ASSERT_RTNL(); 242 ASSERT_RTNL();
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 8a5ba5add4bc..648778aef1a2 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -948,7 +948,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n)
948 u32 portid = skb ? NETLINK_CB(skb).portid : 0; 948 u32 portid = skb ? NETLINK_CB(skb).portid : 0;
949 int ret = 0, ovr = 0; 949 int ret = 0, ovr = 0;
950 950
951 if ((n->nlmsg_type != RTM_GETACTION) && !capable(CAP_NET_ADMIN)) 951 if ((n->nlmsg_type != RTM_GETACTION) && !netlink_capable(skb, CAP_NET_ADMIN))
952 return -EPERM; 952 return -EPERM;
953 953
954 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL); 954 ret = nlmsg_parse(n, sizeof(struct tcamsg), tca, TCA_ACT_MAX, NULL);
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 1a4a20267787..45527e6b52db 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -135,7 +135,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
135 int tp_created = 0; 135 int tp_created = 0;
136 136
137 if ((n->nlmsg_type != RTM_GETTFILTER) && 137 if ((n->nlmsg_type != RTM_GETTFILTER) &&
138 !ns_capable(net->user_ns, CAP_NET_ADMIN)) 138 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
139 return -EPERM; 139 return -EPERM;
140 140
141replay: 141replay:
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 86f8edfd6b8a..fd14df56e5ff 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1085,7 +1085,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
1085 int err; 1085 int err;
1086 1086
1087 if ((n->nlmsg_type != RTM_GETQDISC) && 1087 if ((n->nlmsg_type != RTM_GETQDISC) &&
1088 !ns_capable(net->user_ns, CAP_NET_ADMIN)) 1088 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
1089 return -EPERM; 1089 return -EPERM;
1090 1090
1091 err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL); 1091 err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
@@ -1152,7 +1152,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
1152 struct Qdisc *q, *p; 1152 struct Qdisc *q, *p;
1153 int err; 1153 int err;
1154 1154
1155 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 1155 if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
1156 return -EPERM; 1156 return -EPERM;
1157 1157
1158replay: 1158replay:
@@ -1492,7 +1492,7 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n)
1492 int err; 1492 int err;
1493 1493
1494 if ((n->nlmsg_type != RTM_GETTCLASS) && 1494 if ((n->nlmsg_type != RTM_GETTCLASS) &&
1495 !ns_capable(net->user_ns, CAP_NET_ADMIN)) 1495 !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
1496 return -EPERM; 1496 return -EPERM;
1497 1497
1498 err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL); 1498 err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c
index edee03d922e2..6e957c3b9854 100644
--- a/net/sched/sch_hhf.c
+++ b/net/sched/sch_hhf.c
@@ -553,11 +553,6 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt)
553 if (err < 0) 553 if (err < 0)
554 return err; 554 return err;
555 555
556 sch_tree_lock(sch);
557
558 if (tb[TCA_HHF_BACKLOG_LIMIT])
559 sch->limit = nla_get_u32(tb[TCA_HHF_BACKLOG_LIMIT]);
560
561 if (tb[TCA_HHF_QUANTUM]) 556 if (tb[TCA_HHF_QUANTUM])
562 new_quantum = nla_get_u32(tb[TCA_HHF_QUANTUM]); 557 new_quantum = nla_get_u32(tb[TCA_HHF_QUANTUM]);
563 558
@@ -567,6 +562,12 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt)
567 non_hh_quantum = (u64)new_quantum * new_hhf_non_hh_weight; 562 non_hh_quantum = (u64)new_quantum * new_hhf_non_hh_weight;
568 if (non_hh_quantum > INT_MAX) 563 if (non_hh_quantum > INT_MAX)
569 return -EINVAL; 564 return -EINVAL;
565
566 sch_tree_lock(sch);
567
568 if (tb[TCA_HHF_BACKLOG_LIMIT])
569 sch->limit = nla_get_u32(tb[TCA_HHF_BACKLOG_LIMIT]);
570
570 q->quantum = new_quantum; 571 q->quantum = new_quantum;
571 q->hhf_non_hh_weight = new_hhf_non_hh_weight; 572 q->hhf_non_hh_weight = new_hhf_non_hh_weight;
572 573
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 074b60e2faab..af5afca4b85a 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -491,8 +491,13 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
491 continue; 491 continue;
492 if ((laddr->state == SCTP_ADDR_SRC) && 492 if ((laddr->state == SCTP_ADDR_SRC) &&
493 (AF_INET == laddr->a.sa.sa_family)) { 493 (AF_INET == laddr->a.sa.sa_family)) {
494 fl4->saddr = laddr->a.v4.sin_addr.s_addr;
495 fl4->fl4_sport = laddr->a.v4.sin_port; 494 fl4->fl4_sport = laddr->a.v4.sin_port;
495 flowi4_update_output(fl4,
496 asoc->base.sk->sk_bound_dev_if,
497 RT_CONN_FLAGS(asoc->base.sk),
498 daddr->v4.sin_addr.s_addr,
499 laddr->a.v4.sin_addr.s_addr);
500
496 rt = ip_route_output_key(sock_net(sk), fl4); 501 rt = ip_route_output_key(sock_net(sk), fl4);
497 if (!IS_ERR(rt)) { 502 if (!IS_ERR(rt)) {
498 dst = &rt->dst; 503 dst = &rt->dst;
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 5d6883ff00c3..fef2acdf4a2e 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -496,11 +496,10 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
496 496
497 /* If the transport error count is greater than the pf_retrans 497 /* If the transport error count is greater than the pf_retrans
498 * threshold, and less than pathmaxrtx, and if the current state 498 * threshold, and less than pathmaxrtx, and if the current state
499 * is not SCTP_UNCONFIRMED, then mark this transport as Partially 499 * is SCTP_ACTIVE, then mark this transport as Partially Failed,
500 * Failed, see SCTP Quick Failover Draft, section 5.1 500 * see SCTP Quick Failover Draft, section 5.1
501 */ 501 */
502 if ((transport->state != SCTP_PF) && 502 if ((transport->state == SCTP_ACTIVE) &&
503 (transport->state != SCTP_UNCONFIRMED) &&
504 (asoc->pf_retrans < transport->pathmaxrxt) && 503 (asoc->pf_retrans < transport->pathmaxrxt) &&
505 (transport->error_count > asoc->pf_retrans)) { 504 (transport->error_count > asoc->pf_retrans)) {
506 505
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 3aaf73de9e2d..ad844d365340 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -47,7 +47,7 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
47 int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN); 47 int hdr_space = nlmsg_total_size(GENL_HDRLEN + TIPC_GENL_HDRLEN);
48 u16 cmd; 48 u16 cmd;
49 49
50 if ((req_userhdr->cmd & 0xC000) && (!capable(CAP_NET_ADMIN))) 50 if ((req_userhdr->cmd & 0xC000) && (!netlink_capable(skb, CAP_NET_ADMIN)))
51 cmd = TIPC_CMD_NOT_NET_ADMIN; 51 cmd = TIPC_CMD_NOT_NET_ADMIN;
52 else 52 else
53 cmd = req_userhdr->cmd; 53 cmd = req_userhdr->cmd;
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 5adfd94c5b85..85d232bed87d 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1925,9 +1925,23 @@ static struct miscdevice vsock_device = {
1925 .fops = &vsock_device_ops, 1925 .fops = &vsock_device_ops,
1926}; 1926};
1927 1927
1928static int __vsock_core_init(void) 1928int __vsock_core_init(const struct vsock_transport *t, struct module *owner)
1929{ 1929{
1930 int err; 1930 int err = mutex_lock_interruptible(&vsock_register_mutex);
1931
1932 if (err)
1933 return err;
1934
1935 if (transport) {
1936 err = -EBUSY;
1937 goto err_busy;
1938 }
1939
1940 /* Transport must be the owner of the protocol so that it can't
1941 * unload while there are open sockets.
1942 */
1943 vsock_proto.owner = owner;
1944 transport = t;
1931 1945
1932 vsock_init_tables(); 1946 vsock_init_tables();
1933 1947
@@ -1951,36 +1965,19 @@ static int __vsock_core_init(void)
1951 goto err_unregister_proto; 1965 goto err_unregister_proto;
1952 } 1966 }
1953 1967
1968 mutex_unlock(&vsock_register_mutex);
1954 return 0; 1969 return 0;
1955 1970
1956err_unregister_proto: 1971err_unregister_proto:
1957 proto_unregister(&vsock_proto); 1972 proto_unregister(&vsock_proto);
1958err_misc_deregister: 1973err_misc_deregister:
1959 misc_deregister(&vsock_device); 1974 misc_deregister(&vsock_device);
1960 return err; 1975 transport = NULL;
1961} 1976err_busy:
1962
1963int vsock_core_init(const struct vsock_transport *t)
1964{
1965 int retval = mutex_lock_interruptible(&vsock_register_mutex);
1966 if (retval)
1967 return retval;
1968
1969 if (transport) {
1970 retval = -EBUSY;
1971 goto out;
1972 }
1973
1974 transport = t;
1975 retval = __vsock_core_init();
1976 if (retval)
1977 transport = NULL;
1978
1979out:
1980 mutex_unlock(&vsock_register_mutex); 1977 mutex_unlock(&vsock_register_mutex);
1981 return retval; 1978 return err;
1982} 1979}
1983EXPORT_SYMBOL_GPL(vsock_core_init); 1980EXPORT_SYMBOL_GPL(__vsock_core_init);
1984 1981
1985void vsock_core_exit(void) 1982void vsock_core_exit(void)
1986{ 1983{
@@ -2000,5 +1997,5 @@ EXPORT_SYMBOL_GPL(vsock_core_exit);
2000 1997
2001MODULE_AUTHOR("VMware, Inc."); 1998MODULE_AUTHOR("VMware, Inc.");
2002MODULE_DESCRIPTION("VMware Virtual Socket Family"); 1999MODULE_DESCRIPTION("VMware Virtual Socket Family");
2003MODULE_VERSION("1.0.0.0-k"); 2000MODULE_VERSION("1.0.1.0-k");
2004MODULE_LICENSE("GPL v2"); 2001MODULE_LICENSE("GPL v2");
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 0f5da18cc619..e7329bb6a323 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -284,14 +284,22 @@ void cfg80211_sched_scan_results(struct wiphy *wiphy)
284} 284}
285EXPORT_SYMBOL(cfg80211_sched_scan_results); 285EXPORT_SYMBOL(cfg80211_sched_scan_results);
286 286
287void cfg80211_sched_scan_stopped(struct wiphy *wiphy) 287void cfg80211_sched_scan_stopped_rtnl(struct wiphy *wiphy)
288{ 288{
289 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 289 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
290 290
291 ASSERT_RTNL();
292
291 trace_cfg80211_sched_scan_stopped(wiphy); 293 trace_cfg80211_sched_scan_stopped(wiphy);
292 294
293 rtnl_lock();
294 __cfg80211_stop_sched_scan(rdev, true); 295 __cfg80211_stop_sched_scan(rdev, true);
296}
297EXPORT_SYMBOL(cfg80211_sched_scan_stopped_rtnl);
298
299void cfg80211_sched_scan_stopped(struct wiphy *wiphy)
300{
301 rtnl_lock();
302 cfg80211_sched_scan_stopped_rtnl(wiphy);
295 rtnl_unlock(); 303 rtnl_unlock();
296} 304}
297EXPORT_SYMBOL(cfg80211_sched_scan_stopped); 305EXPORT_SYMBOL(cfg80211_sched_scan_stopped);
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index e2923a3f2e5c..0c0844b585d1 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -234,7 +234,6 @@ void cfg80211_conn_work(struct work_struct *work)
234 NULL, 0, NULL, 0, 234 NULL, 0, NULL, 0,
235 WLAN_STATUS_UNSPECIFIED_FAILURE, 235 WLAN_STATUS_UNSPECIFIED_FAILURE,
236 false, NULL); 236 false, NULL);
237 cfg80211_sme_free(wdev);
238 } 237 }
239 wdev_unlock(wdev); 238 wdev_unlock(wdev);
240 } 239 }
@@ -647,6 +646,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
647 cfg80211_unhold_bss(bss_from_pub(bss)); 646 cfg80211_unhold_bss(bss_from_pub(bss));
648 cfg80211_put_bss(wdev->wiphy, bss); 647 cfg80211_put_bss(wdev->wiphy, bss);
649 } 648 }
649 cfg80211_sme_free(wdev);
650 return; 650 return;
651 } 651 }
652 652
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 8f131c10a6f3..51398ae6cda8 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2377,7 +2377,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
2377 link = &xfrm_dispatch[type]; 2377 link = &xfrm_dispatch[type];
2378 2378
2379 /* All operations require privileges, even GET */ 2379 /* All operations require privileges, even GET */
2380 if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) 2380 if (!netlink_net_capable(skb, CAP_NET_ADMIN))
2381 return -EPERM; 2381 return -EPERM;
2382 2382
2383 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) || 2383 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index cc49062acdee..1052d4834a44 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -35,6 +35,10 @@
35#define EM_ARCOMPACT 93 35#define EM_ARCOMPACT 93
36#endif 36#endif
37 37
38#ifndef EM_XTENSA
39#define EM_XTENSA 94
40#endif
41
38#ifndef EM_AARCH64 42#ifndef EM_AARCH64
39#define EM_AARCH64 183 43#define EM_AARCH64 183
40#endif 44#endif
@@ -281,6 +285,7 @@ do_file(char const *const fname)
281 case EM_AARCH64: 285 case EM_AARCH64:
282 case EM_MICROBLAZE: 286 case EM_MICROBLAZE:
283 case EM_MIPS: 287 case EM_MIPS:
288 case EM_XTENSA:
284 break; 289 break;
285 } /* end switch */ 290 } /* end switch */
286 291
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index b4beb77967b1..2c7341dbc5d6 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3317,9 +3317,9 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
3317 case F_GETLK: 3317 case F_GETLK:
3318 case F_SETLK: 3318 case F_SETLK:
3319 case F_SETLKW: 3319 case F_SETLKW:
3320 case F_GETLKP: 3320 case F_OFD_GETLK:
3321 case F_SETLKP: 3321 case F_OFD_SETLK:
3322 case F_SETLKPW: 3322 case F_OFD_SETLKW:
3323#if BITS_PER_LONG == 32 3323#if BITS_PER_LONG == 32
3324 case F_GETLK64: 3324 case F_GETLK64:
3325 case F_SETLK64: 3325 case F_SETLK64:
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 248b90abb882..480bbddbd801 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -1059,24 +1059,26 @@ static void azx_init_cmd_io(struct azx *chip)
1059 1059
1060 /* reset the corb hw read pointer */ 1060 /* reset the corb hw read pointer */
1061 azx_writew(chip, CORBRP, ICH6_CORBRP_RST); 1061 azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
1062 for (timeout = 1000; timeout > 0; timeout--) { 1062 if (!(chip->driver_caps & AZX_DCAPS_CORBRP_SELF_CLEAR)) {
1063 if ((azx_readw(chip, CORBRP) & ICH6_CORBRP_RST) == ICH6_CORBRP_RST) 1063 for (timeout = 1000; timeout > 0; timeout--) {
1064 break; 1064 if ((azx_readw(chip, CORBRP) & ICH6_CORBRP_RST) == ICH6_CORBRP_RST)
1065 udelay(1); 1065 break;
1066 } 1066 udelay(1);
1067 if (timeout <= 0) 1067 }
1068 dev_err(chip->card->dev, "CORB reset timeout#1, CORBRP = %d\n", 1068 if (timeout <= 0)
1069 azx_readw(chip, CORBRP)); 1069 dev_err(chip->card->dev, "CORB reset timeout#1, CORBRP = %d\n",
1070 azx_readw(chip, CORBRP));
1070 1071
1071 azx_writew(chip, CORBRP, 0); 1072 azx_writew(chip, CORBRP, 0);
1072 for (timeout = 1000; timeout > 0; timeout--) { 1073 for (timeout = 1000; timeout > 0; timeout--) {
1073 if (azx_readw(chip, CORBRP) == 0) 1074 if (azx_readw(chip, CORBRP) == 0)
1074 break; 1075 break;
1075 udelay(1); 1076 udelay(1);
1077 }
1078 if (timeout <= 0)
1079 dev_err(chip->card->dev, "CORB reset timeout#2, CORBRP = %d\n",
1080 azx_readw(chip, CORBRP));
1076 } 1081 }
1077 if (timeout <= 0)
1078 dev_err(chip->card->dev, "CORB reset timeout#2, CORBRP = %d\n",
1079 azx_readw(chip, CORBRP));
1080 1082
1081 /* enable corb dma */ 1083 /* enable corb dma */
1082 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN); 1084 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index d6bca62ef387..b540ad71eb0d 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -249,7 +249,8 @@ enum {
249/* quirks for Nvidia */ 249/* quirks for Nvidia */
250#define AZX_DCAPS_PRESET_NVIDIA \ 250#define AZX_DCAPS_PRESET_NVIDIA \
251 (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\ 251 (AZX_DCAPS_NVIDIA_SNOOP | AZX_DCAPS_RIRB_DELAY | AZX_DCAPS_NO_MSI |\
252 AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT) 252 AZX_DCAPS_ALIGN_BUFSIZE | AZX_DCAPS_NO_64BIT |\
253 AZX_DCAPS_CORBRP_SELF_CLEAR)
253 254
254#define AZX_DCAPS_PRESET_CTHDA \ 255#define AZX_DCAPS_PRESET_CTHDA \
255 (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY) 256 (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY)
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
index ba38b819f984..4a7cb01fa912 100644
--- a/sound/pci/hda/hda_priv.h
+++ b/sound/pci/hda/hda_priv.h
@@ -189,6 +189,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
189#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */ 189#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
190#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */ 190#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
191#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */ 191#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */
192#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */
192 193
193/* position fix mode */ 194/* position fix mode */
194enum { 195enum {
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c643dfc0a826..c1952c910339 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4621,6 +4621,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4621 SND_PCI_QUIRK(0x1028, 0x0667, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4621 SND_PCI_QUIRK(0x1028, 0x0667, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4622 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4622 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4623 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE), 4623 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4624 SND_PCI_QUIRK(0x1028, 0x0674, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4624 SND_PCI_QUIRK(0x1028, 0x067f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4625 SND_PCI_QUIRK(0x1028, 0x067f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4625 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4626 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4626 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4627 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c
index f500905e9373..2acf82f4a08a 100644
--- a/sound/soc/codecs/alc5623.c
+++ b/sound/soc/codecs/alc5623.c
@@ -1018,13 +1018,13 @@ static int alc5623_i2c_probe(struct i2c_client *client,
1018 dev_err(&client->dev, "failed to read vendor ID1: %d\n", ret); 1018 dev_err(&client->dev, "failed to read vendor ID1: %d\n", ret);
1019 return ret; 1019 return ret;
1020 } 1020 }
1021 vid1 = ((vid1 & 0xff) << 8) | (vid1 >> 8);
1022 1021
1023 ret = regmap_read(alc5623->regmap, ALC5623_VENDOR_ID2, &vid2); 1022 ret = regmap_read(alc5623->regmap, ALC5623_VENDOR_ID2, &vid2);
1024 if (ret < 0) { 1023 if (ret < 0) {
1025 dev_err(&client->dev, "failed to read vendor ID2: %d\n", ret); 1024 dev_err(&client->dev, "failed to read vendor ID2: %d\n", ret);
1026 return ret; 1025 return ret;
1027 } 1026 }
1027 vid2 >>= 8;
1028 1028
1029 if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) { 1029 if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) {
1030 dev_err(&client->dev, "unknown or wrong codec\n"); 1030 dev_err(&client->dev, "unknown or wrong codec\n");
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 460d35547a68..2213a037c893 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -1229,8 +1229,10 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client,
1229 } 1229 }
1230 1230
1231 if (cs42l52->pdata.reset_gpio) { 1231 if (cs42l52->pdata.reset_gpio) {
1232 ret = gpio_request_one(cs42l52->pdata.reset_gpio, 1232 ret = devm_gpio_request_one(&i2c_client->dev,
1233 GPIOF_OUT_INIT_HIGH, "CS42L52 /RST"); 1233 cs42l52->pdata.reset_gpio,
1234 GPIOF_OUT_INIT_HIGH,
1235 "CS42L52 /RST");
1234 if (ret < 0) { 1236 if (ret < 0) {
1235 dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", 1237 dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
1236 cs42l52->pdata.reset_gpio, ret); 1238 cs42l52->pdata.reset_gpio, ret);
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
index 0ee60a19a263..ae3717992d56 100644
--- a/sound/soc/codecs/cs42l73.c
+++ b/sound/soc/codecs/cs42l73.c
@@ -1443,8 +1443,10 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
1443 i2c_set_clientdata(i2c_client, cs42l73); 1443 i2c_set_clientdata(i2c_client, cs42l73);
1444 1444
1445 if (cs42l73->pdata.reset_gpio) { 1445 if (cs42l73->pdata.reset_gpio) {
1446 ret = gpio_request_one(cs42l73->pdata.reset_gpio, 1446 ret = devm_gpio_request_one(&i2c_client->dev,
1447 GPIOF_OUT_INIT_HIGH, "CS42L73 /RST"); 1447 cs42l73->pdata.reset_gpio,
1448 GPIOF_OUT_INIT_HIGH,
1449 "CS42L73 /RST");
1448 if (ret < 0) { 1450 if (ret < 0) {
1449 dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", 1451 dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
1450 cs42l73->pdata.reset_gpio, ret); 1452 cs42l73->pdata.reset_gpio, ret);
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index b1835103e9b4..d7349bc89ad3 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1399,7 +1399,6 @@ static int aic3x_probe(struct snd_soc_codec *codec)
1399 } 1399 }
1400 1400
1401 aic3x_add_widgets(codec); 1401 aic3x_add_widgets(codec);
1402 list_add(&aic3x->list, &reset_list);
1403 1402
1404 return 0; 1403 return 0;
1405 1404
@@ -1569,7 +1568,13 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
1569 1568
1570 ret = snd_soc_register_codec(&i2c->dev, 1569 ret = snd_soc_register_codec(&i2c->dev,
1571 &soc_codec_dev_aic3x, &aic3x_dai, 1); 1570 &soc_codec_dev_aic3x, &aic3x_dai, 1);
1572 return ret; 1571
1572 if (ret != 0)
1573 goto err_gpio;
1574
1575 list_add(&aic3x->list, &reset_list);
1576
1577 return 0;
1573 1578
1574err_gpio: 1579err_gpio:
1575 if (gpio_is_valid(aic3x->gpio_reset) && 1580 if (gpio_is_valid(aic3x->gpio_reset) &&
diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h
index b1266790d117..605a10b2112b 100644
--- a/sound/soc/fsl/fsl_spdif.h
+++ b/sound/soc/fsl/fsl_spdif.h
@@ -144,8 +144,8 @@ enum spdif_gainsel {
144 144
145/* SPDIF Clock register */ 145/* SPDIF Clock register */
146#define STC_SYSCLK_DIV_OFFSET 11 146#define STC_SYSCLK_DIV_OFFSET 11
147#define STC_SYSCLK_DIV_MASK (0x1ff << STC_TXCLK_SRC_OFFSET) 147#define STC_SYSCLK_DIV_MASK (0x1ff << STC_SYSCLK_DIV_OFFSET)
148#define STC_SYSCLK_DIV(x) ((((x) - 1) << STC_TXCLK_DIV_OFFSET) & STC_SYSCLK_DIV_MASK) 148#define STC_SYSCLK_DIV(x) ((((x) - 1) << STC_SYSCLK_DIV_OFFSET) & STC_SYSCLK_DIV_MASK)
149#define STC_TXCLK_SRC_OFFSET 8 149#define STC_TXCLK_SRC_OFFSET 8
150#define STC_TXCLK_SRC_MASK (0x7 << STC_TXCLK_SRC_OFFSET) 150#define STC_TXCLK_SRC_MASK (0x7 << STC_TXCLK_SRC_OFFSET)
151#define STC_TXCLK_SRC_SET(x) ((x << STC_TXCLK_SRC_OFFSET) & STC_TXCLK_SRC_MASK) 151#define STC_TXCLK_SRC_SET(x) ((x << STC_TXCLK_SRC_OFFSET) & STC_TXCLK_SRC_MASK)
diff --git a/sound/soc/intel/sst-dsp-priv.h b/sound/soc/intel/sst-dsp-priv.h
index fe8e81aad646..30ca14a6a835 100644
--- a/sound/soc/intel/sst-dsp-priv.h
+++ b/sound/soc/intel/sst-dsp-priv.h
@@ -136,7 +136,7 @@ struct sst_module_data {
136 enum sst_data_type data_type; /* type of module data */ 136 enum sst_data_type data_type; /* type of module data */
137 137
138 u32 size; /* size in bytes */ 138 u32 size; /* size in bytes */
139 u32 offset; /* offset in FW file */ 139 int32_t offset; /* offset in FW file */
140 u32 data_offset; /* offset in ADSP memory space */ 140 u32 data_offset; /* offset in ADSP memory space */
141 void *data; /* module data */ 141 void *data; /* module data */
142}; 142};
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c
index f46bb4ddde6f..50e4246d4b57 100644
--- a/sound/soc/intel/sst-haswell-ipc.c
+++ b/sound/soc/intel/sst-haswell-ipc.c
@@ -617,7 +617,7 @@ static void hsw_notification_work(struct work_struct *work)
617 case IPC_POSITION_CHANGED: 617 case IPC_POSITION_CHANGED:
618 trace_ipc_notification("DSP stream position changed for", 618 trace_ipc_notification("DSP stream position changed for",
619 stream->reply.stream_hw_id); 619 stream->reply.stream_hw_id);
620 sst_dsp_inbox_read(hsw->dsp, pos, sizeof(pos)); 620 sst_dsp_inbox_read(hsw->dsp, pos, sizeof(*pos));
621 621
622 if (stream->notify_position) 622 if (stream->notify_position)
623 stream->notify_position(stream, stream->pdata); 623 stream->notify_position(stream, stream->pdata);
@@ -991,7 +991,8 @@ int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream
991 return -EINVAL; 991 return -EINVAL;
992 992
993 sst_dsp_read(hsw->dsp, volume, 993 sst_dsp_read(hsw->dsp, volume,
994 stream->reply.volume_register_address[channel], sizeof(volume)); 994 stream->reply.volume_register_address[channel],
995 sizeof(*volume));
995 996
996 return 0; 997 return 0;
997} 998}
@@ -1609,7 +1610,7 @@ int sst_hsw_dx_set_state(struct sst_hsw *hsw,
1609 trace_ipc_request("PM enter Dx state", state); 1610 trace_ipc_request("PM enter Dx state", state);
1610 1611
1611 ret = ipc_tx_message_wait(hsw, header, &state_, sizeof(state_), 1612 ret = ipc_tx_message_wait(hsw, header, &state_, sizeof(state_),
1612 dx, sizeof(dx)); 1613 dx, sizeof(*dx));
1613 if (ret < 0) { 1614 if (ret < 0) {
1614 dev_err(hsw->dev, "ipc: error set dx state %d failed\n", state); 1615 dev_err(hsw->dev, "ipc: error set dx state %d failed\n", state);
1615 return ret; 1616 return ret;
diff --git a/sound/soc/jz4740/Makefile b/sound/soc/jz4740/Makefile
index be873c1b0c20..d32c540555c4 100644
--- a/sound/soc/jz4740/Makefile
+++ b/sound/soc/jz4740/Makefile
@@ -1,10 +1,8 @@
1# 1#
2# Jz4740 Platform Support 2# Jz4740 Platform Support
3# 3#
4snd-soc-jz4740-objs := jz4740-pcm.o
5snd-soc-jz4740-i2s-objs := jz4740-i2s.o 4snd-soc-jz4740-i2s-objs := jz4740-i2s.o
6 5
7obj-$(CONFIG_SND_JZ4740_SOC) += snd-soc-jz4740.o
8obj-$(CONFIG_SND_JZ4740_SOC_I2S) += snd-soc-jz4740-i2s.o 6obj-$(CONFIG_SND_JZ4740_SOC_I2S) += snd-soc-jz4740-i2s.o
9 7
10# Jz4740 Machine Support 8# Jz4740 Machine Support
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
index 6232b7d307aa..4d0720ed5a90 100644
--- a/sound/soc/sh/rcar/src.c
+++ b/sound/soc/sh/rcar/src.c
@@ -258,7 +258,7 @@ static int rsnd_src_init(struct rsnd_mod *mod,
258{ 258{
259 struct rsnd_src *src = rsnd_mod_to_src(mod); 259 struct rsnd_src *src = rsnd_mod_to_src(mod);
260 260
261 clk_enable(src->clk); 261 clk_prepare_enable(src->clk);
262 262
263 return 0; 263 return 0;
264} 264}
@@ -269,7 +269,7 @@ static int rsnd_src_quit(struct rsnd_mod *mod,
269{ 269{
270 struct rsnd_src *src = rsnd_mod_to_src(mod); 270 struct rsnd_src *src = rsnd_mod_to_src(mod);
271 271
272 clk_disable(src->clk); 272 clk_disable_unprepare(src->clk);
273 273
274 return 0; 274 return 0;
275} 275}
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c
index 4b7e20603dd7..1d8387c25bd8 100644
--- a/sound/soc/sh/rcar/ssi.c
+++ b/sound/soc/sh/rcar/ssi.c
@@ -171,7 +171,7 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
171 u32 cr; 171 u32 cr;
172 172
173 if (0 == ssi->usrcnt) { 173 if (0 == ssi->usrcnt) {
174 clk_enable(ssi->clk); 174 clk_prepare_enable(ssi->clk);
175 175
176 if (rsnd_dai_is_clk_master(rdai)) { 176 if (rsnd_dai_is_clk_master(rdai)) {
177 if (rsnd_ssi_clk_from_parent(ssi)) 177 if (rsnd_ssi_clk_from_parent(ssi))
@@ -230,7 +230,7 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi,
230 rsnd_ssi_master_clk_stop(ssi); 230 rsnd_ssi_master_clk_stop(ssi);
231 } 231 }
232 232
233 clk_disable(ssi->clk); 233 clk_disable_unprepare(ssi->clk);
234 } 234 }
235 235
236 dev_dbg(dev, "ssi%d hw stopped\n", rsnd_mod_id(&ssi->mod)); 236 dev_dbg(dev, "ssi%d hw stopped\n", rsnd_mod_id(&ssi->mod));
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index c8a780d0d057..7769b0a2bc5a 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -254,7 +254,6 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
254static void dapm_kcontrol_free(struct snd_kcontrol *kctl) 254static void dapm_kcontrol_free(struct snd_kcontrol *kctl)
255{ 255{
256 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl); 256 struct dapm_kcontrol_data *data = snd_kcontrol_chip(kctl);
257 kfree(data->widget);
258 kfree(data->wlist); 257 kfree(data->wlist);
259 kfree(data); 258 kfree(data);
260} 259}
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index 7c4347962353..a74fba6d7743 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -12,8 +12,8 @@
12char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug"; 12char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug";
13 13
14static const char * const debugfs_known_mountpoints[] = { 14static const char * const debugfs_known_mountpoints[] = {
15 "/sys/kernel/debug/", 15 "/sys/kernel/debug",
16 "/debug/", 16 "/debug",
17 0, 17 0,
18}; 18};
19 19
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index baec7d887da4..b83184f2d484 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4344,6 +4344,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
4344 format, len_arg, arg); 4344 format, len_arg, arg);
4345 trace_seq_terminate(&p); 4345 trace_seq_terminate(&p);
4346 trace_seq_puts(s, p.buffer); 4346 trace_seq_puts(s, p.buffer);
4347 trace_seq_destroy(&p);
4347 arg = arg->next; 4348 arg = arg->next;
4348 break; 4349 break;
4349 default: 4350 default:
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 791c539374c7..feab94281634 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -876,8 +876,8 @@ struct event_filter {
876struct event_filter *pevent_filter_alloc(struct pevent *pevent); 876struct event_filter *pevent_filter_alloc(struct pevent *pevent);
877 877
878/* for backward compatibility */ 878/* for backward compatibility */
879#define FILTER_NONE PEVENT_ERRNO__FILTER_NOT_FOUND 879#define FILTER_NONE PEVENT_ERRNO__NO_FILTER
880#define FILTER_NOEXIST PEVENT_ERRNO__NO_FILTER 880#define FILTER_NOEXIST PEVENT_ERRNO__FILTER_NOT_FOUND
881#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS 881#define FILTER_MISS PEVENT_ERRNO__FILTER_MISS
882#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH 882#define FILTER_MATCH PEVENT_ERRNO__FILTER_MATCH
883 883
diff --git a/tools/net/bpf_dbg.c b/tools/net/bpf_dbg.c
index bb31813e43dd..9a287bec695a 100644
--- a/tools/net/bpf_dbg.c
+++ b/tools/net/bpf_dbg.c
@@ -820,7 +820,7 @@ do_div:
820 r->A &= r->X; 820 r->A &= r->X;
821 break; 821 break;
822 case BPF_ALU_AND | BPF_K: 822 case BPF_ALU_AND | BPF_K:
823 r->A &= r->X; 823 r->A &= K;
824 break; 824 break;
825 case BPF_ALU_OR | BPF_X: 825 case BPF_ALU_OR | BPF_X:
826 r->A |= r->X; 826 r->A |= r->X;
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index e96923310d57..895edd32930c 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -589,7 +589,7 @@ $(GTK_OBJS): $(OUTPUT)%.o: %.c $(LIB_H)
589 $(QUIET_CC)$(CC) -o $@ -c -fPIC $(CFLAGS) $(GTK_CFLAGS) $< 589 $(QUIET_CC)$(CC) -o $@ -c -fPIC $(CFLAGS) $(GTK_CFLAGS) $<
590 590
591$(OUTPUT)libperf-gtk.so: $(GTK_OBJS) $(PERFLIBS) 591$(OUTPUT)libperf-gtk.so: $(GTK_OBJS) $(PERFLIBS)
592 $(QUIET_LINK)$(CC) -o $@ -shared $(ALL_LDFLAGS) $(filter %.o,$^) $(GTK_LIBS) 592 $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)
593 593
594$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS 594$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
595 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ 595 $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c
index b602ad93ce63..83bc2385e6d3 100644
--- a/tools/perf/arch/x86/tests/dwarf-unwind.c
+++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
@@ -23,9 +23,10 @@ static int sample_ustack(struct perf_sample *sample,
23 23
24 sp = (unsigned long) regs[PERF_REG_X86_SP]; 24 sp = (unsigned long) regs[PERF_REG_X86_SP];
25 25
26 map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp); 26 map = map_groups__find(&thread->mg, MAP__VARIABLE, (u64) sp);
27 if (!map) { 27 if (!map) {
28 pr_debug("failed to get stack map\n"); 28 pr_debug("failed to get stack map\n");
29 free(buf);
29 return -1; 30 return -1;
30 } 31 }
31 32
diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S
index 99167bf644ea..60875d5c556c 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -1,4 +1,3 @@
1
2#include <linux/linkage.h> 1#include <linux/linkage.h>
3 2
4#define AX 0 3#define AX 0
@@ -90,3 +89,10 @@ ENTRY(perf_regs_load)
90 ret 89 ret
91ENDPROC(perf_regs_load) 90ENDPROC(perf_regs_load)
92#endif 91#endif
92
93/*
94 * We need to provide note.GNU-stack section, saying that we want
95 * NOT executable stack. Otherwise the final linking will assume that
96 * the ELF stack should not be restricted at all and set it RWX.
97 */
98.section .note.GNU-stack,"",@progbits
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 21c164b8f9db..0f1e5a2f6ad7 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -404,6 +404,7 @@ static struct kvm_event *kvm_alloc_init_event(struct event_key *key)
404 } 404 }
405 405
406 event->key = *key; 406 event->key = *key;
407 init_stats(&event->total.stats);
407 return event; 408 return event;
408} 409}
409 410
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index eb524f91bffe..8ce62ef7f6c3 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -374,7 +374,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
374 374
375 session = perf_session__new(file, false, NULL); 375 session = perf_session__new(file, false, NULL);
376 if (session == NULL) { 376 if (session == NULL) {
377 pr_err("Not enough memory for reading perf file header\n"); 377 pr_err("Perf session creation failed.\n");
378 return -1; 378 return -1;
379 } 379 }
380 380
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index ee21fa95ebcf..802cf544202b 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -34,6 +34,14 @@ ifeq ($(ARCH),arm)
34 LIBUNWIND_LIBS = -lunwind -lunwind-arm 34 LIBUNWIND_LIBS = -lunwind -lunwind-arm
35endif 35endif
36 36
37# So far there's only x86 libdw unwind support merged in perf.
38# Disable it on all other architectures in case libdw unwind
39# support is detected in system. Add supported architectures
40# to the check.
41ifneq ($(ARCH),x86)
42 NO_LIBDW_DWARF_UNWIND := 1
43endif
44
37ifeq ($(LIBUNWIND_LIBS),) 45ifeq ($(LIBUNWIND_LIBS),)
38 NO_LIBUNWIND := 1 46 NO_LIBUNWIND := 1
39else 47else
@@ -109,6 +117,10 @@ CFLAGS += -Wall
109CFLAGS += -Wextra 117CFLAGS += -Wextra
110CFLAGS += -std=gnu99 118CFLAGS += -std=gnu99
111 119
120# Enforce a non-executable stack, as we may regress (again) in the future by
121# adding assembler files missing the .GNU-stack linker note.
122LDFLAGS += -Wl,-z,noexecstack
123
112EXTLIBS = -lelf -lpthread -lrt -lm -ldl 124EXTLIBS = -lelf -lpthread -lrt -lm -ldl
113 125
114ifneq ($(OUTPUT),) 126ifneq ($(OUTPUT),)
@@ -186,7 +198,10 @@ VF_FEATURE_TESTS = \
186 stackprotector-all \ 198 stackprotector-all \
187 timerfd \ 199 timerfd \
188 libunwind-debug-frame \ 200 libunwind-debug-frame \
189 bionic 201 bionic \
202 liberty \
203 liberty-z \
204 cplus-demangle
190 205
191# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features. 206# Set FEATURE_CHECK_(C|LD)FLAGS-all for all CORE_FEATURE_TESTS features.
192# If in the future we need per-feature checks/flags for features not 207# If in the future we need per-feature checks/flags for features not
@@ -504,7 +519,21 @@ else
504endif 519endif
505 520
506ifeq ($(feature-libbfd), 1) 521ifeq ($(feature-libbfd), 1)
507 EXTLIBS += -lbfd -lz -liberty 522 EXTLIBS += -lbfd
523
524 # call all detections now so we get correct
525 # status in VF output
526 $(call feature_check,liberty)
527 $(call feature_check,liberty-z)
528 $(call feature_check,cplus-demangle)
529
530 ifeq ($(feature-liberty), 1)
531 EXTLIBS += -liberty
532 else
533 ifeq ($(feature-liberty-z), 1)
534 EXTLIBS += -liberty -lz
535 endif
536 endif
508endif 537endif
509 538
510ifdef NO_DEMANGLE 539ifdef NO_DEMANGLE
@@ -515,15 +544,10 @@ else
515 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 544 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
516 else 545 else
517 ifneq ($(feature-libbfd), 1) 546 ifneq ($(feature-libbfd), 1)
518 $(call feature_check,liberty) 547 ifneq ($(feature-liberty), 1)
519 ifeq ($(feature-liberty), 1) 548 ifneq ($(feature-liberty-z), 1)
520 EXTLIBS += -lbfd -liberty 549 # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
521 else 550 # or any of 'bfd iberty z' trinity
522 $(call feature_check,liberty-z)
523 ifeq ($(feature-liberty-z), 1)
524 EXTLIBS += -lbfd -liberty -lz
525 else
526 $(call feature_check,cplus-demangle)
527 ifeq ($(feature-cplus-demangle), 1) 551 ifeq ($(feature-cplus-demangle), 1)
528 EXTLIBS += -liberty 552 EXTLIBS += -liberty
529 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT 553 CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 5daeae1cb4c0..2f92d6e7ee00 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -46,6 +46,7 @@ make_install_man := install-man
46make_install_html := install-html 46make_install_html := install-html
47make_install_info := install-info 47make_install_info := install-info
48make_install_pdf := install-pdf 48make_install_pdf := install-pdf
49make_static := LDFLAGS=-static
49 50
50# all the NO_* variable combined 51# all the NO_* variable combined
51make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 52make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
@@ -87,6 +88,7 @@ run += make_install_bin
87# run += make_install_info 88# run += make_install_info
88# run += make_install_pdf 89# run += make_install_pdf
89run += make_minimal 90run += make_minimal
91run += make_static
90 92
91ifneq ($(call has,ctags),) 93ifneq ($(call has,ctags),)
92run += make_tags 94run += make_tags
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 1fbcd8bdc11b..55de44ecebef 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -86,10 +86,17 @@ static int open_file_read(struct perf_data_file *file)
86 86
87static int open_file_write(struct perf_data_file *file) 87static int open_file_write(struct perf_data_file *file)
88{ 88{
89 int fd;
90
89 if (check_backup(file)) 91 if (check_backup(file))
90 return -1; 92 return -1;
91 93
92 return open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); 94 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
95
96 if (fd < 0)
97 pr_err("failed to open %s : %s\n", file->path, strerror(errno));
98
99 return fd;
93} 100}
94 101
95static int open_file(struct perf_data_file *file) 102static int open_file(struct perf_data_file *file)
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index a53cd0b8c151..27c2a5efe450 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -717,7 +717,7 @@ static char *get_kernel_version(const char *root_dir)
717} 717}
718 718
719static int map_groups__set_modules_path_dir(struct map_groups *mg, 719static int map_groups__set_modules_path_dir(struct map_groups *mg,
720 const char *dir_name) 720 const char *dir_name, int depth)
721{ 721{
722 struct dirent *dent; 722 struct dirent *dent;
723 DIR *dir = opendir(dir_name); 723 DIR *dir = opendir(dir_name);
@@ -742,7 +742,15 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg,
742 !strcmp(dent->d_name, "..")) 742 !strcmp(dent->d_name, ".."))
743 continue; 743 continue;
744 744
745 ret = map_groups__set_modules_path_dir(mg, path); 745 /* Do not follow top-level source and build symlinks */
746 if (depth == 0) {
747 if (!strcmp(dent->d_name, "source") ||
748 !strcmp(dent->d_name, "build"))
749 continue;
750 }
751
752 ret = map_groups__set_modules_path_dir(mg, path,
753 depth + 1);
746 if (ret < 0) 754 if (ret < 0)
747 goto out; 755 goto out;
748 } else { 756 } else {
@@ -786,11 +794,11 @@ static int machine__set_modules_path(struct machine *machine)
786 if (!version) 794 if (!version)
787 return -1; 795 return -1;
788 796
789 snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s/kernel", 797 snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s",
790 machine->root_dir, version); 798 machine->root_dir, version);
791 free(version); 799 free(version);
792 800
793 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path); 801 return map_groups__set_modules_path_dir(&machine->kmaps, modules_path, 0);
794} 802}
795 803
796static int machine__create_module(void *arg, const char *name, u64 start) 804static int machine__create_module(void *arg, const char *name, u64 start)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 3b7dbf51d4a9..6864661a79dd 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -6,6 +6,7 @@
6#include <inttypes.h> 6#include <inttypes.h>
7 7
8#include "symbol.h" 8#include "symbol.h"
9#include "vdso.h"
9#include <symbol/kallsyms.h> 10#include <symbol/kallsyms.h>
10#include "debug.h" 11#include "debug.h"
11 12
@@ -618,6 +619,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
618 GElf_Shdr shdr; 619 GElf_Shdr shdr;
619 ss->adjust_symbols = (ehdr.e_type == ET_EXEC || 620 ss->adjust_symbols = (ehdr.e_type == ET_EXEC ||
620 ehdr.e_type == ET_REL || 621 ehdr.e_type == ET_REL ||
622 is_vdso_map(dso->short_name) ||
621 elf_section_by_name(elf, &ehdr, &shdr, 623 elf_section_by_name(elf, &ehdr, &shdr,
622 ".gnu.prelink_undo", 624 ".gnu.prelink_undo",
623 NULL) != NULL); 625 NULL) != NULL);
diff --git a/tools/power/acpi/Makefile b/tools/power/acpi/Makefile
index d9186a2fdf06..c2c0f20067a5 100644
--- a/tools/power/acpi/Makefile
+++ b/tools/power/acpi/Makefile
@@ -89,15 +89,6 @@ else
89 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment 89 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
90endif 90endif
91 91
92# if DEBUG is enabled, then we do not strip or optimize
93ifeq ($(strip $(DEBUG)),true)
94 CFLAGS += -O1 -g -DDEBUG
95 STRIPCMD = /bin/true -Since_we_are_debugging
96else
97 CFLAGS += $(OPTIMIZATION) -fomit-frame-pointer
98 STRIPCMD = $(STRIP) -s --remove-section=.note --remove-section=.comment
99endif
100
101# --- ACPIDUMP BEGIN --- 92# --- ACPIDUMP BEGIN ---
102 93
103vpath %.c \ 94vpath %.c \
@@ -128,7 +119,7 @@ clean:
128 -rm -f $(OUTPUT)acpidump 119 -rm -f $(OUTPUT)acpidump
129 120
130install-tools: 121install-tools:
131 $(INSTALL) -d $(DESTDIR)${bindir} 122 $(INSTALL) -d $(DESTDIR)${sbindir}
132 $(INSTALL_PROGRAM) $(OUTPUT)acpidump $(DESTDIR)${sbindir} 123 $(INSTALL_PROGRAM) $(OUTPUT)acpidump $(DESTDIR)${sbindir}
133 124
134install-man: 125install-man:
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 47b29834a6b6..56ff9bebb577 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -548,11 +548,10 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
548 u32 val; 548 u32 val;
549 u32 *reg; 549 u32 *reg;
550 550
551 offset >>= 1;
552 reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg, 551 reg = vgic_bitmap_get_reg(&vcpu->kvm->arch.vgic.irq_cfg,
553 vcpu->vcpu_id, offset); 552 vcpu->vcpu_id, offset >> 1);
554 553
555 if (offset & 2) 554 if (offset & 4)
556 val = *reg >> 16; 555 val = *reg >> 16;
557 else 556 else
558 val = *reg & 0xffff; 557 val = *reg & 0xffff;
@@ -561,13 +560,13 @@ static bool handle_mmio_cfg_reg(struct kvm_vcpu *vcpu,
561 vgic_reg_access(mmio, &val, offset, 560 vgic_reg_access(mmio, &val, offset,
562 ACCESS_READ_VALUE | ACCESS_WRITE_VALUE); 561 ACCESS_READ_VALUE | ACCESS_WRITE_VALUE);
563 if (mmio->is_write) { 562 if (mmio->is_write) {
564 if (offset < 4) { 563 if (offset < 8) {
565 *reg = ~0U; /* Force PPIs/SGIs to 1 */ 564 *reg = ~0U; /* Force PPIs/SGIs to 1 */
566 return false; 565 return false;
567 } 566 }
568 567
569 val = vgic_cfg_compress(val); 568 val = vgic_cfg_compress(val);
570 if (offset & 2) { 569 if (offset & 4) {
571 *reg &= 0xffff; 570 *reg &= 0xffff;
572 *reg |= val << 16; 571 *reg |= val << 16;
573 } else { 572 } else {
@@ -916,6 +915,7 @@ static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg)
916 case 0: 915 case 0:
917 if (!target_cpus) 916 if (!target_cpus)
918 return; 917 return;
918 break;
919 919
920 case 1: 920 case 1:
921 target_cpus = ((1 << nrcpus) - 1) & ~(1 << vcpu_id) & 0xff; 921 target_cpus = ((1 << nrcpus) - 1) & ~(1 << vcpu_id) & 0xff;
@@ -1667,10 +1667,11 @@ static int vgic_ioaddr_assign(struct kvm *kvm, phys_addr_t *ioaddr,
1667 if (addr + size < addr) 1667 if (addr + size < addr)
1668 return -EINVAL; 1668 return -EINVAL;
1669 1669
1670 *ioaddr = addr;
1670 ret = vgic_ioaddr_overlap(kvm); 1671 ret = vgic_ioaddr_overlap(kvm);
1671 if (ret) 1672 if (ret)
1672 return ret; 1673 *ioaddr = VGIC_ADDR_UNDEF;
1673 *ioaddr = addr; 1674
1674 return ret; 1675 return ret;
1675} 1676}
1676 1677
diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
index 8db43701016f..bf06577fea51 100644
--- a/virt/kvm/assigned-dev.c
+++ b/virt/kvm/assigned-dev.c
@@ -395,7 +395,8 @@ static int assigned_device_enable_host_msix(struct kvm *kvm,
395 if (dev->entries_nr == 0) 395 if (dev->entries_nr == 0)
396 return r; 396 return r;
397 397
398 r = pci_enable_msix(dev->dev, dev->host_msix_entries, dev->entries_nr); 398 r = pci_enable_msix_exact(dev->dev,
399 dev->host_msix_entries, dev->entries_nr);
399 if (r) 400 if (r)
400 return r; 401 return r;
401 402
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index 10df100c4514..06e6401d6ef4 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -101,7 +101,7 @@ static void async_pf_execute(struct work_struct *work)
101 if (waitqueue_active(&vcpu->wq)) 101 if (waitqueue_active(&vcpu->wq))
102 wake_up_interruptible(&vcpu->wq); 102 wake_up_interruptible(&vcpu->wq);
103 103
104 mmdrop(mm); 104 mmput(mm);
105 kvm_put_kvm(vcpu->kvm); 105 kvm_put_kvm(vcpu->kvm);
106} 106}
107 107
@@ -118,7 +118,7 @@ void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu)
118 flush_work(&work->work); 118 flush_work(&work->work);
119#else 119#else
120 if (cancel_work_sync(&work->work)) { 120 if (cancel_work_sync(&work->work)) {
121 mmdrop(work->mm); 121 mmput(work->mm);
122 kvm_put_kvm(vcpu->kvm); /* == work->vcpu->kvm */ 122 kvm_put_kvm(vcpu->kvm); /* == work->vcpu->kvm */
123 kmem_cache_free(async_pf_cache, work); 123 kmem_cache_free(async_pf_cache, work);
124 } 124 }
@@ -183,7 +183,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva,
183 work->addr = hva; 183 work->addr = hva;
184 work->arch = *arch; 184 work->arch = *arch;
185 work->mm = current->mm; 185 work->mm = current->mm;
186 atomic_inc(&work->mm->mm_count); 186 atomic_inc(&work->mm->mm_users);
187 kvm_get_kvm(work->vcpu->kvm); 187 kvm_get_kvm(work->vcpu->kvm);
188 188
189 /* this can't really happen otherwise gfn_to_pfn_async 189 /* this can't really happen otherwise gfn_to_pfn_async
@@ -201,7 +201,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva,
201 return 1; 201 return 1;
202retry_sync: 202retry_sync:
203 kvm_put_kvm(work->vcpu->kvm); 203 kvm_put_kvm(work->vcpu->kvm);
204 mmdrop(work->mm); 204 mmput(work->mm);
205 kmem_cache_free(async_pf_cache, work); 205 kmem_cache_free(async_pf_cache, work);
206 return 0; 206 return 0;
207} 207}