aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/ata/sata_rcar.txt6
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/interrupts.txt4
-rw-r--r--Documentation/devicetree/bindings/pci/pci.txt11
-rw-r--r--Documentation/devicetree/bindings/pinctrl/img,tz1090-pdc-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/img,tz1090-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/lantiq,falcon-pinumx.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/lantiq,xway-pinumx.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/pinctrl_spear.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,apq8084-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,ipq8064-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,msm8960-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/qcom,msm8974-pinctrl.txt2
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt5
-rw-r--r--Documentation/filesystems/overlayfs.txt2
-rw-r--r--Documentation/input/elantech.txt81
-rw-r--r--Documentation/networking/ip-sysctl.txt14
-rw-r--r--Documentation/networking/timestamping.txt2
-rw-r--r--MAINTAINERS42
-rw-r--r--Makefile7
-rw-r--r--arch/arm/boot/compressed/head.S20
-rw-r--r--arch/arm/boot/dts/am335x-evm.dts2
-rw-r--r--arch/arm/boot/dts/am437x-gp-evm.dts4
-rw-r--r--arch/arm/boot/dts/am437x-sk-evm.dts4
-rw-r--r--arch/arm/boot/dts/am43x-epos-evm.dts4
-rw-r--r--arch/arm/boot/dts/exynos5250-snow.dts4
-rw-r--r--arch/arm/boot/dts/exynos5250.dtsi2
-rw-r--r--arch/arm/boot/dts/r8a7740.dtsi2
-rw-r--r--arch/arm/boot/dts/r8a7790.dtsi4
-rw-r--r--arch/arm/boot/dts/sama5d31.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d33.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d34.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d35.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d36.dtsi2
-rw-r--r--arch/arm/boot/dts/sama5d3xcm.dtsi2
-rw-r--r--arch/arm/boot/dts/sun6i-a31.dtsi4
-rw-r--r--arch/arm/boot/dts/tegra114-dalmore.dts1
-rw-r--r--arch/arm/boot/dts/tegra114-roth.dts9
-rw-r--r--arch/arm/boot/dts/tegra114-tn7.dts5
-rw-r--r--arch/arm/boot/dts/tegra114.dtsi7
-rw-r--r--arch/arm/boot/dts/tegra124-jetson-tk1.dts1
-rw-r--r--arch/arm/boot/dts/tegra124-nyan-big.dts1
-rw-r--r--arch/arm/boot/dts/tegra124-venice2.dts1
-rw-r--r--arch/arm/boot/dts/tegra124.dtsi8
-rw-r--r--arch/arm/boot/dts/tegra20-harmony.dts1
-rw-r--r--arch/arm/boot/dts/tegra20-iris-512.dts5
-rw-r--r--arch/arm/boot/dts/tegra20-medcom-wide.dts4
-rw-r--r--arch/arm/boot/dts/tegra20-paz00.dts2
-rw-r--r--arch/arm/boot/dts/tegra20-seaboard.dts1
-rw-r--r--arch/arm/boot/dts/tegra20-tamonten.dtsi1
-rw-r--r--arch/arm/boot/dts/tegra20-trimslice.dts1
-rw-r--r--arch/arm/boot/dts/tegra20-ventana.dts1
-rw-r--r--arch/arm/boot/dts/tegra20-whistler.dts1
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi8
-rw-r--r--arch/arm/boot/dts/tegra30-apalis-eval.dts4
-rw-r--r--arch/arm/boot/dts/tegra30-beaver.dts1
-rw-r--r--arch/arm/boot/dts/tegra30-cardhu.dtsi2
-rw-r--r--arch/arm/boot/dts/tegra30-colibri-eval-v3.dts3
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi8
-rw-r--r--arch/arm/configs/exynos_defconfig2
-rw-r--r--arch/arm/configs/multi_v7_defconfig1
-rw-r--r--arch/arm/include/asm/thread_info.h11
-rw-r--r--arch/arm/kernel/traps.c31
-rw-r--r--arch/arm/kvm/mmu.c10
-rw-r--r--arch/arm/mach-mvebu/board-v7.c2
-rw-r--r--arch/arm/mach-mvebu/coherency.c2
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c9
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7790.c2
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c20
-rw-r--r--arch/arm/mach-tegra/irq.c22
-rw-r--r--arch/arm/mm/Kconfig1
-rw-r--r--arch/arm/mm/proc-v7.S2
-rw-r--r--arch/arm/mm/proc-xscale.S4
-rw-r--r--arch/arm/plat-orion/gpio.c36
-rw-r--r--arch/arm64/boot/dts/apm-storm.dtsi10
-rw-r--r--arch/arm64/include/asm/memory.h2
-rw-r--r--arch/arm64/kernel/efi-entry.S27
-rw-r--r--arch/arm64/kernel/insn.c5
-rw-r--r--arch/arm64/kvm/sys_regs.c9
-rw-r--r--arch/arm64/lib/clear_user.S2
-rw-r--r--arch/arm64/mm/mmu.c2
-rw-r--r--arch/ia64/kvm/kvm-ia64.c2
-rw-r--r--arch/mips/Kconfig14
-rw-r--r--arch/mips/include/asm/jump_label.h8
-rw-r--r--arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h2
-rw-r--r--arch/mips/include/asm/mipsregs.h2
-rw-r--r--arch/mips/include/asm/r4kcache.h4
-rw-r--r--arch/mips/include/asm/uaccess.h18
-rw-r--r--arch/mips/include/uapi/asm/unistd.h2
-rw-r--r--arch/mips/kernel/bmips_vec.S3
-rw-r--r--arch/mips/kernel/cps-vec.S2
-rw-r--r--arch/mips/kernel/cpu-probe.c40
-rw-r--r--arch/mips/kernel/jump_label.c42
-rw-r--r--arch/mips/kernel/rtlx.c4
-rw-r--r--arch/mips/kernel/setup.c4
-rw-r--r--arch/mips/kernel/signal.c8
-rw-r--r--arch/mips/lib/memcpy.S1
-rw-r--r--arch/mips/loongson/common/Makefile3
-rw-r--r--arch/mips/loongson/loongson-3/numa.c1
-rw-r--r--arch/mips/mm/tlb-r4k.c4
-rw-r--r--arch/mips/mm/tlbex.c10
-rw-r--r--arch/mips/mti-sead3/sead3-leds.c8
-rw-r--r--arch/mips/netlogic/xlp/Makefile12
-rw-r--r--arch/mips/oprofile/backtrace.c2
-rw-r--r--arch/mips/sgi-ip27/ip27-memory.c1
-rw-r--r--arch/parisc/include/asm/uaccess.h19
-rw-r--r--arch/parisc/include/uapi/asm/bitsperlong.h8
-rw-r--r--arch/parisc/include/uapi/asm/msgbuf.h8
-rw-r--r--arch/parisc/include/uapi/asm/sembuf.h6
-rw-r--r--arch/parisc/include/uapi/asm/shmbuf.h35
-rw-r--r--arch/parisc/include/uapi/asm/signal.h2
-rw-r--r--arch/parisc/include/uapi/asm/unistd.h3
-rw-r--r--arch/parisc/kernel/syscall_table.S9
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h2
-rw-r--r--arch/powerpc/kernel/eeh_sysfs.c2
-rw-r--r--arch/powerpc/kernel/pci_64.c10
-rw-r--r--arch/powerpc/kernel/vdso32/getcpu.S4
-rw-r--r--arch/powerpc/platforms/powernv/opal-hmi.c2
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c5
-rw-r--r--arch/powerpc/platforms/powernv/pci.c3
-rw-r--r--arch/powerpc/platforms/pseries/msi.c2
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c2
-rw-r--r--arch/powerpc/xmon/xmon.c6
-rw-r--r--arch/sparc/include/asm/atomic_32.h2
-rw-r--r--arch/sparc/include/asm/cmpxchg_32.h12
-rw-r--r--arch/sparc/include/asm/dma-mapping.h8
-rw-r--r--arch/sparc/include/uapi/asm/swab.h12
-rw-r--r--arch/sparc/kernel/pci_schizo.c6
-rw-r--r--arch/sparc/kernel/smp_64.c4
-rw-r--r--arch/sparc/lib/atomic32.c27
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/boot/compressed/Makefile4
-rw-r--r--arch/x86/boot/compressed/head_32.S5
-rw-r--r--arch/x86/boot/compressed/head_64.S5
-rw-r--r--arch/x86/boot/compressed/misc.c13
-rw-r--r--arch/x86/boot/compressed/mkpiggy.c9
-rw-r--r--arch/x86/include/asm/page_32_types.h1
-rw-r--r--arch/x86/include/asm/page_64_types.h11
-rw-r--r--arch/x86/include/asm/smp.h1
-rw-r--r--arch/x86/include/asm/thread_info.h2
-rw-r--r--arch/x86/include/asm/traps.h1
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/cpu/microcode/amd_early.c33
-rw-r--r--arch/x86/kernel/cpu/microcode/core.c8
-rw-r--r--arch/x86/kernel/cpu/microcode/core_early.c2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c49
-rw-r--r--arch/x86/kernel/dumpstack_64.c1
-rw-r--r--arch/x86/kernel/entry_64.S81
-rw-r--r--arch/x86/kernel/ptrace.c2
-rw-r--r--arch/x86/kernel/smpboot.c15
-rw-r--r--arch/x86/kernel/traps.c71
-rw-r--r--arch/x86/kvm/emulate.c8
-rw-r--r--arch/x86/kvm/mmu.c6
-rw-r--r--arch/x86/lib/csum-wrappers_64.c5
-rw-r--r--arch/x86/mm/init_64.c11
-rw-r--r--arch/x86/tools/calc_run_size.pl39
-rw-r--r--arch/x86/xen/smp.c3
-rw-r--r--arch/xtensa/Kconfig4
-rw-r--r--arch/xtensa/boot/dts/lx200mx.dts16
-rw-r--r--arch/xtensa/configs/generic_kc705_defconfig131
-rw-r--r--arch/xtensa/configs/smp_lx200_defconfig135
-rw-r--r--arch/xtensa/include/asm/pgtable.h2
-rw-r--r--arch/xtensa/include/uapi/asm/unistd.h12
-rw-r--r--block/blk-merge.c19
-rw-r--r--block/blk-mq.c41
-rw-r--r--block/ioprio.c14
-rw-r--r--block/scsi_ioctl.c8
-rw-r--r--drivers/acpi/blacklist.c8
-rw-r--r--drivers/acpi/device_pm.c2
-rw-r--r--drivers/ata/ahci.c28
-rw-r--r--drivers/ata/libahci.c78
-rw-r--r--drivers/ata/sata_rcar.c15
-rw-r--r--drivers/atm/solos-pci.c2
-rw-r--r--drivers/base/power/domain.c42
-rw-r--r--drivers/block/zram/zram_drv.c3
-rw-r--r--drivers/char/hw_random/pseries-rng.c11
-rw-r--r--drivers/char/virtio_console.c4
-rw-r--r--drivers/clk/at91/clk-usb.c35
-rw-r--r--drivers/clk/clk-divider.c18
-rw-r--r--drivers/clk/pxa/clk-pxa27x.c4
-rw-r--r--drivers/clk/qcom/mmcc-apq8084.c2
-rw-r--r--drivers/clk/rockchip/clk.c4
-rw-r--r--drivers/clocksource/sun4i_timer.c12
-rw-r--r--drivers/cpufreq/cpufreq-dt.c4
-rw-r--r--drivers/cpufreq/cpufreq.c3
-rw-r--r--drivers/crypto/caam/key_gen.c29
-rw-r--r--drivers/crypto/qat/qat_common/adf_accel_devices.h3
-rw-r--r--drivers/crypto/qat/qat_common/adf_transport.c12
-rw-r--r--drivers/crypto/qat/qat_common/qat_algs.c7
-rw-r--r--drivers/crypto/qat/qat_common/qat_crypto.c8
-rw-r--r--drivers/crypto/qat/qat_dh895xcc/adf_admin.c2
-rw-r--r--drivers/crypto/qat/qat_dh895xcc/adf_drv.c32
-rw-r--r--drivers/crypto/qat/qat_dh895xcc/adf_isr.c2
-rw-r--r--drivers/dma/pl330.c23
-rw-r--r--drivers/dma/sun6i-dma.c61
-rw-r--r--drivers/firewire/core-cdev.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c12
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c10
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c16
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c19
-rw-r--r--drivers/gpu/drm/i915/intel_display.c4
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c1
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c17
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/gk20a.c16
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c25
-rw-r--r--drivers/gpu/drm/radeon/atom.c11
-rw-r--r--drivers/gpu/drm/radeon/atom.h2
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_i2c.c4
-rw-r--r--drivers/gpu/drm/radeon/cik.c7
-rw-r--r--drivers/gpu/drm/radeon/cik_sdma.c21
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/r100.c3
-rw-r--r--drivers/gpu/drm/radeon/r600_dma.c20
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c10
-rw-r--r--drivers/gpu/drm/radeon/rs600.c3
-rw-r--r--drivers/gpu/drm/radeon/rs690.c3
-rw-r--r--drivers/gpu/drm/radeon/rv515.c3
-rw-r--r--drivers/gpu/drm/radeon/si.c3
-rw-r--r--drivers/gpu/drm/tegra/dc.c8
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hwmon/fam15h_power.c2
-rw-r--r--drivers/hwmon/g762.c6
-rw-r--r--drivers/hwmon/ibmpowernv.c6
-rw-r--r--drivers/hwmon/pwm-fan.c13
-rw-r--r--drivers/iio/accel/bmc150-accel.c40
-rw-r--r--drivers/iio/accel/kxcjk-1013.c2
-rw-r--r--drivers/iio/adc/men_z188_adc.c1
-rw-r--r--drivers/iio/gyro/bmg160.c53
-rw-r--r--drivers/infiniband/ulp/isert/ib_isert.c44
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c8
-rw-r--r--drivers/input/joystick/xpad.c16
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c1
-rw-r--r--drivers/input/mouse/alps.c28
-rw-r--r--drivers/input/mouse/elantech.c64
-rw-r--r--drivers/input/mouse/synaptics.c9
-rw-r--r--drivers/irqchip/irq-atmel-aic-common.c6
-rw-r--r--drivers/irqchip/irq-bcm7120-l2.c4
-rw-r--r--drivers/irqchip/irq-brcmstb-l2.c4
-rw-r--r--drivers/md/dm-bufio.c12
-rw-r--r--drivers/md/dm-raid.c17
-rw-r--r--drivers/md/dm-stripe.c4
-rw-r--r--drivers/md/dm-thin.c16
-rw-r--r--drivers/md/md.c4
-rw-r--r--drivers/md/persistent-data/dm-btree-internal.h6
-rw-r--r--drivers/md/persistent-data/dm-btree-spine.c2
-rw-r--r--drivers/md/persistent-data/dm-btree.c24
-rw-r--r--drivers/mfd/max77693.c14
-rw-r--r--drivers/mfd/rtsx_pcr.c2
-rw-r--r--drivers/mfd/stmpe.h2
-rw-r--r--drivers/mfd/twl4030-power.c52
-rw-r--r--drivers/mfd/viperboard.c5
-rw-r--r--drivers/net/bonding/bond_main.c3
-rw-r--r--drivers/net/can/dev.c4
-rw-r--r--drivers/net/can/m_can/Kconfig1
-rw-r--r--drivers/net/can/m_can/m_can.c219
-rw-r--r--drivers/net/can/rcar_can.c1
-rw-r--r--drivers/net/can/sja1000/kvaser_pci.c5
-rw-r--r--drivers/net/can/usb/ems_usb.c3
-rw-r--r--drivers/net/can/usb/esd_usb2.c3
-rw-r--r--drivers/net/can/usb/gs_usb.c1
-rw-r--r--drivers/net/can/xilinx_can.c4
-rw-r--r--drivers/net/dsa/bcm_sf2.c58
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c18
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.h4
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.c11
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.h5
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c7
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c7
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c13
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c11
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.h3
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c9
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c3
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c33
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c30
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c51
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_regs.h10
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/adapter.h8
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/sge.c136
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c28
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c20
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c11
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c39
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c23
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c17
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c4
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c18
-rw-r--r--drivers/net/ethernet/marvell/mvpp2.c27
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c35
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c4
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c3
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c6
-rw-r--r--drivers/net/ethernet/qualcomm/Kconfig3
-rw-r--r--drivers/net/ethernet/sfc/ef10.c3
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c20
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c61
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c52
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c13
-rw-r--r--drivers/net/ethernet/sun/sunhme.c62
-rw-r--r--drivers/net/ethernet/ti/cpsw.c6
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.c1
-rw-r--r--drivers/net/ethernet/ti/cpts.c2
-rw-r--r--drivers/net/ieee802154/fakehard.c13
-rw-r--r--drivers/net/macvtap.c2
-rw-r--r--drivers/net/phy/dp83640.c4
-rw-r--r--drivers/net/phy/phy.c36
-rw-r--r--drivers/net/ppp/ppp_generic.c40
-rw-r--r--drivers/net/ppp/pptp.c4
-rw-r--r--drivers/net/tun.c28
-rw-r--r--drivers/net/usb/asix_devices.c14
-rw-r--r--drivers/net/usb/qmi_wwan.c1
-rw-r--r--drivers/net/virtio_net.c37
-rw-r--r--drivers/net/vxlan.c41
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c13
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c9
-rw-r--r--drivers/net/wireless/b43/phy_common.c4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/of.c4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/pcie.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c6
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fw.h2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw.c10
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c13
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mvm.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/ops.c12
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c20
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c7
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c50
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c39
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/hw.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/phy.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c16
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8821ae/hw.c5
-rw-r--r--drivers/net/xen-netback/xenbus.c15
-rw-r--r--drivers/of/address.c19
-rw-r--r--drivers/of/dynamic.c2
-rw-r--r--drivers/of/fdt.c2
-rw-r--r--drivers/of/selftest.c11
-rw-r--r--drivers/pci/access.c2
-rw-r--r--drivers/pci/host/pci-xgene.c7
-rw-r--r--drivers/pci/msi.c26
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/probe.c30
-rw-r--r--drivers/platform/x86/Kconfig1
-rw-r--r--drivers/platform/x86/hp_accel.c44
-rw-r--r--drivers/power/ab8500_fg.c17
-rw-r--r--drivers/power/bq2415x_charger.c23
-rw-r--r--drivers/power/charger-manager.c164
-rw-r--r--drivers/power/power_supply_core.c3
-rw-r--r--drivers/s390/kvm/virtio_ccw.c1
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_els.c2
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c7
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_io.c19
-rw-r--r--drivers/scsi/cxgbi/cxgb4i/cxgb4i.c17
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c20
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c7
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c2
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/scsi/scsi_error.c20
-rw-r--r--drivers/scsi/ufs/ufshcd-pltfrm.c15
-rw-r--r--drivers/scsi/ufs/ufshcd.c104
-rw-r--r--drivers/scsi/ufs/ufshcd.h2
-rw-r--r--drivers/spi/spi-dw.c6
-rw-r--r--drivers/spi/spi-sirf.c4
-rw-r--r--drivers/spi/spi.c6
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_cmd.c22
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme_ext.c12
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_wlan_util.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c1
-rw-r--r--drivers/target/iscsi/iscsi_target.c2
-rw-r--r--drivers/target/target_core_pr.c9
-rw-r--r--drivers/target/target_core_transport.c2
-rw-r--r--drivers/thermal/cpu_cooling.c37
-rw-r--r--drivers/thermal/imx_thermal.c45
-rw-r--r--drivers/thermal/int340x_thermal/int3403_thermal.c8
-rw-r--r--drivers/thermal/samsung/exynos_thermal_common.c9
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c1
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.h1
-rw-r--r--drivers/thermal/st/st_thermal.c3
-rw-r--r--drivers/tty/serial/of_serial.c27
-rw-r--r--drivers/usb/core/quirks.c3
-rw-r--r--drivers/usb/dwc3/ep0.c8
-rw-r--r--drivers/usb/host/xhci-hub.c5
-rw-r--r--drivers/usb/host/xhci-pci.c2
-rw-r--r--drivers/usb/host/xhci-plat.c10
-rw-r--r--drivers/usb/host/xhci-ring.c43
-rw-r--r--drivers/usb/host/xhci.c107
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c33
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h39
-rw-r--r--drivers/usb/serial/keyspan.c97
-rw-r--r--drivers/usb/serial/ssu100.c11
-rw-r--r--drivers/usb/storage/unusual_uas.h7
-rw-r--r--drivers/vhost/scsi.c24
-rw-r--r--fs/Makefile2
-rw-r--r--fs/aio.c21
-rw-r--r--fs/btrfs/compression.c33
-rw-r--r--fs/btrfs/compression.h4
-rw-r--r--fs/btrfs/ctree.c14
-rw-r--r--fs/btrfs/locking.c24
-rw-r--r--fs/btrfs/locking.h2
-rw-r--r--fs/btrfs/lzo.c15
-rw-r--r--fs/btrfs/zlib.c20
-rw-r--r--fs/ceph/caps.c2
-rw-r--r--fs/dcache.c1
-rw-r--r--fs/isofs/inode.c42
-rw-r--r--fs/nfs/blocklayout/blocklayout.c2
-rw-r--r--fs/nfs/blocklayout/rpc_pipefs.c14
-rw-r--r--fs/nfs/delegation.c25
-rw-r--r--fs/nfs/delegation.h1
-rw-r--r--fs/nfs/dir.c1
-rw-r--r--fs/nfs/direct.c1
-rw-r--r--fs/nfs/filelayout/filelayout.c3
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/netns.h1
-rw-r--r--fs/nfs/nfs4proc.c95
-rw-r--r--fs/nfs/write.c2
-rw-r--r--fs/nfsd/nfs4callback.c8
-rw-r--r--fs/nfsd/nfsd.h9
-rw-r--r--fs/notify/fsnotify.c36
-rw-r--r--fs/notify/fsnotify.h4
-rw-r--r--fs/notify/inode_mark.c8
-rw-r--r--fs/notify/mark.c36
-rw-r--r--fs/notify/vfsmount_mark.c8
-rw-r--r--fs/overlayfs/Kconfig2
-rw-r--r--fs/overlayfs/Makefile4
-rw-r--r--fs/overlayfs/dir.c31
-rw-r--r--fs/overlayfs/inode.c27
-rw-r--r--fs/overlayfs/readdir.c39
-rw-r--r--fs/overlayfs/super.c61
-rw-r--r--include/dt-bindings/clock/qcom,mmcc-apq8084.h2
-rw-r--r--include/dt-bindings/pinctrl/dra.h4
-rw-r--r--include/linux/bitops.h7
-rw-r--r--include/linux/bootmem.h1
-rw-r--r--include/linux/can/dev.h6
-rw-r--r--include/linux/clk-provider.h1
-rw-r--r--include/linux/iio/events.h2
-rw-r--r--include/linux/inetdevice.h2
-rw-r--r--include/linux/kernel_stat.h5
-rw-r--r--include/linux/kvm_host.h2
-rw-r--r--include/linux/mfd/max77693-private.h7
-rw-r--r--include/linux/mmzone.h9
-rw-r--r--include/linux/nfs_xdr.h11
-rw-r--r--include/linux/page-isolation.h8
-rw-r--r--include/linux/pci.h1
-rw-r--r--include/linux/percpu-refcount.h8
-rw-r--r--include/linux/pm_domain.h8
-rw-r--r--include/linux/power/charger-manager.h3
-rw-r--r--include/linux/power_supply.h6
-rw-r--r--include/linux/ring_buffer.h2
-rw-r--r--include/linux/socket.h2
-rw-r--r--include/net/9p/transport.h1
-rw-r--r--include/net/inet_common.h2
-rw-r--r--include/net/netfilter/nf_tables.h2
-rw-r--r--include/net/udp_tunnel.h9
-rw-r--r--include/net/vxlan.h18
-rw-r--r--include/sound/pcm.h2
-rw-r--r--include/sound/soc-dpcm.h2
-rw-r--r--include/uapi/linux/Kbuild4
-rw-r--r--include/uapi/linux/if_bridge.h1
-rw-r--r--include/uapi/sound/asound.h4
-rw-r--r--init/main.c2
-rw-r--r--kernel/audit.c2
-rw-r--r--kernel/audit_tree.c1
-rw-r--r--kernel/events/core.c8
-rw-r--r--kernel/events/uprobes.c1
-rw-r--r--kernel/panic.c1
-rw-r--r--kernel/power/suspend.c4
-rw-r--r--kernel/sched/core.c63
-rw-r--r--kernel/sched/deadline.c2
-rw-r--r--kernel/sched/fair.c14
-rw-r--r--kernel/sched/idle_task.c5
-rw-r--r--kernel/sched/rt.c2
-rw-r--r--kernel/sched/sched.h2
-rw-r--r--kernel/sched/stop_task.c5
-rw-r--r--kernel/time/posix-cpu-timers.c2
-rw-r--r--kernel/trace/ring_buffer.c81
-rw-r--r--kernel/trace/trace.c33
-rw-r--r--lib/Makefile4
-rw-r--r--lib/rhashtable.c10
-rw-r--r--mm/bootmem.c9
-rw-r--r--mm/compaction.c18
-rw-r--r--mm/internal.h25
-rw-r--r--mm/iov_iter.c4
-rw-r--r--mm/memory_hotplug.c26
-rw-r--r--mm/nobootmem.c8
-rw-r--r--mm/page_alloc.c68
-rw-r--r--mm/page_isolation.c43
-rw-r--r--mm/slab_common.c4
-rw-r--r--net/bridge/br_multicast.c3
-rw-r--r--net/bridge/br_netlink.c1
-rw-r--r--net/bridge/netfilter/nft_reject_bridge.c1
-rw-r--r--net/ceph/crypto.c169
-rw-r--r--net/ceph/osd_client.c7
-rw-r--r--net/core/rtnetlink.c23
-rw-r--r--net/core/skbuff.c23
-rw-r--r--net/dcb/dcbnl.c36
-rw-r--r--net/dsa/slave.c7
-rw-r--r--net/ipv4/af_inet.c11
-rw-r--r--net/ipv4/fib_rules.c4
-rw-r--r--net/ipv4/fou.c2
-rw-r--r--net/ipv4/geneve.c3
-rw-r--r--net/ipv4/igmp.c11
-rw-r--r--net/ipv4/ip_sockglue.c2
-rw-r--r--net/ipv4/ip_vti.c1
-rw-r--r--net/ipv4/netfilter/nft_masq_ipv4.c1
-rw-r--r--net/ipv4/ping.c14
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_input.c64
-rw-r--r--net/ipv4/tcp_ipv4.c5
-rw-r--r--net/ipv6/ip6_gre.c9
-rw-r--r--net/ipv6/ip6_offload.c3
-rw-r--r--net/ipv6/ip6_tunnel.c10
-rw-r--r--net/ipv6/ip6_udp_tunnel.c4
-rw-r--r--net/ipv6/ip6_vti.c22
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/ipv6/mcast.c9
-rw-r--r--net/ipv6/netfilter/nft_masq_ipv6.c1
-rw-r--r--net/ipv6/sit.c15
-rw-r--r--net/ipv6/tcp_ipv6.c5
-rw-r--r--net/ipx/af_ipx.c6
-rw-r--r--net/mac80211/aes_ccm.c3
-rw-r--r--net/mac80211/ibss.c2
-rw-r--r--net/mac80211/ieee80211_i.h3
-rw-r--r--net/mac80211/iface.c18
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mlme.c5
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c15
-rw-r--r--net/mac80211/rx.c14
-rw-r--r--net/mac80211/spectmgmt.c18
-rw-r--r--net/netfilter/ipset/ip_set_core.c6
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c2
-rw-r--r--net/netfilter/nf_tables_api.c24
-rw-r--r--net/netfilter/nfnetlink.c12
-rw-r--r--net/netfilter/nft_compat.c40
-rw-r--r--net/netlink/af_netlink.c5
-rw-r--r--net/openvswitch/actions.c10
-rw-r--r--net/openvswitch/datapath.c14
-rw-r--r--net/openvswitch/flow_netlink.c9
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/sctp/auth.c2
-rw-r--r--net/sctp/sm_make_chunk.c3
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c35
-rw-r--r--net/sunrpc/svcsock.c27
-rw-r--r--security/selinux/hooks.c7
-rw-r--r--sound/core/pcm.c2
-rw-r--r--sound/core/pcm_misc.c8
-rw-r--r--sound/pci/hda/hda_intel.c28
-rw-r--r--sound/pci/hda/hda_priv.h1
-rw-r--r--sound/pci/hda/patch_conexant.c31
-rw-r--r--sound/pci/hda/patch_realtek.c114
-rw-r--r--sound/soc/codecs/cs42l51-i2c.c1
-rw-r--r--sound/soc/codecs/cs42l51.c4
-rw-r--r--sound/soc/codecs/cs42l51.h1
-rw-r--r--sound/soc/codecs/es8328-i2c.c2
-rw-r--r--sound/soc/codecs/max98090.c6
-rw-r--r--sound/soc/codecs/rt5645.c2
-rw-r--r--sound/soc/codecs/rt5670.c36
-rw-r--r--sound/soc/codecs/sgtl5000.c3
-rw-r--r--sound/soc/codecs/sgtl5000.h2
-rw-r--r--sound/soc/codecs/wm_adsp.c1
-rw-r--r--sound/soc/fsl/fsl_asrc.c26
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c4
-rw-r--r--sound/soc/samsung/snow.c1
-rw-r--r--sound/soc/sh/fsi.c3
-rw-r--r--sound/soc/sh/rcar/core.c3
-rw-r--r--sound/soc/soc-core.c2
-rw-r--r--sound/soc/soc-pcm.c72
-rw-r--r--sound/usb/mixer.c7
-rw-r--r--sound/usb/mixer_quirks.c10
-rw-r--r--sound/usb/quirks.c18
-rw-r--r--tools/testing/selftests/net/psock_fanout.c2
-rw-r--r--virt/kvm/arm/vgic.c8
-rw-r--r--virt/kvm/kvm_main.c16
590 files changed, 5467 insertions, 2560 deletions
diff --git a/Documentation/devicetree/bindings/ata/sata_rcar.txt b/Documentation/devicetree/bindings/ata/sata_rcar.txt
index 1e6111333fa8..80ae87a0784b 100644
--- a/Documentation/devicetree/bindings/ata/sata_rcar.txt
+++ b/Documentation/devicetree/bindings/ata/sata_rcar.txt
@@ -3,8 +3,10 @@
3Required properties: 3Required properties:
4- compatible : should contain one of the following: 4- compatible : should contain one of the following:
5 - "renesas,sata-r8a7779" for R-Car H1 5 - "renesas,sata-r8a7779" for R-Car H1
6 - "renesas,sata-r8a7790" for R-Car H2 6 - "renesas,sata-r8a7790-es1" for R-Car H2 ES1
7 - "renesas,sata-r8a7791" for R-Car M2 7 - "renesas,sata-r8a7790" for R-Car H2 other than ES1
8 - "renesas,sata-r8a7791" for R-Car M2-W
9 - "renesas,sata-r8a7793" for R-Car M2-N
8- reg : address and length of the SATA registers; 10- reg : address and length of the SATA registers;
9- interrupts : must consist of one interrupt specifier. 11- interrupts : must consist of one interrupt specifier.
10 12
diff --git a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
index ce6a1a072028..8a3c40829899 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
@@ -30,10 +30,6 @@ should only be used when a device has multiple interrupt parents.
30 Example: 30 Example:
31 interrupts-extended = <&intc1 5 1>, <&intc2 1 0>; 31 interrupts-extended = <&intc1 5 1>, <&intc2 1 0>;
32 32
33A device node may contain either "interrupts" or "interrupts-extended", but not
34both. If both properties are present, then the operating system should log an
35error and use only the data in "interrupts".
36
372) Interrupt controller nodes 332) Interrupt controller nodes
38----------------------------- 34-----------------------------
39 35
diff --git a/Documentation/devicetree/bindings/pci/pci.txt b/Documentation/devicetree/bindings/pci/pci.txt
index 41aeed38926d..f8fbe9af7b2f 100644
--- a/Documentation/devicetree/bindings/pci/pci.txt
+++ b/Documentation/devicetree/bindings/pci/pci.txt
@@ -7,3 +7,14 @@ And for the interrupt mapping part:
7 7
8Open Firmware Recommended Practice: Interrupt Mapping 8Open Firmware Recommended Practice: Interrupt Mapping
9http://www.openfirmware.org/1275/practice/imap/imap0_9d.pdf 9http://www.openfirmware.org/1275/practice/imap/imap0_9d.pdf
10
11Additionally to the properties specified in the above standards a host bridge
12driver implementation may support the following properties:
13
14- linux,pci-domain:
15 If present this property assigns a fixed PCI domain number to a host bridge,
16 otherwise an unstable (across boots) unique number will be assigned.
17 It is required to either not set this property at all or set it for all
18 host bridges in the system, otherwise potentially conflicting domain numbers
19 may be assigned to root buses behind different host bridges. The domain
20 number for each host bridge in the system must be unique.
diff --git a/Documentation/devicetree/bindings/pinctrl/img,tz1090-pdc-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/img,tz1090-pdc-pinctrl.txt
index a186181c402b..51b943cc9770 100644
--- a/Documentation/devicetree/bindings/pinctrl/img,tz1090-pdc-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/img,tz1090-pdc-pinctrl.txt
@@ -9,7 +9,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
9common pinctrl bindings used by client devices, including the meaning of the 9common pinctrl bindings used by client devices, including the meaning of the
10phrase "pin configuration node". 10phrase "pin configuration node".
11 11
12TZ1090-PDC's pin configuration nodes act as a container for an abitrary number 12TZ1090-PDC's pin configuration nodes act as a container for an arbitrary number
13of subnodes. Each of these subnodes represents some desired configuration for a 13of subnodes. Each of these subnodes represents some desired configuration for a
14pin, a group, or a list of pins or groups. This configuration can include the 14pin, a group, or a list of pins or groups. This configuration can include the
15mux function to select on those pin(s)/group(s), and various pin configuration 15mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/img,tz1090-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/img,tz1090-pinctrl.txt
index 4b27c99f7f9d..49d0e6050940 100644
--- a/Documentation/devicetree/bindings/pinctrl/img,tz1090-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/img,tz1090-pinctrl.txt
@@ -9,7 +9,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
9common pinctrl bindings used by client devices, including the meaning of the 9common pinctrl bindings used by client devices, including the meaning of the
10phrase "pin configuration node". 10phrase "pin configuration node".
11 11
12TZ1090's pin configuration nodes act as a container for an abitrary number of 12TZ1090's pin configuration nodes act as a container for an arbitrary number of
13subnodes. Each of these subnodes represents some desired configuration for a 13subnodes. Each of these subnodes represents some desired configuration for a
14pin, a group, or a list of pins or groups. This configuration can include the 14pin, a group, or a list of pins or groups. This configuration can include the
15mux function to select on those pin(s)/group(s), and various pin configuration 15mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/lantiq,falcon-pinumx.txt b/Documentation/devicetree/bindings/pinctrl/lantiq,falcon-pinumx.txt
index daa768956069..ac4da9fe07bd 100644
--- a/Documentation/devicetree/bindings/pinctrl/lantiq,falcon-pinumx.txt
+++ b/Documentation/devicetree/bindings/pinctrl/lantiq,falcon-pinumx.txt
@@ -9,7 +9,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
9common pinctrl bindings used by client devices, including the meaning of the 9common pinctrl bindings used by client devices, including the meaning of the
10phrase "pin configuration node". 10phrase "pin configuration node".
11 11
12Lantiq's pin configuration nodes act as a container for an abitrary number of 12Lantiq's pin configuration nodes act as a container for an arbitrary number of
13subnodes. Each of these subnodes represents some desired configuration for a 13subnodes. Each of these subnodes represents some desired configuration for a
14pin, a group, or a list of pins or groups. This configuration can include the 14pin, a group, or a list of pins or groups. This configuration can include the
15mux function to select on those group(s), and two pin configuration parameters: 15mux function to select on those group(s), and two pin configuration parameters:
diff --git a/Documentation/devicetree/bindings/pinctrl/lantiq,xway-pinumx.txt b/Documentation/devicetree/bindings/pinctrl/lantiq,xway-pinumx.txt
index b5469db1d7ad..e89b4677567d 100644
--- a/Documentation/devicetree/bindings/pinctrl/lantiq,xway-pinumx.txt
+++ b/Documentation/devicetree/bindings/pinctrl/lantiq,xway-pinumx.txt
@@ -9,7 +9,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
9common pinctrl bindings used by client devices, including the meaning of the 9common pinctrl bindings used by client devices, including the meaning of the
10phrase "pin configuration node". 10phrase "pin configuration node".
11 11
12Lantiq's pin configuration nodes act as a container for an abitrary number of 12Lantiq's pin configuration nodes act as a container for an arbitrary number of
13subnodes. Each of these subnodes represents some desired configuration for a 13subnodes. Each of these subnodes represents some desired configuration for a
14pin, a group, or a list of pins or groups. This configuration can include the 14pin, a group, or a list of pins or groups. This configuration can include the
15mux function to select on those group(s), and two pin configuration parameters: 15mux function to select on those group(s), and two pin configuration parameters:
diff --git a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
index 61e73cde9ae9..3c8ce28baad6 100644
--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
+++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
@@ -9,7 +9,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
9common pinctrl bindings used by client devices, including the meaning of the 9common pinctrl bindings used by client devices, including the meaning of the
10phrase "pin configuration node". 10phrase "pin configuration node".
11 11
12Tegra's pin configuration nodes act as a container for an abitrary number of 12Tegra's pin configuration nodes act as a container for an arbitrary number of
13subnodes. Each of these subnodes represents some desired configuration for a 13subnodes. Each of these subnodes represents some desired configuration for a
14pin, a group, or a list of pins or groups. This configuration can include the 14pin, a group, or a list of pins or groups. This configuration can include the
15mux function to select on those pin(s)/group(s), and various pin configuration 15mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt
index c596a6ad3285..5f55be59d914 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-sirf.txt
@@ -13,7 +13,7 @@ Optional properties:
13Please refer to pinctrl-bindings.txt in this directory for details of the common 13Please refer to pinctrl-bindings.txt in this directory for details of the common
14pinctrl bindings used by client devices. 14pinctrl bindings used by client devices.
15 15
16SiRFprimaII's pinmux nodes act as a container for an abitrary number of subnodes. 16SiRFprimaII's pinmux nodes act as a container for an arbitrary number of subnodes.
17Each of these subnodes represents some desired configuration for a group of pins. 17Each of these subnodes represents some desired configuration for a group of pins.
18 18
19Required subnode-properties: 19Required subnode-properties:
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl_spear.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl_spear.txt
index b4480d5c3aca..458615596946 100644
--- a/Documentation/devicetree/bindings/pinctrl/pinctrl_spear.txt
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl_spear.txt
@@ -32,7 +32,7 @@ Required properties:
32Please refer to pinctrl-bindings.txt in this directory for details of the common 32Please refer to pinctrl-bindings.txt in this directory for details of the common
33pinctrl bindings used by client devices. 33pinctrl bindings used by client devices.
34 34
35SPEAr's pinmux nodes act as a container for an abitrary number of subnodes. Each 35SPEAr's pinmux nodes act as a container for an arbitrary number of subnodes. Each
36of these subnodes represents muxing for a pin, a group, or a list of pins or 36of these subnodes represents muxing for a pin, a group, or a list of pins or
37groups. 37groups.
38 38
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
index 2fb90b37aa09..a7bde64798c7 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,apq8064-pinctrl.txt
@@ -18,7 +18,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
18common pinctrl bindings used by client devices, including the meaning of the 18common pinctrl bindings used by client devices, including the meaning of the
19phrase "pin configuration node". 19phrase "pin configuration node".
20 20
21Qualcomm's pin configuration nodes act as a container for an abitrary number of 21Qualcomm's pin configuration nodes act as a container for an arbitrary number of
22subnodes. Each of these subnodes represents some desired configuration for a 22subnodes. Each of these subnodes represents some desired configuration for a
23pin, a group, or a list of pins or groups. This configuration can include the 23pin, a group, or a list of pins or groups. This configuration can include the
24mux function to select on those pin(s)/group(s), and various pin configuration 24mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,apq8084-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,apq8084-pinctrl.txt
index ffafa1990a30..c4ea61ac56f2 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,apq8084-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,apq8084-pinctrl.txt
@@ -47,7 +47,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
47common pinctrl bindings used by client devices, including the meaning of the 47common pinctrl bindings used by client devices, including the meaning of the
48phrase "pin configuration node". 48phrase "pin configuration node".
49 49
50The pin configuration nodes act as a container for an abitrary number of 50The pin configuration nodes act as a container for an arbitrary number of
51subnodes. Each of these subnodes represents some desired configuration for a 51subnodes. Each of these subnodes represents some desired configuration for a
52pin, a group, or a list of pins or groups. This configuration can include the 52pin, a group, or a list of pins or groups. This configuration can include the
53mux function to select on those pin(s)/group(s), and various pin configuration 53mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,ipq8064-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,ipq8064-pinctrl.txt
index e33e4dcdce79..6e88e91feb11 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,ipq8064-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,ipq8064-pinctrl.txt
@@ -18,7 +18,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
18common pinctrl bindings used by client devices, including the meaning of the 18common pinctrl bindings used by client devices, including the meaning of the
19phrase "pin configuration node". 19phrase "pin configuration node".
20 20
21Qualcomm's pin configuration nodes act as a container for an abitrary number of 21Qualcomm's pin configuration nodes act as a container for an arbitrary number of
22subnodes. Each of these subnodes represents some desired configuration for a 22subnodes. Each of these subnodes represents some desired configuration for a
23pin, a group, or a list of pins or groups. This configuration can include the 23pin, a group, or a list of pins or groups. This configuration can include the
24mux function to select on those pin(s)/group(s), and various pin configuration 24mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,msm8960-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,msm8960-pinctrl.txt
index 93b7de91b9f6..eb8d8aa41f20 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,msm8960-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,msm8960-pinctrl.txt
@@ -47,7 +47,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
47common pinctrl bindings used by client devices, including the meaning of the 47common pinctrl bindings used by client devices, including the meaning of the
48phrase "pin configuration node". 48phrase "pin configuration node".
49 49
50The pin configuration nodes act as a container for an abitrary number of 50The pin configuration nodes act as a container for an arbitrary number of
51subnodes. Each of these subnodes represents some desired configuration for a 51subnodes. Each of these subnodes represents some desired configuration for a
52pin, a group, or a list of pins or groups. This configuration can include the 52pin, a group, or a list of pins or groups. This configuration can include the
53mux function to select on those pin(s)/group(s), and various pin configuration 53mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,msm8974-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/qcom,msm8974-pinctrl.txt
index d2ea80dc43eb..e4d6a9d20f7d 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,msm8974-pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,msm8974-pinctrl.txt
@@ -18,7 +18,7 @@ Please refer to pinctrl-bindings.txt in this directory for details of the
18common pinctrl bindings used by client devices, including the meaning of the 18common pinctrl bindings used by client devices, including the meaning of the
19phrase "pin configuration node". 19phrase "pin configuration node".
20 20
21Qualcomm's pin configuration nodes act as a container for an abitrary number of 21Qualcomm's pin configuration nodes act as a container for an arbitrary number of
22subnodes. Each of these subnodes represents some desired configuration for a 22subnodes. Each of these subnodes represents some desired configuration for a
23pin, a group, or a list of pins or groups. This configuration can include the 23pin, a group, or a list of pins or groups. This configuration can include the
24mux function to select on those pin(s)/group(s), and various pin configuration 24mux function to select on those pin(s)/group(s), and various pin configuration
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0b2fc732f1f3..78efebbf2788 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -34,6 +34,7 @@ chipidea Chipidea, Inc
34chrp Common Hardware Reference Platform 34chrp Common Hardware Reference Platform
35chunghwa Chunghwa Picture Tubes Ltd. 35chunghwa Chunghwa Picture Tubes Ltd.
36cirrus Cirrus Logic, Inc. 36cirrus Cirrus Logic, Inc.
37cnm Chips&Media, Inc.
37cortina Cortina Systems, Inc. 38cortina Cortina Systems, Inc.
38crystalfontz Crystalfontz America, Inc. 39crystalfontz Crystalfontz America, Inc.
39dallas Maxim Integrated Products (formerly Dallas Semiconductor) 40dallas Maxim Integrated Products (formerly Dallas Semiconductor)
@@ -94,6 +95,7 @@ maxim Maxim Integrated Products
94mediatek MediaTek Inc. 95mediatek MediaTek Inc.
95micrel Micrel Inc. 96micrel Micrel Inc.
96microchip Microchip Technology Inc. 97microchip Microchip Technology Inc.
98micron Micron Technology Inc.
97mitsubishi Mitsubishi Electric Corporation 99mitsubishi Mitsubishi Electric Corporation
98mosaixtech Mosaix Technologies, Inc. 100mosaixtech Mosaix Technologies, Inc.
99moxa Moxa 101moxa Moxa
@@ -129,6 +131,7 @@ renesas Renesas Electronics Corporation
129ricoh Ricoh Co. Ltd. 131ricoh Ricoh Co. Ltd.
130rockchip Fuzhou Rockchip Electronics Co., Ltd 132rockchip Fuzhou Rockchip Electronics Co., Ltd
131samsung Samsung Semiconductor 133samsung Samsung Semiconductor
134sandisk Sandisk Corporation
132sbs Smart Battery System 135sbs Smart Battery System
133schindler Schindler 136schindler Schindler
134seagate Seagate Technology PLC 137seagate Seagate Technology PLC
@@ -140,7 +143,7 @@ silergy Silergy Corp.
140sirf SiRF Technology, Inc. 143sirf SiRF Technology, Inc.
141sitronix Sitronix Technology Corporation 144sitronix Sitronix Technology Corporation
142smsc Standard Microsystems Corporation 145smsc Standard Microsystems Corporation
143snps Synopsys, Inc. 146snps Synopsys, Inc.
144solidrun SolidRun 147solidrun SolidRun
145sony Sony Corporation 148sony Sony Corporation
146spansion Spansion Inc. 149spansion Spansion Inc.
diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt
index 530850a72735..a27c950ece61 100644
--- a/Documentation/filesystems/overlayfs.txt
+++ b/Documentation/filesystems/overlayfs.txt
@@ -64,7 +64,7 @@ is formed.
64At mount time, the two directories given as mount options "lowerdir" and 64At mount time, the two directories given as mount options "lowerdir" and
65"upperdir" are combined into a merged directory: 65"upperdir" are combined into a merged directory:
66 66
67 mount -t overlayfs overlayfs -olowerdir=/lower,upperdir=/upper,\ 67 mount -t overlay overlay -olowerdir=/lower,upperdir=/upper,\
68workdir=/work /merged 68workdir=/work /merged
69 69
70The "workdir" needs to be an empty directory on the same filesystem 70The "workdir" needs to be an empty directory on the same filesystem
diff --git a/Documentation/input/elantech.txt b/Documentation/input/elantech.txt
index e1ae127ed099..1ec0db7879d3 100644
--- a/Documentation/input/elantech.txt
+++ b/Documentation/input/elantech.txt
@@ -38,22 +38,38 @@ Contents
38 7.2.1 Status packet 38 7.2.1 Status packet
39 7.2.2 Head packet 39 7.2.2 Head packet
40 7.2.3 Motion packet 40 7.2.3 Motion packet
41 8. Trackpoint (for Hardware version 3 and 4)
42 8.1 Registers
43 8.2 Native relative mode 6 byte packet format
44 8.2.1 Status Packet
41 45
42 46
43 47
441. Introduction 481. Introduction
45 ~~~~~~~~~~~~ 49 ~~~~~~~~~~~~
46 50
47Currently the Linux Elantech touchpad driver is aware of two different 51Currently the Linux Elantech touchpad driver is aware of four different
48hardware versions unimaginatively called version 1 and version 2. Version 1 52hardware versions unimaginatively called version 1,version 2, version 3
49is found in "older" laptops and uses 4 bytes per packet. Version 2 seems to 53and version 4. Version 1 is found in "older" laptops and uses 4 bytes per
50be introduced with the EeePC and uses 6 bytes per packet, and provides 54packet. Version 2 seems to be introduced with the EeePC and uses 6 bytes
51additional features such as position of two fingers, and width of the touch. 55per packet, and provides additional features such as position of two fingers,
56and width of the touch. Hardware version 3 uses 6 bytes per packet (and
57for 2 fingers the concatenation of two 6 bytes packets) and allows tracking
58of up to 3 fingers. Hardware version 4 uses 6 bytes per packet, and can
59combine a status packet with multiple head or motion packets. Hardware version
604 allows tracking up to 5 fingers.
61
62Some Hardware version 3 and version 4 also have a trackpoint which uses a
63separate packet format. It is also 6 bytes per packet.
52 64
53The driver tries to support both hardware versions and should be compatible 65The driver tries to support both hardware versions and should be compatible
54with the Xorg Synaptics touchpad driver and its graphical configuration 66with the Xorg Synaptics touchpad driver and its graphical configuration
55utilities. 67utilities.
56 68
69Note that a mouse button is also associated with either the touchpad or the
70trackpoint when a trackpoint is available. Disabling the Touchpad in xorg
71(TouchPadOff=0) will also disable the buttons associated with the touchpad.
72
57Additionally the operation of the touchpad can be altered by adjusting the 73Additionally the operation of the touchpad can be altered by adjusting the
58contents of some of its internal registers. These registers are represented 74contents of some of its internal registers. These registers are represented
59by the driver as sysfs entries under /sys/bus/serio/drivers/psmouse/serio? 75by the driver as sysfs entries under /sys/bus/serio/drivers/psmouse/serio?
@@ -78,7 +94,7 @@ completeness sake.
782. Extra knobs 942. Extra knobs
79 ~~~~~~~~~~~ 95 ~~~~~~~~~~~
80 96
81Currently the Linux Elantech touchpad driver provides two extra knobs under 97Currently the Linux Elantech touchpad driver provides three extra knobs under
82/sys/bus/serio/drivers/psmouse/serio? for the user. 98/sys/bus/serio/drivers/psmouse/serio? for the user.
83 99
84* debug 100* debug
@@ -112,6 +128,20 @@ Currently the Linux Elantech touchpad driver provides two extra knobs under
112 data consistency checking can be done. For now checking is disabled by 128 data consistency checking can be done. For now checking is disabled by
113 default. Currently even turning it on will do nothing. 129 default. Currently even turning it on will do nothing.
114 130
131* crc_enabled
132
133 Sets crc_enabled to 0/1. The name "crc_enabled" is the official name of
134 this integrity check, even though it is not an actual cyclic redundancy
135 check.
136
137 Depending on the state of crc_enabled, certain basic data integrity
138 verification is done by the driver on hardware version 3 and 4. The
139 driver will reject any packet that appears corrupted. Using this knob,
140 The state of crc_enabled can be altered with this knob.
141
142 Reading the crc_enabled value will show the active value. Echoing
143 "0" or "1" to this file will set the state to "0" or "1".
144
115///////////////////////////////////////////////////////////////////////////// 145/////////////////////////////////////////////////////////////////////////////
116 146
1173. Differentiating hardware versions 1473. Differentiating hardware versions
@@ -746,3 +776,42 @@ byte 5:
746 776
747 byte 0 ~ 2 for one finger 777 byte 0 ~ 2 for one finger
748 byte 3 ~ 5 for another 778 byte 3 ~ 5 for another
779
780
7818. Trackpoint (for Hardware version 3 and 4)
782 =========================================
7838.1 Registers
784 ~~~~~~~~~
785No special registers have been identified.
786
7878.2 Native relative mode 6 byte packet format
788 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7898.2.1 Status Packet
790 ~~~~~~~~~~~~~
791
792byte 0:
793 bit 7 6 5 4 3 2 1 0
794 0 0 sx sy 0 M R L
795byte 1:
796 bit 7 6 5 4 3 2 1 0
797 ~sx 0 0 0 0 0 0 0
798byte 2:
799 bit 7 6 5 4 3 2 1 0
800 ~sy 0 0 0 0 0 0 0
801byte 3:
802 bit 7 6 5 4 3 2 1 0
803 0 0 ~sy ~sx 0 1 1 0
804byte 4:
805 bit 7 6 5 4 3 2 1 0
806 x7 x6 x5 x4 x3 x2 x1 x0
807byte 5:
808 bit 7 6 5 4 3 2 1 0
809 y7 y6 y5 y4 y3 y2 y1 y0
810
811
812 x and y are written in two's complement spread
813 over 9 bits with sx/sy the relative top bit and
814 x7..x0 and y7..y0 the lower bits.
815 ~sx is the inverse of sx, ~sy is the inverse of sy.
816 The sign of y is opposite to what the input driver
817 expects for a relative movement
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 0307e2875f21..a476b08a43e0 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -56,6 +56,13 @@ ip_forward_use_pmtu - BOOLEAN
56 0 - disabled 56 0 - disabled
57 1 - enabled 57 1 - enabled
58 58
59fwmark_reflect - BOOLEAN
60 Controls the fwmark of kernel-generated IPv4 reply packets that are not
61 associated with a socket for example, TCP RSTs or ICMP echo replies).
62 If unset, these packets have a fwmark of zero. If set, they have the
63 fwmark of the packet they are replying to.
64 Default: 0
65
59route/max_size - INTEGER 66route/max_size - INTEGER
60 Maximum number of routes allowed in the kernel. Increase 67 Maximum number of routes allowed in the kernel. Increase
61 this when using large numbers of interfaces and/or routes. 68 this when using large numbers of interfaces and/or routes.
@@ -1201,6 +1208,13 @@ conf/all/forwarding - BOOLEAN
1201proxy_ndp - BOOLEAN 1208proxy_ndp - BOOLEAN
1202 Do proxy ndp. 1209 Do proxy ndp.
1203 1210
1211fwmark_reflect - BOOLEAN
1212 Controls the fwmark of kernel-generated IPv6 reply packets that are not
1213 associated with a socket for example, TCP RSTs or ICMPv6 echo replies).
1214 If unset, these packets have a fwmark of zero. If set, they have the
1215 fwmark of the packet they are replying to.
1216 Default: 0
1217
1204conf/interface/*: 1218conf/interface/*:
1205 Change special settings per interface. 1219 Change special settings per interface.
1206 1220
diff --git a/Documentation/networking/timestamping.txt b/Documentation/networking/timestamping.txt
index 412f45ca2d73..1d6d02d6ba52 100644
--- a/Documentation/networking/timestamping.txt
+++ b/Documentation/networking/timestamping.txt
@@ -136,7 +136,7 @@ SOF_TIMESTAMPING_OPT_ID:
136 136
137 This option is implemented only for transmit timestamps. There, the 137 This option is implemented only for transmit timestamps. There, the
138 timestamp is always looped along with a struct sock_extended_err. 138 timestamp is always looped along with a struct sock_extended_err.
139 The option modifies field ee_info to pass an id that is unique 139 The option modifies field ee_data to pass an id that is unique
140 among all possibly concurrently outstanding timestamp requests for 140 among all possibly concurrently outstanding timestamp requests for
141 that socket. In practice, it is a monotonically increasing u32 141 that socket. In practice, it is a monotonically increasing u32
142 (that wraps). 142 (that wraps).
diff --git a/MAINTAINERS b/MAINTAINERS
index b29325d4a072..55d3e9b93338 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2754,6 +2754,13 @@ W: http://www.chelsio.com
2754S: Supported 2754S: Supported
2755F: drivers/net/ethernet/chelsio/cxgb3/ 2755F: drivers/net/ethernet/chelsio/cxgb3/
2756 2756
2757CXGB3 ISCSI DRIVER (CXGB3I)
2758M: Karen Xie <kxie@chelsio.com>
2759L: linux-scsi@vger.kernel.org
2760W: http://www.chelsio.com
2761S: Supported
2762F: drivers/scsi/cxgbi/cxgb3i
2763
2757CXGB3 IWARP RNIC DRIVER (IW_CXGB3) 2764CXGB3 IWARP RNIC DRIVER (IW_CXGB3)
2758M: Steve Wise <swise@chelsio.com> 2765M: Steve Wise <swise@chelsio.com>
2759L: linux-rdma@vger.kernel.org 2766L: linux-rdma@vger.kernel.org
@@ -2768,6 +2775,13 @@ W: http://www.chelsio.com
2768S: Supported 2775S: Supported
2769F: drivers/net/ethernet/chelsio/cxgb4/ 2776F: drivers/net/ethernet/chelsio/cxgb4/
2770 2777
2778CXGB4 ISCSI DRIVER (CXGB4I)
2779M: Karen Xie <kxie@chelsio.com>
2780L: linux-scsi@vger.kernel.org
2781W: http://www.chelsio.com
2782S: Supported
2783F: drivers/scsi/cxgbi/cxgb4i
2784
2771CXGB4 IWARP RNIC DRIVER (IW_CXGB4) 2785CXGB4 IWARP RNIC DRIVER (IW_CXGB4)
2772M: Steve Wise <swise@chelsio.com> 2786M: Steve Wise <swise@chelsio.com>
2773L: linux-rdma@vger.kernel.org 2787L: linux-rdma@vger.kernel.org
@@ -4733,6 +4747,7 @@ L: linux-iio@vger.kernel.org
4733S: Maintained 4747S: Maintained
4734F: drivers/iio/ 4748F: drivers/iio/
4735F: drivers/staging/iio/ 4749F: drivers/staging/iio/
4750F: include/linux/iio/
4736 4751
4737IKANOS/ADI EAGLE ADSL USB DRIVER 4752IKANOS/ADI EAGLE ADSL USB DRIVER
4738M: Matthieu Castet <castet.matthieu@free.fr> 4753M: Matthieu Castet <castet.matthieu@free.fr>
@@ -6613,6 +6628,23 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git
6613S: Maintained 6628S: Maintained
6614F: arch/arm/*omap*/ 6629F: arch/arm/*omap*/
6615F: drivers/i2c/busses/i2c-omap.c 6630F: drivers/i2c/busses/i2c-omap.c
6631F: drivers/irqchip/irq-omap-intc.c
6632F: drivers/mfd/*omap*.c
6633F: drivers/mfd/menelaus.c
6634F: drivers/mfd/palmas.c
6635F: drivers/mfd/tps65217.c
6636F: drivers/mfd/tps65218.c
6637F: drivers/mfd/tps65910.c
6638F: drivers/mfd/twl-core.[ch]
6639F: drivers/mfd/twl4030*.c
6640F: drivers/mfd/twl6030*.c
6641F: drivers/mfd/twl6040*.c
6642F: drivers/regulator/palmas-regulator*.c
6643F: drivers/regulator/pbias-regulator.c
6644F: drivers/regulator/tps65217-regulator.c
6645F: drivers/regulator/tps65218-regulator.c
6646F: drivers/regulator/tps65910-regulator.c
6647F: drivers/regulator/twl-regulator.c
6616F: include/linux/i2c-omap.h 6648F: include/linux/i2c-omap.h
6617 6649
6618OMAP DEVICE TREE SUPPORT 6650OMAP DEVICE TREE SUPPORT
@@ -6623,6 +6655,9 @@ L: devicetree@vger.kernel.org
6623S: Maintained 6655S: Maintained
6624F: arch/arm/boot/dts/*omap* 6656F: arch/arm/boot/dts/*omap*
6625F: arch/arm/boot/dts/*am3* 6657F: arch/arm/boot/dts/*am3*
6658F: arch/arm/boot/dts/*am4*
6659F: arch/arm/boot/dts/*am5*
6660F: arch/arm/boot/dts/*dra7*
6626 6661
6627OMAP CLOCK FRAMEWORK SUPPORT 6662OMAP CLOCK FRAMEWORK SUPPORT
6628M: Paul Walmsley <paul@pwsan.com> 6663M: Paul Walmsley <paul@pwsan.com>
@@ -6870,11 +6905,12 @@ F: drivers/scsi/osd/
6870F: include/scsi/osd_* 6905F: include/scsi/osd_*
6871F: fs/exofs/ 6906F: fs/exofs/
6872 6907
6873OVERLAYFS FILESYSTEM 6908OVERLAY FILESYSTEM
6874M: Miklos Szeredi <miklos@szeredi.hu> 6909M: Miklos Szeredi <miklos@szeredi.hu>
6875L: linux-fsdevel@vger.kernel.org 6910L: linux-unionfs@vger.kernel.org
6911T: git git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git
6876S: Supported 6912S: Supported
6877F: fs/overlayfs/* 6913F: fs/overlayfs/
6878F: Documentation/filesystems/overlayfs.txt 6914F: Documentation/filesystems/overlayfs.txt
6879 6915
6880P54 WIRELESS DRIVER 6916P54 WIRELESS DRIVER
diff --git a/Makefile b/Makefile
index bc7eb6ada966..ce70361f766e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 18 2PATCHLEVEL = 18
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc7
5NAME = Diseased Newt 5NAME = Diseased Newt
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -297,7 +297,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
297 297
298HOSTCC = gcc 298HOSTCC = gcc
299HOSTCXX = g++ 299HOSTCXX = g++
300HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer 300HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
301HOSTCXXFLAGS = -O2 301HOSTCXXFLAGS = -O2
302 302
303ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1) 303ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
@@ -401,7 +401,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__
401KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 401KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
402 -fno-strict-aliasing -fno-common \ 402 -fno-strict-aliasing -fno-common \
403 -Werror-implicit-function-declaration \ 403 -Werror-implicit-function-declaration \
404 -Wno-format-security 404 -Wno-format-security \
405 -std=gnu89
405 406
406KBUILD_AFLAGS_KERNEL := 407KBUILD_AFLAGS_KERNEL :=
407KBUILD_CFLAGS_KERNEL := 408KBUILD_CFLAGS_KERNEL :=
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 413fd94b5301..68be9017593d 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -397,8 +397,7 @@ dtb_check_done:
397 add sp, sp, r6 397 add sp, sp, r6
398#endif 398#endif
399 399
400 tst r4, #1 400 bl cache_clean_flush
401 bleq cache_clean_flush
402 401
403 adr r0, BSYM(restart) 402 adr r0, BSYM(restart)
404 add r0, r0, r6 403 add r0, r0, r6
@@ -1047,6 +1046,8 @@ cache_clean_flush:
1047 b call_cache_fn 1046 b call_cache_fn
1048 1047
1049__armv4_mpu_cache_flush: 1048__armv4_mpu_cache_flush:
1049 tst r4, #1
1050 movne pc, lr
1050 mov r2, #1 1051 mov r2, #1
1051 mov r3, #0 1052 mov r3, #0
1052 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache 1053 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
@@ -1064,6 +1065,8 @@ __armv4_mpu_cache_flush:
1064 mov pc, lr 1065 mov pc, lr
1065 1066
1066__fa526_cache_flush: 1067__fa526_cache_flush:
1068 tst r4, #1
1069 movne pc, lr
1067 mov r1, #0 1070 mov r1, #0
1068 mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache 1071 mcr p15, 0, r1, c7, c14, 0 @ clean and invalidate D cache
1069 mcr p15, 0, r1, c7, c5, 0 @ flush I cache 1072 mcr p15, 0, r1, c7, c5, 0 @ flush I cache
@@ -1072,13 +1075,16 @@ __fa526_cache_flush:
1072 1075
1073__armv6_mmu_cache_flush: 1076__armv6_mmu_cache_flush:
1074 mov r1, #0 1077 mov r1, #0
1075 mcr p15, 0, r1, c7, c14, 0 @ clean+invalidate D 1078 tst r4, #1
1079 mcreq p15, 0, r1, c7, c14, 0 @ clean+invalidate D
1076 mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB 1080 mcr p15, 0, r1, c7, c5, 0 @ invalidate I+BTB
1077 mcr p15, 0, r1, c7, c15, 0 @ clean+invalidate unified 1081 mcreq p15, 0, r1, c7, c15, 0 @ clean+invalidate unified
1078 mcr p15, 0, r1, c7, c10, 4 @ drain WB 1082 mcr p15, 0, r1, c7, c10, 4 @ drain WB
1079 mov pc, lr 1083 mov pc, lr
1080 1084
1081__armv7_mmu_cache_flush: 1085__armv7_mmu_cache_flush:
1086 tst r4, #1
1087 bne iflush
1082 mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1 1088 mrc p15, 0, r10, c0, c1, 5 @ read ID_MMFR1
1083 tst r10, #0xf << 16 @ hierarchical cache (ARMv7) 1089 tst r10, #0xf << 16 @ hierarchical cache (ARMv7)
1084 mov r10, #0 1090 mov r10, #0
@@ -1139,6 +1145,8 @@ iflush:
1139 mov pc, lr 1145 mov pc, lr
1140 1146
1141__armv5tej_mmu_cache_flush: 1147__armv5tej_mmu_cache_flush:
1148 tst r4, #1
1149 movne pc, lr
11421: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate D cache 11501: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate D cache
1143 bne 1b 1151 bne 1b
1144 mcr p15, 0, r0, c7, c5, 0 @ flush I cache 1152 mcr p15, 0, r0, c7, c5, 0 @ flush I cache
@@ -1146,6 +1154,8 @@ __armv5tej_mmu_cache_flush:
1146 mov pc, lr 1154 mov pc, lr
1147 1155
1148__armv4_mmu_cache_flush: 1156__armv4_mmu_cache_flush:
1157 tst r4, #1
1158 movne pc, lr
1149 mov r2, #64*1024 @ default: 32K dcache size (*2) 1159 mov r2, #64*1024 @ default: 32K dcache size (*2)
1150 mov r11, #32 @ default: 32 byte line size 1160 mov r11, #32 @ default: 32 byte line size
1151 mrc p15, 0, r3, c0, c0, 1 @ read cache type 1161 mrc p15, 0, r3, c0, c0, 1 @ read cache type
@@ -1179,6 +1189,8 @@ no_cache_id:
1179 1189
1180__armv3_mmu_cache_flush: 1190__armv3_mmu_cache_flush:
1181__armv3_mpu_cache_flush: 1191__armv3_mpu_cache_flush:
1192 tst r4, #1
1193 movne pc, lr
1182 mov r1, #0 1194 mov r1, #0
1183 mcr p15, 0, r1, c7, c0, 0 @ invalidate whole cache v3 1195 mcr p15, 0, r1, c7, c0, 0 @ invalidate whole cache v3
1184 mov pc, lr 1196 mov pc, lr
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index e2156a583de7..c4b968f0feb5 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -489,7 +489,7 @@
489 reg = <0x00060000 0x00020000>; 489 reg = <0x00060000 0x00020000>;
490 }; 490 };
491 partition@4 { 491 partition@4 {
492 label = "NAND.u-boot-spl"; 492 label = "NAND.u-boot-spl-os";
493 reg = <0x00080000 0x00040000>; 493 reg = <0x00080000 0x00040000>;
494 }; 494 };
495 partition@5 { 495 partition@5 {
diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts b/arch/arm/boot/dts/am437x-gp-evm.dts
index e7ac47fa6615..a521ac0a7d5a 100644
--- a/arch/arm/boot/dts/am437x-gp-evm.dts
+++ b/arch/arm/boot/dts/am437x-gp-evm.dts
@@ -291,8 +291,8 @@
291 dcdc3: regulator-dcdc3 { 291 dcdc3: regulator-dcdc3 {
292 compatible = "ti,tps65218-dcdc3"; 292 compatible = "ti,tps65218-dcdc3";
293 regulator-name = "vdcdc3"; 293 regulator-name = "vdcdc3";
294 regulator-min-microvolt = <1350000>; 294 regulator-min-microvolt = <1500000>;
295 regulator-max-microvolt = <1350000>; 295 regulator-max-microvolt = <1500000>;
296 regulator-boot-on; 296 regulator-boot-on;
297 regulator-always-on; 297 regulator-always-on;
298 }; 298 };
diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
index 859ff3d620ee..87aa4f3b8b3d 100644
--- a/arch/arm/boot/dts/am437x-sk-evm.dts
+++ b/arch/arm/boot/dts/am437x-sk-evm.dts
@@ -363,8 +363,8 @@
363 dcdc3: regulator-dcdc3 { 363 dcdc3: regulator-dcdc3 {
364 compatible = "ti,tps65218-dcdc3"; 364 compatible = "ti,tps65218-dcdc3";
365 regulator-name = "vdds_ddr"; 365 regulator-name = "vdds_ddr";
366 regulator-min-microvolt = <1350000>; 366 regulator-min-microvolt = <1500000>;
367 regulator-max-microvolt = <1350000>; 367 regulator-max-microvolt = <1500000>;
368 regulator-boot-on; 368 regulator-boot-on;
369 regulator-always-on; 369 regulator-always-on;
370 }; 370 };
diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts
index ac3e4859935f..f7e9bba10bd6 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -358,8 +358,8 @@
358 dcdc3: regulator-dcdc3 { 358 dcdc3: regulator-dcdc3 {
359 compatible = "ti,tps65218-dcdc3"; 359 compatible = "ti,tps65218-dcdc3";
360 regulator-name = "vdcdc3"; 360 regulator-name = "vdcdc3";
361 regulator-min-microvolt = <1350000>; 361 regulator-min-microvolt = <1500000>;
362 regulator-max-microvolt = <1350000>; 362 regulator-max-microvolt = <1500000>;
363 regulator-boot-on; 363 regulator-boot-on;
364 regulator-always-on; 364 regulator-always-on;
365 }; 365 };
diff --git a/arch/arm/boot/dts/exynos5250-snow.dts b/arch/arm/boot/dts/exynos5250-snow.dts
index e51fcef884a4..60429ad1c5d8 100644
--- a/arch/arm/boot/dts/exynos5250-snow.dts
+++ b/arch/arm/boot/dts/exynos5250-snow.dts
@@ -624,4 +624,8 @@
624 num-cs = <1>; 624 num-cs = <1>;
625}; 625};
626 626
627&usbdrd_dwc3 {
628 dr_mode = "host";
629};
630
627#include "cros-ec-keyboard.dtsi" 631#include "cros-ec-keyboard.dtsi"
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
index f21b9aa00fbb..d55c1a2eb798 100644
--- a/arch/arm/boot/dts/exynos5250.dtsi
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -555,7 +555,7 @@
555 #size-cells = <1>; 555 #size-cells = <1>;
556 ranges; 556 ranges;
557 557
558 dwc3 { 558 usbdrd_dwc3: dwc3 {
559 compatible = "synopsys,dwc3"; 559 compatible = "synopsys,dwc3";
560 reg = <0x12000000 0x10000>; 560 reg = <0x12000000 0x10000>;
561 interrupts = <0 72 0>; 561 interrupts = <0 72 0>;
diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi
index d46c213a17ad..eed697a6bd6b 100644
--- a/arch/arm/boot/dts/r8a7740.dtsi
+++ b/arch/arm/boot/dts/r8a7740.dtsi
@@ -433,7 +433,7 @@
433 clocks = <&cpg_clocks R8A7740_CLK_S>, 433 clocks = <&cpg_clocks R8A7740_CLK_S>,
434 <&cpg_clocks R8A7740_CLK_S>, <&sub_clk>, 434 <&cpg_clocks R8A7740_CLK_S>, <&sub_clk>,
435 <&cpg_clocks R8A7740_CLK_B>, 435 <&cpg_clocks R8A7740_CLK_B>,
436 <&sub_clk>, <&sub_clk>, 436 <&cpg_clocks R8A7740_CLK_HPP>, <&sub_clk>,
437 <&cpg_clocks R8A7740_CLK_B>; 437 <&cpg_clocks R8A7740_CLK_B>;
438 #clock-cells = <1>; 438 #clock-cells = <1>;
439 renesas,clock-indices = < 439 renesas,clock-indices = <
diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi
index b7c59b7b06b0..0c20c90d8c06 100644
--- a/arch/arm/boot/dts/r8a7790.dtsi
+++ b/arch/arm/boot/dts/r8a7790.dtsi
@@ -756,9 +756,9 @@
756 #clock-cells = <0>; 756 #clock-cells = <0>;
757 clock-output-names = "sd2"; 757 clock-output-names = "sd2";
758 }; 758 };
759 sd3_clk: sd3_clk@e615007c { 759 sd3_clk: sd3_clk@e615026c {
760 compatible = "renesas,r8a7790-div6-clock", "renesas,cpg-div6-clock"; 760 compatible = "renesas,r8a7790-div6-clock", "renesas,cpg-div6-clock";
761 reg = <0 0xe615007c 0 4>; 761 reg = <0 0xe615026c 0 4>;
762 clocks = <&pll1_div2_clk>; 762 clocks = <&pll1_div2_clk>;
763 #clock-cells = <0>; 763 #clock-cells = <0>;
764 clock-output-names = "sd3"; 764 clock-output-names = "sd3";
diff --git a/arch/arm/boot/dts/sama5d31.dtsi b/arch/arm/boot/dts/sama5d31.dtsi
index 7997dc9863ed..883878b32971 100644
--- a/arch/arm/boot/dts/sama5d31.dtsi
+++ b/arch/arm/boot/dts/sama5d31.dtsi
@@ -12,5 +12,5 @@
12#include "sama5d3_uart.dtsi" 12#include "sama5d3_uart.dtsi"
13 13
14/ { 14/ {
15 compatible = "atmel,samad31", "atmel,sama5d3", "atmel,sama5"; 15 compatible = "atmel,sama5d31", "atmel,sama5d3", "atmel,sama5";
16}; 16};
diff --git a/arch/arm/boot/dts/sama5d33.dtsi b/arch/arm/boot/dts/sama5d33.dtsi
index 39f832253caf..4b4434aca351 100644
--- a/arch/arm/boot/dts/sama5d33.dtsi
+++ b/arch/arm/boot/dts/sama5d33.dtsi
@@ -10,5 +10,5 @@
10#include "sama5d3_gmac.dtsi" 10#include "sama5d3_gmac.dtsi"
11 11
12/ { 12/ {
13 compatible = "atmel,samad33", "atmel,sama5d3", "atmel,sama5"; 13 compatible = "atmel,sama5d33", "atmel,sama5d3", "atmel,sama5";
14}; 14};
diff --git a/arch/arm/boot/dts/sama5d34.dtsi b/arch/arm/boot/dts/sama5d34.dtsi
index 89cda2c0da39..aa01573fdee9 100644
--- a/arch/arm/boot/dts/sama5d34.dtsi
+++ b/arch/arm/boot/dts/sama5d34.dtsi
@@ -12,5 +12,5 @@
12#include "sama5d3_mci2.dtsi" 12#include "sama5d3_mci2.dtsi"
13 13
14/ { 14/ {
15 compatible = "atmel,samad34", "atmel,sama5d3", "atmel,sama5"; 15 compatible = "atmel,sama5d34", "atmel,sama5d3", "atmel,sama5";
16}; 16};
diff --git a/arch/arm/boot/dts/sama5d35.dtsi b/arch/arm/boot/dts/sama5d35.dtsi
index d20cd71b5f0e..16c39f4c96a4 100644
--- a/arch/arm/boot/dts/sama5d35.dtsi
+++ b/arch/arm/boot/dts/sama5d35.dtsi
@@ -14,5 +14,5 @@
14#include "sama5d3_tcb1.dtsi" 14#include "sama5d3_tcb1.dtsi"
15 15
16/ { 16/ {
17 compatible = "atmel,samad35", "atmel,sama5d3", "atmel,sama5"; 17 compatible = "atmel,sama5d35", "atmel,sama5d3", "atmel,sama5";
18}; 18};
diff --git a/arch/arm/boot/dts/sama5d36.dtsi b/arch/arm/boot/dts/sama5d36.dtsi
index db58cad6acd3..e85139ef40af 100644
--- a/arch/arm/boot/dts/sama5d36.dtsi
+++ b/arch/arm/boot/dts/sama5d36.dtsi
@@ -16,5 +16,5 @@
16#include "sama5d3_uart.dtsi" 16#include "sama5d3_uart.dtsi"
17 17
18/ { 18/ {
19 compatible = "atmel,samad36", "atmel,sama5d3", "atmel,sama5"; 19 compatible = "atmel,sama5d36", "atmel,sama5d3", "atmel,sama5";
20}; 20};
diff --git a/arch/arm/boot/dts/sama5d3xcm.dtsi b/arch/arm/boot/dts/sama5d3xcm.dtsi
index 962dc28dc37b..cfcd200b0c17 100644
--- a/arch/arm/boot/dts/sama5d3xcm.dtsi
+++ b/arch/arm/boot/dts/sama5d3xcm.dtsi
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10/ { 10/ {
11 compatible = "atmel,samad3xcm", "atmel,sama5d3", "atmel,sama5"; 11 compatible = "atmel,sama5d3xcm", "atmel,sama5d3", "atmel,sama5";
12 12
13 chosen { 13 chosen {
14 bootargs = "console=ttyS0,115200 rootfstype=ubifs ubi.mtd=5 root=ubi0:rootfs"; 14 bootargs = "console=ttyS0,115200 rootfstype=ubifs ubi.mtd=5 root=ubi0:rootfs";
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 543f895d18d3..2e652e2339e9 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -361,6 +361,10 @@
361 clocks = <&ahb1_gates 6>; 361 clocks = <&ahb1_gates 6>;
362 resets = <&ahb1_rst 6>; 362 resets = <&ahb1_rst 6>;
363 #dma-cells = <1>; 363 #dma-cells = <1>;
364
365 /* DMA controller requires AHB1 clocked from PLL6 */
366 assigned-clocks = <&ahb1_mux>;
367 assigned-clock-parents = <&pll6>;
364 }; 368 };
365 369
366 mmc0: mmc@01c0f000 { 370 mmc0: mmc@01c0f000 {
diff --git a/arch/arm/boot/dts/tegra114-dalmore.dts b/arch/arm/boot/dts/tegra114-dalmore.dts
index 5c21d216515a..8b7aa0dcdc6e 100644
--- a/arch/arm/boot/dts/tegra114-dalmore.dts
+++ b/arch/arm/boot/dts/tegra114-dalmore.dts
@@ -15,6 +15,7 @@
15 aliases { 15 aliases {
16 rtc0 = "/i2c@7000d000/tps65913@58"; 16 rtc0 = "/i2c@7000d000/tps65913@58";
17 rtc1 = "/rtc@7000e000"; 17 rtc1 = "/rtc@7000e000";
18 serial0 = &uartd;
18 }; 19 };
19 20
20 memory { 21 memory {
diff --git a/arch/arm/boot/dts/tegra114-roth.dts b/arch/arm/boot/dts/tegra114-roth.dts
index c7c6825f11fb..38acf78d7815 100644
--- a/arch/arm/boot/dts/tegra114-roth.dts
+++ b/arch/arm/boot/dts/tegra114-roth.dts
@@ -15,6 +15,10 @@
15 linux,initrd-end = <0x82800000>; 15 linux,initrd-end = <0x82800000>;
16 }; 16 };
17 17
18 aliases {
19 serial0 = &uartd;
20 };
21
18 firmware { 22 firmware {
19 trusted-foundations { 23 trusted-foundations {
20 compatible = "tlm,trusted-foundations"; 24 compatible = "tlm,trusted-foundations";
@@ -916,8 +920,6 @@
916 regulator-name = "vddio-sdmmc3"; 920 regulator-name = "vddio-sdmmc3";
917 regulator-min-microvolt = <1800000>; 921 regulator-min-microvolt = <1800000>;
918 regulator-max-microvolt = <3300000>; 922 regulator-max-microvolt = <3300000>;
919 regulator-always-on;
920 regulator-boot-on;
921 }; 923 };
922 924
923 ldousb { 925 ldousb {
@@ -962,7 +964,7 @@
962 sdhci@78000400 { 964 sdhci@78000400 {
963 status = "okay"; 965 status = "okay";
964 bus-width = <4>; 966 bus-width = <4>;
965 vmmc-supply = <&vddio_sdmmc3>; 967 vqmmc-supply = <&vddio_sdmmc3>;
966 cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>; 968 cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>;
967 power-gpios = <&gpio TEGRA_GPIO(H, 0) GPIO_ACTIVE_HIGH>; 969 power-gpios = <&gpio TEGRA_GPIO(H, 0) GPIO_ACTIVE_HIGH>;
968 }; 970 };
@@ -971,7 +973,6 @@
971 sdhci@78000600 { 973 sdhci@78000600 {
972 status = "okay"; 974 status = "okay";
973 bus-width = <8>; 975 bus-width = <8>;
974 vmmc-supply = <&vdd_1v8>;
975 non-removable; 976 non-removable;
976 }; 977 };
977 978
diff --git a/arch/arm/boot/dts/tegra114-tn7.dts b/arch/arm/boot/dts/tegra114-tn7.dts
index 963662145635..f91c2c9b2f94 100644
--- a/arch/arm/boot/dts/tegra114-tn7.dts
+++ b/arch/arm/boot/dts/tegra114-tn7.dts
@@ -15,6 +15,10 @@
15 linux,initrd-end = <0x82800000>; 15 linux,initrd-end = <0x82800000>;
16 }; 16 };
17 17
18 aliases {
19 serial0 = &uartd;
20 };
21
18 firmware { 22 firmware {
19 trusted-foundations { 23 trusted-foundations {
20 compatible = "tlm,trusted-foundations"; 24 compatible = "tlm,trusted-foundations";
@@ -240,7 +244,6 @@
240 sdhci@78000600 { 244 sdhci@78000600 {
241 status = "okay"; 245 status = "okay";
242 bus-width = <8>; 246 bus-width = <8>;
243 vmmc-supply = <&vdd_1v8>;
244 non-removable; 247 non-removable;
245 }; 248 };
246 249
diff --git a/arch/arm/boot/dts/tegra114.dtsi b/arch/arm/boot/dts/tegra114.dtsi
index 2ca9c1807f72..222f3b3f4dd5 100644
--- a/arch/arm/boot/dts/tegra114.dtsi
+++ b/arch/arm/boot/dts/tegra114.dtsi
@@ -9,13 +9,6 @@
9 compatible = "nvidia,tegra114"; 9 compatible = "nvidia,tegra114";
10 interrupt-parent = <&gic>; 10 interrupt-parent = <&gic>;
11 11
12 aliases {
13 serial0 = &uarta;
14 serial1 = &uartb;
15 serial2 = &uartc;
16 serial3 = &uartd;
17 };
18
19 host1x@50000000 { 12 host1x@50000000 {
20 compatible = "nvidia,tegra114-host1x", "simple-bus"; 13 compatible = "nvidia,tegra114-host1x", "simple-bus";
21 reg = <0x50000000 0x00028000>; 14 reg = <0x50000000 0x00028000>;
diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
index 029c9a021541..51b373ff1065 100644
--- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts
+++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@0,7000d000/pmic@40"; 11 rtc0 = "/i2c@0,7000d000/pmic@40";
12 rtc1 = "/rtc@0,7000e000"; 12 rtc1 = "/rtc@0,7000e000";
13 serial0 = &uartd;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra124-nyan-big.dts b/arch/arm/boot/dts/tegra124-nyan-big.dts
index 7d0784ce4c74..53181d310247 100644
--- a/arch/arm/boot/dts/tegra124-nyan-big.dts
+++ b/arch/arm/boot/dts/tegra124-nyan-big.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@0,7000d000/pmic@40"; 11 rtc0 = "/i2c@0,7000d000/pmic@40";
12 rtc1 = "/rtc@0,7000e000"; 12 rtc1 = "/rtc@0,7000e000";
13 serial0 = &uarta;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra124-venice2.dts b/arch/arm/boot/dts/tegra124-venice2.dts
index 13008858e967..5c3f7813360d 100644
--- a/arch/arm/boot/dts/tegra124-venice2.dts
+++ b/arch/arm/boot/dts/tegra124-venice2.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@0,7000d000/pmic@40"; 11 rtc0 = "/i2c@0,7000d000/pmic@40";
12 rtc1 = "/rtc@0,7000e000"; 12 rtc1 = "/rtc@0,7000e000";
13 serial0 = &uarta;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra124.dtsi b/arch/arm/boot/dts/tegra124.dtsi
index 478c555ebd96..df2b06b29985 100644
--- a/arch/arm/boot/dts/tegra124.dtsi
+++ b/arch/arm/boot/dts/tegra124.dtsi
@@ -286,7 +286,7 @@
286 * the APB DMA based serial driver, the comptible is 286 * the APB DMA based serial driver, the comptible is
287 * "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart". 287 * "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart".
288 */ 288 */
289 serial@0,70006000 { 289 uarta: serial@0,70006000 {
290 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart"; 290 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
291 reg = <0x0 0x70006000 0x0 0x40>; 291 reg = <0x0 0x70006000 0x0 0x40>;
292 reg-shift = <2>; 292 reg-shift = <2>;
@@ -299,7 +299,7 @@
299 status = "disabled"; 299 status = "disabled";
300 }; 300 };
301 301
302 serial@0,70006040 { 302 uartb: serial@0,70006040 {
303 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart"; 303 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
304 reg = <0x0 0x70006040 0x0 0x40>; 304 reg = <0x0 0x70006040 0x0 0x40>;
305 reg-shift = <2>; 305 reg-shift = <2>;
@@ -312,7 +312,7 @@
312 status = "disabled"; 312 status = "disabled";
313 }; 313 };
314 314
315 serial@0,70006200 { 315 uartc: serial@0,70006200 {
316 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart"; 316 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
317 reg = <0x0 0x70006200 0x0 0x40>; 317 reg = <0x0 0x70006200 0x0 0x40>;
318 reg-shift = <2>; 318 reg-shift = <2>;
@@ -325,7 +325,7 @@
325 status = "disabled"; 325 status = "disabled";
326 }; 326 };
327 327
328 serial@0,70006300 { 328 uartd: serial@0,70006300 {
329 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart"; 329 compatible = "nvidia,tegra124-uart", "nvidia,tegra20-uart";
330 reg = <0x0 0x70006300 0x0 0x40>; 330 reg = <0x0 0x70006300 0x0 0x40>;
331 reg-shift = <2>; 331 reg-shift = <2>;
diff --git a/arch/arm/boot/dts/tegra20-harmony.dts b/arch/arm/boot/dts/tegra20-harmony.dts
index a37279af687c..b926a07b9443 100644
--- a/arch/arm/boot/dts/tegra20-harmony.dts
+++ b/arch/arm/boot/dts/tegra20-harmony.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000d000/tps6586x@34"; 11 rtc0 = "/i2c@7000d000/tps6586x@34";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uartd;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra20-iris-512.dts b/arch/arm/boot/dts/tegra20-iris-512.dts
index 8cfb83f42e1f..1dd7d7bfdfcc 100644
--- a/arch/arm/boot/dts/tegra20-iris-512.dts
+++ b/arch/arm/boot/dts/tegra20-iris-512.dts
@@ -6,6 +6,11 @@
6 model = "Toradex Colibri T20 512MB on Iris"; 6 model = "Toradex Colibri T20 512MB on Iris";
7 compatible = "toradex,iris", "toradex,colibri_t20-512", "nvidia,tegra20"; 7 compatible = "toradex,iris", "toradex,colibri_t20-512", "nvidia,tegra20";
8 8
9 aliases {
10 serial0 = &uarta;
11 serial1 = &uartd;
12 };
13
9 host1x@50000000 { 14 host1x@50000000 {
10 hdmi@54280000 { 15 hdmi@54280000 {
11 status = "okay"; 16 status = "okay";
diff --git a/arch/arm/boot/dts/tegra20-medcom-wide.dts b/arch/arm/boot/dts/tegra20-medcom-wide.dts
index 1b7c56b33aca..9b87526ab0b7 100644
--- a/arch/arm/boot/dts/tegra20-medcom-wide.dts
+++ b/arch/arm/boot/dts/tegra20-medcom-wide.dts
@@ -6,6 +6,10 @@
6 model = "Avionic Design Medcom-Wide board"; 6 model = "Avionic Design Medcom-Wide board";
7 compatible = "ad,medcom-wide", "ad,tamonten", "nvidia,tegra20"; 7 compatible = "ad,medcom-wide", "ad,tamonten", "nvidia,tegra20";
8 8
9 aliases {
10 serial0 = &uartd;
11 };
12
9 pwm@7000a000 { 13 pwm@7000a000 {
10 status = "okay"; 14 status = "okay";
11 }; 15 };
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts b/arch/arm/boot/dts/tegra20-paz00.dts
index d4438e30de45..ed7e1009326c 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -10,6 +10,8 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000d000/tps6586x@34"; 11 rtc0 = "/i2c@7000d000/tps6586x@34";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uarta;
14 serial1 = &uartc;
13 }; 15 };
14 16
15 memory { 17 memory {
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts
index a1d4bf9895d7..ea282c7c0ca5 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000d000/tps6586x@34"; 11 rtc0 = "/i2c@7000d000/tps6586x@34";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uartd;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi
index 80e7d386ce34..13d4e6185275 100644
--- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
+++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
@@ -7,6 +7,7 @@
7 aliases { 7 aliases {
8 rtc0 = "/i2c@7000d000/tps6586x@34"; 8 rtc0 = "/i2c@7000d000/tps6586x@34";
9 rtc1 = "/rtc@7000e000"; 9 rtc1 = "/rtc@7000e000";
10 serial0 = &uartd;
10 }; 11 };
11 12
12 memory { 13 memory {
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts b/arch/arm/boot/dts/tegra20-trimslice.dts
index 5ad87979ab13..d99af4ef9c64 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000c500/rtc@56"; 11 rtc0 = "/i2c@7000c500/rtc@56";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uarta;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra20-ventana.dts b/arch/arm/boot/dts/tegra20-ventana.dts
index ca8484cccddc..04c58e9ca490 100644
--- a/arch/arm/boot/dts/tegra20-ventana.dts
+++ b/arch/arm/boot/dts/tegra20-ventana.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000d000/tps6586x@34"; 11 rtc0 = "/i2c@7000d000/tps6586x@34";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uartd;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts b/arch/arm/boot/dts/tegra20-whistler.dts
index 1843725785c9..340d81108df1 100644
--- a/arch/arm/boot/dts/tegra20-whistler.dts
+++ b/arch/arm/boot/dts/tegra20-whistler.dts
@@ -10,6 +10,7 @@
10 aliases { 10 aliases {
11 rtc0 = "/i2c@7000d000/max8907@3c"; 11 rtc0 = "/i2c@7000d000/max8907@3c";
12 rtc1 = "/rtc@7000e000"; 12 rtc1 = "/rtc@7000e000";
13 serial0 = &uarta;
13 }; 14 };
14 15
15 memory { 16 memory {
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 3b374c49d04d..8acf5d85c99d 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -9,14 +9,6 @@
9 compatible = "nvidia,tegra20"; 9 compatible = "nvidia,tegra20";
10 interrupt-parent = <&intc>; 10 interrupt-parent = <&intc>;
11 11
12 aliases {
13 serial0 = &uarta;
14 serial1 = &uartb;
15 serial2 = &uartc;
16 serial3 = &uartd;
17 serial4 = &uarte;
18 };
19
20 host1x@50000000 { 12 host1x@50000000 {
21 compatible = "nvidia,tegra20-host1x", "simple-bus"; 13 compatible = "nvidia,tegra20-host1x", "simple-bus";
22 reg = <0x50000000 0x00024000>; 14 reg = <0x50000000 0x00024000>;
diff --git a/arch/arm/boot/dts/tegra30-apalis-eval.dts b/arch/arm/boot/dts/tegra30-apalis-eval.dts
index 45d40f024585..6236bdecb48b 100644
--- a/arch/arm/boot/dts/tegra30-apalis-eval.dts
+++ b/arch/arm/boot/dts/tegra30-apalis-eval.dts
@@ -11,6 +11,10 @@
11 rtc0 = "/i2c@7000c000/rtc@68"; 11 rtc0 = "/i2c@7000c000/rtc@68";
12 rtc1 = "/i2c@7000d000/tps65911@2d"; 12 rtc1 = "/i2c@7000d000/tps65911@2d";
13 rtc2 = "/rtc@7000e000"; 13 rtc2 = "/rtc@7000e000";
14 serial0 = &uarta;
15 serial1 = &uartb;
16 serial2 = &uartc;
17 serial3 = &uartd;
14 }; 18 };
15 19
16 pcie-controller@00003000 { 20 pcie-controller@00003000 {
diff --git a/arch/arm/boot/dts/tegra30-beaver.dts b/arch/arm/boot/dts/tegra30-beaver.dts
index cee8f2246fdb..6b157eeabcc5 100644
--- a/arch/arm/boot/dts/tegra30-beaver.dts
+++ b/arch/arm/boot/dts/tegra30-beaver.dts
@@ -9,6 +9,7 @@
9 aliases { 9 aliases {
10 rtc0 = "/i2c@7000d000/tps65911@2d"; 10 rtc0 = "/i2c@7000d000/tps65911@2d";
11 rtc1 = "/rtc@7000e000"; 11 rtc1 = "/rtc@7000e000";
12 serial0 = &uarta;
12 }; 13 };
13 14
14 memory { 15 memory {
diff --git a/arch/arm/boot/dts/tegra30-cardhu.dtsi b/arch/arm/boot/dts/tegra30-cardhu.dtsi
index 206379546244..a1b682ea01bd 100644
--- a/arch/arm/boot/dts/tegra30-cardhu.dtsi
+++ b/arch/arm/boot/dts/tegra30-cardhu.dtsi
@@ -30,6 +30,8 @@
30 aliases { 30 aliases {
31 rtc0 = "/i2c@7000d000/tps65911@2d"; 31 rtc0 = "/i2c@7000d000/tps65911@2d";
32 rtc1 = "/rtc@7000e000"; 32 rtc1 = "/rtc@7000e000";
33 serial0 = &uarta;
34 serial1 = &uartc;
33 }; 35 };
34 36
35 memory { 37 memory {
diff --git a/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts b/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
index 7793abd5bef1..4d3ddc585641 100644
--- a/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
+++ b/arch/arm/boot/dts/tegra30-colibri-eval-v3.dts
@@ -10,6 +10,9 @@
10 rtc0 = "/i2c@7000c000/rtc@68"; 10 rtc0 = "/i2c@7000c000/rtc@68";
11 rtc1 = "/i2c@7000d000/tps65911@2d"; 11 rtc1 = "/i2c@7000d000/tps65911@2d";
12 rtc2 = "/rtc@7000e000"; 12 rtc2 = "/rtc@7000e000";
13 serial0 = &uarta;
14 serial1 = &uartb;
15 serial2 = &uartd;
13 }; 16 };
14 17
15 host1x@50000000 { 18 host1x@50000000 {
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index aa6ccea13d30..b270b9e3d455 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -9,14 +9,6 @@
9 compatible = "nvidia,tegra30"; 9 compatible = "nvidia,tegra30";
10 interrupt-parent = <&intc>; 10 interrupt-parent = <&intc>;
11 11
12 aliases {
13 serial0 = &uarta;
14 serial1 = &uartb;
15 serial2 = &uartc;
16 serial3 = &uartd;
17 serial4 = &uarte;
18 };
19
20 pcie-controller@00003000 { 12 pcie-controller@00003000 {
21 compatible = "nvidia,tegra30-pcie"; 13 compatible = "nvidia,tegra30-pcie";
22 device_type = "pci"; 14 device_type = "pci";
diff --git a/arch/arm/configs/exynos_defconfig b/arch/arm/configs/exynos_defconfig
index 72058b8a6f4d..e21ef830a483 100644
--- a/arch/arm/configs/exynos_defconfig
+++ b/arch/arm/configs/exynos_defconfig
@@ -142,11 +142,13 @@ CONFIG_MMC_DW_IDMAC=y
142CONFIG_MMC_DW_EXYNOS=y 142CONFIG_MMC_DW_EXYNOS=y
143CONFIG_RTC_CLASS=y 143CONFIG_RTC_CLASS=y
144CONFIG_RTC_DRV_MAX77686=y 144CONFIG_RTC_DRV_MAX77686=y
145CONFIG_RTC_DRV_MAX77802=y
145CONFIG_RTC_DRV_S5M=y 146CONFIG_RTC_DRV_S5M=y
146CONFIG_RTC_DRV_S3C=y 147CONFIG_RTC_DRV_S3C=y
147CONFIG_DMADEVICES=y 148CONFIG_DMADEVICES=y
148CONFIG_PL330_DMA=y 149CONFIG_PL330_DMA=y
149CONFIG_COMMON_CLK_MAX77686=y 150CONFIG_COMMON_CLK_MAX77686=y
151CONFIG_COMMON_CLK_MAX77802=y
150CONFIG_COMMON_CLK_S2MPS11=y 152CONFIG_COMMON_CLK_S2MPS11=y
151CONFIG_EXYNOS_IOMMU=y 153CONFIG_EXYNOS_IOMMU=y
152CONFIG_IIO=y 154CONFIG_IIO=y
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index 3487046d8a78..9d7a32f93fcf 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -217,6 +217,7 @@ CONFIG_I2C_CADENCE=y
217CONFIG_I2C_DESIGNWARE_PLATFORM=y 217CONFIG_I2C_DESIGNWARE_PLATFORM=y
218CONFIG_I2C_EXYNOS5=y 218CONFIG_I2C_EXYNOS5=y
219CONFIG_I2C_MV64XXX=y 219CONFIG_I2C_MV64XXX=y
220CONFIG_I2C_S3C2410=y
220CONFIG_I2C_SIRF=y 221CONFIG_I2C_SIRF=y
221CONFIG_I2C_TEGRA=y 222CONFIG_I2C_TEGRA=y
222CONFIG_I2C_ST=y 223CONFIG_I2C_ST=y
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index fc44d3761f9e..ce73ab635414 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -44,16 +44,6 @@ struct cpu_context_save {
44 __u32 extra[2]; /* Xscale 'acc' register, etc */ 44 __u32 extra[2]; /* Xscale 'acc' register, etc */
45}; 45};
46 46
47struct arm_restart_block {
48 union {
49 /* For user cache flushing */
50 struct {
51 unsigned long start;
52 unsigned long end;
53 } cache;
54 };
55};
56
57/* 47/*
58 * low level task data that entry.S needs immediate access to. 48 * low level task data that entry.S needs immediate access to.
59 * __switch_to() assumes cpu_context follows immediately after cpu_domain. 49 * __switch_to() assumes cpu_context follows immediately after cpu_domain.
@@ -79,7 +69,6 @@ struct thread_info {
79 unsigned long thumbee_state; /* ThumbEE Handler Base register */ 69 unsigned long thumbee_state; /* ThumbEE Handler Base register */
80#endif 70#endif
81 struct restart_block restart_block; 71 struct restart_block restart_block;
82 struct arm_restart_block arm_restart_block;
83}; 72};
84 73
85#define INIT_THREAD_INFO(tsk) \ 74#define INIT_THREAD_INFO(tsk) \
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 0c8b10801d36..9f5d81881eb6 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -533,8 +533,6 @@ static int bad_syscall(int n, struct pt_regs *regs)
533 return regs->ARM_r0; 533 return regs->ARM_r0;
534} 534}
535 535
536static long do_cache_op_restart(struct restart_block *);
537
538static inline int 536static inline int
539__do_cache_op(unsigned long start, unsigned long end) 537__do_cache_op(unsigned long start, unsigned long end)
540{ 538{
@@ -543,24 +541,8 @@ __do_cache_op(unsigned long start, unsigned long end)
543 do { 541 do {
544 unsigned long chunk = min(PAGE_SIZE, end - start); 542 unsigned long chunk = min(PAGE_SIZE, end - start);
545 543
546 if (signal_pending(current)) { 544 if (fatal_signal_pending(current))
547 struct thread_info *ti = current_thread_info(); 545 return 0;
548
549 ti->restart_block = (struct restart_block) {
550 .fn = do_cache_op_restart,
551 };
552
553 ti->arm_restart_block = (struct arm_restart_block) {
554 {
555 .cache = {
556 .start = start,
557 .end = end,
558 },
559 },
560 };
561
562 return -ERESTART_RESTARTBLOCK;
563 }
564 546
565 ret = flush_cache_user_range(start, start + chunk); 547 ret = flush_cache_user_range(start, start + chunk);
566 if (ret) 548 if (ret)
@@ -573,15 +555,6 @@ __do_cache_op(unsigned long start, unsigned long end)
573 return 0; 555 return 0;
574} 556}
575 557
576static long do_cache_op_restart(struct restart_block *unused)
577{
578 struct arm_restart_block *restart_block;
579
580 restart_block = &current_thread_info()->arm_restart_block;
581 return __do_cache_op(restart_block->cache.start,
582 restart_block->cache.end);
583}
584
585static inline int 558static inline int
586do_cache_op(unsigned long start, unsigned long end, int flags) 559do_cache_op(unsigned long start, unsigned long end, int flags)
587{ 560{
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 57a403a5c22b..8664ff17cbbe 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -197,7 +197,8 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
197 pgd = pgdp + pgd_index(addr); 197 pgd = pgdp + pgd_index(addr);
198 do { 198 do {
199 next = kvm_pgd_addr_end(addr, end); 199 next = kvm_pgd_addr_end(addr, end);
200 unmap_puds(kvm, pgd, addr, next); 200 if (!pgd_none(*pgd))
201 unmap_puds(kvm, pgd, addr, next);
201 } while (pgd++, addr = next, addr != end); 202 } while (pgd++, addr = next, addr != end);
202} 203}
203 204
@@ -834,6 +835,11 @@ static bool kvm_is_write_fault(struct kvm_vcpu *vcpu)
834 return kvm_vcpu_dabt_iswrite(vcpu); 835 return kvm_vcpu_dabt_iswrite(vcpu);
835} 836}
836 837
838static bool kvm_is_device_pfn(unsigned long pfn)
839{
840 return !pfn_valid(pfn);
841}
842
837static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, 843static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
838 struct kvm_memory_slot *memslot, unsigned long hva, 844 struct kvm_memory_slot *memslot, unsigned long hva,
839 unsigned long fault_status) 845 unsigned long fault_status)
@@ -904,7 +910,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
904 if (is_error_pfn(pfn)) 910 if (is_error_pfn(pfn))
905 return -EFAULT; 911 return -EFAULT;
906 912
907 if (kvm_is_mmio_pfn(pfn)) 913 if (kvm_is_device_pfn(pfn))
908 mem_type = PAGE_S2_DEVICE; 914 mem_type = PAGE_S2_DEVICE;
909 915
910 spin_lock(&kvm->mmu_lock); 916 spin_lock(&kvm->mmu_lock);
diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index 6478626e3ff6..d0d39f150fab 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -188,7 +188,7 @@ static void __init thermal_quirk(void)
188 188
189static void __init mvebu_dt_init(void) 189static void __init mvebu_dt_init(void)
190{ 190{
191 if (of_machine_is_compatible("plathome,openblocks-ax3-4")) 191 if (of_machine_is_compatible("marvell,armadaxp"))
192 i2c_quirk(); 192 i2c_quirk();
193 if (of_machine_is_compatible("marvell,a375-db")) { 193 if (of_machine_is_compatible("marvell,a375-db")) {
194 external_abort_quirk(); 194 external_abort_quirk();
diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index 2bdc3233abe2..044b51185fcc 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -400,6 +400,8 @@ int __init coherency_init(void)
400 type == COHERENCY_FABRIC_TYPE_ARMADA_380) 400 type == COHERENCY_FABRIC_TYPE_ARMADA_380)
401 armada_375_380_coherency_init(np); 401 armada_375_380_coherency_init(np);
402 402
403 of_node_put(np);
404
403 return 0; 405 return 0;
404} 406}
405 407
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index 969e85dad09b..9cac8247c72b 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -451,7 +451,7 @@ enum {
451 MSTP128, MSTP127, MSTP125, 451 MSTP128, MSTP127, MSTP125,
452 MSTP116, MSTP111, MSTP100, MSTP117, 452 MSTP116, MSTP111, MSTP100, MSTP117,
453 453
454 MSTP230, 454 MSTP230, MSTP229,
455 MSTP222, 455 MSTP222,
456 MSTP218, MSTP217, MSTP216, MSTP214, 456 MSTP218, MSTP217, MSTP216, MSTP214,
457 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200, 457 MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, MSTP201, MSTP200,
@@ -470,11 +470,12 @@ static struct clk mstp_clks[MSTP_NR] = {
470 [MSTP127] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 27, 0), /* CEU20 */ 470 [MSTP127] = SH_CLK_MSTP32(&div4_clks[DIV4_S], SMSTPCR1, 27, 0), /* CEU20 */
471 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */ 471 [MSTP125] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 25, 0), /* TMU0 */
472 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */ 472 [MSTP117] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 17, 0), /* LCDC1 */
473 [MSTP116] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 16, 0), /* IIC0 */ 473 [MSTP116] = SH_CLK_MSTP32(&div4_clks[DIV4_HPP], SMSTPCR1, 16, 0), /* IIC0 */
474 [MSTP111] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 11, 0), /* TMU1 */ 474 [MSTP111] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR1, 11, 0), /* TMU1 */
475 [MSTP100] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */ 475 [MSTP100] = SH_CLK_MSTP32(&div4_clks[DIV4_B], SMSTPCR1, 0, 0), /* LCDC0 */
476 476
477 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */ 477 [MSTP230] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 30, 0), /* SCIFA6 */
478 [MSTP229] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 29, 0), /* INTCA */
478 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */ 479 [MSTP222] = SH_CLK_MSTP32(&div6_clks[DIV6_SUB], SMSTPCR2, 22, 0), /* SCIFA7 */
479 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */ 480 [MSTP218] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 18, 0), /* DMAC1 */
480 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */ 481 [MSTP217] = SH_CLK_MSTP32(&div4_clks[DIV4_HP], SMSTPCR2, 17, 0), /* DMAC2 */
@@ -571,6 +572,10 @@ static struct clk_lookup lookups[] = {
571 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), 572 CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]),
572 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]), 573 CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP222]),
573 CLKDEV_DEV_ID("e6cd0000.serial", &mstp_clks[MSTP222]), 574 CLKDEV_DEV_ID("e6cd0000.serial", &mstp_clks[MSTP222]),
575 CLKDEV_DEV_ID("renesas_intc_irqpin.0", &mstp_clks[MSTP229]),
576 CLKDEV_DEV_ID("renesas_intc_irqpin.1", &mstp_clks[MSTP229]),
577 CLKDEV_DEV_ID("renesas_intc_irqpin.2", &mstp_clks[MSTP229]),
578 CLKDEV_DEV_ID("renesas_intc_irqpin.3", &mstp_clks[MSTP229]),
574 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]), 579 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP230]),
575 CLKDEV_DEV_ID("e6cc0000.serial", &mstp_clks[MSTP230]), 580 CLKDEV_DEV_ID("e6cc0000.serial", &mstp_clks[MSTP230]),
576 581
diff --git a/arch/arm/mach-shmobile/clock-r8a7790.c b/arch/arm/mach-shmobile/clock-r8a7790.c
index c395ff194254..f9bbc5f0a9a1 100644
--- a/arch/arm/mach-shmobile/clock-r8a7790.c
+++ b/arch/arm/mach-shmobile/clock-r8a7790.c
@@ -64,7 +64,7 @@
64 64
65#define SDCKCR 0xE6150074 65#define SDCKCR 0xE6150074
66#define SD2CKCR 0xE6150078 66#define SD2CKCR 0xE6150078
67#define SD3CKCR 0xE615007C 67#define SD3CKCR 0xE615026C
68#define MMC0CKCR 0xE6150240 68#define MMC0CKCR 0xE6150240
69#define MMC1CKCR 0xE6150244 69#define MMC1CKCR 0xE6150244
70#define SSPCKCR 0xE6150248 70#define SSPCKCR 0xE6150248
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 1c8172dc2c6c..f2e01dc22a08 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -22,6 +22,7 @@
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/i2c/i2c-sh_mobile.h>
25#include <linux/io.h> 26#include <linux/io.h>
26#include <linux/serial_sci.h> 27#include <linux/serial_sci.h>
27#include <linux/sh_dma.h> 28#include <linux/sh_dma.h>
@@ -188,11 +189,18 @@ static struct resource i2c4_resources[] = {
188 }, 189 },
189}; 190};
190 191
192static struct i2c_sh_mobile_platform_data i2c_platform_data = {
193 .clks_per_count = 2,
194};
195
191static struct platform_device i2c0_device = { 196static struct platform_device i2c0_device = {
192 .name = "i2c-sh_mobile", 197 .name = "i2c-sh_mobile",
193 .id = 0, 198 .id = 0,
194 .resource = i2c0_resources, 199 .resource = i2c0_resources,
195 .num_resources = ARRAY_SIZE(i2c0_resources), 200 .num_resources = ARRAY_SIZE(i2c0_resources),
201 .dev = {
202 .platform_data = &i2c_platform_data,
203 },
196}; 204};
197 205
198static struct platform_device i2c1_device = { 206static struct platform_device i2c1_device = {
@@ -200,6 +208,9 @@ static struct platform_device i2c1_device = {
200 .id = 1, 208 .id = 1,
201 .resource = i2c1_resources, 209 .resource = i2c1_resources,
202 .num_resources = ARRAY_SIZE(i2c1_resources), 210 .num_resources = ARRAY_SIZE(i2c1_resources),
211 .dev = {
212 .platform_data = &i2c_platform_data,
213 },
203}; 214};
204 215
205static struct platform_device i2c2_device = { 216static struct platform_device i2c2_device = {
@@ -207,6 +218,9 @@ static struct platform_device i2c2_device = {
207 .id = 2, 218 .id = 2,
208 .resource = i2c2_resources, 219 .resource = i2c2_resources,
209 .num_resources = ARRAY_SIZE(i2c2_resources), 220 .num_resources = ARRAY_SIZE(i2c2_resources),
221 .dev = {
222 .platform_data = &i2c_platform_data,
223 },
210}; 224};
211 225
212static struct platform_device i2c3_device = { 226static struct platform_device i2c3_device = {
@@ -214,6 +228,9 @@ static struct platform_device i2c3_device = {
214 .id = 3, 228 .id = 3,
215 .resource = i2c3_resources, 229 .resource = i2c3_resources,
216 .num_resources = ARRAY_SIZE(i2c3_resources), 230 .num_resources = ARRAY_SIZE(i2c3_resources),
231 .dev = {
232 .platform_data = &i2c_platform_data,
233 },
217}; 234};
218 235
219static struct platform_device i2c4_device = { 236static struct platform_device i2c4_device = {
@@ -221,6 +238,9 @@ static struct platform_device i2c4_device = {
221 .id = 4, 238 .id = 4,
222 .resource = i2c4_resources, 239 .resource = i2c4_resources,
223 .num_resources = ARRAY_SIZE(i2c4_resources), 240 .num_resources = ARRAY_SIZE(i2c4_resources),
241 .dev = {
242 .platform_data = &i2c_platform_data,
243 },
224}; 244};
225 245
226static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = { 246static const struct sh_dmae_slave_config sh73a0_dmae_slaves[] = {
diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
index da7be13aecce..ab95f5391a2b 100644
--- a/arch/arm/mach-tegra/irq.c
+++ b/arch/arm/mach-tegra/irq.c
@@ -99,42 +99,42 @@ static inline void tegra_irq_write_mask(unsigned int irq, unsigned long reg)
99 99
100static void tegra_mask(struct irq_data *d) 100static void tegra_mask(struct irq_data *d)
101{ 101{
102 if (d->irq < FIRST_LEGACY_IRQ) 102 if (d->hwirq < FIRST_LEGACY_IRQ)
103 return; 103 return;
104 104
105 tegra_irq_write_mask(d->irq, ICTLR_CPU_IER_CLR); 105 tegra_irq_write_mask(d->hwirq, ICTLR_CPU_IER_CLR);
106} 106}
107 107
108static void tegra_unmask(struct irq_data *d) 108static void tegra_unmask(struct irq_data *d)
109{ 109{
110 if (d->irq < FIRST_LEGACY_IRQ) 110 if (d->hwirq < FIRST_LEGACY_IRQ)
111 return; 111 return;
112 112
113 tegra_irq_write_mask(d->irq, ICTLR_CPU_IER_SET); 113 tegra_irq_write_mask(d->hwirq, ICTLR_CPU_IER_SET);
114} 114}
115 115
116static void tegra_ack(struct irq_data *d) 116static void tegra_ack(struct irq_data *d)
117{ 117{
118 if (d->irq < FIRST_LEGACY_IRQ) 118 if (d->hwirq < FIRST_LEGACY_IRQ)
119 return; 119 return;
120 120
121 tegra_irq_write_mask(d->irq, ICTLR_CPU_IEP_FIR_CLR); 121 tegra_irq_write_mask(d->hwirq, ICTLR_CPU_IEP_FIR_CLR);
122} 122}
123 123
124static void tegra_eoi(struct irq_data *d) 124static void tegra_eoi(struct irq_data *d)
125{ 125{
126 if (d->irq < FIRST_LEGACY_IRQ) 126 if (d->hwirq < FIRST_LEGACY_IRQ)
127 return; 127 return;
128 128
129 tegra_irq_write_mask(d->irq, ICTLR_CPU_IEP_FIR_CLR); 129 tegra_irq_write_mask(d->hwirq, ICTLR_CPU_IEP_FIR_CLR);
130} 130}
131 131
132static int tegra_retrigger(struct irq_data *d) 132static int tegra_retrigger(struct irq_data *d)
133{ 133{
134 if (d->irq < FIRST_LEGACY_IRQ) 134 if (d->hwirq < FIRST_LEGACY_IRQ)
135 return 0; 135 return 0;
136 136
137 tegra_irq_write_mask(d->irq, ICTLR_CPU_IEP_FIR_SET); 137 tegra_irq_write_mask(d->hwirq, ICTLR_CPU_IEP_FIR_SET);
138 138
139 return 1; 139 return 1;
140} 140}
@@ -142,7 +142,7 @@ static int tegra_retrigger(struct irq_data *d)
142#ifdef CONFIG_PM_SLEEP 142#ifdef CONFIG_PM_SLEEP
143static int tegra_set_wake(struct irq_data *d, unsigned int enable) 143static int tegra_set_wake(struct irq_data *d, unsigned int enable)
144{ 144{
145 u32 irq = d->irq; 145 u32 irq = d->hwirq;
146 u32 index, mask; 146 u32 index, mask;
147 147
148 if (irq < FIRST_LEGACY_IRQ || 148 if (irq < FIRST_LEGACY_IRQ ||
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index ae69809a9e47..7eb94e6fc376 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -798,6 +798,7 @@ config NEED_KUSER_HELPERS
798 798
799config KUSER_HELPERS 799config KUSER_HELPERS
800 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS 800 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
801 depends on MMU
801 default y 802 default y
802 help 803 help
803 Warning: disabling this option may break user programs. 804 Warning: disabling this option may break user programs.
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index b3a947863ac7..22ac2a6fbfe3 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -270,7 +270,6 @@ __v7_pj4b_setup:
270/* Auxiliary Debug Modes Control 1 Register */ 270/* Auxiliary Debug Modes Control 1 Register */
271#define PJ4B_STATIC_BP (1 << 2) /* Enable Static BP */ 271#define PJ4B_STATIC_BP (1 << 2) /* Enable Static BP */
272#define PJ4B_INTER_PARITY (1 << 8) /* Disable Internal Parity Handling */ 272#define PJ4B_INTER_PARITY (1 << 8) /* Disable Internal Parity Handling */
273#define PJ4B_BCK_OFF_STREX (1 << 5) /* Enable the back off of STREX instr */
274#define PJ4B_CLEAN_LINE (1 << 16) /* Disable data transfer for clean line */ 273#define PJ4B_CLEAN_LINE (1 << 16) /* Disable data transfer for clean line */
275 274
276/* Auxiliary Debug Modes Control 2 Register */ 275/* Auxiliary Debug Modes Control 2 Register */
@@ -293,7 +292,6 @@ __v7_pj4b_setup:
293 /* Auxiliary Debug Modes Control 1 Register */ 292 /* Auxiliary Debug Modes Control 1 Register */
294 mrc p15, 1, r0, c15, c1, 1 293 mrc p15, 1, r0, c15, c1, 1
295 orr r0, r0, #PJ4B_CLEAN_LINE 294 orr r0, r0, #PJ4B_CLEAN_LINE
296 orr r0, r0, #PJ4B_BCK_OFF_STREX
297 orr r0, r0, #PJ4B_INTER_PARITY 295 orr r0, r0, #PJ4B_INTER_PARITY
298 bic r0, r0, #PJ4B_STATIC_BP 296 bic r0, r0, #PJ4B_STATIC_BP
299 mcr p15, 1, r0, c15, c1, 1 297 mcr p15, 1, r0, c15, c1, 1
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 23259f104c66..afa2b3c4df4a 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -535,7 +535,7 @@ ENTRY(cpu_xscale_do_suspend)
535 mrc p15, 0, r5, c15, c1, 0 @ CP access reg 535 mrc p15, 0, r5, c15, c1, 0 @ CP access reg
536 mrc p15, 0, r6, c13, c0, 0 @ PID 536 mrc p15, 0, r6, c13, c0, 0 @ PID
537 mrc p15, 0, r7, c3, c0, 0 @ domain ID 537 mrc p15, 0, r7, c3, c0, 0 @ domain ID
538 mrc p15, 0, r8, c1, c1, 0 @ auxiliary control reg 538 mrc p15, 0, r8, c1, c0, 1 @ auxiliary control reg
539 mrc p15, 0, r9, c1, c0, 0 @ control reg 539 mrc p15, 0, r9, c1, c0, 0 @ control reg
540 bic r4, r4, #2 @ clear frequency change bit 540 bic r4, r4, #2 @ clear frequency change bit
541 stmia r0, {r4 - r9} @ store cp regs 541 stmia r0, {r4 - r9} @ store cp regs
@@ -552,7 +552,7 @@ ENTRY(cpu_xscale_do_resume)
552 mcr p15, 0, r6, c13, c0, 0 @ PID 552 mcr p15, 0, r6, c13, c0, 0 @ PID
553 mcr p15, 0, r7, c3, c0, 0 @ domain ID 553 mcr p15, 0, r7, c3, c0, 0 @ domain ID
554 mcr p15, 0, r1, c2, c0, 0 @ translation table base addr 554 mcr p15, 0, r1, c2, c0, 0 @ translation table base addr
555 mcr p15, 0, r8, c1, c1, 0 @ auxiliary control reg 555 mcr p15, 0, r8, c1, c0, 1 @ auxiliary control reg
556 mov r0, r9 @ control register 556 mov r0, r9 @ control register
557 b cpu_resume_mmu 557 b cpu_resume_mmu
558ENDPROC(cpu_xscale_do_resume) 558ENDPROC(cpu_xscale_do_resume)
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c
index b61a3bcc2fa8..e048f6198d68 100644
--- a/arch/arm/plat-orion/gpio.c
+++ b/arch/arm/plat-orion/gpio.c
@@ -497,6 +497,34 @@ static void orion_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
497#define orion_gpio_dbg_show NULL 497#define orion_gpio_dbg_show NULL
498#endif 498#endif
499 499
500static void orion_gpio_unmask_irq(struct irq_data *d)
501{
502 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
503 struct irq_chip_type *ct = irq_data_get_chip_type(d);
504 u32 reg_val;
505 u32 mask = d->mask;
506
507 irq_gc_lock(gc);
508 reg_val = irq_reg_readl(gc->reg_base + ct->regs.mask);
509 reg_val |= mask;
510 irq_reg_writel(reg_val, gc->reg_base + ct->regs.mask);
511 irq_gc_unlock(gc);
512}
513
514static void orion_gpio_mask_irq(struct irq_data *d)
515{
516 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
517 struct irq_chip_type *ct = irq_data_get_chip_type(d);
518 u32 mask = d->mask;
519 u32 reg_val;
520
521 irq_gc_lock(gc);
522 reg_val = irq_reg_readl(gc->reg_base + ct->regs.mask);
523 reg_val &= ~mask;
524 irq_reg_writel(reg_val, gc->reg_base + ct->regs.mask);
525 irq_gc_unlock(gc);
526}
527
500void __init orion_gpio_init(struct device_node *np, 528void __init orion_gpio_init(struct device_node *np,
501 int gpio_base, int ngpio, 529 int gpio_base, int ngpio,
502 void __iomem *base, int mask_offset, 530 void __iomem *base, int mask_offset,
@@ -565,8 +593,8 @@ void __init orion_gpio_init(struct device_node *np,
565 ct = gc->chip_types; 593 ct = gc->chip_types;
566 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF; 594 ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF;
567 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW; 595 ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
568 ct->chip.irq_mask = irq_gc_mask_clr_bit; 596 ct->chip.irq_mask = orion_gpio_mask_irq;
569 ct->chip.irq_unmask = irq_gc_mask_set_bit; 597 ct->chip.irq_unmask = orion_gpio_unmask_irq;
570 ct->chip.irq_set_type = gpio_irq_set_type; 598 ct->chip.irq_set_type = gpio_irq_set_type;
571 ct->chip.name = ochip->chip.label; 599 ct->chip.name = ochip->chip.label;
572 600
@@ -575,8 +603,8 @@ void __init orion_gpio_init(struct device_node *np,
575 ct->regs.ack = GPIO_EDGE_CAUSE_OFF; 603 ct->regs.ack = GPIO_EDGE_CAUSE_OFF;
576 ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; 604 ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
577 ct->chip.irq_ack = irq_gc_ack_clr_bit; 605 ct->chip.irq_ack = irq_gc_ack_clr_bit;
578 ct->chip.irq_mask = irq_gc_mask_clr_bit; 606 ct->chip.irq_mask = orion_gpio_mask_irq;
579 ct->chip.irq_unmask = irq_gc_mask_set_bit; 607 ct->chip.irq_unmask = orion_gpio_unmask_irq;
580 ct->chip.irq_set_type = gpio_irq_set_type; 608 ct->chip.irq_set_type = gpio_irq_set_type;
581 ct->handler = handle_edge_irq; 609 ct->handler = handle_edge_irq;
582 ct->chip.name = ochip->chip.label; 610 ct->chip.name = ochip->chip.label;
diff --git a/arch/arm64/boot/dts/apm-storm.dtsi b/arch/arm64/boot/dts/apm-storm.dtsi
index 295c72d52a1f..f1ad9c2ab2e9 100644
--- a/arch/arm64/boot/dts/apm-storm.dtsi
+++ b/arch/arm64/boot/dts/apm-storm.dtsi
@@ -599,7 +599,7 @@
599 compatible = "apm,xgene-enet"; 599 compatible = "apm,xgene-enet";
600 status = "disabled"; 600 status = "disabled";
601 reg = <0x0 0x17020000 0x0 0xd100>, 601 reg = <0x0 0x17020000 0x0 0xd100>,
602 <0x0 0X17030000 0x0 0X400>, 602 <0x0 0X17030000 0x0 0Xc300>,
603 <0x0 0X10000000 0x0 0X200>; 603 <0x0 0X10000000 0x0 0X200>;
604 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 604 reg-names = "enet_csr", "ring_csr", "ring_cmd";
605 interrupts = <0x0 0x3c 0x4>; 605 interrupts = <0x0 0x3c 0x4>;
@@ -624,9 +624,9 @@
624 sgenet0: ethernet@1f210000 { 624 sgenet0: ethernet@1f210000 {
625 compatible = "apm,xgene-enet"; 625 compatible = "apm,xgene-enet";
626 status = "disabled"; 626 status = "disabled";
627 reg = <0x0 0x1f210000 0x0 0x10000>, 627 reg = <0x0 0x1f210000 0x0 0xd100>,
628 <0x0 0x1f200000 0x0 0X10000>, 628 <0x0 0x1f200000 0x0 0Xc300>,
629 <0x0 0x1B000000 0x0 0X20000>; 629 <0x0 0x1B000000 0x0 0X200>;
630 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 630 reg-names = "enet_csr", "ring_csr", "ring_cmd";
631 interrupts = <0x0 0xA0 0x4>; 631 interrupts = <0x0 0xA0 0x4>;
632 dma-coherent; 632 dma-coherent;
@@ -639,7 +639,7 @@
639 compatible = "apm,xgene-enet"; 639 compatible = "apm,xgene-enet";
640 status = "disabled"; 640 status = "disabled";
641 reg = <0x0 0x1f610000 0x0 0xd100>, 641 reg = <0x0 0x1f610000 0x0 0xd100>,
642 <0x0 0x1f600000 0x0 0X400>, 642 <0x0 0x1f600000 0x0 0Xc300>,
643 <0x0 0x18000000 0x0 0X200>; 643 <0x0 0x18000000 0x0 0X200>;
644 reg-names = "enet_csr", "ring_csr", "ring_cmd"; 644 reg-names = "enet_csr", "ring_csr", "ring_cmd";
645 interrupts = <0x0 0x60 0x4>; 645 interrupts = <0x0 0x60 0x4>;
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index ccc7087d3c4e..a62cd077457b 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -142,7 +142,7 @@ static inline void *phys_to_virt(phys_addr_t x)
142 * virt_to_page(k) convert a _valid_ virtual address to struct page * 142 * virt_to_page(k) convert a _valid_ virtual address to struct page *
143 * virt_addr_valid(k) indicates whether a virtual address is valid 143 * virt_addr_valid(k) indicates whether a virtual address is valid
144 */ 144 */
145#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 145#define ARCH_PFN_OFFSET ((unsigned long)PHYS_PFN_OFFSET)
146 146
147#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 147#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
148#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 148#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S
index 619b1dd7bcde..d18a44940968 100644
--- a/arch/arm64/kernel/efi-entry.S
+++ b/arch/arm64/kernel/efi-entry.S
@@ -54,18 +54,17 @@ ENTRY(efi_stub_entry)
54 b.eq efi_load_fail 54 b.eq efi_load_fail
55 55
56 /* 56 /*
57 * efi_entry() will have relocated the kernel image if necessary 57 * efi_entry() will have copied the kernel image if necessary and we
58 * and we return here with device tree address in x0 and the kernel 58 * return here with device tree address in x0 and the kernel entry
59 * entry point stored at *image_addr. Save those values in registers 59 * point stored at *image_addr. Save those values in registers which
60 * which are callee preserved. 60 * are callee preserved.
61 */ 61 */
62 mov x20, x0 // DTB address 62 mov x20, x0 // DTB address
63 ldr x0, [sp, #16] // relocated _text address 63 ldr x0, [sp, #16] // relocated _text address
64 mov x21, x0 64 mov x21, x0
65 65
66 /* 66 /*
67 * Flush dcache covering current runtime addresses 67 * Calculate size of the kernel Image (same for original and copy).
68 * of kernel text/data. Then flush all of icache.
69 */ 68 */
70 adrp x1, _text 69 adrp x1, _text
71 add x1, x1, #:lo12:_text 70 add x1, x1, #:lo12:_text
@@ -73,9 +72,24 @@ ENTRY(efi_stub_entry)
73 add x2, x2, #:lo12:_edata 72 add x2, x2, #:lo12:_edata
74 sub x1, x2, x1 73 sub x1, x2, x1
75 74
75 /*
76 * Flush the copied Image to the PoC, and ensure it is not shadowed by
77 * stale icache entries from before relocation.
78 */
76 bl __flush_dcache_area 79 bl __flush_dcache_area
77 ic ialluis 80 ic ialluis
78 81
82 /*
83 * Ensure that the rest of this function (in the original Image) is
84 * visible when the caches are disabled. The I-cache can't have stale
85 * entries for the VA range of the current image, so no maintenance is
86 * necessary.
87 */
88 adr x0, efi_stub_entry
89 adr x1, efi_stub_entry_end
90 sub x1, x1, x0
91 bl __flush_dcache_area
92
79 /* Turn off Dcache and MMU */ 93 /* Turn off Dcache and MMU */
80 mrs x0, CurrentEL 94 mrs x0, CurrentEL
81 cmp x0, #CurrentEL_EL2 95 cmp x0, #CurrentEL_EL2
@@ -105,4 +119,5 @@ efi_load_fail:
105 ldp x29, x30, [sp], #32 119 ldp x29, x30, [sp], #32
106 ret 120 ret
107 121
122efi_stub_entry_end:
108ENDPROC(efi_stub_entry) 123ENDPROC(efi_stub_entry)
diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
index e007714ded04..8cd27fedc8b6 100644
--- a/arch/arm64/kernel/insn.c
+++ b/arch/arm64/kernel/insn.c
@@ -163,9 +163,10 @@ static int __kprobes aarch64_insn_patch_text_cb(void *arg)
163 * which ends with "dsb; isb" pair guaranteeing global 163 * which ends with "dsb; isb" pair guaranteeing global
164 * visibility. 164 * visibility.
165 */ 165 */
166 atomic_set(&pp->cpu_count, -1); 166 /* Notify other processors with an additional increment. */
167 atomic_inc(&pp->cpu_count);
167 } else { 168 } else {
168 while (atomic_read(&pp->cpu_count) != -1) 169 while (atomic_read(&pp->cpu_count) <= num_online_cpus())
169 cpu_relax(); 170 cpu_relax();
170 isb(); 171 isb();
171 } 172 }
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 4cc3b719208e..3d7c2df89946 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -424,6 +424,11 @@ static const struct sys_reg_desc sys_reg_descs[] = {
424 /* VBAR_EL1 */ 424 /* VBAR_EL1 */
425 { Op0(0b11), Op1(0b000), CRn(0b1100), CRm(0b0000), Op2(0b000), 425 { Op0(0b11), Op1(0b000), CRn(0b1100), CRm(0b0000), Op2(0b000),
426 NULL, reset_val, VBAR_EL1, 0 }, 426 NULL, reset_val, VBAR_EL1, 0 },
427
428 /* ICC_SRE_EL1 */
429 { Op0(0b11), Op1(0b000), CRn(0b1100), CRm(0b1100), Op2(0b101),
430 trap_raz_wi },
431
427 /* CONTEXTIDR_EL1 */ 432 /* CONTEXTIDR_EL1 */
428 { Op0(0b11), Op1(0b000), CRn(0b1101), CRm(0b0000), Op2(0b001), 433 { Op0(0b11), Op1(0b000), CRn(0b1101), CRm(0b0000), Op2(0b001),
429 access_vm_reg, reset_val, CONTEXTIDR_EL1, 0 }, 434 access_vm_reg, reset_val, CONTEXTIDR_EL1, 0 },
@@ -690,6 +695,10 @@ static const struct sys_reg_desc cp15_regs[] = {
690 { Op1( 0), CRn(10), CRm( 2), Op2( 1), access_vm_reg, NULL, c10_NMRR }, 695 { Op1( 0), CRn(10), CRm( 2), Op2( 1), access_vm_reg, NULL, c10_NMRR },
691 { Op1( 0), CRn(10), CRm( 3), Op2( 0), access_vm_reg, NULL, c10_AMAIR0 }, 696 { Op1( 0), CRn(10), CRm( 3), Op2( 0), access_vm_reg, NULL, c10_AMAIR0 },
692 { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 }, 697 { Op1( 0), CRn(10), CRm( 3), Op2( 1), access_vm_reg, NULL, c10_AMAIR1 },
698
699 /* ICC_SRE */
700 { Op1( 0), CRn(12), CRm(12), Op2( 5), trap_raz_wi },
701
693 { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID }, 702 { Op1( 0), CRn(13), CRm( 0), Op2( 1), access_vm_reg, NULL, c13_CID },
694}; 703};
695 704
diff --git a/arch/arm64/lib/clear_user.S b/arch/arm64/lib/clear_user.S
index 6e0ed93d51fe..c17967fdf5f6 100644
--- a/arch/arm64/lib/clear_user.S
+++ b/arch/arm64/lib/clear_user.S
@@ -46,7 +46,7 @@ USER(9f, strh wzr, [x0], #2 )
46 sub x1, x1, #2 46 sub x1, x1, #2
474: adds x1, x1, #1 474: adds x1, x1, #1
48 b.mi 5f 48 b.mi 5f
49 strb wzr, [x0] 49USER(9f, strb wzr, [x0] )
505: mov x0, #0 505: mov x0, #0
51 ret 51 ret
52ENDPROC(__clear_user) 52ENDPROC(__clear_user)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 0bf90d26e745..f4f8b500f74c 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -202,7 +202,7 @@ static void __init alloc_init_pmd(pud_t *pud, unsigned long addr,
202} 202}
203 203
204static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, 204static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr,
205 unsigned long end, unsigned long phys, 205 unsigned long end, phys_addr_t phys,
206 int map_io) 206 int map_io)
207{ 207{
208 pud_t *pud; 208 pud_t *pud;
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index ec6b9acb6bea..dbe46f43884d 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1563,7 +1563,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
1563 1563
1564 for (i = 0; i < npages; i++) { 1564 for (i = 0; i < npages; i++) {
1565 pfn = gfn_to_pfn(kvm, base_gfn + i); 1565 pfn = gfn_to_pfn(kvm, base_gfn + i);
1566 if (!kvm_is_mmio_pfn(pfn)) { 1566 if (!kvm_is_reserved_pfn(pfn)) {
1567 kvm_set_pmt_entry(kvm, base_gfn + i, 1567 kvm_set_pmt_entry(kvm, base_gfn + i,
1568 pfn << PAGE_SHIFT, 1568 pfn << PAGE_SHIFT,
1569 _PAGE_AR_RWX | _PAGE_MA_WB); 1569 _PAGE_AR_RWX | _PAGE_MA_WB);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index f43aa536c517..9536ef912f59 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2101,9 +2101,17 @@ config 64BIT_PHYS_ADDR
2101config ARCH_PHYS_ADDR_T_64BIT 2101config ARCH_PHYS_ADDR_T_64BIT
2102 def_bool 64BIT_PHYS_ADDR 2102 def_bool 64BIT_PHYS_ADDR
2103 2103
2104choice
2105 prompt "SmartMIPS or microMIPS ASE support"
2106
2107config CPU_NEEDS_NO_SMARTMIPS_OR_MICROMIPS
2108 bool "None"
2109 help
2110 Select this if you want neither microMIPS nor SmartMIPS support
2111
2104config CPU_HAS_SMARTMIPS 2112config CPU_HAS_SMARTMIPS
2105 depends on SYS_SUPPORTS_SMARTMIPS 2113 depends on SYS_SUPPORTS_SMARTMIPS
2106 bool "Support for the SmartMIPS ASE" 2114 bool "SmartMIPS"
2107 help 2115 help
2108 SmartMIPS is a extension of the MIPS32 architecture aimed at 2116 SmartMIPS is a extension of the MIPS32 architecture aimed at
2109 increased security at both hardware and software level for 2117 increased security at both hardware and software level for
@@ -2115,11 +2123,13 @@ config CPU_HAS_SMARTMIPS
2115 2123
2116config CPU_MICROMIPS 2124config CPU_MICROMIPS
2117 depends on SYS_SUPPORTS_MICROMIPS 2125 depends on SYS_SUPPORTS_MICROMIPS
2118 bool "Build kernel using microMIPS ISA" 2126 bool "microMIPS"
2119 help 2127 help
2120 When this option is enabled the kernel will be built using the 2128 When this option is enabled the kernel will be built using the
2121 microMIPS ISA 2129 microMIPS ISA
2122 2130
2131endchoice
2132
2123config CPU_HAS_MSA 2133config CPU_HAS_MSA
2124 bool "Support for the MIPS SIMD Architecture (EXPERIMENTAL)" 2134 bool "Support for the MIPS SIMD Architecture (EXPERIMENTAL)"
2125 depends on CPU_SUPPORTS_MSA 2135 depends on CPU_SUPPORTS_MSA
diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h
index e194f957ca8c..fdbff44e5482 100644
--- a/arch/mips/include/asm/jump_label.h
+++ b/arch/mips/include/asm/jump_label.h
@@ -20,9 +20,15 @@
20#define WORD_INSN ".word" 20#define WORD_INSN ".word"
21#endif 21#endif
22 22
23#ifdef CONFIG_CPU_MICROMIPS
24#define NOP_INSN "nop32"
25#else
26#define NOP_INSN "nop"
27#endif
28
23static __always_inline bool arch_static_branch(struct static_key *key) 29static __always_inline bool arch_static_branch(struct static_key *key)
24{ 30{
25 asm_volatile_goto("1:\tnop\n\t" 31 asm_volatile_goto("1:\t" NOP_INSN "\n\t"
26 "nop\n\t" 32 "nop\n\t"
27 ".pushsection __jump_table, \"aw\"\n\t" 33 ".pushsection __jump_table, \"aw\"\n\t"
28 WORD_INSN " 1b, %l[l_yes], %0\n\t" 34 WORD_INSN " 1b, %l[l_yes], %0\n\t"
diff --git a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h
index 7d28f95b0512..6d69332f21ec 100644
--- a/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h
@@ -41,10 +41,8 @@
41#define cpu_has_mcheck 0 41#define cpu_has_mcheck 0
42#define cpu_has_mdmx 0 42#define cpu_has_mdmx 0
43#define cpu_has_mips16 0 43#define cpu_has_mips16 0
44#define cpu_has_mips32r1 0
45#define cpu_has_mips32r2 0 44#define cpu_has_mips32r2 0
46#define cpu_has_mips3d 0 45#define cpu_has_mips3d 0
47#define cpu_has_mips64r1 0
48#define cpu_has_mips64r2 0 46#define cpu_has_mips64r2 0
49#define cpu_has_mipsmt 0 47#define cpu_has_mipsmt 0
50#define cpu_has_prefetch 0 48#define cpu_has_prefetch 0
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index b46cd220a018..22a135ac91de 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -661,6 +661,8 @@
661#define MIPS_CONF6_SYND (_ULCAST_(1) << 13) 661#define MIPS_CONF6_SYND (_ULCAST_(1) << 13)
662/* proAptiv FTLB on/off bit */ 662/* proAptiv FTLB on/off bit */
663#define MIPS_CONF6_FTLBEN (_ULCAST_(1) << 15) 663#define MIPS_CONF6_FTLBEN (_ULCAST_(1) << 15)
664/* FTLB probability bits */
665#define MIPS_CONF6_FTLBP_SHIFT (16)
664 666
665#define MIPS_CONF7_WII (_ULCAST_(1) << 31) 667#define MIPS_CONF7_WII (_ULCAST_(1) << 31)
666 668
diff --git a/arch/mips/include/asm/r4kcache.h b/arch/mips/include/asm/r4kcache.h
index 4520adc8699b..cd6e0afc6833 100644
--- a/arch/mips/include/asm/r4kcache.h
+++ b/arch/mips/include/asm/r4kcache.h
@@ -257,7 +257,11 @@ static inline void protected_flush_icache_line(unsigned long addr)
257 */ 257 */
258static inline void protected_writeback_dcache_line(unsigned long addr) 258static inline void protected_writeback_dcache_line(unsigned long addr)
259{ 259{
260#ifdef CONFIG_EVA
261 protected_cachee_op(Hit_Writeback_Inv_D, addr);
262#else
260 protected_cache_op(Hit_Writeback_Inv_D, addr); 263 protected_cache_op(Hit_Writeback_Inv_D, addr);
264#endif
261} 265}
262 266
263static inline void protected_writeback_scache_line(unsigned long addr) 267static inline void protected_writeback_scache_line(unsigned long addr)
diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index a10951090234..22a5624e2fd2 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -301,7 +301,8 @@ do { \
301 __get_kernel_common((x), size, __gu_ptr); \ 301 __get_kernel_common((x), size, __gu_ptr); \
302 else \ 302 else \
303 __get_user_common((x), size, __gu_ptr); \ 303 __get_user_common((x), size, __gu_ptr); \
304 } \ 304 } else \
305 (x) = 0; \
305 \ 306 \
306 __gu_err; \ 307 __gu_err; \
307}) 308})
@@ -316,6 +317,7 @@ do { \
316 " .insn \n" \ 317 " .insn \n" \
317 " .section .fixup,\"ax\" \n" \ 318 " .section .fixup,\"ax\" \n" \
318 "3: li %0, %4 \n" \ 319 "3: li %0, %4 \n" \
320 " move %1, $0 \n" \
319 " j 2b \n" \ 321 " j 2b \n" \
320 " .previous \n" \ 322 " .previous \n" \
321 " .section __ex_table,\"a\" \n" \ 323 " .section __ex_table,\"a\" \n" \
@@ -630,6 +632,7 @@ do { \
630 " .insn \n" \ 632 " .insn \n" \
631 " .section .fixup,\"ax\" \n" \ 633 " .section .fixup,\"ax\" \n" \
632 "3: li %0, %4 \n" \ 634 "3: li %0, %4 \n" \
635 " move %1, $0 \n" \
633 " j 2b \n" \ 636 " j 2b \n" \
634 " .previous \n" \ 637 " .previous \n" \
635 " .section __ex_table,\"a\" \n" \ 638 " .section __ex_table,\"a\" \n" \
@@ -773,10 +776,11 @@ extern void __put_user_unaligned_unknown(void);
773 "jal\t" #destination "\n\t" 776 "jal\t" #destination "\n\t"
774#endif 777#endif
775 778
776#ifndef CONFIG_CPU_DADDI_WORKAROUNDS 779#if defined(CONFIG_CPU_DADDI_WORKAROUNDS) || (defined(CONFIG_EVA) && \
777#define DADDI_SCRATCH "$0" 780 defined(CONFIG_CPU_HAS_PREFETCH))
778#else
779#define DADDI_SCRATCH "$3" 781#define DADDI_SCRATCH "$3"
782#else
783#define DADDI_SCRATCH "$0"
780#endif 784#endif
781 785
782extern size_t __copy_user(void *__to, const void *__from, size_t __n); 786extern size_t __copy_user(void *__to, const void *__from, size_t __n);
@@ -1418,7 +1422,7 @@ static inline long __strnlen_user(const char __user *s, long n)
1418} 1422}
1419 1423
1420/* 1424/*
1421 * strlen_user: - Get the size of a string in user space. 1425 * strnlen_user: - Get the size of a string in user space.
1422 * @str: The string to measure. 1426 * @str: The string to measure.
1423 * 1427 *
1424 * Context: User context only. This function may sleep. 1428 * Context: User context only. This function may sleep.
@@ -1427,9 +1431,7 @@ static inline long __strnlen_user(const char __user *s, long n)
1427 * 1431 *
1428 * Returns the size of the string INCLUDING the terminating NUL. 1432 * Returns the size of the string INCLUDING the terminating NUL.
1429 * On exception, returns 0. 1433 * On exception, returns 0.
1430 * 1434 * If the string is too long, returns a value greater than @n.
1431 * If there is a limit on the length of a valid string, you may wish to
1432 * consider using strnlen_user() instead.
1433 */ 1435 */
1434static inline long strnlen_user(const char __user *s, long n) 1436static inline long strnlen_user(const char __user *s, long n)
1435{ 1437{
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h
index 9dc58568f230..d001bb1ad177 100644
--- a/arch/mips/include/uapi/asm/unistd.h
+++ b/arch/mips/include/uapi/asm/unistd.h
@@ -1045,7 +1045,7 @@
1045#define __NR_seccomp (__NR_Linux + 316) 1045#define __NR_seccomp (__NR_Linux + 316)
1046#define __NR_getrandom (__NR_Linux + 317) 1046#define __NR_getrandom (__NR_Linux + 317)
1047#define __NR_memfd_create (__NR_Linux + 318) 1047#define __NR_memfd_create (__NR_Linux + 318)
1048#define __NR_memfd_create (__NR_Linux + 319) 1048#define __NR_bpf (__NR_Linux + 319)
1049 1049
1050/* 1050/*
1051 * Offset of the last N32 flavoured syscall 1051 * Offset of the last N32 flavoured syscall
diff --git a/arch/mips/kernel/bmips_vec.S b/arch/mips/kernel/bmips_vec.S
index 290c23b51678..86495072a922 100644
--- a/arch/mips/kernel/bmips_vec.S
+++ b/arch/mips/kernel/bmips_vec.S
@@ -208,7 +208,6 @@ bmips_reset_nmi_vec_end:
208END(bmips_reset_nmi_vec) 208END(bmips_reset_nmi_vec)
209 209
210 .set pop 210 .set pop
211 .previous
212 211
213/*********************************************************************** 212/***********************************************************************
214 * CPU1 warm restart vector (used for second and subsequent boots). 213 * CPU1 warm restart vector (used for second and subsequent boots).
@@ -281,5 +280,3 @@ LEAF(bmips_enable_xks01)
281 jr ra 280 jr ra
282 281
283END(bmips_enable_xks01) 282END(bmips_enable_xks01)
284
285 .previous
diff --git a/arch/mips/kernel/cps-vec.S b/arch/mips/kernel/cps-vec.S
index e6e97d2a5c9e..0384b05ab5a0 100644
--- a/arch/mips/kernel/cps-vec.S
+++ b/arch/mips/kernel/cps-vec.S
@@ -229,6 +229,7 @@ LEAF(mips_cps_core_init)
229 nop 229 nop
230 230
231 .set push 231 .set push
232 .set mips32r2
232 .set mt 233 .set mt
233 234
234 /* Only allow 1 TC per VPE to execute... */ 235 /* Only allow 1 TC per VPE to execute... */
@@ -345,6 +346,7 @@ LEAF(mips_cps_boot_vpes)
345 nop 346 nop
346 347
347 .set push 348 .set push
349 .set mips32r2
348 .set mt 350 .set mt
349 351
3501: /* Enter VPE configuration state */ 3521: /* Enter VPE configuration state */
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 94c4a0c0a577..dc49cf30c2db 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -193,6 +193,32 @@ static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
193static char unknown_isa[] = KERN_ERR \ 193static char unknown_isa[] = KERN_ERR \
194 "Unsupported ISA type, c0.config0: %d."; 194 "Unsupported ISA type, c0.config0: %d.";
195 195
196static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
197{
198
199 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
200
201 /*
202 * 0 = All TLBWR instructions go to FTLB
203 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
204 * FTLB and 1 goes to the VTLB.
205 * 2 = 7:1: As above with 7:1 ratio.
206 * 3 = 3:1: As above with 3:1 ratio.
207 *
208 * Use the linear midpoint as the probability threshold.
209 */
210 if (probability >= 12)
211 return 1;
212 else if (probability >= 6)
213 return 2;
214 else
215 /*
216 * So FTLB is less than 4 times bigger than VTLB.
217 * A 3:1 ratio can still be useful though.
218 */
219 return 3;
220}
221
196static void set_ftlb_enable(struct cpuinfo_mips *c, int enable) 222static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
197{ 223{
198 unsigned int config6; 224 unsigned int config6;
@@ -203,9 +229,14 @@ static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
203 case CPU_P5600: 229 case CPU_P5600:
204 /* proAptiv & related cores use Config6 to enable the FTLB */ 230 /* proAptiv & related cores use Config6 to enable the FTLB */
205 config6 = read_c0_config6(); 231 config6 = read_c0_config6();
232 /* Clear the old probability value */
233 config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
206 if (enable) 234 if (enable)
207 /* Enable FTLB */ 235 /* Enable FTLB */
208 write_c0_config6(config6 | MIPS_CONF6_FTLBEN); 236 write_c0_config6(config6 |
237 (calculate_ftlb_probability(c)
238 << MIPS_CONF6_FTLBP_SHIFT)
239 | MIPS_CONF6_FTLBEN);
209 else 240 else
210 /* Disable FTLB */ 241 /* Disable FTLB */
211 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN); 242 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
@@ -757,31 +788,34 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
757 c->cputype = CPU_LOONGSON2; 788 c->cputype = CPU_LOONGSON2;
758 __cpu_name[cpu] = "ICT Loongson-2"; 789 __cpu_name[cpu] = "ICT Loongson-2";
759 set_elf_platform(cpu, "loongson2e"); 790 set_elf_platform(cpu, "loongson2e");
791 set_isa(c, MIPS_CPU_ISA_III);
760 break; 792 break;
761 case PRID_REV_LOONGSON2F: 793 case PRID_REV_LOONGSON2F:
762 c->cputype = CPU_LOONGSON2; 794 c->cputype = CPU_LOONGSON2;
763 __cpu_name[cpu] = "ICT Loongson-2"; 795 __cpu_name[cpu] = "ICT Loongson-2";
764 set_elf_platform(cpu, "loongson2f"); 796 set_elf_platform(cpu, "loongson2f");
797 set_isa(c, MIPS_CPU_ISA_III);
765 break; 798 break;
766 case PRID_REV_LOONGSON3A: 799 case PRID_REV_LOONGSON3A:
767 c->cputype = CPU_LOONGSON3; 800 c->cputype = CPU_LOONGSON3;
768 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
769 __cpu_name[cpu] = "ICT Loongson-3"; 801 __cpu_name[cpu] = "ICT Loongson-3";
770 set_elf_platform(cpu, "loongson3a"); 802 set_elf_platform(cpu, "loongson3a");
803 set_isa(c, MIPS_CPU_ISA_M64R1);
771 break; 804 break;
772 case PRID_REV_LOONGSON3B_R1: 805 case PRID_REV_LOONGSON3B_R1:
773 case PRID_REV_LOONGSON3B_R2: 806 case PRID_REV_LOONGSON3B_R2:
774 c->cputype = CPU_LOONGSON3; 807 c->cputype = CPU_LOONGSON3;
775 __cpu_name[cpu] = "ICT Loongson-3"; 808 __cpu_name[cpu] = "ICT Loongson-3";
776 set_elf_platform(cpu, "loongson3b"); 809 set_elf_platform(cpu, "loongson3b");
810 set_isa(c, MIPS_CPU_ISA_M64R1);
777 break; 811 break;
778 } 812 }
779 813
780 set_isa(c, MIPS_CPU_ISA_III);
781 c->options = R4K_OPTS | 814 c->options = R4K_OPTS |
782 MIPS_CPU_FPU | MIPS_CPU_LLSC | 815 MIPS_CPU_FPU | MIPS_CPU_LLSC |
783 MIPS_CPU_32FPR; 816 MIPS_CPU_32FPR;
784 c->tlbsize = 64; 817 c->tlbsize = 64;
818 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
785 break; 819 break;
786 case PRID_IMP_LOONGSON_32: /* Loongson-1 */ 820 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
787 decode_configs(c); 821 decode_configs(c);
diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
index 6001610cfe55..dda800e9e731 100644
--- a/arch/mips/kernel/jump_label.c
+++ b/arch/mips/kernel/jump_label.c
@@ -18,31 +18,53 @@
18 18
19#ifdef HAVE_JUMP_LABEL 19#ifdef HAVE_JUMP_LABEL
20 20
21#define J_RANGE_MASK ((1ul << 28) - 1) 21/*
22 * Define parameters for the standard MIPS and the microMIPS jump
23 * instruction encoding respectively:
24 *
25 * - the ISA bit of the target, either 0 or 1 respectively,
26 *
27 * - the amount the jump target address is shifted right to fit in the
28 * immediate field of the machine instruction, either 2 or 1,
29 *
30 * - the mask determining the size of the jump region relative to the
31 * delay-slot instruction, either 256MB or 128MB,
32 *
33 * - the jump target alignment, either 4 or 2 bytes.
34 */
35#define J_ISA_BIT IS_ENABLED(CONFIG_CPU_MICROMIPS)
36#define J_RANGE_SHIFT (2 - J_ISA_BIT)
37#define J_RANGE_MASK ((1ul << (26 + J_RANGE_SHIFT)) - 1)
38#define J_ALIGN_MASK ((1ul << J_RANGE_SHIFT) - 1)
22 39
23void arch_jump_label_transform(struct jump_entry *e, 40void arch_jump_label_transform(struct jump_entry *e,
24 enum jump_label_type type) 41 enum jump_label_type type)
25{ 42{
43 union mips_instruction *insn_p;
26 union mips_instruction insn; 44 union mips_instruction insn;
27 union mips_instruction *insn_p =
28 (union mips_instruction *)(unsigned long)e->code;
29 45
30 /* Jump only works within a 256MB aligned region. */ 46 insn_p = (union mips_instruction *)msk_isa16_mode(e->code);
31 BUG_ON((e->target & ~J_RANGE_MASK) != (e->code & ~J_RANGE_MASK)); 47
48 /* Jump only works within an aligned region its delay slot is in. */
49 BUG_ON((e->target & ~J_RANGE_MASK) != ((e->code + 4) & ~J_RANGE_MASK));
32 50
33 /* Target must have 4 byte alignment. */ 51 /* Target must have the right alignment and ISA must be preserved. */
34 BUG_ON((e->target & 3) != 0); 52 BUG_ON((e->target & J_ALIGN_MASK) != J_ISA_BIT);
35 53
36 if (type == JUMP_LABEL_ENABLE) { 54 if (type == JUMP_LABEL_ENABLE) {
37 insn.j_format.opcode = j_op; 55 insn.j_format.opcode = J_ISA_BIT ? mm_j32_op : j_op;
38 insn.j_format.target = (e->target & J_RANGE_MASK) >> 2; 56 insn.j_format.target = e->target >> J_RANGE_SHIFT;
39 } else { 57 } else {
40 insn.word = 0; /* nop */ 58 insn.word = 0; /* nop */
41 } 59 }
42 60
43 get_online_cpus(); 61 get_online_cpus();
44 mutex_lock(&text_mutex); 62 mutex_lock(&text_mutex);
45 *insn_p = insn; 63 if (IS_ENABLED(CONFIG_CPU_MICROMIPS)) {
64 insn_p->halfword[0] = insn.word >> 16;
65 insn_p->halfword[1] = insn.word;
66 } else
67 *insn_p = insn;
46 68
47 flush_icache_range((unsigned long)insn_p, 69 flush_icache_range((unsigned long)insn_p,
48 (unsigned long)insn_p + sizeof(*insn_p)); 70 (unsigned long)insn_p + sizeof(*insn_p));
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 31b1b763cb29..c5c4fd54d797 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -94,12 +94,12 @@ int rtlx_open(int index, int can_sleep)
94 int ret = 0; 94 int ret = 0;
95 95
96 if (index >= RTLX_CHANNELS) { 96 if (index >= RTLX_CHANNELS) {
97 pr_debug(KERN_DEBUG "rtlx_open index out of range\n"); 97 pr_debug("rtlx_open index out of range\n");
98 return -ENOSYS; 98 return -ENOSYS;
99 } 99 }
100 100
101 if (atomic_inc_return(&channel_wqs[index].in_open) > 1) { 101 if (atomic_inc_return(&channel_wqs[index].in_open) > 1) {
102 pr_debug(KERN_DEBUG "rtlx_open channel %d already opened\n", index); 102 pr_debug("rtlx_open channel %d already opened\n", index);
103 ret = -EBUSY; 103 ret = -EBUSY;
104 goto out_fail; 104 goto out_fail;
105 } 105 }
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index d21ec57b6e95..f3b635f86c39 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -485,7 +485,7 @@ static void __init bootmem_init(void)
485 * NOTE: historically plat_mem_setup did the entire platform initialization. 485 * NOTE: historically plat_mem_setup did the entire platform initialization.
486 * This was rather impractical because it meant plat_mem_setup had to 486 * This was rather impractical because it meant plat_mem_setup had to
487 * get away without any kind of memory allocator. To keep old code from 487 * get away without any kind of memory allocator. To keep old code from
488 * breaking plat_setup was just renamed to plat_setup and a second platform 488 * breaking plat_setup was just renamed to plat_mem_setup and a second platform
489 * initialization hook for anything else was introduced. 489 * initialization hook for anything else was introduced.
490 */ 490 */
491 491
@@ -493,7 +493,7 @@ static int usermem __initdata;
493 493
494static int __init early_parse_mem(char *p) 494static int __init early_parse_mem(char *p)
495{ 495{
496 unsigned long start, size; 496 phys_t start, size;
497 497
498 /* 498 /*
499 * If a user specifies memory size, we 499 * If a user specifies memory size, we
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 1d57605e4615..16f1e4f2bf3c 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -658,13 +658,13 @@ static int signal_setup(void)
658 save_fp_context = _save_fp_context; 658 save_fp_context = _save_fp_context;
659 restore_fp_context = _restore_fp_context; 659 restore_fp_context = _restore_fp_context;
660 } else { 660 } else {
661 save_fp_context = copy_fp_from_sigcontext; 661 save_fp_context = copy_fp_to_sigcontext;
662 restore_fp_context = copy_fp_to_sigcontext; 662 restore_fp_context = copy_fp_from_sigcontext;
663 } 663 }
664#endif /* CONFIG_SMP */ 664#endif /* CONFIG_SMP */
665#else 665#else
666 save_fp_context = copy_fp_from_sigcontext;; 666 save_fp_context = copy_fp_to_sigcontext;
667 restore_fp_context = copy_fp_to_sigcontext; 667 restore_fp_context = copy_fp_from_sigcontext;
668#endif 668#endif
669 669
670 return 0; 670 return 0;
diff --git a/arch/mips/lib/memcpy.S b/arch/mips/lib/memcpy.S
index c17ef80cf65a..5d3238af9b5c 100644
--- a/arch/mips/lib/memcpy.S
+++ b/arch/mips/lib/memcpy.S
@@ -503,6 +503,7 @@
503 STOREB(t0, NBYTES-2(dst), .Ls_exc_p1\@) 503 STOREB(t0, NBYTES-2(dst), .Ls_exc_p1\@)
504.Ldone\@: 504.Ldone\@:
505 jr ra 505 jr ra
506 nop
506 .if __memcpy == 1 507 .if __memcpy == 1
507 END(memcpy) 508 END(memcpy)
508 .set __memcpy, 0 509 .set __memcpy, 0
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile
index 0bb9cc9dc621..d87e03330b29 100644
--- a/arch/mips/loongson/common/Makefile
+++ b/arch/mips/loongson/common/Makefile
@@ -11,7 +11,8 @@ obj-$(CONFIG_PCI) += pci.o
11# Serial port support 11# Serial port support
12# 12#
13obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 13obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
14obj-$(CONFIG_SERIAL_8250) += serial.o 14loongson-serial-$(CONFIG_SERIAL_8250) := serial.o
15obj-y += $(loongson-serial-m) $(loongson-serial-y)
15obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o 16obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o
16obj-$(CONFIG_LOONGSON_MC146818) += rtc.o 17obj-$(CONFIG_LOONGSON_MC146818) += rtc.o
17 18
diff --git a/arch/mips/loongson/loongson-3/numa.c b/arch/mips/loongson/loongson-3/numa.c
index 37ed184398c6..42323bcc5d28 100644
--- a/arch/mips/loongson/loongson-3/numa.c
+++ b/arch/mips/loongson/loongson-3/numa.c
@@ -33,6 +33,7 @@
33 33
34static struct node_data prealloc__node_data[MAX_NUMNODES]; 34static struct node_data prealloc__node_data[MAX_NUMNODES];
35unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; 35unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
36EXPORT_SYMBOL(__node_distances);
36struct node_data *__node_data[MAX_NUMNODES]; 37struct node_data *__node_data[MAX_NUMNODES];
37EXPORT_SYMBOL(__node_data); 38EXPORT_SYMBOL(__node_data);
38 39
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index fa6ebd4bc9e9..c3917e251f59 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -299,6 +299,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
299 299
300 local_irq_save(flags); 300 local_irq_save(flags);
301 301
302 htw_stop();
302 pid = read_c0_entryhi() & ASID_MASK; 303 pid = read_c0_entryhi() & ASID_MASK;
303 address &= (PAGE_MASK << 1); 304 address &= (PAGE_MASK << 1);
304 write_c0_entryhi(address | pid); 305 write_c0_entryhi(address | pid);
@@ -346,6 +347,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
346 tlb_write_indexed(); 347 tlb_write_indexed();
347 } 348 }
348 tlbw_use_hazard(); 349 tlbw_use_hazard();
350 htw_start();
349 flush_itlb_vm(vma); 351 flush_itlb_vm(vma);
350 local_irq_restore(flags); 352 local_irq_restore(flags);
351} 353}
@@ -422,6 +424,7 @@ __init int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
422 424
423 local_irq_save(flags); 425 local_irq_save(flags);
424 /* Save old context and create impossible VPN2 value */ 426 /* Save old context and create impossible VPN2 value */
427 htw_stop();
425 old_ctx = read_c0_entryhi(); 428 old_ctx = read_c0_entryhi();
426 old_pagemask = read_c0_pagemask(); 429 old_pagemask = read_c0_pagemask();
427 wired = read_c0_wired(); 430 wired = read_c0_wired();
@@ -443,6 +446,7 @@ __init int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,
443 446
444 write_c0_entryhi(old_ctx); 447 write_c0_entryhi(old_ctx);
445 write_c0_pagemask(old_pagemask); 448 write_c0_pagemask(old_pagemask);
449 htw_start();
446out: 450out:
447 local_irq_restore(flags); 451 local_irq_restore(flags);
448 return ret; 452 return ret;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index b5f228e7eae6..e3328a96e809 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -1872,8 +1872,16 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
1872 uasm_l_smp_pgtable_change(l, *p); 1872 uasm_l_smp_pgtable_change(l, *p);
1873#endif 1873#endif
1874 iPTE_LW(p, wr.r1, wr.r2); /* get even pte */ 1874 iPTE_LW(p, wr.r1, wr.r2); /* get even pte */
1875 if (!m4kc_tlbp_war()) 1875 if (!m4kc_tlbp_war()) {
1876 build_tlb_probe_entry(p); 1876 build_tlb_probe_entry(p);
1877 if (cpu_has_htw) {
1878 /* race condition happens, leaving */
1879 uasm_i_ehb(p);
1880 uasm_i_mfc0(p, wr.r3, C0_INDEX);
1881 uasm_il_bltz(p, r, wr.r3, label_leave);
1882 uasm_i_nop(p);
1883 }
1884 }
1877 return wr; 1885 return wr;
1878} 1886}
1879 1887
diff --git a/arch/mips/mti-sead3/sead3-leds.c b/arch/mips/mti-sead3/sead3-leds.c
index 20102a6d4141..c427c5778186 100644
--- a/arch/mips/mti-sead3/sead3-leds.c
+++ b/arch/mips/mti-sead3/sead3-leds.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 */ 7 */
8#include <linux/module.h> 8#include <linux/init.h>
9#include <linux/leds.h> 9#include <linux/leds.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11 11
@@ -76,8 +76,4 @@ static int __init led_init(void)
76 return platform_device_register(&fled_device); 76 return platform_device_register(&fled_device);
77} 77}
78 78
79module_init(led_init); 79device_initcall(led_init);
80
81MODULE_AUTHOR("Chris Dearman <chris@mips.com>");
82MODULE_LICENSE("GPL");
83MODULE_DESCRIPTION("LED probe driver for SEAD-3");
diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile
index be358a8050c5..6b43af0a34d9 100644
--- a/arch/mips/netlogic/xlp/Makefile
+++ b/arch/mips/netlogic/xlp/Makefile
@@ -1,6 +1,10 @@
1obj-y += setup.o nlm_hal.o cop2-ex.o dt.o 1obj-y += setup.o nlm_hal.o cop2-ex.o dt.o
2obj-$(CONFIG_SMP) += wakeup.o 2obj-$(CONFIG_SMP) += wakeup.o
3obj-$(CONFIG_USB) += usb-init.o 3ifdef CONFIG_USB
4obj-$(CONFIG_USB) += usb-init-xlp2.o 4obj-y += usb-init.o
5obj-$(CONFIG_SATA_AHCI) += ahci-init.o 5obj-y += usb-init-xlp2.o
6obj-$(CONFIG_SATA_AHCI) += ahci-init-xlp2.o 6endif
7ifdef CONFIG_SATA_AHCI
8obj-y += ahci-init.o
9obj-y += ahci-init-xlp2.o
10endif
diff --git a/arch/mips/oprofile/backtrace.c b/arch/mips/oprofile/backtrace.c
index 6854ed5097d2..83a1dfd8f0e3 100644
--- a/arch/mips/oprofile/backtrace.c
+++ b/arch/mips/oprofile/backtrace.c
@@ -92,7 +92,7 @@ static inline int unwind_user_frame(struct stackframe *old_frame,
92 /* This marks the end of the previous function, 92 /* This marks the end of the previous function,
93 which means we overran. */ 93 which means we overran. */
94 break; 94 break;
95 stack_size = (unsigned) stack_adjustment; 95 stack_size = (unsigned long) stack_adjustment;
96 } else if (is_ra_save_ins(&ip)) { 96 } else if (is_ra_save_ins(&ip)) {
97 int ra_slot = ip.i_format.simmediate; 97 int ra_slot = ip.i_format.simmediate;
98 if (ra_slot < 0) 98 if (ra_slot < 0)
diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c
index a95c00f5fb96..a304bcc37e4f 100644
--- a/arch/mips/sgi-ip27/ip27-memory.c
+++ b/arch/mips/sgi-ip27/ip27-memory.c
@@ -107,6 +107,7 @@ static void router_recurse(klrou_t *router_a, klrou_t *router_b, int depth)
107} 107}
108 108
109unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES]; 109unsigned char __node_distances[MAX_COMPACT_NODES][MAX_COMPACT_NODES];
110EXPORT_SYMBOL(__node_distances);
110 111
111static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b) 112static int __init compute_node_distance(nasid_t nasid_a, nasid_t nasid_b)
112{ 113{
diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
index 4006964d8e12..a5cb070b54bf 100644
--- a/arch/parisc/include/asm/uaccess.h
+++ b/arch/parisc/include/asm/uaccess.h
@@ -9,6 +9,8 @@
9#include <asm/errno.h> 9#include <asm/errno.h>
10#include <asm-generic/uaccess-unaligned.h> 10#include <asm-generic/uaccess-unaligned.h>
11 11
12#include <linux/bug.h>
13
12#define VERIFY_READ 0 14#define VERIFY_READ 0
13#define VERIFY_WRITE 1 15#define VERIFY_WRITE 1
14 16
@@ -28,11 +30,6 @@
28 * that put_user is the same as __put_user, etc. 30 * that put_user is the same as __put_user, etc.
29 */ 31 */
30 32
31extern int __get_kernel_bad(void);
32extern int __get_user_bad(void);
33extern int __put_kernel_bad(void);
34extern int __put_user_bad(void);
35
36static inline long access_ok(int type, const void __user * addr, 33static inline long access_ok(int type, const void __user * addr,
37 unsigned long size) 34 unsigned long size)
38{ 35{
@@ -43,8 +40,8 @@ static inline long access_ok(int type, const void __user * addr,
43#define get_user __get_user 40#define get_user __get_user
44 41
45#if !defined(CONFIG_64BIT) 42#if !defined(CONFIG_64BIT)
46#define LDD_KERNEL(ptr) __get_kernel_bad(); 43#define LDD_KERNEL(ptr) BUILD_BUG()
47#define LDD_USER(ptr) __get_user_bad(); 44#define LDD_USER(ptr) BUILD_BUG()
48#define STD_KERNEL(x, ptr) __put_kernel_asm64(x,ptr) 45#define STD_KERNEL(x, ptr) __put_kernel_asm64(x,ptr)
49#define STD_USER(x, ptr) __put_user_asm64(x,ptr) 46#define STD_USER(x, ptr) __put_user_asm64(x,ptr)
50#define ASM_WORD_INSN ".word\t" 47#define ASM_WORD_INSN ".word\t"
@@ -94,7 +91,7 @@ struct exception_data {
94 case 2: __get_kernel_asm("ldh",ptr); break; \ 91 case 2: __get_kernel_asm("ldh",ptr); break; \
95 case 4: __get_kernel_asm("ldw",ptr); break; \ 92 case 4: __get_kernel_asm("ldw",ptr); break; \
96 case 8: LDD_KERNEL(ptr); break; \ 93 case 8: LDD_KERNEL(ptr); break; \
97 default: __get_kernel_bad(); break; \ 94 default: BUILD_BUG(); break; \
98 } \ 95 } \
99 } \ 96 } \
100 else { \ 97 else { \
@@ -103,7 +100,7 @@ struct exception_data {
103 case 2: __get_user_asm("ldh",ptr); break; \ 100 case 2: __get_user_asm("ldh",ptr); break; \
104 case 4: __get_user_asm("ldw",ptr); break; \ 101 case 4: __get_user_asm("ldw",ptr); break; \
105 case 8: LDD_USER(ptr); break; \ 102 case 8: LDD_USER(ptr); break; \
106 default: __get_user_bad(); break; \ 103 default: BUILD_BUG(); break; \
107 } \ 104 } \
108 } \ 105 } \
109 \ 106 \
@@ -136,7 +133,7 @@ struct exception_data {
136 case 2: __put_kernel_asm("sth",__x,ptr); break; \ 133 case 2: __put_kernel_asm("sth",__x,ptr); break; \
137 case 4: __put_kernel_asm("stw",__x,ptr); break; \ 134 case 4: __put_kernel_asm("stw",__x,ptr); break; \
138 case 8: STD_KERNEL(__x,ptr); break; \ 135 case 8: STD_KERNEL(__x,ptr); break; \
139 default: __put_kernel_bad(); break; \ 136 default: BUILD_BUG(); break; \
140 } \ 137 } \
141 } \ 138 } \
142 else { \ 139 else { \
@@ -145,7 +142,7 @@ struct exception_data {
145 case 2: __put_user_asm("sth",__x,ptr); break; \ 142 case 2: __put_user_asm("sth",__x,ptr); break; \
146 case 4: __put_user_asm("stw",__x,ptr); break; \ 143 case 4: __put_user_asm("stw",__x,ptr); break; \
147 case 8: STD_USER(__x,ptr); break; \ 144 case 8: STD_USER(__x,ptr); break; \
148 default: __put_user_bad(); break; \ 145 default: BUILD_BUG(); break; \
149 } \ 146 } \
150 } \ 147 } \
151 \ 148 \
diff --git a/arch/parisc/include/uapi/asm/bitsperlong.h b/arch/parisc/include/uapi/asm/bitsperlong.h
index 75196b415d3f..e0a23c7bdd43 100644
--- a/arch/parisc/include/uapi/asm/bitsperlong.h
+++ b/arch/parisc/include/uapi/asm/bitsperlong.h
@@ -1,13 +1,7 @@
1#ifndef __ASM_PARISC_BITSPERLONG_H 1#ifndef __ASM_PARISC_BITSPERLONG_H
2#define __ASM_PARISC_BITSPERLONG_H 2#define __ASM_PARISC_BITSPERLONG_H
3 3
4/* 4#if defined(__LP64__)
5 * using CONFIG_* outside of __KERNEL__ is wrong,
6 * __LP64__ was also removed from headers, so what
7 * is the right approach on parisc?
8 * -arnd
9 */
10#if (defined(__KERNEL__) && defined(CONFIG_64BIT)) || defined (__LP64__)
11#define __BITS_PER_LONG 64 5#define __BITS_PER_LONG 64
12#define SHIFT_PER_LONG 6 6#define SHIFT_PER_LONG 6
13#else 7#else
diff --git a/arch/parisc/include/uapi/asm/msgbuf.h b/arch/parisc/include/uapi/asm/msgbuf.h
index fe88f2649418..342138983914 100644
--- a/arch/parisc/include/uapi/asm/msgbuf.h
+++ b/arch/parisc/include/uapi/asm/msgbuf.h
@@ -1,6 +1,8 @@
1#ifndef _PARISC_MSGBUF_H 1#ifndef _PARISC_MSGBUF_H
2#define _PARISC_MSGBUF_H 2#define _PARISC_MSGBUF_H
3 3
4#include <asm/bitsperlong.h>
5
4/* 6/*
5 * The msqid64_ds structure for parisc architecture, copied from sparc. 7 * The msqid64_ds structure for parisc architecture, copied from sparc.
6 * Note extra padding because this structure is passed back and forth 8 * Note extra padding because this structure is passed back and forth
@@ -13,15 +15,15 @@
13 15
14struct msqid64_ds { 16struct msqid64_ds {
15 struct ipc64_perm msg_perm; 17 struct ipc64_perm msg_perm;
16#ifndef CONFIG_64BIT 18#if __BITS_PER_LONG != 64
17 unsigned int __pad1; 19 unsigned int __pad1;
18#endif 20#endif
19 __kernel_time_t msg_stime; /* last msgsnd time */ 21 __kernel_time_t msg_stime; /* last msgsnd time */
20#ifndef CONFIG_64BIT 22#if __BITS_PER_LONG != 64
21 unsigned int __pad2; 23 unsigned int __pad2;
22#endif 24#endif
23 __kernel_time_t msg_rtime; /* last msgrcv time */ 25 __kernel_time_t msg_rtime; /* last msgrcv time */
24#ifndef CONFIG_64BIT 26#if __BITS_PER_LONG != 64
25 unsigned int __pad3; 27 unsigned int __pad3;
26#endif 28#endif
27 __kernel_time_t msg_ctime; /* last change time */ 29 __kernel_time_t msg_ctime; /* last change time */
diff --git a/arch/parisc/include/uapi/asm/sembuf.h b/arch/parisc/include/uapi/asm/sembuf.h
index 1e59ffd3bd1e..f01d89e30d73 100644
--- a/arch/parisc/include/uapi/asm/sembuf.h
+++ b/arch/parisc/include/uapi/asm/sembuf.h
@@ -1,6 +1,8 @@
1#ifndef _PARISC_SEMBUF_H 1#ifndef _PARISC_SEMBUF_H
2#define _PARISC_SEMBUF_H 2#define _PARISC_SEMBUF_H
3 3
4#include <asm/bitsperlong.h>
5
4/* 6/*
5 * The semid64_ds structure for parisc architecture. 7 * The semid64_ds structure for parisc architecture.
6 * Note extra padding because this structure is passed back and forth 8 * Note extra padding because this structure is passed back and forth
@@ -13,11 +15,11 @@
13 15
14struct semid64_ds { 16struct semid64_ds {
15 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ 17 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
16#ifndef CONFIG_64BIT 18#if __BITS_PER_LONG != 64
17 unsigned int __pad1; 19 unsigned int __pad1;
18#endif 20#endif
19 __kernel_time_t sem_otime; /* last semop time */ 21 __kernel_time_t sem_otime; /* last semop time */
20#ifndef CONFIG_64BIT 22#if __BITS_PER_LONG != 64
21 unsigned int __pad2; 23 unsigned int __pad2;
22#endif 24#endif
23 __kernel_time_t sem_ctime; /* last change time */ 25 __kernel_time_t sem_ctime; /* last change time */
diff --git a/arch/parisc/include/uapi/asm/shmbuf.h b/arch/parisc/include/uapi/asm/shmbuf.h
index 0a3eada1863b..8496c38560c6 100644
--- a/arch/parisc/include/uapi/asm/shmbuf.h
+++ b/arch/parisc/include/uapi/asm/shmbuf.h
@@ -1,6 +1,8 @@
1#ifndef _PARISC_SHMBUF_H 1#ifndef _PARISC_SHMBUF_H
2#define _PARISC_SHMBUF_H 2#define _PARISC_SHMBUF_H
3 3
4#include <asm/bitsperlong.h>
5
4/* 6/*
5 * The shmid64_ds structure for parisc architecture. 7 * The shmid64_ds structure for parisc architecture.
6 * Note extra padding because this structure is passed back and forth 8 * Note extra padding because this structure is passed back and forth
@@ -13,19 +15,19 @@
13 15
14struct shmid64_ds { 16struct shmid64_ds {
15 struct ipc64_perm shm_perm; /* operation perms */ 17 struct ipc64_perm shm_perm; /* operation perms */
16#ifndef CONFIG_64BIT 18#if __BITS_PER_LONG != 64
17 unsigned int __pad1; 19 unsigned int __pad1;
18#endif 20#endif
19 __kernel_time_t shm_atime; /* last attach time */ 21 __kernel_time_t shm_atime; /* last attach time */
20#ifndef CONFIG_64BIT 22#if __BITS_PER_LONG != 64
21 unsigned int __pad2; 23 unsigned int __pad2;
22#endif 24#endif
23 __kernel_time_t shm_dtime; /* last detach time */ 25 __kernel_time_t shm_dtime; /* last detach time */
24#ifndef CONFIG_64BIT 26#if __BITS_PER_LONG != 64
25 unsigned int __pad3; 27 unsigned int __pad3;
26#endif 28#endif
27 __kernel_time_t shm_ctime; /* last change time */ 29 __kernel_time_t shm_ctime; /* last change time */
28#ifndef CONFIG_64BIT 30#if __BITS_PER_LONG != 64
29 unsigned int __pad4; 31 unsigned int __pad4;
30#endif 32#endif
31 size_t shm_segsz; /* size of segment (bytes) */ 33 size_t shm_segsz; /* size of segment (bytes) */
@@ -36,23 +38,16 @@ struct shmid64_ds {
36 unsigned int __unused2; 38 unsigned int __unused2;
37}; 39};
38 40
39#ifdef CONFIG_64BIT
40/* The 'unsigned int' (formerly 'unsigned long') data types below will
41 * ensure that a 32-bit app calling shmctl(*,IPC_INFO,*) will work on
42 * a wide kernel, but if some of these values are meant to contain pointers
43 * they may need to be 'long long' instead. -PB XXX FIXME
44 */
45#endif
46struct shminfo64 { 41struct shminfo64 {
47 unsigned int shmmax; 42 unsigned long shmmax;
48 unsigned int shmmin; 43 unsigned long shmmin;
49 unsigned int shmmni; 44 unsigned long shmmni;
50 unsigned int shmseg; 45 unsigned long shmseg;
51 unsigned int shmall; 46 unsigned long shmall;
52 unsigned int __unused1; 47 unsigned long __unused1;
53 unsigned int __unused2; 48 unsigned long __unused2;
54 unsigned int __unused3; 49 unsigned long __unused3;
55 unsigned int __unused4; 50 unsigned long __unused4;
56}; 51};
57 52
58#endif /* _PARISC_SHMBUF_H */ 53#endif /* _PARISC_SHMBUF_H */
diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h
index 10df7079f4cd..e26043b73f5d 100644
--- a/arch/parisc/include/uapi/asm/signal.h
+++ b/arch/parisc/include/uapi/asm/signal.h
@@ -85,7 +85,7 @@
85struct siginfo; 85struct siginfo;
86 86
87/* Type of a signal handler. */ 87/* Type of a signal handler. */
88#ifdef CONFIG_64BIT 88#if defined(__LP64__)
89/* function pointers on 64-bit parisc are pointers to little structs and the 89/* function pointers on 64-bit parisc are pointers to little structs and the
90 * compiler doesn't support code which changes or tests the address of 90 * compiler doesn't support code which changes or tests the address of
91 * the function in the little struct. This is really ugly -PB 91 * the function in the little struct. This is really ugly -PB
diff --git a/arch/parisc/include/uapi/asm/unistd.h b/arch/parisc/include/uapi/asm/unistd.h
index 8667f18be238..5f5c0373de63 100644
--- a/arch/parisc/include/uapi/asm/unistd.h
+++ b/arch/parisc/include/uapi/asm/unistd.h
@@ -833,8 +833,9 @@
833#define __NR_seccomp (__NR_Linux + 338) 833#define __NR_seccomp (__NR_Linux + 338)
834#define __NR_getrandom (__NR_Linux + 339) 834#define __NR_getrandom (__NR_Linux + 339)
835#define __NR_memfd_create (__NR_Linux + 340) 835#define __NR_memfd_create (__NR_Linux + 340)
836#define __NR_bpf (__NR_Linux + 341)
836 837
837#define __NR_Linux_syscalls (__NR_memfd_create + 1) 838#define __NR_Linux_syscalls (__NR_bpf + 1)
838 839
839 840
840#define __IGNORE_select /* newselect */ 841#define __IGNORE_select /* newselect */
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index b563d9c8268b..fe4f0b89bf8f 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -286,11 +286,11 @@
286 ENTRY_COMP(msgsnd) 286 ENTRY_COMP(msgsnd)
287 ENTRY_COMP(msgrcv) 287 ENTRY_COMP(msgrcv)
288 ENTRY_SAME(msgget) /* 190 */ 288 ENTRY_SAME(msgget) /* 190 */
289 ENTRY_SAME(msgctl) 289 ENTRY_COMP(msgctl)
290 ENTRY_SAME(shmat) 290 ENTRY_COMP(shmat)
291 ENTRY_SAME(shmdt) 291 ENTRY_SAME(shmdt)
292 ENTRY_SAME(shmget) 292 ENTRY_SAME(shmget)
293 ENTRY_SAME(shmctl) /* 195 */ 293 ENTRY_COMP(shmctl) /* 195 */
294 ENTRY_SAME(ni_syscall) /* streams1 */ 294 ENTRY_SAME(ni_syscall) /* streams1 */
295 ENTRY_SAME(ni_syscall) /* streams2 */ 295 ENTRY_SAME(ni_syscall) /* streams2 */
296 ENTRY_SAME(lstat64) 296 ENTRY_SAME(lstat64)
@@ -323,7 +323,7 @@
323 ENTRY_SAME(epoll_ctl) /* 225 */ 323 ENTRY_SAME(epoll_ctl) /* 225 */
324 ENTRY_SAME(epoll_wait) 324 ENTRY_SAME(epoll_wait)
325 ENTRY_SAME(remap_file_pages) 325 ENTRY_SAME(remap_file_pages)
326 ENTRY_SAME(semtimedop) 326 ENTRY_COMP(semtimedop)
327 ENTRY_COMP(mq_open) 327 ENTRY_COMP(mq_open)
328 ENTRY_SAME(mq_unlink) /* 230 */ 328 ENTRY_SAME(mq_unlink) /* 230 */
329 ENTRY_COMP(mq_timedsend) 329 ENTRY_COMP(mq_timedsend)
@@ -436,6 +436,7 @@
436 ENTRY_SAME(seccomp) 436 ENTRY_SAME(seccomp)
437 ENTRY_SAME(getrandom) 437 ENTRY_SAME(getrandom)
438 ENTRY_SAME(memfd_create) /* 340 */ 438 ENTRY_SAME(memfd_create) /* 340 */
439 ENTRY_SAME(bpf)
439 440
440 /* Nothing yet */ 441 /* Nothing yet */
441 442
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 4ca90a39d6d0..725247beebec 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -159,8 +159,6 @@ struct pci_dn {
159 159
160 int pci_ext_config_space; /* for pci devices */ 160 int pci_ext_config_space; /* for pci devices */
161 161
162 bool force_32bit_msi;
163
164 struct pci_dev *pcidev; /* back-pointer to the pci device */ 162 struct pci_dev *pcidev; /* back-pointer to the pci device */
165#ifdef CONFIG_EEH 163#ifdef CONFIG_EEH
166 struct eeh_dev *edev; /* eeh device */ 164 struct eeh_dev *edev; /* eeh device */
diff --git a/arch/powerpc/kernel/eeh_sysfs.c b/arch/powerpc/kernel/eeh_sysfs.c
index f19b1e5cb060..1ceecdda810b 100644
--- a/arch/powerpc/kernel/eeh_sysfs.c
+++ b/arch/powerpc/kernel/eeh_sysfs.c
@@ -65,7 +65,7 @@ static ssize_t eeh_pe_state_show(struct device *dev,
65 return -ENODEV; 65 return -ENODEV;
66 66
67 state = eeh_ops->get_state(edev->pe, NULL); 67 state = eeh_ops->get_state(edev->pe, NULL);
68 return sprintf(buf, "%0x08x %0x08x\n", 68 return sprintf(buf, "0x%08x 0x%08x\n",
69 state, edev->pe->state); 69 state, edev->pe->state);
70} 70}
71 71
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 155013da27e0..b15194e2c5fc 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -266,13 +266,3 @@ int pcibus_to_node(struct pci_bus *bus)
266} 266}
267EXPORT_SYMBOL(pcibus_to_node); 267EXPORT_SYMBOL(pcibus_to_node);
268#endif 268#endif
269
270static void quirk_radeon_32bit_msi(struct pci_dev *dev)
271{
272 struct pci_dn *pdn = pci_get_pdn(dev);
273
274 if (pdn)
275 pdn->force_32bit_msi = true;
276}
277DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x68f2, quirk_radeon_32bit_msi);
278DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0xaa68, quirk_radeon_32bit_msi);
diff --git a/arch/powerpc/kernel/vdso32/getcpu.S b/arch/powerpc/kernel/vdso32/getcpu.S
index 23eb9a9441bd..c62be60c7274 100644
--- a/arch/powerpc/kernel/vdso32/getcpu.S
+++ b/arch/powerpc/kernel/vdso32/getcpu.S
@@ -30,8 +30,8 @@
30V_FUNCTION_BEGIN(__kernel_getcpu) 30V_FUNCTION_BEGIN(__kernel_getcpu)
31 .cfi_startproc 31 .cfi_startproc
32 mfspr r5,SPRN_SPRG_VDSO_READ 32 mfspr r5,SPRN_SPRG_VDSO_READ
33 cmpdi cr0,r3,0 33 cmpwi cr0,r3,0
34 cmpdi cr1,r4,0 34 cmpwi cr1,r4,0
35 clrlwi r6,r5,16 35 clrlwi r6,r5,16
36 rlwinm r7,r5,16,31-15,31-0 36 rlwinm r7,r5,16,31-15,31-0
37 beq cr0,1f 37 beq cr0,1f
diff --git a/arch/powerpc/platforms/powernv/opal-hmi.c b/arch/powerpc/platforms/powernv/opal-hmi.c
index 5e1ed1575aab..b322bfb51343 100644
--- a/arch/powerpc/platforms/powernv/opal-hmi.c
+++ b/arch/powerpc/platforms/powernv/opal-hmi.c
@@ -57,7 +57,7 @@ static void print_hmi_event_info(struct OpalHMIEvent *hmi_evt)
57 }; 57 };
58 58
59 /* Print things out */ 59 /* Print things out */
60 if (hmi_evt->version != OpalHMIEvt_V1) { 60 if (hmi_evt->version < OpalHMIEvt_V1) {
61 pr_err("HMI Interrupt, Unknown event version %d !\n", 61 pr_err("HMI Interrupt, Unknown event version %d !\n",
62 hmi_evt->version); 62 hmi_evt->version);
63 return; 63 return;
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 468a0f23c7f2..3ba435ec3dcd 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1509,7 +1509,6 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
1509 unsigned int is_64, struct msi_msg *msg) 1509 unsigned int is_64, struct msi_msg *msg)
1510{ 1510{
1511 struct pnv_ioda_pe *pe = pnv_ioda_get_pe(dev); 1511 struct pnv_ioda_pe *pe = pnv_ioda_get_pe(dev);
1512 struct pci_dn *pdn = pci_get_pdn(dev);
1513 unsigned int xive_num = hwirq - phb->msi_base; 1512 unsigned int xive_num = hwirq - phb->msi_base;
1514 __be32 data; 1513 __be32 data;
1515 int rc; 1514 int rc;
@@ -1523,7 +1522,7 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
1523 return -ENXIO; 1522 return -ENXIO;
1524 1523
1525 /* Force 32-bit MSI on some broken devices */ 1524 /* Force 32-bit MSI on some broken devices */
1526 if (pdn && pdn->force_32bit_msi) 1525 if (dev->no_64bit_msi)
1527 is_64 = 0; 1526 is_64 = 0;
1528 1527
1529 /* Assign XIVE to PE */ 1528 /* Assign XIVE to PE */
@@ -1997,7 +1996,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
1997 if (is_kdump_kernel()) { 1996 if (is_kdump_kernel()) {
1998 pr_info(" Issue PHB reset ...\n"); 1997 pr_info(" Issue PHB reset ...\n");
1999 ioda_eeh_phb_reset(hose, EEH_RESET_FUNDAMENTAL); 1998 ioda_eeh_phb_reset(hose, EEH_RESET_FUNDAMENTAL);
2000 ioda_eeh_phb_reset(hose, OPAL_DEASSERT_RESET); 1999 ioda_eeh_phb_reset(hose, EEH_RESET_DEACTIVATE);
2001 } 2000 }
2002 2001
2003 /* Configure M64 window */ 2002 /* Configure M64 window */
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index b2187d0068b8..4b20f2c6b3b2 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -50,7 +50,6 @@ static int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
50{ 50{
51 struct pci_controller *hose = pci_bus_to_host(pdev->bus); 51 struct pci_controller *hose = pci_bus_to_host(pdev->bus);
52 struct pnv_phb *phb = hose->private_data; 52 struct pnv_phb *phb = hose->private_data;
53 struct pci_dn *pdn = pci_get_pdn(pdev);
54 struct msi_desc *entry; 53 struct msi_desc *entry;
55 struct msi_msg msg; 54 struct msi_msg msg;
56 int hwirq; 55 int hwirq;
@@ -60,7 +59,7 @@ static int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
60 if (WARN_ON(!phb) || !phb->msi_bmp.bitmap) 59 if (WARN_ON(!phb) || !phb->msi_bmp.bitmap)
61 return -ENODEV; 60 return -ENODEV;
62 61
63 if (pdn && pdn->force_32bit_msi && !phb->msi32_support) 62 if (pdev->no_64bit_msi && !phb->msi32_support)
64 return -ENODEV; 63 return -ENODEV;
65 64
66 list_for_each_entry(entry, &pdev->msi_list, list) { 65 list_for_each_entry(entry, &pdev->msi_list, list) {
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index 8ab5add4ac82..8b909e94fd9a 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -420,7 +420,7 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
420 */ 420 */
421again: 421again:
422 if (type == PCI_CAP_ID_MSI) { 422 if (type == PCI_CAP_ID_MSI) {
423 if (pdn->force_32bit_msi) { 423 if (pdev->no_64bit_msi) {
424 rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec); 424 rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec);
425 if (rc < 0) { 425 if (rc < 0) {
426 /* 426 /*
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index de40b48b460e..da08ed088157 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -361,7 +361,7 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
361 cascade_data->virq = virt_msir; 361 cascade_data->virq = virt_msir;
362 msi->cascade_array[irq_index] = cascade_data; 362 msi->cascade_array[irq_index] = cascade_data;
363 363
364 ret = request_irq(virt_msir, fsl_msi_cascade, 0, 364 ret = request_irq(virt_msir, fsl_msi_cascade, IRQF_NO_THREAD,
365 "fsl-msi-cascade", cascade_data); 365 "fsl-msi-cascade", cascade_data);
366 if (ret) { 366 if (ret) {
367 dev_err(&dev->dev, "failed to request_irq(%d), ret = %d\n", 367 dev_err(&dev->dev, "failed to request_irq(%d), ret = %d\n",
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index b988b5addf86..c8efbb37d6e0 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -293,10 +293,10 @@ static inline void disable_surveillance(void)
293 args.token = rtas_token("set-indicator"); 293 args.token = rtas_token("set-indicator");
294 if (args.token == RTAS_UNKNOWN_SERVICE) 294 if (args.token == RTAS_UNKNOWN_SERVICE)
295 return; 295 return;
296 args.nargs = 3; 296 args.nargs = cpu_to_be32(3);
297 args.nret = 1; 297 args.nret = cpu_to_be32(1);
298 args.rets = &args.args[3]; 298 args.rets = &args.args[3];
299 args.args[0] = SURVEILLANCE_TOKEN; 299 args.args[0] = cpu_to_be32(SURVEILLANCE_TOKEN);
300 args.args[1] = 0; 300 args.args[1] = 0;
301 args.args[2] = 0; 301 args.args[2] = 0;
302 enter_rtas(__pa(&args)); 302 enter_rtas(__pa(&args));
diff --git a/arch/sparc/include/asm/atomic_32.h b/arch/sparc/include/asm/atomic_32.h
index 765c1776ec9f..0e69b7e7a439 100644
--- a/arch/sparc/include/asm/atomic_32.h
+++ b/arch/sparc/include/asm/atomic_32.h
@@ -22,7 +22,7 @@
22 22
23int atomic_add_return(int, atomic_t *); 23int atomic_add_return(int, atomic_t *);
24int atomic_cmpxchg(atomic_t *, int, int); 24int atomic_cmpxchg(atomic_t *, int, int);
25#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) 25int atomic_xchg(atomic_t *, int);
26int __atomic_add_unless(atomic_t *, int, int); 26int __atomic_add_unless(atomic_t *, int, int);
27void atomic_set(atomic_t *, int); 27void atomic_set(atomic_t *, int);
28 28
diff --git a/arch/sparc/include/asm/cmpxchg_32.h b/arch/sparc/include/asm/cmpxchg_32.h
index 32c29a133f9d..d38b52dca216 100644
--- a/arch/sparc/include/asm/cmpxchg_32.h
+++ b/arch/sparc/include/asm/cmpxchg_32.h
@@ -11,22 +11,14 @@
11#ifndef __ARCH_SPARC_CMPXCHG__ 11#ifndef __ARCH_SPARC_CMPXCHG__
12#define __ARCH_SPARC_CMPXCHG__ 12#define __ARCH_SPARC_CMPXCHG__
13 13
14static inline unsigned long xchg_u32(__volatile__ unsigned long *m, unsigned long val) 14unsigned long __xchg_u32(volatile u32 *m, u32 new);
15{
16 __asm__ __volatile__("swap [%2], %0"
17 : "=&r" (val)
18 : "0" (val), "r" (m)
19 : "memory");
20 return val;
21}
22
23void __xchg_called_with_bad_pointer(void); 15void __xchg_called_with_bad_pointer(void);
24 16
25static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size) 17static inline unsigned long __xchg(unsigned long x, __volatile__ void * ptr, int size)
26{ 18{
27 switch (size) { 19 switch (size) {
28 case 4: 20 case 4:
29 return xchg_u32(ptr, x); 21 return __xchg_u32(ptr, x);
30 } 22 }
31 __xchg_called_with_bad_pointer(); 23 __xchg_called_with_bad_pointer();
32 return x; 24 return x;
diff --git a/arch/sparc/include/asm/dma-mapping.h b/arch/sparc/include/asm/dma-mapping.h
index 5b1b52a04ad6..7e064c68c5ec 100644
--- a/arch/sparc/include/asm/dma-mapping.h
+++ b/arch/sparc/include/asm/dma-mapping.h
@@ -12,6 +12,14 @@ int dma_supported(struct device *dev, u64 mask);
12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 12#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 13#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
14 14
15static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
16 enum dma_data_direction dir)
17{
18 /* Since dma_{alloc,free}_noncoherent() allocated coherent memory, this
19 * routine can be a nop.
20 */
21}
22
15extern struct dma_map_ops *dma_ops; 23extern struct dma_map_ops *dma_ops;
16extern struct dma_map_ops *leon_dma_ops; 24extern struct dma_map_ops *leon_dma_ops;
17extern struct dma_map_ops pci32_dma_ops; 25extern struct dma_map_ops pci32_dma_ops;
diff --git a/arch/sparc/include/uapi/asm/swab.h b/arch/sparc/include/uapi/asm/swab.h
index a34ad079487e..4c7c12d69bea 100644
--- a/arch/sparc/include/uapi/asm/swab.h
+++ b/arch/sparc/include/uapi/asm/swab.h
@@ -9,9 +9,9 @@ static inline __u16 __arch_swab16p(const __u16 *addr)
9{ 9{
10 __u16 ret; 10 __u16 ret;
11 11
12 __asm__ __volatile__ ("lduha [%1] %2, %0" 12 __asm__ __volatile__ ("lduha [%2] %3, %0"
13 : "=r" (ret) 13 : "=r" (ret)
14 : "r" (addr), "i" (ASI_PL)); 14 : "m" (*addr), "r" (addr), "i" (ASI_PL));
15 return ret; 15 return ret;
16} 16}
17#define __arch_swab16p __arch_swab16p 17#define __arch_swab16p __arch_swab16p
@@ -20,9 +20,9 @@ static inline __u32 __arch_swab32p(const __u32 *addr)
20{ 20{
21 __u32 ret; 21 __u32 ret;
22 22
23 __asm__ __volatile__ ("lduwa [%1] %2, %0" 23 __asm__ __volatile__ ("lduwa [%2] %3, %0"
24 : "=r" (ret) 24 : "=r" (ret)
25 : "r" (addr), "i" (ASI_PL)); 25 : "m" (*addr), "r" (addr), "i" (ASI_PL));
26 return ret; 26 return ret;
27} 27}
28#define __arch_swab32p __arch_swab32p 28#define __arch_swab32p __arch_swab32p
@@ -31,9 +31,9 @@ static inline __u64 __arch_swab64p(const __u64 *addr)
31{ 31{
32 __u64 ret; 32 __u64 ret;
33 33
34 __asm__ __volatile__ ("ldxa [%1] %2, %0" 34 __asm__ __volatile__ ("ldxa [%2] %3, %0"
35 : "=r" (ret) 35 : "=r" (ret)
36 : "r" (addr), "i" (ASI_PL)); 36 : "m" (*addr), "r" (addr), "i" (ASI_PL));
37 return ret; 37 return ret;
38} 38}
39#define __arch_swab64p __arch_swab64p 39#define __arch_swab64p __arch_swab64p
diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c
index 8f76f23dac38..f9c6813c132d 100644
--- a/arch/sparc/kernel/pci_schizo.c
+++ b/arch/sparc/kernel/pci_schizo.c
@@ -581,7 +581,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
581{ 581{
582 unsigned long csr_reg, csr, csr_error_bits; 582 unsigned long csr_reg, csr, csr_error_bits;
583 irqreturn_t ret = IRQ_NONE; 583 irqreturn_t ret = IRQ_NONE;
584 u16 stat; 584 u32 stat;
585 585
586 csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL; 586 csr_reg = pbm->pbm_regs + SCHIZO_PCI_CTRL;
587 csr = upa_readq(csr_reg); 587 csr = upa_readq(csr_reg);
@@ -617,7 +617,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
617 pbm->name); 617 pbm->name);
618 ret = IRQ_HANDLED; 618 ret = IRQ_HANDLED;
619 } 619 }
620 pci_read_config_word(pbm->pci_bus->self, PCI_STATUS, &stat); 620 pbm->pci_ops->read(pbm->pci_bus, 0, PCI_STATUS, 2, &stat);
621 if (stat & (PCI_STATUS_PARITY | 621 if (stat & (PCI_STATUS_PARITY |
622 PCI_STATUS_SIG_TARGET_ABORT | 622 PCI_STATUS_SIG_TARGET_ABORT |
623 PCI_STATUS_REC_TARGET_ABORT | 623 PCI_STATUS_REC_TARGET_ABORT |
@@ -625,7 +625,7 @@ static irqreturn_t schizo_pcierr_intr_other(struct pci_pbm_info *pbm)
625 PCI_STATUS_SIG_SYSTEM_ERROR)) { 625 PCI_STATUS_SIG_SYSTEM_ERROR)) {
626 printk("%s: PCI bus error, PCI_STATUS[%04x]\n", 626 printk("%s: PCI bus error, PCI_STATUS[%04x]\n",
627 pbm->name, stat); 627 pbm->name, stat);
628 pci_write_config_word(pbm->pci_bus->self, PCI_STATUS, 0xffff); 628 pbm->pci_ops->write(pbm->pci_bus, 0, PCI_STATUS, 2, 0xffff);
629 ret = IRQ_HANDLED; 629 ret = IRQ_HANDLED;
630 } 630 }
631 return ret; 631 return ret;
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 302c476413d5..da6f1a7fc4db 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -816,13 +816,17 @@ void arch_send_call_function_single_ipi(int cpu)
816void __irq_entry smp_call_function_client(int irq, struct pt_regs *regs) 816void __irq_entry smp_call_function_client(int irq, struct pt_regs *regs)
817{ 817{
818 clear_softint(1 << irq); 818 clear_softint(1 << irq);
819 irq_enter();
819 generic_smp_call_function_interrupt(); 820 generic_smp_call_function_interrupt();
821 irq_exit();
820} 822}
821 823
822void __irq_entry smp_call_function_single_client(int irq, struct pt_regs *regs) 824void __irq_entry smp_call_function_single_client(int irq, struct pt_regs *regs)
823{ 825{
824 clear_softint(1 << irq); 826 clear_softint(1 << irq);
827 irq_enter();
825 generic_smp_call_function_single_interrupt(); 828 generic_smp_call_function_single_interrupt();
829 irq_exit();
826} 830}
827 831
828static void tsb_sync(void *info) 832static void tsb_sync(void *info)
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index a7c418ac26af..71cd65ab200c 100644
--- a/arch/sparc/lib/atomic32.c
+++ b/arch/sparc/lib/atomic32.c
@@ -45,6 +45,19 @@ ATOMIC_OP(add, +=)
45 45
46#undef ATOMIC_OP 46#undef ATOMIC_OP
47 47
48int atomic_xchg(atomic_t *v, int new)
49{
50 int ret;
51 unsigned long flags;
52
53 spin_lock_irqsave(ATOMIC_HASH(v), flags);
54 ret = v->counter;
55 v->counter = new;
56 spin_unlock_irqrestore(ATOMIC_HASH(v), flags);
57 return ret;
58}
59EXPORT_SYMBOL(atomic_xchg);
60
48int atomic_cmpxchg(atomic_t *v, int old, int new) 61int atomic_cmpxchg(atomic_t *v, int old, int new)
49{ 62{
50 int ret; 63 int ret;
@@ -137,3 +150,17 @@ unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new)
137 return (unsigned long)prev; 150 return (unsigned long)prev;
138} 151}
139EXPORT_SYMBOL(__cmpxchg_u32); 152EXPORT_SYMBOL(__cmpxchg_u32);
153
154unsigned long __xchg_u32(volatile u32 *ptr, u32 new)
155{
156 unsigned long flags;
157 u32 prev;
158
159 spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
160 prev = *ptr;
161 *ptr = new;
162 spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
163
164 return (unsigned long)prev;
165}
166EXPORT_SYMBOL(__xchg_u32);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index ded8a6774ac9..41a503c15862 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -144,7 +144,7 @@ config INSTRUCTION_DECODER
144 144
145config PERF_EVENTS_INTEL_UNCORE 145config PERF_EVENTS_INTEL_UNCORE
146 def_bool y 146 def_bool y
147 depends on PERF_EVENTS && SUP_SUP_INTEL && PCI 147 depends on PERF_EVENTS && CPU_SUP_INTEL && PCI
148 148
149config OUTPUT_FORMAT 149config OUTPUT_FORMAT
150 string 150 string
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 704f58aa79cd..be1e07d4b596 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -76,8 +76,10 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
76suffix-$(CONFIG_KERNEL_LZO) := lzo 76suffix-$(CONFIG_KERNEL_LZO) := lzo
77suffix-$(CONFIG_KERNEL_LZ4) := lz4 77suffix-$(CONFIG_KERNEL_LZ4) := lz4
78 78
79RUN_SIZE = $(shell objdump -h vmlinux | \
80 perl $(srctree)/arch/x86/tools/calc_run_size.pl)
79quiet_cmd_mkpiggy = MKPIGGY $@ 81quiet_cmd_mkpiggy = MKPIGGY $@
80 cmd_mkpiggy = $(obj)/mkpiggy $< > $@ || ( rm -f $@ ; false ) 82 cmd_mkpiggy = $(obj)/mkpiggy $< $(RUN_SIZE) > $@ || ( rm -f $@ ; false )
81 83
82targets += piggy.S 84targets += piggy.S
83$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE 85$(obj)/piggy.S: $(obj)/vmlinux.bin.$(suffix-y) $(obj)/mkpiggy FORCE
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index cbed1407a5cd..1d7fbbcc196d 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -207,7 +207,8 @@ relocated:
207 * Do the decompression, and jump to the new kernel.. 207 * Do the decompression, and jump to the new kernel..
208 */ 208 */
209 /* push arguments for decompress_kernel: */ 209 /* push arguments for decompress_kernel: */
210 pushl $z_output_len /* decompressed length */ 210 pushl $z_run_size /* size of kernel with .bss and .brk */
211 pushl $z_output_len /* decompressed length, end of relocs */
211 leal z_extract_offset_negative(%ebx), %ebp 212 leal z_extract_offset_negative(%ebx), %ebp
212 pushl %ebp /* output address */ 213 pushl %ebp /* output address */
213 pushl $z_input_len /* input_len */ 214 pushl $z_input_len /* input_len */
@@ -217,7 +218,7 @@ relocated:
217 pushl %eax /* heap area */ 218 pushl %eax /* heap area */
218 pushl %esi /* real mode pointer */ 219 pushl %esi /* real mode pointer */
219 call decompress_kernel /* returns kernel location in %eax */ 220 call decompress_kernel /* returns kernel location in %eax */
220 addl $24, %esp 221 addl $28, %esp
221 222
222/* 223/*
223 * Jump to the decompressed kernel. 224 * Jump to the decompressed kernel.
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 2884e0c3e8a5..6b1766c6c082 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -402,13 +402,16 @@ relocated:
402 * Do the decompression, and jump to the new kernel.. 402 * Do the decompression, and jump to the new kernel..
403 */ 403 */
404 pushq %rsi /* Save the real mode argument */ 404 pushq %rsi /* Save the real mode argument */
405 movq $z_run_size, %r9 /* size of kernel with .bss and .brk */
406 pushq %r9
405 movq %rsi, %rdi /* real mode address */ 407 movq %rsi, %rdi /* real mode address */
406 leaq boot_heap(%rip), %rsi /* malloc area for uncompression */ 408 leaq boot_heap(%rip), %rsi /* malloc area for uncompression */
407 leaq input_data(%rip), %rdx /* input_data */ 409 leaq input_data(%rip), %rdx /* input_data */
408 movl $z_input_len, %ecx /* input_len */ 410 movl $z_input_len, %ecx /* input_len */
409 movq %rbp, %r8 /* output target address */ 411 movq %rbp, %r8 /* output target address */
410 movq $z_output_len, %r9 /* decompressed length */ 412 movq $z_output_len, %r9 /* decompressed length, end of relocs */
411 call decompress_kernel /* returns kernel location in %rax */ 413 call decompress_kernel /* returns kernel location in %rax */
414 popq %r9
412 popq %rsi 415 popq %rsi
413 416
414/* 417/*
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 57ab74df7eea..30dd59a9f0b4 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -358,7 +358,8 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
358 unsigned char *input_data, 358 unsigned char *input_data,
359 unsigned long input_len, 359 unsigned long input_len,
360 unsigned char *output, 360 unsigned char *output,
361 unsigned long output_len) 361 unsigned long output_len,
362 unsigned long run_size)
362{ 363{
363 real_mode = rmode; 364 real_mode = rmode;
364 365
@@ -381,8 +382,14 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap,
381 free_mem_ptr = heap; /* Heap */ 382 free_mem_ptr = heap; /* Heap */
382 free_mem_end_ptr = heap + BOOT_HEAP_SIZE; 383 free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
383 384
384 output = choose_kernel_location(input_data, input_len, 385 /*
385 output, output_len); 386 * The memory hole needed for the kernel is the larger of either
387 * the entire decompressed kernel plus relocation table, or the
388 * entire decompressed kernel plus .bss and .brk sections.
389 */
390 output = choose_kernel_location(input_data, input_len, output,
391 output_len > run_size ? output_len
392 : run_size);
386 393
387 /* Validate memory location choices. */ 394 /* Validate memory location choices. */
388 if ((unsigned long)output & (MIN_KERNEL_ALIGN - 1)) 395 if ((unsigned long)output & (MIN_KERNEL_ALIGN - 1))
diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
index b669ab65bf6c..d8222f213182 100644
--- a/arch/x86/boot/compressed/mkpiggy.c
+++ b/arch/x86/boot/compressed/mkpiggy.c
@@ -36,11 +36,13 @@ int main(int argc, char *argv[])
36 uint32_t olen; 36 uint32_t olen;
37 long ilen; 37 long ilen;
38 unsigned long offs; 38 unsigned long offs;
39 unsigned long run_size;
39 FILE *f = NULL; 40 FILE *f = NULL;
40 int retval = 1; 41 int retval = 1;
41 42
42 if (argc < 2) { 43 if (argc < 3) {
43 fprintf(stderr, "Usage: %s compressed_file\n", argv[0]); 44 fprintf(stderr, "Usage: %s compressed_file run_size\n",
45 argv[0]);
44 goto bail; 46 goto bail;
45 } 47 }
46 48
@@ -74,6 +76,7 @@ int main(int argc, char *argv[])
74 offs += olen >> 12; /* Add 8 bytes for each 32K block */ 76 offs += olen >> 12; /* Add 8 bytes for each 32K block */
75 offs += 64*1024 + 128; /* Add 64K + 128 bytes slack */ 77 offs += 64*1024 + 128; /* Add 64K + 128 bytes slack */
76 offs = (offs+4095) & ~4095; /* Round to a 4K boundary */ 78 offs = (offs+4095) & ~4095; /* Round to a 4K boundary */
79 run_size = atoi(argv[2]);
77 80
78 printf(".section \".rodata..compressed\",\"a\",@progbits\n"); 81 printf(".section \".rodata..compressed\",\"a\",@progbits\n");
79 printf(".globl z_input_len\n"); 82 printf(".globl z_input_len\n");
@@ -85,6 +88,8 @@ int main(int argc, char *argv[])
85 /* z_extract_offset_negative allows simplification of head_32.S */ 88 /* z_extract_offset_negative allows simplification of head_32.S */
86 printf(".globl z_extract_offset_negative\n"); 89 printf(".globl z_extract_offset_negative\n");
87 printf("z_extract_offset_negative = -0x%lx\n", offs); 90 printf("z_extract_offset_negative = -0x%lx\n", offs);
91 printf(".globl z_run_size\n");
92 printf("z_run_size = %lu\n", run_size);
88 93
89 printf(".globl input_data, input_data_end\n"); 94 printf(".globl input_data, input_data_end\n");
90 printf("input_data:\n"); 95 printf("input_data:\n");
diff --git a/arch/x86/include/asm/page_32_types.h b/arch/x86/include/asm/page_32_types.h
index f48b17df4224..3a52ee0e726d 100644
--- a/arch/x86/include/asm/page_32_types.h
+++ b/arch/x86/include/asm/page_32_types.h
@@ -20,7 +20,6 @@
20#define THREAD_SIZE_ORDER 1 20#define THREAD_SIZE_ORDER 1
21#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER) 21#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
22 22
23#define STACKFAULT_STACK 0
24#define DOUBLEFAULT_STACK 1 23#define DOUBLEFAULT_STACK 1
25#define NMI_STACK 0 24#define NMI_STACK 0
26#define DEBUG_STACK 0 25#define DEBUG_STACK 0
diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
index 678205195ae1..75450b2c7be4 100644
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -14,12 +14,11 @@
14#define IRQ_STACK_ORDER 2 14#define IRQ_STACK_ORDER 2
15#define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER) 15#define IRQ_STACK_SIZE (PAGE_SIZE << IRQ_STACK_ORDER)
16 16
17#define STACKFAULT_STACK 1 17#define DOUBLEFAULT_STACK 1
18#define DOUBLEFAULT_STACK 2 18#define NMI_STACK 2
19#define NMI_STACK 3 19#define DEBUG_STACK 3
20#define DEBUG_STACK 4 20#define MCE_STACK 4
21#define MCE_STACK 5 21#define N_EXCEPTION_STACKS 4 /* hw limit: 7 */
22#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
23 22
24#define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT) 23#define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT)
25#define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1)) 24#define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1))
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 8cd27e08e23c..8cd1cc3bc835 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -150,6 +150,7 @@ static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
150} 150}
151 151
152void cpu_disable_common(void); 152void cpu_disable_common(void);
153void cpu_die_common(unsigned int cpu);
153void native_smp_prepare_boot_cpu(void); 154void native_smp_prepare_boot_cpu(void);
154void native_smp_prepare_cpus(unsigned int max_cpus); 155void native_smp_prepare_cpus(unsigned int max_cpus);
155void native_smp_cpus_done(unsigned int max_cpus); 156void native_smp_cpus_done(unsigned int max_cpus);
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
index 854053889d4d..547e344a6dc6 100644
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -141,7 +141,7 @@ struct thread_info {
141/* Only used for 64 bit */ 141/* Only used for 64 bit */
142#define _TIF_DO_NOTIFY_MASK \ 142#define _TIF_DO_NOTIFY_MASK \
143 (_TIF_SIGPENDING | _TIF_MCE_NOTIFY | _TIF_NOTIFY_RESUME | \ 143 (_TIF_SIGPENDING | _TIF_MCE_NOTIFY | _TIF_NOTIFY_RESUME | \
144 _TIF_USER_RETURN_NOTIFY) 144 _TIF_USER_RETURN_NOTIFY | _TIF_UPROBE)
145 145
146/* flags to check in __switch_to() */ 146/* flags to check in __switch_to() */
147#define _TIF_WORK_CTXSW \ 147#define _TIF_WORK_CTXSW \
diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
index bc8352e7010a..707adc6549d8 100644
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@ -39,6 +39,7 @@ asmlinkage void simd_coprocessor_error(void);
39 39
40#ifdef CONFIG_TRACING 40#ifdef CONFIG_TRACING
41asmlinkage void trace_page_fault(void); 41asmlinkage void trace_page_fault(void);
42#define trace_stack_segment stack_segment
42#define trace_divide_error divide_error 43#define trace_divide_error divide_error
43#define trace_bounds bounds 44#define trace_bounds bounds
44#define trace_invalid_op invalid_op 45#define trace_invalid_op invalid_op
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 4b4f78c9ba19..cfa9b5b2c27a 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -146,6 +146,8 @@ EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
146 146
147static int __init x86_xsave_setup(char *s) 147static int __init x86_xsave_setup(char *s)
148{ 148{
149 if (strlen(s))
150 return 0;
149 setup_clear_cpu_cap(X86_FEATURE_XSAVE); 151 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
150 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT); 152 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
151 setup_clear_cpu_cap(X86_FEATURE_XSAVES); 153 setup_clear_cpu_cap(X86_FEATURE_XSAVES);
diff --git a/arch/x86/kernel/cpu/microcode/amd_early.c b/arch/x86/kernel/cpu/microcode/amd_early.c
index 7aa1acc79789..06674473b0e6 100644
--- a/arch/x86/kernel/cpu/microcode/amd_early.c
+++ b/arch/x86/kernel/cpu/microcode/amd_early.c
@@ -108,12 +108,13 @@ static size_t compute_container_size(u8 *data, u32 total_size)
108 * load_microcode_amd() to save equivalent cpu table and microcode patches in 108 * load_microcode_amd() to save equivalent cpu table and microcode patches in
109 * kernel heap memory. 109 * kernel heap memory.
110 */ 110 */
111static void apply_ucode_in_initrd(void *ucode, size_t size) 111static void apply_ucode_in_initrd(void *ucode, size_t size, bool save_patch)
112{ 112{
113 struct equiv_cpu_entry *eq; 113 struct equiv_cpu_entry *eq;
114 size_t *cont_sz; 114 size_t *cont_sz;
115 u32 *header; 115 u32 *header;
116 u8 *data, **cont; 116 u8 *data, **cont;
117 u8 (*patch)[PATCH_MAX_SIZE];
117 u16 eq_id = 0; 118 u16 eq_id = 0;
118 int offset, left; 119 int offset, left;
119 u32 rev, eax, ebx, ecx, edx; 120 u32 rev, eax, ebx, ecx, edx;
@@ -123,10 +124,12 @@ static void apply_ucode_in_initrd(void *ucode, size_t size)
123 new_rev = (u32 *)__pa_nodebug(&ucode_new_rev); 124 new_rev = (u32 *)__pa_nodebug(&ucode_new_rev);
124 cont_sz = (size_t *)__pa_nodebug(&container_size); 125 cont_sz = (size_t *)__pa_nodebug(&container_size);
125 cont = (u8 **)__pa_nodebug(&container); 126 cont = (u8 **)__pa_nodebug(&container);
127 patch = (u8 (*)[PATCH_MAX_SIZE])__pa_nodebug(&amd_ucode_patch);
126#else 128#else
127 new_rev = &ucode_new_rev; 129 new_rev = &ucode_new_rev;
128 cont_sz = &container_size; 130 cont_sz = &container_size;
129 cont = &container; 131 cont = &container;
132 patch = &amd_ucode_patch;
130#endif 133#endif
131 134
132 data = ucode; 135 data = ucode;
@@ -213,9 +216,9 @@ static void apply_ucode_in_initrd(void *ucode, size_t size)
213 rev = mc->hdr.patch_id; 216 rev = mc->hdr.patch_id;
214 *new_rev = rev; 217 *new_rev = rev;
215 218
216 /* save ucode patch */ 219 if (save_patch)
217 memcpy(amd_ucode_patch, mc, 220 memcpy(patch, mc,
218 min_t(u32, header[1], PATCH_MAX_SIZE)); 221 min_t(u32, header[1], PATCH_MAX_SIZE));
219 } 222 }
220 } 223 }
221 224
@@ -246,7 +249,7 @@ void __init load_ucode_amd_bsp(void)
246 *data = cp.data; 249 *data = cp.data;
247 *size = cp.size; 250 *size = cp.size;
248 251
249 apply_ucode_in_initrd(cp.data, cp.size); 252 apply_ucode_in_initrd(cp.data, cp.size, true);
250} 253}
251 254
252#ifdef CONFIG_X86_32 255#ifdef CONFIG_X86_32
@@ -263,7 +266,7 @@ void load_ucode_amd_ap(void)
263 size_t *usize; 266 size_t *usize;
264 void **ucode; 267 void **ucode;
265 268
266 mc = (struct microcode_amd *)__pa(amd_ucode_patch); 269 mc = (struct microcode_amd *)__pa_nodebug(amd_ucode_patch);
267 if (mc->hdr.patch_id && mc->hdr.processor_rev_id) { 270 if (mc->hdr.patch_id && mc->hdr.processor_rev_id) {
268 __apply_microcode_amd(mc); 271 __apply_microcode_amd(mc);
269 return; 272 return;
@@ -275,7 +278,7 @@ void load_ucode_amd_ap(void)
275 if (!*ucode || !*usize) 278 if (!*ucode || !*usize)
276 return; 279 return;
277 280
278 apply_ucode_in_initrd(*ucode, *usize); 281 apply_ucode_in_initrd(*ucode, *usize, false);
279} 282}
280 283
281static void __init collect_cpu_sig_on_bsp(void *arg) 284static void __init collect_cpu_sig_on_bsp(void *arg)
@@ -339,7 +342,7 @@ void load_ucode_amd_ap(void)
339 * AP has a different equivalence ID than BSP, looks like 342 * AP has a different equivalence ID than BSP, looks like
340 * mixed-steppings silicon so go through the ucode blob anew. 343 * mixed-steppings silicon so go through the ucode blob anew.
341 */ 344 */
342 apply_ucode_in_initrd(ucode_cpio.data, ucode_cpio.size); 345 apply_ucode_in_initrd(ucode_cpio.data, ucode_cpio.size, false);
343 } 346 }
344} 347}
345#endif 348#endif
@@ -347,7 +350,9 @@ void load_ucode_amd_ap(void)
347int __init save_microcode_in_initrd_amd(void) 350int __init save_microcode_in_initrd_amd(void)
348{ 351{
349 unsigned long cont; 352 unsigned long cont;
353 int retval = 0;
350 enum ucode_state ret; 354 enum ucode_state ret;
355 u8 *cont_va;
351 u32 eax; 356 u32 eax;
352 357
353 if (!container) 358 if (!container)
@@ -355,13 +360,15 @@ int __init save_microcode_in_initrd_amd(void)
355 360
356#ifdef CONFIG_X86_32 361#ifdef CONFIG_X86_32
357 get_bsp_sig(); 362 get_bsp_sig();
358 cont = (unsigned long)container; 363 cont = (unsigned long)container;
364 cont_va = __va(container);
359#else 365#else
360 /* 366 /*
361 * We need the physical address of the container for both bitness since 367 * We need the physical address of the container for both bitness since
362 * boot_params.hdr.ramdisk_image is a physical address. 368 * boot_params.hdr.ramdisk_image is a physical address.
363 */ 369 */
364 cont = __pa(container); 370 cont = __pa(container);
371 cont_va = container;
365#endif 372#endif
366 373
367 /* 374 /*
@@ -372,6 +379,8 @@ int __init save_microcode_in_initrd_amd(void)
372 if (relocated_ramdisk) 379 if (relocated_ramdisk)
373 container = (u8 *)(__va(relocated_ramdisk) + 380 container = (u8 *)(__va(relocated_ramdisk) +
374 (cont - boot_params.hdr.ramdisk_image)); 381 (cont - boot_params.hdr.ramdisk_image));
382 else
383 container = cont_va;
375 384
376 if (ucode_new_rev) 385 if (ucode_new_rev)
377 pr_info("microcode: updated early to new patch_level=0x%08x\n", 386 pr_info("microcode: updated early to new patch_level=0x%08x\n",
@@ -382,7 +391,7 @@ int __init save_microcode_in_initrd_amd(void)
382 391
383 ret = load_microcode_amd(eax, container, container_size); 392 ret = load_microcode_amd(eax, container, container_size);
384 if (ret != UCODE_OK) 393 if (ret != UCODE_OK)
385 return -EINVAL; 394 retval = -EINVAL;
386 395
387 /* 396 /*
388 * This will be freed any msec now, stash patches for the current 397 * This will be freed any msec now, stash patches for the current
@@ -391,5 +400,5 @@ int __init save_microcode_in_initrd_amd(void)
391 container = NULL; 400 container = NULL;
392 container_size = 0; 401 container_size = 0;
393 402
394 return 0; 403 return retval;
395} 404}
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index dd9d6190b08d..2ce9051174e6 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -465,6 +465,14 @@ static void mc_bp_resume(void)
465 465
466 if (uci->valid && uci->mc) 466 if (uci->valid && uci->mc)
467 microcode_ops->apply_microcode(cpu); 467 microcode_ops->apply_microcode(cpu);
468 else if (!uci->mc)
469 /*
470 * We might resume and not have applied late microcode but still
471 * have a newer patch stashed from the early loader. We don't
472 * have it in uci->mc so we have to load it the same way we're
473 * applying patches early on the APs.
474 */
475 load_ucode_ap();
468} 476}
469 477
470static struct syscore_ops mc_syscore_ops = { 478static struct syscore_ops mc_syscore_ops = {
diff --git a/arch/x86/kernel/cpu/microcode/core_early.c b/arch/x86/kernel/cpu/microcode/core_early.c
index 5f28a64e71ea..2c017f242a78 100644
--- a/arch/x86/kernel/cpu/microcode/core_early.c
+++ b/arch/x86/kernel/cpu/microcode/core_early.c
@@ -124,7 +124,7 @@ void __init load_ucode_bsp(void)
124static bool check_loader_disabled_ap(void) 124static bool check_loader_disabled_ap(void)
125{ 125{
126#ifdef CONFIG_X86_32 126#ifdef CONFIG_X86_32
127 return __pa_nodebug(dis_ucode_ldr); 127 return *((bool *)__pa_nodebug(&dis_ucode_ldr));
128#else 128#else
129 return dis_ucode_ldr; 129 return dis_ucode_ldr;
130#endif 130#endif
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
index adf138eac85c..f9ed429d6e4f 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c
@@ -486,14 +486,17 @@ static struct attribute_group snbep_uncore_qpi_format_group = {
486 .attrs = snbep_uncore_qpi_formats_attr, 486 .attrs = snbep_uncore_qpi_formats_attr,
487}; 487};
488 488
489#define SNBEP_UNCORE_MSR_OPS_COMMON_INIT() \ 489#define __SNBEP_UNCORE_MSR_OPS_COMMON_INIT() \
490 .init_box = snbep_uncore_msr_init_box, \
491 .disable_box = snbep_uncore_msr_disable_box, \ 490 .disable_box = snbep_uncore_msr_disable_box, \
492 .enable_box = snbep_uncore_msr_enable_box, \ 491 .enable_box = snbep_uncore_msr_enable_box, \
493 .disable_event = snbep_uncore_msr_disable_event, \ 492 .disable_event = snbep_uncore_msr_disable_event, \
494 .enable_event = snbep_uncore_msr_enable_event, \ 493 .enable_event = snbep_uncore_msr_enable_event, \
495 .read_counter = uncore_msr_read_counter 494 .read_counter = uncore_msr_read_counter
496 495
496#define SNBEP_UNCORE_MSR_OPS_COMMON_INIT() \
497 __SNBEP_UNCORE_MSR_OPS_COMMON_INIT(), \
498 .init_box = snbep_uncore_msr_init_box \
499
497static struct intel_uncore_ops snbep_uncore_msr_ops = { 500static struct intel_uncore_ops snbep_uncore_msr_ops = {
498 SNBEP_UNCORE_MSR_OPS_COMMON_INIT(), 501 SNBEP_UNCORE_MSR_OPS_COMMON_INIT(),
499}; 502};
@@ -1919,6 +1922,30 @@ static struct intel_uncore_type hswep_uncore_cbox = {
1919 .format_group = &hswep_uncore_cbox_format_group, 1922 .format_group = &hswep_uncore_cbox_format_group,
1920}; 1923};
1921 1924
1925/*
1926 * Write SBOX Initialization register bit by bit to avoid spurious #GPs
1927 */
1928static void hswep_uncore_sbox_msr_init_box(struct intel_uncore_box *box)
1929{
1930 unsigned msr = uncore_msr_box_ctl(box);
1931
1932 if (msr) {
1933 u64 init = SNBEP_PMON_BOX_CTL_INT;
1934 u64 flags = 0;
1935 int i;
1936
1937 for_each_set_bit(i, (unsigned long *)&init, 64) {
1938 flags |= (1ULL << i);
1939 wrmsrl(msr, flags);
1940 }
1941 }
1942}
1943
1944static struct intel_uncore_ops hswep_uncore_sbox_msr_ops = {
1945 __SNBEP_UNCORE_MSR_OPS_COMMON_INIT(),
1946 .init_box = hswep_uncore_sbox_msr_init_box
1947};
1948
1922static struct attribute *hswep_uncore_sbox_formats_attr[] = { 1949static struct attribute *hswep_uncore_sbox_formats_attr[] = {
1923 &format_attr_event.attr, 1950 &format_attr_event.attr,
1924 &format_attr_umask.attr, 1951 &format_attr_umask.attr,
@@ -1944,7 +1971,7 @@ static struct intel_uncore_type hswep_uncore_sbox = {
1944 .event_mask = HSWEP_S_MSR_PMON_RAW_EVENT_MASK, 1971 .event_mask = HSWEP_S_MSR_PMON_RAW_EVENT_MASK,
1945 .box_ctl = HSWEP_S0_MSR_PMON_BOX_CTL, 1972 .box_ctl = HSWEP_S0_MSR_PMON_BOX_CTL,
1946 .msr_offset = HSWEP_SBOX_MSR_OFFSET, 1973 .msr_offset = HSWEP_SBOX_MSR_OFFSET,
1947 .ops = &snbep_uncore_msr_ops, 1974 .ops = &hswep_uncore_sbox_msr_ops,
1948 .format_group = &hswep_uncore_sbox_format_group, 1975 .format_group = &hswep_uncore_sbox_format_group,
1949}; 1976};
1950 1977
@@ -2025,13 +2052,27 @@ static struct intel_uncore_type hswep_uncore_imc = {
2025 SNBEP_UNCORE_PCI_COMMON_INIT(), 2052 SNBEP_UNCORE_PCI_COMMON_INIT(),
2026}; 2053};
2027 2054
2055static unsigned hswep_uncore_irp_ctrs[] = {0xa0, 0xa8, 0xb0, 0xb8};
2056
2057static u64 hswep_uncore_irp_read_counter(struct intel_uncore_box *box, struct perf_event *event)
2058{
2059 struct pci_dev *pdev = box->pci_dev;
2060 struct hw_perf_event *hwc = &event->hw;
2061 u64 count = 0;
2062
2063 pci_read_config_dword(pdev, hswep_uncore_irp_ctrs[hwc->idx], (u32 *)&count);
2064 pci_read_config_dword(pdev, hswep_uncore_irp_ctrs[hwc->idx] + 4, (u32 *)&count + 1);
2065
2066 return count;
2067}
2068
2028static struct intel_uncore_ops hswep_uncore_irp_ops = { 2069static struct intel_uncore_ops hswep_uncore_irp_ops = {
2029 .init_box = snbep_uncore_pci_init_box, 2070 .init_box = snbep_uncore_pci_init_box,
2030 .disable_box = snbep_uncore_pci_disable_box, 2071 .disable_box = snbep_uncore_pci_disable_box,
2031 .enable_box = snbep_uncore_pci_enable_box, 2072 .enable_box = snbep_uncore_pci_enable_box,
2032 .disable_event = ivbep_uncore_irp_disable_event, 2073 .disable_event = ivbep_uncore_irp_disable_event,
2033 .enable_event = ivbep_uncore_irp_enable_event, 2074 .enable_event = ivbep_uncore_irp_enable_event,
2034 .read_counter = ivbep_uncore_irp_read_counter, 2075 .read_counter = hswep_uncore_irp_read_counter,
2035}; 2076};
2036 2077
2037static struct intel_uncore_type hswep_uncore_irp = { 2078static struct intel_uncore_type hswep_uncore_irp = {
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index 1abcb50b48ae..ff86f19b5758 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -24,7 +24,6 @@ static char x86_stack_ids[][8] = {
24 [ DEBUG_STACK-1 ] = "#DB", 24 [ DEBUG_STACK-1 ] = "#DB",
25 [ NMI_STACK-1 ] = "NMI", 25 [ NMI_STACK-1 ] = "NMI",
26 [ DOUBLEFAULT_STACK-1 ] = "#DF", 26 [ DOUBLEFAULT_STACK-1 ] = "#DF",
27 [ STACKFAULT_STACK-1 ] = "#SS",
28 [ MCE_STACK-1 ] = "#MC", 27 [ MCE_STACK-1 ] = "#MC",
29#if DEBUG_STKSZ > EXCEPTION_STKSZ 28#if DEBUG_STKSZ > EXCEPTION_STKSZ
30 [ N_EXCEPTION_STACKS ... 29 [ N_EXCEPTION_STACKS ...
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index df088bb03fb3..c0226ab54106 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -828,9 +828,15 @@ ENTRY(native_iret)
828 jnz native_irq_return_ldt 828 jnz native_irq_return_ldt
829#endif 829#endif
830 830
831.global native_irq_return_iret
831native_irq_return_iret: 832native_irq_return_iret:
833 /*
834 * This may fault. Non-paranoid faults on return to userspace are
835 * handled by fixup_bad_iret. These include #SS, #GP, and #NP.
836 * Double-faults due to espfix64 are handled in do_double_fault.
837 * Other faults here are fatal.
838 */
832 iretq 839 iretq
833 _ASM_EXTABLE(native_irq_return_iret, bad_iret)
834 840
835#ifdef CONFIG_X86_ESPFIX64 841#ifdef CONFIG_X86_ESPFIX64
836native_irq_return_ldt: 842native_irq_return_ldt:
@@ -858,25 +864,6 @@ native_irq_return_ldt:
858 jmp native_irq_return_iret 864 jmp native_irq_return_iret
859#endif 865#endif
860 866
861 .section .fixup,"ax"
862bad_iret:
863 /*
864 * The iret traps when the %cs or %ss being restored is bogus.
865 * We've lost the original trap vector and error code.
866 * #GPF is the most likely one to get for an invalid selector.
867 * So pretend we completed the iret and took the #GPF in user mode.
868 *
869 * We are now running with the kernel GS after exception recovery.
870 * But error_entry expects us to have user GS to match the user %cs,
871 * so swap back.
872 */
873 pushq $0
874
875 SWAPGS
876 jmp general_protection
877
878 .previous
879
880 /* edi: workmask, edx: work */ 867 /* edi: workmask, edx: work */
881retint_careful: 868retint_careful:
882 CFI_RESTORE_STATE 869 CFI_RESTORE_STATE
@@ -922,37 +909,6 @@ ENTRY(retint_kernel)
922 CFI_ENDPROC 909 CFI_ENDPROC
923END(common_interrupt) 910END(common_interrupt)
924 911
925 /*
926 * If IRET takes a fault on the espfix stack, then we
927 * end up promoting it to a doublefault. In that case,
928 * modify the stack to make it look like we just entered
929 * the #GP handler from user space, similar to bad_iret.
930 */
931#ifdef CONFIG_X86_ESPFIX64
932 ALIGN
933__do_double_fault:
934 XCPT_FRAME 1 RDI+8
935 movq RSP(%rdi),%rax /* Trap on the espfix stack? */
936 sarq $PGDIR_SHIFT,%rax
937 cmpl $ESPFIX_PGD_ENTRY,%eax
938 jne do_double_fault /* No, just deliver the fault */
939 cmpl $__KERNEL_CS,CS(%rdi)
940 jne do_double_fault
941 movq RIP(%rdi),%rax
942 cmpq $native_irq_return_iret,%rax
943 jne do_double_fault /* This shouldn't happen... */
944 movq PER_CPU_VAR(kernel_stack),%rax
945 subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */
946 movq %rax,RSP(%rdi)
947 movq $0,(%rax) /* Missing (lost) #GP error code */
948 movq $general_protection,RIP(%rdi)
949 retq
950 CFI_ENDPROC
951END(__do_double_fault)
952#else
953# define __do_double_fault do_double_fault
954#endif
955
956/* 912/*
957 * APIC interrupts. 913 * APIC interrupts.
958 */ 914 */
@@ -1124,7 +1080,7 @@ idtentry overflow do_overflow has_error_code=0
1124idtentry bounds do_bounds has_error_code=0 1080idtentry bounds do_bounds has_error_code=0
1125idtentry invalid_op do_invalid_op has_error_code=0 1081idtentry invalid_op do_invalid_op has_error_code=0
1126idtentry device_not_available do_device_not_available has_error_code=0 1082idtentry device_not_available do_device_not_available has_error_code=0
1127idtentry double_fault __do_double_fault has_error_code=1 paranoid=1 1083idtentry double_fault do_double_fault has_error_code=1 paranoid=1
1128idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0 1084idtentry coprocessor_segment_overrun do_coprocessor_segment_overrun has_error_code=0
1129idtentry invalid_TSS do_invalid_TSS has_error_code=1 1085idtentry invalid_TSS do_invalid_TSS has_error_code=1
1130idtentry segment_not_present do_segment_not_present has_error_code=1 1086idtentry segment_not_present do_segment_not_present has_error_code=1
@@ -1289,7 +1245,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
1289 1245
1290idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK 1246idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
1291idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK 1247idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
1292idtentry stack_segment do_stack_segment has_error_code=1 paranoid=1 1248idtentry stack_segment do_stack_segment has_error_code=1
1293#ifdef CONFIG_XEN 1249#ifdef CONFIG_XEN
1294idtentry xen_debug do_debug has_error_code=0 1250idtentry xen_debug do_debug has_error_code=0
1295idtentry xen_int3 do_int3 has_error_code=0 1251idtentry xen_int3 do_int3 has_error_code=0
@@ -1399,17 +1355,16 @@ error_sti:
1399 1355
1400/* 1356/*
1401 * There are two places in the kernel that can potentially fault with 1357 * There are two places in the kernel that can potentially fault with
1402 * usergs. Handle them here. The exception handlers after iret run with 1358 * usergs. Handle them here. B stepping K8s sometimes report a
1403 * kernel gs again, so don't set the user space flag. B stepping K8s 1359 * truncated RIP for IRET exceptions returning to compat mode. Check
1404 * sometimes report an truncated RIP for IRET exceptions returning to 1360 * for these here too.
1405 * compat mode. Check for these here too.
1406 */ 1361 */
1407error_kernelspace: 1362error_kernelspace:
1408 CFI_REL_OFFSET rcx, RCX+8 1363 CFI_REL_OFFSET rcx, RCX+8
1409 incl %ebx 1364 incl %ebx
1410 leaq native_irq_return_iret(%rip),%rcx 1365 leaq native_irq_return_iret(%rip),%rcx
1411 cmpq %rcx,RIP+8(%rsp) 1366 cmpq %rcx,RIP+8(%rsp)
1412 je error_swapgs 1367 je error_bad_iret
1413 movl %ecx,%eax /* zero extend */ 1368 movl %ecx,%eax /* zero extend */
1414 cmpq %rax,RIP+8(%rsp) 1369 cmpq %rax,RIP+8(%rsp)
1415 je bstep_iret 1370 je bstep_iret
@@ -1420,7 +1375,15 @@ error_kernelspace:
1420bstep_iret: 1375bstep_iret:
1421 /* Fix truncated RIP */ 1376 /* Fix truncated RIP */
1422 movq %rcx,RIP+8(%rsp) 1377 movq %rcx,RIP+8(%rsp)
1423 jmp error_swapgs 1378 /* fall through */
1379
1380error_bad_iret:
1381 SWAPGS
1382 mov %rsp,%rdi
1383 call fixup_bad_iret
1384 mov %rax,%rsp
1385 decl %ebx /* Return to usergs */
1386 jmp error_sti
1424 CFI_ENDPROC 1387 CFI_ENDPROC
1425END(error_entry) 1388END(error_entry)
1426 1389
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 749b0e423419..e510618b2e91 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1484,7 +1484,7 @@ unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch)
1484 */ 1484 */
1485 if (work & _TIF_NOHZ) { 1485 if (work & _TIF_NOHZ) {
1486 user_exit(); 1486 user_exit();
1487 work &= ~TIF_NOHZ; 1487 work &= ~_TIF_NOHZ;
1488 } 1488 }
1489 1489
1490#ifdef CONFIG_SECCOMP 1490#ifdef CONFIG_SECCOMP
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 4d2128ac70bd..668d8f2a8781 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1303,10 +1303,14 @@ static void __ref remove_cpu_from_maps(int cpu)
1303 numa_remove_cpu(cpu); 1303 numa_remove_cpu(cpu);
1304} 1304}
1305 1305
1306static DEFINE_PER_CPU(struct completion, die_complete);
1307
1306void cpu_disable_common(void) 1308void cpu_disable_common(void)
1307{ 1309{
1308 int cpu = smp_processor_id(); 1310 int cpu = smp_processor_id();
1309 1311
1312 init_completion(&per_cpu(die_complete, smp_processor_id()));
1313
1310 remove_siblinginfo(cpu); 1314 remove_siblinginfo(cpu);
1311 1315
1312 /* It's now safe to remove this processor from the online map */ 1316 /* It's now safe to remove this processor from the online map */
@@ -1316,8 +1320,6 @@ void cpu_disable_common(void)
1316 fixup_irqs(); 1320 fixup_irqs();
1317} 1321}
1318 1322
1319static DEFINE_PER_CPU(struct completion, die_complete);
1320
1321int native_cpu_disable(void) 1323int native_cpu_disable(void)
1322{ 1324{
1323 int ret; 1325 int ret;
@@ -1327,16 +1329,21 @@ int native_cpu_disable(void)
1327 return ret; 1329 return ret;
1328 1330
1329 clear_local_APIC(); 1331 clear_local_APIC();
1330 init_completion(&per_cpu(die_complete, smp_processor_id()));
1331 cpu_disable_common(); 1332 cpu_disable_common();
1332 1333
1333 return 0; 1334 return 0;
1334} 1335}
1335 1336
1337void cpu_die_common(unsigned int cpu)
1338{
1339 wait_for_completion_timeout(&per_cpu(die_complete, cpu), HZ);
1340}
1341
1336void native_cpu_die(unsigned int cpu) 1342void native_cpu_die(unsigned int cpu)
1337{ 1343{
1338 /* We don't do anything here: idle task is faking death itself. */ 1344 /* We don't do anything here: idle task is faking death itself. */
1339 wait_for_completion_timeout(&per_cpu(die_complete, cpu), HZ); 1345
1346 cpu_die_common(cpu);
1340 1347
1341 /* They ack this in play_dead() by setting CPU_DEAD */ 1348 /* They ack this in play_dead() by setting CPU_DEAD */
1342 if (per_cpu(cpu_state, cpu) == CPU_DEAD) { 1349 if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 0d0e922fafc1..de801f22128a 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -233,32 +233,40 @@ DO_ERROR(X86_TRAP_UD, SIGILL, "invalid opcode", invalid_op)
233DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, "coprocessor segment overrun",coprocessor_segment_overrun) 233DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, "coprocessor segment overrun",coprocessor_segment_overrun)
234DO_ERROR(X86_TRAP_TS, SIGSEGV, "invalid TSS", invalid_TSS) 234DO_ERROR(X86_TRAP_TS, SIGSEGV, "invalid TSS", invalid_TSS)
235DO_ERROR(X86_TRAP_NP, SIGBUS, "segment not present", segment_not_present) 235DO_ERROR(X86_TRAP_NP, SIGBUS, "segment not present", segment_not_present)
236#ifdef CONFIG_X86_32
237DO_ERROR(X86_TRAP_SS, SIGBUS, "stack segment", stack_segment) 236DO_ERROR(X86_TRAP_SS, SIGBUS, "stack segment", stack_segment)
238#endif
239DO_ERROR(X86_TRAP_AC, SIGBUS, "alignment check", alignment_check) 237DO_ERROR(X86_TRAP_AC, SIGBUS, "alignment check", alignment_check)
240 238
241#ifdef CONFIG_X86_64 239#ifdef CONFIG_X86_64
242/* Runs on IST stack */ 240/* Runs on IST stack */
243dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code)
244{
245 enum ctx_state prev_state;
246
247 prev_state = exception_enter();
248 if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
249 X86_TRAP_SS, SIGBUS) != NOTIFY_STOP) {
250 preempt_conditional_sti(regs);
251 do_trap(X86_TRAP_SS, SIGBUS, "stack segment", regs, error_code, NULL);
252 preempt_conditional_cli(regs);
253 }
254 exception_exit(prev_state);
255}
256
257dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code) 241dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
258{ 242{
259 static const char str[] = "double fault"; 243 static const char str[] = "double fault";
260 struct task_struct *tsk = current; 244 struct task_struct *tsk = current;
261 245
246#ifdef CONFIG_X86_ESPFIX64
247 extern unsigned char native_irq_return_iret[];
248
249 /*
250 * If IRET takes a non-IST fault on the espfix64 stack, then we
251 * end up promoting it to a doublefault. In that case, modify
252 * the stack to make it look like we just entered the #GP
253 * handler from user space, similar to bad_iret.
254 */
255 if (((long)regs->sp >> PGDIR_SHIFT) == ESPFIX_PGD_ENTRY &&
256 regs->cs == __KERNEL_CS &&
257 regs->ip == (unsigned long)native_irq_return_iret)
258 {
259 struct pt_regs *normal_regs = task_pt_regs(current);
260
261 /* Fake a #GP(0) from userspace. */
262 memmove(&normal_regs->ip, (void *)regs->sp, 5*8);
263 normal_regs->orig_ax = 0; /* Missing (lost) #GP error code */
264 regs->ip = (unsigned long)general_protection;
265 regs->sp = (unsigned long)&normal_regs->orig_ax;
266 return;
267 }
268#endif
269
262 exception_enter(); 270 exception_enter();
263 /* Return not checked because double check cannot be ignored */ 271 /* Return not checked because double check cannot be ignored */
264 notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV); 272 notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
@@ -399,6 +407,35 @@ asmlinkage __visible struct pt_regs *sync_regs(struct pt_regs *eregs)
399 return regs; 407 return regs;
400} 408}
401NOKPROBE_SYMBOL(sync_regs); 409NOKPROBE_SYMBOL(sync_regs);
410
411struct bad_iret_stack {
412 void *error_entry_ret;
413 struct pt_regs regs;
414};
415
416asmlinkage __visible
417struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
418{
419 /*
420 * This is called from entry_64.S early in handling a fault
421 * caused by a bad iret to user mode. To handle the fault
422 * correctly, we want move our stack frame to task_pt_regs
423 * and we want to pretend that the exception came from the
424 * iret target.
425 */
426 struct bad_iret_stack *new_stack =
427 container_of(task_pt_regs(current),
428 struct bad_iret_stack, regs);
429
430 /* Copy the IRET target to the new stack. */
431 memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
432
433 /* Copy the remainder of the stack from the current stack. */
434 memmove(new_stack, s, offsetof(struct bad_iret_stack, regs.ip));
435
436 BUG_ON(!user_mode_vm(&new_stack->regs));
437 return new_stack;
438}
402#endif 439#endif
403 440
404/* 441/*
@@ -778,7 +815,7 @@ void __init trap_init(void)
778 set_intr_gate(X86_TRAP_OLD_MF, coprocessor_segment_overrun); 815 set_intr_gate(X86_TRAP_OLD_MF, coprocessor_segment_overrun);
779 set_intr_gate(X86_TRAP_TS, invalid_TSS); 816 set_intr_gate(X86_TRAP_TS, invalid_TSS);
780 set_intr_gate(X86_TRAP_NP, segment_not_present); 817 set_intr_gate(X86_TRAP_NP, segment_not_present);
781 set_intr_gate_ist(X86_TRAP_SS, &stack_segment, STACKFAULT_STACK); 818 set_intr_gate(X86_TRAP_SS, stack_segment);
782 set_intr_gate(X86_TRAP_GP, general_protection); 819 set_intr_gate(X86_TRAP_GP, general_protection);
783 set_intr_gate(X86_TRAP_SPURIOUS, spurious_interrupt_bug); 820 set_intr_gate(X86_TRAP_SPURIOUS, spurious_interrupt_bug);
784 set_intr_gate(X86_TRAP_MF, coprocessor_error); 821 set_intr_gate(X86_TRAP_MF, coprocessor_error);
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 5edf088ca51e..9f8a2faf5040 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4287,6 +4287,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
4287 fetch_register_operand(op); 4287 fetch_register_operand(op);
4288 break; 4288 break;
4289 case OpCL: 4289 case OpCL:
4290 op->type = OP_IMM;
4290 op->bytes = 1; 4291 op->bytes = 1;
4291 op->val = reg_read(ctxt, VCPU_REGS_RCX) & 0xff; 4292 op->val = reg_read(ctxt, VCPU_REGS_RCX) & 0xff;
4292 break; 4293 break;
@@ -4294,6 +4295,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
4294 rc = decode_imm(ctxt, op, 1, true); 4295 rc = decode_imm(ctxt, op, 1, true);
4295 break; 4296 break;
4296 case OpOne: 4297 case OpOne:
4298 op->type = OP_IMM;
4297 op->bytes = 1; 4299 op->bytes = 1;
4298 op->val = 1; 4300 op->val = 1;
4299 break; 4301 break;
@@ -4352,21 +4354,27 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
4352 ctxt->memop.bytes = ctxt->op_bytes + 2; 4354 ctxt->memop.bytes = ctxt->op_bytes + 2;
4353 goto mem_common; 4355 goto mem_common;
4354 case OpES: 4356 case OpES:
4357 op->type = OP_IMM;
4355 op->val = VCPU_SREG_ES; 4358 op->val = VCPU_SREG_ES;
4356 break; 4359 break;
4357 case OpCS: 4360 case OpCS:
4361 op->type = OP_IMM;
4358 op->val = VCPU_SREG_CS; 4362 op->val = VCPU_SREG_CS;
4359 break; 4363 break;
4360 case OpSS: 4364 case OpSS:
4365 op->type = OP_IMM;
4361 op->val = VCPU_SREG_SS; 4366 op->val = VCPU_SREG_SS;
4362 break; 4367 break;
4363 case OpDS: 4368 case OpDS:
4369 op->type = OP_IMM;
4364 op->val = VCPU_SREG_DS; 4370 op->val = VCPU_SREG_DS;
4365 break; 4371 break;
4366 case OpFS: 4372 case OpFS:
4373 op->type = OP_IMM;
4367 op->val = VCPU_SREG_FS; 4374 op->val = VCPU_SREG_FS;
4368 break; 4375 break;
4369 case OpGS: 4376 case OpGS:
4377 op->type = OP_IMM;
4370 op->val = VCPU_SREG_GS; 4378 op->val = VCPU_SREG_GS;
4371 break; 4379 break;
4372 case OpImplicit: 4380 case OpImplicit:
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ac1c4de3a484..978f402006ee 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -630,7 +630,7 @@ static int mmu_spte_clear_track_bits(u64 *sptep)
630 * kvm mmu, before reclaiming the page, we should 630 * kvm mmu, before reclaiming the page, we should
631 * unmap it from mmu first. 631 * unmap it from mmu first.
632 */ 632 */
633 WARN_ON(!kvm_is_mmio_pfn(pfn) && !page_count(pfn_to_page(pfn))); 633 WARN_ON(!kvm_is_reserved_pfn(pfn) && !page_count(pfn_to_page(pfn)));
634 634
635 if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) 635 if (!shadow_accessed_mask || old_spte & shadow_accessed_mask)
636 kvm_set_pfn_accessed(pfn); 636 kvm_set_pfn_accessed(pfn);
@@ -2461,7 +2461,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2461 spte |= PT_PAGE_SIZE_MASK; 2461 spte |= PT_PAGE_SIZE_MASK;
2462 if (tdp_enabled) 2462 if (tdp_enabled)
2463 spte |= kvm_x86_ops->get_mt_mask(vcpu, gfn, 2463 spte |= kvm_x86_ops->get_mt_mask(vcpu, gfn,
2464 kvm_is_mmio_pfn(pfn)); 2464 kvm_is_reserved_pfn(pfn));
2465 2465
2466 if (host_writable) 2466 if (host_writable)
2467 spte |= SPTE_HOST_WRITEABLE; 2467 spte |= SPTE_HOST_WRITEABLE;
@@ -2737,7 +2737,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu,
2737 * PT_PAGE_TABLE_LEVEL and there would be no adjustment done 2737 * PT_PAGE_TABLE_LEVEL and there would be no adjustment done
2738 * here. 2738 * here.
2739 */ 2739 */
2740 if (!is_error_noslot_pfn(pfn) && !kvm_is_mmio_pfn(pfn) && 2740 if (!is_error_noslot_pfn(pfn) && !kvm_is_reserved_pfn(pfn) &&
2741 level == PT_PAGE_TABLE_LEVEL && 2741 level == PT_PAGE_TABLE_LEVEL &&
2742 PageTransCompound(pfn_to_page(pfn)) && 2742 PageTransCompound(pfn_to_page(pfn)) &&
2743 !has_wrprotected_page(vcpu->kvm, gfn, PT_DIRECTORY_LEVEL)) { 2743 !has_wrprotected_page(vcpu->kvm, gfn, PT_DIRECTORY_LEVEL)) {
diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
index 7609e0e421ec..1318f75d56e4 100644
--- a/arch/x86/lib/csum-wrappers_64.c
+++ b/arch/x86/lib/csum-wrappers_64.c
@@ -41,9 +41,8 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
41 while (((unsigned long)src & 6) && len >= 2) { 41 while (((unsigned long)src & 6) && len >= 2) {
42 __u16 val16; 42 __u16 val16;
43 43
44 *errp = __get_user(val16, (const __u16 __user *)src); 44 if (__get_user(val16, (const __u16 __user *)src))
45 if (*errp) 45 goto out_err;
46 return isum;
47 46
48 *(__u16 *)dst = val16; 47 *(__u16 *)dst = val16;
49 isum = (__force __wsum)add32_with_carry( 48 isum = (__force __wsum)add32_with_carry(
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 4cb8763868fc..4e5dfec750fc 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1123,7 +1123,7 @@ void mark_rodata_ro(void)
1123 unsigned long end = (unsigned long) &__end_rodata_hpage_align; 1123 unsigned long end = (unsigned long) &__end_rodata_hpage_align;
1124 unsigned long text_end = PFN_ALIGN(&__stop___ex_table); 1124 unsigned long text_end = PFN_ALIGN(&__stop___ex_table);
1125 unsigned long rodata_end = PFN_ALIGN(&__end_rodata); 1125 unsigned long rodata_end = PFN_ALIGN(&__end_rodata);
1126 unsigned long all_end = PFN_ALIGN(&_end); 1126 unsigned long all_end;
1127 1127
1128 printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n", 1128 printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
1129 (end - start) >> 10); 1129 (end - start) >> 10);
@@ -1134,7 +1134,16 @@ void mark_rodata_ro(void)
1134 /* 1134 /*
1135 * The rodata/data/bss/brk section (but not the kernel text!) 1135 * The rodata/data/bss/brk section (but not the kernel text!)
1136 * should also be not-executable. 1136 * should also be not-executable.
1137 *
1138 * We align all_end to PMD_SIZE because the existing mapping
1139 * is a full PMD. If we would align _brk_end to PAGE_SIZE we
1140 * split the PMD and the reminder between _brk_end and the end
1141 * of the PMD will remain mapped executable.
1142 *
1143 * Any PMD which was setup after the one which covers _brk_end
1144 * has been zapped already via cleanup_highmem().
1137 */ 1145 */
1146 all_end = roundup((unsigned long)_brk_end, PMD_SIZE);
1138 set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); 1147 set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT);
1139 1148
1140 rodata_test(); 1149 rodata_test();
diff --git a/arch/x86/tools/calc_run_size.pl b/arch/x86/tools/calc_run_size.pl
new file mode 100644
index 000000000000..23210baade2d
--- /dev/null
+++ b/arch/x86/tools/calc_run_size.pl
@@ -0,0 +1,39 @@
1#!/usr/bin/perl
2#
3# Calculate the amount of space needed to run the kernel, including room for
4# the .bss and .brk sections.
5#
6# Usage:
7# objdump -h a.out | perl calc_run_size.pl
8use strict;
9
10my $mem_size = 0;
11my $file_offset = 0;
12
13my $sections=" *[0-9]+ \.(?:bss|brk) +";
14while (<>) {
15 if (/^$sections([0-9a-f]+) +(?:[0-9a-f]+ +){2}([0-9a-f]+)/) {
16 my $size = hex($1);
17 my $offset = hex($2);
18 $mem_size += $size;
19 if ($file_offset == 0) {
20 $file_offset = $offset;
21 } elsif ($file_offset != $offset) {
22 # BFD linker shows the same file offset in ELF.
23 # Gold linker shows them as consecutive.
24 next if ($file_offset + $mem_size == $offset + $size);
25
26 printf STDERR "file_offset: 0x%lx\n", $file_offset;
27 printf STDERR "mem_size: 0x%lx\n", $mem_size;
28 printf STDERR "offset: 0x%lx\n", $offset;
29 printf STDERR "size: 0x%lx\n", $size;
30
31 die ".bss and .brk are non-contiguous\n";
32 }
33 }
34}
35
36if ($file_offset == 0) {
37 die "Never found .bss or .brk file offset\n";
38}
39printf("%d\n", $mem_size + $file_offset);
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 8650cdb53209..4c071aeb8417 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -510,6 +510,9 @@ static void xen_cpu_die(unsigned int cpu)
510 current->state = TASK_UNINTERRUPTIBLE; 510 current->state = TASK_UNINTERRUPTIBLE;
511 schedule_timeout(HZ/10); 511 schedule_timeout(HZ/10);
512 } 512 }
513
514 cpu_die_common(cpu);
515
513 xen_smp_intr_free(cpu); 516 xen_smp_intr_free(cpu);
514 xen_uninit_lock_cpu(cpu); 517 xen_uninit_lock_cpu(cpu);
515 xen_teardown_timer(cpu); 518 xen_teardown_timer(cpu);
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 49c6c3d94449..81f57e8c8f1b 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -319,8 +319,8 @@ config XTENSA_PLATFORM_S6105
319 319
320config XTENSA_PLATFORM_XTFPGA 320config XTENSA_PLATFORM_XTFPGA
321 bool "XTFPGA" 321 bool "XTFPGA"
322 select ETHOC if ETHERNET
322 select SERIAL_CONSOLE 323 select SERIAL_CONSOLE
323 select ETHOC
324 select XTENSA_CALIBRATE_CCOUNT 324 select XTENSA_CALIBRATE_CCOUNT
325 help 325 help
326 XTFPGA is the name of Tensilica board family (LX60, LX110, LX200, ML605). 326 XTFPGA is the name of Tensilica board family (LX60, LX110, LX200, ML605).
@@ -367,7 +367,7 @@ config BUILTIN_DTB
367config BLK_DEV_SIMDISK 367config BLK_DEV_SIMDISK
368 tristate "Host file-based simulated block device support" 368 tristate "Host file-based simulated block device support"
369 default n 369 default n
370 depends on XTENSA_PLATFORM_ISS 370 depends on XTENSA_PLATFORM_ISS && BLOCK
371 help 371 help
372 Create block devices that map to files in the host file system. 372 Create block devices that map to files in the host file system.
373 Device binding to host file may be changed at runtime via proc 373 Device binding to host file may be changed at runtime via proc
diff --git a/arch/xtensa/boot/dts/lx200mx.dts b/arch/xtensa/boot/dts/lx200mx.dts
new file mode 100644
index 000000000000..249822b99bd6
--- /dev/null
+++ b/arch/xtensa/boot/dts/lx200mx.dts
@@ -0,0 +1,16 @@
1/dts-v1/;
2/include/ "xtfpga.dtsi"
3/include/ "xtfpga-flash-16m.dtsi"
4
5/ {
6 compatible = "cdns,xtensa-lx200";
7 memory@0 {
8 device_type = "memory";
9 reg = <0x00000000 0x06000000>;
10 };
11 pic: pic {
12 compatible = "cdns,xtensa-mx";
13 #interrupt-cells = <2>;
14 interrupt-controller;
15 };
16};
diff --git a/arch/xtensa/configs/generic_kc705_defconfig b/arch/xtensa/configs/generic_kc705_defconfig
new file mode 100644
index 000000000000..f4b7b3888da8
--- /dev/null
+++ b/arch/xtensa/configs/generic_kc705_defconfig
@@ -0,0 +1,131 @@
1CONFIG_SYSVIPC=y
2CONFIG_POSIX_MQUEUE=y
3CONFIG_FHANDLE=y
4CONFIG_IRQ_DOMAIN_DEBUG=y
5CONFIG_NO_HZ_IDLE=y
6CONFIG_HIGH_RES_TIMERS=y
7CONFIG_IRQ_TIME_ACCOUNTING=y
8CONFIG_BSD_PROCESS_ACCT=y
9CONFIG_CGROUP_DEBUG=y
10CONFIG_CGROUP_FREEZER=y
11CONFIG_CGROUP_DEVICE=y
12CONFIG_CPUSETS=y
13CONFIG_CGROUP_CPUACCT=y
14CONFIG_RESOURCE_COUNTERS=y
15CONFIG_MEMCG=y
16CONFIG_NAMESPACES=y
17CONFIG_SCHED_AUTOGROUP=y
18CONFIG_RELAY=y
19CONFIG_BLK_DEV_INITRD=y
20CONFIG_EXPERT=y
21CONFIG_SYSCTL_SYSCALL=y
22CONFIG_KALLSYMS_ALL=y
23CONFIG_PROFILING=y
24CONFIG_OPROFILE=y
25CONFIG_MODULES=y
26CONFIG_MODULE_UNLOAD=y
27# CONFIG_IOSCHED_DEADLINE is not set
28# CONFIG_IOSCHED_CFQ is not set
29CONFIG_XTENSA_VARIANT_DC233C=y
30CONFIG_XTENSA_UNALIGNED_USER=y
31CONFIG_PREEMPT=y
32CONFIG_HIGHMEM=y
33# CONFIG_PCI is not set
34CONFIG_XTENSA_PLATFORM_XTFPGA=y
35CONFIG_CMDLINE_BOOL=y
36CONFIG_CMDLINE="earlycon=uart8250,mmio32,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug"
37CONFIG_USE_OF=y
38CONFIG_BUILTIN_DTB="kc705"
39# CONFIG_COMPACTION is not set
40# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
41CONFIG_NET=y
42CONFIG_PACKET=y
43CONFIG_UNIX=y
44CONFIG_INET=y
45CONFIG_IP_MULTICAST=y
46CONFIG_IP_PNP=y
47CONFIG_IP_PNP_DHCP=y
48CONFIG_IP_PNP_BOOTP=y
49CONFIG_IP_PNP_RARP=y
50# CONFIG_IPV6 is not set
51CONFIG_NETFILTER=y
52# CONFIG_WIRELESS is not set
53CONFIG_DEVTMPFS=y
54CONFIG_DEVTMPFS_MOUNT=y
55# CONFIG_STANDALONE is not set
56CONFIG_MTD=y
57CONFIG_MTD_CFI=y
58CONFIG_MTD_JEDECPROBE=y
59CONFIG_MTD_CFI_INTELEXT=y
60CONFIG_MTD_CFI_AMDSTD=y
61CONFIG_MTD_CFI_STAA=y
62CONFIG_MTD_PHYSMAP_OF=y
63CONFIG_MTD_UBI=y
64CONFIG_BLK_DEV_LOOP=y
65CONFIG_BLK_DEV_RAM=y
66CONFIG_SCSI=y
67CONFIG_BLK_DEV_SD=y
68CONFIG_NETDEVICES=y
69# CONFIG_NET_VENDOR_ARC is not set
70# CONFIG_NET_VENDOR_BROADCOM is not set
71# CONFIG_NET_VENDOR_INTEL is not set
72# CONFIG_NET_VENDOR_MARVELL is not set
73# CONFIG_NET_VENDOR_MICREL is not set
74# CONFIG_NET_VENDOR_NATSEMI is not set
75# CONFIG_NET_VENDOR_SAMSUNG is not set
76# CONFIG_NET_VENDOR_SEEQ is not set
77# CONFIG_NET_VENDOR_SMSC is not set
78# CONFIG_NET_VENDOR_STMICRO is not set
79# CONFIG_NET_VENDOR_VIA is not set
80# CONFIG_NET_VENDOR_WIZNET is not set
81CONFIG_MARVELL_PHY=y
82# CONFIG_WLAN is not set
83# CONFIG_INPUT_MOUSEDEV is not set
84# CONFIG_INPUT_KEYBOARD is not set
85# CONFIG_INPUT_MOUSE is not set
86# CONFIG_SERIO is not set
87CONFIG_SERIAL_8250=y
88# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
89CONFIG_SERIAL_8250_CONSOLE=y
90CONFIG_SERIAL_OF_PLATFORM=y
91CONFIG_HW_RANDOM=y
92# CONFIG_HWMON is not set
93CONFIG_WATCHDOG=y
94CONFIG_WATCHDOG_NOWAYOUT=y
95CONFIG_SOFT_WATCHDOG=y
96# CONFIG_VGA_CONSOLE is not set
97# CONFIG_USB_SUPPORT is not set
98# CONFIG_IOMMU_SUPPORT is not set
99CONFIG_EXT3_FS=y
100CONFIG_EXT4_FS=y
101CONFIG_FANOTIFY=y
102CONFIG_VFAT_FS=y
103CONFIG_PROC_KCORE=y
104CONFIG_TMPFS=y
105CONFIG_TMPFS_POSIX_ACL=y
106CONFIG_UBIFS_FS=y
107CONFIG_NFS_FS=y
108CONFIG_NFS_V4=y
109CONFIG_NFS_SWAP=y
110CONFIG_ROOT_NFS=y
111CONFIG_SUNRPC_DEBUG=y
112CONFIG_NLS_CODEPAGE_437=y
113CONFIG_NLS_ISO8859_1=y
114CONFIG_PRINTK_TIME=y
115CONFIG_DYNAMIC_DEBUG=y
116CONFIG_DEBUG_INFO=y
117CONFIG_MAGIC_SYSRQ=y
118CONFIG_LOCKUP_DETECTOR=y
119# CONFIG_SCHED_DEBUG is not set
120CONFIG_SCHEDSTATS=y
121CONFIG_TIMER_STATS=y
122CONFIG_DEBUG_RT_MUTEXES=y
123CONFIG_DEBUG_SPINLOCK=y
124CONFIG_DEBUG_MUTEXES=y
125CONFIG_DEBUG_ATOMIC_SLEEP=y
126CONFIG_STACKTRACE=y
127CONFIG_RCU_TRACE=y
128# CONFIG_FTRACE is not set
129CONFIG_LD_NO_RELAX=y
130# CONFIG_S32C1I_SELFTEST is not set
131CONFIG_CRYPTO_ANSI_CPRNG=y
diff --git a/arch/xtensa/configs/smp_lx200_defconfig b/arch/xtensa/configs/smp_lx200_defconfig
new file mode 100644
index 000000000000..22eeacba37cc
--- /dev/null
+++ b/arch/xtensa/configs/smp_lx200_defconfig
@@ -0,0 +1,135 @@
1CONFIG_SYSVIPC=y
2CONFIG_POSIX_MQUEUE=y
3CONFIG_FHANDLE=y
4CONFIG_IRQ_DOMAIN_DEBUG=y
5CONFIG_NO_HZ_IDLE=y
6CONFIG_HIGH_RES_TIMERS=y
7CONFIG_IRQ_TIME_ACCOUNTING=y
8CONFIG_BSD_PROCESS_ACCT=y
9CONFIG_CGROUP_DEBUG=y
10CONFIG_CGROUP_FREEZER=y
11CONFIG_CGROUP_DEVICE=y
12CONFIG_CPUSETS=y
13CONFIG_CGROUP_CPUACCT=y
14CONFIG_RESOURCE_COUNTERS=y
15CONFIG_MEMCG=y
16CONFIG_NAMESPACES=y
17CONFIG_SCHED_AUTOGROUP=y
18CONFIG_RELAY=y
19CONFIG_BLK_DEV_INITRD=y
20CONFIG_EXPERT=y
21CONFIG_SYSCTL_SYSCALL=y
22CONFIG_KALLSYMS_ALL=y
23CONFIG_PROFILING=y
24CONFIG_OPROFILE=y
25CONFIG_MODULES=y
26CONFIG_MODULE_UNLOAD=y
27# CONFIG_IOSCHED_DEADLINE is not set
28# CONFIG_IOSCHED_CFQ is not set
29CONFIG_XTENSA_VARIANT_CUSTOM=y
30CONFIG_XTENSA_VARIANT_CUSTOM_NAME="test_mmuhifi_c3"
31CONFIG_XTENSA_UNALIGNED_USER=y
32CONFIG_PREEMPT=y
33CONFIG_HAVE_SMP=y
34CONFIG_SMP=y
35CONFIG_HOTPLUG_CPU=y
36# CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX is not set
37# CONFIG_PCI is not set
38CONFIG_XTENSA_PLATFORM_XTFPGA=y
39CONFIG_CMDLINE_BOOL=y
40CONFIG_CMDLINE="earlycon=uart8250,mmio32,0xfd050020,115200n8 console=ttyS0,115200n8 ip=dhcp root=/dev/nfs rw debug"
41CONFIG_USE_OF=y
42CONFIG_BUILTIN_DTB="lx200mx"
43# CONFIG_COMPACTION is not set
44# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
45CONFIG_NET=y
46CONFIG_PACKET=y
47CONFIG_UNIX=y
48CONFIG_INET=y
49CONFIG_IP_MULTICAST=y
50CONFIG_IP_PNP=y
51CONFIG_IP_PNP_DHCP=y
52CONFIG_IP_PNP_BOOTP=y
53CONFIG_IP_PNP_RARP=y
54# CONFIG_IPV6 is not set
55CONFIG_NETFILTER=y
56# CONFIG_WIRELESS is not set
57CONFIG_DEVTMPFS=y
58CONFIG_DEVTMPFS_MOUNT=y
59# CONFIG_STANDALONE is not set
60CONFIG_MTD=y
61CONFIG_MTD_CFI=y
62CONFIG_MTD_JEDECPROBE=y
63CONFIG_MTD_CFI_INTELEXT=y
64CONFIG_MTD_CFI_AMDSTD=y
65CONFIG_MTD_CFI_STAA=y
66CONFIG_MTD_PHYSMAP_OF=y
67CONFIG_MTD_UBI=y
68CONFIG_BLK_DEV_LOOP=y
69CONFIG_BLK_DEV_RAM=y
70CONFIG_SCSI=y
71CONFIG_BLK_DEV_SD=y
72CONFIG_NETDEVICES=y
73# CONFIG_NET_VENDOR_ARC is not set
74# CONFIG_NET_VENDOR_BROADCOM is not set
75# CONFIG_NET_VENDOR_INTEL is not set
76# CONFIG_NET_VENDOR_MARVELL is not set
77# CONFIG_NET_VENDOR_MICREL is not set
78# CONFIG_NET_VENDOR_NATSEMI is not set
79# CONFIG_NET_VENDOR_SAMSUNG is not set
80# CONFIG_NET_VENDOR_SEEQ is not set
81# CONFIG_NET_VENDOR_SMSC is not set
82# CONFIG_NET_VENDOR_STMICRO is not set
83# CONFIG_NET_VENDOR_VIA is not set
84# CONFIG_NET_VENDOR_WIZNET is not set
85CONFIG_MARVELL_PHY=y
86# CONFIG_WLAN is not set
87# CONFIG_INPUT_MOUSEDEV is not set
88# CONFIG_INPUT_KEYBOARD is not set
89# CONFIG_INPUT_MOUSE is not set
90# CONFIG_SERIO is not set
91CONFIG_SERIAL_8250=y
92# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
93CONFIG_SERIAL_8250_CONSOLE=y
94CONFIG_SERIAL_OF_PLATFORM=y
95CONFIG_HW_RANDOM=y
96# CONFIG_HWMON is not set
97CONFIG_WATCHDOG=y
98CONFIG_WATCHDOG_NOWAYOUT=y
99CONFIG_SOFT_WATCHDOG=y
100# CONFIG_VGA_CONSOLE is not set
101# CONFIG_USB_SUPPORT is not set
102# CONFIG_IOMMU_SUPPORT is not set
103CONFIG_EXT3_FS=y
104CONFIG_EXT4_FS=y
105CONFIG_FANOTIFY=y
106CONFIG_VFAT_FS=y
107CONFIG_PROC_KCORE=y
108CONFIG_TMPFS=y
109CONFIG_TMPFS_POSIX_ACL=y
110CONFIG_UBIFS_FS=y
111CONFIG_NFS_FS=y
112CONFIG_NFS_V4=y
113CONFIG_NFS_SWAP=y
114CONFIG_ROOT_NFS=y
115CONFIG_SUNRPC_DEBUG=y
116CONFIG_NLS_CODEPAGE_437=y
117CONFIG_NLS_ISO8859_1=y
118CONFIG_PRINTK_TIME=y
119CONFIG_DYNAMIC_DEBUG=y
120CONFIG_DEBUG_INFO=y
121CONFIG_MAGIC_SYSRQ=y
122CONFIG_DEBUG_VM=y
123CONFIG_LOCKUP_DETECTOR=y
124CONFIG_SCHEDSTATS=y
125CONFIG_TIMER_STATS=y
126CONFIG_DEBUG_RT_MUTEXES=y
127CONFIG_DEBUG_SPINLOCK=y
128CONFIG_DEBUG_MUTEXES=y
129CONFIG_DEBUG_ATOMIC_SLEEP=y
130CONFIG_STACKTRACE=y
131CONFIG_RCU_TRACE=y
132# CONFIG_FTRACE is not set
133CONFIG_LD_NO_RELAX=y
134# CONFIG_S32C1I_SELFTEST is not set
135CONFIG_CRYPTO_ANSI_CPRNG=y
diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h
index b2173e5da601..0383aed59121 100644
--- a/arch/xtensa/include/asm/pgtable.h
+++ b/arch/xtensa/include/asm/pgtable.h
@@ -277,6 +277,8 @@ static inline pte_t pte_mkwrite(pte_t pte)
277static inline pte_t pte_mkspecial(pte_t pte) 277static inline pte_t pte_mkspecial(pte_t pte)
278 { return pte; } 278 { return pte; }
279 279
280#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) & ~_PAGE_CA_MASK))
281
280/* 282/*
281 * Conversion functions: convert a page and protection to a page entry, 283 * Conversion functions: convert a page and protection to a page entry,
282 * and a page entry and page directory to the page they refer to. 284 * and a page entry and page directory to the page they refer to.
diff --git a/arch/xtensa/include/uapi/asm/unistd.h b/arch/xtensa/include/uapi/asm/unistd.h
index 8883fc877c5c..db5bb72e2f4e 100644
--- a/arch/xtensa/include/uapi/asm/unistd.h
+++ b/arch/xtensa/include/uapi/asm/unistd.h
@@ -384,7 +384,8 @@ __SYSCALL(174, sys_chroot, 1)
384#define __NR_pivot_root 175 384#define __NR_pivot_root 175
385__SYSCALL(175, sys_pivot_root, 2) 385__SYSCALL(175, sys_pivot_root, 2)
386#define __NR_umount 176 386#define __NR_umount 176
387__SYSCALL(176, sys_umount, 2) 387__SYSCALL(176, sys_oldumount, 1)
388#define __ARCH_WANT_SYS_OLDUMOUNT
388#define __NR_swapoff 177 389#define __NR_swapoff 177
389__SYSCALL(177, sys_swapoff, 1) 390__SYSCALL(177, sys_swapoff, 1)
390#define __NR_sync 178 391#define __NR_sync 178
@@ -742,7 +743,14 @@ __SYSCALL(335, sys_sched_getattr, 3)
742#define __NR_renameat2 336 743#define __NR_renameat2 336
743__SYSCALL(336, sys_renameat2, 5) 744__SYSCALL(336, sys_renameat2, 5)
744 745
745#define __NR_syscall_count 337 746#define __NR_seccomp 337
747__SYSCALL(337, sys_seccomp, 3)
748#define __NR_getrandom 338
749__SYSCALL(338, sys_getrandom, 3)
750#define __NR_memfd_create 339
751__SYSCALL(339, sys_memfd_create, 2)
752
753#define __NR_syscall_count 340
746 754
747/* 755/*
748 * sysxtensa syscall handler 756 * sysxtensa syscall handler
diff --git a/block/blk-merge.c b/block/blk-merge.c
index b3ac40aef46b..89b97b5e0881 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -97,19 +97,22 @@ void blk_recalc_rq_segments(struct request *rq)
97 97
98void blk_recount_segments(struct request_queue *q, struct bio *bio) 98void blk_recount_segments(struct request_queue *q, struct bio *bio)
99{ 99{
100 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, 100 unsigned short seg_cnt;
101 &q->queue_flags); 101
102 bool merge_not_need = bio->bi_vcnt < queue_max_segments(q); 102 /* estimate segment number by bi_vcnt for non-cloned bio */
103 if (bio_flagged(bio, BIO_CLONED))
104 seg_cnt = bio_segments(bio);
105 else
106 seg_cnt = bio->bi_vcnt;
103 107
104 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) && 108 if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) &&
105 merge_not_need) 109 (seg_cnt < queue_max_segments(q)))
106 bio->bi_phys_segments = bio->bi_vcnt; 110 bio->bi_phys_segments = seg_cnt;
107 else { 111 else {
108 struct bio *nxt = bio->bi_next; 112 struct bio *nxt = bio->bi_next;
109 113
110 bio->bi_next = NULL; 114 bio->bi_next = NULL;
111 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, 115 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, false);
112 no_sg_merge && merge_not_need);
113 bio->bi_next = nxt; 116 bio->bi_next = nxt;
114 } 117 }
115 118
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 68929bad9a6a..1d016fc9a8b6 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -107,11 +107,7 @@ static void blk_mq_usage_counter_release(struct percpu_ref *ref)
107 wake_up_all(&q->mq_freeze_wq); 107 wake_up_all(&q->mq_freeze_wq);
108} 108}
109 109
110/* 110static void blk_mq_freeze_queue_start(struct request_queue *q)
111 * Guarantee no request is in use, so we can change any data structure of
112 * the queue afterward.
113 */
114void blk_mq_freeze_queue(struct request_queue *q)
115{ 111{
116 bool freeze; 112 bool freeze;
117 113
@@ -123,9 +119,23 @@ void blk_mq_freeze_queue(struct request_queue *q)
123 percpu_ref_kill(&q->mq_usage_counter); 119 percpu_ref_kill(&q->mq_usage_counter);
124 blk_mq_run_queues(q, false); 120 blk_mq_run_queues(q, false);
125 } 121 }
122}
123
124static void blk_mq_freeze_queue_wait(struct request_queue *q)
125{
126 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter)); 126 wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->mq_usage_counter));
127} 127}
128 128
129/*
130 * Guarantee no request is in use, so we can change any data structure of
131 * the queue afterward.
132 */
133void blk_mq_freeze_queue(struct request_queue *q)
134{
135 blk_mq_freeze_queue_start(q);
136 blk_mq_freeze_queue_wait(q);
137}
138
129static void blk_mq_unfreeze_queue(struct request_queue *q) 139static void blk_mq_unfreeze_queue(struct request_queue *q)
130{ 140{
131 bool wake; 141 bool wake;
@@ -1921,7 +1931,7 @@ void blk_mq_free_queue(struct request_queue *q)
1921/* Basically redo blk_mq_init_queue with queue frozen */ 1931/* Basically redo blk_mq_init_queue with queue frozen */
1922static void blk_mq_queue_reinit(struct request_queue *q) 1932static void blk_mq_queue_reinit(struct request_queue *q)
1923{ 1933{
1924 blk_mq_freeze_queue(q); 1934 WARN_ON_ONCE(!q->mq_freeze_depth);
1925 1935
1926 blk_mq_sysfs_unregister(q); 1936 blk_mq_sysfs_unregister(q);
1927 1937
@@ -1936,8 +1946,6 @@ static void blk_mq_queue_reinit(struct request_queue *q)
1936 blk_mq_map_swqueue(q); 1946 blk_mq_map_swqueue(q);
1937 1947
1938 blk_mq_sysfs_register(q); 1948 blk_mq_sysfs_register(q);
1939
1940 blk_mq_unfreeze_queue(q);
1941} 1949}
1942 1950
1943static int blk_mq_queue_reinit_notify(struct notifier_block *nb, 1951static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
@@ -1956,8 +1964,25 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb,
1956 return NOTIFY_OK; 1964 return NOTIFY_OK;
1957 1965
1958 mutex_lock(&all_q_mutex); 1966 mutex_lock(&all_q_mutex);
1967
1968 /*
1969 * We need to freeze and reinit all existing queues. Freezing
1970 * involves synchronous wait for an RCU grace period and doing it
1971 * one by one may take a long time. Start freezing all queues in
1972 * one swoop and then wait for the completions so that freezing can
1973 * take place in parallel.
1974 */
1975 list_for_each_entry(q, &all_q_list, all_q_node)
1976 blk_mq_freeze_queue_start(q);
1977 list_for_each_entry(q, &all_q_list, all_q_node)
1978 blk_mq_freeze_queue_wait(q);
1979
1959 list_for_each_entry(q, &all_q_list, all_q_node) 1980 list_for_each_entry(q, &all_q_list, all_q_node)
1960 blk_mq_queue_reinit(q); 1981 blk_mq_queue_reinit(q);
1982
1983 list_for_each_entry(q, &all_q_list, all_q_node)
1984 blk_mq_unfreeze_queue(q);
1985
1961 mutex_unlock(&all_q_mutex); 1986 mutex_unlock(&all_q_mutex);
1962 return NOTIFY_OK; 1987 return NOTIFY_OK;
1963} 1988}
diff --git a/block/ioprio.c b/block/ioprio.c
index e50170ca7c33..31666c92b46a 100644
--- a/block/ioprio.c
+++ b/block/ioprio.c
@@ -157,14 +157,16 @@ out:
157 157
158int ioprio_best(unsigned short aprio, unsigned short bprio) 158int ioprio_best(unsigned short aprio, unsigned short bprio)
159{ 159{
160 unsigned short aclass = IOPRIO_PRIO_CLASS(aprio); 160 unsigned short aclass;
161 unsigned short bclass = IOPRIO_PRIO_CLASS(bprio); 161 unsigned short bclass;
162 162
163 if (aclass == IOPRIO_CLASS_NONE) 163 if (!ioprio_valid(aprio))
164 aclass = IOPRIO_CLASS_BE; 164 aprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
165 if (bclass == IOPRIO_CLASS_NONE) 165 if (!ioprio_valid(bprio))
166 bclass = IOPRIO_CLASS_BE; 166 bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM);
167 167
168 aclass = IOPRIO_PRIO_CLASS(aprio);
169 bclass = IOPRIO_PRIO_CLASS(bprio);
168 if (aclass == bclass) 170 if (aclass == bclass)
169 return min(aprio, bprio); 171 return min(aprio, bprio);
170 if (aclass > bclass) 172 if (aclass > bclass)
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 1e053d911240..b0c2a616c8f9 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -458,7 +458,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
458 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); 458 rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
459 if (IS_ERR(rq)) { 459 if (IS_ERR(rq)) {
460 err = PTR_ERR(rq); 460 err = PTR_ERR(rq);
461 goto error; 461 goto error_free_buffer;
462 } 462 }
463 blk_rq_set_block_pc(rq); 463 blk_rq_set_block_pc(rq);
464 464
@@ -531,9 +531,11 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
531 } 531 }
532 532
533error: 533error:
534 blk_put_request(rq);
535
536error_free_buffer:
534 kfree(buffer); 537 kfree(buffer);
535 if (rq) 538
536 blk_put_request(rq);
537 return err; 539 return err;
538} 540}
539EXPORT_SYMBOL_GPL(sg_scsi_ioctl); 541EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index ed122e17636e..7556e7c4a055 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -290,6 +290,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
290 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"), 290 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3446"),
291 }, 291 },
292 }, 292 },
293 {
294 .callback = dmi_disable_osi_win8,
295 .ident = "Dell Vostro 3546",
296 .matches = {
297 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
298 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 3546"),
299 },
300 },
293 301
294 /* 302 /*
295 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 303 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 143ec6ea1468..7db193160766 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -878,7 +878,7 @@ int acpi_dev_suspend_late(struct device *dev)
878 return 0; 878 return 0;
879 879
880 target_state = acpi_target_system_state(); 880 target_state = acpi_target_system_state();
881 wakeup = device_may_wakeup(dev); 881 wakeup = device_may_wakeup(dev) && acpi_device_can_wakeup(adev);
882 error = acpi_device_wakeup(adev, target_state, wakeup); 882 error = acpi_device_wakeup(adev, target_state, wakeup);
883 if (wakeup && error) 883 if (wakeup && error)
884 return error; 884 return error;
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5f039f191067..e45f83789809 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -60,6 +60,7 @@ enum board_ids {
60 /* board IDs by feature in alphabetical order */ 60 /* board IDs by feature in alphabetical order */
61 board_ahci, 61 board_ahci,
62 board_ahci_ign_iferr, 62 board_ahci_ign_iferr,
63 board_ahci_nomsi,
63 board_ahci_noncq, 64 board_ahci_noncq,
64 board_ahci_nosntf, 65 board_ahci_nosntf,
65 board_ahci_yes_fbs, 66 board_ahci_yes_fbs,
@@ -121,6 +122,13 @@ static const struct ata_port_info ahci_port_info[] = {
121 .udma_mask = ATA_UDMA6, 122 .udma_mask = ATA_UDMA6,
122 .port_ops = &ahci_ops, 123 .port_ops = &ahci_ops,
123 }, 124 },
125 [board_ahci_nomsi] = {
126 AHCI_HFLAGS (AHCI_HFLAG_NO_MSI),
127 .flags = AHCI_FLAG_COMMON,
128 .pio_mask = ATA_PIO4,
129 .udma_mask = ATA_UDMA6,
130 .port_ops = &ahci_ops,
131 },
124 [board_ahci_noncq] = { 132 [board_ahci_noncq] = {
125 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ), 133 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ),
126 .flags = AHCI_FLAG_COMMON, 134 .flags = AHCI_FLAG_COMMON,
@@ -313,6 +321,11 @@ static const struct pci_device_id ahci_pci_tbl[] = {
313 { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series RAID */ 321 { PCI_VDEVICE(INTEL, 0x8c87), board_ahci }, /* 9 Series RAID */
314 { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */ 322 { PCI_VDEVICE(INTEL, 0x8c8e), board_ahci }, /* 9 Series RAID */
315 { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series RAID */ 323 { PCI_VDEVICE(INTEL, 0x8c8f), board_ahci }, /* 9 Series RAID */
324 { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H AHCI */
325 { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H RAID */
326 { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
327 { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H RAID */
328 { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
316 329
317 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 330 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
318 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 331 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -475,10 +488,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
475 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */ 488 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
476 489
477 /* 490 /*
478 * Samsung SSDs found on some macbooks. NCQ times out. 491 * Samsung SSDs found on some macbooks. NCQ times out if MSI is
479 * https://bugzilla.kernel.org/show_bug.cgi?id=60731 492 * enabled. https://bugzilla.kernel.org/show_bug.cgi?id=60731
480 */ 493 */
481 { PCI_VDEVICE(SAMSUNG, 0x1600), board_ahci_noncq }, 494 { PCI_VDEVICE(SAMSUNG, 0x1600), board_ahci_nomsi },
482 495
483 /* Enmotus */ 496 /* Enmotus */
484 { PCI_DEVICE(0x1c44, 0x8000), board_ahci }, 497 { PCI_DEVICE(0x1c44, 0x8000), board_ahci },
@@ -514,12 +527,9 @@ MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
514static void ahci_pci_save_initial_config(struct pci_dev *pdev, 527static void ahci_pci_save_initial_config(struct pci_dev *pdev,
515 struct ahci_host_priv *hpriv) 528 struct ahci_host_priv *hpriv)
516{ 529{
517 unsigned int force_port_map = 0;
518 unsigned int mask_port_map = 0;
519
520 if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) { 530 if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
521 dev_info(&pdev->dev, "JMB361 has only one port\n"); 531 dev_info(&pdev->dev, "JMB361 has only one port\n");
522 force_port_map = 1; 532 hpriv->force_port_map = 1;
523 } 533 }
524 534
525 /* 535 /*
@@ -529,9 +539,9 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev,
529 */ 539 */
530 if (hpriv->flags & AHCI_HFLAG_MV_PATA) { 540 if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
531 if (pdev->device == 0x6121) 541 if (pdev->device == 0x6121)
532 mask_port_map = 0x3; 542 hpriv->mask_port_map = 0x3;
533 else 543 else
534 mask_port_map = 0xf; 544 hpriv->mask_port_map = 0xf;
535 dev_info(&pdev->dev, 545 dev_info(&pdev->dev,
536 "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n"); 546 "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
537 } 547 }
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 5eb61c9e63da..97683e45ab04 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1778,16 +1778,15 @@ static void ahci_handle_port_interrupt(struct ata_port *ap,
1778 } 1778 }
1779} 1779}
1780 1780
1781static void ahci_update_intr_status(struct ata_port *ap) 1781static void ahci_port_intr(struct ata_port *ap)
1782{ 1782{
1783 void __iomem *port_mmio = ahci_port_base(ap); 1783 void __iomem *port_mmio = ahci_port_base(ap);
1784 struct ahci_port_priv *pp = ap->private_data;
1785 u32 status; 1784 u32 status;
1786 1785
1787 status = readl(port_mmio + PORT_IRQ_STAT); 1786 status = readl(port_mmio + PORT_IRQ_STAT);
1788 writel(status, port_mmio + PORT_IRQ_STAT); 1787 writel(status, port_mmio + PORT_IRQ_STAT);
1789 1788
1790 atomic_or(status, &pp->intr_status); 1789 ahci_handle_port_interrupt(ap, port_mmio, status);
1791} 1790}
1792 1791
1793static irqreturn_t ahci_port_thread_fn(int irq, void *dev_instance) 1792static irqreturn_t ahci_port_thread_fn(int irq, void *dev_instance)
@@ -1808,34 +1807,6 @@ static irqreturn_t ahci_port_thread_fn(int irq, void *dev_instance)
1808 return IRQ_HANDLED; 1807 return IRQ_HANDLED;
1809} 1808}
1810 1809
1811irqreturn_t ahci_thread_fn(int irq, void *dev_instance)
1812{
1813 struct ata_host *host = dev_instance;
1814 struct ahci_host_priv *hpriv = host->private_data;
1815 u32 irq_masked = hpriv->port_map;
1816 unsigned int i;
1817
1818 for (i = 0; i < host->n_ports; i++) {
1819 struct ata_port *ap;
1820
1821 if (!(irq_masked & (1 << i)))
1822 continue;
1823
1824 ap = host->ports[i];
1825 if (ap) {
1826 ahci_port_thread_fn(irq, ap);
1827 VPRINTK("port %u\n", i);
1828 } else {
1829 VPRINTK("port %u (no irq)\n", i);
1830 if (ata_ratelimit())
1831 dev_warn(host->dev,
1832 "interrupt on disabled port %u\n", i);
1833 }
1834 }
1835
1836 return IRQ_HANDLED;
1837}
1838
1839static irqreturn_t ahci_multi_irqs_intr(int irq, void *dev_instance) 1810static irqreturn_t ahci_multi_irqs_intr(int irq, void *dev_instance)
1840{ 1811{
1841 struct ata_port *ap = dev_instance; 1812 struct ata_port *ap = dev_instance;
@@ -1875,6 +1846,8 @@ static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
1875 1846
1876 irq_masked = irq_stat & hpriv->port_map; 1847 irq_masked = irq_stat & hpriv->port_map;
1877 1848
1849 spin_lock(&host->lock);
1850
1878 for (i = 0; i < host->n_ports; i++) { 1851 for (i = 0; i < host->n_ports; i++) {
1879 struct ata_port *ap; 1852 struct ata_port *ap;
1880 1853
@@ -1883,7 +1856,7 @@ static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
1883 1856
1884 ap = host->ports[i]; 1857 ap = host->ports[i];
1885 if (ap) { 1858 if (ap) {
1886 ahci_update_intr_status(ap); 1859 ahci_port_intr(ap);
1887 VPRINTK("port %u\n", i); 1860 VPRINTK("port %u\n", i);
1888 } else { 1861 } else {
1889 VPRINTK("port %u (no irq)\n", i); 1862 VPRINTK("port %u (no irq)\n", i);
@@ -1906,9 +1879,11 @@ static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
1906 */ 1879 */
1907 writel(irq_stat, mmio + HOST_IRQ_STAT); 1880 writel(irq_stat, mmio + HOST_IRQ_STAT);
1908 1881
1882 spin_unlock(&host->lock);
1883
1909 VPRINTK("EXIT\n"); 1884 VPRINTK("EXIT\n");
1910 1885
1911 return handled ? IRQ_WAKE_THREAD : IRQ_NONE; 1886 return IRQ_RETVAL(handled);
1912} 1887}
1913 1888
1914unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) 1889unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
@@ -2320,8 +2295,13 @@ static int ahci_port_start(struct ata_port *ap)
2320 */ 2295 */
2321 pp->intr_mask = DEF_PORT_IRQ; 2296 pp->intr_mask = DEF_PORT_IRQ;
2322 2297
2323 spin_lock_init(&pp->lock); 2298 /*
2324 ap->lock = &pp->lock; 2299 * Switch to per-port locking in case each port has its own MSI vector.
2300 */
2301 if ((hpriv->flags & AHCI_HFLAG_MULTI_MSI)) {
2302 spin_lock_init(&pp->lock);
2303 ap->lock = &pp->lock;
2304 }
2325 2305
2326 ap->private_data = pp; 2306 ap->private_data = pp;
2327 2307
@@ -2482,31 +2462,6 @@ out_free_irqs:
2482 return rc; 2462 return rc;
2483} 2463}
2484 2464
2485static int ahci_host_activate_single_irq(struct ata_host *host, int irq,
2486 struct scsi_host_template *sht)
2487{
2488 int i, rc;
2489
2490 rc = ata_host_start(host);
2491 if (rc)
2492 return rc;
2493
2494 rc = devm_request_threaded_irq(host->dev, irq, ahci_single_irq_intr,
2495 ahci_thread_fn, IRQF_SHARED,
2496 dev_driver_string(host->dev), host);
2497 if (rc)
2498 return rc;
2499
2500 for (i = 0; i < host->n_ports; i++)
2501 ata_port_desc(host->ports[i], "irq %d", irq);
2502
2503 rc = ata_host_register(host, sht);
2504 if (rc)
2505 devm_free_irq(host->dev, irq, host);
2506
2507 return rc;
2508}
2509
2510/** 2465/**
2511 * ahci_host_activate - start AHCI host, request IRQs and register it 2466 * ahci_host_activate - start AHCI host, request IRQs and register it
2512 * @host: target ATA host 2467 * @host: target ATA host
@@ -2532,7 +2487,8 @@ int ahci_host_activate(struct ata_host *host, int irq,
2532 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI) 2487 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI)
2533 rc = ahci_host_activate_multi_irqs(host, irq, sht); 2488 rc = ahci_host_activate_multi_irqs(host, irq, sht);
2534 else 2489 else
2535 rc = ahci_host_activate_single_irq(host, irq, sht); 2490 rc = ata_host_activate(host, irq, ahci_single_irq_intr,
2491 IRQF_SHARED, sht);
2536 return rc; 2492 return rc;
2537} 2493}
2538EXPORT_SYMBOL_GPL(ahci_host_activate); 2494EXPORT_SYMBOL_GPL(ahci_host_activate);
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
index 61eb6d77dac7..ea1fbc1d4c5f 100644
--- a/drivers/ata/sata_rcar.c
+++ b/drivers/ata/sata_rcar.c
@@ -146,6 +146,7 @@
146enum sata_rcar_type { 146enum sata_rcar_type {
147 RCAR_GEN1_SATA, 147 RCAR_GEN1_SATA,
148 RCAR_GEN2_SATA, 148 RCAR_GEN2_SATA,
149 RCAR_R8A7790_ES1_SATA,
149}; 150};
150 151
151struct sata_rcar_priv { 152struct sata_rcar_priv {
@@ -763,6 +764,9 @@ static void sata_rcar_setup_port(struct ata_host *host)
763 ap->udma_mask = ATA_UDMA6; 764 ap->udma_mask = ATA_UDMA6;
764 ap->flags |= ATA_FLAG_SATA; 765 ap->flags |= ATA_FLAG_SATA;
765 766
767 if (priv->type == RCAR_R8A7790_ES1_SATA)
768 ap->flags |= ATA_FLAG_NO_DIPM;
769
766 ioaddr->cmd_addr = base + SDATA_REG; 770 ioaddr->cmd_addr = base + SDATA_REG;
767 ioaddr->ctl_addr = base + SSDEVCON_REG; 771 ioaddr->ctl_addr = base + SSDEVCON_REG;
768 ioaddr->scr_addr = base + SCRSSTS_REG; 772 ioaddr->scr_addr = base + SCRSSTS_REG;
@@ -792,6 +796,7 @@ static void sata_rcar_init_controller(struct ata_host *host)
792 sata_rcar_gen1_phy_init(priv); 796 sata_rcar_gen1_phy_init(priv);
793 break; 797 break;
794 case RCAR_GEN2_SATA: 798 case RCAR_GEN2_SATA:
799 case RCAR_R8A7790_ES1_SATA:
795 sata_rcar_gen2_phy_init(priv); 800 sata_rcar_gen2_phy_init(priv);
796 break; 801 break;
797 default: 802 default:
@@ -838,9 +843,17 @@ static struct of_device_id sata_rcar_match[] = {
838 .data = (void *)RCAR_GEN2_SATA 843 .data = (void *)RCAR_GEN2_SATA
839 }, 844 },
840 { 845 {
846 .compatible = "renesas,sata-r8a7790-es1",
847 .data = (void *)RCAR_R8A7790_ES1_SATA
848 },
849 {
841 .compatible = "renesas,sata-r8a7791", 850 .compatible = "renesas,sata-r8a7791",
842 .data = (void *)RCAR_GEN2_SATA 851 .data = (void *)RCAR_GEN2_SATA
843 }, 852 },
853 {
854 .compatible = "renesas,sata-r8a7793",
855 .data = (void *)RCAR_GEN2_SATA
856 },
844 { }, 857 { },
845}; 858};
846MODULE_DEVICE_TABLE(of, sata_rcar_match); 859MODULE_DEVICE_TABLE(of, sata_rcar_match);
@@ -849,7 +862,9 @@ static const struct platform_device_id sata_rcar_id_table[] = {
849 { "sata_rcar", RCAR_GEN1_SATA }, /* Deprecated by "sata-r8a7779" */ 862 { "sata_rcar", RCAR_GEN1_SATA }, /* Deprecated by "sata-r8a7779" */
850 { "sata-r8a7779", RCAR_GEN1_SATA }, 863 { "sata-r8a7779", RCAR_GEN1_SATA },
851 { "sata-r8a7790", RCAR_GEN2_SATA }, 864 { "sata-r8a7790", RCAR_GEN2_SATA },
865 { "sata-r8a7790-es1", RCAR_R8A7790_ES1_SATA },
852 { "sata-r8a7791", RCAR_GEN2_SATA }, 866 { "sata-r8a7791", RCAR_GEN2_SATA },
867 { "sata-r8a7793", RCAR_GEN2_SATA },
853 { }, 868 { },
854}; 869};
855MODULE_DEVICE_TABLE(platform, sata_rcar_id_table); 870MODULE_DEVICE_TABLE(platform, sata_rcar_id_table);
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 7652e8dc188f..21b0bc6a9c96 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -1225,11 +1225,13 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
1225 card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE); 1225 card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE);
1226 if (!card->config_regs) { 1226 if (!card->config_regs) {
1227 dev_warn(&dev->dev, "Failed to ioremap config registers\n"); 1227 dev_warn(&dev->dev, "Failed to ioremap config registers\n");
1228 err = -ENOMEM;
1228 goto out_release_regions; 1229 goto out_release_regions;
1229 } 1230 }
1230 card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE); 1231 card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE);
1231 if (!card->buffers) { 1232 if (!card->buffers) {
1232 dev_warn(&dev->dev, "Failed to ioremap data buffers\n"); 1233 dev_warn(&dev->dev, "Failed to ioremap data buffers\n");
1234 err = -ENOMEM;
1233 goto out_unmap_config; 1235 goto out_unmap_config;
1234 } 1236 }
1235 1237
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 40bc2f4072cc..fb83d4acd400 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -361,9 +361,19 @@ static int __pm_genpd_save_device(struct pm_domain_data *pdd,
361 struct device *dev = pdd->dev; 361 struct device *dev = pdd->dev;
362 int ret = 0; 362 int ret = 0;
363 363
364 if (gpd_data->need_restore) 364 if (gpd_data->need_restore > 0)
365 return 0; 365 return 0;
366 366
367 /*
368 * If the value of the need_restore flag is still unknown at this point,
369 * we trust that pm_genpd_poweroff() has verified that the device is
370 * already runtime PM suspended.
371 */
372 if (gpd_data->need_restore < 0) {
373 gpd_data->need_restore = 1;
374 return 0;
375 }
376
367 mutex_unlock(&genpd->lock); 377 mutex_unlock(&genpd->lock);
368 378
369 genpd_start_dev(genpd, dev); 379 genpd_start_dev(genpd, dev);
@@ -373,7 +383,7 @@ static int __pm_genpd_save_device(struct pm_domain_data *pdd,
373 mutex_lock(&genpd->lock); 383 mutex_lock(&genpd->lock);
374 384
375 if (!ret) 385 if (!ret)
376 gpd_data->need_restore = true; 386 gpd_data->need_restore = 1;
377 387
378 return ret; 388 return ret;
379} 389}
@@ -389,12 +399,17 @@ static void __pm_genpd_restore_device(struct pm_domain_data *pdd,
389{ 399{
390 struct generic_pm_domain_data *gpd_data = to_gpd_data(pdd); 400 struct generic_pm_domain_data *gpd_data = to_gpd_data(pdd);
391 struct device *dev = pdd->dev; 401 struct device *dev = pdd->dev;
392 bool need_restore = gpd_data->need_restore; 402 int need_restore = gpd_data->need_restore;
393 403
394 gpd_data->need_restore = false; 404 gpd_data->need_restore = 0;
395 mutex_unlock(&genpd->lock); 405 mutex_unlock(&genpd->lock);
396 406
397 genpd_start_dev(genpd, dev); 407 genpd_start_dev(genpd, dev);
408
409 /*
410 * Call genpd_restore_dev() for recently added devices too (need_restore
411 * is negative then).
412 */
398 if (need_restore) 413 if (need_restore)
399 genpd_restore_dev(genpd, dev); 414 genpd_restore_dev(genpd, dev);
400 415
@@ -603,6 +618,7 @@ static void genpd_power_off_work_fn(struct work_struct *work)
603static int pm_genpd_runtime_suspend(struct device *dev) 618static int pm_genpd_runtime_suspend(struct device *dev)
604{ 619{
605 struct generic_pm_domain *genpd; 620 struct generic_pm_domain *genpd;
621 struct generic_pm_domain_data *gpd_data;
606 bool (*stop_ok)(struct device *__dev); 622 bool (*stop_ok)(struct device *__dev);
607 int ret; 623 int ret;
608 624
@@ -628,6 +644,16 @@ static int pm_genpd_runtime_suspend(struct device *dev)
628 return 0; 644 return 0;
629 645
630 mutex_lock(&genpd->lock); 646 mutex_lock(&genpd->lock);
647
648 /*
649 * If we have an unknown state of the need_restore flag, it means none
650 * of the runtime PM callbacks has been invoked yet. Let's update the
651 * flag to reflect that the current state is active.
652 */
653 gpd_data = to_gpd_data(dev->power.subsys_data->domain_data);
654 if (gpd_data->need_restore < 0)
655 gpd_data->need_restore = 0;
656
631 genpd->in_progress++; 657 genpd->in_progress++;
632 pm_genpd_poweroff(genpd); 658 pm_genpd_poweroff(genpd);
633 genpd->in_progress--; 659 genpd->in_progress--;
@@ -1437,12 +1463,12 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
1437 spin_unlock_irq(&dev->power.lock); 1463 spin_unlock_irq(&dev->power.lock);
1438 1464
1439 if (genpd->attach_dev) 1465 if (genpd->attach_dev)
1440 genpd->attach_dev(dev); 1466 genpd->attach_dev(genpd, dev);
1441 1467
1442 mutex_lock(&gpd_data->lock); 1468 mutex_lock(&gpd_data->lock);
1443 gpd_data->base.dev = dev; 1469 gpd_data->base.dev = dev;
1444 list_add_tail(&gpd_data->base.list_node, &genpd->dev_list); 1470 list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);
1445 gpd_data->need_restore = genpd->status == GPD_STATE_POWER_OFF; 1471 gpd_data->need_restore = -1;
1446 gpd_data->td.constraint_changed = true; 1472 gpd_data->td.constraint_changed = true;
1447 gpd_data->td.effective_constraint_ns = -1; 1473 gpd_data->td.effective_constraint_ns = -1;
1448 mutex_unlock(&gpd_data->lock); 1474 mutex_unlock(&gpd_data->lock);
@@ -1499,7 +1525,7 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
1499 genpd->max_off_time_changed = true; 1525 genpd->max_off_time_changed = true;
1500 1526
1501 if (genpd->detach_dev) 1527 if (genpd->detach_dev)
1502 genpd->detach_dev(dev); 1528 genpd->detach_dev(genpd, dev);
1503 1529
1504 spin_lock_irq(&dev->power.lock); 1530 spin_lock_irq(&dev->power.lock);
1505 1531
@@ -1546,7 +1572,7 @@ void pm_genpd_dev_need_restore(struct device *dev, bool val)
1546 1572
1547 psd = dev_to_psd(dev); 1573 psd = dev_to_psd(dev);
1548 if (psd && psd->domain_data) 1574 if (psd && psd->domain_data)
1549 to_gpd_data(psd->domain_data)->need_restore = val; 1575 to_gpd_data(psd->domain_data)->need_restore = val ? 1 : 0;
1550 1576
1551 spin_unlock_irqrestore(&dev->power.lock, flags); 1577 spin_unlock_irqrestore(&dev->power.lock, flags);
1552} 1578}
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 2ad0b5bce44b..3920ee45aa59 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -560,7 +560,8 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
560 } 560 }
561 561
562 if (page_zero_filled(uncmem)) { 562 if (page_zero_filled(uncmem)) {
563 kunmap_atomic(user_mem); 563 if (user_mem)
564 kunmap_atomic(user_mem);
564 /* Free memory associated with this sector now. */ 565 /* Free memory associated with this sector now. */
565 bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); 566 bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value);
566 zram_free_page(zram, index); 567 zram_free_page(zram, index);
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c
index 6226aa08c36a..bcf86f91800a 100644
--- a/drivers/char/hw_random/pseries-rng.c
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -25,18 +25,21 @@
25#include <asm/vio.h> 25#include <asm/vio.h>
26 26
27 27
28static int pseries_rng_data_read(struct hwrng *rng, u32 *data) 28static int pseries_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
29{ 29{
30 u64 buffer[PLPAR_HCALL_BUFSIZE];
31 size_t size = max < 8 ? max : 8;
30 int rc; 32 int rc;
31 33
32 rc = plpar_hcall(H_RANDOM, (unsigned long *)data); 34 rc = plpar_hcall(H_RANDOM, (unsigned long *)buffer);
33 if (rc != H_SUCCESS) { 35 if (rc != H_SUCCESS) {
34 pr_err_ratelimited("H_RANDOM call failed %d\n", rc); 36 pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
35 return -EIO; 37 return -EIO;
36 } 38 }
39 memcpy(data, buffer, size);
37 40
38 /* The hypervisor interface returns 64 bits */ 41 /* The hypervisor interface returns 64 bits */
39 return 8; 42 return size;
40} 43}
41 44
42/** 45/**
@@ -55,7 +58,7 @@ static unsigned long pseries_rng_get_desired_dma(struct vio_dev *vdev)
55 58
56static struct hwrng pseries_rng = { 59static struct hwrng pseries_rng = {
57 .name = KBUILD_MODNAME, 60 .name = KBUILD_MODNAME,
58 .data_read = pseries_rng_data_read, 61 .read = pseries_rng_read,
59}; 62};
60 63
61static int __init pseries_rng_probe(struct vio_dev *dev, 64static int __init pseries_rng_probe(struct vio_dev *dev,
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index bfa640023e64..cf7a561fad7c 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1449,8 +1449,6 @@ static int add_port(struct ports_device *portdev, u32 id)
1449 spin_lock_init(&port->outvq_lock); 1449 spin_lock_init(&port->outvq_lock);
1450 init_waitqueue_head(&port->waitqueue); 1450 init_waitqueue_head(&port->waitqueue);
1451 1451
1452 virtio_device_ready(portdev->vdev);
1453
1454 /* Fill the in_vq with buffers so the host can send us data. */ 1452 /* Fill the in_vq with buffers so the host can send us data. */
1455 nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock); 1453 nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
1456 if (!nr_added_bufs) { 1454 if (!nr_added_bufs) {
@@ -2026,6 +2024,8 @@ static int virtcons_probe(struct virtio_device *vdev)
2026 spin_lock_init(&portdev->ports_lock); 2024 spin_lock_init(&portdev->ports_lock);
2027 INIT_LIST_HEAD(&portdev->ports); 2025 INIT_LIST_HEAD(&portdev->ports);
2028 2026
2027 virtio_device_ready(portdev->vdev);
2028
2029 if (multiport) { 2029 if (multiport) {
2030 unsigned int nr_added_bufs; 2030 unsigned int nr_added_bufs;
2031 2031
diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c
index 24b5b020753a..a23ac0c724f0 100644
--- a/drivers/clk/at91/clk-usb.c
+++ b/drivers/clk/at91/clk-usb.c
@@ -52,29 +52,26 @@ static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw,
52 52
53 tmp = pmc_read(pmc, AT91_PMC_USB); 53 tmp = pmc_read(pmc, AT91_PMC_USB);
54 usbdiv = (tmp & AT91_PMC_OHCIUSBDIV) >> SAM9X5_USB_DIV_SHIFT; 54 usbdiv = (tmp & AT91_PMC_OHCIUSBDIV) >> SAM9X5_USB_DIV_SHIFT;
55 return parent_rate / (usbdiv + 1); 55
56 return DIV_ROUND_CLOSEST(parent_rate, (usbdiv + 1));
56} 57}
57 58
58static long at91sam9x5_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate, 59static long at91sam9x5_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate,
59 unsigned long *parent_rate) 60 unsigned long *parent_rate)
60{ 61{
61 unsigned long div; 62 unsigned long div;
62 unsigned long bestrate; 63
63 unsigned long tmp; 64 if (!rate)
65 return -EINVAL;
64 66
65 if (rate >= *parent_rate) 67 if (rate >= *parent_rate)
66 return *parent_rate; 68 return *parent_rate;
67 69
68 div = *parent_rate / rate; 70 div = DIV_ROUND_CLOSEST(*parent_rate, rate);
69 if (div >= SAM9X5_USB_MAX_DIV) 71 if (div > SAM9X5_USB_MAX_DIV + 1)
70 return *parent_rate / (SAM9X5_USB_MAX_DIV + 1); 72 div = SAM9X5_USB_MAX_DIV + 1;
71
72 bestrate = *parent_rate / div;
73 tmp = *parent_rate / (div + 1);
74 if (bestrate - rate > rate - tmp)
75 bestrate = tmp;
76 73
77 return bestrate; 74 return DIV_ROUND_CLOSEST(*parent_rate, div);
78} 75}
79 76
80static int at91sam9x5_clk_usb_set_parent(struct clk_hw *hw, u8 index) 77static int at91sam9x5_clk_usb_set_parent(struct clk_hw *hw, u8 index)
@@ -106,9 +103,13 @@ static int at91sam9x5_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate,
106 u32 tmp; 103 u32 tmp;
107 struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); 104 struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw);
108 struct at91_pmc *pmc = usb->pmc; 105 struct at91_pmc *pmc = usb->pmc;
109 unsigned long div = parent_rate / rate; 106 unsigned long div;
107
108 if (!rate)
109 return -EINVAL;
110 110
111 if (parent_rate % rate || div < 1 || div >= SAM9X5_USB_MAX_DIV) 111 div = DIV_ROUND_CLOSEST(parent_rate, rate);
112 if (div > SAM9X5_USB_MAX_DIV + 1 || !div)
112 return -EINVAL; 113 return -EINVAL;
113 114
114 tmp = pmc_read(pmc, AT91_PMC_USB) & ~AT91_PMC_OHCIUSBDIV; 115 tmp = pmc_read(pmc, AT91_PMC_USB) & ~AT91_PMC_OHCIUSBDIV;
@@ -253,7 +254,7 @@ static long at91rm9200_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate,
253 254
254 tmp_parent_rate = rate * usb->divisors[i]; 255 tmp_parent_rate = rate * usb->divisors[i];
255 tmp_parent_rate = __clk_round_rate(parent, tmp_parent_rate); 256 tmp_parent_rate = __clk_round_rate(parent, tmp_parent_rate);
256 tmprate = tmp_parent_rate / usb->divisors[i]; 257 tmprate = DIV_ROUND_CLOSEST(tmp_parent_rate, usb->divisors[i]);
257 if (tmprate < rate) 258 if (tmprate < rate)
258 tmpdiff = rate - tmprate; 259 tmpdiff = rate - tmprate;
259 else 260 else
@@ -281,10 +282,10 @@ static int at91rm9200_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate,
281 struct at91_pmc *pmc = usb->pmc; 282 struct at91_pmc *pmc = usb->pmc;
282 unsigned long div; 283 unsigned long div;
283 284
284 if (!rate || parent_rate % rate) 285 if (!rate)
285 return -EINVAL; 286 return -EINVAL;
286 287
287 div = parent_rate / rate; 288 div = DIV_ROUND_CLOSEST(parent_rate, rate);
288 289
289 for (i = 0; i < RM9200_USB_DIV_TAB_SIZE; i++) { 290 for (i = 0; i < RM9200_USB_DIV_TAB_SIZE; i++) {
290 if (usb->divisors[i] == div) { 291 if (usb->divisors[i] == div) {
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 18a9de29df0e..c0a842b335c5 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -263,6 +263,14 @@ static int clk_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
263 if (!rate) 263 if (!rate)
264 rate = 1; 264 rate = 1;
265 265
266 /* if read only, just return current value */
267 if (divider->flags & CLK_DIVIDER_READ_ONLY) {
268 bestdiv = readl(divider->reg) >> divider->shift;
269 bestdiv &= div_mask(divider);
270 bestdiv = _get_div(divider, bestdiv);
271 return bestdiv;
272 }
273
266 maxdiv = _get_maxdiv(divider); 274 maxdiv = _get_maxdiv(divider);
267 275
268 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) { 276 if (!(__clk_get_flags(hw->clk) & CLK_SET_RATE_PARENT)) {
@@ -361,11 +369,6 @@ const struct clk_ops clk_divider_ops = {
361}; 369};
362EXPORT_SYMBOL_GPL(clk_divider_ops); 370EXPORT_SYMBOL_GPL(clk_divider_ops);
363 371
364const struct clk_ops clk_divider_ro_ops = {
365 .recalc_rate = clk_divider_recalc_rate,
366};
367EXPORT_SYMBOL_GPL(clk_divider_ro_ops);
368
369static struct clk *_register_divider(struct device *dev, const char *name, 372static struct clk *_register_divider(struct device *dev, const char *name,
370 const char *parent_name, unsigned long flags, 373 const char *parent_name, unsigned long flags,
371 void __iomem *reg, u8 shift, u8 width, 374 void __iomem *reg, u8 shift, u8 width,
@@ -391,10 +394,7 @@ static struct clk *_register_divider(struct device *dev, const char *name,
391 } 394 }
392 395
393 init.name = name; 396 init.name = name;
394 if (clk_divider_flags & CLK_DIVIDER_READ_ONLY) 397 init.ops = &clk_divider_ops;
395 init.ops = &clk_divider_ro_ops;
396 else
397 init.ops = &clk_divider_ops;
398 init.flags = flags | CLK_IS_BASIC; 398 init.flags = flags | CLK_IS_BASIC;
399 init.parent_names = (parent_name ? &parent_name: NULL); 399 init.parent_names = (parent_name ? &parent_name: NULL);
400 init.num_parents = (parent_name ? 1 : 0); 400 init.num_parents = (parent_name ? 1 : 0);
diff --git a/drivers/clk/pxa/clk-pxa27x.c b/drivers/clk/pxa/clk-pxa27x.c
index b345cc791e5d..88b9fe13fa44 100644
--- a/drivers/clk/pxa/clk-pxa27x.c
+++ b/drivers/clk/pxa/clk-pxa27x.c
@@ -322,7 +322,7 @@ static unsigned long clk_pxa27x_memory_get_rate(struct clk_hw *hw,
322 unsigned long ccsr = CCSR; 322 unsigned long ccsr = CCSR;
323 323
324 osc_forced = ccsr & (1 << CCCR_CPDIS_BIT); 324 osc_forced = ccsr & (1 << CCCR_CPDIS_BIT);
325 a = cccr & CCCR_A_BIT; 325 a = cccr & (1 << CCCR_A_BIT);
326 l = ccsr & CCSR_L_MASK; 326 l = ccsr & CCSR_L_MASK;
327 327
328 if (osc_forced || a) 328 if (osc_forced || a)
@@ -341,7 +341,7 @@ static u8 clk_pxa27x_memory_get_parent(struct clk_hw *hw)
341 unsigned long ccsr = CCSR; 341 unsigned long ccsr = CCSR;
342 342
343 osc_forced = ccsr & (1 << CCCR_CPDIS_BIT); 343 osc_forced = ccsr & (1 << CCCR_CPDIS_BIT);
344 a = cccr & CCCR_A_BIT; 344 a = cccr & (1 << CCCR_A_BIT);
345 if (osc_forced) 345 if (osc_forced)
346 return PXA_MEM_13Mhz; 346 return PXA_MEM_13Mhz;
347 if (a) 347 if (a)
diff --git a/drivers/clk/qcom/mmcc-apq8084.c b/drivers/clk/qcom/mmcc-apq8084.c
index dab988ab8cf1..157139a5c1ca 100644
--- a/drivers/clk/qcom/mmcc-apq8084.c
+++ b/drivers/clk/qcom/mmcc-apq8084.c
@@ -3122,7 +3122,7 @@ static struct clk_regmap *mmcc_apq8084_clocks[] = {
3122 [ESC1_CLK_SRC] = &esc1_clk_src.clkr, 3122 [ESC1_CLK_SRC] = &esc1_clk_src.clkr,
3123 [HDMI_CLK_SRC] = &hdmi_clk_src.clkr, 3123 [HDMI_CLK_SRC] = &hdmi_clk_src.clkr,
3124 [VSYNC_CLK_SRC] = &vsync_clk_src.clkr, 3124 [VSYNC_CLK_SRC] = &vsync_clk_src.clkr,
3125 [RBCPR_CLK_SRC] = &rbcpr_clk_src.clkr, 3125 [MMSS_RBCPR_CLK_SRC] = &rbcpr_clk_src.clkr,
3126 [RBBMTIMER_CLK_SRC] = &rbbmtimer_clk_src.clkr, 3126 [RBBMTIMER_CLK_SRC] = &rbbmtimer_clk_src.clkr,
3127 [MAPLE_CLK_SRC] = &maple_clk_src.clkr, 3127 [MAPLE_CLK_SRC] = &maple_clk_src.clkr,
3128 [VDP_CLK_SRC] = &vdp_clk_src.clkr, 3128 [VDP_CLK_SRC] = &vdp_clk_src.clkr,
diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c
index 1e68bff481b8..880a266f0143 100644
--- a/drivers/clk/rockchip/clk.c
+++ b/drivers/clk/rockchip/clk.c
@@ -90,9 +90,7 @@ static struct clk *rockchip_clk_register_branch(const char *name,
90 div->width = div_width; 90 div->width = div_width;
91 div->lock = lock; 91 div->lock = lock;
92 div->table = div_table; 92 div->table = div_table;
93 div_ops = (div_flags & CLK_DIVIDER_READ_ONLY) 93 div_ops = &clk_divider_ops;
94 ? &clk_divider_ro_ops
95 : &clk_divider_ops;
96 } 94 }
97 95
98 clk = clk_register_composite(NULL, name, parent_names, num_parents, 96 clk = clk_register_composite(NULL, name, parent_names, num_parents,
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c
index efb17c3ee120..f4a9c0058b4d 100644
--- a/drivers/clocksource/sun4i_timer.c
+++ b/drivers/clocksource/sun4i_timer.c
@@ -182,6 +182,12 @@ static void __init sun4i_timer_init(struct device_node *node)
182 /* Make sure timer is stopped before playing with interrupts */ 182 /* Make sure timer is stopped before playing with interrupts */
183 sun4i_clkevt_time_stop(0); 183 sun4i_clkevt_time_stop(0);
184 184
185 sun4i_clockevent.cpumask = cpu_possible_mask;
186 sun4i_clockevent.irq = irq;
187
188 clockevents_config_and_register(&sun4i_clockevent, rate,
189 TIMER_SYNC_TICKS, 0xffffffff);
190
185 ret = setup_irq(irq, &sun4i_timer_irq); 191 ret = setup_irq(irq, &sun4i_timer_irq);
186 if (ret) 192 if (ret)
187 pr_warn("failed to setup irq %d\n", irq); 193 pr_warn("failed to setup irq %d\n", irq);
@@ -189,12 +195,6 @@ static void __init sun4i_timer_init(struct device_node *node)
189 /* Enable timer0 interrupt */ 195 /* Enable timer0 interrupt */
190 val = readl(timer_base + TIMER_IRQ_EN_REG); 196 val = readl(timer_base + TIMER_IRQ_EN_REG);
191 writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG); 197 writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG);
192
193 sun4i_clockevent.cpumask = cpu_possible_mask;
194 sun4i_clockevent.irq = irq;
195
196 clockevents_config_and_register(&sun4i_clockevent, rate,
197 TIMER_SYNC_TICKS, 0xffffffff);
198} 198}
199CLOCKSOURCE_OF_DECLARE(sun4i, "allwinner,sun4i-a10-timer", 199CLOCKSOURCE_OF_DECLARE(sun4i, "allwinner,sun4i-a10-timer",
200 sun4i_timer_init); 200 sun4i_timer_init);
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 23aaf40cf37f..f657c571b18e 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -166,8 +166,8 @@ try_again:
166 if (ret == -EPROBE_DEFER) 166 if (ret == -EPROBE_DEFER)
167 dev_dbg(cpu_dev, "cpu%d clock not ready, retry\n", cpu); 167 dev_dbg(cpu_dev, "cpu%d clock not ready, retry\n", cpu);
168 else 168 else
169 dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", ret, 169 dev_err(cpu_dev, "failed to get cpu%d clock: %d\n", cpu,
170 cpu); 170 ret);
171 } else { 171 } else {
172 *cdev = cpu_dev; 172 *cdev = cpu_dev;
173 *creg = cpu_reg; 173 *creg = cpu_reg;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 644b54e1e7d1..4473eba1d6b0 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1022,7 +1022,8 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
1022 1022
1023 read_unlock_irqrestore(&cpufreq_driver_lock, flags); 1023 read_unlock_irqrestore(&cpufreq_driver_lock, flags);
1024 1024
1025 policy->governor = NULL; 1025 if (policy)
1026 policy->governor = NULL;
1026 1027
1027 return policy; 1028 return policy;
1028} 1029}
diff --git a/drivers/crypto/caam/key_gen.c b/drivers/crypto/caam/key_gen.c
index 871703c49d2c..e1eaf4ff9762 100644
--- a/drivers/crypto/caam/key_gen.c
+++ b/drivers/crypto/caam/key_gen.c
@@ -48,23 +48,29 @@ int gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len,
48 u32 *desc; 48 u32 *desc;
49 struct split_key_result result; 49 struct split_key_result result;
50 dma_addr_t dma_addr_in, dma_addr_out; 50 dma_addr_t dma_addr_in, dma_addr_out;
51 int ret = 0; 51 int ret = -ENOMEM;
52 52
53 desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); 53 desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA);
54 if (!desc) { 54 if (!desc) {
55 dev_err(jrdev, "unable to allocate key input memory\n"); 55 dev_err(jrdev, "unable to allocate key input memory\n");
56 return -ENOMEM; 56 return ret;
57 } 57 }
58 58
59 init_job_desc(desc, 0);
60
61 dma_addr_in = dma_map_single(jrdev, (void *)key_in, keylen, 59 dma_addr_in = dma_map_single(jrdev, (void *)key_in, keylen,
62 DMA_TO_DEVICE); 60 DMA_TO_DEVICE);
63 if (dma_mapping_error(jrdev, dma_addr_in)) { 61 if (dma_mapping_error(jrdev, dma_addr_in)) {
64 dev_err(jrdev, "unable to map key input memory\n"); 62 dev_err(jrdev, "unable to map key input memory\n");
65 kfree(desc); 63 goto out_free;
66 return -ENOMEM;
67 } 64 }
65
66 dma_addr_out = dma_map_single(jrdev, key_out, split_key_pad_len,
67 DMA_FROM_DEVICE);
68 if (dma_mapping_error(jrdev, dma_addr_out)) {
69 dev_err(jrdev, "unable to map key output memory\n");
70 goto out_unmap_in;
71 }
72
73 init_job_desc(desc, 0);
68 append_key(desc, dma_addr_in, keylen, CLASS_2 | KEY_DEST_CLASS_REG); 74 append_key(desc, dma_addr_in, keylen, CLASS_2 | KEY_DEST_CLASS_REG);
69 75
70 /* Sets MDHA up into an HMAC-INIT */ 76 /* Sets MDHA up into an HMAC-INIT */
@@ -81,13 +87,6 @@ int gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len,
81 * FIFO_STORE with the explicit split-key content store 87 * FIFO_STORE with the explicit split-key content store
82 * (0x26 output type) 88 * (0x26 output type)
83 */ 89 */
84 dma_addr_out = dma_map_single(jrdev, key_out, split_key_pad_len,
85 DMA_FROM_DEVICE);
86 if (dma_mapping_error(jrdev, dma_addr_out)) {
87 dev_err(jrdev, "unable to map key output memory\n");
88 kfree(desc);
89 return -ENOMEM;
90 }
91 append_fifo_store(desc, dma_addr_out, split_key_len, 90 append_fifo_store(desc, dma_addr_out, split_key_len,
92 LDST_CLASS_2_CCB | FIFOST_TYPE_SPLIT_KEK); 91 LDST_CLASS_2_CCB | FIFOST_TYPE_SPLIT_KEK);
93 92
@@ -115,10 +114,10 @@ int gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len,
115 114
116 dma_unmap_single(jrdev, dma_addr_out, split_key_pad_len, 115 dma_unmap_single(jrdev, dma_addr_out, split_key_pad_len,
117 DMA_FROM_DEVICE); 116 DMA_FROM_DEVICE);
117out_unmap_in:
118 dma_unmap_single(jrdev, dma_addr_in, keylen, DMA_TO_DEVICE); 118 dma_unmap_single(jrdev, dma_addr_in, keylen, DMA_TO_DEVICE);
119 119out_free:
120 kfree(desc); 120 kfree(desc);
121
122 return ret; 121 return ret;
123} 122}
124EXPORT_SYMBOL(gen_split_key); 123EXPORT_SYMBOL(gen_split_key);
diff --git a/drivers/crypto/qat/qat_common/adf_accel_devices.h b/drivers/crypto/qat/qat_common/adf_accel_devices.h
index 9282381b03ce..fe7b3f06f6e6 100644
--- a/drivers/crypto/qat/qat_common/adf_accel_devices.h
+++ b/drivers/crypto/qat/qat_common/adf_accel_devices.h
@@ -198,8 +198,7 @@ struct adf_accel_dev {
198 struct dentry *debugfs_dir; 198 struct dentry *debugfs_dir;
199 struct list_head list; 199 struct list_head list;
200 struct module *owner; 200 struct module *owner;
201 uint8_t accel_id;
202 uint8_t numa_node;
203 struct adf_accel_pci accel_pci_dev; 201 struct adf_accel_pci accel_pci_dev;
202 uint8_t accel_id;
204} __packed; 203} __packed;
205#endif 204#endif
diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c
index 5f3fa45348b4..9dd2cb72a4e8 100644
--- a/drivers/crypto/qat/qat_common/adf_transport.c
+++ b/drivers/crypto/qat/qat_common/adf_transport.c
@@ -419,9 +419,10 @@ static int adf_init_bank(struct adf_accel_dev *accel_dev,
419 WRITE_CSR_RING_BASE(csr_addr, bank_num, i, 0); 419 WRITE_CSR_RING_BASE(csr_addr, bank_num, i, 0);
420 ring = &bank->rings[i]; 420 ring = &bank->rings[i];
421 if (hw_data->tx_rings_mask & (1 << i)) { 421 if (hw_data->tx_rings_mask & (1 << i)) {
422 ring->inflights = kzalloc_node(sizeof(atomic_t), 422 ring->inflights =
423 GFP_KERNEL, 423 kzalloc_node(sizeof(atomic_t),
424 accel_dev->numa_node); 424 GFP_KERNEL,
425 dev_to_node(&GET_DEV(accel_dev)));
425 if (!ring->inflights) 426 if (!ring->inflights)
426 goto err; 427 goto err;
427 } else { 428 } else {
@@ -469,13 +470,14 @@ int adf_init_etr_data(struct adf_accel_dev *accel_dev)
469 int i, ret; 470 int i, ret;
470 471
471 etr_data = kzalloc_node(sizeof(*etr_data), GFP_KERNEL, 472 etr_data = kzalloc_node(sizeof(*etr_data), GFP_KERNEL,
472 accel_dev->numa_node); 473 dev_to_node(&GET_DEV(accel_dev)));
473 if (!etr_data) 474 if (!etr_data)
474 return -ENOMEM; 475 return -ENOMEM;
475 476
476 num_banks = GET_MAX_BANKS(accel_dev); 477 num_banks = GET_MAX_BANKS(accel_dev);
477 size = num_banks * sizeof(struct adf_etr_bank_data); 478 size = num_banks * sizeof(struct adf_etr_bank_data);
478 etr_data->banks = kzalloc_node(size, GFP_KERNEL, accel_dev->numa_node); 479 etr_data->banks = kzalloc_node(size, GFP_KERNEL,
480 dev_to_node(&GET_DEV(accel_dev)));
479 if (!etr_data->banks) { 481 if (!etr_data->banks) {
480 ret = -ENOMEM; 482 ret = -ENOMEM;
481 goto err_bank; 483 goto err_bank;
diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
index f2e2f158cfbe..9e9619cd4a79 100644
--- a/drivers/crypto/qat/qat_common/qat_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_algs.c
@@ -596,7 +596,8 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
596 if (unlikely(!n)) 596 if (unlikely(!n))
597 return -EINVAL; 597 return -EINVAL;
598 598
599 bufl = kmalloc_node(sz, GFP_ATOMIC, inst->accel_dev->numa_node); 599 bufl = kmalloc_node(sz, GFP_ATOMIC,
600 dev_to_node(&GET_DEV(inst->accel_dev)));
600 if (unlikely(!bufl)) 601 if (unlikely(!bufl))
601 return -ENOMEM; 602 return -ENOMEM;
602 603
@@ -605,6 +606,8 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
605 goto err; 606 goto err;
606 607
607 for_each_sg(assoc, sg, assoc_n, i) { 608 for_each_sg(assoc, sg, assoc_n, i) {
609 if (!sg->length)
610 continue;
608 bufl->bufers[bufs].addr = dma_map_single(dev, 611 bufl->bufers[bufs].addr = dma_map_single(dev,
609 sg_virt(sg), 612 sg_virt(sg),
610 sg->length, 613 sg->length,
@@ -640,7 +643,7 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst,
640 struct qat_alg_buf *bufers; 643 struct qat_alg_buf *bufers;
641 644
642 buflout = kmalloc_node(sz, GFP_ATOMIC, 645 buflout = kmalloc_node(sz, GFP_ATOMIC,
643 inst->accel_dev->numa_node); 646 dev_to_node(&GET_DEV(inst->accel_dev)));
644 if (unlikely(!buflout)) 647 if (unlikely(!buflout))
645 goto err; 648 goto err;
646 bloutp = dma_map_single(dev, buflout, sz, DMA_TO_DEVICE); 649 bloutp = dma_map_single(dev, buflout, sz, DMA_TO_DEVICE);
diff --git a/drivers/crypto/qat/qat_common/qat_crypto.c b/drivers/crypto/qat/qat_common/qat_crypto.c
index 0d59bcb50de1..828f2a686aab 100644
--- a/drivers/crypto/qat/qat_common/qat_crypto.c
+++ b/drivers/crypto/qat/qat_common/qat_crypto.c
@@ -109,12 +109,14 @@ struct qat_crypto_instance *qat_crypto_get_instance_node(int node)
109 109
110 list_for_each(itr, adf_devmgr_get_head()) { 110 list_for_each(itr, adf_devmgr_get_head()) {
111 accel_dev = list_entry(itr, struct adf_accel_dev, list); 111 accel_dev = list_entry(itr, struct adf_accel_dev, list);
112 if (accel_dev->numa_node == node && adf_dev_started(accel_dev)) 112 if ((node == dev_to_node(&GET_DEV(accel_dev)) ||
113 dev_to_node(&GET_DEV(accel_dev)) < 0)
114 && adf_dev_started(accel_dev))
113 break; 115 break;
114 accel_dev = NULL; 116 accel_dev = NULL;
115 } 117 }
116 if (!accel_dev) { 118 if (!accel_dev) {
117 pr_err("QAT: Could not find device on give node\n"); 119 pr_err("QAT: Could not find device on node %d\n", node);
118 accel_dev = adf_devmgr_get_first(); 120 accel_dev = adf_devmgr_get_first();
119 } 121 }
120 if (!accel_dev || !adf_dev_started(accel_dev)) 122 if (!accel_dev || !adf_dev_started(accel_dev))
@@ -164,7 +166,7 @@ static int qat_crypto_create_instances(struct adf_accel_dev *accel_dev)
164 166
165 for (i = 0; i < num_inst; i++) { 167 for (i = 0; i < num_inst; i++) {
166 inst = kzalloc_node(sizeof(*inst), GFP_KERNEL, 168 inst = kzalloc_node(sizeof(*inst), GFP_KERNEL,
167 accel_dev->numa_node); 169 dev_to_node(&GET_DEV(accel_dev)));
168 if (!inst) 170 if (!inst)
169 goto err; 171 goto err;
170 172
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_admin.c b/drivers/crypto/qat/qat_dh895xcc/adf_admin.c
index 978d6c56639d..53c491b59f07 100644
--- a/drivers/crypto/qat/qat_dh895xcc/adf_admin.c
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_admin.c
@@ -108,7 +108,7 @@ int adf_init_admin_comms(struct adf_accel_dev *accel_dev)
108 uint64_t reg_val; 108 uint64_t reg_val;
109 109
110 admin = kzalloc_node(sizeof(*accel_dev->admin), GFP_KERNEL, 110 admin = kzalloc_node(sizeof(*accel_dev->admin), GFP_KERNEL,
111 accel_dev->numa_node); 111 dev_to_node(&GET_DEV(accel_dev)));
112 if (!admin) 112 if (!admin)
113 return -ENOMEM; 113 return -ENOMEM;
114 admin->virt_addr = dma_zalloc_coherent(&GET_DEV(accel_dev), PAGE_SIZE, 114 admin->virt_addr = dma_zalloc_coherent(&GET_DEV(accel_dev), PAGE_SIZE,
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
index 0d0435a41be9..948f66be262b 100644
--- a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c
@@ -119,21 +119,6 @@ static void adf_cleanup_accel(struct adf_accel_dev *accel_dev)
119 kfree(accel_dev); 119 kfree(accel_dev);
120} 120}
121 121
122static uint8_t adf_get_dev_node_id(struct pci_dev *pdev)
123{
124 unsigned int bus_per_cpu = 0;
125 struct cpuinfo_x86 *c = &cpu_data(num_online_cpus() - 1);
126
127 if (!c->phys_proc_id)
128 return 0;
129
130 bus_per_cpu = 256 / (c->phys_proc_id + 1);
131
132 if (bus_per_cpu != 0)
133 return pdev->bus->number / bus_per_cpu;
134 return 0;
135}
136
137static int qat_dev_start(struct adf_accel_dev *accel_dev) 122static int qat_dev_start(struct adf_accel_dev *accel_dev)
138{ 123{
139 int cpus = num_online_cpus(); 124 int cpus = num_online_cpus();
@@ -235,7 +220,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
235 void __iomem *pmisc_bar_addr = NULL; 220 void __iomem *pmisc_bar_addr = NULL;
236 char name[ADF_DEVICE_NAME_LENGTH]; 221 char name[ADF_DEVICE_NAME_LENGTH];
237 unsigned int i, bar_nr; 222 unsigned int i, bar_nr;
238 uint8_t node;
239 int ret; 223 int ret;
240 224
241 switch (ent->device) { 225 switch (ent->device) {
@@ -246,12 +230,19 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
246 return -ENODEV; 230 return -ENODEV;
247 } 231 }
248 232
249 node = adf_get_dev_node_id(pdev); 233 if (num_possible_nodes() > 1 && dev_to_node(&pdev->dev) < 0) {
250 accel_dev = kzalloc_node(sizeof(*accel_dev), GFP_KERNEL, node); 234 /* If the accelerator is connected to a node with no memory
235 * there is no point in using the accelerator since the remote
236 * memory transaction will be very slow. */
237 dev_err(&pdev->dev, "Invalid NUMA configuration.\n");
238 return -EINVAL;
239 }
240
241 accel_dev = kzalloc_node(sizeof(*accel_dev), GFP_KERNEL,
242 dev_to_node(&pdev->dev));
251 if (!accel_dev) 243 if (!accel_dev)
252 return -ENOMEM; 244 return -ENOMEM;
253 245
254 accel_dev->numa_node = node;
255 INIT_LIST_HEAD(&accel_dev->crypto_list); 246 INIT_LIST_HEAD(&accel_dev->crypto_list);
256 247
257 /* Add accel device to accel table. 248 /* Add accel device to accel table.
@@ -264,7 +255,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
264 255
265 accel_dev->owner = THIS_MODULE; 256 accel_dev->owner = THIS_MODULE;
266 /* Allocate and configure device configuration structure */ 257 /* Allocate and configure device configuration structure */
267 hw_data = kzalloc_node(sizeof(*hw_data), GFP_KERNEL, node); 258 hw_data = kzalloc_node(sizeof(*hw_data), GFP_KERNEL,
259 dev_to_node(&pdev->dev));
268 if (!hw_data) { 260 if (!hw_data) {
269 ret = -ENOMEM; 261 ret = -ENOMEM;
270 goto out_err; 262 goto out_err;
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_isr.c b/drivers/crypto/qat/qat_dh895xcc/adf_isr.c
index 67ec61e51185..d96ee21b9b77 100644
--- a/drivers/crypto/qat/qat_dh895xcc/adf_isr.c
+++ b/drivers/crypto/qat/qat_dh895xcc/adf_isr.c
@@ -168,7 +168,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev)
168 uint32_t msix_num_entries = hw_data->num_banks + 1; 168 uint32_t msix_num_entries = hw_data->num_banks + 1;
169 169
170 entries = kzalloc_node(msix_num_entries * sizeof(*entries), 170 entries = kzalloc_node(msix_num_entries * sizeof(*entries),
171 GFP_KERNEL, accel_dev->numa_node); 171 GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev)));
172 if (!entries) 172 if (!entries)
173 return -ENOMEM; 173 return -ENOMEM;
174 174
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 4839bfa74a10..19a99743cf52 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -271,7 +271,7 @@ struct pl330_config {
271#define DMAC_MODE_NS (1 << 0) 271#define DMAC_MODE_NS (1 << 0)
272 unsigned int mode; 272 unsigned int mode;
273 unsigned int data_bus_width:10; /* In number of bits */ 273 unsigned int data_bus_width:10; /* In number of bits */
274 unsigned int data_buf_dep:10; 274 unsigned int data_buf_dep:11;
275 unsigned int num_chan:4; 275 unsigned int num_chan:4;
276 unsigned int num_peri:6; 276 unsigned int num_peri:6;
277 u32 peri_ns; 277 u32 peri_ns;
@@ -2336,7 +2336,7 @@ static inline int get_burst_len(struct dma_pl330_desc *desc, size_t len)
2336 int burst_len; 2336 int burst_len;
2337 2337
2338 burst_len = pl330->pcfg.data_bus_width / 8; 2338 burst_len = pl330->pcfg.data_bus_width / 8;
2339 burst_len *= pl330->pcfg.data_buf_dep; 2339 burst_len *= pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan;
2340 burst_len >>= desc->rqcfg.brst_size; 2340 burst_len >>= desc->rqcfg.brst_size;
2341 2341
2342 /* src/dst_burst_len can't be more than 16 */ 2342 /* src/dst_burst_len can't be more than 16 */
@@ -2459,16 +2459,25 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
2459 /* Select max possible burst size */ 2459 /* Select max possible burst size */
2460 burst = pl330->pcfg.data_bus_width / 8; 2460 burst = pl330->pcfg.data_bus_width / 8;
2461 2461
2462 while (burst > 1) { 2462 /*
2463 if (!(len % burst)) 2463 * Make sure we use a burst size that aligns with all the memcpy
2464 break; 2464 * parameters because our DMA programming algorithm doesn't cope with
2465 * transfers which straddle an entry in the DMA device's MFIFO.
2466 */
2467 while ((src | dst | len) & (burst - 1))
2465 burst /= 2; 2468 burst /= 2;
2466 }
2467 2469
2468 desc->rqcfg.brst_size = 0; 2470 desc->rqcfg.brst_size = 0;
2469 while (burst != (1 << desc->rqcfg.brst_size)) 2471 while (burst != (1 << desc->rqcfg.brst_size))
2470 desc->rqcfg.brst_size++; 2472 desc->rqcfg.brst_size++;
2471 2473
2474 /*
2475 * If burst size is smaller than bus width then make sure we only
2476 * transfer one at a time to avoid a burst stradling an MFIFO entry.
2477 */
2478 if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width)
2479 desc->rqcfg.brst_len = 1;
2480
2472 desc->rqcfg.brst_len = get_burst_len(desc, len); 2481 desc->rqcfg.brst_len = get_burst_len(desc, len);
2473 2482
2474 desc->txd.flags = flags; 2483 desc->txd.flags = flags;
@@ -2732,7 +2741,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
2732 2741
2733 2742
2734 dev_info(&adev->dev, 2743 dev_info(&adev->dev,
2735 "Loaded driver for PL330 DMAC-%d\n", adev->periphid); 2744 "Loaded driver for PL330 DMAC-%x\n", adev->periphid);
2736 dev_info(&adev->dev, 2745 dev_info(&adev->dev,
2737 "\tDBUFF-%ux%ubytes Num_Chans-%u Num_Peri-%u Num_Events-%u\n", 2746 "\tDBUFF-%ux%ubytes Num_Chans-%u Num_Peri-%u Num_Events-%u\n",
2738 pcfg->data_buf_dep, pcfg->data_bus_width / 8, pcfg->num_chan, 2747 pcfg->data_buf_dep, pcfg->data_bus_width / 8, pcfg->num_chan,
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index 3aa10b328254..91292f5513ff 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -230,30 +230,25 @@ static inline void sun6i_dma_dump_chan_regs(struct sun6i_dma_dev *sdev,
230 readl(pchan->base + DMA_CHAN_CUR_PARA)); 230 readl(pchan->base + DMA_CHAN_CUR_PARA));
231} 231}
232 232
233static inline int convert_burst(u32 maxburst, u8 *burst) 233static inline s8 convert_burst(u32 maxburst)
234{ 234{
235 switch (maxburst) { 235 switch (maxburst) {
236 case 1: 236 case 1:
237 *burst = 0; 237 return 0;
238 break;
239 case 8: 238 case 8:
240 *burst = 2; 239 return 2;
241 break;
242 default: 240 default:
243 return -EINVAL; 241 return -EINVAL;
244 } 242 }
245
246 return 0;
247} 243}
248 244
249static inline int convert_buswidth(enum dma_slave_buswidth addr_width, u8 *width) 245static inline s8 convert_buswidth(enum dma_slave_buswidth addr_width)
250{ 246{
251 if ((addr_width < DMA_SLAVE_BUSWIDTH_1_BYTE) || 247 if ((addr_width < DMA_SLAVE_BUSWIDTH_1_BYTE) ||
252 (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES)) 248 (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES))
253 return -EINVAL; 249 return -EINVAL;
254 250
255 *width = addr_width >> 1; 251 return addr_width >> 1;
256 return 0;
257} 252}
258 253
259static void *sun6i_dma_lli_add(struct sun6i_dma_lli *prev, 254static void *sun6i_dma_lli_add(struct sun6i_dma_lli *prev,
@@ -284,26 +279,25 @@ static inline int sun6i_dma_cfg_lli(struct sun6i_dma_lli *lli,
284 struct dma_slave_config *config) 279 struct dma_slave_config *config)
285{ 280{
286 u8 src_width, dst_width, src_burst, dst_burst; 281 u8 src_width, dst_width, src_burst, dst_burst;
287 int ret;
288 282
289 if (!config) 283 if (!config)
290 return -EINVAL; 284 return -EINVAL;
291 285
292 ret = convert_burst(config->src_maxburst, &src_burst); 286 src_burst = convert_burst(config->src_maxburst);
293 if (ret) 287 if (src_burst)
294 return ret; 288 return src_burst;
295 289
296 ret = convert_burst(config->dst_maxburst, &dst_burst); 290 dst_burst = convert_burst(config->dst_maxburst);
297 if (ret) 291 if (dst_burst)
298 return ret; 292 return dst_burst;
299 293
300 ret = convert_buswidth(config->src_addr_width, &src_width); 294 src_width = convert_buswidth(config->src_addr_width);
301 if (ret) 295 if (src_width)
302 return ret; 296 return src_width;
303 297
304 ret = convert_buswidth(config->dst_addr_width, &dst_width); 298 dst_width = convert_buswidth(config->dst_addr_width);
305 if (ret) 299 if (dst_width)
306 return ret; 300 return dst_width;
307 301
308 lli->cfg = DMA_CHAN_CFG_SRC_BURST(src_burst) | 302 lli->cfg = DMA_CHAN_CFG_SRC_BURST(src_burst) |
309 DMA_CHAN_CFG_SRC_WIDTH(src_width) | 303 DMA_CHAN_CFG_SRC_WIDTH(src_width) |
@@ -542,11 +536,10 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
542{ 536{
543 struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device); 537 struct sun6i_dma_dev *sdev = to_sun6i_dma_dev(chan->device);
544 struct sun6i_vchan *vchan = to_sun6i_vchan(chan); 538 struct sun6i_vchan *vchan = to_sun6i_vchan(chan);
545 struct dma_slave_config *sconfig = &vchan->cfg;
546 struct sun6i_dma_lli *v_lli; 539 struct sun6i_dma_lli *v_lli;
547 struct sun6i_desc *txd; 540 struct sun6i_desc *txd;
548 dma_addr_t p_lli; 541 dma_addr_t p_lli;
549 int ret; 542 s8 burst, width;
550 543
551 dev_dbg(chan2dev(chan), 544 dev_dbg(chan2dev(chan),
552 "%s; chan: %d, dest: %pad, src: %pad, len: %zu. flags: 0x%08lx\n", 545 "%s; chan: %d, dest: %pad, src: %pad, len: %zu. flags: 0x%08lx\n",
@@ -565,14 +558,21 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
565 goto err_txd_free; 558 goto err_txd_free;
566 } 559 }
567 560
568 ret = sun6i_dma_cfg_lli(v_lli, src, dest, len, sconfig); 561 v_lli->src = src;
569 if (ret) 562 v_lli->dst = dest;
570 goto err_dma_free; 563 v_lli->len = len;
564 v_lli->para = NORMAL_WAIT;
571 565
566 burst = convert_burst(8);
567 width = convert_buswidth(DMA_SLAVE_BUSWIDTH_4_BYTES);
572 v_lli->cfg |= DMA_CHAN_CFG_SRC_DRQ(DRQ_SDRAM) | 568 v_lli->cfg |= DMA_CHAN_CFG_SRC_DRQ(DRQ_SDRAM) |
573 DMA_CHAN_CFG_DST_DRQ(DRQ_SDRAM) | 569 DMA_CHAN_CFG_DST_DRQ(DRQ_SDRAM) |
574 DMA_CHAN_CFG_DST_LINEAR_MODE | 570 DMA_CHAN_CFG_DST_LINEAR_MODE |
575 DMA_CHAN_CFG_SRC_LINEAR_MODE; 571 DMA_CHAN_CFG_SRC_LINEAR_MODE |
572 DMA_CHAN_CFG_SRC_BURST(burst) |
573 DMA_CHAN_CFG_SRC_WIDTH(width) |
574 DMA_CHAN_CFG_DST_BURST(burst) |
575 DMA_CHAN_CFG_DST_WIDTH(width);
576 576
577 sun6i_dma_lli_add(NULL, v_lli, p_lli, txd); 577 sun6i_dma_lli_add(NULL, v_lli, p_lli, txd);
578 578
@@ -580,8 +580,6 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
580 580
581 return vchan_tx_prep(&vchan->vc, &txd->vd, flags); 581 return vchan_tx_prep(&vchan->vc, &txd->vd, flags);
582 582
583err_dma_free:
584 dma_pool_free(sdev->pool, v_lli, p_lli);
585err_txd_free: 583err_txd_free:
586 kfree(txd); 584 kfree(txd);
587 return NULL; 585 return NULL;
@@ -915,6 +913,7 @@ static int sun6i_dma_probe(struct platform_device *pdev)
915 sdc->slave.device_prep_dma_memcpy = sun6i_dma_prep_dma_memcpy; 913 sdc->slave.device_prep_dma_memcpy = sun6i_dma_prep_dma_memcpy;
916 sdc->slave.device_control = sun6i_dma_control; 914 sdc->slave.device_control = sun6i_dma_control;
917 sdc->slave.chancnt = NR_MAX_VCHANS; 915 sdc->slave.chancnt = NR_MAX_VCHANS;
916 sdc->slave.copy_align = 4;
918 917
919 sdc->slave.dev = &pdev->dev; 918 sdc->slave.dev = &pdev->dev;
920 919
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
index 5d997a33907e..2a3973a7c441 100644
--- a/drivers/firewire/core-cdev.c
+++ b/drivers/firewire/core-cdev.c
@@ -1637,8 +1637,7 @@ static int dispatch_ioctl(struct client *client,
1637 _IOC_SIZE(cmd) > sizeof(buffer)) 1637 _IOC_SIZE(cmd) > sizeof(buffer))
1638 return -ENOTTY; 1638 return -ENOTTY;
1639 1639
1640 if (_IOC_DIR(cmd) == _IOC_READ) 1640 memset(&buffer, 0, sizeof(buffer));
1641 memset(&buffer, 0, _IOC_SIZE(cmd));
1642 1641
1643 if (_IOC_DIR(cmd) & _IOC_WRITE) 1642 if (_IOC_DIR(cmd) & _IOC_WRITE)
1644 if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd))) 1643 if (copy_from_user(&buffer, arg, _IOC_SIZE(cmd)))
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d71fb54582d2..25ba3628960a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -646,6 +646,18 @@ static int exynos_drm_init(void)
646 if (!is_exynos) 646 if (!is_exynos)
647 return -ENODEV; 647 return -ENODEV;
648 648
649 /*
650 * Register device object only in case of Exynos SoC.
651 *
652 * Below codes resolves temporarily infinite loop issue incurred
653 * by Exynos drm driver when using multi-platform kernel.
654 * So these codes will be replaced with more generic way later.
655 */
656 if (!of_machine_is_compatible("samsung,exynos3") &&
657 !of_machine_is_compatible("samsung,exynos4") &&
658 !of_machine_is_compatible("samsung,exynos5"))
659 return -ENODEV;
660
649 exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1, 661 exynos_drm_pdev = platform_device_register_simple("exynos-drm", -1,
650 NULL, 0); 662 NULL, 0);
651 if (IS_ERR(exynos_drm_pdev)) 663 if (IS_ERR(exynos_drm_pdev))
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 9a7353302b3f..7a966f3c9950 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1663,15 +1663,17 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1663 goto out_regs; 1663 goto out_regs;
1664 1664
1665 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1665 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1666 ret = i915_kick_out_vgacon(dev_priv); 1666 /* WARNING: Apparently we must kick fbdev drivers before vgacon,
1667 * otherwise the vga fbdev driver falls over. */
1668 ret = i915_kick_out_firmware_fb(dev_priv);
1667 if (ret) { 1669 if (ret) {
1668 DRM_ERROR("failed to remove conflicting VGA console\n"); 1670 DRM_ERROR("failed to remove conflicting framebuffer drivers\n");
1669 goto out_gtt; 1671 goto out_gtt;
1670 } 1672 }
1671 1673
1672 ret = i915_kick_out_firmware_fb(dev_priv); 1674 ret = i915_kick_out_vgacon(dev_priv);
1673 if (ret) { 1675 if (ret) {
1674 DRM_ERROR("failed to remove conflicting framebuffer drivers\n"); 1676 DRM_ERROR("failed to remove conflicting VGA console\n");
1675 goto out_gtt; 1677 goto out_gtt;
1676 } 1678 }
1677 } 1679 }
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index de12017c809b..c1cf3329108c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -1920,6 +1920,22 @@ static void bdw_setup_private_ppat(struct drm_i915_private *dev_priv)
1920 GEN8_PPAT(6, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2)) | 1920 GEN8_PPAT(6, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(2)) |
1921 GEN8_PPAT(7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(3)); 1921 GEN8_PPAT(7, GEN8_PPAT_WB | GEN8_PPAT_LLCELLC | GEN8_PPAT_AGE(3));
1922 1922
1923 if (!USES_PPGTT(dev_priv->dev))
1924 /* Spec: "For GGTT, there is NO pat_sel[2:0] from the entry,
1925 * so RTL will always use the value corresponding to
1926 * pat_sel = 000".
1927 * So let's disable cache for GGTT to avoid screen corruptions.
1928 * MOCS still can be used though.
1929 * - System agent ggtt writes (i.e. cpu gtt mmaps) already work
1930 * before this patch, i.e. the same uncached + snooping access
1931 * like on gen6/7 seems to be in effect.
1932 * - So this just fixes blitter/render access. Again it looks
1933 * like it's not just uncached access, but uncached + snooping.
1934 * So we can still hold onto all our assumptions wrt cpu
1935 * clflushing on LLC machines.
1936 */
1937 pat = GEN8_PPAT(0, GEN8_PPAT_UC);
1938
1923 /* XXX: spec defines this as 2 distinct registers. It's unclear if a 64b 1939 /* XXX: spec defines this as 2 distinct registers. It's unclear if a 64b
1924 * write would work. */ 1940 * write would work. */
1925 I915_WRITE(GEN8_PRIVATE_PAT, pat); 1941 I915_WRITE(GEN8_PRIVATE_PAT, pat);
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 749ab485569e..cd7f4734c9f8 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -375,22 +375,9 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
375 * has to also include the unfenced register the GPU uses 375 * has to also include the unfenced register the GPU uses
376 * whilst executing a fenced command for an untiled object. 376 * whilst executing a fenced command for an untiled object.
377 */ 377 */
378 378 if (obj->map_and_fenceable &&
379 obj->map_and_fenceable = 379 !i915_gem_object_fence_ok(obj, args->tiling_mode))
380 !i915_gem_obj_ggtt_bound(obj) || 380 ret = i915_gem_object_ggtt_unbind(obj);
381 (i915_gem_obj_ggtt_offset(obj) +
382 obj->base.size <= dev_priv->gtt.mappable_end &&
383 i915_gem_object_fence_ok(obj, args->tiling_mode));
384
385 /* Rebind if we need a change of alignment */
386 if (!obj->map_and_fenceable) {
387 u32 unfenced_align =
388 i915_gem_get_gtt_alignment(dev, obj->base.size,
389 args->tiling_mode,
390 false);
391 if (i915_gem_obj_ggtt_offset(obj) & (unfenced_align - 1))
392 ret = i915_gem_object_ggtt_unbind(obj);
393 }
394 381
395 if (ret == 0) { 382 if (ret == 0) {
396 obj->fence_dirty = 383 obj->fence_dirty =
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 947144985700..e9a0df8a437b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9066,6 +9066,10 @@ static bool page_flip_finished(struct intel_crtc *crtc)
9066 struct drm_device *dev = crtc->base.dev; 9066 struct drm_device *dev = crtc->base.dev;
9067 struct drm_i915_private *dev_priv = dev->dev_private; 9067 struct drm_i915_private *dev_priv = dev->dev_private;
9068 9068
9069 if (i915_reset_in_progress(&dev_priv->gpu_error) ||
9070 crtc->reset_counter != atomic_read(&dev_priv->gpu_error.reset_counter))
9071 return true;
9072
9069 /* 9073 /*
9070 * The relevant registers doen't exist on pre-ctg. 9074 * The relevant registers doen't exist on pre-ctg.
9071 * As the flip done interrupt doesn't trigger for mmio 9075 * As the flip done interrupt doesn't trigger for mmio
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index ceb528f07c25..49288437e52a 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4686,6 +4686,7 @@ static void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder)
4686 * vdd might still be enabled do to the delayed vdd off. 4686 * vdd might still be enabled do to the delayed vdd off.
4687 * Make sure vdd is actually turned off here. 4687 * Make sure vdd is actually turned off here.
4688 */ 4688 */
4689 cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
4689 pps_lock(intel_dp); 4690 pps_lock(intel_dp);
4690 edp_panel_vdd_off_sync(intel_dp); 4691 edp_panel_vdd_off_sync(intel_dp);
4691 pps_unlock(intel_dp); 4692 pps_unlock(intel_dp);
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index e18b3f49074c..b001c90312e7 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1094,12 +1094,25 @@ static u32 get_backlight_min_vbt(struct intel_connector *connector)
1094 struct drm_device *dev = connector->base.dev; 1094 struct drm_device *dev = connector->base.dev;
1095 struct drm_i915_private *dev_priv = dev->dev_private; 1095 struct drm_i915_private *dev_priv = dev->dev_private;
1096 struct intel_panel *panel = &connector->panel; 1096 struct intel_panel *panel = &connector->panel;
1097 int min;
1097 1098
1098 WARN_ON(panel->backlight.max == 0); 1099 WARN_ON(panel->backlight.max == 0);
1099 1100
1101 /*
1102 * XXX: If the vbt value is 255, it makes min equal to max, which leads
1103 * to problems. There are such machines out there. Either our
1104 * interpretation is wrong or the vbt has bogus data. Or both. Safeguard
1105 * against this by letting the minimum be at most (arbitrarily chosen)
1106 * 25% of the max.
1107 */
1108 min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, 64);
1109 if (min != dev_priv->vbt.backlight.min_brightness) {
1110 DRM_DEBUG_KMS("clamping VBT min backlight %d/255 to %d/255\n",
1111 dev_priv->vbt.backlight.min_brightness, min);
1112 }
1113
1100 /* vbt value is a coefficient in range [0..255] */ 1114 /* vbt value is a coefficient in range [0..255] */
1101 return scale(dev_priv->vbt.backlight.min_brightness, 0, 255, 1115 return scale(min, 0, 255, 0, panel->backlight.max);
1102 0, panel->backlight.max);
1103} 1116}
1104 1117
1105static int bdw_setup_backlight(struct intel_connector *connector) 1118static int bdw_setup_backlight(struct intel_connector *connector)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 300d7e503f96..8a0788dcf106 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -6533,11 +6533,6 @@ static void gen6_init_clock_gating(struct drm_device *dev)
6533 I915_WRITE(_3D_CHICKEN, 6533 I915_WRITE(_3D_CHICKEN,
6534 _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB)); 6534 _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB));
6535 6535
6536 /* WaSetupGtModeTdRowDispatch:snb */
6537 if (IS_SNB_GT1(dev))
6538 I915_WRITE(GEN6_GT_MODE,
6539 _MASKED_BIT_ENABLE(GEN6_TD_FOUR_ROW_DISPATCH_DISABLE));
6540
6541 /* WaDisable_RenderCache_OperationalFlush:snb */ 6536 /* WaDisable_RenderCache_OperationalFlush:snb */
6542 I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE)); 6537 I915_WRITE(CACHE_MODE_0, _MASKED_BIT_DISABLE(RC_OP_FLUSH_ENABLE));
6543 6538
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/gk20a.c b/drivers/gpu/drm/nouveau/core/subdev/fb/gk20a.c
index a16024a74771..fde42e4d1b56 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/gk20a.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/gk20a.c
@@ -27,6 +27,20 @@ struct gk20a_fb_priv {
27}; 27};
28 28
29static int 29static int
30gk20a_fb_init(struct nouveau_object *object)
31{
32 struct gk20a_fb_priv *priv = (void *)object;
33 int ret;
34
35 ret = nouveau_fb_init(&priv->base);
36 if (ret)
37 return ret;
38
39 nv_mask(priv, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */
40 return 0;
41}
42
43static int
30gk20a_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 44gk20a_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
31 struct nouveau_oclass *oclass, void *data, u32 size, 45 struct nouveau_oclass *oclass, void *data, u32 size,
32 struct nouveau_object **pobject) 46 struct nouveau_object **pobject)
@@ -48,7 +62,7 @@ gk20a_fb_oclass = &(struct nouveau_fb_impl) {
48 .base.ofuncs = &(struct nouveau_ofuncs) { 62 .base.ofuncs = &(struct nouveau_ofuncs) {
49 .ctor = gk20a_fb_ctor, 63 .ctor = gk20a_fb_ctor,
50 .dtor = _nouveau_fb_dtor, 64 .dtor = _nouveau_fb_dtor,
51 .init = _nouveau_fb_init, 65 .init = gk20a_fb_init,
52 .fini = _nouveau_fb_fini, 66 .fini = _nouveau_fb_fini,
53 }, 67 },
54 .memtype = nvc0_fb_memtype_valid, 68 .memtype = nvc0_fb_memtype_valid,
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 76b8c4f980ea..5beae7596f62 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -792,6 +792,22 @@ nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, bool update)
792} 792}
793 793
794static int 794static int
795nv50_crtc_set_raster_vblank_dmi(struct nouveau_crtc *nv_crtc, u32 usec)
796{
797 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
798 u32 *push;
799
800 push = evo_wait(mast, 8);
801 if (!push)
802 return -ENOMEM;
803
804 evo_mthd(push, 0x0828 + (nv_crtc->index * 0x400), 1);
805 evo_data(push, usec);
806 evo_kick(push, mast);
807 return 0;
808}
809
810static int
795nv50_crtc_set_color_vibrance(struct nouveau_crtc *nv_crtc, bool update) 811nv50_crtc_set_color_vibrance(struct nouveau_crtc *nv_crtc, bool update)
796{ 812{
797 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 813 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
@@ -1105,14 +1121,14 @@ nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
1105 evo_mthd(push, 0x0804 + (nv_crtc->index * 0x400), 2); 1121 evo_mthd(push, 0x0804 + (nv_crtc->index * 0x400), 2);
1106 evo_data(push, 0x00800000 | mode->clock); 1122 evo_data(push, 0x00800000 | mode->clock);
1107 evo_data(push, (ilace == 2) ? 2 : 0); 1123 evo_data(push, (ilace == 2) ? 2 : 0);
1108 evo_mthd(push, 0x0810 + (nv_crtc->index * 0x400), 8); 1124 evo_mthd(push, 0x0810 + (nv_crtc->index * 0x400), 6);
1109 evo_data(push, 0x00000000); 1125 evo_data(push, 0x00000000);
1110 evo_data(push, (vactive << 16) | hactive); 1126 evo_data(push, (vactive << 16) | hactive);
1111 evo_data(push, ( vsynce << 16) | hsynce); 1127 evo_data(push, ( vsynce << 16) | hsynce);
1112 evo_data(push, (vblanke << 16) | hblanke); 1128 evo_data(push, (vblanke << 16) | hblanke);
1113 evo_data(push, (vblanks << 16) | hblanks); 1129 evo_data(push, (vblanks << 16) | hblanks);
1114 evo_data(push, (vblan2e << 16) | vblan2s); 1130 evo_data(push, (vblan2e << 16) | vblan2s);
1115 evo_data(push, vblankus); 1131 evo_mthd(push, 0x082c + (nv_crtc->index * 0x400), 1);
1116 evo_data(push, 0x00000000); 1132 evo_data(push, 0x00000000);
1117 evo_mthd(push, 0x0900 + (nv_crtc->index * 0x400), 2); 1133 evo_mthd(push, 0x0900 + (nv_crtc->index * 0x400), 2);
1118 evo_data(push, 0x00000311); 1134 evo_data(push, 0x00000311);
@@ -1142,6 +1158,11 @@ nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
1142 nv_connector = nouveau_crtc_connector_get(nv_crtc); 1158 nv_connector = nouveau_crtc_connector_get(nv_crtc);
1143 nv50_crtc_set_dither(nv_crtc, false); 1159 nv50_crtc_set_dither(nv_crtc, false);
1144 nv50_crtc_set_scale(nv_crtc, false); 1160 nv50_crtc_set_scale(nv_crtc, false);
1161
1162 /* G94 only accepts this after setting scale */
1163 if (nv50_vers(mast) < GF110_DISP_CORE_CHANNEL_DMA)
1164 nv50_crtc_set_raster_vblank_dmi(nv_crtc, vblankus);
1165
1145 nv50_crtc_set_color_vibrance(nv_crtc, false); 1166 nv50_crtc_set_color_vibrance(nv_crtc, false);
1146 nv50_crtc_set_image(nv_crtc, crtc->primary->fb, x, y, false); 1167 nv50_crtc_set_image(nv_crtc, crtc->primary->fb, x, y, false);
1147 return 0; 1168 return 0;
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
index 15da7ef344a4..ec1593a6a561 100644
--- a/drivers/gpu/drm/radeon/atom.c
+++ b/drivers/gpu/drm/radeon/atom.c
@@ -1217,7 +1217,7 @@ free:
1217 return ret; 1217 return ret;
1218} 1218}
1219 1219
1220int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params) 1220int atom_execute_table_scratch_unlocked(struct atom_context *ctx, int index, uint32_t * params)
1221{ 1221{
1222 int r; 1222 int r;
1223 1223
@@ -1238,6 +1238,15 @@ int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
1238 return r; 1238 return r;
1239} 1239}
1240 1240
1241int atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
1242{
1243 int r;
1244 mutex_lock(&ctx->scratch_mutex);
1245 r = atom_execute_table_scratch_unlocked(ctx, index, params);
1246 mutex_unlock(&ctx->scratch_mutex);
1247 return r;
1248}
1249
1241static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 }; 1250static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 };
1242 1251
1243static void atom_index_iio(struct atom_context *ctx, int base) 1252static void atom_index_iio(struct atom_context *ctx, int base)
diff --git a/drivers/gpu/drm/radeon/atom.h b/drivers/gpu/drm/radeon/atom.h
index feba6b8d36b3..6d014ddb6b78 100644
--- a/drivers/gpu/drm/radeon/atom.h
+++ b/drivers/gpu/drm/radeon/atom.h
@@ -125,6 +125,7 @@ struct card_info {
125struct atom_context { 125struct atom_context {
126 struct card_info *card; 126 struct card_info *card;
127 struct mutex mutex; 127 struct mutex mutex;
128 struct mutex scratch_mutex;
128 void *bios; 129 void *bios;
129 uint32_t cmd_table, data_table; 130 uint32_t cmd_table, data_table;
130 uint16_t *iio; 131 uint16_t *iio;
@@ -145,6 +146,7 @@ extern int atom_debug;
145 146
146struct atom_context *atom_parse(struct card_info *, void *); 147struct atom_context *atom_parse(struct card_info *, void *);
147int atom_execute_table(struct atom_context *, int, uint32_t *); 148int atom_execute_table(struct atom_context *, int, uint32_t *);
149int atom_execute_table_scratch_unlocked(struct atom_context *, int, uint32_t *);
148int atom_asic_init(struct atom_context *); 150int atom_asic_init(struct atom_context *);
149void atom_destroy(struct atom_context *); 151void atom_destroy(struct atom_context *);
150bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size, 152bool atom_parse_data_header(struct atom_context *ctx, int index, uint16_t *size,
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 95d5d4ab3335..11ba9d21b89b 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -100,6 +100,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
100 memset(&args, 0, sizeof(args)); 100 memset(&args, 0, sizeof(args));
101 101
102 mutex_lock(&chan->mutex); 102 mutex_lock(&chan->mutex);
103 mutex_lock(&rdev->mode_info.atom_context->scratch_mutex);
103 104
104 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1); 105 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
105 106
@@ -113,7 +114,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
113 if (ASIC_IS_DCE4(rdev)) 114 if (ASIC_IS_DCE4(rdev))
114 args.v2.ucHPD_ID = chan->rec.hpd; 115 args.v2.ucHPD_ID = chan->rec.hpd;
115 116
116 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 117 atom_execute_table_scratch_unlocked(rdev->mode_info.atom_context, index, (uint32_t *)&args);
117 118
118 *ack = args.v1.ucReplyStatus; 119 *ack = args.v1.ucReplyStatus;
119 120
@@ -147,6 +148,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
147 148
148 r = recv_bytes; 149 r = recv_bytes;
149done: 150done:
151 mutex_unlock(&rdev->mode_info.atom_context->scratch_mutex);
150 mutex_unlock(&chan->mutex); 152 mutex_unlock(&chan->mutex);
151 153
152 return r; 154 return r;
diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c
index 9c570fb15b8c..4157780585a0 100644
--- a/drivers/gpu/drm/radeon/atombios_i2c.c
+++ b/drivers/gpu/drm/radeon/atombios_i2c.c
@@ -48,6 +48,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
48 memset(&args, 0, sizeof(args)); 48 memset(&args, 0, sizeof(args));
49 49
50 mutex_lock(&chan->mutex); 50 mutex_lock(&chan->mutex);
51 mutex_lock(&rdev->mode_info.atom_context->scratch_mutex);
51 52
52 base = (unsigned char *)rdev->mode_info.atom_context->scratch; 53 base = (unsigned char *)rdev->mode_info.atom_context->scratch;
53 54
@@ -82,7 +83,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
82 args.ucSlaveAddr = slave_addr << 1; 83 args.ucSlaveAddr = slave_addr << 1;
83 args.ucLineNumber = chan->rec.i2c_id; 84 args.ucLineNumber = chan->rec.i2c_id;
84 85
85 atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); 86 atom_execute_table_scratch_unlocked(rdev->mode_info.atom_context, index, (uint32_t *)&args);
86 87
87 /* error */ 88 /* error */
88 if (args.ucStatus != HW_ASSISTED_I2C_STATUS_SUCCESS) { 89 if (args.ucStatus != HW_ASSISTED_I2C_STATUS_SUCCESS) {
@@ -95,6 +96,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
95 radeon_atom_copy_swap(buf, base, num, false); 96 radeon_atom_copy_swap(buf, base, num, false);
96 97
97done: 98done:
99 mutex_unlock(&rdev->mode_info.atom_context->scratch_mutex);
98 mutex_unlock(&chan->mutex); 100 mutex_unlock(&chan->mutex);
99 101
100 return r; 102 return r;
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 3deeed33322f..6dcde3798b45 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -4333,8 +4333,8 @@ static int cik_cp_gfx_start(struct radeon_device *rdev)
4333 /* init the CE partitions. CE only used for gfx on CIK */ 4333 /* init the CE partitions. CE only used for gfx on CIK */
4334 radeon_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2)); 4334 radeon_ring_write(ring, PACKET3(PACKET3_SET_BASE, 2));
4335 radeon_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE)); 4335 radeon_ring_write(ring, PACKET3_BASE_INDEX(CE_PARTITION_BASE));
4336 radeon_ring_write(ring, 0xc000); 4336 radeon_ring_write(ring, 0x8000);
4337 radeon_ring_write(ring, 0xc000); 4337 radeon_ring_write(ring, 0x8000);
4338 4338
4339 /* setup clear context state */ 4339 /* setup clear context state */
4340 radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0)); 4340 radeon_ring_write(ring, PACKET3(PACKET3_PREAMBLE_CNTL, 0));
@@ -9417,6 +9417,9 @@ void dce8_bandwidth_update(struct radeon_device *rdev)
9417 u32 num_heads = 0, lb_size; 9417 u32 num_heads = 0, lb_size;
9418 int i; 9418 int i;
9419 9419
9420 if (!rdev->mode_info.mode_config_initialized)
9421 return;
9422
9420 radeon_update_display_priority(rdev); 9423 radeon_update_display_priority(rdev);
9421 9424
9422 for (i = 0; i < rdev->num_crtc; i++) { 9425 for (i = 0; i < rdev->num_crtc; i++) {
diff --git a/drivers/gpu/drm/radeon/cik_sdma.c b/drivers/gpu/drm/radeon/cik_sdma.c
index 54b98379188d..dde5c7e29eb2 100644
--- a/drivers/gpu/drm/radeon/cik_sdma.c
+++ b/drivers/gpu/drm/radeon/cik_sdma.c
@@ -663,17 +663,20 @@ int cik_sdma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
663{ 663{
664 struct radeon_ib ib; 664 struct radeon_ib ib;
665 unsigned i; 665 unsigned i;
666 unsigned index;
666 int r; 667 int r;
667 void __iomem *ptr = (void *)rdev->vram_scratch.ptr;
668 u32 tmp = 0; 668 u32 tmp = 0;
669 u64 gpu_addr;
669 670
670 if (!ptr) { 671 if (ring->idx == R600_RING_TYPE_DMA_INDEX)
671 DRM_ERROR("invalid vram scratch pointer\n"); 672 index = R600_WB_DMA_RING_TEST_OFFSET;
672 return -EINVAL; 673 else
673 } 674 index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
675
676 gpu_addr = rdev->wb.gpu_addr + index;
674 677
675 tmp = 0xCAFEDEAD; 678 tmp = 0xCAFEDEAD;
676 writel(tmp, ptr); 679 rdev->wb.wb[index/4] = cpu_to_le32(tmp);
677 680
678 r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256); 681 r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256);
679 if (r) { 682 if (r) {
@@ -682,8 +685,8 @@ int cik_sdma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
682 } 685 }
683 686
684 ib.ptr[0] = SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0); 687 ib.ptr[0] = SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0);
685 ib.ptr[1] = rdev->vram_scratch.gpu_addr & 0xfffffffc; 688 ib.ptr[1] = lower_32_bits(gpu_addr);
686 ib.ptr[2] = upper_32_bits(rdev->vram_scratch.gpu_addr); 689 ib.ptr[2] = upper_32_bits(gpu_addr);
687 ib.ptr[3] = 1; 690 ib.ptr[3] = 1;
688 ib.ptr[4] = 0xDEADBEEF; 691 ib.ptr[4] = 0xDEADBEEF;
689 ib.length_dw = 5; 692 ib.length_dw = 5;
@@ -700,7 +703,7 @@ int cik_sdma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
700 return r; 703 return r;
701 } 704 }
702 for (i = 0; i < rdev->usec_timeout; i++) { 705 for (i = 0; i < rdev->usec_timeout; i++) {
703 tmp = readl(ptr); 706 tmp = le32_to_cpu(rdev->wb.wb[index/4]);
704 if (tmp == 0xDEADBEEF) 707 if (tmp == 0xDEADBEEF)
705 break; 708 break;
706 DRM_UDELAY(1); 709 DRM_UDELAY(1);
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index f37d39d2bbbc..85995b4e3338 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2345,6 +2345,9 @@ void evergreen_bandwidth_update(struct radeon_device *rdev)
2345 u32 num_heads = 0, lb_size; 2345 u32 num_heads = 0, lb_size;
2346 int i; 2346 int i;
2347 2347
2348 if (!rdev->mode_info.mode_config_initialized)
2349 return;
2350
2348 radeon_update_display_priority(rdev); 2351 radeon_update_display_priority(rdev);
2349 2352
2350 for (i = 0; i < rdev->num_crtc; i++) { 2353 for (i = 0; i < rdev->num_crtc; i++) {
@@ -2552,6 +2555,7 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
2552 WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1); 2555 WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
2553 tmp |= EVERGREEN_CRTC_BLANK_DATA_EN; 2556 tmp |= EVERGREEN_CRTC_BLANK_DATA_EN;
2554 WREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i], tmp); 2557 WREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i], tmp);
2558 WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
2555 } 2559 }
2556 } else { 2560 } else {
2557 tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]); 2561 tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]);
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 10f8be0ee173..b53b31a7b76f 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3207,6 +3207,9 @@ void r100_bandwidth_update(struct radeon_device *rdev)
3207 uint32_t pixel_bytes1 = 0; 3207 uint32_t pixel_bytes1 = 0;
3208 uint32_t pixel_bytes2 = 0; 3208 uint32_t pixel_bytes2 = 0;
3209 3209
3210 if (!rdev->mode_info.mode_config_initialized)
3211 return;
3212
3210 radeon_update_display_priority(rdev); 3213 radeon_update_display_priority(rdev);
3211 3214
3212 if (rdev->mode_info.crtcs[0]->base.enabled) { 3215 if (rdev->mode_info.crtcs[0]->base.enabled) {
diff --git a/drivers/gpu/drm/radeon/r600_dma.c b/drivers/gpu/drm/radeon/r600_dma.c
index 3a58b8073f49..d2dd29ab24fa 100644
--- a/drivers/gpu/drm/radeon/r600_dma.c
+++ b/drivers/gpu/drm/radeon/r600_dma.c
@@ -338,17 +338,17 @@ int r600_dma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
338{ 338{
339 struct radeon_ib ib; 339 struct radeon_ib ib;
340 unsigned i; 340 unsigned i;
341 unsigned index;
341 int r; 342 int r;
342 void __iomem *ptr = (void *)rdev->vram_scratch.ptr;
343 u32 tmp = 0; 343 u32 tmp = 0;
344 u64 gpu_addr;
344 345
345 if (!ptr) { 346 if (ring->idx == R600_RING_TYPE_DMA_INDEX)
346 DRM_ERROR("invalid vram scratch pointer\n"); 347 index = R600_WB_DMA_RING_TEST_OFFSET;
347 return -EINVAL; 348 else
348 } 349 index = CAYMAN_WB_DMA1_RING_TEST_OFFSET;
349 350
350 tmp = 0xCAFEDEAD; 351 gpu_addr = rdev->wb.gpu_addr + index;
351 writel(tmp, ptr);
352 352
353 r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256); 353 r = radeon_ib_get(rdev, ring->idx, &ib, NULL, 256);
354 if (r) { 354 if (r) {
@@ -357,8 +357,8 @@ int r600_dma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
357 } 357 }
358 358
359 ib.ptr[0] = DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1); 359 ib.ptr[0] = DMA_PACKET(DMA_PACKET_WRITE, 0, 0, 1);
360 ib.ptr[1] = rdev->vram_scratch.gpu_addr & 0xfffffffc; 360 ib.ptr[1] = lower_32_bits(gpu_addr);
361 ib.ptr[2] = upper_32_bits(rdev->vram_scratch.gpu_addr) & 0xff; 361 ib.ptr[2] = upper_32_bits(gpu_addr) & 0xff;
362 ib.ptr[3] = 0xDEADBEEF; 362 ib.ptr[3] = 0xDEADBEEF;
363 ib.length_dw = 4; 363 ib.length_dw = 4;
364 364
@@ -374,7 +374,7 @@ int r600_dma_ib_test(struct radeon_device *rdev, struct radeon_ring *ring)
374 return r; 374 return r;
375 } 375 }
376 for (i = 0; i < rdev->usec_timeout; i++) { 376 for (i = 0; i < rdev->usec_timeout; i++) {
377 tmp = readl(ptr); 377 tmp = le32_to_cpu(rdev->wb.wb[index/4]);
378 if (tmp == 0xDEADBEEF) 378 if (tmp == 0xDEADBEEF)
379 break; 379 break;
380 DRM_UDELAY(1); 380 DRM_UDELAY(1);
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index 76c6a17eeb2d..843b65f46ece 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -1265,7 +1265,7 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
1265 (mode_info->atom_context->bios + data_offset + 1265 (mode_info->atom_context->bios + data_offset +
1266 le16_to_cpu(ext_hdr->usPowerTuneTableOffset)); 1266 le16_to_cpu(ext_hdr->usPowerTuneTableOffset));
1267 rdev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit = 1267 rdev->pm.dpm.dyn_state.cac_tdp_table->maximum_power_delivery_limit =
1268 ppt->usMaximumPowerDeliveryLimit; 1268 le16_to_cpu(ppt->usMaximumPowerDeliveryLimit);
1269 pt = &ppt->power_tune_table; 1269 pt = &ppt->power_tune_table;
1270 } else { 1270 } else {
1271 ATOM_PPLIB_POWERTUNE_Table *ppt = (ATOM_PPLIB_POWERTUNE_Table *) 1271 ATOM_PPLIB_POWERTUNE_Table *ppt = (ATOM_PPLIB_POWERTUNE_Table *)
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 300c4b3d4669..26baa9c05f6c 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -322,6 +322,12 @@ static void radeon_connector_get_edid(struct drm_connector *connector)
322 } 322 }
323 323
324 if (!radeon_connector->edid) { 324 if (!radeon_connector->edid) {
325 /* don't fetch the edid from the vbios if ddc fails and runpm is
326 * enabled so we report disconnected.
327 */
328 if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
329 return;
330
325 if (rdev->is_atom_bios) { 331 if (rdev->is_atom_bios) {
326 /* some laptops provide a hardcoded edid in rom for LCDs */ 332 /* some laptops provide a hardcoded edid in rom for LCDs */
327 if (((connector->connector_type == DRM_MODE_CONNECTOR_LVDS) || 333 if (((connector->connector_type == DRM_MODE_CONNECTOR_LVDS) ||
@@ -826,6 +832,8 @@ static int radeon_lvds_mode_valid(struct drm_connector *connector,
826static enum drm_connector_status 832static enum drm_connector_status
827radeon_lvds_detect(struct drm_connector *connector, bool force) 833radeon_lvds_detect(struct drm_connector *connector, bool force)
828{ 834{
835 struct drm_device *dev = connector->dev;
836 struct radeon_device *rdev = dev->dev_private;
829 struct radeon_connector *radeon_connector = to_radeon_connector(connector); 837 struct radeon_connector *radeon_connector = to_radeon_connector(connector);
830 struct drm_encoder *encoder = radeon_best_single_encoder(connector); 838 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
831 enum drm_connector_status ret = connector_status_disconnected; 839 enum drm_connector_status ret = connector_status_disconnected;
@@ -842,7 +850,11 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
842 /* check if panel is valid */ 850 /* check if panel is valid */
843 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 851 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
844 ret = connector_status_connected; 852 ret = connector_status_connected;
845 853 /* don't fetch the edid from the vbios if ddc fails and runpm is
854 * enabled so we report disconnected.
855 */
856 if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
857 ret = connector_status_disconnected;
846 } 858 }
847 859
848 /* check for edid as well */ 860 /* check for edid as well */
@@ -1589,6 +1601,11 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1589 /* check if panel is valid */ 1601 /* check if panel is valid */
1590 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240) 1602 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
1591 ret = connector_status_connected; 1603 ret = connector_status_connected;
1604 /* don't fetch the edid from the vbios if ddc fails and runpm is
1605 * enabled so we report disconnected.
1606 */
1607 if ((rdev->flags & RADEON_IS_PX) && (radeon_runtime_pm != 0))
1608 ret = connector_status_disconnected;
1592 } 1609 }
1593 /* eDP is always DP */ 1610 /* eDP is always DP */
1594 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT; 1611 radeon_dig_connector->dp_sink_type = CONNECTOR_OBJECT_ID_DISPLAYPORT;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index ae87310fd96e..0ec65168f331 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -983,6 +983,7 @@ int radeon_atombios_init(struct radeon_device *rdev)
983 } 983 }
984 984
985 mutex_init(&rdev->mode_info.atom_context->mutex); 985 mutex_init(&rdev->mode_info.atom_context->mutex);
986 mutex_init(&rdev->mode_info.atom_context->scratch_mutex);
986 radeon_atom_initialize_bios_scratch_regs(rdev->ddev); 987 radeon_atom_initialize_bios_scratch_regs(rdev->ddev);
987 atom_allocate_fb_scratch(rdev->mode_info.atom_context); 988 atom_allocate_fb_scratch(rdev->mode_info.atom_context);
988 return 0; 989 return 0;
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 9a19e52cc655..6b670b0bc47b 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -179,6 +179,9 @@ static void radeon_encoder_add_backlight(struct radeon_encoder *radeon_encoder,
179 (rdev->pdev->subsystem_vendor == 0x1734) && 179 (rdev->pdev->subsystem_vendor == 0x1734) &&
180 (rdev->pdev->subsystem_device == 0x1107)) 180 (rdev->pdev->subsystem_device == 0x1107))
181 use_bl = false; 181 use_bl = false;
182 /* disable native backlight control on older asics */
183 else if (rdev->family < CHIP_R600)
184 use_bl = false;
182 else 185 else
183 use_bl = true; 186 use_bl = true;
184 } 187 }
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 7784911d78ef..00fc59762e0d 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -185,6 +185,16 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
185 if (rdev->flags & RADEON_IS_AGP) 185 if (rdev->flags & RADEON_IS_AGP)
186 return false; 186 return false;
187 187
188 /*
189 * Older chips have a HW limitation, they can only generate 40 bits
190 * of address for "64-bit" MSIs which breaks on some platforms, notably
191 * IBM POWER servers, so we limit them
192 */
193 if (rdev->family < CHIP_BONAIRE) {
194 dev_info(rdev->dev, "radeon: MSI limited to 32-bit\n");
195 rdev->pdev->no_64bit_msi = 1;
196 }
197
188 /* force MSI on */ 198 /* force MSI on */
189 if (radeon_msi == 1) 199 if (radeon_msi == 1)
190 return true; 200 return true;
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index 5f6db4629aaa..9acb1c3c005b 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -879,6 +879,9 @@ void rs600_bandwidth_update(struct radeon_device *rdev)
879 u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt; 879 u32 d1mode_priority_a_cnt, d2mode_priority_a_cnt;
880 /* FIXME: implement full support */ 880 /* FIXME: implement full support */
881 881
882 if (!rdev->mode_info.mode_config_initialized)
883 return;
884
882 radeon_update_display_priority(rdev); 885 radeon_update_display_priority(rdev);
883 886
884 if (rdev->mode_info.crtcs[0]->base.enabled) 887 if (rdev->mode_info.crtcs[0]->base.enabled)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 3462b64369bf..0a2d36e81108 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -579,6 +579,9 @@ void rs690_bandwidth_update(struct radeon_device *rdev)
579 u32 d1mode_priority_a_cnt, d1mode_priority_b_cnt; 579 u32 d1mode_priority_a_cnt, d1mode_priority_b_cnt;
580 u32 d2mode_priority_a_cnt, d2mode_priority_b_cnt; 580 u32 d2mode_priority_a_cnt, d2mode_priority_b_cnt;
581 581
582 if (!rdev->mode_info.mode_config_initialized)
583 return;
584
582 radeon_update_display_priority(rdev); 585 radeon_update_display_priority(rdev);
583 586
584 if (rdev->mode_info.crtcs[0]->base.enabled) 587 if (rdev->mode_info.crtcs[0]->base.enabled)
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 8a477bf1fdb3..c55d653aaf5f 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -1277,6 +1277,9 @@ void rv515_bandwidth_update(struct radeon_device *rdev)
1277 struct drm_display_mode *mode0 = NULL; 1277 struct drm_display_mode *mode0 = NULL;
1278 struct drm_display_mode *mode1 = NULL; 1278 struct drm_display_mode *mode1 = NULL;
1279 1279
1280 if (!rdev->mode_info.mode_config_initialized)
1281 return;
1282
1280 radeon_update_display_priority(rdev); 1283 radeon_update_display_priority(rdev);
1281 1284
1282 if (rdev->mode_info.crtcs[0]->base.enabled) 1285 if (rdev->mode_info.crtcs[0]->base.enabled)
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 14896ce76324..60df444bd075 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -2384,6 +2384,9 @@ void dce6_bandwidth_update(struct radeon_device *rdev)
2384 u32 num_heads = 0, lb_size; 2384 u32 num_heads = 0, lb_size;
2385 int i; 2385 int i;
2386 2386
2387 if (!rdev->mode_info.mode_config_initialized)
2388 return;
2389
2387 radeon_update_display_priority(rdev); 2390 radeon_update_display_priority(rdev);
2388 2391
2389 for (i = 0; i < rdev->num_crtc; i++) { 2392 for (i = 0; i < rdev->num_crtc; i++) {
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b957908aec73..3367960286a6 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -906,7 +906,7 @@ static void tegra_crtc_disable(struct drm_crtc *crtc)
906 } 906 }
907 } 907 }
908 908
909 drm_vblank_off(drm, dc->pipe); 909 drm_crtc_vblank_off(crtc);
910 tegra_dc_commit(dc); 910 tegra_dc_commit(dc);
911} 911}
912 912
@@ -996,8 +996,6 @@ static int tegra_crtc_mode_set(struct drm_crtc *crtc,
996 u32 value; 996 u32 value;
997 int err; 997 int err;
998 998
999 drm_vblank_pre_modeset(crtc->dev, dc->pipe);
1000
1001 err = tegra_crtc_setup_clk(crtc, mode); 999 err = tegra_crtc_setup_clk(crtc, mode);
1002 if (err) { 1000 if (err) {
1003 dev_err(dc->dev, "failed to setup clock for CRTC: %d\n", err); 1001 dev_err(dc->dev, "failed to setup clock for CRTC: %d\n", err);
@@ -1051,6 +1049,8 @@ static void tegra_crtc_prepare(struct drm_crtc *crtc)
1051 unsigned int syncpt; 1049 unsigned int syncpt;
1052 unsigned long value; 1050 unsigned long value;
1053 1051
1052 drm_crtc_vblank_off(crtc);
1053
1054 /* hardware initialization */ 1054 /* hardware initialization */
1055 reset_control_deassert(dc->rst); 1055 reset_control_deassert(dc->rst);
1056 usleep_range(10000, 20000); 1056 usleep_range(10000, 20000);
@@ -1091,7 +1091,7 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
1091{ 1091{
1092 struct tegra_dc *dc = to_tegra_dc(crtc); 1092 struct tegra_dc *dc = to_tegra_dc(crtc);
1093 1093
1094 drm_vblank_post_modeset(crtc->dev, dc->pipe); 1094 drm_crtc_vblank_on(crtc);
1095 tegra_dc_commit(dc); 1095 tegra_dc_commit(dc);
1096} 1096}
1097 1097
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 73bd9e2e42bc..3402033fa52a 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1659,6 +1659,7 @@ void hid_disconnect(struct hid_device *hdev)
1659 hdev->hiddev_disconnect(hdev); 1659 hdev->hiddev_disconnect(hdev);
1660 if (hdev->claimed & HID_CLAIMED_HIDRAW) 1660 if (hdev->claimed & HID_CLAIMED_HIDRAW)
1661 hidraw_disconnect(hdev); 1661 hidraw_disconnect(hdev);
1662 hdev->claimed = 0;
1662} 1663}
1663EXPORT_SYMBOL_GPL(hid_disconnect); 1664EXPORT_SYMBOL_GPL(hid_disconnect);
1664 1665
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index e23ab8b30626..7c863738e419 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -299,6 +299,7 @@
299#define USB_VENDOR_ID_ELAN 0x04f3 299#define USB_VENDOR_ID_ELAN 0x04f3
300#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089 300#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089
301#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b 301#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b
302#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_0103 0x0103
302#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f 303#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f
303 304
304#define USB_VENDOR_ID_ELECOM 0x056e 305#define USB_VENDOR_ID_ELECOM 0x056e
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 5014bb567b29..552671ee7c5d 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -72,6 +72,7 @@ static const struct hid_blacklist {
72 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 72 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
73 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, 73 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL },
74 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL }, 74 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL },
75 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_0103, HID_QUIRK_ALWAYS_POLL },
75 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL }, 76 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL },
76 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 77 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
77 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 78 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index fcdbde4ec692..3057dfc7e3bc 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -234,7 +234,7 @@ static const struct pci_device_id fam15h_power_id_table[] = {
234 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) }, 234 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_NB_F4) },
235 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) }, 235 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_15H_M30H_NB_F4) },
236 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) }, 236 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_NB_F4) },
237 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F3) }, 237 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_16H_M30H_NB_F4) },
238 {} 238 {}
239}; 239};
240MODULE_DEVICE_TABLE(pci, fam15h_power_id_table); 240MODULE_DEVICE_TABLE(pci, fam15h_power_id_table);
diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c
index 6aac695b1688..9b55e673b67c 100644
--- a/drivers/hwmon/g762.c
+++ b/drivers/hwmon/g762.c
@@ -1084,10 +1084,8 @@ static int g762_probe(struct i2c_client *client, const struct i2c_device_id *id)
1084 if (ret) 1084 if (ret)
1085 goto clock_dis; 1085 goto clock_dis;
1086 1086
1087 data->hwmon_dev = devm_hwmon_device_register_with_groups(dev, 1087 data->hwmon_dev = hwmon_device_register_with_groups(dev, client->name,
1088 client->name, 1088 data, g762_groups);
1089 data,
1090 g762_groups);
1091 if (IS_ERR(data->hwmon_dev)) { 1089 if (IS_ERR(data->hwmon_dev)) {
1092 ret = PTR_ERR(data->hwmon_dev); 1090 ret = PTR_ERR(data->hwmon_dev);
1093 goto clock_dis; 1091 goto clock_dis;
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index d2bf2c97ae70..6a30eeea94be 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -181,7 +181,7 @@ static int __init populate_attr_groups(struct platform_device *pdev)
181 181
182 opal = of_find_node_by_path("/ibm,opal/sensors"); 182 opal = of_find_node_by_path("/ibm,opal/sensors");
183 if (!opal) { 183 if (!opal) {
184 dev_err(&pdev->dev, "Opal node 'sensors' not found\n"); 184 dev_dbg(&pdev->dev, "Opal node 'sensors' not found\n");
185 return -ENODEV; 185 return -ENODEV;
186 } 186 }
187 187
@@ -335,7 +335,9 @@ static int __init ibmpowernv_init(void)
335 335
336 err = platform_driver_probe(&ibmpowernv_driver, ibmpowernv_probe); 336 err = platform_driver_probe(&ibmpowernv_driver, ibmpowernv_probe);
337 if (err) { 337 if (err) {
338 pr_err("Platfrom driver probe failed\n"); 338 if (err != -ENODEV)
339 pr_err("Platform driver probe failed (%d)\n", err);
340
339 goto exit_device_del; 341 goto exit_device_del;
340 } 342 }
341 343
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 823c877a1ec0..1991d9032c38 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -161,10 +161,17 @@ static int pwm_fan_suspend(struct device *dev)
161static int pwm_fan_resume(struct device *dev) 161static int pwm_fan_resume(struct device *dev)
162{ 162{
163 struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); 163 struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
164 unsigned long duty;
165 int ret;
164 166
165 if (ctx->pwm_value) 167 if (ctx->pwm_value == 0)
166 return pwm_enable(ctx->pwm); 168 return 0;
167 return 0; 169
170 duty = DIV_ROUND_UP(ctx->pwm_value * (ctx->pwm->period - 1), MAX_PWM);
171 ret = pwm_config(ctx->pwm, duty, ctx->pwm->period);
172 if (ret)
173 return ret;
174 return pwm_enable(ctx->pwm);
168} 175}
169#endif 176#endif
170 177
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 22c096ce39ad..513bd6d14293 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -44,6 +44,9 @@
44 44
45#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B 45#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B
46#define BMC150_ACCEL_ANY_MOTION_MASK 0x07 46#define BMC150_ACCEL_ANY_MOTION_MASK 0x07
47#define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0)
48#define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1)
49#define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2)
47#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3) 50#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3)
48 51
49#define BMC150_ACCEL_REG_PMU_LPW 0x11 52#define BMC150_ACCEL_REG_PMU_LPW 0x11
@@ -92,9 +95,9 @@
92#define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF 95#define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF
93 96
94/* Slope duration in terms of number of samples */ 97/* Slope duration in terms of number of samples */
95#define BMC150_ACCEL_DEF_SLOPE_DURATION 2 98#define BMC150_ACCEL_DEF_SLOPE_DURATION 1
96/* in terms of multiples of g's/LSB, based on range */ 99/* in terms of multiples of g's/LSB, based on range */
97#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 5 100#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 1
98 101
99#define BMC150_ACCEL_REG_XOUT_L 0x02 102#define BMC150_ACCEL_REG_XOUT_L 0x02
100 103
@@ -536,6 +539,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)
536 if (ret < 0) { 539 if (ret < 0) {
537 dev_err(&data->client->dev, 540 dev_err(&data->client->dev,
538 "Failed: bmc150_accel_set_power_state for %d\n", on); 541 "Failed: bmc150_accel_set_power_state for %d\n", on);
542 if (on)
543 pm_runtime_put_noidle(&data->client->dev);
544
539 return ret; 545 return ret;
540 } 546 }
541 547
@@ -811,6 +817,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev,
811 817
812 ret = bmc150_accel_setup_any_motion_interrupt(data, state); 818 ret = bmc150_accel_setup_any_motion_interrupt(data, state);
813 if (ret < 0) { 819 if (ret < 0) {
820 bmc150_accel_set_power_state(data, false);
814 mutex_unlock(&data->mutex); 821 mutex_unlock(&data->mutex);
815 return ret; 822 return ret;
816 } 823 }
@@ -846,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = {
846 853
847static const struct iio_event_spec bmc150_accel_event = { 854static const struct iio_event_spec bmc150_accel_event = {
848 .type = IIO_EV_TYPE_ROC, 855 .type = IIO_EV_TYPE_ROC,
849 .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING, 856 .dir = IIO_EV_DIR_EITHER,
850 .mask_separate = BIT(IIO_EV_INFO_VALUE) | 857 .mask_separate = BIT(IIO_EV_INFO_VALUE) |
851 BIT(IIO_EV_INFO_ENABLE) | 858 BIT(IIO_EV_INFO_ENABLE) |
852 BIT(IIO_EV_INFO_PERIOD) 859 BIT(IIO_EV_INFO_PERIOD)
@@ -1054,6 +1061,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
1054 else 1061 else
1055 ret = bmc150_accel_setup_new_data_interrupt(data, state); 1062 ret = bmc150_accel_setup_new_data_interrupt(data, state);
1056 if (ret < 0) { 1063 if (ret < 0) {
1064 bmc150_accel_set_power_state(data, false);
1057 mutex_unlock(&data->mutex); 1065 mutex_unlock(&data->mutex);
1058 return ret; 1066 return ret;
1059 } 1067 }
@@ -1092,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)
1092 else 1100 else
1093 dir = IIO_EV_DIR_RISING; 1101 dir = IIO_EV_DIR_RISING;
1094 1102
1095 if (ret & BMC150_ACCEL_ANY_MOTION_MASK) 1103 if (ret & BMC150_ACCEL_ANY_MOTION_BIT_X)
1104 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
1105 0,
1106 IIO_MOD_X,
1107 IIO_EV_TYPE_ROC,
1108 dir),
1109 data->timestamp);
1110 if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Y)
1096 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 1111 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
1097 0, 1112 0,
1098 IIO_MOD_X_OR_Y_OR_Z, 1113 IIO_MOD_Y,
1099 IIO_EV_TYPE_ROC, 1114 IIO_EV_TYPE_ROC,
1100 IIO_EV_DIR_EITHER), 1115 dir),
1116 data->timestamp);
1117 if (ret & BMC150_ACCEL_ANY_MOTION_BIT_Z)
1118 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL,
1119 0,
1120 IIO_MOD_Z,
1121 IIO_EV_TYPE_ROC,
1122 dir),
1101 data->timestamp); 1123 data->timestamp);
1102ack_intr_status: 1124ack_intr_status:
1103 if (!data->dready_trigger_on) 1125 if (!data->dready_trigger_on)
@@ -1354,10 +1376,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev)
1354{ 1376{
1355 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1377 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
1356 struct bmc150_accel_data *data = iio_priv(indio_dev); 1378 struct bmc150_accel_data *data = iio_priv(indio_dev);
1379 int ret;
1357 1380
1358 dev_dbg(&data->client->dev, __func__); 1381 dev_dbg(&data->client->dev, __func__);
1382 ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0);
1383 if (ret < 0)
1384 return -EAGAIN;
1359 1385
1360 return bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); 1386 return 0;
1361} 1387}
1362 1388
1363static int bmc150_accel_runtime_resume(struct device *dev) 1389static int bmc150_accel_runtime_resume(struct device *dev)
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index a23e58c4ed99..320aa72c0349 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -269,6 +269,8 @@ static int kxcjk1013_set_range(struct kxcjk1013_data *data, int range_index)
269 return ret; 269 return ret;
270 } 270 }
271 271
272 ret &= ~(KXCJK1013_REG_CTRL1_BIT_GSEL0 |
273 KXCJK1013_REG_CTRL1_BIT_GSEL1);
272 ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3); 274 ret |= (KXCJK1013_scale_table[range_index].gsel_0 << 3);
273 ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4); 275 ret |= (KXCJK1013_scale_table[range_index].gsel_1 << 4);
274 276
diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
index b58d6302521f..d095efe1ba14 100644
--- a/drivers/iio/adc/men_z188_adc.c
+++ b/drivers/iio/adc/men_z188_adc.c
@@ -152,6 +152,7 @@ static void men_z188_remove(struct mcb_device *dev)
152 152
153static const struct mcb_device_id men_z188_ids[] = { 153static const struct mcb_device_id men_z188_ids[] = {
154 { .device = 0xbc }, 154 { .device = 0xbc },
155 { }
155}; 156};
156MODULE_DEVICE_TABLE(mcb, men_z188_ids); 157MODULE_DEVICE_TABLE(mcb, men_z188_ids);
157 158
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 1f967e0d688e..d2fa526740ca 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -67,6 +67,9 @@
67#define BMG160_REG_INT_EN_0 0x15 67#define BMG160_REG_INT_EN_0 0x15
68#define BMG160_DATA_ENABLE_INT BIT(7) 68#define BMG160_DATA_ENABLE_INT BIT(7)
69 69
70#define BMG160_REG_INT_EN_1 0x16
71#define BMG160_INT1_BIT_OD BIT(1)
72
70#define BMG160_REG_XOUT_L 0x02 73#define BMG160_REG_XOUT_L 0x02
71#define BMG160_AXIS_TO_REG(axis) (BMG160_REG_XOUT_L + (axis * 2)) 74#define BMG160_AXIS_TO_REG(axis) (BMG160_REG_XOUT_L + (axis * 2))
72 75
@@ -82,6 +85,9 @@
82 85
83#define BMG160_REG_INT_STATUS_2 0x0B 86#define BMG160_REG_INT_STATUS_2 0x0B
84#define BMG160_ANY_MOTION_MASK 0x07 87#define BMG160_ANY_MOTION_MASK 0x07
88#define BMG160_ANY_MOTION_BIT_X BIT(0)
89#define BMG160_ANY_MOTION_BIT_Y BIT(1)
90#define BMG160_ANY_MOTION_BIT_Z BIT(2)
85 91
86#define BMG160_REG_TEMP 0x08 92#define BMG160_REG_TEMP 0x08
87#define BMG160_TEMP_CENTER_VAL 23 93#define BMG160_TEMP_CENTER_VAL 23
@@ -222,6 +228,19 @@ static int bmg160_chip_init(struct bmg160_data *data)
222 data->slope_thres = ret; 228 data->slope_thres = ret;
223 229
224 /* Set default interrupt mode */ 230 /* Set default interrupt mode */
231 ret = i2c_smbus_read_byte_data(data->client, BMG160_REG_INT_EN_1);
232 if (ret < 0) {
233 dev_err(&data->client->dev, "Error reading reg_int_en_1\n");
234 return ret;
235 }
236 ret &= ~BMG160_INT1_BIT_OD;
237 ret = i2c_smbus_write_byte_data(data->client,
238 BMG160_REG_INT_EN_1, ret);
239 if (ret < 0) {
240 dev_err(&data->client->dev, "Error writing reg_int_en_1\n");
241 return ret;
242 }
243
225 ret = i2c_smbus_write_byte_data(data->client, 244 ret = i2c_smbus_write_byte_data(data->client,
226 BMG160_REG_INT_RST_LATCH, 245 BMG160_REG_INT_RST_LATCH,
227 BMG160_INT_MODE_LATCH_INT | 246 BMG160_INT_MODE_LATCH_INT |
@@ -250,6 +269,9 @@ static int bmg160_set_power_state(struct bmg160_data *data, bool on)
250 if (ret < 0) { 269 if (ret < 0) {
251 dev_err(&data->client->dev, 270 dev_err(&data->client->dev,
252 "Failed: bmg160_set_power_state for %d\n", on); 271 "Failed: bmg160_set_power_state for %d\n", on);
272 if (on)
273 pm_runtime_put_noidle(&data->client->dev);
274
253 return ret; 275 return ret;
254 } 276 }
255#endif 277#endif
@@ -705,6 +727,7 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
705 727
706 ret = bmg160_setup_any_motion_interrupt(data, state); 728 ret = bmg160_setup_any_motion_interrupt(data, state);
707 if (ret < 0) { 729 if (ret < 0) {
730 bmg160_set_power_state(data, false);
708 mutex_unlock(&data->mutex); 731 mutex_unlock(&data->mutex);
709 return ret; 732 return ret;
710 } 733 }
@@ -743,7 +766,7 @@ static const struct attribute_group bmg160_attrs_group = {
743 766
744static const struct iio_event_spec bmg160_event = { 767static const struct iio_event_spec bmg160_event = {
745 .type = IIO_EV_TYPE_ROC, 768 .type = IIO_EV_TYPE_ROC,
746 .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING, 769 .dir = IIO_EV_DIR_EITHER,
747 .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) | 770 .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE) |
748 BIT(IIO_EV_INFO_ENABLE) 771 BIT(IIO_EV_INFO_ENABLE)
749}; 772};
@@ -871,6 +894,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig,
871 else 894 else
872 ret = bmg160_setup_new_data_interrupt(data, state); 895 ret = bmg160_setup_new_data_interrupt(data, state);
873 if (ret < 0) { 896 if (ret < 0) {
897 bmg160_set_power_state(data, false);
874 mutex_unlock(&data->mutex); 898 mutex_unlock(&data->mutex);
875 return ret; 899 return ret;
876 } 900 }
@@ -908,10 +932,24 @@ static irqreturn_t bmg160_event_handler(int irq, void *private)
908 else 932 else
909 dir = IIO_EV_DIR_FALLING; 933 dir = IIO_EV_DIR_FALLING;
910 934
911 if (ret & BMG160_ANY_MOTION_MASK) 935 if (ret & BMG160_ANY_MOTION_BIT_X)
912 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, 936 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
913 0, 937 0,
914 IIO_MOD_X_OR_Y_OR_Z, 938 IIO_MOD_X,
939 IIO_EV_TYPE_ROC,
940 dir),
941 data->timestamp);
942 if (ret & BMG160_ANY_MOTION_BIT_Y)
943 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
944 0,
945 IIO_MOD_Y,
946 IIO_EV_TYPE_ROC,
947 dir),
948 data->timestamp);
949 if (ret & BMG160_ANY_MOTION_BIT_Z)
950 iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
951 0,
952 IIO_MOD_Z,
915 IIO_EV_TYPE_ROC, 953 IIO_EV_TYPE_ROC,
916 dir), 954 dir),
917 data->timestamp); 955 data->timestamp);
@@ -1169,8 +1207,15 @@ static int bmg160_runtime_suspend(struct device *dev)
1169{ 1207{
1170 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); 1208 struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
1171 struct bmg160_data *data = iio_priv(indio_dev); 1209 struct bmg160_data *data = iio_priv(indio_dev);
1210 int ret;
1211
1212 ret = bmg160_set_mode(data, BMG160_MODE_SUSPEND);
1213 if (ret < 0) {
1214 dev_err(&data->client->dev, "set mode failed\n");
1215 return -EAGAIN;
1216 }
1172 1217
1173 return bmg160_set_mode(data, BMG160_MODE_SUSPEND); 1218 return 0;
1174} 1219}
1175 1220
1176static int bmg160_runtime_resume(struct device *dev) 1221static int bmg160_runtime_resume(struct device *dev)
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 3effa931fce2..10641b7816f4 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -115,9 +115,12 @@ isert_conn_setup_qp(struct isert_conn *isert_conn, struct rdma_cm_id *cma_id,
115 attr.cap.max_recv_wr = ISERT_QP_MAX_RECV_DTOS; 115 attr.cap.max_recv_wr = ISERT_QP_MAX_RECV_DTOS;
116 /* 116 /*
117 * FIXME: Use devattr.max_sge - 2 for max_send_sge as 117 * FIXME: Use devattr.max_sge - 2 for max_send_sge as
118 * work-around for RDMA_READ.. 118 * work-around for RDMA_READs with ConnectX-2.
119 *
120 * Also, still make sure to have at least two SGEs for
121 * outgoing control PDU responses.
119 */ 122 */
120 attr.cap.max_send_sge = device->dev_attr.max_sge - 2; 123 attr.cap.max_send_sge = max(2, device->dev_attr.max_sge - 2);
121 isert_conn->max_sge = attr.cap.max_send_sge; 124 isert_conn->max_sge = attr.cap.max_send_sge;
122 125
123 attr.cap.max_recv_sge = 1; 126 attr.cap.max_recv_sge = 1;
@@ -225,12 +228,16 @@ isert_create_device_ib_res(struct isert_device *device)
225 struct isert_cq_desc *cq_desc; 228 struct isert_cq_desc *cq_desc;
226 struct ib_device_attr *dev_attr; 229 struct ib_device_attr *dev_attr;
227 int ret = 0, i, j; 230 int ret = 0, i, j;
231 int max_rx_cqe, max_tx_cqe;
228 232
229 dev_attr = &device->dev_attr; 233 dev_attr = &device->dev_attr;
230 ret = isert_query_device(ib_dev, dev_attr); 234 ret = isert_query_device(ib_dev, dev_attr);
231 if (ret) 235 if (ret)
232 return ret; 236 return ret;
233 237
238 max_rx_cqe = min(ISER_MAX_RX_CQ_LEN, dev_attr->max_cqe);
239 max_tx_cqe = min(ISER_MAX_TX_CQ_LEN, dev_attr->max_cqe);
240
234 /* asign function handlers */ 241 /* asign function handlers */
235 if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS && 242 if (dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS &&
236 dev_attr->device_cap_flags & IB_DEVICE_SIGNATURE_HANDOVER) { 243 dev_attr->device_cap_flags & IB_DEVICE_SIGNATURE_HANDOVER) {
@@ -272,7 +279,7 @@ isert_create_device_ib_res(struct isert_device *device)
272 isert_cq_rx_callback, 279 isert_cq_rx_callback,
273 isert_cq_event_callback, 280 isert_cq_event_callback,
274 (void *)&cq_desc[i], 281 (void *)&cq_desc[i],
275 ISER_MAX_RX_CQ_LEN, i); 282 max_rx_cqe, i);
276 if (IS_ERR(device->dev_rx_cq[i])) { 283 if (IS_ERR(device->dev_rx_cq[i])) {
277 ret = PTR_ERR(device->dev_rx_cq[i]); 284 ret = PTR_ERR(device->dev_rx_cq[i]);
278 device->dev_rx_cq[i] = NULL; 285 device->dev_rx_cq[i] = NULL;
@@ -284,7 +291,7 @@ isert_create_device_ib_res(struct isert_device *device)
284 isert_cq_tx_callback, 291 isert_cq_tx_callback,
285 isert_cq_event_callback, 292 isert_cq_event_callback,
286 (void *)&cq_desc[i], 293 (void *)&cq_desc[i],
287 ISER_MAX_TX_CQ_LEN, i); 294 max_tx_cqe, i);
288 if (IS_ERR(device->dev_tx_cq[i])) { 295 if (IS_ERR(device->dev_tx_cq[i])) {
289 ret = PTR_ERR(device->dev_tx_cq[i]); 296 ret = PTR_ERR(device->dev_tx_cq[i]);
290 device->dev_tx_cq[i] = NULL; 297 device->dev_tx_cq[i] = NULL;
@@ -803,14 +810,25 @@ wake_up:
803 complete(&isert_conn->conn_wait); 810 complete(&isert_conn->conn_wait);
804} 811}
805 812
806static void 813static int
807isert_disconnected_handler(struct rdma_cm_id *cma_id, bool disconnect) 814isert_disconnected_handler(struct rdma_cm_id *cma_id, bool disconnect)
808{ 815{
809 struct isert_conn *isert_conn = (struct isert_conn *)cma_id->context; 816 struct isert_conn *isert_conn;
817
818 if (!cma_id->qp) {
819 struct isert_np *isert_np = cma_id->context;
820
821 isert_np->np_cm_id = NULL;
822 return -1;
823 }
824
825 isert_conn = (struct isert_conn *)cma_id->context;
810 826
811 isert_conn->disconnect = disconnect; 827 isert_conn->disconnect = disconnect;
812 INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work); 828 INIT_WORK(&isert_conn->conn_logout_work, isert_disconnect_work);
813 schedule_work(&isert_conn->conn_logout_work); 829 schedule_work(&isert_conn->conn_logout_work);
830
831 return 0;
814} 832}
815 833
816static int 834static int
@@ -825,6 +843,9 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
825 switch (event->event) { 843 switch (event->event) {
826 case RDMA_CM_EVENT_CONNECT_REQUEST: 844 case RDMA_CM_EVENT_CONNECT_REQUEST:
827 ret = isert_connect_request(cma_id, event); 845 ret = isert_connect_request(cma_id, event);
846 if (ret)
847 pr_err("isert_cma_handler failed RDMA_CM_EVENT: 0x%08x %d\n",
848 event->event, ret);
828 break; 849 break;
829 case RDMA_CM_EVENT_ESTABLISHED: 850 case RDMA_CM_EVENT_ESTABLISHED:
830 isert_connected_handler(cma_id); 851 isert_connected_handler(cma_id);
@@ -834,7 +855,7 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
834 case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */ 855 case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */
835 disconnect = true; 856 disconnect = true;
836 case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */ 857 case RDMA_CM_EVENT_TIMEWAIT_EXIT: /* FALLTHRU */
837 isert_disconnected_handler(cma_id, disconnect); 858 ret = isert_disconnected_handler(cma_id, disconnect);
838 break; 859 break;
839 case RDMA_CM_EVENT_CONNECT_ERROR: 860 case RDMA_CM_EVENT_CONNECT_ERROR:
840 default: 861 default:
@@ -842,12 +863,6 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
842 break; 863 break;
843 } 864 }
844 865
845 if (ret != 0) {
846 pr_err("isert_cma_handler failed RDMA_CM_EVENT: 0x%08x %d\n",
847 event->event, ret);
848 dump_stack();
849 }
850
851 return ret; 866 return ret;
852} 867}
853 868
@@ -3190,7 +3205,8 @@ isert_free_np(struct iscsi_np *np)
3190{ 3205{
3191 struct isert_np *isert_np = (struct isert_np *)np->np_context; 3206 struct isert_np *isert_np = (struct isert_np *)np->np_context;
3192 3207
3193 rdma_destroy_id(isert_np->np_cm_id); 3208 if (isert_np->np_cm_id)
3209 rdma_destroy_id(isert_np->np_cm_id);
3194 3210
3195 np->np_context = NULL; 3211 np->np_context = NULL;
3196 kfree(isert_np); 3212 kfree(isert_np);
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 7206547c13ce..dc829682701a 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2092,6 +2092,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
2092 if (!qp_init) 2092 if (!qp_init)
2093 goto out; 2093 goto out;
2094 2094
2095retry:
2095 ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch, 2096 ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch,
2096 ch->rq_size + srp_sq_size, 0); 2097 ch->rq_size + srp_sq_size, 0);
2097 if (IS_ERR(ch->cq)) { 2098 if (IS_ERR(ch->cq)) {
@@ -2115,6 +2116,13 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
2115 ch->qp = ib_create_qp(sdev->pd, qp_init); 2116 ch->qp = ib_create_qp(sdev->pd, qp_init);
2116 if (IS_ERR(ch->qp)) { 2117 if (IS_ERR(ch->qp)) {
2117 ret = PTR_ERR(ch->qp); 2118 ret = PTR_ERR(ch->qp);
2119 if (ret == -ENOMEM) {
2120 srp_sq_size /= 2;
2121 if (srp_sq_size >= MIN_SRPT_SQ_SIZE) {
2122 ib_destroy_cq(ch->cq);
2123 goto retry;
2124 }
2125 }
2118 printk(KERN_ERR "failed to create_qp ret= %d\n", ret); 2126 printk(KERN_ERR "failed to create_qp ret= %d\n", ret);
2119 goto err_destroy_cq; 2127 goto err_destroy_cq;
2120 } 2128 }
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 2ed7905a068f..fc55f0d15b70 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1179,9 +1179,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
1179 } 1179 }
1180 1180
1181 ep_irq_in = &intf->cur_altsetting->endpoint[1].desc; 1181 ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
1182 usb_fill_bulk_urb(xpad->bulk_out, udev, 1182 if (usb_endpoint_is_bulk_out(ep_irq_in)) {
1183 usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress), 1183 usb_fill_bulk_urb(xpad->bulk_out, udev,
1184 xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad); 1184 usb_sndbulkpipe(udev,
1185 ep_irq_in->bEndpointAddress),
1186 xpad->bdata, XPAD_PKT_LEN,
1187 xpad_bulk_out, xpad);
1188 } else {
1189 usb_fill_int_urb(xpad->bulk_out, udev,
1190 usb_sndintpipe(udev,
1191 ep_irq_in->bEndpointAddress),
1192 xpad->bdata, XPAD_PKT_LEN,
1193 xpad_bulk_out, xpad, 0);
1194 }
1185 1195
1186 /* 1196 /*
1187 * Submit the int URB immediately rather than waiting for open 1197 * Submit the int URB immediately rather than waiting for open
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index fb3b63b2f85c..8400a1a34d87 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -85,6 +85,7 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
85 } 85 }
86 86
87 platform_set_drvdata(pdev, pwr); 87 platform_set_drvdata(pdev, pwr);
88 device_init_wakeup(&pdev->dev, true);
88 89
89 return 0; 90 return 0;
90} 91}
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 2b0ae8cc8e51..d125a019383f 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -1156,7 +1156,13 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
1156{ 1156{
1157 struct alps_data *priv = psmouse->private; 1157 struct alps_data *priv = psmouse->private;
1158 1158
1159 if ((psmouse->packet[0] & 0xc8) == 0x08) { /* PS/2 packet */ 1159 /*
1160 * Check if we are dealing with a bare PS/2 packet, presumably from
1161 * a device connected to the external PS/2 port. Because bare PS/2
1162 * protocol does not have enough constant bits to self-synchronize
1163 * properly we only do this if the device is fully synchronized.
1164 */
1165 if (!psmouse->out_of_sync_cnt && (psmouse->packet[0] & 0xc8) == 0x08) {
1160 if (psmouse->pktcnt == 3) { 1166 if (psmouse->pktcnt == 3) {
1161 alps_report_bare_ps2_packet(psmouse, psmouse->packet, 1167 alps_report_bare_ps2_packet(psmouse, psmouse->packet,
1162 true); 1168 true);
@@ -1180,12 +1186,27 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
1180 } 1186 }
1181 1187
1182 /* Bytes 2 - pktsize should have 0 in the highest bit */ 1188 /* Bytes 2 - pktsize should have 0 in the highest bit */
1183 if ((priv->proto_version < ALPS_PROTO_V5) && 1189 if (priv->proto_version < ALPS_PROTO_V5 &&
1184 psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && 1190 psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
1185 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { 1191 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
1186 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", 1192 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
1187 psmouse->pktcnt - 1, 1193 psmouse->pktcnt - 1,
1188 psmouse->packet[psmouse->pktcnt - 1]); 1194 psmouse->packet[psmouse->pktcnt - 1]);
1195
1196 if (priv->proto_version == ALPS_PROTO_V3 &&
1197 psmouse->pktcnt == psmouse->pktsize) {
1198 /*
1199 * Some Dell boxes, such as Latitude E6440 or E7440
1200 * with closed lid, quite often smash last byte of
1201 * otherwise valid packet with 0xff. Given that the
1202 * next packet is very likely to be valid let's
1203 * report PSMOUSE_FULL_PACKET but not process data,
1204 * rather than reporting PSMOUSE_BAD_DATA and
1205 * filling the logs.
1206 */
1207 return PSMOUSE_FULL_PACKET;
1208 }
1209
1189 return PSMOUSE_BAD_DATA; 1210 return PSMOUSE_BAD_DATA;
1190 } 1211 }
1191 1212
@@ -2389,6 +2410,9 @@ int alps_init(struct psmouse *psmouse)
2389 /* We are having trouble resyncing ALPS touchpads so disable it for now */ 2410 /* We are having trouble resyncing ALPS touchpads so disable it for now */
2390 psmouse->resync_time = 0; 2411 psmouse->resync_time = 0;
2391 2412
2413 /* Allow 2 invalid packets without resetting device */
2414 psmouse->resetafter = psmouse->pktsize * 2;
2415
2392 return 0; 2416 return 0;
2393 2417
2394init_fail: 2418init_fail:
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 06fc6e76ffbe..f2b978026407 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -428,14 +428,6 @@ static void elantech_report_trackpoint(struct psmouse *psmouse,
428 int x, y; 428 int x, y;
429 u32 t; 429 u32 t;
430 430
431 if (dev_WARN_ONCE(&psmouse->ps2dev.serio->dev,
432 !tp_dev,
433 psmouse_fmt("Unexpected trackpoint message\n"))) {
434 if (etd->debug == 1)
435 elantech_packet_dump(psmouse);
436 return;
437 }
438
439 t = get_unaligned_le32(&packet[0]); 431 t = get_unaligned_le32(&packet[0]);
440 432
441 switch (t & ~7U) { 433 switch (t & ~7U) {
@@ -563,6 +555,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
563 } else { 555 } else {
564 input_report_key(dev, BTN_LEFT, packet[0] & 0x01); 556 input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
565 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02); 557 input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
558 input_report_key(dev, BTN_MIDDLE, packet[0] & 0x04);
566 } 559 }
567 560
568 input_mt_report_pointer_emulation(dev, true); 561 input_mt_report_pointer_emulation(dev, true);
@@ -792,6 +785,9 @@ static int elantech_packet_check_v4(struct psmouse *psmouse)
792 unsigned char packet_type = packet[3] & 0x03; 785 unsigned char packet_type = packet[3] & 0x03;
793 bool sanity_check; 786 bool sanity_check;
794 787
788 if (etd->tp_dev && (packet[3] & 0x0f) == 0x06)
789 return PACKET_TRACKPOINT;
790
795 /* 791 /*
796 * Sanity check based on the constant bits of a packet. 792 * Sanity check based on the constant bits of a packet.
797 * The constant bits change depending on the value of 793 * The constant bits change depending on the value of
@@ -877,10 +873,19 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
877 873
878 case 4: 874 case 4:
879 packet_type = elantech_packet_check_v4(psmouse); 875 packet_type = elantech_packet_check_v4(psmouse);
880 if (packet_type == PACKET_UNKNOWN) 876 switch (packet_type) {
877 case PACKET_UNKNOWN:
881 return PSMOUSE_BAD_DATA; 878 return PSMOUSE_BAD_DATA;
882 879
883 elantech_report_absolute_v4(psmouse, packet_type); 880 case PACKET_TRACKPOINT:
881 elantech_report_trackpoint(psmouse, packet_type);
882 break;
883
884 default:
885 elantech_report_absolute_v4(psmouse, packet_type);
886 break;
887 }
888
884 break; 889 break;
885 } 890 }
886 891
@@ -1120,6 +1125,22 @@ static void elantech_set_buttonpad_prop(struct psmouse *psmouse)
1120} 1125}
1121 1126
1122/* 1127/*
1128 * Some hw_version 4 models do have a middle button
1129 */
1130static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
1131#if defined(CONFIG_DMI) && defined(CONFIG_X86)
1132 {
1133 /* Fujitsu H730 has a middle button */
1134 .matches = {
1135 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
1136 DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"),
1137 },
1138 },
1139#endif
1140 { }
1141};
1142
1143/*
1123 * Set the appropriate event bits for the input subsystem 1144 * Set the appropriate event bits for the input subsystem
1124 */ 1145 */
1125static int elantech_set_input_params(struct psmouse *psmouse) 1146static int elantech_set_input_params(struct psmouse *psmouse)
@@ -1138,6 +1159,8 @@ static int elantech_set_input_params(struct psmouse *psmouse)
1138 __clear_bit(EV_REL, dev->evbit); 1159 __clear_bit(EV_REL, dev->evbit);
1139 1160
1140 __set_bit(BTN_LEFT, dev->keybit); 1161 __set_bit(BTN_LEFT, dev->keybit);
1162 if (dmi_check_system(elantech_dmi_has_middle_button))
1163 __set_bit(BTN_MIDDLE, dev->keybit);
1141 __set_bit(BTN_RIGHT, dev->keybit); 1164 __set_bit(BTN_RIGHT, dev->keybit);
1142 1165
1143 __set_bit(BTN_TOUCH, dev->keybit); 1166 __set_bit(BTN_TOUCH, dev->keybit);
@@ -1299,6 +1322,7 @@ ELANTECH_INT_ATTR(reg_25, 0x25);
1299ELANTECH_INT_ATTR(reg_26, 0x26); 1322ELANTECH_INT_ATTR(reg_26, 0x26);
1300ELANTECH_INT_ATTR(debug, 0); 1323ELANTECH_INT_ATTR(debug, 0);
1301ELANTECH_INT_ATTR(paritycheck, 0); 1324ELANTECH_INT_ATTR(paritycheck, 0);
1325ELANTECH_INT_ATTR(crc_enabled, 0);
1302 1326
1303static struct attribute *elantech_attrs[] = { 1327static struct attribute *elantech_attrs[] = {
1304 &psmouse_attr_reg_07.dattr.attr, 1328 &psmouse_attr_reg_07.dattr.attr,
@@ -1313,6 +1337,7 @@ static struct attribute *elantech_attrs[] = {
1313 &psmouse_attr_reg_26.dattr.attr, 1337 &psmouse_attr_reg_26.dattr.attr,
1314 &psmouse_attr_debug.dattr.attr, 1338 &psmouse_attr_debug.dattr.attr,
1315 &psmouse_attr_paritycheck.dattr.attr, 1339 &psmouse_attr_paritycheck.dattr.attr,
1340 &psmouse_attr_crc_enabled.dattr.attr,
1316 NULL 1341 NULL
1317}; 1342};
1318 1343
@@ -1439,6 +1464,22 @@ static int elantech_reconnect(struct psmouse *psmouse)
1439} 1464}
1440 1465
1441/* 1466/*
1467 * Some hw_version 4 models do not work with crc_disabled
1468 */
1469static const struct dmi_system_id elantech_dmi_force_crc_enabled[] = {
1470#if defined(CONFIG_DMI) && defined(CONFIG_X86)
1471 {
1472 /* Fujitsu H730 does not work with crc_enabled == 0 */
1473 .matches = {
1474 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
1475 DMI_MATCH(DMI_PRODUCT_NAME, "CELSIUS H730"),
1476 },
1477 },
1478#endif
1479 { }
1480};
1481
1482/*
1442 * Some hw_version 3 models go into error state when we try to set 1483 * Some hw_version 3 models go into error state when we try to set
1443 * bit 3 and/or bit 1 of r10. 1484 * bit 3 and/or bit 1 of r10.
1444 */ 1485 */
@@ -1513,7 +1554,8 @@ static int elantech_set_properties(struct elantech_data *etd)
1513 * The signatures of v3 and v4 packets change depending on the 1554 * The signatures of v3 and v4 packets change depending on the
1514 * value of this hardware flag. 1555 * value of this hardware flag.
1515 */ 1556 */
1516 etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000); 1557 etd->crc_enabled = (etd->fw_version & 0x4000) == 0x4000 ||
1558 dmi_check_system(elantech_dmi_force_crc_enabled);
1517 1559
1518 /* Enable real hardware resolution on hw_version 3 ? */ 1560 /* Enable real hardware resolution on hw_version 3 ? */
1519 etd->set_hw_resolution = !dmi_check_system(no_hw_res_dmi_table); 1561 etd->set_hw_resolution = !dmi_check_system(no_hw_res_dmi_table);
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 9031a0a28ea4..f9472920d986 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -135,14 +135,18 @@ static const struct min_max_quirk min_max_pnpid_table[] = {
135 1232, 5710, 1156, 4696 135 1232, 5710, 1156, 4696
136 }, 136 },
137 { 137 {
138 (const char * const []){"LEN0034", "LEN0036", "LEN2002", 138 (const char * const []){"LEN0034", "LEN0036", "LEN0039",
139 "LEN2004", NULL}, 139 "LEN2002", "LEN2004", NULL},
140 1024, 5112, 2024, 4832 140 1024, 5112, 2024, 4832
141 }, 141 },
142 { 142 {
143 (const char * const []){"LEN2001", NULL}, 143 (const char * const []){"LEN2001", NULL},
144 1024, 5022, 2508, 4832 144 1024, 5022, 2508, 4832
145 }, 145 },
146 {
147 (const char * const []){"LEN2006", NULL},
148 1264, 5675, 1171, 4688
149 },
146 { } 150 { }
147}; 151};
148 152
@@ -163,6 +167,7 @@ static const char * const topbuttonpad_pnp_ids[] = {
163 "LEN0036", /* T440 */ 167 "LEN0036", /* T440 */
164 "LEN0037", 168 "LEN0037",
165 "LEN0038", 169 "LEN0038",
170 "LEN0039", /* T440s */
166 "LEN0041", 171 "LEN0041",
167 "LEN0042", /* Yoga */ 172 "LEN0042", /* Yoga */
168 "LEN0045", 173 "LEN0045",
diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 6ae3cdee0681..cc4f9d80122e 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -217,8 +217,9 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
217 } 217 }
218 218
219 ret = irq_alloc_domain_generic_chips(domain, 32, 1, name, 219 ret = irq_alloc_domain_generic_chips(domain, 32, 1, name,
220 handle_level_irq, 0, 0, 220 handle_fasteoi_irq,
221 IRQCHIP_SKIP_SET_WAKE); 221 IRQ_NOREQUEST | IRQ_NOPROBE |
222 IRQ_NOAUTOEN, 0, 0);
222 if (ret) 223 if (ret)
223 goto err_domain_remove; 224 goto err_domain_remove;
224 225
@@ -230,7 +231,6 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
230 gc->unused = 0; 231 gc->unused = 0;
231 gc->wake_enabled = ~0; 232 gc->wake_enabled = ~0;
232 gc->chip_types[0].type = IRQ_TYPE_SENSE_MASK; 233 gc->chip_types[0].type = IRQ_TYPE_SENSE_MASK;
233 gc->chip_types[0].handler = handle_fasteoi_irq;
234 gc->chip_types[0].chip.irq_eoi = irq_gc_eoi; 234 gc->chip_types[0].chip.irq_eoi = irq_gc_eoi;
235 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; 235 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake;
236 gc->chip_types[0].chip.irq_shutdown = aic_common_shutdown; 236 gc->chip_types[0].chip.irq_shutdown = aic_common_shutdown;
diff --git a/drivers/irqchip/irq-bcm7120-l2.c b/drivers/irqchip/irq-bcm7120-l2.c
index b9f4fb808e49..5fb38a2ac226 100644
--- a/drivers/irqchip/irq-bcm7120-l2.c
+++ b/drivers/irqchip/irq-bcm7120-l2.c
@@ -101,9 +101,9 @@ static int bcm7120_l2_intc_init_one(struct device_node *dn,
101 int parent_irq; 101 int parent_irq;
102 102
103 parent_irq = irq_of_parse_and_map(dn, irq); 103 parent_irq = irq_of_parse_and_map(dn, irq);
104 if (parent_irq < 0) { 104 if (!parent_irq) {
105 pr_err("failed to map interrupt %d\n", irq); 105 pr_err("failed to map interrupt %d\n", irq);
106 return parent_irq; 106 return -EINVAL;
107 } 107 }
108 108
109 data->irq_map_mask |= be32_to_cpup(map_mask + irq); 109 data->irq_map_mask |= be32_to_cpup(map_mask + irq);
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index c15c840987d2..14691a4cb84c 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -135,9 +135,9 @@ int __init brcmstb_l2_intc_of_init(struct device_node *np,
135 __raw_writel(0xffffffff, data->base + CPU_CLEAR); 135 __raw_writel(0xffffffff, data->base + CPU_CLEAR);
136 136
137 data->parent_irq = irq_of_parse_and_map(np, 0); 137 data->parent_irq = irq_of_parse_and_map(np, 0);
138 if (data->parent_irq < 0) { 138 if (!data->parent_irq) {
139 pr_err("failed to find parent interrupt\n"); 139 pr_err("failed to find parent interrupt\n");
140 ret = data->parent_irq; 140 ret = -EINVAL;
141 goto out_unmap; 141 goto out_unmap;
142 } 142 }
143 143
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 825ca1f87639..afe79719ea32 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1434,9 +1434,9 @@ static void drop_buffers(struct dm_bufio_client *c)
1434 1434
1435/* 1435/*
1436 * Test if the buffer is unused and too old, and commit it. 1436 * Test if the buffer is unused and too old, and commit it.
1437 * At if noio is set, we must not do any I/O because we hold 1437 * And if GFP_NOFS is used, we must not do any I/O because we hold
1438 * dm_bufio_clients_lock and we would risk deadlock if the I/O gets rerouted to 1438 * dm_bufio_clients_lock and we would risk deadlock if the I/O gets
1439 * different bufio client. 1439 * rerouted to different bufio client.
1440 */ 1440 */
1441static int __cleanup_old_buffer(struct dm_buffer *b, gfp_t gfp, 1441static int __cleanup_old_buffer(struct dm_buffer *b, gfp_t gfp,
1442 unsigned long max_jiffies) 1442 unsigned long max_jiffies)
@@ -1444,7 +1444,7 @@ static int __cleanup_old_buffer(struct dm_buffer *b, gfp_t gfp,
1444 if (jiffies - b->last_accessed < max_jiffies) 1444 if (jiffies - b->last_accessed < max_jiffies)
1445 return 0; 1445 return 0;
1446 1446
1447 if (!(gfp & __GFP_IO)) { 1447 if (!(gfp & __GFP_FS)) {
1448 if (test_bit(B_READING, &b->state) || 1448 if (test_bit(B_READING, &b->state) ||
1449 test_bit(B_WRITING, &b->state) || 1449 test_bit(B_WRITING, &b->state) ||
1450 test_bit(B_DIRTY, &b->state)) 1450 test_bit(B_DIRTY, &b->state))
@@ -1486,7 +1486,7 @@ dm_bufio_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
1486 unsigned long freed; 1486 unsigned long freed;
1487 1487
1488 c = container_of(shrink, struct dm_bufio_client, shrinker); 1488 c = container_of(shrink, struct dm_bufio_client, shrinker);
1489 if (sc->gfp_mask & __GFP_IO) 1489 if (sc->gfp_mask & __GFP_FS)
1490 dm_bufio_lock(c); 1490 dm_bufio_lock(c);
1491 else if (!dm_bufio_trylock(c)) 1491 else if (!dm_bufio_trylock(c))
1492 return SHRINK_STOP; 1492 return SHRINK_STOP;
@@ -1503,7 +1503,7 @@ dm_bufio_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
1503 unsigned long count; 1503 unsigned long count;
1504 1504
1505 c = container_of(shrink, struct dm_bufio_client, shrinker); 1505 c = container_of(shrink, struct dm_bufio_client, shrinker);
1506 if (sc->gfp_mask & __GFP_IO) 1506 if (sc->gfp_mask & __GFP_FS)
1507 dm_bufio_lock(c); 1507 dm_bufio_lock(c);
1508 else if (!dm_bufio_trylock(c)) 1508 else if (!dm_bufio_trylock(c))
1509 return 0; 1509 return 0;
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4857fa4a5484..07c0fa0fa284 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -789,8 +789,7 @@ struct dm_raid_superblock {
789 __le32 layout; 789 __le32 layout;
790 __le32 stripe_sectors; 790 __le32 stripe_sectors;
791 791
792 __u8 pad[452]; /* Round struct to 512 bytes. */ 792 /* Remainder of a logical block is zero-filled when writing (see super_sync()). */
793 /* Always set to 0 when writing. */
794} __packed; 793} __packed;
795 794
796static int read_disk_sb(struct md_rdev *rdev, int size) 795static int read_disk_sb(struct md_rdev *rdev, int size)
@@ -827,7 +826,7 @@ static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
827 test_bit(Faulty, &(rs->dev[i].rdev.flags))) 826 test_bit(Faulty, &(rs->dev[i].rdev.flags)))
828 failed_devices |= (1ULL << i); 827 failed_devices |= (1ULL << i);
829 828
830 memset(sb, 0, sizeof(*sb)); 829 memset(sb + 1, 0, rdev->sb_size - sizeof(*sb));
831 830
832 sb->magic = cpu_to_le32(DM_RAID_MAGIC); 831 sb->magic = cpu_to_le32(DM_RAID_MAGIC);
833 sb->features = cpu_to_le32(0); /* No features yet */ 832 sb->features = cpu_to_le32(0); /* No features yet */
@@ -862,7 +861,11 @@ static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
862 uint64_t events_sb, events_refsb; 861 uint64_t events_sb, events_refsb;
863 862
864 rdev->sb_start = 0; 863 rdev->sb_start = 0;
865 rdev->sb_size = sizeof(*sb); 864 rdev->sb_size = bdev_logical_block_size(rdev->meta_bdev);
865 if (rdev->sb_size < sizeof(*sb) || rdev->sb_size > PAGE_SIZE) {
866 DMERR("superblock size of a logical block is no longer valid");
867 return -EINVAL;
868 }
866 869
867 ret = read_disk_sb(rdev, rdev->sb_size); 870 ret = read_disk_sb(rdev, rdev->sb_size);
868 if (ret) 871 if (ret)
@@ -1169,8 +1172,12 @@ static void configure_discard_support(struct dm_target *ti, struct raid_set *rs)
1169 raid456 = (rs->md.level == 4 || rs->md.level == 5 || rs->md.level == 6); 1172 raid456 = (rs->md.level == 4 || rs->md.level == 5 || rs->md.level == 6);
1170 1173
1171 for (i = 0; i < rs->md.raid_disks; i++) { 1174 for (i = 0; i < rs->md.raid_disks; i++) {
1172 struct request_queue *q = bdev_get_queue(rs->dev[i].rdev.bdev); 1175 struct request_queue *q;
1176
1177 if (!rs->dev[i].rdev.bdev)
1178 continue;
1173 1179
1180 q = bdev_get_queue(rs->dev[i].rdev.bdev);
1174 if (!q || !blk_queue_discard(q)) 1181 if (!q || !blk_queue_discard(q))
1175 return; 1182 return;
1176 1183
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index d1600d2aa2e2..f8b37d4c05d8 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -159,8 +159,10 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
159 sc->stripes_shift = __ffs(stripes); 159 sc->stripes_shift = __ffs(stripes);
160 160
161 r = dm_set_target_max_io_len(ti, chunk_size); 161 r = dm_set_target_max_io_len(ti, chunk_size);
162 if (r) 162 if (r) {
163 kfree(sc);
163 return r; 164 return r;
165 }
164 166
165 ti->num_flush_bios = stripes; 167 ti->num_flush_bios = stripes;
166 ti->num_discard_bios = stripes; 168 ti->num_discard_bios = stripes;
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 4843801173fe..0f86d802b533 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1936,6 +1936,14 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
1936 return DM_MAPIO_SUBMITTED; 1936 return DM_MAPIO_SUBMITTED;
1937 } 1937 }
1938 1938
1939 /*
1940 * We must hold the virtual cell before doing the lookup, otherwise
1941 * there's a race with discard.
1942 */
1943 build_virtual_key(tc->td, block, &key);
1944 if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1, &cell_result))
1945 return DM_MAPIO_SUBMITTED;
1946
1939 r = dm_thin_find_block(td, block, 0, &result); 1947 r = dm_thin_find_block(td, block, 0, &result);
1940 1948
1941 /* 1949 /*
@@ -1959,13 +1967,10 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
1959 * shared flag will be set in their case. 1967 * shared flag will be set in their case.
1960 */ 1968 */
1961 thin_defer_bio(tc, bio); 1969 thin_defer_bio(tc, bio);
1970 cell_defer_no_holder_no_free(tc, &cell1);
1962 return DM_MAPIO_SUBMITTED; 1971 return DM_MAPIO_SUBMITTED;
1963 } 1972 }
1964 1973
1965 build_virtual_key(tc->td, block, &key);
1966 if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1, &cell_result))
1967 return DM_MAPIO_SUBMITTED;
1968
1969 build_data_key(tc->td, result.block, &key); 1974 build_data_key(tc->td, result.block, &key);
1970 if (dm_bio_detain(tc->pool->prison, &key, bio, &cell2, &cell_result)) { 1975 if (dm_bio_detain(tc->pool->prison, &key, bio, &cell2, &cell_result)) {
1971 cell_defer_no_holder_no_free(tc, &cell1); 1976 cell_defer_no_holder_no_free(tc, &cell1);
@@ -1986,6 +1991,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
1986 * of doing so. 1991 * of doing so.
1987 */ 1992 */
1988 handle_unserviceable_bio(tc->pool, bio); 1993 handle_unserviceable_bio(tc->pool, bio);
1994 cell_defer_no_holder_no_free(tc, &cell1);
1989 return DM_MAPIO_SUBMITTED; 1995 return DM_MAPIO_SUBMITTED;
1990 } 1996 }
1991 /* fall through */ 1997 /* fall through */
@@ -1996,6 +2002,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
1996 * provide the hint to load the metadata into cache. 2002 * provide the hint to load the metadata into cache.
1997 */ 2003 */
1998 thin_defer_bio(tc, bio); 2004 thin_defer_bio(tc, bio);
2005 cell_defer_no_holder_no_free(tc, &cell1);
1999 return DM_MAPIO_SUBMITTED; 2006 return DM_MAPIO_SUBMITTED;
2000 2007
2001 default: 2008 default:
@@ -2005,6 +2012,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio)
2005 * pool is switched to fail-io mode. 2012 * pool is switched to fail-io mode.
2006 */ 2013 */
2007 bio_io_error(bio); 2014 bio_io_error(bio);
2015 cell_defer_no_holder_no_free(tc, &cell1);
2008 return DM_MAPIO_SUBMITTED; 2016 return DM_MAPIO_SUBMITTED;
2009 } 2017 }
2010} 2018}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4dfa15da9cb8..9233c71138f1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5121,6 +5121,7 @@ static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
5121 printk("md: %s still in use.\n",mdname(mddev)); 5121 printk("md: %s still in use.\n",mdname(mddev));
5122 if (did_freeze) { 5122 if (did_freeze) {
5123 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 5123 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5124 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
5124 md_wakeup_thread(mddev->thread); 5125 md_wakeup_thread(mddev->thread);
5125 } 5126 }
5126 err = -EBUSY; 5127 err = -EBUSY;
@@ -5135,6 +5136,8 @@ static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
5135 mddev->ro = 1; 5136 mddev->ro = 1;
5136 set_disk_ro(mddev->gendisk, 1); 5137 set_disk_ro(mddev->gendisk, 1);
5137 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 5138 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5139 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
5140 md_wakeup_thread(mddev->thread);
5138 sysfs_notify_dirent_safe(mddev->sysfs_state); 5141 sysfs_notify_dirent_safe(mddev->sysfs_state);
5139 err = 0; 5142 err = 0;
5140 } 5143 }
@@ -5178,6 +5181,7 @@ static int do_md_stop(struct mddev *mddev, int mode,
5178 mutex_unlock(&mddev->open_mutex); 5181 mutex_unlock(&mddev->open_mutex);
5179 if (did_freeze) { 5182 if (did_freeze) {
5180 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 5183 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5184 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
5181 md_wakeup_thread(mddev->thread); 5185 md_wakeup_thread(mddev->thread);
5182 } 5186 }
5183 return -EBUSY; 5187 return -EBUSY;
diff --git a/drivers/md/persistent-data/dm-btree-internal.h b/drivers/md/persistent-data/dm-btree-internal.h
index 37d367bb9aa8..bf2b80d5c470 100644
--- a/drivers/md/persistent-data/dm-btree-internal.h
+++ b/drivers/md/persistent-data/dm-btree-internal.h
@@ -42,6 +42,12 @@ struct btree_node {
42} __packed; 42} __packed;
43 43
44 44
45/*
46 * Locks a block using the btree node validator.
47 */
48int bn_read_lock(struct dm_btree_info *info, dm_block_t b,
49 struct dm_block **result);
50
45void inc_children(struct dm_transaction_manager *tm, struct btree_node *n, 51void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
46 struct dm_btree_value_type *vt); 52 struct dm_btree_value_type *vt);
47 53
diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c
index cf9fd676ae44..1b5e13ec7f96 100644
--- a/drivers/md/persistent-data/dm-btree-spine.c
+++ b/drivers/md/persistent-data/dm-btree-spine.c
@@ -92,7 +92,7 @@ struct dm_block_validator btree_node_validator = {
92 92
93/*----------------------------------------------------------------*/ 93/*----------------------------------------------------------------*/
94 94
95static int bn_read_lock(struct dm_btree_info *info, dm_block_t b, 95int bn_read_lock(struct dm_btree_info *info, dm_block_t b,
96 struct dm_block **result) 96 struct dm_block **result)
97{ 97{
98 return dm_tm_read_lock(info->tm, b, &btree_node_validator, result); 98 return dm_tm_read_lock(info->tm, b, &btree_node_validator, result);
diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c
index 416060c25709..200ac12a1d40 100644
--- a/drivers/md/persistent-data/dm-btree.c
+++ b/drivers/md/persistent-data/dm-btree.c
@@ -847,22 +847,26 @@ EXPORT_SYMBOL_GPL(dm_btree_find_lowest_key);
847 * FIXME: We shouldn't use a recursive algorithm when we have limited stack 847 * FIXME: We shouldn't use a recursive algorithm when we have limited stack
848 * space. Also this only works for single level trees. 848 * space. Also this only works for single level trees.
849 */ 849 */
850static int walk_node(struct ro_spine *s, dm_block_t block, 850static int walk_node(struct dm_btree_info *info, dm_block_t block,
851 int (*fn)(void *context, uint64_t *keys, void *leaf), 851 int (*fn)(void *context, uint64_t *keys, void *leaf),
852 void *context) 852 void *context)
853{ 853{
854 int r; 854 int r;
855 unsigned i, nr; 855 unsigned i, nr;
856 struct dm_block *node;
856 struct btree_node *n; 857 struct btree_node *n;
857 uint64_t keys; 858 uint64_t keys;
858 859
859 r = ro_step(s, block); 860 r = bn_read_lock(info, block, &node);
860 n = ro_node(s); 861 if (r)
862 return r;
863
864 n = dm_block_data(node);
861 865
862 nr = le32_to_cpu(n->header.nr_entries); 866 nr = le32_to_cpu(n->header.nr_entries);
863 for (i = 0; i < nr; i++) { 867 for (i = 0; i < nr; i++) {
864 if (le32_to_cpu(n->header.flags) & INTERNAL_NODE) { 868 if (le32_to_cpu(n->header.flags) & INTERNAL_NODE) {
865 r = walk_node(s, value64(n, i), fn, context); 869 r = walk_node(info, value64(n, i), fn, context);
866 if (r) 870 if (r)
867 goto out; 871 goto out;
868 } else { 872 } else {
@@ -874,7 +878,7 @@ static int walk_node(struct ro_spine *s, dm_block_t block,
874 } 878 }
875 879
876out: 880out:
877 ro_pop(s); 881 dm_tm_unlock(info->tm, node);
878 return r; 882 return r;
879} 883}
880 884
@@ -882,15 +886,7 @@ int dm_btree_walk(struct dm_btree_info *info, dm_block_t root,
882 int (*fn)(void *context, uint64_t *keys, void *leaf), 886 int (*fn)(void *context, uint64_t *keys, void *leaf),
883 void *context) 887 void *context)
884{ 888{
885 int r;
886 struct ro_spine spine;
887
888 BUG_ON(info->levels > 1); 889 BUG_ON(info->levels > 1);
889 890 return walk_node(info, root, fn, context);
890 init_ro_spine(&spine, info);
891 r = walk_node(&spine, root, fn, context);
892 exit_ro_spine(&spine);
893
894 return r;
895} 891}
896EXPORT_SYMBOL_GPL(dm_btree_walk); 892EXPORT_SYMBOL_GPL(dm_btree_walk);
diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index cf008f45968c..711773e8e64b 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -240,7 +240,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
240 goto err_irq_charger; 240 goto err_irq_charger;
241 } 241 }
242 242
243 ret = regmap_add_irq_chip(max77693->regmap, max77693->irq, 243 ret = regmap_add_irq_chip(max77693->regmap_muic, max77693->irq,
244 IRQF_ONESHOT | IRQF_SHARED | 244 IRQF_ONESHOT | IRQF_SHARED |
245 IRQF_TRIGGER_FALLING, 0, 245 IRQF_TRIGGER_FALLING, 0,
246 &max77693_muic_irq_chip, 246 &max77693_muic_irq_chip,
@@ -250,6 +250,17 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
250 goto err_irq_muic; 250 goto err_irq_muic;
251 } 251 }
252 252
253 /* Unmask interrupts from all blocks in interrupt source register */
254 ret = regmap_update_bits(max77693->regmap,
255 MAX77693_PMIC_REG_INTSRC_MASK,
256 SRC_IRQ_ALL, (unsigned int)~SRC_IRQ_ALL);
257 if (ret < 0) {
258 dev_err(max77693->dev,
259 "Could not unmask interrupts in INTSRC: %d\n",
260 ret);
261 goto err_intsrc;
262 }
263
253 pm_runtime_set_active(max77693->dev); 264 pm_runtime_set_active(max77693->dev);
254 265
255 ret = mfd_add_devices(max77693->dev, -1, max77693_devs, 266 ret = mfd_add_devices(max77693->dev, -1, max77693_devs,
@@ -261,6 +272,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
261 272
262err_mfd: 273err_mfd:
263 mfd_remove_devices(max77693->dev); 274 mfd_remove_devices(max77693->dev);
275err_intsrc:
264 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic); 276 regmap_del_irq_chip(max77693->irq, max77693->irq_data_muic);
265err_irq_muic: 277err_irq_muic:
266 regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger); 278 regmap_del_irq_chip(max77693->irq, max77693->irq_data_charger);
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index f2643c221d34..30f7ca89a0e6 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -947,6 +947,7 @@ static void rtsx_pci_idle_work(struct work_struct *work)
947 mutex_unlock(&pcr->pcr_mutex); 947 mutex_unlock(&pcr->pcr_mutex);
948} 948}
949 949
950#ifdef CONFIG_PM
950static void rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state) 951static void rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
951{ 952{
952 if (pcr->ops->turn_off_led) 953 if (pcr->ops->turn_off_led)
@@ -961,6 +962,7 @@ static void rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
961 if (pcr->ops->force_power_down) 962 if (pcr->ops->force_power_down)
962 pcr->ops->force_power_down(pcr, pm_state); 963 pcr->ops->force_power_down(pcr, pm_state);
963} 964}
965#endif
964 966
965static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) 967static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
966{ 968{
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index 2d045f26f193..bee0abf82040 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -269,7 +269,7 @@ int stmpe_remove(struct stmpe *stmpe);
269#define STMPE24XX_REG_CHIP_ID 0x80 269#define STMPE24XX_REG_CHIP_ID 0x80
270#define STMPE24XX_REG_IEGPIOR_LSB 0x18 270#define STMPE24XX_REG_IEGPIOR_LSB 0x18
271#define STMPE24XX_REG_ISGPIOR_MSB 0x19 271#define STMPE24XX_REG_ISGPIOR_MSB 0x19
272#define STMPE24XX_REG_GPMR_LSB 0xA5 272#define STMPE24XX_REG_GPMR_LSB 0xA4
273#define STMPE24XX_REG_GPSR_LSB 0x85 273#define STMPE24XX_REG_GPSR_LSB 0x85
274#define STMPE24XX_REG_GPCR_LSB 0x88 274#define STMPE24XX_REG_GPCR_LSB 0x88
275#define STMPE24XX_REG_GPDR_LSB 0x8B 275#define STMPE24XX_REG_GPDR_LSB 0x8B
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index cf92a6d1c532..50f9091bcd38 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -44,6 +44,15 @@ static u8 twl4030_start_script_address = 0x2b;
44#define PWR_DEVSLP BIT(1) 44#define PWR_DEVSLP BIT(1)
45#define PWR_DEVOFF BIT(0) 45#define PWR_DEVOFF BIT(0)
46 46
47/* Register bits for CFG_P1_TRANSITION (also for P2 and P3) */
48#define STARTON_SWBUG BIT(7) /* Start on watchdog */
49#define STARTON_VBUS BIT(5) /* Start on VBUS */
50#define STARTON_VBAT BIT(4) /* Start on battery insert */
51#define STARTON_RTC BIT(3) /* Start on RTC */
52#define STARTON_USB BIT(2) /* Start on USB host */
53#define STARTON_CHG BIT(1) /* Start on charger */
54#define STARTON_PWON BIT(0) /* Start on PWRON button */
55
47#define SEQ_OFFSYNC (1 << 0) 56#define SEQ_OFFSYNC (1 << 0)
48 57
49#define PHY_TO_OFF_PM_MASTER(p) (p - 0x36) 58#define PHY_TO_OFF_PM_MASTER(p) (p - 0x36)
@@ -606,6 +615,44 @@ twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
606 return 0; 615 return 0;
607} 616}
608 617
618static int twl4030_starton_mask_and_set(u8 bitmask, u8 bitvalues)
619{
620 u8 regs[3] = { TWL4030_PM_MASTER_CFG_P1_TRANSITION,
621 TWL4030_PM_MASTER_CFG_P2_TRANSITION,
622 TWL4030_PM_MASTER_CFG_P3_TRANSITION, };
623 u8 val;
624 int i, err;
625
626 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1,
627 TWL4030_PM_MASTER_PROTECT_KEY);
628 if (err)
629 goto relock;
630 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
631 TWL4030_PM_MASTER_KEY_CFG2,
632 TWL4030_PM_MASTER_PROTECT_KEY);
633 if (err)
634 goto relock;
635
636 for (i = 0; i < sizeof(regs); i++) {
637 err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER,
638 &val, regs[i]);
639 if (err)
640 break;
641 val = (~bitmask & val) | (bitmask & bitvalues);
642 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER,
643 val, regs[i]);
644 if (err)
645 break;
646 }
647
648 if (err)
649 pr_err("TWL4030 Register access failed: %i\n", err);
650
651relock:
652 return twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0,
653 TWL4030_PM_MASTER_PROTECT_KEY);
654}
655
609/* 656/*
610 * In master mode, start the power off sequence. 657 * In master mode, start the power off sequence.
611 * After a successful execution, TWL shuts down the power to the SoC 658 * After a successful execution, TWL shuts down the power to the SoC
@@ -615,6 +662,11 @@ void twl4030_power_off(void)
615{ 662{
616 int err; 663 int err;
617 664
665 /* Disable start on charger or VBUS as it can break poweroff */
666 err = twl4030_starton_mask_and_set(STARTON_VBUS | STARTON_CHG, 0);
667 if (err)
668 pr_err("TWL4030 Unable to configure start-up\n");
669
618 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF, 670 err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF,
619 TWL4030_PM_MASTER_P1_SW_EVENTS); 671 TWL4030_PM_MASTER_P1_SW_EVENTS);
620 if (err) 672 if (err)
diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c
index e00f5340ed87..3c2b8f9e3c84 100644
--- a/drivers/mfd/viperboard.c
+++ b/drivers/mfd/viperboard.c
@@ -93,8 +93,9 @@ static int vprbrd_probe(struct usb_interface *interface,
93 version >> 8, version & 0xff, 93 version >> 8, version & 0xff,
94 vb->usb_dev->bus->busnum, vb->usb_dev->devnum); 94 vb->usb_dev->bus->busnum, vb->usb_dev->devnum);
95 95
96 ret = mfd_add_devices(&interface->dev, -1, vprbrd_devs, 96 ret = mfd_add_devices(&interface->dev, PLATFORM_DEVID_AUTO,
97 ARRAY_SIZE(vprbrd_devs), NULL, 0, NULL); 97 vprbrd_devs, ARRAY_SIZE(vprbrd_devs), NULL, 0,
98 NULL);
98 if (ret != 0) { 99 if (ret != 0) {
99 dev_err(&interface->dev, "Failed to add mfd devices to core."); 100 dev_err(&interface->dev, "Failed to add mfd devices to core.");
100 goto error; 101 goto error;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c9ac06cfe6b7..a5115fb7cf33 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2471,7 +2471,8 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)
2471 bond_slave_state_change(bond); 2471 bond_slave_state_change(bond);
2472 if (BOND_MODE(bond) == BOND_MODE_XOR) 2472 if (BOND_MODE(bond) == BOND_MODE_XOR)
2473 bond_update_slave_arr(bond, NULL); 2473 bond_update_slave_arr(bond, NULL);
2474 } else if (do_failover) { 2474 }
2475 if (do_failover) {
2475 block_netpoll_tx(); 2476 block_netpoll_tx();
2476 bond_select_active_slave(bond); 2477 bond_select_active_slave(bond);
2477 unblock_netpoll_tx(); 2478 unblock_netpoll_tx();
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 02492d241e4c..2cfe5012e4e5 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -110,7 +110,7 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt,
110 long rate; 110 long rate;
111 u64 v64; 111 u64 v64;
112 112
113 /* Use CIA recommended sample points */ 113 /* Use CiA recommended sample points */
114 if (bt->sample_point) { 114 if (bt->sample_point) {
115 sampl_pt = bt->sample_point; 115 sampl_pt = bt->sample_point;
116 } else { 116 } else {
@@ -382,7 +382,7 @@ void can_free_echo_skb(struct net_device *dev, unsigned int idx)
382 BUG_ON(idx >= priv->echo_skb_max); 382 BUG_ON(idx >= priv->echo_skb_max);
383 383
384 if (priv->echo_skb[idx]) { 384 if (priv->echo_skb[idx]) {
385 kfree_skb(priv->echo_skb[idx]); 385 dev_kfree_skb_any(priv->echo_skb[idx]);
386 priv->echo_skb[idx] = NULL; 386 priv->echo_skb[idx] = NULL;
387 } 387 }
388} 388}
diff --git a/drivers/net/can/m_can/Kconfig b/drivers/net/can/m_can/Kconfig
index fca5482c09ac..04f20dd39007 100644
--- a/drivers/net/can/m_can/Kconfig
+++ b/drivers/net/can/m_can/Kconfig
@@ -1,4 +1,5 @@
1config CAN_M_CAN 1config CAN_M_CAN
2 depends on HAS_IOMEM
2 tristate "Bosch M_CAN devices" 3 tristate "Bosch M_CAN devices"
3 ---help--- 4 ---help---
4 Say Y here if you want to support for Bosch M_CAN controller. 5 Say Y here if you want to support for Bosch M_CAN controller.
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 10d571eaed85..d7bc462aafdc 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -105,14 +105,36 @@ enum m_can_mram_cfg {
105 MRAM_CFG_NUM, 105 MRAM_CFG_NUM,
106}; 106};
107 107
108/* Fast Bit Timing & Prescaler Register (FBTP) */
109#define FBTR_FBRP_MASK 0x1f
110#define FBTR_FBRP_SHIFT 16
111#define FBTR_FTSEG1_SHIFT 8
112#define FBTR_FTSEG1_MASK (0xf << FBTR_FTSEG1_SHIFT)
113#define FBTR_FTSEG2_SHIFT 4
114#define FBTR_FTSEG2_MASK (0x7 << FBTR_FTSEG2_SHIFT)
115#define FBTR_FSJW_SHIFT 0
116#define FBTR_FSJW_MASK 0x3
117
108/* Test Register (TEST) */ 118/* Test Register (TEST) */
109#define TEST_LBCK BIT(4) 119#define TEST_LBCK BIT(4)
110 120
111/* CC Control Register(CCCR) */ 121/* CC Control Register(CCCR) */
112#define CCCR_TEST BIT(7) 122#define CCCR_TEST BIT(7)
113#define CCCR_MON BIT(5) 123#define CCCR_CMR_MASK 0x3
114#define CCCR_CCE BIT(1) 124#define CCCR_CMR_SHIFT 10
115#define CCCR_INIT BIT(0) 125#define CCCR_CMR_CANFD 0x1
126#define CCCR_CMR_CANFD_BRS 0x2
127#define CCCR_CMR_CAN 0x3
128#define CCCR_CME_MASK 0x3
129#define CCCR_CME_SHIFT 8
130#define CCCR_CME_CAN 0
131#define CCCR_CME_CANFD 0x1
132#define CCCR_CME_CANFD_BRS 0x2
133#define CCCR_TEST BIT(7)
134#define CCCR_MON BIT(5)
135#define CCCR_CCE BIT(1)
136#define CCCR_INIT BIT(0)
137#define CCCR_CANFD 0x10
116 138
117/* Bit Timing & Prescaler Register (BTP) */ 139/* Bit Timing & Prescaler Register (BTP) */
118#define BTR_BRP_MASK 0x3ff 140#define BTR_BRP_MASK 0x3ff
@@ -204,6 +226,7 @@ enum m_can_mram_cfg {
204 226
205/* Rx Buffer / FIFO Element Size Configuration (RXESC) */ 227/* Rx Buffer / FIFO Element Size Configuration (RXESC) */
206#define M_CAN_RXESC_8BYTES 0x0 228#define M_CAN_RXESC_8BYTES 0x0
229#define M_CAN_RXESC_64BYTES 0x777
207 230
208/* Tx Buffer Configuration(TXBC) */ 231/* Tx Buffer Configuration(TXBC) */
209#define TXBC_NDTB_OFF 16 232#define TXBC_NDTB_OFF 16
@@ -211,6 +234,7 @@ enum m_can_mram_cfg {
211 234
212/* Tx Buffer Element Size Configuration(TXESC) */ 235/* Tx Buffer Element Size Configuration(TXESC) */
213#define TXESC_TBDS_8BYTES 0x0 236#define TXESC_TBDS_8BYTES 0x0
237#define TXESC_TBDS_64BYTES 0x7
214 238
215/* Tx Event FIFO Con.guration (TXEFC) */ 239/* Tx Event FIFO Con.guration (TXEFC) */
216#define TXEFC_EFS_OFF 16 240#define TXEFC_EFS_OFF 16
@@ -219,11 +243,11 @@ enum m_can_mram_cfg {
219/* Message RAM Configuration (in bytes) */ 243/* Message RAM Configuration (in bytes) */
220#define SIDF_ELEMENT_SIZE 4 244#define SIDF_ELEMENT_SIZE 4
221#define XIDF_ELEMENT_SIZE 8 245#define XIDF_ELEMENT_SIZE 8
222#define RXF0_ELEMENT_SIZE 16 246#define RXF0_ELEMENT_SIZE 72
223#define RXF1_ELEMENT_SIZE 16 247#define RXF1_ELEMENT_SIZE 72
224#define RXB_ELEMENT_SIZE 16 248#define RXB_ELEMENT_SIZE 16
225#define TXE_ELEMENT_SIZE 8 249#define TXE_ELEMENT_SIZE 8
226#define TXB_ELEMENT_SIZE 16 250#define TXB_ELEMENT_SIZE 72
227 251
228/* Message RAM Elements */ 252/* Message RAM Elements */
229#define M_CAN_FIFO_ID 0x0 253#define M_CAN_FIFO_ID 0x0
@@ -231,11 +255,17 @@ enum m_can_mram_cfg {
231#define M_CAN_FIFO_DATA(n) (0x8 + ((n) << 2)) 255#define M_CAN_FIFO_DATA(n) (0x8 + ((n) << 2))
232 256
233/* Rx Buffer Element */ 257/* Rx Buffer Element */
258/* R0 */
234#define RX_BUF_ESI BIT(31) 259#define RX_BUF_ESI BIT(31)
235#define RX_BUF_XTD BIT(30) 260#define RX_BUF_XTD BIT(30)
236#define RX_BUF_RTR BIT(29) 261#define RX_BUF_RTR BIT(29)
262/* R1 */
263#define RX_BUF_ANMF BIT(31)
264#define RX_BUF_EDL BIT(21)
265#define RX_BUF_BRS BIT(20)
237 266
238/* Tx Buffer Element */ 267/* Tx Buffer Element */
268/* R0 */
239#define TX_BUF_XTD BIT(30) 269#define TX_BUF_XTD BIT(30)
240#define TX_BUF_RTR BIT(29) 270#define TX_BUF_RTR BIT(29)
241 271
@@ -296,6 +326,7 @@ static inline void m_can_config_endisable(const struct m_can_priv *priv,
296 if (enable) { 326 if (enable) {
297 /* enable m_can configuration */ 327 /* enable m_can configuration */
298 m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT); 328 m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT);
329 udelay(5);
299 /* CCCR.CCE can only be set/reset while CCCR.INIT = '1' */ 330 /* CCCR.CCE can only be set/reset while CCCR.INIT = '1' */
300 m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT | CCCR_CCE); 331 m_can_write(priv, M_CAN_CCCR, cccr | CCCR_INIT | CCCR_CCE);
301 } else { 332 } else {
@@ -326,41 +357,67 @@ static inline void m_can_disable_all_interrupts(const struct m_can_priv *priv)
326 m_can_write(priv, M_CAN_ILE, 0x0); 357 m_can_write(priv, M_CAN_ILE, 0x0);
327} 358}
328 359
329static void m_can_read_fifo(const struct net_device *dev, struct can_frame *cf, 360static void m_can_read_fifo(struct net_device *dev, u32 rxfs)
330 u32 rxfs)
331{ 361{
362 struct net_device_stats *stats = &dev->stats;
332 struct m_can_priv *priv = netdev_priv(dev); 363 struct m_can_priv *priv = netdev_priv(dev);
333 u32 id, fgi; 364 struct canfd_frame *cf;
365 struct sk_buff *skb;
366 u32 id, fgi, dlc;
367 int i;
334 368
335 /* calculate the fifo get index for where to read data */ 369 /* calculate the fifo get index for where to read data */
336 fgi = (rxfs & RXFS_FGI_MASK) >> RXFS_FGI_OFF; 370 fgi = (rxfs & RXFS_FGI_MASK) >> RXFS_FGI_OFF;
371 dlc = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC);
372 if (dlc & RX_BUF_EDL)
373 skb = alloc_canfd_skb(dev, &cf);
374 else
375 skb = alloc_can_skb(dev, (struct can_frame **)&cf);
376 if (!skb) {
377 stats->rx_dropped++;
378 return;
379 }
380
381 if (dlc & RX_BUF_EDL)
382 cf->len = can_dlc2len((dlc >> 16) & 0x0F);
383 else
384 cf->len = get_can_dlc((dlc >> 16) & 0x0F);
385
337 id = m_can_fifo_read(priv, fgi, M_CAN_FIFO_ID); 386 id = m_can_fifo_read(priv, fgi, M_CAN_FIFO_ID);
338 if (id & RX_BUF_XTD) 387 if (id & RX_BUF_XTD)
339 cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG; 388 cf->can_id = (id & CAN_EFF_MASK) | CAN_EFF_FLAG;
340 else 389 else
341 cf->can_id = (id >> 18) & CAN_SFF_MASK; 390 cf->can_id = (id >> 18) & CAN_SFF_MASK;
342 391
343 if (id & RX_BUF_RTR) { 392 if (id & RX_BUF_ESI) {
393 cf->flags |= CANFD_ESI;
394 netdev_dbg(dev, "ESI Error\n");
395 }
396
397 if (!(dlc & RX_BUF_EDL) && (id & RX_BUF_RTR)) {
344 cf->can_id |= CAN_RTR_FLAG; 398 cf->can_id |= CAN_RTR_FLAG;
345 } else { 399 } else {
346 id = m_can_fifo_read(priv, fgi, M_CAN_FIFO_DLC); 400 if (dlc & RX_BUF_BRS)
347 cf->can_dlc = get_can_dlc((id >> 16) & 0x0F); 401 cf->flags |= CANFD_BRS;
348 *(u32 *)(cf->data + 0) = m_can_fifo_read(priv, fgi, 402
349 M_CAN_FIFO_DATA(0)); 403 for (i = 0; i < cf->len; i += 4)
350 *(u32 *)(cf->data + 4) = m_can_fifo_read(priv, fgi, 404 *(u32 *)(cf->data + i) =
351 M_CAN_FIFO_DATA(1)); 405 m_can_fifo_read(priv, fgi,
406 M_CAN_FIFO_DATA(i / 4));
352 } 407 }
353 408
354 /* acknowledge rx fifo 0 */ 409 /* acknowledge rx fifo 0 */
355 m_can_write(priv, M_CAN_RXF0A, fgi); 410 m_can_write(priv, M_CAN_RXF0A, fgi);
411
412 stats->rx_packets++;
413 stats->rx_bytes += cf->len;
414
415 netif_receive_skb(skb);
356} 416}
357 417
358static int m_can_do_rx_poll(struct net_device *dev, int quota) 418static int m_can_do_rx_poll(struct net_device *dev, int quota)
359{ 419{
360 struct m_can_priv *priv = netdev_priv(dev); 420 struct m_can_priv *priv = netdev_priv(dev);
361 struct net_device_stats *stats = &dev->stats;
362 struct sk_buff *skb;
363 struct can_frame *frame;
364 u32 pkts = 0; 421 u32 pkts = 0;
365 u32 rxfs; 422 u32 rxfs;
366 423
@@ -374,18 +431,7 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
374 if (rxfs & RXFS_RFL) 431 if (rxfs & RXFS_RFL)
375 netdev_warn(dev, "Rx FIFO 0 Message Lost\n"); 432 netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
376 433
377 skb = alloc_can_skb(dev, &frame); 434 m_can_read_fifo(dev, rxfs);
378 if (!skb) {
379 stats->rx_dropped++;
380 return pkts;
381 }
382
383 m_can_read_fifo(dev, frame, rxfs);
384
385 stats->rx_packets++;
386 stats->rx_bytes += frame->can_dlc;
387
388 netif_receive_skb(skb);
389 435
390 quota--; 436 quota--;
391 pkts++; 437 pkts++;
@@ -481,11 +527,23 @@ static int m_can_handle_lec_err(struct net_device *dev,
481 return 1; 527 return 1;
482} 528}
483 529
530static int __m_can_get_berr_counter(const struct net_device *dev,
531 struct can_berr_counter *bec)
532{
533 struct m_can_priv *priv = netdev_priv(dev);
534 unsigned int ecr;
535
536 ecr = m_can_read(priv, M_CAN_ECR);
537 bec->rxerr = (ecr & ECR_REC_MASK) >> ECR_REC_SHIFT;
538 bec->txerr = ecr & ECR_TEC_MASK;
539
540 return 0;
541}
542
484static int m_can_get_berr_counter(const struct net_device *dev, 543static int m_can_get_berr_counter(const struct net_device *dev,
485 struct can_berr_counter *bec) 544 struct can_berr_counter *bec)
486{ 545{
487 struct m_can_priv *priv = netdev_priv(dev); 546 struct m_can_priv *priv = netdev_priv(dev);
488 unsigned int ecr;
489 int err; 547 int err;
490 548
491 err = clk_prepare_enable(priv->hclk); 549 err = clk_prepare_enable(priv->hclk);
@@ -498,9 +556,7 @@ static int m_can_get_berr_counter(const struct net_device *dev,
498 return err; 556 return err;
499 } 557 }
500 558
501 ecr = m_can_read(priv, M_CAN_ECR); 559 __m_can_get_berr_counter(dev, bec);
502 bec->rxerr = (ecr & ECR_REC_MASK) >> ECR_REC_SHIFT;
503 bec->txerr = ecr & ECR_TEC_MASK;
504 560
505 clk_disable_unprepare(priv->cclk); 561 clk_disable_unprepare(priv->cclk);
506 clk_disable_unprepare(priv->hclk); 562 clk_disable_unprepare(priv->hclk);
@@ -544,7 +600,7 @@ static int m_can_handle_state_change(struct net_device *dev,
544 if (unlikely(!skb)) 600 if (unlikely(!skb))
545 return 0; 601 return 0;
546 602
547 m_can_get_berr_counter(dev, &bec); 603 __m_can_get_berr_counter(dev, &bec);
548 604
549 switch (new_state) { 605 switch (new_state) {
550 case CAN_STATE_ERROR_ACTIVE: 606 case CAN_STATE_ERROR_ACTIVE:
@@ -596,14 +652,14 @@ static int m_can_handle_state_errors(struct net_device *dev, u32 psr)
596 652
597 if ((psr & PSR_EP) && 653 if ((psr & PSR_EP) &&
598 (priv->can.state != CAN_STATE_ERROR_PASSIVE)) { 654 (priv->can.state != CAN_STATE_ERROR_PASSIVE)) {
599 netdev_dbg(dev, "entered error warning state\n"); 655 netdev_dbg(dev, "entered error passive state\n");
600 work_done += m_can_handle_state_change(dev, 656 work_done += m_can_handle_state_change(dev,
601 CAN_STATE_ERROR_PASSIVE); 657 CAN_STATE_ERROR_PASSIVE);
602 } 658 }
603 659
604 if ((psr & PSR_BO) && 660 if ((psr & PSR_BO) &&
605 (priv->can.state != CAN_STATE_BUS_OFF)) { 661 (priv->can.state != CAN_STATE_BUS_OFF)) {
606 netdev_dbg(dev, "entered error warning state\n"); 662 netdev_dbg(dev, "entered error bus off state\n");
607 work_done += m_can_handle_state_change(dev, 663 work_done += m_can_handle_state_change(dev,
608 CAN_STATE_BUS_OFF); 664 CAN_STATE_BUS_OFF);
609 } 665 }
@@ -615,7 +671,7 @@ static void m_can_handle_other_err(struct net_device *dev, u32 irqstatus)
615{ 671{
616 if (irqstatus & IR_WDI) 672 if (irqstatus & IR_WDI)
617 netdev_err(dev, "Message RAM Watchdog event due to missing READY\n"); 673 netdev_err(dev, "Message RAM Watchdog event due to missing READY\n");
618 if (irqstatus & IR_BEU) 674 if (irqstatus & IR_ELO)
619 netdev_err(dev, "Error Logging Overflow\n"); 675 netdev_err(dev, "Error Logging Overflow\n");
620 if (irqstatus & IR_BEU) 676 if (irqstatus & IR_BEU)
621 netdev_err(dev, "Bit Error Uncorrected\n"); 677 netdev_err(dev, "Bit Error Uncorrected\n");
@@ -733,10 +789,23 @@ static const struct can_bittiming_const m_can_bittiming_const = {
733 .brp_inc = 1, 789 .brp_inc = 1,
734}; 790};
735 791
792static const struct can_bittiming_const m_can_data_bittiming_const = {
793 .name = KBUILD_MODNAME,
794 .tseg1_min = 2, /* Time segment 1 = prop_seg + phase_seg1 */
795 .tseg1_max = 16,
796 .tseg2_min = 1, /* Time segment 2 = phase_seg2 */
797 .tseg2_max = 8,
798 .sjw_max = 4,
799 .brp_min = 1,
800 .brp_max = 32,
801 .brp_inc = 1,
802};
803
736static int m_can_set_bittiming(struct net_device *dev) 804static int m_can_set_bittiming(struct net_device *dev)
737{ 805{
738 struct m_can_priv *priv = netdev_priv(dev); 806 struct m_can_priv *priv = netdev_priv(dev);
739 const struct can_bittiming *bt = &priv->can.bittiming; 807 const struct can_bittiming *bt = &priv->can.bittiming;
808 const struct can_bittiming *dbt = &priv->can.data_bittiming;
740 u16 brp, sjw, tseg1, tseg2; 809 u16 brp, sjw, tseg1, tseg2;
741 u32 reg_btp; 810 u32 reg_btp;
742 811
@@ -747,7 +816,17 @@ static int m_can_set_bittiming(struct net_device *dev)
747 reg_btp = (brp << BTR_BRP_SHIFT) | (sjw << BTR_SJW_SHIFT) | 816 reg_btp = (brp << BTR_BRP_SHIFT) | (sjw << BTR_SJW_SHIFT) |
748 (tseg1 << BTR_TSEG1_SHIFT) | (tseg2 << BTR_TSEG2_SHIFT); 817 (tseg1 << BTR_TSEG1_SHIFT) | (tseg2 << BTR_TSEG2_SHIFT);
749 m_can_write(priv, M_CAN_BTP, reg_btp); 818 m_can_write(priv, M_CAN_BTP, reg_btp);
750 netdev_dbg(dev, "setting BTP 0x%x\n", reg_btp); 819
820 if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
821 brp = dbt->brp - 1;
822 sjw = dbt->sjw - 1;
823 tseg1 = dbt->prop_seg + dbt->phase_seg1 - 1;
824 tseg2 = dbt->phase_seg2 - 1;
825 reg_btp = (brp << FBTR_FBRP_SHIFT) | (sjw << FBTR_FSJW_SHIFT) |
826 (tseg1 << FBTR_FTSEG1_SHIFT) |
827 (tseg2 << FBTR_FTSEG2_SHIFT);
828 m_can_write(priv, M_CAN_FBTP, reg_btp);
829 }
751 830
752 return 0; 831 return 0;
753} 832}
@@ -767,8 +846,8 @@ static void m_can_chip_config(struct net_device *dev)
767 846
768 m_can_config_endisable(priv, true); 847 m_can_config_endisable(priv, true);
769 848
770 /* RX Buffer/FIFO Element Size 8 bytes data field */ 849 /* RX Buffer/FIFO Element Size 64 bytes data field */
771 m_can_write(priv, M_CAN_RXESC, M_CAN_RXESC_8BYTES); 850 m_can_write(priv, M_CAN_RXESC, M_CAN_RXESC_64BYTES);
772 851
773 /* Accept Non-matching Frames Into FIFO 0 */ 852 /* Accept Non-matching Frames Into FIFO 0 */
774 m_can_write(priv, M_CAN_GFC, 0x0); 853 m_can_write(priv, M_CAN_GFC, 0x0);
@@ -777,8 +856,8 @@ static void m_can_chip_config(struct net_device *dev)
777 m_can_write(priv, M_CAN_TXBC, (1 << TXBC_NDTB_OFF) | 856 m_can_write(priv, M_CAN_TXBC, (1 << TXBC_NDTB_OFF) |
778 priv->mcfg[MRAM_TXB].off); 857 priv->mcfg[MRAM_TXB].off);
779 858
780 /* only support 8 bytes firstly */ 859 /* support 64 bytes payload */
781 m_can_write(priv, M_CAN_TXESC, TXESC_TBDS_8BYTES); 860 m_can_write(priv, M_CAN_TXESC, TXESC_TBDS_64BYTES);
782 861
783 m_can_write(priv, M_CAN_TXEFC, (1 << TXEFC_EFS_OFF) | 862 m_can_write(priv, M_CAN_TXEFC, (1 << TXEFC_EFS_OFF) |
784 priv->mcfg[MRAM_TXE].off); 863 priv->mcfg[MRAM_TXE].off);
@@ -793,7 +872,8 @@ static void m_can_chip_config(struct net_device *dev)
793 RXFC_FWM_1 | priv->mcfg[MRAM_RXF1].off); 872 RXFC_FWM_1 | priv->mcfg[MRAM_RXF1].off);
794 873
795 cccr = m_can_read(priv, M_CAN_CCCR); 874 cccr = m_can_read(priv, M_CAN_CCCR);
796 cccr &= ~(CCCR_TEST | CCCR_MON); 875 cccr &= ~(CCCR_TEST | CCCR_MON | (CCCR_CMR_MASK << CCCR_CMR_SHIFT) |
876 (CCCR_CME_MASK << CCCR_CME_SHIFT));
797 test = m_can_read(priv, M_CAN_TEST); 877 test = m_can_read(priv, M_CAN_TEST);
798 test &= ~TEST_LBCK; 878 test &= ~TEST_LBCK;
799 879
@@ -805,6 +885,9 @@ static void m_can_chip_config(struct net_device *dev)
805 test |= TEST_LBCK; 885 test |= TEST_LBCK;
806 } 886 }
807 887
888 if (priv->can.ctrlmode & CAN_CTRLMODE_FD)
889 cccr |= CCCR_CME_CANFD_BRS << CCCR_CME_SHIFT;
890
808 m_can_write(priv, M_CAN_CCCR, cccr); 891 m_can_write(priv, M_CAN_CCCR, cccr);
809 m_can_write(priv, M_CAN_TEST, test); 892 m_can_write(priv, M_CAN_TEST, test);
810 893
@@ -869,11 +952,13 @@ static struct net_device *alloc_m_can_dev(void)
869 952
870 priv->dev = dev; 953 priv->dev = dev;
871 priv->can.bittiming_const = &m_can_bittiming_const; 954 priv->can.bittiming_const = &m_can_bittiming_const;
955 priv->can.data_bittiming_const = &m_can_data_bittiming_const;
872 priv->can.do_set_mode = m_can_set_mode; 956 priv->can.do_set_mode = m_can_set_mode;
873 priv->can.do_get_berr_counter = m_can_get_berr_counter; 957 priv->can.do_get_berr_counter = m_can_get_berr_counter;
874 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | 958 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
875 CAN_CTRLMODE_LISTENONLY | 959 CAN_CTRLMODE_LISTENONLY |
876 CAN_CTRLMODE_BERR_REPORTING; 960 CAN_CTRLMODE_BERR_REPORTING |
961 CAN_CTRLMODE_FD;
877 962
878 return dev; 963 return dev;
879} 964}
@@ -956,8 +1041,9 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,
956 struct net_device *dev) 1041 struct net_device *dev)
957{ 1042{
958 struct m_can_priv *priv = netdev_priv(dev); 1043 struct m_can_priv *priv = netdev_priv(dev);
959 struct can_frame *cf = (struct can_frame *)skb->data; 1044 struct canfd_frame *cf = (struct canfd_frame *)skb->data;
960 u32 id; 1045 u32 id, cccr;
1046 int i;
961 1047
962 if (can_dropped_invalid_skb(dev, skb)) 1048 if (can_dropped_invalid_skb(dev, skb))
963 return NETDEV_TX_OK; 1049 return NETDEV_TX_OK;
@@ -976,11 +1062,28 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,
976 1062
977 /* message ram configuration */ 1063 /* message ram configuration */
978 m_can_fifo_write(priv, 0, M_CAN_FIFO_ID, id); 1064 m_can_fifo_write(priv, 0, M_CAN_FIFO_ID, id);
979 m_can_fifo_write(priv, 0, M_CAN_FIFO_DLC, cf->can_dlc << 16); 1065 m_can_fifo_write(priv, 0, M_CAN_FIFO_DLC, can_len2dlc(cf->len) << 16);
980 m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(0), *(u32 *)(cf->data + 0)); 1066
981 m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(1), *(u32 *)(cf->data + 4)); 1067 for (i = 0; i < cf->len; i += 4)
1068 m_can_fifo_write(priv, 0, M_CAN_FIFO_DATA(i / 4),
1069 *(u32 *)(cf->data + i));
1070
982 can_put_echo_skb(skb, dev, 0); 1071 can_put_echo_skb(skb, dev, 0);
983 1072
1073 if (priv->can.ctrlmode & CAN_CTRLMODE_FD) {
1074 cccr = m_can_read(priv, M_CAN_CCCR);
1075 cccr &= ~(CCCR_CMR_MASK << CCCR_CMR_SHIFT);
1076 if (can_is_canfd_skb(skb)) {
1077 if (cf->flags & CANFD_BRS)
1078 cccr |= CCCR_CMR_CANFD_BRS << CCCR_CMR_SHIFT;
1079 else
1080 cccr |= CCCR_CMR_CANFD << CCCR_CMR_SHIFT;
1081 } else {
1082 cccr |= CCCR_CMR_CAN << CCCR_CMR_SHIFT;
1083 }
1084 m_can_write(priv, M_CAN_CCCR, cccr);
1085 }
1086
984 /* enable first TX buffer to start transfer */ 1087 /* enable first TX buffer to start transfer */
985 m_can_write(priv, M_CAN_TXBTIE, 0x1); 1088 m_can_write(priv, M_CAN_TXBTIE, 0x1);
986 m_can_write(priv, M_CAN_TXBAR, 0x1); 1089 m_can_write(priv, M_CAN_TXBAR, 0x1);
@@ -992,6 +1095,7 @@ static const struct net_device_ops m_can_netdev_ops = {
992 .ndo_open = m_can_open, 1095 .ndo_open = m_can_open,
993 .ndo_stop = m_can_close, 1096 .ndo_stop = m_can_close,
994 .ndo_start_xmit = m_can_start_xmit, 1097 .ndo_start_xmit = m_can_start_xmit,
1098 .ndo_change_mtu = can_change_mtu,
995}; 1099};
996 1100
997static int register_m_can_dev(struct net_device *dev) 1101static int register_m_can_dev(struct net_device *dev)
@@ -1009,7 +1113,7 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
1009 struct resource *res; 1113 struct resource *res;
1010 void __iomem *addr; 1114 void __iomem *addr;
1011 u32 out_val[MRAM_CFG_LEN]; 1115 u32 out_val[MRAM_CFG_LEN];
1012 int ret; 1116 int i, start, end, ret;
1013 1117
1014 /* message ram could be shared */ 1118 /* message ram could be shared */
1015 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram"); 1119 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
@@ -1060,6 +1164,15 @@ static int m_can_of_parse_mram(struct platform_device *pdev,
1060 priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num, 1164 priv->mcfg[MRAM_TXE].off, priv->mcfg[MRAM_TXE].num,
1061 priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num); 1165 priv->mcfg[MRAM_TXB].off, priv->mcfg[MRAM_TXB].num);
1062 1166
1167 /* initialize the entire Message RAM in use to avoid possible
1168 * ECC/parity checksum errors when reading an uninitialized buffer
1169 */
1170 start = priv->mcfg[MRAM_SIDF].off;
1171 end = priv->mcfg[MRAM_TXB].off +
1172 priv->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE;
1173 for (i = start; i < end; i += 4)
1174 writel(0x0, priv->mram_base + i);
1175
1063 return 0; 1176 return 0;
1064} 1177}
1065 1178
diff --git a/drivers/net/can/rcar_can.c b/drivers/net/can/rcar_can.c
index 1abe133d1594..9718248e55f1 100644
--- a/drivers/net/can/rcar_can.c
+++ b/drivers/net/can/rcar_can.c
@@ -628,6 +628,7 @@ static const struct net_device_ops rcar_can_netdev_ops = {
628 .ndo_open = rcar_can_open, 628 .ndo_open = rcar_can_open,
629 .ndo_stop = rcar_can_close, 629 .ndo_stop = rcar_can_close,
630 .ndo_start_xmit = rcar_can_start_xmit, 630 .ndo_start_xmit = rcar_can_start_xmit,
631 .ndo_change_mtu = can_change_mtu,
631}; 632};
632 633
633static void rcar_can_rx_pkt(struct rcar_can_priv *priv) 634static void rcar_can_rx_pkt(struct rcar_can_priv *priv)
diff --git a/drivers/net/can/sja1000/kvaser_pci.c b/drivers/net/can/sja1000/kvaser_pci.c
index 8ff3424d5147..15c00faeec61 100644
--- a/drivers/net/can/sja1000/kvaser_pci.c
+++ b/drivers/net/can/sja1000/kvaser_pci.c
@@ -214,7 +214,7 @@ static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel,
214 struct net_device *dev; 214 struct net_device *dev;
215 struct sja1000_priv *priv; 215 struct sja1000_priv *priv;
216 struct kvaser_pci *board; 216 struct kvaser_pci *board;
217 int err, init_step; 217 int err;
218 218
219 dev = alloc_sja1000dev(sizeof(struct kvaser_pci)); 219 dev = alloc_sja1000dev(sizeof(struct kvaser_pci));
220 if (dev == NULL) 220 if (dev == NULL)
@@ -235,7 +235,6 @@ static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel,
235 if (channel == 0) { 235 if (channel == 0) {
236 board->xilinx_ver = 236 board->xilinx_ver =
237 ioread8(board->res_addr + XILINX_VERINT) >> 4; 237 ioread8(board->res_addr + XILINX_VERINT) >> 4;
238 init_step = 2;
239 238
240 /* Assert PTADR# - we're in passive mode so the other bits are 239 /* Assert PTADR# - we're in passive mode so the other bits are
241 not important */ 240 not important */
@@ -264,8 +263,6 @@ static int kvaser_pci_add_chan(struct pci_dev *pdev, int channel,
264 priv->irq_flags = IRQF_SHARED; 263 priv->irq_flags = IRQF_SHARED;
265 dev->irq = pdev->irq; 264 dev->irq = pdev->irq;
266 265
267 init_step = 4;
268
269 dev_info(&pdev->dev, "reg_base=%p conf_addr=%p irq=%d\n", 266 dev_info(&pdev->dev, "reg_base=%p conf_addr=%p irq=%d\n",
270 priv->reg_base, board->conf_addr, dev->irq); 267 priv->reg_base, board->conf_addr, dev->irq);
271 268
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index 00f2534dde73..29d3f0938eb8 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -434,10 +434,9 @@ static void ems_usb_read_bulk_callback(struct urb *urb)
434 if (urb->actual_length > CPC_HEADER_SIZE) { 434 if (urb->actual_length > CPC_HEADER_SIZE) {
435 struct ems_cpc_msg *msg; 435 struct ems_cpc_msg *msg;
436 u8 *ibuf = urb->transfer_buffer; 436 u8 *ibuf = urb->transfer_buffer;
437 u8 msg_count, again, start; 437 u8 msg_count, start;
438 438
439 msg_count = ibuf[0] & ~0x80; 439 msg_count = ibuf[0] & ~0x80;
440 again = ibuf[0] & 0x80;
441 440
442 start = CPC_HEADER_SIZE; 441 start = CPC_HEADER_SIZE;
443 442
diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c
index b7c9e8b11460..c063a54ab8dd 100644
--- a/drivers/net/can/usb/esd_usb2.c
+++ b/drivers/net/can/usb/esd_usb2.c
@@ -464,7 +464,6 @@ static void esd_usb2_write_bulk_callback(struct urb *urb)
464{ 464{
465 struct esd_tx_urb_context *context = urb->context; 465 struct esd_tx_urb_context *context = urb->context;
466 struct esd_usb2_net_priv *priv; 466 struct esd_usb2_net_priv *priv;
467 struct esd_usb2 *dev;
468 struct net_device *netdev; 467 struct net_device *netdev;
469 size_t size = sizeof(struct esd_usb2_msg); 468 size_t size = sizeof(struct esd_usb2_msg);
470 469
@@ -472,7 +471,6 @@ static void esd_usb2_write_bulk_callback(struct urb *urb)
472 471
473 priv = context->priv; 472 priv = context->priv;
474 netdev = priv->netdev; 473 netdev = priv->netdev;
475 dev = priv->usb2;
476 474
477 /* free up our allocated buffer */ 475 /* free up our allocated buffer */
478 usb_free_coherent(urb->dev, size, 476 usb_free_coherent(urb->dev, size,
@@ -1143,6 +1141,7 @@ static void esd_usb2_disconnect(struct usb_interface *intf)
1143 } 1141 }
1144 } 1142 }
1145 unlink_all_urbs(dev); 1143 unlink_all_urbs(dev);
1144 kfree(dev);
1146 } 1145 }
1147} 1146}
1148 1147
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 04b0f84612f0..009acc8641fc 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -718,6 +718,7 @@ static const struct net_device_ops gs_usb_netdev_ops = {
718 .ndo_open = gs_can_open, 718 .ndo_open = gs_can_open,
719 .ndo_stop = gs_can_close, 719 .ndo_stop = gs_can_close,
720 .ndo_start_xmit = gs_can_start_xmit, 720 .ndo_start_xmit = gs_can_start_xmit,
721 .ndo_change_mtu = can_change_mtu,
721}; 722};
722 723
723static struct gs_can *gs_make_candev(unsigned int channel, struct usb_interface *intf) 724static struct gs_can *gs_make_candev(unsigned int channel, struct usb_interface *intf)
diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 5e8b5609c067..8a998e3884ce 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -300,7 +300,8 @@ static int xcan_set_bittiming(struct net_device *ndev)
300static int xcan_chip_start(struct net_device *ndev) 300static int xcan_chip_start(struct net_device *ndev)
301{ 301{
302 struct xcan_priv *priv = netdev_priv(ndev); 302 struct xcan_priv *priv = netdev_priv(ndev);
303 u32 err, reg_msr, reg_sr_mask; 303 u32 reg_msr, reg_sr_mask;
304 int err;
304 unsigned long timeout; 305 unsigned long timeout;
305 306
306 /* Check if it is in reset mode */ 307 /* Check if it is in reset mode */
@@ -961,6 +962,7 @@ static const struct net_device_ops xcan_netdev_ops = {
961 .ndo_open = xcan_open, 962 .ndo_open = xcan_open,
962 .ndo_stop = xcan_close, 963 .ndo_stop = xcan_close,
963 .ndo_start_xmit = xcan_start_xmit, 964 .ndo_start_xmit = xcan_start_xmit,
965 .ndo_change_mtu = can_change_mtu,
964}; 966};
965 967
966/** 968/**
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index b9625968daac..4f4c2a7888e5 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -377,6 +377,29 @@ static irqreturn_t bcm_sf2_switch_1_isr(int irq, void *dev_id)
377 return IRQ_HANDLED; 377 return IRQ_HANDLED;
378} 378}
379 379
380static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
381{
382 unsigned int timeout = 1000;
383 u32 reg;
384
385 reg = core_readl(priv, CORE_WATCHDOG_CTRL);
386 reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
387 core_writel(priv, reg, CORE_WATCHDOG_CTRL);
388
389 do {
390 reg = core_readl(priv, CORE_WATCHDOG_CTRL);
391 if (!(reg & SOFTWARE_RESET))
392 break;
393
394 usleep_range(1000, 2000);
395 } while (timeout-- > 0);
396
397 if (timeout == 0)
398 return -ETIMEDOUT;
399
400 return 0;
401}
402
380static int bcm_sf2_sw_setup(struct dsa_switch *ds) 403static int bcm_sf2_sw_setup(struct dsa_switch *ds)
381{ 404{
382 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME; 405 const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
@@ -404,11 +427,18 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
404 *base = of_iomap(dn, i); 427 *base = of_iomap(dn, i);
405 if (*base == NULL) { 428 if (*base == NULL) {
406 pr_err("unable to find register: %s\n", reg_names[i]); 429 pr_err("unable to find register: %s\n", reg_names[i]);
407 return -ENODEV; 430 ret = -ENOMEM;
431 goto out_unmap;
408 } 432 }
409 base++; 433 base++;
410 } 434 }
411 435
436 ret = bcm_sf2_sw_rst(priv);
437 if (ret) {
438 pr_err("unable to software reset switch: %d\n", ret);
439 goto out_unmap;
440 }
441
412 /* Disable all interrupts and request them */ 442 /* Disable all interrupts and request them */
413 intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_MASK_SET); 443 intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_MASK_SET);
414 intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_CLEAR); 444 intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_CLEAR);
@@ -484,7 +514,8 @@ out_free_irq0:
484out_unmap: 514out_unmap:
485 base = &priv->core; 515 base = &priv->core;
486 for (i = 0; i < BCM_SF2_REGS_NUM; i++) { 516 for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
487 iounmap(*base); 517 if (*base)
518 iounmap(*base);
488 base++; 519 base++;
489 } 520 }
490 return ret; 521 return ret;
@@ -733,29 +764,6 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
733 return 0; 764 return 0;
734} 765}
735 766
736static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
737{
738 unsigned int timeout = 1000;
739 u32 reg;
740
741 reg = core_readl(priv, CORE_WATCHDOG_CTRL);
742 reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
743 core_writel(priv, reg, CORE_WATCHDOG_CTRL);
744
745 do {
746 reg = core_readl(priv, CORE_WATCHDOG_CTRL);
747 if (!(reg & SOFTWARE_RESET))
748 break;
749
750 usleep_range(1000, 2000);
751 } while (timeout-- > 0);
752
753 if (timeout == 0)
754 return -ETIMEDOUT;
755
756 return 0;
757}
758
759static int bcm_sf2_sw_resume(struct dsa_switch *ds) 767static int bcm_sf2_sw_resume(struct dsa_switch *ds)
760{ 768{
761 struct bcm_sf2_priv *priv = ds_to_priv(ds); 769 struct bcm_sf2_priv *priv = ds_to_priv(ds);
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 63ea1941e973..7ba83ffb08ac 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -575,10 +575,24 @@ static void xgene_gmac_tx_disable(struct xgene_enet_pdata *pdata)
575 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN); 575 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN);
576} 576}
577 577
578static void xgene_enet_reset(struct xgene_enet_pdata *pdata) 578bool xgene_ring_mgr_init(struct xgene_enet_pdata *p)
579{
580 if (!ioread32(p->ring_csr_addr + CLKEN_ADDR))
581 return false;
582
583 if (ioread32(p->ring_csr_addr + SRST_ADDR))
584 return false;
585
586 return true;
587}
588
589static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
579{ 590{
580 u32 val; 591 u32 val;
581 592
593 if (!xgene_ring_mgr_init(pdata))
594 return -ENODEV;
595
582 clk_prepare_enable(pdata->clk); 596 clk_prepare_enable(pdata->clk);
583 clk_disable_unprepare(pdata->clk); 597 clk_disable_unprepare(pdata->clk);
584 clk_prepare_enable(pdata->clk); 598 clk_prepare_enable(pdata->clk);
@@ -590,6 +604,8 @@ static void xgene_enet_reset(struct xgene_enet_pdata *pdata)
590 val |= SCAN_AUTO_INCR; 604 val |= SCAN_AUTO_INCR;
591 MGMT_CLOCK_SEL_SET(&val, 1); 605 MGMT_CLOCK_SEL_SET(&val, 1);
592 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val); 606 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val);
607
608 return 0;
593} 609}
594 610
595static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata) 611static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
index 38558584080e..ec45f3256f0e 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
@@ -104,6 +104,9 @@ enum xgene_enet_rm {
104#define BLOCK_ETH_MAC_OFFSET 0x0000 104#define BLOCK_ETH_MAC_OFFSET 0x0000
105#define BLOCK_ETH_MAC_CSR_OFFSET 0x2800 105#define BLOCK_ETH_MAC_CSR_OFFSET 0x2800
106 106
107#define CLKEN_ADDR 0xc208
108#define SRST_ADDR 0xc200
109
107#define MAC_ADDR_REG_OFFSET 0x00 110#define MAC_ADDR_REG_OFFSET 0x00
108#define MAC_COMMAND_REG_OFFSET 0x04 111#define MAC_COMMAND_REG_OFFSET 0x04
109#define MAC_WRITE_REG_OFFSET 0x08 112#define MAC_WRITE_REG_OFFSET 0x08
@@ -318,6 +321,7 @@ void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
318 321
319int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata); 322int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
320void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata); 323void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
324bool xgene_ring_mgr_init(struct xgene_enet_pdata *p);
321 325
322extern struct xgene_mac_ops xgene_gmac_ops; 326extern struct xgene_mac_ops xgene_gmac_ops;
323extern struct xgene_port_ops xgene_gport_ops; 327extern struct xgene_port_ops xgene_gport_ops;
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 3c208cc6f6bb..123669696184 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -639,9 +639,9 @@ static int xgene_enet_create_desc_rings(struct net_device *ndev)
639 struct device *dev = ndev_to_dev(ndev); 639 struct device *dev = ndev_to_dev(ndev);
640 struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring; 640 struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
641 struct xgene_enet_desc_ring *buf_pool = NULL; 641 struct xgene_enet_desc_ring *buf_pool = NULL;
642 u8 cpu_bufnum = 0, eth_bufnum = 0; 642 u8 cpu_bufnum = 0, eth_bufnum = START_ETH_BUFNUM;
643 u8 bp_bufnum = 0x20; 643 u8 bp_bufnum = START_BP_BUFNUM;
644 u16 ring_id, ring_num = 0; 644 u16 ring_id, ring_num = START_RING_NUM;
645 int ret; 645 int ret;
646 646
647 /* allocate rx descriptor ring */ 647 /* allocate rx descriptor ring */
@@ -852,7 +852,9 @@ static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata)
852 u16 dst_ring_num; 852 u16 dst_ring_num;
853 int ret; 853 int ret;
854 854
855 pdata->port_ops->reset(pdata); 855 ret = pdata->port_ops->reset(pdata);
856 if (ret)
857 return ret;
856 858
857 ret = xgene_enet_create_desc_rings(ndev); 859 ret = xgene_enet_create_desc_rings(ndev);
858 if (ret) { 860 if (ret) {
@@ -954,6 +956,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
954 956
955 return ret; 957 return ret;
956err: 958err:
959 unregister_netdev(ndev);
957 free_netdev(ndev); 960 free_netdev(ndev);
958 return ret; 961 return ret;
959} 962}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
index 874e5a01161f..f9958fae6ffd 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
@@ -38,6 +38,9 @@
38#define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN) 38#define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN)
39#define NUM_PKT_BUF 64 39#define NUM_PKT_BUF 64
40#define NUM_BUFPOOL 32 40#define NUM_BUFPOOL 32
41#define START_ETH_BUFNUM 2
42#define START_BP_BUFNUM 0x22
43#define START_RING_NUM 8
41 44
42#define PHY_POLL_LINK_ON (10 * HZ) 45#define PHY_POLL_LINK_ON (10 * HZ)
43#define PHY_POLL_LINK_OFF (PHY_POLL_LINK_ON / 5) 46#define PHY_POLL_LINK_OFF (PHY_POLL_LINK_ON / 5)
@@ -83,7 +86,7 @@ struct xgene_mac_ops {
83}; 86};
84 87
85struct xgene_port_ops { 88struct xgene_port_ops {
86 void (*reset)(struct xgene_enet_pdata *pdata); 89 int (*reset)(struct xgene_enet_pdata *pdata);
87 void (*cle_bypass)(struct xgene_enet_pdata *pdata, 90 void (*cle_bypass)(struct xgene_enet_pdata *pdata,
88 u32 dst_ring_num, u16 bufpool_id); 91 u32 dst_ring_num, u16 bufpool_id);
89 void (*shutdown)(struct xgene_enet_pdata *pdata); 92 void (*shutdown)(struct xgene_enet_pdata *pdata);
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index c22f32622fa9..f5d4f68c288c 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -311,14 +311,19 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata *p)
311 xgene_sgmac_rxtx(p, TX_EN, false); 311 xgene_sgmac_rxtx(p, TX_EN, false);
312} 312}
313 313
314static void xgene_enet_reset(struct xgene_enet_pdata *p) 314static int xgene_enet_reset(struct xgene_enet_pdata *p)
315{ 315{
316 if (!xgene_ring_mgr_init(p))
317 return -ENODEV;
318
316 clk_prepare_enable(p->clk); 319 clk_prepare_enable(p->clk);
317 clk_disable_unprepare(p->clk); 320 clk_disable_unprepare(p->clk);
318 clk_prepare_enable(p->clk); 321 clk_prepare_enable(p->clk);
319 322
320 xgene_enet_ecc_init(p); 323 xgene_enet_ecc_init(p);
321 xgene_enet_config_ring_if_assoc(p); 324 xgene_enet_config_ring_if_assoc(p);
325
326 return 0;
322} 327}
323 328
324static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p, 329static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p,
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
index 67d07206b3c7..a18a9d1f1143 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
@@ -252,14 +252,19 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata *pdata)
252 xgene_enet_wr_mac(pdata, AXGMAC_CONFIG_1, data & ~HSTTFEN); 252 xgene_enet_wr_mac(pdata, AXGMAC_CONFIG_1, data & ~HSTTFEN);
253} 253}
254 254
255static void xgene_enet_reset(struct xgene_enet_pdata *pdata) 255static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
256{ 256{
257 if (!xgene_ring_mgr_init(pdata))
258 return -ENODEV;
259
257 clk_prepare_enable(pdata->clk); 260 clk_prepare_enable(pdata->clk);
258 clk_disable_unprepare(pdata->clk); 261 clk_disable_unprepare(pdata->clk);
259 clk_prepare_enable(pdata->clk); 262 clk_prepare_enable(pdata->clk);
260 263
261 xgene_enet_ecc_init(pdata); 264 xgene_enet_ecc_init(pdata);
262 xgene_enet_config_ring_if_assoc(pdata); 265 xgene_enet_config_ring_if_assoc(pdata);
266
267 return 0;
263} 268}
264 269
265static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata, 270static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata,
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 3a6778a667f4..531bb7c57531 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1110,7 +1110,8 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,
1110 /* We just need one DMA descriptor which is DMA-able, since writing to 1110 /* We just need one DMA descriptor which is DMA-able, since writing to
1111 * the port will allocate a new descriptor in its internal linked-list 1111 * the port will allocate a new descriptor in its internal linked-list
1112 */ 1112 */
1113 p = dma_zalloc_coherent(kdev, 1, &ring->desc_dma, GFP_KERNEL); 1113 p = dma_zalloc_coherent(kdev, sizeof(struct dma_desc), &ring->desc_dma,
1114 GFP_KERNEL);
1114 if (!p) { 1115 if (!p) {
1115 netif_err(priv, hw, priv->netdev, "DMA alloc failed\n"); 1116 netif_err(priv, hw, priv->netdev, "DMA alloc failed\n");
1116 return -ENOMEM; 1117 return -ENOMEM;
@@ -1174,6 +1175,13 @@ static void bcm_sysport_fini_tx_ring(struct bcm_sysport_priv *priv,
1174 if (!(reg & TDMA_DISABLED)) 1175 if (!(reg & TDMA_DISABLED))
1175 netdev_warn(priv->netdev, "TDMA not stopped!\n"); 1176 netdev_warn(priv->netdev, "TDMA not stopped!\n");
1176 1177
1178 /* ring->cbs is the last part in bcm_sysport_init_tx_ring which could
1179 * fail, so by checking this pointer we know whether the TX ring was
1180 * fully initialized or not.
1181 */
1182 if (!ring->cbs)
1183 return;
1184
1177 napi_disable(&ring->napi); 1185 napi_disable(&ring->napi);
1178 netif_napi_del(&ring->napi); 1186 netif_napi_del(&ring->napi);
1179 1187
@@ -1183,7 +1191,8 @@ static void bcm_sysport_fini_tx_ring(struct bcm_sysport_priv *priv,
1183 ring->cbs = NULL; 1191 ring->cbs = NULL;
1184 1192
1185 if (ring->desc_dma) { 1193 if (ring->desc_dma) {
1186 dma_free_coherent(kdev, 1, ring->desc_cpu, ring->desc_dma); 1194 dma_free_coherent(kdev, sizeof(struct dma_desc),
1195 ring->desc_cpu, ring->desc_dma);
1187 ring->desc_dma = 0; 1196 ring->desc_dma = 0;
1188 } 1197 }
1189 ring->size = 0; 1198 ring->size = 0;
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index fdc9ec09e453..da1a2500c91c 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2140,6 +2140,12 @@ static int bcmgenet_open(struct net_device *dev)
2140 goto err_irq0; 2140 goto err_irq0;
2141 } 2141 }
2142 2142
2143 /* Re-configure the port multiplexer towards the PHY device */
2144 bcmgenet_mii_config(priv->dev, false);
2145
2146 phy_connect_direct(dev, priv->phydev, bcmgenet_mii_setup,
2147 priv->phy_interface);
2148
2143 bcmgenet_netif_start(dev); 2149 bcmgenet_netif_start(dev);
2144 2150
2145 return 0; 2151 return 0;
@@ -2184,6 +2190,9 @@ static int bcmgenet_close(struct net_device *dev)
2184 2190
2185 bcmgenet_netif_stop(dev); 2191 bcmgenet_netif_stop(dev);
2186 2192
2193 /* Really kill the PHY state machine and disconnect from it */
2194 phy_disconnect(priv->phydev);
2195
2187 /* Disable MAC receive */ 2196 /* Disable MAC receive */
2188 umac_enable_set(priv, CMD_RX_EN, false); 2197 umac_enable_set(priv, CMD_RX_EN, false);
2189 2198
@@ -2685,7 +2694,7 @@ static int bcmgenet_resume(struct device *d)
2685 2694
2686 phy_init_hw(priv->phydev); 2695 phy_init_hw(priv->phydev);
2687 /* Speed settings must be restored */ 2696 /* Speed settings must be restored */
2688 bcmgenet_mii_config(priv->dev); 2697 bcmgenet_mii_config(priv->dev, false);
2689 2698
2690 /* disable ethernet MAC while updating its registers */ 2699 /* disable ethernet MAC while updating its registers */
2691 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false); 2700 umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, false);
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
index dbf524ea3b19..31b2da5f9b82 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
@@ -617,9 +617,10 @@ GENET_IO_MACRO(rbuf, GENET_RBUF_OFF);
617 617
618/* MDIO routines */ 618/* MDIO routines */
619int bcmgenet_mii_init(struct net_device *dev); 619int bcmgenet_mii_init(struct net_device *dev);
620int bcmgenet_mii_config(struct net_device *dev); 620int bcmgenet_mii_config(struct net_device *dev, bool init);
621void bcmgenet_mii_exit(struct net_device *dev); 621void bcmgenet_mii_exit(struct net_device *dev);
622void bcmgenet_mii_reset(struct net_device *dev); 622void bcmgenet_mii_reset(struct net_device *dev);
623void bcmgenet_mii_setup(struct net_device *dev);
623 624
624/* Wake-on-LAN routines */ 625/* Wake-on-LAN routines */
625void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol); 626void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol);
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 9ff799a9f801..933cd7e7cd33 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -77,7 +77,7 @@ static int bcmgenet_mii_write(struct mii_bus *bus, int phy_id,
77/* setup netdev link state when PHY link status change and 77/* setup netdev link state when PHY link status change and
78 * update UMAC and RGMII block when link up 78 * update UMAC and RGMII block when link up
79 */ 79 */
80static void bcmgenet_mii_setup(struct net_device *dev) 80void bcmgenet_mii_setup(struct net_device *dev)
81{ 81{
82 struct bcmgenet_priv *priv = netdev_priv(dev); 82 struct bcmgenet_priv *priv = netdev_priv(dev);
83 struct phy_device *phydev = priv->phydev; 83 struct phy_device *phydev = priv->phydev;
@@ -211,7 +211,7 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
211 bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL); 211 bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL);
212} 212}
213 213
214int bcmgenet_mii_config(struct net_device *dev) 214int bcmgenet_mii_config(struct net_device *dev, bool init)
215{ 215{
216 struct bcmgenet_priv *priv = netdev_priv(dev); 216 struct bcmgenet_priv *priv = netdev_priv(dev);
217 struct phy_device *phydev = priv->phydev; 217 struct phy_device *phydev = priv->phydev;
@@ -298,7 +298,8 @@ int bcmgenet_mii_config(struct net_device *dev)
298 return -EINVAL; 298 return -EINVAL;
299 } 299 }
300 300
301 dev_info(kdev, "configuring instance for %s\n", phy_name); 301 if (init)
302 dev_info(kdev, "configuring instance for %s\n", phy_name);
302 303
303 return 0; 304 return 0;
304} 305}
@@ -350,7 +351,7 @@ static int bcmgenet_mii_probe(struct net_device *dev)
350 * PHY speed which is needed for bcmgenet_mii_config() to configure 351 * PHY speed which is needed for bcmgenet_mii_config() to configure
351 * things appropriately. 352 * things appropriately.
352 */ 353 */
353 ret = bcmgenet_mii_config(dev); 354 ret = bcmgenet_mii_config(dev, true);
354 if (ret) { 355 if (ret) {
355 phy_disconnect(priv->phydev); 356 phy_disconnect(priv->phydev);
356 return ret; 357 return ret;
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index dbb41c1923e6..77f8f836cbbe 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8563,7 +8563,8 @@ static int tg3_init_rings(struct tg3 *tp)
8563 if (tnapi->rx_rcb) 8563 if (tnapi->rx_rcb)
8564 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp)); 8564 memset(tnapi->rx_rcb, 0, TG3_RX_RCB_RING_BYTES(tp));
8565 8565
8566 if (tg3_rx_prodring_alloc(tp, &tnapi->prodring)) { 8566 if (tnapi->prodring.rx_std &&
8567 tg3_rx_prodring_alloc(tp, &tnapi->prodring)) {
8567 tg3_free_rings(tp); 8568 tg3_free_rings(tp);
8568 return -ENOMEM; 8569 return -ENOMEM;
8569 } 8570 }
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 6fe300e316c3..4fe33606f372 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -79,8 +79,9 @@ static void cxgb4_dcb_cleanup_apps(struct net_device *dev)
79 app.protocol = dcb->app_priority[i].protocolid; 79 app.protocol = dcb->app_priority[i].protocolid;
80 80
81 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) { 81 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
82 app.priority = dcb->app_priority[i].user_prio_map;
82 app.selector = dcb->app_priority[i].sel_field + 1; 83 app.selector = dcb->app_priority[i].sel_field + 1;
83 err = dcb_ieee_setapp(dev, &app); 84 err = dcb_ieee_delapp(dev, &app);
84 } else { 85 } else {
85 app.selector = !!(dcb->app_priority[i].sel_field); 86 app.selector = !!(dcb->app_priority[i].sel_field);
86 err = dcb_setapp(dev, &app); 87 err = dcb_setapp(dev, &app);
@@ -122,7 +123,11 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
122 case CXGB4_DCB_INPUT_FW_ENABLED: { 123 case CXGB4_DCB_INPUT_FW_ENABLED: {
123 /* we're going to use Firmware DCB */ 124 /* we're going to use Firmware DCB */
124 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; 125 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
125 dcb->supported = CXGB4_DCBX_FW_SUPPORT; 126 dcb->supported = DCB_CAP_DCBX_LLD_MANAGED;
127 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE)
128 dcb->supported |= DCB_CAP_DCBX_VER_IEEE;
129 else
130 dcb->supported |= DCB_CAP_DCBX_VER_CEE;
126 break; 131 break;
127 } 132 }
128 133
@@ -436,14 +441,17 @@ static void cxgb4_getpgtccfg(struct net_device *dev, int tc,
436 *up_tc_map = (1 << tc); 441 *up_tc_map = (1 << tc);
437 442
438 /* prio_type is link strict */ 443 /* prio_type is link strict */
439 *prio_type = 0x2; 444 if (*pgid != 0xF)
445 *prio_type = 0x2;
440} 446}
441 447
442static void cxgb4_getpgtccfg_tx(struct net_device *dev, int tc, 448static void cxgb4_getpgtccfg_tx(struct net_device *dev, int tc,
443 u8 *prio_type, u8 *pgid, u8 *bw_per, 449 u8 *prio_type, u8 *pgid, u8 *bw_per,
444 u8 *up_tc_map) 450 u8 *up_tc_map)
445{ 451{
446 return cxgb4_getpgtccfg(dev, tc, prio_type, pgid, bw_per, up_tc_map, 1); 452 /* tc 0 is written at MSB position */
453 return cxgb4_getpgtccfg(dev, (7 - tc), prio_type, pgid, bw_per,
454 up_tc_map, 1);
447} 455}
448 456
449 457
@@ -451,7 +459,9 @@ static void cxgb4_getpgtccfg_rx(struct net_device *dev, int tc,
451 u8 *prio_type, u8 *pgid, u8 *bw_per, 459 u8 *prio_type, u8 *pgid, u8 *bw_per,
452 u8 *up_tc_map) 460 u8 *up_tc_map)
453{ 461{
454 return cxgb4_getpgtccfg(dev, tc, prio_type, pgid, bw_per, up_tc_map, 0); 462 /* tc 0 is written at MSB position */
463 return cxgb4_getpgtccfg(dev, (7 - tc), prio_type, pgid, bw_per,
464 up_tc_map, 0);
455} 465}
456 466
457static void cxgb4_setpgtccfg_tx(struct net_device *dev, int tc, 467static void cxgb4_setpgtccfg_tx(struct net_device *dev, int tc,
@@ -461,6 +471,7 @@ static void cxgb4_setpgtccfg_tx(struct net_device *dev, int tc,
461 struct fw_port_cmd pcmd; 471 struct fw_port_cmd pcmd;
462 struct port_info *pi = netdev2pinfo(dev); 472 struct port_info *pi = netdev2pinfo(dev);
463 struct adapter *adap = pi->adapter; 473 struct adapter *adap = pi->adapter;
474 int fw_tc = 7 - tc;
464 u32 _pgid; 475 u32 _pgid;
465 int err; 476 int err;
466 477
@@ -479,8 +490,8 @@ static void cxgb4_setpgtccfg_tx(struct net_device *dev, int tc,
479 } 490 }
480 491
481 _pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid); 492 _pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid);
482 _pgid &= ~(0xF << (tc * 4)); 493 _pgid &= ~(0xF << (fw_tc * 4));
483 _pgid |= pgid << (tc * 4); 494 _pgid |= pgid << (fw_tc * 4);
484 pcmd.u.dcb.pgid.pgid = cpu_to_be32(_pgid); 495 pcmd.u.dcb.pgid.pgid = cpu_to_be32(_pgid);
485 496
486 INIT_PORT_DCB_WRITE_CMD(pcmd, pi->port_id); 497 INIT_PORT_DCB_WRITE_CMD(pcmd, pi->port_id);
@@ -593,7 +604,7 @@ static void cxgb4_getpfccfg(struct net_device *dev, int priority, u8 *pfccfg)
593 priority >= CXGB4_MAX_PRIORITY) 604 priority >= CXGB4_MAX_PRIORITY)
594 *pfccfg = 0; 605 *pfccfg = 0;
595 else 606 else
596 *pfccfg = (pi->dcb.pfcen >> priority) & 1; 607 *pfccfg = (pi->dcb.pfcen >> (7 - priority)) & 1;
597} 608}
598 609
599/* Enable/disable Priority Pause Frames for the specified Traffic Class 610/* Enable/disable Priority Pause Frames for the specified Traffic Class
@@ -618,9 +629,9 @@ static void cxgb4_setpfccfg(struct net_device *dev, int priority, u8 pfccfg)
618 pcmd.u.dcb.pfc.pfcen = pi->dcb.pfcen; 629 pcmd.u.dcb.pfc.pfcen = pi->dcb.pfcen;
619 630
620 if (pfccfg) 631 if (pfccfg)
621 pcmd.u.dcb.pfc.pfcen |= (1 << priority); 632 pcmd.u.dcb.pfc.pfcen |= (1 << (7 - priority));
622 else 633 else
623 pcmd.u.dcb.pfc.pfcen &= (~(1 << priority)); 634 pcmd.u.dcb.pfc.pfcen &= (~(1 << (7 - priority)));
624 635
625 err = t4_wr_mbox(adap, adap->mbox, &pcmd, sizeof(pcmd), &pcmd); 636 err = t4_wr_mbox(adap, adap->mbox, &pcmd, sizeof(pcmd), &pcmd);
626 if (err != FW_PORT_DCB_CFG_SUCCESS) { 637 if (err != FW_PORT_DCB_CFG_SUCCESS) {
@@ -1071,7 +1082,7 @@ static int cxgb4_cee_peer_getpg(struct net_device *dev, struct cee_pg *pg)
1071 pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid); 1082 pgid = be32_to_cpu(pcmd.u.dcb.pgid.pgid);
1072 1083
1073 for (i = 0; i < CXGB4_MAX_PRIORITY; i++) 1084 for (i = 0; i < CXGB4_MAX_PRIORITY; i++)
1074 pg->prio_pg[i] = (pgid >> (i * 4)) & 0xF; 1085 pg->prio_pg[7 - i] = (pgid >> (i * 4)) & 0xF;
1075 1086
1076 INIT_PORT_DCB_READ_PEER_CMD(pcmd, pi->port_id); 1087 INIT_PORT_DCB_READ_PEER_CMD(pcmd, pi->port_id);
1077 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE; 1088 pcmd.u.dcb.pgrate.type = FW_PORT_DCB_TYPE_PGRATE;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index 5e1b314e11af..39f2b13e66c7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2914,7 +2914,8 @@ static int t4_sge_init_hard(struct adapter *adap)
2914int t4_sge_init(struct adapter *adap) 2914int t4_sge_init(struct adapter *adap)
2915{ 2915{
2916 struct sge *s = &adap->sge; 2916 struct sge *s = &adap->sge;
2917 u32 sge_control, sge_conm_ctrl; 2917 u32 sge_control, sge_control2, sge_conm_ctrl;
2918 unsigned int ingpadboundary, ingpackboundary;
2918 int ret, egress_threshold; 2919 int ret, egress_threshold;
2919 2920
2920 /* 2921 /*
@@ -2924,8 +2925,31 @@ int t4_sge_init(struct adapter *adap)
2924 sge_control = t4_read_reg(adap, SGE_CONTROL); 2925 sge_control = t4_read_reg(adap, SGE_CONTROL);
2925 s->pktshift = PKTSHIFT_GET(sge_control); 2926 s->pktshift = PKTSHIFT_GET(sge_control);
2926 s->stat_len = (sge_control & EGRSTATUSPAGESIZE_MASK) ? 128 : 64; 2927 s->stat_len = (sge_control & EGRSTATUSPAGESIZE_MASK) ? 128 : 64;
2927 s->fl_align = 1 << (INGPADBOUNDARY_GET(sge_control) + 2928
2928 X_INGPADBOUNDARY_SHIFT); 2929 /* T4 uses a single control field to specify both the PCIe Padding and
2930 * Packing Boundary. T5 introduced the ability to specify these
2931 * separately. The actual Ingress Packet Data alignment boundary
2932 * within Packed Buffer Mode is the maximum of these two
2933 * specifications.
2934 */
2935 ingpadboundary = 1 << (INGPADBOUNDARY_GET(sge_control) +
2936 X_INGPADBOUNDARY_SHIFT);
2937 if (is_t4(adap->params.chip)) {
2938 s->fl_align = ingpadboundary;
2939 } else {
2940 /* T5 has a different interpretation of one of the PCIe Packing
2941 * Boundary values.
2942 */
2943 sge_control2 = t4_read_reg(adap, SGE_CONTROL2_A);
2944 ingpackboundary = INGPACKBOUNDARY_G(sge_control2);
2945 if (ingpackboundary == INGPACKBOUNDARY_16B_X)
2946 ingpackboundary = 16;
2947 else
2948 ingpackboundary = 1 << (ingpackboundary +
2949 INGPACKBOUNDARY_SHIFT_X);
2950
2951 s->fl_align = max(ingpadboundary, ingpackboundary);
2952 }
2929 2953
2930 if (adap->flags & USING_SOFT_PARAMS) 2954 if (adap->flags & USING_SOFT_PARAMS)
2931 ret = t4_sge_init_soft(adap); 2955 ret = t4_sge_init_soft(adap);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index a9d9d74e4f09..163a2a14948c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3129,12 +3129,51 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
3129 HOSTPAGESIZEPF6(sge_hps) | 3129 HOSTPAGESIZEPF6(sge_hps) |
3130 HOSTPAGESIZEPF7(sge_hps)); 3130 HOSTPAGESIZEPF7(sge_hps));
3131 3131
3132 t4_set_reg_field(adap, SGE_CONTROL, 3132 if (is_t4(adap->params.chip)) {
3133 INGPADBOUNDARY_MASK | 3133 t4_set_reg_field(adap, SGE_CONTROL,
3134 EGRSTATUSPAGESIZE_MASK, 3134 INGPADBOUNDARY_MASK |
3135 INGPADBOUNDARY(fl_align_log - 5) | 3135 EGRSTATUSPAGESIZE_MASK,
3136 EGRSTATUSPAGESIZE(stat_len != 64)); 3136 INGPADBOUNDARY(fl_align_log - 5) |
3137 3137 EGRSTATUSPAGESIZE(stat_len != 64));
3138 } else {
3139 /* T5 introduced the separation of the Free List Padding and
3140 * Packing Boundaries. Thus, we can select a smaller Padding
3141 * Boundary to avoid uselessly chewing up PCIe Link and Memory
3142 * Bandwidth, and use a Packing Boundary which is large enough
3143 * to avoid false sharing between CPUs, etc.
3144 *
3145 * For the PCI Link, the smaller the Padding Boundary the
3146 * better. For the Memory Controller, a smaller Padding
3147 * Boundary is better until we cross under the Memory Line
3148 * Size (the minimum unit of transfer to/from Memory). If we
3149 * have a Padding Boundary which is smaller than the Memory
3150 * Line Size, that'll involve a Read-Modify-Write cycle on the
3151 * Memory Controller which is never good. For T5 the smallest
3152 * Padding Boundary which we can select is 32 bytes which is
3153 * larger than any known Memory Controller Line Size so we'll
3154 * use that.
3155 *
3156 * T5 has a different interpretation of the "0" value for the
3157 * Packing Boundary. This corresponds to 16 bytes instead of
3158 * the expected 32 bytes. We never have a Packing Boundary
3159 * less than 32 bytes so we can't use that special value but
3160 * on the other hand, if we wanted 32 bytes, the best we can
3161 * really do is 64 bytes.
3162 */
3163 if (fl_align <= 32) {
3164 fl_align = 64;
3165 fl_align_log = 6;
3166 }
3167 t4_set_reg_field(adap, SGE_CONTROL,
3168 INGPADBOUNDARY_MASK |
3169 EGRSTATUSPAGESIZE_MASK,
3170 INGPADBOUNDARY(INGPCIEBOUNDARY_32B_X) |
3171 EGRSTATUSPAGESIZE(stat_len != 64));
3172 t4_set_reg_field(adap, SGE_CONTROL2_A,
3173 INGPACKBOUNDARY_V(INGPACKBOUNDARY_M),
3174 INGPACKBOUNDARY_V(fl_align_log -
3175 INGPACKBOUNDARY_SHIFT_X));
3176 }
3138 /* 3177 /*
3139 * Adjust various SGE Free List Host Buffer Sizes. 3178 * Adjust various SGE Free List Host Buffer Sizes.
3140 * 3179 *
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
index a1024db5dc13..8d2de1006b08 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
@@ -95,6 +95,7 @@
95#define X_INGPADBOUNDARY_SHIFT 5 95#define X_INGPADBOUNDARY_SHIFT 5
96 96
97#define SGE_CONTROL 0x1008 97#define SGE_CONTROL 0x1008
98#define SGE_CONTROL2_A 0x1124
98#define DCASYSTYPE 0x00080000U 99#define DCASYSTYPE 0x00080000U
99#define RXPKTCPLMODE_MASK 0x00040000U 100#define RXPKTCPLMODE_MASK 0x00040000U
100#define RXPKTCPLMODE_SHIFT 18 101#define RXPKTCPLMODE_SHIFT 18
@@ -106,6 +107,7 @@
106#define PKTSHIFT_SHIFT 10 107#define PKTSHIFT_SHIFT 10
107#define PKTSHIFT(x) ((x) << PKTSHIFT_SHIFT) 108#define PKTSHIFT(x) ((x) << PKTSHIFT_SHIFT)
108#define PKTSHIFT_GET(x) (((x) & PKTSHIFT_MASK) >> PKTSHIFT_SHIFT) 109#define PKTSHIFT_GET(x) (((x) & PKTSHIFT_MASK) >> PKTSHIFT_SHIFT)
110#define INGPCIEBOUNDARY_32B_X 0
109#define INGPCIEBOUNDARY_MASK 0x00000380U 111#define INGPCIEBOUNDARY_MASK 0x00000380U
110#define INGPCIEBOUNDARY_SHIFT 7 112#define INGPCIEBOUNDARY_SHIFT 7
111#define INGPCIEBOUNDARY(x) ((x) << INGPCIEBOUNDARY_SHIFT) 113#define INGPCIEBOUNDARY(x) ((x) << INGPCIEBOUNDARY_SHIFT)
@@ -114,6 +116,14 @@
114#define INGPADBOUNDARY(x) ((x) << INGPADBOUNDARY_SHIFT) 116#define INGPADBOUNDARY(x) ((x) << INGPADBOUNDARY_SHIFT)
115#define INGPADBOUNDARY_GET(x) (((x) & INGPADBOUNDARY_MASK) \ 117#define INGPADBOUNDARY_GET(x) (((x) & INGPADBOUNDARY_MASK) \
116 >> INGPADBOUNDARY_SHIFT) 118 >> INGPADBOUNDARY_SHIFT)
119#define INGPACKBOUNDARY_16B_X 0
120#define INGPACKBOUNDARY_SHIFT_X 5
121
122#define INGPACKBOUNDARY_S 16
123#define INGPACKBOUNDARY_M 0x7U
124#define INGPACKBOUNDARY_V(x) ((x) << INGPACKBOUNDARY_S)
125#define INGPACKBOUNDARY_G(x) (((x) >> INGPACKBOUNDARY_S) \
126 & INGPACKBOUNDARY_M)
117#define EGRPCIEBOUNDARY_MASK 0x0000000eU 127#define EGRPCIEBOUNDARY_MASK 0x0000000eU
118#define EGRPCIEBOUNDARY_SHIFT 1 128#define EGRPCIEBOUNDARY_SHIFT 1
119#define EGRPCIEBOUNDARY(x) ((x) << EGRPCIEBOUNDARY_SHIFT) 129#define EGRPCIEBOUNDARY(x) ((x) << EGRPCIEBOUNDARY_SHIFT)
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
index 68eaa9c88c7d..3d06e77d7121 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
@@ -299,6 +299,14 @@ struct sge {
299 u16 timer_val[SGE_NTIMERS]; /* interrupt holdoff timer array */ 299 u16 timer_val[SGE_NTIMERS]; /* interrupt holdoff timer array */
300 u8 counter_val[SGE_NCOUNTERS]; /* interrupt RX threshold array */ 300 u8 counter_val[SGE_NCOUNTERS]; /* interrupt RX threshold array */
301 301
302 /* Decoded Adapter Parameters.
303 */
304 u32 fl_pg_order; /* large page allocation size */
305 u32 stat_len; /* length of status page at ring end */
306 u32 pktshift; /* padding between CPL & packet data */
307 u32 fl_align; /* response queue message alignment */
308 u32 fl_starve_thres; /* Free List starvation threshold */
309
302 /* 310 /*
303 * Reverse maps from Absolute Queue IDs to associated queue pointers. 311 * Reverse maps from Absolute Queue IDs to associated queue pointers.
304 * The absolute Queue IDs are in a compact range which start at a 312 * The absolute Queue IDs are in a compact range which start at a
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 85036e6b42c4..fdd078d7d82c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -51,14 +51,6 @@
51#include "../cxgb4/t4_msg.h" 51#include "../cxgb4/t4_msg.h"
52 52
53/* 53/*
54 * Decoded Adapter Parameters.
55 */
56static u32 FL_PG_ORDER; /* large page allocation size */
57static u32 STAT_LEN; /* length of status page at ring end */
58static u32 PKTSHIFT; /* padding between CPL and packet data */
59static u32 FL_ALIGN; /* response queue message alignment */
60
61/*
62 * Constants ... 54 * Constants ...
63 */ 55 */
64enum { 56enum {
@@ -102,12 +94,6 @@ enum {
102 MAX_TIMER_TX_RECLAIM = 100, 94 MAX_TIMER_TX_RECLAIM = 100,
103 95
104 /* 96 /*
105 * An FL with <= FL_STARVE_THRES buffers is starving and a periodic
106 * timer will attempt to refill it.
107 */
108 FL_STARVE_THRES = 4,
109
110 /*
111 * Suspend an Ethernet TX queue with fewer available descriptors than 97 * Suspend an Ethernet TX queue with fewer available descriptors than
112 * this. We always want to have room for a maximum sized packet: 98 * this. We always want to have room for a maximum sized packet:
113 * inline immediate data + MAX_SKB_FRAGS. This is the same as 99 * inline immediate data + MAX_SKB_FRAGS. This is the same as
@@ -264,15 +250,19 @@ static inline unsigned int fl_cap(const struct sge_fl *fl)
264 250
265/** 251/**
266 * fl_starving - return whether a Free List is starving. 252 * fl_starving - return whether a Free List is starving.
253 * @adapter: pointer to the adapter
267 * @fl: the Free List 254 * @fl: the Free List
268 * 255 *
269 * Tests specified Free List to see whether the number of buffers 256 * Tests specified Free List to see whether the number of buffers
270 * available to the hardware has falled below our "starvation" 257 * available to the hardware has falled below our "starvation"
271 * threshold. 258 * threshold.
272 */ 259 */
273static inline bool fl_starving(const struct sge_fl *fl) 260static inline bool fl_starving(const struct adapter *adapter,
261 const struct sge_fl *fl)
274{ 262{
275 return fl->avail - fl->pend_cred <= FL_STARVE_THRES; 263 const struct sge *s = &adapter->sge;
264
265 return fl->avail - fl->pend_cred <= s->fl_starve_thres;
276} 266}
277 267
278/** 268/**
@@ -457,13 +447,16 @@ static inline void reclaim_completed_tx(struct adapter *adapter,
457 447
458/** 448/**
459 * get_buf_size - return the size of an RX Free List buffer. 449 * get_buf_size - return the size of an RX Free List buffer.
450 * @adapter: pointer to the associated adapter
460 * @sdesc: pointer to the software buffer descriptor 451 * @sdesc: pointer to the software buffer descriptor
461 */ 452 */
462static inline int get_buf_size(const struct rx_sw_desc *sdesc) 453static inline int get_buf_size(const struct adapter *adapter,
454 const struct rx_sw_desc *sdesc)
463{ 455{
464 return FL_PG_ORDER > 0 && (sdesc->dma_addr & RX_LARGE_BUF) 456 const struct sge *s = &adapter->sge;
465 ? (PAGE_SIZE << FL_PG_ORDER) 457
466 : PAGE_SIZE; 458 return (s->fl_pg_order > 0 && (sdesc->dma_addr & RX_LARGE_BUF)
459 ? (PAGE_SIZE << s->fl_pg_order) : PAGE_SIZE);
467} 460}
468 461
469/** 462/**
@@ -483,7 +476,8 @@ static void free_rx_bufs(struct adapter *adapter, struct sge_fl *fl, int n)
483 476
484 if (is_buf_mapped(sdesc)) 477 if (is_buf_mapped(sdesc))
485 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc), 478 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc),
486 get_buf_size(sdesc), PCI_DMA_FROMDEVICE); 479 get_buf_size(adapter, sdesc),
480 PCI_DMA_FROMDEVICE);
487 put_page(sdesc->page); 481 put_page(sdesc->page);
488 sdesc->page = NULL; 482 sdesc->page = NULL;
489 if (++fl->cidx == fl->size) 483 if (++fl->cidx == fl->size)
@@ -511,7 +505,8 @@ static void unmap_rx_buf(struct adapter *adapter, struct sge_fl *fl)
511 505
512 if (is_buf_mapped(sdesc)) 506 if (is_buf_mapped(sdesc))
513 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc), 507 dma_unmap_page(adapter->pdev_dev, get_buf_addr(sdesc),
514 get_buf_size(sdesc), PCI_DMA_FROMDEVICE); 508 get_buf_size(adapter, sdesc),
509 PCI_DMA_FROMDEVICE);
515 sdesc->page = NULL; 510 sdesc->page = NULL;
516 if (++fl->cidx == fl->size) 511 if (++fl->cidx == fl->size)
517 fl->cidx = 0; 512 fl->cidx = 0;
@@ -589,6 +584,7 @@ static inline void poison_buf(struct page *page, size_t sz)
589static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl, 584static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
590 int n, gfp_t gfp) 585 int n, gfp_t gfp)
591{ 586{
587 struct sge *s = &adapter->sge;
592 struct page *page; 588 struct page *page;
593 dma_addr_t dma_addr; 589 dma_addr_t dma_addr;
594 unsigned int cred = fl->avail; 590 unsigned int cred = fl->avail;
@@ -608,12 +604,12 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
608 * If we don't support large pages, drop directly into the small page 604 * If we don't support large pages, drop directly into the small page
609 * allocation code. 605 * allocation code.
610 */ 606 */
611 if (FL_PG_ORDER == 0) 607 if (s->fl_pg_order == 0)
612 goto alloc_small_pages; 608 goto alloc_small_pages;
613 609
614 while (n) { 610 while (n) {
615 page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN, 611 page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
616 FL_PG_ORDER); 612 s->fl_pg_order);
617 if (unlikely(!page)) { 613 if (unlikely(!page)) {
618 /* 614 /*
619 * We've failed inour attempt to allocate a "large 615 * We've failed inour attempt to allocate a "large
@@ -623,10 +619,10 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
623 fl->large_alloc_failed++; 619 fl->large_alloc_failed++;
624 break; 620 break;
625 } 621 }
626 poison_buf(page, PAGE_SIZE << FL_PG_ORDER); 622 poison_buf(page, PAGE_SIZE << s->fl_pg_order);
627 623
628 dma_addr = dma_map_page(adapter->pdev_dev, page, 0, 624 dma_addr = dma_map_page(adapter->pdev_dev, page, 0,
629 PAGE_SIZE << FL_PG_ORDER, 625 PAGE_SIZE << s->fl_pg_order,
630 PCI_DMA_FROMDEVICE); 626 PCI_DMA_FROMDEVICE);
631 if (unlikely(dma_mapping_error(adapter->pdev_dev, dma_addr))) { 627 if (unlikely(dma_mapping_error(adapter->pdev_dev, dma_addr))) {
632 /* 628 /*
@@ -637,7 +633,7 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
637 * because DMA mapping resources are typically 633 * because DMA mapping resources are typically
638 * critical resources once they become scarse. 634 * critical resources once they become scarse.
639 */ 635 */
640 __free_pages(page, FL_PG_ORDER); 636 __free_pages(page, s->fl_pg_order);
641 goto out; 637 goto out;
642 } 638 }
643 dma_addr |= RX_LARGE_BUF; 639 dma_addr |= RX_LARGE_BUF;
@@ -693,7 +689,7 @@ out:
693 fl->pend_cred += cred; 689 fl->pend_cred += cred;
694 ring_fl_db(adapter, fl); 690 ring_fl_db(adapter, fl);
695 691
696 if (unlikely(fl_starving(fl))) { 692 if (unlikely(fl_starving(adapter, fl))) {
697 smp_wmb(); 693 smp_wmb();
698 set_bit(fl->cntxt_id, adapter->sge.starving_fl); 694 set_bit(fl->cntxt_id, adapter->sge.starving_fl);
699 } 695 }
@@ -1468,6 +1464,8 @@ static void t4vf_pktgl_free(const struct pkt_gl *gl)
1468static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl, 1464static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
1469 const struct cpl_rx_pkt *pkt) 1465 const struct cpl_rx_pkt *pkt)
1470{ 1466{
1467 struct adapter *adapter = rxq->rspq.adapter;
1468 struct sge *s = &adapter->sge;
1471 int ret; 1469 int ret;
1472 struct sk_buff *skb; 1470 struct sk_buff *skb;
1473 1471
@@ -1478,8 +1476,8 @@ static void do_gro(struct sge_eth_rxq *rxq, const struct pkt_gl *gl,
1478 return; 1476 return;
1479 } 1477 }
1480 1478
1481 copy_frags(skb, gl, PKTSHIFT); 1479 copy_frags(skb, gl, s->pktshift);
1482 skb->len = gl->tot_len - PKTSHIFT; 1480 skb->len = gl->tot_len - s->pktshift;
1483 skb->data_len = skb->len; 1481 skb->data_len = skb->len;
1484 skb->truesize += skb->data_len; 1482 skb->truesize += skb->data_len;
1485 skb->ip_summed = CHECKSUM_UNNECESSARY; 1483 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -1516,6 +1514,8 @@ int t4vf_ethrx_handler(struct sge_rspq *rspq, const __be64 *rsp,
1516 bool csum_ok = pkt->csum_calc && !pkt->err_vec && 1514 bool csum_ok = pkt->csum_calc && !pkt->err_vec &&
1517 (rspq->netdev->features & NETIF_F_RXCSUM); 1515 (rspq->netdev->features & NETIF_F_RXCSUM);
1518 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq); 1516 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq);
1517 struct adapter *adapter = rspq->adapter;
1518 struct sge *s = &adapter->sge;
1519 1519
1520 /* 1520 /*
1521 * If this is a good TCP packet and we have Generic Receive Offload 1521 * If this is a good TCP packet and we have Generic Receive Offload
@@ -1537,7 +1537,7 @@ int t4vf_ethrx_handler(struct sge_rspq *rspq, const __be64 *rsp,
1537 rxq->stats.rx_drops++; 1537 rxq->stats.rx_drops++;
1538 return 0; 1538 return 0;
1539 } 1539 }
1540 __skb_pull(skb, PKTSHIFT); 1540 __skb_pull(skb, s->pktshift);
1541 skb->protocol = eth_type_trans(skb, rspq->netdev); 1541 skb->protocol = eth_type_trans(skb, rspq->netdev);
1542 skb_record_rx_queue(skb, rspq->idx); 1542 skb_record_rx_queue(skb, rspq->idx);
1543 rxq->stats.pkts++; 1543 rxq->stats.pkts++;
@@ -1648,6 +1648,8 @@ static inline void rspq_next(struct sge_rspq *rspq)
1648static int process_responses(struct sge_rspq *rspq, int budget) 1648static int process_responses(struct sge_rspq *rspq, int budget)
1649{ 1649{
1650 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq); 1650 struct sge_eth_rxq *rxq = container_of(rspq, struct sge_eth_rxq, rspq);
1651 struct adapter *adapter = rspq->adapter;
1652 struct sge *s = &adapter->sge;
1651 int budget_left = budget; 1653 int budget_left = budget;
1652 1654
1653 while (likely(budget_left)) { 1655 while (likely(budget_left)) {
@@ -1697,7 +1699,7 @@ static int process_responses(struct sge_rspq *rspq, int budget)
1697 BUG_ON(frag >= MAX_SKB_FRAGS); 1699 BUG_ON(frag >= MAX_SKB_FRAGS);
1698 BUG_ON(rxq->fl.avail == 0); 1700 BUG_ON(rxq->fl.avail == 0);
1699 sdesc = &rxq->fl.sdesc[rxq->fl.cidx]; 1701 sdesc = &rxq->fl.sdesc[rxq->fl.cidx];
1700 bufsz = get_buf_size(sdesc); 1702 bufsz = get_buf_size(adapter, sdesc);
1701 fp->page = sdesc->page; 1703 fp->page = sdesc->page;
1702 fp->offset = rspq->offset; 1704 fp->offset = rspq->offset;
1703 fp->size = min(bufsz, len); 1705 fp->size = min(bufsz, len);
@@ -1726,7 +1728,7 @@ static int process_responses(struct sge_rspq *rspq, int budget)
1726 */ 1728 */
1727 ret = rspq->handler(rspq, rspq->cur_desc, &gl); 1729 ret = rspq->handler(rspq, rspq->cur_desc, &gl);
1728 if (likely(ret == 0)) 1730 if (likely(ret == 0))
1729 rspq->offset += ALIGN(fp->size, FL_ALIGN); 1731 rspq->offset += ALIGN(fp->size, s->fl_align);
1730 else 1732 else
1731 restore_rx_bufs(&gl, &rxq->fl, frag); 1733 restore_rx_bufs(&gl, &rxq->fl, frag);
1732 } else if (likely(rsp_type == RSP_TYPE_CPL)) { 1734 } else if (likely(rsp_type == RSP_TYPE_CPL)) {
@@ -1963,7 +1965,7 @@ static void sge_rx_timer_cb(unsigned long data)
1963 * schedule napi but the FL is no longer starving. 1965 * schedule napi but the FL is no longer starving.
1964 * No biggie. 1966 * No biggie.
1965 */ 1967 */
1966 if (fl_starving(fl)) { 1968 if (fl_starving(adapter, fl)) {
1967 struct sge_eth_rxq *rxq; 1969 struct sge_eth_rxq *rxq;
1968 1970
1969 rxq = container_of(fl, struct sge_eth_rxq, fl); 1971 rxq = container_of(fl, struct sge_eth_rxq, fl);
@@ -2047,6 +2049,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
2047 int intr_dest, 2049 int intr_dest,
2048 struct sge_fl *fl, rspq_handler_t hnd) 2050 struct sge_fl *fl, rspq_handler_t hnd)
2049{ 2051{
2052 struct sge *s = &adapter->sge;
2050 struct port_info *pi = netdev_priv(dev); 2053 struct port_info *pi = netdev_priv(dev);
2051 struct fw_iq_cmd cmd, rpl; 2054 struct fw_iq_cmd cmd, rpl;
2052 int ret, iqandst, flsz = 0; 2055 int ret, iqandst, flsz = 0;
@@ -2117,7 +2120,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
2117 fl->size = roundup(fl->size, FL_PER_EQ_UNIT); 2120 fl->size = roundup(fl->size, FL_PER_EQ_UNIT);
2118 fl->desc = alloc_ring(adapter->pdev_dev, fl->size, 2121 fl->desc = alloc_ring(adapter->pdev_dev, fl->size,
2119 sizeof(__be64), sizeof(struct rx_sw_desc), 2122 sizeof(__be64), sizeof(struct rx_sw_desc),
2120 &fl->addr, &fl->sdesc, STAT_LEN); 2123 &fl->addr, &fl->sdesc, s->stat_len);
2121 if (!fl->desc) { 2124 if (!fl->desc) {
2122 ret = -ENOMEM; 2125 ret = -ENOMEM;
2123 goto err; 2126 goto err;
@@ -2129,7 +2132,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
2129 * free list ring) in Egress Queue Units. 2132 * free list ring) in Egress Queue Units.
2130 */ 2133 */
2131 flsz = (fl->size / FL_PER_EQ_UNIT + 2134 flsz = (fl->size / FL_PER_EQ_UNIT +
2132 STAT_LEN / EQ_UNIT); 2135 s->stat_len / EQ_UNIT);
2133 2136
2134 /* 2137 /*
2135 * Fill in all the relevant firmware Ingress Queue Command 2138 * Fill in all the relevant firmware Ingress Queue Command
@@ -2217,6 +2220,7 @@ int t4vf_sge_alloc_eth_txq(struct adapter *adapter, struct sge_eth_txq *txq,
2217 struct net_device *dev, struct netdev_queue *devq, 2220 struct net_device *dev, struct netdev_queue *devq,
2218 unsigned int iqid) 2221 unsigned int iqid)
2219{ 2222{
2223 struct sge *s = &adapter->sge;
2220 int ret, nentries; 2224 int ret, nentries;
2221 struct fw_eq_eth_cmd cmd, rpl; 2225 struct fw_eq_eth_cmd cmd, rpl;
2222 struct port_info *pi = netdev_priv(dev); 2226 struct port_info *pi = netdev_priv(dev);
@@ -2225,7 +2229,7 @@ int t4vf_sge_alloc_eth_txq(struct adapter *adapter, struct sge_eth_txq *txq,
2225 * Calculate the size of the hardware TX Queue (including the Status 2229 * Calculate the size of the hardware TX Queue (including the Status
2226 * Page on the end of the TX Queue) in units of TX Descriptors. 2230 * Page on the end of the TX Queue) in units of TX Descriptors.
2227 */ 2231 */
2228 nentries = txq->q.size + STAT_LEN / sizeof(struct tx_desc); 2232 nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc);
2229 2233
2230 /* 2234 /*
2231 * Allocate the hardware ring for the TX ring (with space for its 2235 * Allocate the hardware ring for the TX ring (with space for its
@@ -2234,7 +2238,7 @@ int t4vf_sge_alloc_eth_txq(struct adapter *adapter, struct sge_eth_txq *txq,
2234 txq->q.desc = alloc_ring(adapter->pdev_dev, txq->q.size, 2238 txq->q.desc = alloc_ring(adapter->pdev_dev, txq->q.size,
2235 sizeof(struct tx_desc), 2239 sizeof(struct tx_desc),
2236 sizeof(struct tx_sw_desc), 2240 sizeof(struct tx_sw_desc),
2237 &txq->q.phys_addr, &txq->q.sdesc, STAT_LEN); 2241 &txq->q.phys_addr, &txq->q.sdesc, s->stat_len);
2238 if (!txq->q.desc) 2242 if (!txq->q.desc)
2239 return -ENOMEM; 2243 return -ENOMEM;
2240 2244
@@ -2307,8 +2311,10 @@ int t4vf_sge_alloc_eth_txq(struct adapter *adapter, struct sge_eth_txq *txq,
2307 */ 2311 */
2308static void free_txq(struct adapter *adapter, struct sge_txq *tq) 2312static void free_txq(struct adapter *adapter, struct sge_txq *tq)
2309{ 2313{
2314 struct sge *s = &adapter->sge;
2315
2310 dma_free_coherent(adapter->pdev_dev, 2316 dma_free_coherent(adapter->pdev_dev,
2311 tq->size * sizeof(*tq->desc) + STAT_LEN, 2317 tq->size * sizeof(*tq->desc) + s->stat_len,
2312 tq->desc, tq->phys_addr); 2318 tq->desc, tq->phys_addr);
2313 tq->cntxt_id = 0; 2319 tq->cntxt_id = 0;
2314 tq->sdesc = NULL; 2320 tq->sdesc = NULL;
@@ -2322,6 +2328,7 @@ static void free_txq(struct adapter *adapter, struct sge_txq *tq)
2322static void free_rspq_fl(struct adapter *adapter, struct sge_rspq *rspq, 2328static void free_rspq_fl(struct adapter *adapter, struct sge_rspq *rspq,
2323 struct sge_fl *fl) 2329 struct sge_fl *fl)
2324{ 2330{
2331 struct sge *s = &adapter->sge;
2325 unsigned int flid = fl ? fl->cntxt_id : 0xffff; 2332 unsigned int flid = fl ? fl->cntxt_id : 0xffff;
2326 2333
2327 t4vf_iq_free(adapter, FW_IQ_TYPE_FL_INT_CAP, 2334 t4vf_iq_free(adapter, FW_IQ_TYPE_FL_INT_CAP,
@@ -2337,7 +2344,7 @@ static void free_rspq_fl(struct adapter *adapter, struct sge_rspq *rspq,
2337 if (fl) { 2344 if (fl) {
2338 free_rx_bufs(adapter, fl, fl->avail); 2345 free_rx_bufs(adapter, fl, fl->avail);
2339 dma_free_coherent(adapter->pdev_dev, 2346 dma_free_coherent(adapter->pdev_dev,
2340 fl->size * sizeof(*fl->desc) + STAT_LEN, 2347 fl->size * sizeof(*fl->desc) + s->stat_len,
2341 fl->desc, fl->addr); 2348 fl->desc, fl->addr);
2342 kfree(fl->sdesc); 2349 kfree(fl->sdesc);
2343 fl->sdesc = NULL; 2350 fl->sdesc = NULL;
@@ -2423,6 +2430,7 @@ int t4vf_sge_init(struct adapter *adapter)
2423 u32 fl0 = sge_params->sge_fl_buffer_size[0]; 2430 u32 fl0 = sge_params->sge_fl_buffer_size[0];
2424 u32 fl1 = sge_params->sge_fl_buffer_size[1]; 2431 u32 fl1 = sge_params->sge_fl_buffer_size[1];
2425 struct sge *s = &adapter->sge; 2432 struct sge *s = &adapter->sge;
2433 unsigned int ingpadboundary, ingpackboundary;
2426 2434
2427 /* 2435 /*
2428 * Start by vetting the basic SGE parameters which have been set up by 2436 * Start by vetting the basic SGE parameters which have been set up by
@@ -2443,12 +2451,48 @@ int t4vf_sge_init(struct adapter *adapter)
2443 * Now translate the adapter parameters into our internal forms. 2451 * Now translate the adapter parameters into our internal forms.
2444 */ 2452 */
2445 if (fl1) 2453 if (fl1)
2446 FL_PG_ORDER = ilog2(fl1) - PAGE_SHIFT; 2454 s->fl_pg_order = ilog2(fl1) - PAGE_SHIFT;
2447 STAT_LEN = ((sge_params->sge_control & EGRSTATUSPAGESIZE_MASK) 2455 s->stat_len = ((sge_params->sge_control & EGRSTATUSPAGESIZE_MASK)
2448 ? 128 : 64); 2456 ? 128 : 64);
2449 PKTSHIFT = PKTSHIFT_GET(sge_params->sge_control); 2457 s->pktshift = PKTSHIFT_GET(sge_params->sge_control);
2450 FL_ALIGN = 1 << (INGPADBOUNDARY_GET(sge_params->sge_control) + 2458
2451 SGE_INGPADBOUNDARY_SHIFT); 2459 /* T4 uses a single control field to specify both the PCIe Padding and
2460 * Packing Boundary. T5 introduced the ability to specify these
2461 * separately. The actual Ingress Packet Data alignment boundary
2462 * within Packed Buffer Mode is the maximum of these two
2463 * specifications. (Note that it makes no real practical sense to
2464 * have the Pading Boudary be larger than the Packing Boundary but you
2465 * could set the chip up that way and, in fact, legacy T4 code would
2466 * end doing this because it would initialize the Padding Boundary and
2467 * leave the Packing Boundary initialized to 0 (16 bytes).)
2468 */
2469 ingpadboundary = 1 << (INGPADBOUNDARY_GET(sge_params->sge_control) +
2470 X_INGPADBOUNDARY_SHIFT);
2471 if (is_t4(adapter->params.chip)) {
2472 s->fl_align = ingpadboundary;
2473 } else {
2474 /* T5 has a different interpretation of one of the PCIe Packing
2475 * Boundary values.
2476 */
2477 ingpackboundary = INGPACKBOUNDARY_G(sge_params->sge_control2);
2478 if (ingpackboundary == INGPACKBOUNDARY_16B_X)
2479 ingpackboundary = 16;
2480 else
2481 ingpackboundary = 1 << (ingpackboundary +
2482 INGPACKBOUNDARY_SHIFT_X);
2483
2484 s->fl_align = max(ingpadboundary, ingpackboundary);
2485 }
2486
2487 /* A FL with <= fl_starve_thres buffers is starving and a periodic
2488 * timer will attempt to refill it. This needs to be larger than the
2489 * SGE's Egress Congestion Threshold. If it isn't, then we can get
2490 * stuck waiting for new packets while the SGE is waiting for us to
2491 * give it more Free List entries. (Note that the SGE's Egress
2492 * Congestion Threshold is in units of 2 Free List pointers.)
2493 */
2494 s->fl_starve_thres
2495 = EGRTHRESHOLD_GET(sge_params->sge_congestion_control)*2 + 1;
2452 2496
2453 /* 2497 /*
2454 * Set up tasklet timers. 2498 * Set up tasklet timers.
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
index 95df61dcb4ce..4b6a6d14d86d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
@@ -134,11 +134,13 @@ struct dev_params {
134 */ 134 */
135struct sge_params { 135struct sge_params {
136 u32 sge_control; /* padding, boundaries, lengths, etc. */ 136 u32 sge_control; /* padding, boundaries, lengths, etc. */
137 u32 sge_control2; /* T5: more of the same */
137 u32 sge_host_page_size; /* RDMA page sizes */ 138 u32 sge_host_page_size; /* RDMA page sizes */
138 u32 sge_queues_per_page; /* RDMA queues/page */ 139 u32 sge_queues_per_page; /* RDMA queues/page */
139 u32 sge_user_mode_limits; /* limits for BAR2 user mode accesses */ 140 u32 sge_user_mode_limits; /* limits for BAR2 user mode accesses */
140 u32 sge_fl_buffer_size[16]; /* free list buffer sizes */ 141 u32 sge_fl_buffer_size[16]; /* free list buffer sizes */
141 u32 sge_ingress_rx_threshold; /* RX counter interrupt threshold[4] */ 142 u32 sge_ingress_rx_threshold; /* RX counter interrupt threshold[4] */
143 u32 sge_congestion_control; /* congestion thresholds, etc. */
142 u32 sge_timer_value_0_and_1; /* interrupt coalescing timer values */ 144 u32 sge_timer_value_0_and_1; /* interrupt coalescing timer values */
143 u32 sge_timer_value_2_and_3; 145 u32 sge_timer_value_2_and_3;
144 u32 sge_timer_value_4_and_5; 146 u32 sge_timer_value_4_and_5;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index e984fdc48ba2..1e896b923234 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -468,12 +468,38 @@ int t4vf_get_sge_params(struct adapter *adapter)
468 sge_params->sge_timer_value_2_and_3 = vals[5]; 468 sge_params->sge_timer_value_2_and_3 = vals[5];
469 sge_params->sge_timer_value_4_and_5 = vals[6]; 469 sge_params->sge_timer_value_4_and_5 = vals[6];
470 470
471 /* T4 uses a single control field to specify both the PCIe Padding and
472 * Packing Boundary. T5 introduced the ability to specify these
473 * separately with the Padding Boundary in SGE_CONTROL and and Packing
474 * Boundary in SGE_CONTROL2. So for T5 and later we need to grab
475 * SGE_CONTROL in order to determine how ingress packet data will be
476 * laid out in Packed Buffer Mode. Unfortunately, older versions of
477 * the firmware won't let us retrieve SGE_CONTROL2 so if we get a
478 * failure grabbing it we throw an error since we can't figure out the
479 * right value.
480 */
481 if (!is_t4(adapter->params.chip)) {
482 params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) |
483 FW_PARAMS_PARAM_XYZ(SGE_CONTROL2_A));
484 v = t4vf_query_params(adapter, 1, params, vals);
485 if (v != FW_SUCCESS) {
486 dev_err(adapter->pdev_dev,
487 "Unable to get SGE Control2; "
488 "probably old firmware.\n");
489 return v;
490 }
491 sge_params->sge_control2 = vals[0];
492 }
493
471 params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) | 494 params[0] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) |
472 FW_PARAMS_PARAM_XYZ(SGE_INGRESS_RX_THRESHOLD)); 495 FW_PARAMS_PARAM_XYZ(SGE_INGRESS_RX_THRESHOLD));
473 v = t4vf_query_params(adapter, 1, params, vals); 496 params[1] = (FW_PARAMS_MNEM(FW_PARAMS_MNEM_REG) |
497 FW_PARAMS_PARAM_XYZ(SGE_CONM_CTRL));
498 v = t4vf_query_params(adapter, 2, params, vals);
474 if (v) 499 if (v)
475 return v; 500 return v;
476 sge_params->sge_ingress_rx_threshold = vals[0]; 501 sge_params->sge_ingress_rx_threshold = vals[0];
502 sge_params->sge_congestion_control = vals[1];
477 503
478 return 0; 504 return 0;
479} 505}
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 180e53fa628f..73cf1653a4a3 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -940,18 +940,8 @@ static int enic_rq_alloc_buf(struct vnic_rq *rq)
940 struct vnic_rq_buf *buf = rq->to_use; 940 struct vnic_rq_buf *buf = rq->to_use;
941 941
942 if (buf->os_buf) { 942 if (buf->os_buf) {
943 buf = buf->next; 943 enic_queue_rq_desc(rq, buf->os_buf, os_buf_index, buf->dma_addr,
944 rq->to_use = buf; 944 buf->len);
945 rq->ring.desc_avail--;
946 if ((buf->index & VNIC_RQ_RETURN_RATE) == 0) {
947 /* Adding write memory barrier prevents compiler and/or
948 * CPU reordering, thus avoiding descriptor posting
949 * before descriptor is initialized. Otherwise, hardware
950 * can read stale descriptor fields.
951 */
952 wmb();
953 iowrite32(buf->index, &rq->ctrl->posted_index);
954 }
955 945
956 return 0; 946 return 0;
957 } 947 }
@@ -1037,7 +1027,10 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
1037 enic->rq_truncated_pkts++; 1027 enic->rq_truncated_pkts++;
1038 } 1028 }
1039 1029
1030 pci_unmap_single(enic->pdev, buf->dma_addr, buf->len,
1031 PCI_DMA_FROMDEVICE);
1040 dev_kfree_skb_any(skb); 1032 dev_kfree_skb_any(skb);
1033 buf->os_buf = NULL;
1041 1034
1042 return; 1035 return;
1043 } 1036 }
@@ -1088,7 +1081,10 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
1088 /* Buffer overflow 1081 /* Buffer overflow
1089 */ 1082 */
1090 1083
1084 pci_unmap_single(enic->pdev, buf->dma_addr, buf->len,
1085 PCI_DMA_FROMDEVICE);
1091 dev_kfree_skb_any(skb); 1086 dev_kfree_skb_any(skb);
1087 buf->os_buf = NULL;
1092 } 1088 }
1093} 1089}
1094 1090
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 9a18e7930b31..597c463e384d 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4309,11 +4309,16 @@ static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh)
4309 return -EOPNOTSUPP; 4309 return -EOPNOTSUPP;
4310 4310
4311 br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); 4311 br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
4312 if (!br_spec)
4313 return -EINVAL;
4312 4314
4313 nla_for_each_nested(attr, br_spec, rem) { 4315 nla_for_each_nested(attr, br_spec, rem) {
4314 if (nla_type(attr) != IFLA_BRIDGE_MODE) 4316 if (nla_type(attr) != IFLA_BRIDGE_MODE)
4315 continue; 4317 continue;
4316 4318
4319 if (nla_len(attr) < sizeof(mode))
4320 return -EINVAL;
4321
4317 mode = nla_get_u16(attr); 4322 mode = nla_get_u16(attr);
4318 if (mode != BRIDGE_MODE_VEPA && mode != BRIDGE_MODE_VEB) 4323 if (mode != BRIDGE_MODE_VEPA && mode != BRIDGE_MODE_VEB)
4319 return -EINVAL; 4324 return -EINVAL;
@@ -4421,6 +4426,11 @@ static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
4421 "Disabled VxLAN offloads for UDP port %d\n", 4426 "Disabled VxLAN offloads for UDP port %d\n",
4422 be16_to_cpu(port)); 4427 be16_to_cpu(port));
4423} 4428}
4429
4430static bool be_gso_check(struct sk_buff *skb, struct net_device *dev)
4431{
4432 return vxlan_gso_check(skb);
4433}
4424#endif 4434#endif
4425 4435
4426static const struct net_device_ops be_netdev_ops = { 4436static const struct net_device_ops be_netdev_ops = {
@@ -4450,6 +4460,7 @@ static const struct net_device_ops be_netdev_ops = {
4450#ifdef CONFIG_BE2NET_VXLAN 4460#ifdef CONFIG_BE2NET_VXLAN
4451 .ndo_add_vxlan_port = be_add_vxlan_port, 4461 .ndo_add_vxlan_port = be_add_vxlan_port,
4452 .ndo_del_vxlan_port = be_del_vxlan_port, 4462 .ndo_del_vxlan_port = be_del_vxlan_port,
4463 .ndo_gso_check = be_gso_check,
4453#endif 4464#endif
4454}; 4465};
4455 4466
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 50a851db2852..3dca494797bd 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -298,6 +298,16 @@ static void *swap_buffer(void *bufaddr, int len)
298 return bufaddr; 298 return bufaddr;
299} 299}
300 300
301static void swap_buffer2(void *dst_buf, void *src_buf, int len)
302{
303 int i;
304 unsigned int *src = src_buf;
305 unsigned int *dst = dst_buf;
306
307 for (i = 0; i < len; i += 4, src++, dst++)
308 *dst = swab32p(src);
309}
310
301static void fec_dump(struct net_device *ndev) 311static void fec_dump(struct net_device *ndev)
302{ 312{
303 struct fec_enet_private *fep = netdev_priv(ndev); 313 struct fec_enet_private *fep = netdev_priv(ndev);
@@ -1307,7 +1317,7 @@ fec_enet_new_rxbdp(struct net_device *ndev, struct bufdesc *bdp, struct sk_buff
1307} 1317}
1308 1318
1309static bool fec_enet_copybreak(struct net_device *ndev, struct sk_buff **skb, 1319static bool fec_enet_copybreak(struct net_device *ndev, struct sk_buff **skb,
1310 struct bufdesc *bdp, u32 length) 1320 struct bufdesc *bdp, u32 length, bool swap)
1311{ 1321{
1312 struct fec_enet_private *fep = netdev_priv(ndev); 1322 struct fec_enet_private *fep = netdev_priv(ndev);
1313 struct sk_buff *new_skb; 1323 struct sk_buff *new_skb;
@@ -1322,7 +1332,10 @@ static bool fec_enet_copybreak(struct net_device *ndev, struct sk_buff **skb,
1322 dma_sync_single_for_cpu(&fep->pdev->dev, bdp->cbd_bufaddr, 1332 dma_sync_single_for_cpu(&fep->pdev->dev, bdp->cbd_bufaddr,
1323 FEC_ENET_RX_FRSIZE - fep->rx_align, 1333 FEC_ENET_RX_FRSIZE - fep->rx_align,
1324 DMA_FROM_DEVICE); 1334 DMA_FROM_DEVICE);
1325 memcpy(new_skb->data, (*skb)->data, length); 1335 if (!swap)
1336 memcpy(new_skb->data, (*skb)->data, length);
1337 else
1338 swap_buffer2(new_skb->data, (*skb)->data, length);
1326 *skb = new_skb; 1339 *skb = new_skb;
1327 1340
1328 return true; 1341 return true;
@@ -1352,6 +1365,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
1352 u16 vlan_tag; 1365 u16 vlan_tag;
1353 int index = 0; 1366 int index = 0;
1354 bool is_copybreak; 1367 bool is_copybreak;
1368 bool need_swap = id_entry->driver_data & FEC_QUIRK_SWAP_FRAME;
1355 1369
1356#ifdef CONFIG_M532x 1370#ifdef CONFIG_M532x
1357 flush_cache_all(); 1371 flush_cache_all();
@@ -1415,7 +1429,8 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
1415 * include that when passing upstream as it messes up 1429 * include that when passing upstream as it messes up
1416 * bridging applications. 1430 * bridging applications.
1417 */ 1431 */
1418 is_copybreak = fec_enet_copybreak(ndev, &skb, bdp, pkt_len - 4); 1432 is_copybreak = fec_enet_copybreak(ndev, &skb, bdp, pkt_len - 4,
1433 need_swap);
1419 if (!is_copybreak) { 1434 if (!is_copybreak) {
1420 skb_new = netdev_alloc_skb(ndev, FEC_ENET_RX_FRSIZE); 1435 skb_new = netdev_alloc_skb(ndev, FEC_ENET_RX_FRSIZE);
1421 if (unlikely(!skb_new)) { 1436 if (unlikely(!skb_new)) {
@@ -1430,7 +1445,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
1430 prefetch(skb->data - NET_IP_ALIGN); 1445 prefetch(skb->data - NET_IP_ALIGN);
1431 skb_put(skb, pkt_len - 4); 1446 skb_put(skb, pkt_len - 4);
1432 data = skb->data; 1447 data = skb->data;
1433 if (id_entry->driver_data & FEC_QUIRK_SWAP_FRAME) 1448 if (!is_copybreak && need_swap)
1434 swap_buffer(data, pkt_len); 1449 swap_buffer(data, pkt_len);
1435 1450
1436 /* Extract the enhanced buffer descriptor */ 1451 /* Extract the enhanced buffer descriptor */
@@ -3343,12 +3358,11 @@ static int __maybe_unused fec_suspend(struct device *dev)
3343 netif_device_detach(ndev); 3358 netif_device_detach(ndev);
3344 netif_tx_unlock_bh(ndev); 3359 netif_tx_unlock_bh(ndev);
3345 fec_stop(ndev); 3360 fec_stop(ndev);
3361 fec_enet_clk_enable(ndev, false);
3362 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
3346 } 3363 }
3347 rtnl_unlock(); 3364 rtnl_unlock();
3348 3365
3349 fec_enet_clk_enable(ndev, false);
3350 pinctrl_pm_select_sleep_state(&fep->pdev->dev);
3351
3352 if (fep->reg_phy) 3366 if (fep->reg_phy)
3353 regulator_disable(fep->reg_phy); 3367 regulator_disable(fep->reg_phy);
3354 3368
@@ -3367,13 +3381,14 @@ static int __maybe_unused fec_resume(struct device *dev)
3367 return ret; 3381 return ret;
3368 } 3382 }
3369 3383
3370 pinctrl_pm_select_default_state(&fep->pdev->dev);
3371 ret = fec_enet_clk_enable(ndev, true);
3372 if (ret)
3373 goto failed_clk;
3374
3375 rtnl_lock(); 3384 rtnl_lock();
3376 if (netif_running(ndev)) { 3385 if (netif_running(ndev)) {
3386 pinctrl_pm_select_default_state(&fep->pdev->dev);
3387 ret = fec_enet_clk_enable(ndev, true);
3388 if (ret) {
3389 rtnl_unlock();
3390 goto failed_clk;
3391 }
3377 fec_restart(ndev); 3392 fec_restart(ndev);
3378 netif_tx_lock_bh(ndev); 3393 netif_tx_lock_bh(ndev);
3379 netif_device_attach(ndev); 3394 netif_device_attach(ndev);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a2d72a87cbde..487cd9c4ac0d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -1012,7 +1012,8 @@ static void igb_free_q_vector(struct igb_adapter *adapter, int v_idx)
1012 /* igb_get_stats64() might access the rings on this vector, 1012 /* igb_get_stats64() might access the rings on this vector,
1013 * we must wait a grace period before freeing it. 1013 * we must wait a grace period before freeing it.
1014 */ 1014 */
1015 kfree_rcu(q_vector, rcu); 1015 if (q_vector)
1016 kfree_rcu(q_vector, rcu);
1016} 1017}
1017 1018
1018/** 1019/**
@@ -1792,8 +1793,10 @@ void igb_down(struct igb_adapter *adapter)
1792 adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE; 1793 adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE;
1793 1794
1794 for (i = 0; i < adapter->num_q_vectors; i++) { 1795 for (i = 0; i < adapter->num_q_vectors; i++) {
1795 napi_synchronize(&(adapter->q_vector[i]->napi)); 1796 if (adapter->q_vector[i]) {
1796 napi_disable(&(adapter->q_vector[i]->napi)); 1797 napi_synchronize(&adapter->q_vector[i]->napi);
1798 napi_disable(&adapter->q_vector[i]->napi);
1799 }
1797 } 1800 }
1798 1801
1799 1802
@@ -3717,7 +3720,8 @@ static void igb_free_all_tx_resources(struct igb_adapter *adapter)
3717 int i; 3720 int i;
3718 3721
3719 for (i = 0; i < adapter->num_tx_queues; i++) 3722 for (i = 0; i < adapter->num_tx_queues; i++)
3720 igb_free_tx_resources(adapter->tx_ring[i]); 3723 if (adapter->tx_ring[i])
3724 igb_free_tx_resources(adapter->tx_ring[i]);
3721} 3725}
3722 3726
3723void igb_unmap_and_free_tx_resource(struct igb_ring *ring, 3727void igb_unmap_and_free_tx_resource(struct igb_ring *ring,
@@ -3782,7 +3786,8 @@ static void igb_clean_all_tx_rings(struct igb_adapter *adapter)
3782 int i; 3786 int i;
3783 3787
3784 for (i = 0; i < adapter->num_tx_queues; i++) 3788 for (i = 0; i < adapter->num_tx_queues; i++)
3785 igb_clean_tx_ring(adapter->tx_ring[i]); 3789 if (adapter->tx_ring[i])
3790 igb_clean_tx_ring(adapter->tx_ring[i]);
3786} 3791}
3787 3792
3788/** 3793/**
@@ -3819,7 +3824,8 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter)
3819 int i; 3824 int i;
3820 3825
3821 for (i = 0; i < adapter->num_rx_queues; i++) 3826 for (i = 0; i < adapter->num_rx_queues; i++)
3822 igb_free_rx_resources(adapter->rx_ring[i]); 3827 if (adapter->rx_ring[i])
3828 igb_free_rx_resources(adapter->rx_ring[i]);
3823} 3829}
3824 3830
3825/** 3831/**
@@ -3874,7 +3880,8 @@ static void igb_clean_all_rx_rings(struct igb_adapter *adapter)
3874 int i; 3880 int i;
3875 3881
3876 for (i = 0; i < adapter->num_rx_queues; i++) 3882 for (i = 0; i < adapter->num_rx_queues; i++)
3877 igb_clean_rx_ring(adapter->rx_ring[i]); 3883 if (adapter->rx_ring[i])
3884 igb_clean_rx_ring(adapter->rx_ring[i]);
3878} 3885}
3879 3886
3880/** 3887/**
@@ -7404,6 +7411,8 @@ static int igb_resume(struct device *dev)
7404 pci_restore_state(pdev); 7411 pci_restore_state(pdev);
7405 pci_save_state(pdev); 7412 pci_save_state(pdev);
7406 7413
7414 if (!pci_device_is_present(pdev))
7415 return -ENODEV;
7407 err = pci_enable_device_mem(pdev); 7416 err = pci_enable_device_mem(pdev);
7408 if (err) { 7417 if (err) {
7409 dev_err(&pdev->dev, 7418 dev_err(&pdev->dev,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d2df4e3d1032..cc51554c9e99 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -3936,8 +3936,8 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
3936 * if SR-IOV and VMDQ are disabled - otherwise ensure 3936 * if SR-IOV and VMDQ are disabled - otherwise ensure
3937 * that hardware VLAN filters remain enabled. 3937 * that hardware VLAN filters remain enabled.
3938 */ 3938 */
3939 if (!(adapter->flags & (IXGBE_FLAG_VMDQ_ENABLED | 3939 if (adapter->flags & (IXGBE_FLAG_VMDQ_ENABLED |
3940 IXGBE_FLAG_SRIOV_ENABLED))) 3940 IXGBE_FLAG_SRIOV_ENABLED))
3941 vlnctrl |= (IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN); 3941 vlnctrl |= (IXGBE_VLNCTRL_VFE | IXGBE_VLNCTRL_CFIEN);
3942 } else { 3942 } else {
3943 if (netdev->flags & IFF_ALLMULTI) { 3943 if (netdev->flags & IFF_ALLMULTI) {
@@ -7669,6 +7669,8 @@ static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
7669 return -EOPNOTSUPP; 7669 return -EOPNOTSUPP;
7670 7670
7671 br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); 7671 br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC);
7672 if (!br_spec)
7673 return -EINVAL;
7672 7674
7673 nla_for_each_nested(attr, br_spec, rem) { 7675 nla_for_each_nested(attr, br_spec, rem) {
7674 __u16 mode; 7676 __u16 mode;
@@ -7677,6 +7679,9 @@ static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
7677 if (nla_type(attr) != IFLA_BRIDGE_MODE) 7679 if (nla_type(attr) != IFLA_BRIDGE_MODE)
7678 continue; 7680 continue;
7679 7681
7682 if (nla_len(attr) < sizeof(mode))
7683 return -EINVAL;
7684
7680 mode = nla_get_u16(attr); 7685 mode = nla_get_u16(attr);
7681 if (mode == BRIDGE_MODE_VEPA) { 7686 if (mode == BRIDGE_MODE_VEPA) {
7682 reg = 0; 7687 reg = 0;
@@ -7979,6 +7984,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
7979 int i, err, pci_using_dac, expected_gts; 7984 int i, err, pci_using_dac, expected_gts;
7980 unsigned int indices = MAX_TX_QUEUES; 7985 unsigned int indices = MAX_TX_QUEUES;
7981 u8 part_str[IXGBE_PBANUM_LENGTH]; 7986 u8 part_str[IXGBE_PBANUM_LENGTH];
7987 bool disable_dev = false;
7982#ifdef IXGBE_FCOE 7988#ifdef IXGBE_FCOE
7983 u16 device_caps; 7989 u16 device_caps;
7984#endif 7990#endif
@@ -8369,13 +8375,14 @@ err_sw_init:
8369 iounmap(adapter->io_addr); 8375 iounmap(adapter->io_addr);
8370 kfree(adapter->mac_table); 8376 kfree(adapter->mac_table);
8371err_ioremap: 8377err_ioremap:
8378 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
8372 free_netdev(netdev); 8379 free_netdev(netdev);
8373err_alloc_etherdev: 8380err_alloc_etherdev:
8374 pci_release_selected_regions(pdev, 8381 pci_release_selected_regions(pdev,
8375 pci_select_bars(pdev, IORESOURCE_MEM)); 8382 pci_select_bars(pdev, IORESOURCE_MEM));
8376err_pci_reg: 8383err_pci_reg:
8377err_dma: 8384err_dma:
8378 if (!adapter || !test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) 8385 if (!adapter || disable_dev)
8379 pci_disable_device(pdev); 8386 pci_disable_device(pdev);
8380 return err; 8387 return err;
8381} 8388}
@@ -8393,6 +8400,7 @@ static void ixgbe_remove(struct pci_dev *pdev)
8393{ 8400{
8394 struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 8401 struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);
8395 struct net_device *netdev = adapter->netdev; 8402 struct net_device *netdev = adapter->netdev;
8403 bool disable_dev;
8396 8404
8397 ixgbe_dbg_adapter_exit(adapter); 8405 ixgbe_dbg_adapter_exit(adapter);
8398 8406
@@ -8442,11 +8450,12 @@ static void ixgbe_remove(struct pci_dev *pdev)
8442 e_dev_info("complete\n"); 8450 e_dev_info("complete\n");
8443 8451
8444 kfree(adapter->mac_table); 8452 kfree(adapter->mac_table);
8453 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state);
8445 free_netdev(netdev); 8454 free_netdev(netdev);
8446 8455
8447 pci_disable_pcie_error_reporting(pdev); 8456 pci_disable_pcie_error_reporting(pdev);
8448 8457
8449 if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) 8458 if (disable_dev)
8450 pci_disable_device(pdev); 8459 pci_disable_device(pdev);
8451} 8460}
8452 8461
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index d47b19f27c35..28b81ae09b5a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -635,7 +635,6 @@ s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
635 **/ 635 **/
636s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw) 636s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
637{ 637{
638 s32 status;
639 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; 638 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
640 bool autoneg = false; 639 bool autoneg = false;
641 ixgbe_link_speed speed; 640 ixgbe_link_speed speed;
@@ -700,8 +699,7 @@ s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
700 699
701 hw->phy.ops.write_reg(hw, MDIO_CTRL1, 700 hw->phy.ops.write_reg(hw, MDIO_CTRL1,
702 MDIO_MMD_AN, autoneg_reg); 701 MDIO_MMD_AN, autoneg_reg);
703 702 return 0;
704 return status;
705} 703}
706 704
707/** 705/**
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index b151a949f352..d44560d1d268 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1047,7 +1047,6 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
1047 int tx_index; 1047 int tx_index;
1048 struct tx_desc *desc; 1048 struct tx_desc *desc;
1049 u32 cmd_sts; 1049 u32 cmd_sts;
1050 struct sk_buff *skb;
1051 1050
1052 tx_index = txq->tx_used_desc; 1051 tx_index = txq->tx_used_desc;
1053 desc = &txq->tx_desc_area[tx_index]; 1052 desc = &txq->tx_desc_area[tx_index];
@@ -1066,19 +1065,22 @@ static int txq_reclaim(struct tx_queue *txq, int budget, int force)
1066 reclaimed++; 1065 reclaimed++;
1067 txq->tx_desc_count--; 1066 txq->tx_desc_count--;
1068 1067
1069 skb = NULL; 1068 if (!IS_TSO_HEADER(txq, desc->buf_ptr))
1070 if (cmd_sts & TX_LAST_DESC) 1069 dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr,
1071 skb = __skb_dequeue(&txq->tx_skb); 1070 desc->byte_cnt, DMA_TO_DEVICE);
1071
1072 if (cmd_sts & TX_ENABLE_INTERRUPT) {
1073 struct sk_buff *skb = __skb_dequeue(&txq->tx_skb);
1074
1075 if (!WARN_ON(!skb))
1076 dev_kfree_skb(skb);
1077 }
1072 1078
1073 if (cmd_sts & ERROR_SUMMARY) { 1079 if (cmd_sts & ERROR_SUMMARY) {
1074 netdev_info(mp->dev, "tx error\n"); 1080 netdev_info(mp->dev, "tx error\n");
1075 mp->dev->stats.tx_errors++; 1081 mp->dev->stats.tx_errors++;
1076 } 1082 }
1077 1083
1078 if (!IS_TSO_HEADER(txq, desc->buf_ptr))
1079 dma_unmap_single(mp->dev->dev.parent, desc->buf_ptr,
1080 desc->byte_cnt, DMA_TO_DEVICE);
1081 dev_kfree_skb(skb);
1082 } 1084 }
1083 1085
1084 __netif_tx_unlock_bh(nq); 1086 __netif_tx_unlock_bh(nq);
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index ece83f101526..fdf3e382e464 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -1692,6 +1692,7 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
1692{ 1692{
1693 struct mvpp2_prs_entry *pe; 1693 struct mvpp2_prs_entry *pe;
1694 int tid_aux, tid; 1694 int tid_aux, tid;
1695 int ret = 0;
1695 1696
1696 pe = mvpp2_prs_vlan_find(priv, tpid, ai); 1697 pe = mvpp2_prs_vlan_find(priv, tpid, ai);
1697 1698
@@ -1723,8 +1724,10 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
1723 break; 1724 break;
1724 } 1725 }
1725 1726
1726 if (tid <= tid_aux) 1727 if (tid <= tid_aux) {
1727 return -EINVAL; 1728 ret = -EINVAL;
1729 goto error;
1730 }
1728 1731
1729 memset(pe, 0 , sizeof(struct mvpp2_prs_entry)); 1732 memset(pe, 0 , sizeof(struct mvpp2_prs_entry));
1730 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN); 1733 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
@@ -1756,9 +1759,10 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
1756 1759
1757 mvpp2_prs_hw_write(priv, pe); 1760 mvpp2_prs_hw_write(priv, pe);
1758 1761
1762error:
1759 kfree(pe); 1763 kfree(pe);
1760 1764
1761 return 0; 1765 return ret;
1762} 1766}
1763 1767
1764/* Get first free double vlan ai number */ 1768/* Get first free double vlan ai number */
@@ -1821,7 +1825,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
1821 unsigned int port_map) 1825 unsigned int port_map)
1822{ 1826{
1823 struct mvpp2_prs_entry *pe; 1827 struct mvpp2_prs_entry *pe;
1824 int tid_aux, tid, ai; 1828 int tid_aux, tid, ai, ret = 0;
1825 1829
1826 pe = mvpp2_prs_double_vlan_find(priv, tpid1, tpid2); 1830 pe = mvpp2_prs_double_vlan_find(priv, tpid1, tpid2);
1827 1831
@@ -1838,8 +1842,10 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
1838 1842
1839 /* Set ai value for new double vlan entry */ 1843 /* Set ai value for new double vlan entry */
1840 ai = mvpp2_prs_double_vlan_ai_free_get(priv); 1844 ai = mvpp2_prs_double_vlan_ai_free_get(priv);
1841 if (ai < 0) 1845 if (ai < 0) {
1842 return ai; 1846 ret = ai;
1847 goto error;
1848 }
1843 1849
1844 /* Get first single/triple vlan tid */ 1850 /* Get first single/triple vlan tid */
1845 for (tid_aux = MVPP2_PE_FIRST_FREE_TID; 1851 for (tid_aux = MVPP2_PE_FIRST_FREE_TID;
@@ -1859,8 +1865,10 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
1859 break; 1865 break;
1860 } 1866 }
1861 1867
1862 if (tid >= tid_aux) 1868 if (tid >= tid_aux) {
1863 return -ERANGE; 1869 ret = -ERANGE;
1870 goto error;
1871 }
1864 1872
1865 memset(pe, 0, sizeof(struct mvpp2_prs_entry)); 1873 memset(pe, 0, sizeof(struct mvpp2_prs_entry));
1866 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN); 1874 mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
@@ -1887,8 +1895,9 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
1887 mvpp2_prs_tcam_port_map_set(pe, port_map); 1895 mvpp2_prs_tcam_port_map_set(pe, port_map);
1888 mvpp2_prs_hw_write(priv, pe); 1896 mvpp2_prs_hw_write(priv, pe);
1889 1897
1898error:
1890 kfree(pe); 1899 kfree(pe);
1891 return 0; 1900 return ret;
1892} 1901}
1893 1902
1894/* IPv4 header parsing for fragmentation and L4 offset */ 1903/* IPv4 header parsing for fragmentation and L4 offset */
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index f3032fec8fce..4d69e382b4e5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -1693,7 +1693,7 @@ int mlx4_en_start_port(struct net_device *dev)
1693 mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap); 1693 mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap);
1694 1694
1695#ifdef CONFIG_MLX4_EN_VXLAN 1695#ifdef CONFIG_MLX4_EN_VXLAN
1696 if (priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS) 1696 if (priv->mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN)
1697 vxlan_get_rx_port(dev); 1697 vxlan_get_rx_port(dev);
1698#endif 1698#endif
1699 priv->port_up = true; 1699 priv->port_up = true;
@@ -2281,8 +2281,16 @@ static void mlx4_en_add_vxlan_offloads(struct work_struct *work)
2281 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port, 2281 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
2282 VXLAN_STEER_BY_OUTER_MAC, 1); 2282 VXLAN_STEER_BY_OUTER_MAC, 1);
2283out: 2283out:
2284 if (ret) 2284 if (ret) {
2285 en_err(priv, "failed setting L2 tunnel configuration ret %d\n", ret); 2285 en_err(priv, "failed setting L2 tunnel configuration ret %d\n", ret);
2286 return;
2287 }
2288
2289 /* set offloads */
2290 priv->dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2291 NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL;
2292 priv->dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
2293 priv->dev->features |= NETIF_F_GSO_UDP_TUNNEL;
2286} 2294}
2287 2295
2288static void mlx4_en_del_vxlan_offloads(struct work_struct *work) 2296static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
@@ -2290,6 +2298,11 @@ static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
2290 int ret; 2298 int ret;
2291 struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, 2299 struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
2292 vxlan_del_task); 2300 vxlan_del_task);
2301 /* unset offloads */
2302 priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2303 NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL);
2304 priv->dev->hw_features &= ~NETIF_F_GSO_UDP_TUNNEL;
2305 priv->dev->features &= ~NETIF_F_GSO_UDP_TUNNEL;
2293 2306
2294 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port, 2307 ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
2295 VXLAN_STEER_BY_OUTER_MAC, 0); 2308 VXLAN_STEER_BY_OUTER_MAC, 0);
@@ -2342,6 +2355,11 @@ static void mlx4_en_del_vxlan_port(struct net_device *dev,
2342 2355
2343 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task); 2356 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
2344} 2357}
2358
2359static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev)
2360{
2361 return vxlan_gso_check(skb);
2362}
2345#endif 2363#endif
2346 2364
2347static const struct net_device_ops mlx4_netdev_ops = { 2365static const struct net_device_ops mlx4_netdev_ops = {
@@ -2373,6 +2391,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
2373#ifdef CONFIG_MLX4_EN_VXLAN 2391#ifdef CONFIG_MLX4_EN_VXLAN
2374 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2392 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2375 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2393 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2394 .ndo_gso_check = mlx4_en_gso_check,
2376#endif 2395#endif
2377}; 2396};
2378 2397
@@ -2403,6 +2422,11 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
2403 .ndo_rx_flow_steer = mlx4_en_filter_rfs, 2422 .ndo_rx_flow_steer = mlx4_en_filter_rfs,
2404#endif 2423#endif
2405 .ndo_get_phys_port_id = mlx4_en_get_phys_port_id, 2424 .ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
2425#ifdef CONFIG_MLX4_EN_VXLAN
2426 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2427 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2428 .ndo_gso_check = mlx4_en_gso_check,
2429#endif
2406}; 2430};
2407 2431
2408int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, 2432int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
@@ -2568,13 +2592,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2568 if (mdev->dev->caps.steering_mode != MLX4_STEERING_MODE_A0) 2592 if (mdev->dev->caps.steering_mode != MLX4_STEERING_MODE_A0)
2569 dev->priv_flags |= IFF_UNICAST_FLT; 2593 dev->priv_flags |= IFF_UNICAST_FLT;
2570 2594
2571 if (mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) {
2572 dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
2573 NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL;
2574 dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
2575 dev->features |= NETIF_F_GSO_UDP_TUNNEL;
2576 }
2577
2578 mdev->pndev[port] = dev; 2595 mdev->pndev[port] = dev;
2579 2596
2580 netif_carrier_off(dev); 2597 netif_carrier_off(dev);
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 5d2498dcf536..cd5cf6d957c7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -1546,7 +1546,7 @@ static int qp_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd,
1546 1546
1547 switch (op) { 1547 switch (op) {
1548 case RES_OP_RESERVE: 1548 case RES_OP_RESERVE:
1549 count = get_param_l(&in_param); 1549 count = get_param_l(&in_param) & 0xffffff;
1550 align = get_param_h(&in_param); 1550 align = get_param_h(&in_param);
1551 err = mlx4_grant_resource(dev, slave, RES_QP, count, 0); 1551 err = mlx4_grant_resource(dev, slave, RES_QP, count, 0);
1552 if (err) 1552 if (err)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index a278238a2db6..ad2c96a02a53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -374,15 +374,14 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
374 snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s", 374 snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s",
375 name, pci_name(dev->pdev)); 375 name, pci_name(dev->pdev));
376 eq->eqn = out.eq_number; 376 eq->eqn = out.eq_number;
377 eq->irqn = vecidx;
378 eq->dev = dev;
379 eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET;
377 err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, 380 err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0,
378 eq->name, eq); 381 eq->name, eq);
379 if (err) 382 if (err)
380 goto err_eq; 383 goto err_eq;
381 384
382 eq->irqn = vecidx;
383 eq->dev = dev;
384 eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET;
385
386 err = mlx5_debug_eq_add(dev, eq); 385 err = mlx5_debug_eq_add(dev, eq);
387 if (err) 386 if (err)
388 goto err_irq; 387 goto err_irq;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 3d8e8e489b2d..71b10b210792 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -864,14 +864,14 @@ static int init_one(struct pci_dev *pdev,
864 dev->profile = &profile[prof_sel]; 864 dev->profile = &profile[prof_sel];
865 dev->event = mlx5_core_event; 865 dev->event = mlx5_core_event;
866 866
867 INIT_LIST_HEAD(&priv->ctx_list);
868 spin_lock_init(&priv->ctx_lock);
867 err = mlx5_dev_init(dev, pdev); 869 err = mlx5_dev_init(dev, pdev);
868 if (err) { 870 if (err) {
869 dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err); 871 dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err);
870 goto out; 872 goto out;
871 } 873 }
872 874
873 INIT_LIST_HEAD(&priv->ctx_list);
874 spin_lock_init(&priv->ctx_lock);
875 err = mlx5_register_device(dev); 875 err = mlx5_register_device(dev);
876 if (err) { 876 if (err) {
877 dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err); 877 dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err);
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 0b2a1ccd276d..613037584d08 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -2762,7 +2762,8 @@ netxen_fw_poll_work(struct work_struct *work)
2762 if (test_bit(__NX_RESETTING, &adapter->state)) 2762 if (test_bit(__NX_RESETTING, &adapter->state))
2763 goto reschedule; 2763 goto reschedule;
2764 2764
2765 if (test_bit(__NX_DEV_UP, &adapter->state)) { 2765 if (test_bit(__NX_DEV_UP, &adapter->state) &&
2766 !(adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)) {
2766 if (!adapter->has_link_events) { 2767 if (!adapter->has_link_events) {
2767 2768
2768 netxen_nic_handle_phy_intr(adapter); 2769 netxen_nic_handle_phy_intr(adapter);
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index f5e29f7bdae3..a913b3ad2f89 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -503,6 +503,11 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,
503 503
504 adapter->flags |= QLCNIC_DEL_VXLAN_PORT; 504 adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
505} 505}
506
507static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev)
508{
509 return vxlan_gso_check(skb);
510}
506#endif 511#endif
507 512
508static const struct net_device_ops qlcnic_netdev_ops = { 513static const struct net_device_ops qlcnic_netdev_ops = {
@@ -526,6 +531,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
526#ifdef CONFIG_QLCNIC_VXLAN 531#ifdef CONFIG_QLCNIC_VXLAN
527 .ndo_add_vxlan_port = qlcnic_add_vxlan_port, 532 .ndo_add_vxlan_port = qlcnic_add_vxlan_port,
528 .ndo_del_vxlan_port = qlcnic_del_vxlan_port, 533 .ndo_del_vxlan_port = qlcnic_del_vxlan_port,
534 .ndo_gso_check = qlcnic_gso_check,
529#endif 535#endif
530#ifdef CONFIG_NET_POLL_CONTROLLER 536#ifdef CONFIG_NET_POLL_CONTROLLER
531 .ndo_poll_controller = qlcnic_poll_controller, 537 .ndo_poll_controller = qlcnic_poll_controller,
diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index f3a47147937d..9a49f42ac2ba 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -5,7 +5,6 @@
5config NET_VENDOR_QUALCOMM 5config NET_VENDOR_QUALCOMM
6 bool "Qualcomm devices" 6 bool "Qualcomm devices"
7 default y 7 default y
8 depends on SPI_MASTER && OF_GPIO
9 ---help--- 8 ---help---
10 If you have a network (Ethernet) card belonging to this class, say Y 9 If you have a network (Ethernet) card belonging to this class, say Y
11 and read the Ethernet-HOWTO, available from 10 and read the Ethernet-HOWTO, available from
@@ -20,7 +19,7 @@ if NET_VENDOR_QUALCOMM
20 19
21config QCA7000 20config QCA7000
22 tristate "Qualcomm Atheros QCA7000 support" 21 tristate "Qualcomm Atheros QCA7000 support"
23 depends on SPI_MASTER && OF_GPIO 22 depends on SPI_MASTER && OF
24 ---help--- 23 ---help---
25 This SPI protocol driver supports the Qualcomm Atheros QCA7000. 24 This SPI protocol driver supports the Qualcomm Atheros QCA7000.
26 25
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 002d4cdc319f..a77f05ce8325 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -180,7 +180,8 @@ static int efx_ef10_probe(struct efx_nic *efx)
180 EFX_MAX_CHANNELS, 180 EFX_MAX_CHANNELS,
181 resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]) / 181 resource_size(&efx->pci_dev->resource[EFX_MEM_BAR]) /
182 (EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES)); 182 (EFX_VI_PAGE_SIZE * EFX_TXQ_TYPES));
183 BUG_ON(efx->max_channels == 0); 183 if (WARN_ON(efx->max_channels == 0))
184 return -EIO;
184 185
185 nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL); 186 nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL);
186 if (!nic_data) 187 if (!nic_data)
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 2c62208077fe..6cc3cf6f17c8 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2243,9 +2243,10 @@ static int smc_drv_probe(struct platform_device *pdev)
2243 const struct of_device_id *match = NULL; 2243 const struct of_device_id *match = NULL;
2244 struct smc_local *lp; 2244 struct smc_local *lp;
2245 struct net_device *ndev; 2245 struct net_device *ndev;
2246 struct resource *res, *ires; 2246 struct resource *res;
2247 unsigned int __iomem *addr; 2247 unsigned int __iomem *addr;
2248 unsigned long irq_flags = SMC_IRQ_FLAGS; 2248 unsigned long irq_flags = SMC_IRQ_FLAGS;
2249 unsigned long irq_resflags;
2249 int ret; 2250 int ret;
2250 2251
2251 ndev = alloc_etherdev(sizeof(struct smc_local)); 2252 ndev = alloc_etherdev(sizeof(struct smc_local));
@@ -2337,16 +2338,19 @@ static int smc_drv_probe(struct platform_device *pdev)
2337 goto out_free_netdev; 2338 goto out_free_netdev;
2338 } 2339 }
2339 2340
2340 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 2341 ndev->irq = platform_get_irq(pdev, 0);
2341 if (!ires) { 2342 if (ndev->irq <= 0) {
2342 ret = -ENODEV; 2343 ret = -ENODEV;
2343 goto out_release_io; 2344 goto out_release_io;
2344 } 2345 }
2345 2346 /*
2346 ndev->irq = ires->start; 2347 * If this platform does not specify any special irqflags, or if
2347 2348 * the resource supplies a trigger, override the irqflags with
2348 if (irq_flags == -1 || ires->flags & IRQF_TRIGGER_MASK) 2349 * the trigger flags from the resource.
2349 irq_flags = ires->flags & IRQF_TRIGGER_MASK; 2350 */
2351 irq_resflags = irqd_get_trigger_type(irq_get_irq_data(ndev->irq));
2352 if (irq_flags == -1 || irq_resflags & IRQF_TRIGGER_MASK)
2353 irq_flags = irq_resflags & IRQF_TRIGGER_MASK;
2350 2354
2351 ret = smc_request_attrib(pdev, ndev); 2355 ret = smc_request_attrib(pdev, ndev);
2352 if (ret) 2356 if (ret)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index affb29da353e..77ed74561e5f 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1342,6 +1342,42 @@ static void smsc911x_rx_multicast_update_workaround(struct smsc911x_data *pdata)
1342 spin_unlock(&pdata->mac_lock); 1342 spin_unlock(&pdata->mac_lock);
1343} 1343}
1344 1344
1345static int smsc911x_phy_general_power_up(struct smsc911x_data *pdata)
1346{
1347 int rc = 0;
1348
1349 if (!pdata->phy_dev)
1350 return rc;
1351
1352 /* If the internal PHY is in General Power-Down mode, all, except the
1353 * management interface, is powered-down and stays in that condition as
1354 * long as Phy register bit 0.11 is HIGH.
1355 *
1356 * In that case, clear the bit 0.11, so the PHY powers up and we can
1357 * access to the phy registers.
1358 */
1359 rc = phy_read(pdata->phy_dev, MII_BMCR);
1360 if (rc < 0) {
1361 SMSC_WARN(pdata, drv, "Failed reading PHY control reg");
1362 return rc;
1363 }
1364
1365 /* If the PHY general power-down bit is not set is not necessary to
1366 * disable the general power down-mode.
1367 */
1368 if (rc & BMCR_PDOWN) {
1369 rc = phy_write(pdata->phy_dev, MII_BMCR, rc & ~BMCR_PDOWN);
1370 if (rc < 0) {
1371 SMSC_WARN(pdata, drv, "Failed writing PHY control reg");
1372 return rc;
1373 }
1374
1375 usleep_range(1000, 1500);
1376 }
1377
1378 return 0;
1379}
1380
1345static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata) 1381static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
1346{ 1382{
1347 int rc = 0; 1383 int rc = 0;
@@ -1356,12 +1392,8 @@ static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
1356 return rc; 1392 return rc;
1357 } 1393 }
1358 1394
1359 /* 1395 /* Only disable if energy detect mode is already enabled */
1360 * If energy is detected the PHY is already awake so is not necessary 1396 if (rc & MII_LAN83C185_EDPWRDOWN) {
1361 * to disable the energy detect power-down mode.
1362 */
1363 if ((rc & MII_LAN83C185_EDPWRDOWN) &&
1364 !(rc & MII_LAN83C185_ENERGYON)) {
1365 /* Disable energy detect mode for this SMSC Transceivers */ 1397 /* Disable energy detect mode for this SMSC Transceivers */
1366 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1398 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS,
1367 rc & (~MII_LAN83C185_EDPWRDOWN)); 1399 rc & (~MII_LAN83C185_EDPWRDOWN));
@@ -1370,8 +1402,8 @@ static int smsc911x_phy_disable_energy_detect(struct smsc911x_data *pdata)
1370 SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1402 SMSC_WARN(pdata, drv, "Failed writing PHY control reg");
1371 return rc; 1403 return rc;
1372 } 1404 }
1373 1405 /* Allow PHY to wakeup */
1374 mdelay(1); 1406 mdelay(2);
1375 } 1407 }
1376 1408
1377 return 0; 1409 return 0;
@@ -1393,7 +1425,6 @@ static int smsc911x_phy_enable_energy_detect(struct smsc911x_data *pdata)
1393 1425
1394 /* Only enable if energy detect mode is already disabled */ 1426 /* Only enable if energy detect mode is already disabled */
1395 if (!(rc & MII_LAN83C185_EDPWRDOWN)) { 1427 if (!(rc & MII_LAN83C185_EDPWRDOWN)) {
1396 mdelay(100);
1397 /* Enable energy detect mode for this SMSC Transceivers */ 1428 /* Enable energy detect mode for this SMSC Transceivers */
1398 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS, 1429 rc = phy_write(pdata->phy_dev, MII_LAN83C185_CTRL_STATUS,
1399 rc | MII_LAN83C185_EDPWRDOWN); 1430 rc | MII_LAN83C185_EDPWRDOWN);
@@ -1402,8 +1433,6 @@ static int smsc911x_phy_enable_energy_detect(struct smsc911x_data *pdata)
1402 SMSC_WARN(pdata, drv, "Failed writing PHY control reg"); 1433 SMSC_WARN(pdata, drv, "Failed writing PHY control reg");
1403 return rc; 1434 return rc;
1404 } 1435 }
1405
1406 mdelay(1);
1407 } 1436 }
1408 return 0; 1437 return 0;
1409} 1438}
@@ -1415,6 +1444,16 @@ static int smsc911x_soft_reset(struct smsc911x_data *pdata)
1415 int ret; 1444 int ret;
1416 1445
1417 /* 1446 /*
1447 * Make sure to power-up the PHY chip before doing a reset, otherwise
1448 * the reset fails.
1449 */
1450 ret = smsc911x_phy_general_power_up(pdata);
1451 if (ret) {
1452 SMSC_WARN(pdata, drv, "Failed to power-up the PHY chip");
1453 return ret;
1454 }
1455
1456 /*
1418 * LAN9210/LAN9211/LAN9220/LAN9221 chips have an internal PHY that 1457 * LAN9210/LAN9211/LAN9220/LAN9221 chips have an internal PHY that
1419 * are initialized in a Energy Detect Power-Down mode that prevents 1458 * are initialized in a Energy Detect Power-Down mode that prevents
1420 * the MAC chip to be software reseted. So we have to wakeup the PHY 1459 * the MAC chip to be software reseted. So we have to wakeup the PHY
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 6f77a46c7e2c..18c46bb0f3bf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -276,6 +276,7 @@ static void stmmac_eee_ctrl_timer(unsigned long arg)
276bool stmmac_eee_init(struct stmmac_priv *priv) 276bool stmmac_eee_init(struct stmmac_priv *priv)
277{ 277{
278 char *phy_bus_name = priv->plat->phy_bus_name; 278 char *phy_bus_name = priv->plat->phy_bus_name;
279 unsigned long flags;
279 bool ret = false; 280 bool ret = false;
280 281
281 /* Using PCS we cannot dial with the phy registers at this stage 282 /* Using PCS we cannot dial with the phy registers at this stage
@@ -300,6 +301,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
300 * changed). 301 * changed).
301 * In that case the driver disable own timers. 302 * In that case the driver disable own timers.
302 */ 303 */
304 spin_lock_irqsave(&priv->lock, flags);
303 if (priv->eee_active) { 305 if (priv->eee_active) {
304 pr_debug("stmmac: disable EEE\n"); 306 pr_debug("stmmac: disable EEE\n");
305 del_timer_sync(&priv->eee_ctrl_timer); 307 del_timer_sync(&priv->eee_ctrl_timer);
@@ -307,9 +309,11 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
307 tx_lpi_timer); 309 tx_lpi_timer);
308 } 310 }
309 priv->eee_active = 0; 311 priv->eee_active = 0;
312 spin_unlock_irqrestore(&priv->lock, flags);
310 goto out; 313 goto out;
311 } 314 }
312 /* Activate the EEE and start timers */ 315 /* Activate the EEE and start timers */
316 spin_lock_irqsave(&priv->lock, flags);
313 if (!priv->eee_active) { 317 if (!priv->eee_active) {
314 priv->eee_active = 1; 318 priv->eee_active = 1;
315 init_timer(&priv->eee_ctrl_timer); 319 init_timer(&priv->eee_ctrl_timer);
@@ -325,9 +329,10 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
325 /* Set HW EEE according to the speed */ 329 /* Set HW EEE according to the speed */
326 priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); 330 priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link);
327 331
328 pr_debug("stmmac: Energy-Efficient Ethernet initialized\n");
329
330 ret = true; 332 ret = true;
333 spin_unlock_irqrestore(&priv->lock, flags);
334
335 pr_debug("stmmac: Energy-Efficient Ethernet initialized\n");
331 } 336 }
332out: 337out:
333 return ret; 338 return ret;
@@ -760,12 +765,12 @@ static void stmmac_adjust_link(struct net_device *dev)
760 if (new_state && netif_msg_link(priv)) 765 if (new_state && netif_msg_link(priv))
761 phy_print_status(phydev); 766 phy_print_status(phydev);
762 767
768 spin_unlock_irqrestore(&priv->lock, flags);
769
763 /* At this stage, it could be needed to setup the EEE or adjust some 770 /* At this stage, it could be needed to setup the EEE or adjust some
764 * MAC related HW registers. 771 * MAC related HW registers.
765 */ 772 */
766 priv->eee_enabled = stmmac_eee_init(priv); 773 priv->eee_enabled = stmmac_eee_init(priv);
767
768 spin_unlock_irqrestore(&priv->lock, flags);
769} 774}
770 775
771/** 776/**
@@ -959,12 +964,12 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv)
959} 964}
960 965
961static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, 966static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
962 int i) 967 int i, gfp_t flags)
963{ 968{
964 struct sk_buff *skb; 969 struct sk_buff *skb;
965 970
966 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, 971 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN,
967 GFP_KERNEL); 972 flags);
968 if (!skb) { 973 if (!skb) {
969 pr_err("%s: Rx init fails; skb is NULL\n", __func__); 974 pr_err("%s: Rx init fails; skb is NULL\n", __func__);
970 return -ENOMEM; 975 return -ENOMEM;
@@ -1006,7 +1011,7 @@ static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i)
1006 * and allocates the socket buffers. It suppors the chained and ring 1011 * and allocates the socket buffers. It suppors the chained and ring
1007 * modes. 1012 * modes.
1008 */ 1013 */
1009static int init_dma_desc_rings(struct net_device *dev) 1014static int init_dma_desc_rings(struct net_device *dev, gfp_t flags)
1010{ 1015{
1011 int i; 1016 int i;
1012 struct stmmac_priv *priv = netdev_priv(dev); 1017 struct stmmac_priv *priv = netdev_priv(dev);
@@ -1041,7 +1046,7 @@ static int init_dma_desc_rings(struct net_device *dev)
1041 else 1046 else
1042 p = priv->dma_rx + i; 1047 p = priv->dma_rx + i;
1043 1048
1044 ret = stmmac_init_rx_buffers(priv, p, i); 1049 ret = stmmac_init_rx_buffers(priv, p, i, flags);
1045 if (ret) 1050 if (ret)
1046 goto err_init_rx_buffers; 1051 goto err_init_rx_buffers;
1047 1052
@@ -1647,11 +1652,6 @@ static int stmmac_hw_setup(struct net_device *dev)
1647 struct stmmac_priv *priv = netdev_priv(dev); 1652 struct stmmac_priv *priv = netdev_priv(dev);
1648 int ret; 1653 int ret;
1649 1654
1650 ret = init_dma_desc_rings(dev);
1651 if (ret < 0) {
1652 pr_err("%s: DMA descriptors initialization failed\n", __func__);
1653 return ret;
1654 }
1655 /* DMA initialization and SW reset */ 1655 /* DMA initialization and SW reset */
1656 ret = stmmac_init_dma_engine(priv); 1656 ret = stmmac_init_dma_engine(priv);
1657 if (ret < 0) { 1657 if (ret < 0) {
@@ -1705,10 +1705,6 @@ static int stmmac_hw_setup(struct net_device *dev)
1705 } 1705 }
1706 priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; 1706 priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS;
1707 1707
1708 priv->eee_enabled = stmmac_eee_init(priv);
1709
1710 stmmac_init_tx_coalesce(priv);
1711
1712 if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { 1708 if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) {
1713 priv->rx_riwt = MAX_DMA_RIWT; 1709 priv->rx_riwt = MAX_DMA_RIWT;
1714 priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); 1710 priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT);
@@ -1761,12 +1757,20 @@ static int stmmac_open(struct net_device *dev)
1761 goto dma_desc_error; 1757 goto dma_desc_error;
1762 } 1758 }
1763 1759
1760 ret = init_dma_desc_rings(dev, GFP_KERNEL);
1761 if (ret < 0) {
1762 pr_err("%s: DMA descriptors initialization failed\n", __func__);
1763 goto init_error;
1764 }
1765
1764 ret = stmmac_hw_setup(dev); 1766 ret = stmmac_hw_setup(dev);
1765 if (ret < 0) { 1767 if (ret < 0) {
1766 pr_err("%s: Hw setup failed\n", __func__); 1768 pr_err("%s: Hw setup failed\n", __func__);
1767 goto init_error; 1769 goto init_error;
1768 } 1770 }
1769 1771
1772 stmmac_init_tx_coalesce(priv);
1773
1770 if (priv->phydev) 1774 if (priv->phydev)
1771 phy_start(priv->phydev); 1775 phy_start(priv->phydev);
1772 1776
@@ -1894,7 +1898,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
1894 unsigned int nopaged_len = skb_headlen(skb); 1898 unsigned int nopaged_len = skb_headlen(skb);
1895 unsigned int enh_desc = priv->plat->enh_desc; 1899 unsigned int enh_desc = priv->plat->enh_desc;
1896 1900
1901 spin_lock(&priv->tx_lock);
1902
1897 if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { 1903 if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) {
1904 spin_unlock(&priv->tx_lock);
1898 if (!netif_queue_stopped(dev)) { 1905 if (!netif_queue_stopped(dev)) {
1899 netif_stop_queue(dev); 1906 netif_stop_queue(dev);
1900 /* This is a hard error, log it. */ 1907 /* This is a hard error, log it. */
@@ -1903,8 +1910,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
1903 return NETDEV_TX_BUSY; 1910 return NETDEV_TX_BUSY;
1904 } 1911 }
1905 1912
1906 spin_lock(&priv->tx_lock);
1907
1908 if (priv->tx_path_in_lpi_mode) 1913 if (priv->tx_path_in_lpi_mode)
1909 stmmac_disable_eee_mode(priv); 1914 stmmac_disable_eee_mode(priv);
1910 1915
@@ -2025,6 +2030,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
2025 return NETDEV_TX_OK; 2030 return NETDEV_TX_OK;
2026 2031
2027dma_map_err: 2032dma_map_err:
2033 spin_unlock(&priv->tx_lock);
2028 dev_err(priv->device, "Tx dma map failed\n"); 2034 dev_err(priv->device, "Tx dma map failed\n");
2029 dev_kfree_skb(skb); 2035 dev_kfree_skb(skb);
2030 priv->dev->stats.tx_dropped++; 2036 priv->dev->stats.tx_dropped++;
@@ -2281,9 +2287,7 @@ static void stmmac_set_rx_mode(struct net_device *dev)
2281{ 2287{
2282 struct stmmac_priv *priv = netdev_priv(dev); 2288 struct stmmac_priv *priv = netdev_priv(dev);
2283 2289
2284 spin_lock(&priv->lock);
2285 priv->hw->mac->set_filter(priv->hw, dev); 2290 priv->hw->mac->set_filter(priv->hw, dev);
2286 spin_unlock(&priv->lock);
2287} 2291}
2288 2292
2289/** 2293/**
@@ -2950,7 +2954,7 @@ int stmmac_suspend(struct net_device *ndev)
2950 stmmac_set_mac(priv->ioaddr, false); 2954 stmmac_set_mac(priv->ioaddr, false);
2951 pinctrl_pm_select_sleep_state(priv->device); 2955 pinctrl_pm_select_sleep_state(priv->device);
2952 /* Disable clock in case of PWM is off */ 2956 /* Disable clock in case of PWM is off */
2953 clk_disable_unprepare(priv->stmmac_clk); 2957 clk_disable(priv->stmmac_clk);
2954 } 2958 }
2955 spin_unlock_irqrestore(&priv->lock, flags); 2959 spin_unlock_irqrestore(&priv->lock, flags);
2956 2960
@@ -2982,7 +2986,7 @@ int stmmac_resume(struct net_device *ndev)
2982 } else { 2986 } else {
2983 pinctrl_pm_select_default_state(priv->device); 2987 pinctrl_pm_select_default_state(priv->device);
2984 /* enable the clk prevously disabled */ 2988 /* enable the clk prevously disabled */
2985 clk_prepare_enable(priv->stmmac_clk); 2989 clk_enable(priv->stmmac_clk);
2986 /* reset the phy so that it's ready */ 2990 /* reset the phy so that it's ready */
2987 if (priv->mii) 2991 if (priv->mii)
2988 stmmac_mdio_reset(priv->mii); 2992 stmmac_mdio_reset(priv->mii);
@@ -2990,7 +2994,9 @@ int stmmac_resume(struct net_device *ndev)
2990 2994
2991 netif_device_attach(ndev); 2995 netif_device_attach(ndev);
2992 2996
2997 init_dma_desc_rings(ndev, GFP_ATOMIC);
2993 stmmac_hw_setup(ndev); 2998 stmmac_hw_setup(ndev);
2999 stmmac_init_tx_coalesce(priv);
2994 3000
2995 napi_enable(&priv->napi); 3001 napi_enable(&priv->napi);
2996 3002
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index db56fa7ce8f9..5b0da3986216 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -177,12 +177,6 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
177 */ 177 */
178 plat->maxmtu = JUMBO_LEN; 178 plat->maxmtu = JUMBO_LEN;
179 179
180 /* Set default value for multicast hash bins */
181 plat->multicast_filter_bins = HASH_TABLE_SIZE;
182
183 /* Set default value for unicast filter entries */
184 plat->unicast_filter_entries = 1;
185
186 /* 180 /*
187 * Currently only the properties needed on SPEAr600 181 * Currently only the properties needed on SPEAr600
188 * are provided. All other properties should be added 182 * are provided. All other properties should be added
@@ -270,6 +264,13 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
270 return PTR_ERR(addr); 264 return PTR_ERR(addr);
271 265
272 plat_dat = dev_get_platdata(&pdev->dev); 266 plat_dat = dev_get_platdata(&pdev->dev);
267
268 /* Set default value for multicast hash bins */
269 plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
270
271 /* Set default value for unicast filter entries */
272 plat_dat->unicast_filter_entries = 1;
273
273 if (pdev->dev.of_node) { 274 if (pdev->dev.of_node) {
274 if (!plat_dat) 275 if (!plat_dat)
275 plat_dat = devm_kzalloc(&pdev->dev, 276 plat_dat = devm_kzalloc(&pdev->dev,
diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 72c8525d5457..9c014803b03b 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -1262,6 +1262,7 @@ static void happy_meal_init_rings(struct happy_meal *hp)
1262 HMD(("init rxring, ")); 1262 HMD(("init rxring, "));
1263 for (i = 0; i < RX_RING_SIZE; i++) { 1263 for (i = 0; i < RX_RING_SIZE; i++) {
1264 struct sk_buff *skb; 1264 struct sk_buff *skb;
1265 u32 mapping;
1265 1266
1266 skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC); 1267 skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
1267 if (!skb) { 1268 if (!skb) {
@@ -1272,10 +1273,16 @@ static void happy_meal_init_rings(struct happy_meal *hp)
1272 1273
1273 /* Because we reserve afterwards. */ 1274 /* Because we reserve afterwards. */
1274 skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); 1275 skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
1276 mapping = dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE,
1277 DMA_FROM_DEVICE);
1278 if (dma_mapping_error(hp->dma_dev, mapping)) {
1279 dev_kfree_skb_any(skb);
1280 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 0, 0);
1281 continue;
1282 }
1275 hme_write_rxd(hp, &hb->happy_meal_rxd[i], 1283 hme_write_rxd(hp, &hb->happy_meal_rxd[i],
1276 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), 1284 (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)),
1277 dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, 1285 mapping);
1278 DMA_FROM_DEVICE));
1279 skb_reserve(skb, RX_OFFSET); 1286 skb_reserve(skb, RX_OFFSET);
1280 } 1287 }
1281 1288
@@ -2020,6 +2027,7 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2020 skb = hp->rx_skbs[elem]; 2027 skb = hp->rx_skbs[elem];
2021 if (len > RX_COPY_THRESHOLD) { 2028 if (len > RX_COPY_THRESHOLD) {
2022 struct sk_buff *new_skb; 2029 struct sk_buff *new_skb;
2030 u32 mapping;
2023 2031
2024 /* Now refill the entry, if we can. */ 2032 /* Now refill the entry, if we can. */
2025 new_skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC); 2033 new_skb = happy_meal_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
@@ -2027,13 +2035,21 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev)
2027 drops++; 2035 drops++;
2028 goto drop_it; 2036 goto drop_it;
2029 } 2037 }
2038 skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
2039 mapping = dma_map_single(hp->dma_dev, new_skb->data,
2040 RX_BUF_ALLOC_SIZE,
2041 DMA_FROM_DEVICE);
2042 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) {
2043 dev_kfree_skb_any(new_skb);
2044 drops++;
2045 goto drop_it;
2046 }
2047
2030 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); 2048 dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE);
2031 hp->rx_skbs[elem] = new_skb; 2049 hp->rx_skbs[elem] = new_skb;
2032 skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4));
2033 hme_write_rxd(hp, this, 2050 hme_write_rxd(hp, this,
2034 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), 2051 (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)),
2035 dma_map_single(hp->dma_dev, new_skb->data, RX_BUF_ALLOC_SIZE, 2052 mapping);
2036 DMA_FROM_DEVICE));
2037 skb_reserve(new_skb, RX_OFFSET); 2053 skb_reserve(new_skb, RX_OFFSET);
2038 2054
2039 /* Trim the original skb for the netif. */ 2055 /* Trim the original skb for the netif. */
@@ -2248,6 +2264,25 @@ static void happy_meal_tx_timeout(struct net_device *dev)
2248 netif_wake_queue(dev); 2264 netif_wake_queue(dev);
2249} 2265}
2250 2266
2267static void unmap_partial_tx_skb(struct happy_meal *hp, u32 first_mapping,
2268 u32 first_len, u32 first_entry, u32 entry)
2269{
2270 struct happy_meal_txd *txbase = &hp->happy_block->happy_meal_txd[0];
2271
2272 dma_unmap_single(hp->dma_dev, first_mapping, first_len, DMA_TO_DEVICE);
2273
2274 first_entry = NEXT_TX(first_entry);
2275 while (first_entry != entry) {
2276 struct happy_meal_txd *this = &txbase[first_entry];
2277 u32 addr, len;
2278
2279 addr = hme_read_desc32(hp, &this->tx_addr);
2280 len = hme_read_desc32(hp, &this->tx_flags);
2281 len &= TXFLAG_SIZE;
2282 dma_unmap_page(hp->dma_dev, addr, len, DMA_TO_DEVICE);
2283 }
2284}
2285
2251static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb, 2286static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
2252 struct net_device *dev) 2287 struct net_device *dev)
2253{ 2288{
@@ -2284,6 +2319,8 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
2284 2319
2285 len = skb->len; 2320 len = skb->len;
2286 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); 2321 mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE);
2322 if (unlikely(dma_mapping_error(hp->dma_dev, mapping)))
2323 goto out_dma_error;
2287 tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); 2324 tx_flags |= (TXFLAG_SOP | TXFLAG_EOP);
2288 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], 2325 hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry],
2289 (tx_flags | (len & TXFLAG_SIZE)), 2326 (tx_flags | (len & TXFLAG_SIZE)),
@@ -2299,6 +2336,8 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
2299 first_len = skb_headlen(skb); 2336 first_len = skb_headlen(skb);
2300 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, 2337 first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len,
2301 DMA_TO_DEVICE); 2338 DMA_TO_DEVICE);
2339 if (unlikely(dma_mapping_error(hp->dma_dev, first_mapping)))
2340 goto out_dma_error;
2302 entry = NEXT_TX(entry); 2341 entry = NEXT_TX(entry);
2303 2342
2304 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { 2343 for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) {
@@ -2308,6 +2347,11 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
2308 len = skb_frag_size(this_frag); 2347 len = skb_frag_size(this_frag);
2309 mapping = skb_frag_dma_map(hp->dma_dev, this_frag, 2348 mapping = skb_frag_dma_map(hp->dma_dev, this_frag,
2310 0, len, DMA_TO_DEVICE); 2349 0, len, DMA_TO_DEVICE);
2350 if (unlikely(dma_mapping_error(hp->dma_dev, mapping))) {
2351 unmap_partial_tx_skb(hp, first_mapping, first_len,
2352 first_entry, entry);
2353 goto out_dma_error;
2354 }
2311 this_txflags = tx_flags; 2355 this_txflags = tx_flags;
2312 if (frag == skb_shinfo(skb)->nr_frags - 1) 2356 if (frag == skb_shinfo(skb)->nr_frags - 1)
2313 this_txflags |= TXFLAG_EOP; 2357 this_txflags |= TXFLAG_EOP;
@@ -2333,6 +2377,14 @@ static netdev_tx_t happy_meal_start_xmit(struct sk_buff *skb,
2333 2377
2334 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); 2378 tx_add_log(hp, TXLOG_ACTION_TXMIT, 0);
2335 return NETDEV_TX_OK; 2379 return NETDEV_TX_OK;
2380
2381out_dma_error:
2382 hp->tx_skbs[hp->tx_new] = NULL;
2383 spin_unlock_irq(&hp->happy_lock);
2384
2385 dev_kfree_skb_any(skb);
2386 dev->stats.tx_dropped++;
2387 return NETDEV_TX_OK;
2336} 2388}
2337 2389
2338static struct net_device_stats *happy_meal_get_stats(struct net_device *dev) 2390static struct net_device_stats *happy_meal_get_stats(struct net_device *dev)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index d8794488f80a..c560f9aeb55d 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -129,9 +129,9 @@ do { \
129#define CPSW_VLAN_AWARE BIT(1) 129#define CPSW_VLAN_AWARE BIT(1)
130#define CPSW_ALE_VLAN_AWARE 1 130#define CPSW_ALE_VLAN_AWARE 1
131 131
132#define CPSW_FIFO_NORMAL_MODE (0 << 15) 132#define CPSW_FIFO_NORMAL_MODE (0 << 16)
133#define CPSW_FIFO_DUAL_MAC_MODE (1 << 15) 133#define CPSW_FIFO_DUAL_MAC_MODE (1 << 16)
134#define CPSW_FIFO_RATE_LIMIT_MODE (2 << 15) 134#define CPSW_FIFO_RATE_LIMIT_MODE (2 << 16)
135 135
136#define CPSW_INTPACEEN (0x3f << 16) 136#define CPSW_INTPACEEN (0x3f << 16)
137#define CPSW_INTPRESCALE_MASK (0x7FF << 0) 137#define CPSW_INTPRESCALE_MASK (0x7FF << 0)
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 3ae83879a75f..097ebe7077ac 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -785,7 +785,6 @@ int cpsw_ale_destroy(struct cpsw_ale *ale)
785{ 785{
786 if (!ale) 786 if (!ale)
787 return -EINVAL; 787 return -EINVAL;
788 cpsw_ale_stop(ale);
789 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0); 788 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0);
790 kfree(ale); 789 kfree(ale);
791 return 0; 790 return 0;
diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
index ab92f67da035..4a4388b813ac 100644
--- a/drivers/net/ethernet/ti/cpts.c
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -264,7 +264,7 @@ static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
264 264
265 switch (ptp_class & PTP_CLASS_PMASK) { 265 switch (ptp_class & PTP_CLASS_PMASK) {
266 case PTP_CLASS_IPV4: 266 case PTP_CLASS_IPV4:
267 offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 267 offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
268 break; 268 break;
269 case PTP_CLASS_IPV6: 269 case PTP_CLASS_IPV6:
270 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN; 270 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
index 9ce854f43917..6cbc56ad9ff4 100644
--- a/drivers/net/ieee802154/fakehard.c
+++ b/drivers/net/ieee802154/fakehard.c
@@ -377,17 +377,20 @@ static int ieee802154fake_probe(struct platform_device *pdev)
377 377
378 err = wpan_phy_register(phy); 378 err = wpan_phy_register(phy);
379 if (err) 379 if (err)
380 goto out; 380 goto err_phy_reg;
381 381
382 err = register_netdev(dev); 382 err = register_netdev(dev);
383 if (err < 0) 383 if (err)
384 goto out; 384 goto err_netdev_reg;
385 385
386 dev_info(&pdev->dev, "Added ieee802154 HardMAC hardware\n"); 386 dev_info(&pdev->dev, "Added ieee802154 HardMAC hardware\n");
387 return 0; 387 return 0;
388 388
389out: 389err_netdev_reg:
390 unregister_netdev(dev); 390 wpan_phy_unregister(phy);
391err_phy_reg:
392 free_netdev(dev);
393 wpan_phy_free(phy);
391 return err; 394 return err;
392} 395}
393 396
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 6f226de655a4..880cc090dc44 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -629,6 +629,8 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
629 if (skb->ip_summed == CHECKSUM_PARTIAL) { 629 if (skb->ip_summed == CHECKSUM_PARTIAL) {
630 vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 630 vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
631 vnet_hdr->csum_start = skb_checksum_start_offset(skb); 631 vnet_hdr->csum_start = skb_checksum_start_offset(skb);
632 if (vlan_tx_tag_present(skb))
633 vnet_hdr->csum_start += VLAN_HLEN;
632 vnet_hdr->csum_offset = skb->csum_offset; 634 vnet_hdr->csum_offset = skb->csum_offset;
633 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 635 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
634 vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID; 636 vnet_hdr->flags = VIRTIO_NET_HDR_F_DATA_VALID;
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 2954052706e8..e22e602beef3 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -791,7 +791,7 @@ static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
791 791
792 switch (type & PTP_CLASS_PMASK) { 792 switch (type & PTP_CLASS_PMASK) {
793 case PTP_CLASS_IPV4: 793 case PTP_CLASS_IPV4:
794 offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 794 offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
795 break; 795 break;
796 case PTP_CLASS_IPV6: 796 case PTP_CLASS_IPV6:
797 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN; 797 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
@@ -934,7 +934,7 @@ static int is_sync(struct sk_buff *skb, int type)
934 934
935 switch (type & PTP_CLASS_PMASK) { 935 switch (type & PTP_CLASS_PMASK) {
936 case PTP_CLASS_IPV4: 936 case PTP_CLASS_IPV4:
937 offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN; 937 offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
938 break; 938 break;
939 case PTP_CLASS_IPV6: 939 case PTP_CLASS_IPV6:
940 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN; 940 offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1dfffdc9dfc3..767cd110f496 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -352,6 +352,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
352{ 352{
353 struct mii_ioctl_data *mii_data = if_mii(ifr); 353 struct mii_ioctl_data *mii_data = if_mii(ifr);
354 u16 val = mii_data->val_in; 354 u16 val = mii_data->val_in;
355 bool change_autoneg = false;
355 356
356 switch (cmd) { 357 switch (cmd) {
357 case SIOCGMIIPHY: 358 case SIOCGMIIPHY:
@@ -367,22 +368,29 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
367 if (mii_data->phy_id == phydev->addr) { 368 if (mii_data->phy_id == phydev->addr) {
368 switch (mii_data->reg_num) { 369 switch (mii_data->reg_num) {
369 case MII_BMCR: 370 case MII_BMCR:
370 if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0) 371 if ((val & (BMCR_RESET | BMCR_ANENABLE)) == 0) {
372 if (phydev->autoneg == AUTONEG_ENABLE)
373 change_autoneg = true;
371 phydev->autoneg = AUTONEG_DISABLE; 374 phydev->autoneg = AUTONEG_DISABLE;
372 else 375 if (val & BMCR_FULLDPLX)
376 phydev->duplex = DUPLEX_FULL;
377 else
378 phydev->duplex = DUPLEX_HALF;
379 if (val & BMCR_SPEED1000)
380 phydev->speed = SPEED_1000;
381 else if (val & BMCR_SPEED100)
382 phydev->speed = SPEED_100;
383 else phydev->speed = SPEED_10;
384 }
385 else {
386 if (phydev->autoneg == AUTONEG_DISABLE)
387 change_autoneg = true;
373 phydev->autoneg = AUTONEG_ENABLE; 388 phydev->autoneg = AUTONEG_ENABLE;
374 if (!phydev->autoneg && (val & BMCR_FULLDPLX)) 389 }
375 phydev->duplex = DUPLEX_FULL;
376 else
377 phydev->duplex = DUPLEX_HALF;
378 if (!phydev->autoneg && (val & BMCR_SPEED1000))
379 phydev->speed = SPEED_1000;
380 else if (!phydev->autoneg &&
381 (val & BMCR_SPEED100))
382 phydev->speed = SPEED_100;
383 break; 390 break;
384 case MII_ADVERTISE: 391 case MII_ADVERTISE:
385 phydev->advertising = val; 392 phydev->advertising = mii_adv_to_ethtool_adv_t(val);
393 change_autoneg = true;
386 break; 394 break;
387 default: 395 default:
388 /* do nothing */ 396 /* do nothing */
@@ -396,6 +404,10 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
396 if (mii_data->reg_num == MII_BMCR && 404 if (mii_data->reg_num == MII_BMCR &&
397 val & BMCR_RESET) 405 val & BMCR_RESET)
398 return phy_init_hw(phydev); 406 return phy_init_hw(phydev);
407
408 if (change_autoneg)
409 return phy_start_aneg(phydev);
410
399 return 0; 411 return 0;
400 412
401 case SIOCSHWTSTAMP: 413 case SIOCSHWTSTAMP:
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 68c3a3f4e0ab..794a47329368 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -755,23 +755,23 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
755 755
756 err = get_filter(argp, &code); 756 err = get_filter(argp, &code);
757 if (err >= 0) { 757 if (err >= 0) {
758 struct bpf_prog *pass_filter = NULL;
758 struct sock_fprog_kern fprog = { 759 struct sock_fprog_kern fprog = {
759 .len = err, 760 .len = err,
760 .filter = code, 761 .filter = code,
761 }; 762 };
762 763
763 ppp_lock(ppp); 764 err = 0;
764 if (ppp->pass_filter) { 765 if (fprog.filter)
765 bpf_prog_destroy(ppp->pass_filter); 766 err = bpf_prog_create(&pass_filter, &fprog);
766 ppp->pass_filter = NULL; 767 if (!err) {
768 ppp_lock(ppp);
769 if (ppp->pass_filter)
770 bpf_prog_destroy(ppp->pass_filter);
771 ppp->pass_filter = pass_filter;
772 ppp_unlock(ppp);
767 } 773 }
768 if (fprog.filter != NULL)
769 err = bpf_prog_create(&ppp->pass_filter,
770 &fprog);
771 else
772 err = 0;
773 kfree(code); 774 kfree(code);
774 ppp_unlock(ppp);
775 } 775 }
776 break; 776 break;
777 } 777 }
@@ -781,23 +781,23 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
781 781
782 err = get_filter(argp, &code); 782 err = get_filter(argp, &code);
783 if (err >= 0) { 783 if (err >= 0) {
784 struct bpf_prog *active_filter = NULL;
784 struct sock_fprog_kern fprog = { 785 struct sock_fprog_kern fprog = {
785 .len = err, 786 .len = err,
786 .filter = code, 787 .filter = code,
787 }; 788 };
788 789
789 ppp_lock(ppp); 790 err = 0;
790 if (ppp->active_filter) { 791 if (fprog.filter)
791 bpf_prog_destroy(ppp->active_filter); 792 err = bpf_prog_create(&active_filter, &fprog);
792 ppp->active_filter = NULL; 793 if (!err) {
794 ppp_lock(ppp);
795 if (ppp->active_filter)
796 bpf_prog_destroy(ppp->active_filter);
797 ppp->active_filter = active_filter;
798 ppp_unlock(ppp);
793 } 799 }
794 if (fprog.filter != NULL)
795 err = bpf_prog_create(&ppp->active_filter,
796 &fprog);
797 else
798 err = 0;
799 kfree(code); 800 kfree(code);
800 ppp_unlock(ppp);
801 } 801 }
802 break; 802 break;
803 } 803 }
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 1aff970be33e..1dc628ffce2b 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -506,7 +506,9 @@ static int pptp_getname(struct socket *sock, struct sockaddr *uaddr,
506 int len = sizeof(struct sockaddr_pppox); 506 int len = sizeof(struct sockaddr_pppox);
507 struct sockaddr_pppox sp; 507 struct sockaddr_pppox sp;
508 508
509 sp.sa_family = AF_PPPOX; 509 memset(&sp.sa_addr, 0, sizeof(sp.sa_addr));
510
511 sp.sa_family = AF_PPPOX;
510 sp.sa_protocol = PX_PROTO_PPTP; 512 sp.sa_protocol = PX_PROTO_PPTP;
511 sp.sa_addr.pptp = pppox_sk(sock->sk)->proto.pptp.src_addr; 513 sp.sa_addr.pptp = pppox_sk(sock->sk)->proto.pptp.src_addr;
512 514
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7302398f0b1f..9dd3746994a4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1235,12 +1235,20 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1235 struct tun_pi pi = { 0, skb->protocol }; 1235 struct tun_pi pi = { 0, skb->protocol };
1236 ssize_t total = 0; 1236 ssize_t total = 0;
1237 int vlan_offset = 0, copied; 1237 int vlan_offset = 0, copied;
1238 int vlan_hlen = 0;
1239 int vnet_hdr_sz = 0;
1240
1241 if (vlan_tx_tag_present(skb))
1242 vlan_hlen = VLAN_HLEN;
1243
1244 if (tun->flags & TUN_VNET_HDR)
1245 vnet_hdr_sz = tun->vnet_hdr_sz;
1238 1246
1239 if (!(tun->flags & TUN_NO_PI)) { 1247 if (!(tun->flags & TUN_NO_PI)) {
1240 if ((len -= sizeof(pi)) < 0) 1248 if ((len -= sizeof(pi)) < 0)
1241 return -EINVAL; 1249 return -EINVAL;
1242 1250
1243 if (len < skb->len) { 1251 if (len < skb->len + vlan_hlen + vnet_hdr_sz) {
1244 /* Packet will be striped */ 1252 /* Packet will be striped */
1245 pi.flags |= TUN_PKT_STRIP; 1253 pi.flags |= TUN_PKT_STRIP;
1246 } 1254 }
@@ -1250,9 +1258,9 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1250 total += sizeof(pi); 1258 total += sizeof(pi);
1251 } 1259 }
1252 1260
1253 if (tun->flags & TUN_VNET_HDR) { 1261 if (vnet_hdr_sz) {
1254 struct virtio_net_hdr gso = { 0 }; /* no info leak */ 1262 struct virtio_net_hdr gso = { 0 }; /* no info leak */
1255 if ((len -= tun->vnet_hdr_sz) < 0) 1263 if ((len -= vnet_hdr_sz) < 0)
1256 return -EINVAL; 1264 return -EINVAL;
1257 1265
1258 if (skb_is_gso(skb)) { 1266 if (skb_is_gso(skb)) {
@@ -1284,7 +1292,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1284 1292
1285 if (skb->ip_summed == CHECKSUM_PARTIAL) { 1293 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1286 gso.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM; 1294 gso.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
1287 gso.csum_start = skb_checksum_start_offset(skb); 1295 gso.csum_start = skb_checksum_start_offset(skb) +
1296 vlan_hlen;
1288 gso.csum_offset = skb->csum_offset; 1297 gso.csum_offset = skb->csum_offset;
1289 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) { 1298 } else if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
1290 gso.flags = VIRTIO_NET_HDR_F_DATA_VALID; 1299 gso.flags = VIRTIO_NET_HDR_F_DATA_VALID;
@@ -1293,14 +1302,13 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1293 if (unlikely(memcpy_toiovecend(iv, (void *)&gso, total, 1302 if (unlikely(memcpy_toiovecend(iv, (void *)&gso, total,
1294 sizeof(gso)))) 1303 sizeof(gso))))
1295 return -EFAULT; 1304 return -EFAULT;
1296 total += tun->vnet_hdr_sz; 1305 total += vnet_hdr_sz;
1297 } 1306 }
1298 1307
1299 copied = total; 1308 copied = total;
1300 total += skb->len; 1309 len = min_t(int, skb->len + vlan_hlen, len);
1301 if (!vlan_tx_tag_present(skb)) { 1310 total += skb->len + vlan_hlen;
1302 len = min_t(int, skb->len, len); 1311 if (vlan_hlen) {
1303 } else {
1304 int copy, ret; 1312 int copy, ret;
1305 struct { 1313 struct {
1306 __be16 h_vlan_proto; 1314 __be16 h_vlan_proto;
@@ -1311,8 +1319,6 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1311 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb)); 1319 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
1312 1320
1313 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 1321 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
1314 len = min_t(int, skb->len + VLAN_HLEN, len);
1315 total += VLAN_HLEN;
1316 1322
1317 copy = min_t(int, vlan_offset, len); 1323 copy = min_t(int, vlan_offset, len);
1318 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy); 1324 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy);
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 2c05f6cdb12f..816d511e34d3 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -465,19 +465,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
465 return ret; 465 return ret;
466 } 466 }
467 467
468 ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); 468 ax88772_reset(dev);
469 if (ret < 0)
470 return ret;
471
472 msleep(150);
473
474 ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
475 if (ret < 0)
476 return ret;
477
478 msleep(150);
479
480 ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_PRTE);
481 469
482 /* Read PHYID register *AFTER* the PHY was reset properly */ 470 /* Read PHYID register *AFTER* the PHY was reset properly */
483 phyid = asix_get_phyid(dev); 471 phyid = asix_get_phyid(dev);
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 22756db53dca..b8a82b86f909 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -780,6 +780,7 @@ static const struct usb_device_id products[] = {
780 {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ 780 {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
781 {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */ 781 {QMI_FIXED_INTF(0x413c, 0x81a8, 8)}, /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
782 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */ 782 {QMI_FIXED_INTF(0x413c, 0x81a9, 8)}, /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
783 {QMI_FIXED_INTF(0x03f0, 0x581d, 4)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Module (Huawei me906e) */
783 784
784 /* 4. Gobi 1000 devices */ 785 /* 4. Gobi 1000 devices */
785 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 786 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index ec2a8b41ed41..b0bc8ead47de 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1673,6 +1673,40 @@ static const struct attribute_group virtio_net_mrg_rx_group = {
1673}; 1673};
1674#endif 1674#endif
1675 1675
1676static bool virtnet_fail_on_feature(struct virtio_device *vdev,
1677 unsigned int fbit,
1678 const char *fname, const char *dname)
1679{
1680 if (!virtio_has_feature(vdev, fbit))
1681 return false;
1682
1683 dev_err(&vdev->dev, "device advertises feature %s but not %s",
1684 fname, dname);
1685
1686 return true;
1687}
1688
1689#define VIRTNET_FAIL_ON(vdev, fbit, dbit) \
1690 virtnet_fail_on_feature(vdev, fbit, #fbit, dbit)
1691
1692static bool virtnet_validate_features(struct virtio_device *vdev)
1693{
1694 if (!virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) &&
1695 (VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_RX,
1696 "VIRTIO_NET_F_CTRL_VQ") ||
1697 VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_VLAN,
1698 "VIRTIO_NET_F_CTRL_VQ") ||
1699 VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE,
1700 "VIRTIO_NET_F_CTRL_VQ") ||
1701 VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_MQ, "VIRTIO_NET_F_CTRL_VQ") ||
1702 VIRTNET_FAIL_ON(vdev, VIRTIO_NET_F_CTRL_MAC_ADDR,
1703 "VIRTIO_NET_F_CTRL_VQ"))) {
1704 return false;
1705 }
1706
1707 return true;
1708}
1709
1676static int virtnet_probe(struct virtio_device *vdev) 1710static int virtnet_probe(struct virtio_device *vdev)
1677{ 1711{
1678 int i, err; 1712 int i, err;
@@ -1680,6 +1714,9 @@ static int virtnet_probe(struct virtio_device *vdev)
1680 struct virtnet_info *vi; 1714 struct virtnet_info *vi;
1681 u16 max_queue_pairs; 1715 u16 max_queue_pairs;
1682 1716
1717 if (!virtnet_validate_features(vdev))
1718 return -EINVAL;
1719
1683 /* Find if host supports multiqueue virtio_net device */ 1720 /* Find if host supports multiqueue virtio_net device */
1684 err = virtio_cread_feature(vdev, VIRTIO_NET_F_MQ, 1721 err = virtio_cread_feature(vdev, VIRTIO_NET_F_MQ,
1685 struct virtio_net_config, 1722 struct virtio_net_config,
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index ca309820d39e..be4649a49c5e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -67,12 +67,6 @@
67 67
68#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ 68#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
69 69
70/* VXLAN protocol header */
71struct vxlanhdr {
72 __be32 vx_flags;
73 __be32 vx_vni;
74};
75
76/* UDP port for VXLAN traffic. 70/* UDP port for VXLAN traffic.
77 * The IANA assigned port is 4789, but the Linux default is 8472 71 * The IANA assigned port is 4789, but the Linux default is 8472
78 * for compatibility with early adopters. 72 * for compatibility with early adopters.
@@ -275,13 +269,15 @@ static inline struct vxlan_rdst *first_remote_rtnl(struct vxlan_fdb *fdb)
275 return list_first_entry(&fdb->remotes, struct vxlan_rdst, list); 269 return list_first_entry(&fdb->remotes, struct vxlan_rdst, list);
276} 270}
277 271
278/* Find VXLAN socket based on network namespace and UDP port */ 272/* Find VXLAN socket based on network namespace, address family and UDP port */
279static struct vxlan_sock *vxlan_find_sock(struct net *net, __be16 port) 273static struct vxlan_sock *vxlan_find_sock(struct net *net,
274 sa_family_t family, __be16 port)
280{ 275{
281 struct vxlan_sock *vs; 276 struct vxlan_sock *vs;
282 277
283 hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) { 278 hlist_for_each_entry_rcu(vs, vs_head(net, port), hlist) {
284 if (inet_sk(vs->sock->sk)->inet_sport == port) 279 if (inet_sk(vs->sock->sk)->inet_sport == port &&
280 inet_sk(vs->sock->sk)->sk.sk_family == family)
285 return vs; 281 return vs;
286 } 282 }
287 return NULL; 283 return NULL;
@@ -300,11 +296,12 @@ static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, u32 id)
300} 296}
301 297
302/* Look up VNI in a per net namespace table */ 298/* Look up VNI in a per net namespace table */
303static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id, __be16 port) 299static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id,
300 sa_family_t family, __be16 port)
304{ 301{
305 struct vxlan_sock *vs; 302 struct vxlan_sock *vs;
306 303
307 vs = vxlan_find_sock(net, port); 304 vs = vxlan_find_sock(net, family, port);
308 if (!vs) 305 if (!vs)
309 return NULL; 306 return NULL;
310 307
@@ -621,6 +618,8 @@ static int vxlan_gro_complete(struct sk_buff *skb, int nhoff)
621 int vxlan_len = sizeof(struct vxlanhdr) + sizeof(struct ethhdr); 618 int vxlan_len = sizeof(struct vxlanhdr) + sizeof(struct ethhdr);
622 int err = -ENOSYS; 619 int err = -ENOSYS;
623 620
621 udp_tunnel_gro_complete(skb, nhoff);
622
624 eh = (struct ethhdr *)(skb->data + nhoff + sizeof(struct vxlanhdr)); 623 eh = (struct ethhdr *)(skb->data + nhoff + sizeof(struct vxlanhdr));
625 type = eh->h_proto; 624 type = eh->h_proto;
626 625
@@ -1771,7 +1770,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1771 struct vxlan_dev *dst_vxlan; 1770 struct vxlan_dev *dst_vxlan;
1772 1771
1773 ip_rt_put(rt); 1772 ip_rt_put(rt);
1774 dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); 1773 dst_vxlan = vxlan_find_vni(vxlan->net, vni,
1774 dst->sa.sa_family, dst_port);
1775 if (!dst_vxlan) 1775 if (!dst_vxlan)
1776 goto tx_error; 1776 goto tx_error;
1777 vxlan_encap_bypass(skb, vxlan, dst_vxlan); 1777 vxlan_encap_bypass(skb, vxlan, dst_vxlan);
@@ -1825,7 +1825,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1825 struct vxlan_dev *dst_vxlan; 1825 struct vxlan_dev *dst_vxlan;
1826 1826
1827 dst_release(ndst); 1827 dst_release(ndst);
1828 dst_vxlan = vxlan_find_vni(vxlan->net, vni, dst_port); 1828 dst_vxlan = vxlan_find_vni(vxlan->net, vni,
1829 dst->sa.sa_family, dst_port);
1829 if (!dst_vxlan) 1830 if (!dst_vxlan)
1830 goto tx_error; 1831 goto tx_error;
1831 vxlan_encap_bypass(skb, vxlan, dst_vxlan); 1832 vxlan_encap_bypass(skb, vxlan, dst_vxlan);
@@ -1985,13 +1986,15 @@ static int vxlan_init(struct net_device *dev)
1985 struct vxlan_dev *vxlan = netdev_priv(dev); 1986 struct vxlan_dev *vxlan = netdev_priv(dev);
1986 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); 1987 struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id);
1987 struct vxlan_sock *vs; 1988 struct vxlan_sock *vs;
1989 bool ipv6 = vxlan->flags & VXLAN_F_IPV6;
1988 1990
1989 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 1991 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1990 if (!dev->tstats) 1992 if (!dev->tstats)
1991 return -ENOMEM; 1993 return -ENOMEM;
1992 1994
1993 spin_lock(&vn->sock_lock); 1995 spin_lock(&vn->sock_lock);
1994 vs = vxlan_find_sock(vxlan->net, vxlan->dst_port); 1996 vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET,
1997 vxlan->dst_port);
1995 if (vs) { 1998 if (vs) {
1996 /* If we have a socket with same port already, reuse it */ 1999 /* If we have a socket with same port already, reuse it */
1997 atomic_inc(&vs->refcnt); 2000 atomic_inc(&vs->refcnt);
@@ -2303,9 +2306,9 @@ static struct socket *vxlan_create_sock(struct net *net, bool ipv6,
2303 if (ipv6) { 2306 if (ipv6) {
2304 udp_conf.family = AF_INET6; 2307 udp_conf.family = AF_INET6;
2305 udp_conf.use_udp6_tx_checksums = 2308 udp_conf.use_udp6_tx_checksums =
2306 !!(flags & VXLAN_F_UDP_ZERO_CSUM6_TX); 2309 !(flags & VXLAN_F_UDP_ZERO_CSUM6_TX);
2307 udp_conf.use_udp6_rx_checksums = 2310 udp_conf.use_udp6_rx_checksums =
2308 !!(flags & VXLAN_F_UDP_ZERO_CSUM6_RX); 2311 !(flags & VXLAN_F_UDP_ZERO_CSUM6_RX);
2309 } else { 2312 } else {
2310 udp_conf.family = AF_INET; 2313 udp_conf.family = AF_INET;
2311 udp_conf.local_ip.s_addr = INADDR_ANY; 2314 udp_conf.local_ip.s_addr = INADDR_ANY;
@@ -2382,6 +2385,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
2382{ 2385{
2383 struct vxlan_net *vn = net_generic(net, vxlan_net_id); 2386 struct vxlan_net *vn = net_generic(net, vxlan_net_id);
2384 struct vxlan_sock *vs; 2387 struct vxlan_sock *vs;
2388 bool ipv6 = flags & VXLAN_F_IPV6;
2385 2389
2386 vs = vxlan_socket_create(net, port, rcv, data, flags); 2390 vs = vxlan_socket_create(net, port, rcv, data, flags);
2387 if (!IS_ERR(vs)) 2391 if (!IS_ERR(vs))
@@ -2391,7 +2395,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
2391 return vs; 2395 return vs;
2392 2396
2393 spin_lock(&vn->sock_lock); 2397 spin_lock(&vn->sock_lock);
2394 vs = vxlan_find_sock(net, port); 2398 vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port);
2395 if (vs) { 2399 if (vs) {
2396 if (vs->rcv == rcv) 2400 if (vs->rcv == rcv)
2397 atomic_inc(&vs->refcnt); 2401 atomic_inc(&vs->refcnt);
@@ -2550,7 +2554,8 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
2550 nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])) 2554 nla_get_u8(data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]))
2551 vxlan->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX; 2555 vxlan->flags |= VXLAN_F_UDP_ZERO_CSUM6_RX;
2552 2556
2553 if (vxlan_find_vni(net, vni, vxlan->dst_port)) { 2557 if (vxlan_find_vni(net, vni, use_ipv6 ? AF_INET6 : AF_INET,
2558 vxlan->dst_port)) {
2554 pr_info("duplicate VNI %u\n", vni); 2559 pr_info("duplicate VNI %u\n", vni);
2555 return -EEXIST; 2560 return -EEXIST;
2556 } 2561 }
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 697c4ae90af0..1e8ea5e4d4ca 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -664,6 +664,19 @@ static void ar9003_hw_override_ini(struct ath_hw *ah)
664 ah->enabled_cals |= TX_CL_CAL; 664 ah->enabled_cals |= TX_CL_CAL;
665 else 665 else
666 ah->enabled_cals &= ~TX_CL_CAL; 666 ah->enabled_cals &= ~TX_CL_CAL;
667
668 if (AR_SREV_9340(ah) || AR_SREV_9531(ah) || AR_SREV_9550(ah)) {
669 if (ah->is_clk_25mhz) {
670 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
671 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
672 REG_WRITE(ah, AR_SLP32_INC, 0x0001e7ae);
673 } else {
674 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x261 << 1);
675 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f400);
676 REG_WRITE(ah, AR_SLP32_INC, 0x0001e800);
677 }
678 udelay(100);
679 }
667} 680}
668 681
669static void ar9003_hw_prog_ini(struct ath_hw *ah, 682static void ar9003_hw_prog_ini(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 8be4b1453394..2ad605760e21 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -861,19 +861,6 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
861 udelay(RTC_PLL_SETTLE_DELAY); 861 udelay(RTC_PLL_SETTLE_DELAY);
862 862
863 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK); 863 REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_FORCE_DERIVED_CLK);
864
865 if (AR_SREV_9340(ah) || AR_SREV_9550(ah)) {
866 if (ah->is_clk_25mhz) {
867 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x17c << 1);
868 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f3d7);
869 REG_WRITE(ah, AR_SLP32_INC, 0x0001e7ae);
870 } else {
871 REG_WRITE(ah, AR_RTC_DERIVED_CLK, 0x261 << 1);
872 REG_WRITE(ah, AR_SLP32_MODE, 0x0010f400);
873 REG_WRITE(ah, AR_SLP32_INC, 0x0001e800);
874 }
875 udelay(100);
876 }
877} 864}
878 865
879static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah, 866static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 30c66dfcd7a0..4f18a6be0c7d 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -974,9 +974,8 @@ void ath9k_calculate_iter_data(struct ath_softc *sc,
974 struct ath_vif *avp; 974 struct ath_vif *avp;
975 975
976 /* 976 /*
977 * Pick the MAC address of the first interface as the new hardware 977 * The hardware will use primary station addr together with the
978 * MAC address. The hardware will use it together with the BSSID mask 978 * BSSID mask when matching addresses.
979 * when matching addresses.
980 */ 979 */
981 memset(iter_data, 0, sizeof(*iter_data)); 980 memset(iter_data, 0, sizeof(*iter_data));
982 memset(&iter_data->mask, 0xff, ETH_ALEN); 981 memset(&iter_data->mask, 0xff, ETH_ALEN);
@@ -1205,6 +1204,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
1205 list_add_tail(&avp->list, &avp->chanctx->vifs); 1204 list_add_tail(&avp->list, &avp->chanctx->vifs);
1206 } 1205 }
1207 1206
1207 ath9k_calculate_summary_state(sc, avp->chanctx);
1208
1208 ath9k_assign_hw_queues(hw, vif); 1209 ath9k_assign_hw_queues(hw, vif);
1209 1210
1210 an->sc = sc; 1211 an->sc = sc;
@@ -1274,6 +1275,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
1274 1275
1275 ath_tx_node_cleanup(sc, &avp->mcast_node); 1276 ath_tx_node_cleanup(sc, &avp->mcast_node);
1276 1277
1278 ath9k_calculate_summary_state(sc, avp->chanctx);
1279
1277 mutex_unlock(&sc->mutex); 1280 mutex_unlock(&sc->mutex);
1278} 1281}
1279 1282
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 1dfc682a8055..ee27b06074e1 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -300,9 +300,7 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
300 300
301void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg) 301void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
302{ 302{
303 assert_mac_suspended(dev); 303 b43_phy_write(dev, destreg, b43_phy_read(dev, srcreg));
304 dev->phy.ops->phy_write(dev, destreg,
305 dev->phy.ops->phy_read(dev, srcreg));
306} 304}
307 305
308void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask) 306void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/of.c b/drivers/net/wireless/brcm80211/brcmfmac/of.c
index f05f5270fec1..927bffd5be64 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/of.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/of.c
@@ -40,8 +40,8 @@ void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
40 return; 40 return;
41 41
42 irq = irq_of_parse_and_map(np, 0); 42 irq = irq_of_parse_and_map(np, 0);
43 if (irq < 0) { 43 if (!irq) {
44 brcmf_err("interrupt could not be mapped: err=%d\n", irq); 44 brcmf_err("interrupt could not be mapped\n");
45 devm_kfree(dev, sdiodev->pdata); 45 devm_kfree(dev, sdiodev->pdata);
46 return; 46 return;
47 } 47 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
index 8c0632ec9f7a..16fef3382019 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
@@ -19,10 +19,10 @@
19#include <linux/pci.h> 19#include <linux/pci.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/unaligned/access_ok.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/bcma/bcma.h> 23#include <linux/bcma/bcma.h>
25#include <linux/sched.h> 24#include <linux/sched.h>
25#include <asm/unaligned.h>
26 26
27#include <soc.h> 27#include <soc.h>
28#include <chipcommon.h> 28#include <chipcommon.h>
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index dc135915470d..875d1142c8b0 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -669,10 +669,12 @@ static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info *devinfo, u8 cmd,
669 goto finalize; 669 goto finalize;
670 } 670 }
671 671
672 if (!brcmf_usb_ioctl_resp_wait(devinfo)) 672 if (!brcmf_usb_ioctl_resp_wait(devinfo)) {
673 usb_kill_urb(devinfo->ctl_urb);
673 ret = -ETIMEDOUT; 674 ret = -ETIMEDOUT;
674 else 675 } else {
675 memcpy(buffer, tmpbuf, buflen); 676 memcpy(buffer, tmpbuf, buflen);
677 }
676 678
677finalize: 679finalize:
678 kfree(tmpbuf); 680 kfree(tmpbuf);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index 28fa25b509db..39b45c038a93 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -299,6 +299,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
299 primary_offset = ch->center_freq1 - ch->chan->center_freq; 299 primary_offset = ch->center_freq1 - ch->chan->center_freq;
300 switch (ch->width) { 300 switch (ch->width) {
301 case NL80211_CHAN_WIDTH_20: 301 case NL80211_CHAN_WIDTH_20:
302 case NL80211_CHAN_WIDTH_20_NOHT:
302 ch_inf.bw = BRCMU_CHAN_BW_20; 303 ch_inf.bw = BRCMU_CHAN_BW_20;
303 WARN_ON(primary_offset != 0); 304 WARN_ON(primary_offset != 0);
304 break; 305 break;
@@ -323,6 +324,10 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
323 ch_inf.sb = BRCMU_CHAN_SB_LU; 324 ch_inf.sb = BRCMU_CHAN_SB_LU;
324 } 325 }
325 break; 326 break;
327 case NL80211_CHAN_WIDTH_80P80:
328 case NL80211_CHAN_WIDTH_160:
329 case NL80211_CHAN_WIDTH_5:
330 case NL80211_CHAN_WIDTH_10:
326 default: 331 default:
327 WARN_ON_ONCE(1); 332 WARN_ON_ONCE(1);
328 } 333 }
@@ -333,6 +338,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
333 case IEEE80211_BAND_5GHZ: 338 case IEEE80211_BAND_5GHZ:
334 ch_inf.band = BRCMU_CHAN_BAND_5G; 339 ch_inf.band = BRCMU_CHAN_BAND_5G;
335 break; 340 break;
341 case IEEE80211_BAND_60GHZ:
336 default: 342 default:
337 WARN_ON_ONCE(1); 343 WARN_ON_ONCE(1);
338 } 344 }
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h
index 4f6e66892acc..b894a84e8393 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fw.h
@@ -155,6 +155,7 @@ enum iwl_ucode_tlv_api {
155 * @IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT: supports Quiet Period requests 155 * @IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT: supports Quiet Period requests
156 * @IWL_UCODE_TLV_CAPA_DQA_SUPPORT: supports dynamic queue allocation (DQA), 156 * @IWL_UCODE_TLV_CAPA_DQA_SUPPORT: supports dynamic queue allocation (DQA),
157 * which also implies support for the scheduler configuration command 157 * which also implies support for the scheduler configuration command
158 * @IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT: supports Hot Spot Command
158 */ 159 */
159enum iwl_ucode_tlv_capa { 160enum iwl_ucode_tlv_capa {
160 IWL_UCODE_TLV_CAPA_D0I3_SUPPORT = BIT(0), 161 IWL_UCODE_TLV_CAPA_D0I3_SUPPORT = BIT(0),
@@ -163,6 +164,7 @@ enum iwl_ucode_tlv_capa {
163 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT = BIT(10), 164 IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT = BIT(10),
164 IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT = BIT(11), 165 IWL_UCODE_TLV_CAPA_QUIET_PERIOD_SUPPORT = BIT(11),
165 IWL_UCODE_TLV_CAPA_DQA_SUPPORT = BIT(12), 166 IWL_UCODE_TLV_CAPA_DQA_SUPPORT = BIT(12),
167 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT = BIT(18),
166}; 168};
167 169
168/* The default calibrate table size if not specified by firmware file */ 170/* The default calibrate table size if not specified by firmware file */
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index e0d9f19650b0..eb03943f8463 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -284,7 +284,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
284 284
285 lockdep_assert_held(&mvm->mutex); 285 lockdep_assert_held(&mvm->mutex);
286 286
287 if (WARN_ON_ONCE(mvm->init_ucode_complete)) 287 if (WARN_ON_ONCE(mvm->init_ucode_complete || mvm->calibrating))
288 return 0; 288 return 0;
289 289
290 iwl_init_notification_wait(&mvm->notif_wait, 290 iwl_init_notification_wait(&mvm->notif_wait,
@@ -334,6 +334,8 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
334 goto out; 334 goto out;
335 } 335 }
336 336
337 mvm->calibrating = true;
338
337 /* Send TX valid antennas before triggering calibrations */ 339 /* Send TX valid antennas before triggering calibrations */
338 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant); 340 ret = iwl_send_tx_ant_cfg(mvm, mvm->fw->valid_tx_ant);
339 if (ret) 341 if (ret)
@@ -358,11 +360,17 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
358 MVM_UCODE_CALIB_TIMEOUT); 360 MVM_UCODE_CALIB_TIMEOUT);
359 if (!ret) 361 if (!ret)
360 mvm->init_ucode_complete = true; 362 mvm->init_ucode_complete = true;
363
364 if (ret && iwl_mvm_is_radio_killed(mvm)) {
365 IWL_DEBUG_RF_KILL(mvm, "RFKILL while calibrating.\n");
366 ret = 1;
367 }
361 goto out; 368 goto out;
362 369
363error: 370error:
364 iwl_remove_notification(&mvm->notif_wait, &calib_wait); 371 iwl_remove_notification(&mvm->notif_wait, &calib_wait);
365out: 372out:
373 mvm->calibrating = false;
366 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) { 374 if (iwlmvm_mod_params.init_dbg && !mvm->nvm_data) {
367 /* we want to debug INIT and we have no NVM - fake */ 375 /* we want to debug INIT and we have no NVM - fake */
368 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) + 376 mvm->nvm_data = kzalloc(sizeof(struct iwl_nvm_data) +
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 585fe5b7100f..b6d2683da3a9 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -788,6 +788,7 @@ static void iwl_mvm_restart_cleanup(struct iwl_mvm *mvm)
788 788
789 mvm->scan_status = IWL_MVM_SCAN_NONE; 789 mvm->scan_status = IWL_MVM_SCAN_NONE;
790 mvm->ps_disabled = false; 790 mvm->ps_disabled = false;
791 mvm->calibrating = false;
791 792
792 /* just in case one was running */ 793 /* just in case one was running */
793 ieee80211_remain_on_channel_expired(mvm->hw); 794 ieee80211_remain_on_channel_expired(mvm->hw);
@@ -2447,9 +2448,15 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
2447 2448
2448 switch (vif->type) { 2449 switch (vif->type) {
2449 case NL80211_IFTYPE_STATION: 2450 case NL80211_IFTYPE_STATION:
2450 /* Use aux roc framework (HS20) */ 2451 if (mvm->fw->ucode_capa.capa[0] &
2451 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, 2452 IWL_UCODE_TLV_CAPA_HOTSPOT_SUPPORT) {
2452 vif, duration); 2453 /* Use aux roc framework (HS20) */
2454 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel,
2455 vif, duration);
2456 goto out_unlock;
2457 }
2458 IWL_ERR(mvm, "hotspot not supported\n");
2459 ret = -EINVAL;
2453 goto out_unlock; 2460 goto out_unlock;
2454 case NL80211_IFTYPE_P2P_DEVICE: 2461 case NL80211_IFTYPE_P2P_DEVICE:
2455 /* handle below */ 2462 /* handle below */
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index b153ced7015b..845429c88cf4 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -548,6 +548,7 @@ struct iwl_mvm {
548 enum iwl_ucode_type cur_ucode; 548 enum iwl_ucode_type cur_ucode;
549 bool ucode_loaded; 549 bool ucode_loaded;
550 bool init_ucode_complete; 550 bool init_ucode_complete;
551 bool calibrating;
551 u32 error_event_table; 552 u32 error_event_table;
552 u32 log_event_table; 553 u32 log_event_table;
553 u32 umac_error_event_table; 554 u32 umac_error_event_table;
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 48cb25a93591..5b719ee8e789 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -424,6 +424,7 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg,
424 } 424 }
425 mvm->sf_state = SF_UNINIT; 425 mvm->sf_state = SF_UNINIT;
426 mvm->low_latency_agg_frame_limit = 6; 426 mvm->low_latency_agg_frame_limit = 6;
427 mvm->cur_ucode = IWL_UCODE_INIT;
427 428
428 mutex_init(&mvm->mutex); 429 mutex_init(&mvm->mutex);
429 mutex_init(&mvm->d0i3_suspend_mutex); 430 mutex_init(&mvm->d0i3_suspend_mutex);
@@ -752,6 +753,7 @@ void iwl_mvm_set_hw_ctkill_state(struct iwl_mvm *mvm, bool state)
752static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) 753static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
753{ 754{
754 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 755 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
756 bool calibrating = ACCESS_ONCE(mvm->calibrating);
755 757
756 if (state) 758 if (state)
757 set_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); 759 set_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
@@ -760,7 +762,15 @@ static bool iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
760 762
761 wiphy_rfkill_set_hw_state(mvm->hw->wiphy, iwl_mvm_is_radio_killed(mvm)); 763 wiphy_rfkill_set_hw_state(mvm->hw->wiphy, iwl_mvm_is_radio_killed(mvm));
762 764
763 return state && mvm->cur_ucode != IWL_UCODE_INIT; 765 /* iwl_run_init_mvm_ucode is waiting for results, abort it */
766 if (calibrating)
767 iwl_abort_notification_waits(&mvm->notif_wait);
768
769 /*
770 * Stop the device if we run OPERATIONAL firmware or if we are in the
771 * middle of the calibrations.
772 */
773 return state && (mvm->cur_ucode != IWL_UCODE_INIT || calibrating);
764} 774}
765 775
766static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb) 776static void iwl_mvm_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index b280d5d87127..7554f7053830 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -602,16 +602,6 @@ static int iwl_mvm_cancel_regular_scan(struct iwl_mvm *mvm)
602 SCAN_COMPLETE_NOTIFICATION }; 602 SCAN_COMPLETE_NOTIFICATION };
603 int ret; 603 int ret;
604 604
605 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
606 return 0;
607
608 if (iwl_mvm_is_radio_killed(mvm)) {
609 ieee80211_scan_completed(mvm->hw, true);
610 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
611 mvm->scan_status = IWL_MVM_SCAN_NONE;
612 return 0;
613 }
614
615 iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_abort, 605 iwl_init_notification_wait(&mvm->notif_wait, &wait_scan_abort,
616 scan_abort_notif, 606 scan_abort_notif,
617 ARRAY_SIZE(scan_abort_notif), 607 ARRAY_SIZE(scan_abort_notif),
@@ -1400,6 +1390,16 @@ int iwl_mvm_unified_sched_scan_lmac(struct iwl_mvm *mvm,
1400 1390
1401int iwl_mvm_cancel_scan(struct iwl_mvm *mvm) 1391int iwl_mvm_cancel_scan(struct iwl_mvm *mvm)
1402{ 1392{
1393 if (mvm->scan_status == IWL_MVM_SCAN_NONE)
1394 return 0;
1395
1396 if (iwl_mvm_is_radio_killed(mvm)) {
1397 ieee80211_scan_completed(mvm->hw, true);
1398 iwl_mvm_unref(mvm, IWL_MVM_REF_SCAN);
1399 mvm->scan_status = IWL_MVM_SCAN_NONE;
1400 return 0;
1401 }
1402
1403 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN) 1403 if (mvm->fw->ucode_capa.api[0] & IWL_UCODE_TLV_API_LMAC_SCAN)
1404 return iwl_mvm_scan_offload_stop(mvm, true); 1404 return iwl_mvm_scan_offload_stop(mvm, true);
1405 return iwl_mvm_cancel_regular_scan(mvm); 1405 return iwl_mvm_cancel_regular_scan(mvm);
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 3781b029e54a..dd2f3f8baa9d 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -915,7 +915,8 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
915 * restart. So don't process again if the device is 915 * restart. So don't process again if the device is
916 * already dead. 916 * already dead.
917 */ 917 */
918 if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) { 918 if (test_and_clear_bit(STATUS_DEVICE_ENABLED, &trans->status)) {
919 IWL_DEBUG_INFO(trans, "DEVICE_ENABLED bit was set and is now cleared\n");
919 iwl_pcie_tx_stop(trans); 920 iwl_pcie_tx_stop(trans);
920 iwl_pcie_rx_stop(trans); 921 iwl_pcie_rx_stop(trans);
921 922
@@ -945,7 +946,6 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
945 /* clear all status bits */ 946 /* clear all status bits */
946 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 947 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
947 clear_bit(STATUS_INT_ENABLED, &trans->status); 948 clear_bit(STATUS_INT_ENABLED, &trans->status);
948 clear_bit(STATUS_DEVICE_ENABLED, &trans->status);
949 clear_bit(STATUS_TPOWER_PMI, &trans->status); 949 clear_bit(STATUS_TPOWER_PMI, &trans->status);
950 clear_bit(STATUS_RFKILL, &trans->status); 950 clear_bit(STATUS_RFKILL, &trans->status);
951 951
@@ -1894,8 +1894,7 @@ static u32 iwl_trans_pcie_dump_prph(struct iwl_trans *trans,
1894 int reg; 1894 int reg;
1895 __le32 *val; 1895 __le32 *val;
1896 1896
1897 prph_len += sizeof(*data) + sizeof(*prph) + 1897 prph_len += sizeof(**data) + sizeof(*prph) + num_bytes_in_chunk;
1898 num_bytes_in_chunk;
1899 1898
1900 (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PRPH); 1899 (*data)->type = cpu_to_le32(IWL_FW_ERROR_DUMP_PRPH);
1901 (*data)->len = cpu_to_le32(sizeof(*prph) + 1900 (*data)->len = cpu_to_le32(sizeof(*prph) +
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index babbdc1ce741..c9ad4cf1adfb 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1987,7 +1987,7 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2,
1987 if (err != 0) { 1987 if (err != 0) {
1988 printk(KERN_DEBUG "mac80211_hwsim: device_bind_driver failed (%d)\n", 1988 printk(KERN_DEBUG "mac80211_hwsim: device_bind_driver failed (%d)\n",
1989 err); 1989 err);
1990 goto failed_hw; 1990 goto failed_bind;
1991 } 1991 }
1992 1992
1993 skb_queue_head_init(&data->pending); 1993 skb_queue_head_init(&data->pending);
@@ -2183,6 +2183,8 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2,
2183 return idx; 2183 return idx;
2184 2184
2185failed_hw: 2185failed_hw:
2186 device_release_driver(data->dev);
2187failed_bind:
2186 device_unregister(data->dev); 2188 device_unregister(data->dev);
2187failed_drvdata: 2189failed_drvdata:
2188 ieee80211_free_hw(hw); 2190 ieee80211_free_hw(hw);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index 8e68f87ab13c..66ff36447b94 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -158,55 +158,29 @@ void rt2x00queue_align_frame(struct sk_buff *skb)
158 skb_trim(skb, frame_length); 158 skb_trim(skb, frame_length);
159} 159}
160 160
161void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int header_length) 161/*
162 * H/W needs L2 padding between the header and the paylod if header size
163 * is not 4 bytes aligned.
164 */
165void rt2x00queue_insert_l2pad(struct sk_buff *skb, unsigned int hdr_len)
162{ 166{
163 unsigned int payload_length = skb->len - header_length; 167 unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
164 unsigned int header_align = ALIGN_SIZE(skb, 0);
165 unsigned int payload_align = ALIGN_SIZE(skb, header_length);
166 unsigned int l2pad = payload_length ? L2PAD_SIZE(header_length) : 0;
167 168
168 /* 169 if (!l2pad)
169 * Adjust the header alignment if the payload needs to be moved more
170 * than the header.
171 */
172 if (payload_align > header_align)
173 header_align += 4;
174
175 /* There is nothing to do if no alignment is needed */
176 if (!header_align)
177 return; 170 return;
178 171
179 /* Reserve the amount of space needed in front of the frame */ 172 skb_push(skb, l2pad);
180 skb_push(skb, header_align); 173 memmove(skb->data, skb->data + l2pad, hdr_len);
181
182 /*
183 * Move the header.
184 */
185 memmove(skb->data, skb->data + header_align, header_length);
186
187 /* Move the payload, if present and if required */
188 if (payload_length && payload_align)
189 memmove(skb->data + header_length + l2pad,
190 skb->data + header_length + l2pad + payload_align,
191 payload_length);
192
193 /* Trim the skb to the correct size */
194 skb_trim(skb, header_length + l2pad + payload_length);
195} 174}
196 175
197void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length) 176void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int hdr_len)
198{ 177{
199 /* 178 unsigned int l2pad = (skb->len > hdr_len) ? L2PAD_SIZE(hdr_len) : 0;
200 * L2 padding is only present if the skb contains more than just the
201 * IEEE 802.11 header.
202 */
203 unsigned int l2pad = (skb->len > header_length) ?
204 L2PAD_SIZE(header_length) : 0;
205 179
206 if (!l2pad) 180 if (!l2pad)
207 return; 181 return;
208 182
209 memmove(skb->data + l2pad, skb->data, header_length); 183 memmove(skb->data + l2pad, skb->data, hdr_len);
210 skb_pull(skb, l2pad); 184 skb_pull(skb, l2pad);
211} 185}
212 186
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 25daa8715219..846a2e6e34d8 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -842,7 +842,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
842 break; 842 break;
843 } 843 }
844 /* handle command packet here */ 844 /* handle command packet here */
845 if (rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) { 845 if (rtlpriv->cfg->ops->rx_command_packet &&
846 rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
846 dev_kfree_skb_any(skb); 847 dev_kfree_skb_any(skb);
847 goto end; 848 goto end;
848 } 849 }
@@ -1127,9 +1128,14 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1127 1128
1128 __skb_queue_tail(&ring->queue, pskb); 1129 __skb_queue_tail(&ring->queue, pskb);
1129 1130
1130 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN, 1131 if (rtlpriv->use_new_trx_flow) {
1131 &temp_one); 1132 temp_one = 4;
1132 1133 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pbuffer_desc, true,
1134 HW_DESC_OWN, (u8 *)&temp_one);
1135 } else {
1136 rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
1137 &temp_one);
1138 }
1133 return; 1139 return;
1134} 1140}
1135 1141
@@ -1370,9 +1376,9 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1370 ring->desc = NULL; 1376 ring->desc = NULL;
1371 if (rtlpriv->use_new_trx_flow) { 1377 if (rtlpriv->use_new_trx_flow) {
1372 pci_free_consistent(rtlpci->pdev, 1378 pci_free_consistent(rtlpci->pdev,
1373 sizeof(*ring->desc) * ring->entries, 1379 sizeof(*ring->buffer_desc) * ring->entries,
1374 ring->buffer_desc, ring->buffer_desc_dma); 1380 ring->buffer_desc, ring->buffer_desc_dma);
1375 ring->desc = NULL; 1381 ring->buffer_desc = NULL;
1376 } 1382 }
1377} 1383}
1378 1384
@@ -1543,7 +1549,6 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
1543 true, 1549 true,
1544 HW_DESC_TXBUFF_ADDR), 1550 HW_DESC_TXBUFF_ADDR),
1545 skb->len, PCI_DMA_TODEVICE); 1551 skb->len, PCI_DMA_TODEVICE);
1546 ring->idx = (ring->idx + 1) % ring->entries;
1547 kfree_skb(skb); 1552 kfree_skb(skb);
1548 ring->idx = (ring->idx + 1) % ring->entries; 1553 ring->idx = (ring->idx + 1) % ring->entries;
1549 } 1554 }
@@ -2244,6 +2249,16 @@ int rtl_pci_probe(struct pci_dev *pdev,
2244 /*like read eeprom and so on */ 2249 /*like read eeprom and so on */
2245 rtlpriv->cfg->ops->read_eeprom_info(hw); 2250 rtlpriv->cfg->ops->read_eeprom_info(hw);
2246 2251
2252 if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
2253 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
2254 err = -ENODEV;
2255 goto fail3;
2256 }
2257 rtlpriv->cfg->ops->init_sw_leds(hw);
2258
2259 /*aspm */
2260 rtl_pci_init_aspm(hw);
2261
2247 /* Init mac80211 sw */ 2262 /* Init mac80211 sw */
2248 err = rtl_init_core(hw); 2263 err = rtl_init_core(hw);
2249 if (err) { 2264 if (err) {
@@ -2259,16 +2274,6 @@ int rtl_pci_probe(struct pci_dev *pdev,
2259 goto fail3; 2274 goto fail3;
2260 } 2275 }
2261 2276
2262 if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
2263 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
2264 err = -ENODEV;
2265 goto fail3;
2266 }
2267 rtlpriv->cfg->ops->init_sw_leds(hw);
2268
2269 /*aspm */
2270 rtl_pci_init_aspm(hw);
2271
2272 err = ieee80211_register_hw(hw); 2277 err = ieee80211_register_hw(hw);
2273 if (err) { 2278 if (err) {
2274 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2279 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
index 00e067044c08..5761d5b49e39 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -1201,6 +1201,9 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
1201 1201
1202 } 1202 }
1203 1203
1204 if (type != NL80211_IFTYPE_AP &&
1205 rtlpriv->mac80211.link_state < MAC80211_LINKED)
1206 bt_msr = rtl_read_byte(rtlpriv, MSR) & ~MSR_LINK_MASK;
1204 rtl_write_byte(rtlpriv, (MSR), bt_msr); 1207 rtl_write_byte(rtlpriv, (MSR), bt_msr);
1205 1208
1206 temp = rtl_read_dword(rtlpriv, TCR); 1209 temp = rtl_read_dword(rtlpriv, TCR);
@@ -1262,6 +1265,7 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
1262 rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]); 1265 rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]);
1263 /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */ 1266 /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
1264 rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F); 1267 rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
1268 rtlpci->irq_enabled = true;
1265} 1269}
1266 1270
1267void rtl92se_disable_interrupt(struct ieee80211_hw *hw) 1271void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
@@ -1276,8 +1280,7 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
1276 rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 1280 rtlpci = rtl_pcidev(rtl_pcipriv(hw));
1277 rtl_write_dword(rtlpriv, INTA_MASK, 0); 1281 rtl_write_dword(rtlpriv, INTA_MASK, 0);
1278 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0); 1282 rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
1279 1283 rtlpci->irq_enabled = false;
1280 synchronize_irq(rtlpci->pdev->irq);
1281} 1284}
1282 1285
1283static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data) 1286static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
index 77c5b5f35244..4b4612fe2fdb 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
@@ -399,6 +399,8 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
399 case 2: 399 case 2:
400 currentcmd = &postcommoncmd[*step]; 400 currentcmd = &postcommoncmd[*step];
401 break; 401 break;
402 default:
403 return true;
402 } 404 }
403 405
404 if (currentcmd->cmdid == CMDID_END) { 406 if (currentcmd->cmdid == CMDID_END) {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index aadba29c167a..fb003868bdef 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -236,6 +236,19 @@ static void rtl92s_deinit_sw_vars(struct ieee80211_hw *hw)
236 } 236 }
237} 237}
238 238
239static bool rtl92se_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue,
240 u16 index)
241{
242 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
243 struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
244 u8 *entry = (u8 *)(&ring->desc[ring->idx]);
245 u8 own = (u8)rtl92se_get_desc(entry, true, HW_DESC_OWN);
246
247 if (own)
248 return false;
249 return true;
250}
251
239static struct rtl_hal_ops rtl8192se_hal_ops = { 252static struct rtl_hal_ops rtl8192se_hal_ops = {
240 .init_sw_vars = rtl92s_init_sw_vars, 253 .init_sw_vars = rtl92s_init_sw_vars,
241 .deinit_sw_vars = rtl92s_deinit_sw_vars, 254 .deinit_sw_vars = rtl92s_deinit_sw_vars,
@@ -269,6 +282,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
269 .led_control = rtl92se_led_control, 282 .led_control = rtl92se_led_control,
270 .set_desc = rtl92se_set_desc, 283 .set_desc = rtl92se_set_desc,
271 .get_desc = rtl92se_get_desc, 284 .get_desc = rtl92se_get_desc,
285 .is_tx_desc_closed = rtl92se_is_tx_desc_closed,
272 .tx_polling = rtl92se_tx_polling, 286 .tx_polling = rtl92se_tx_polling,
273 .enable_hw_sec = rtl92se_enable_hw_security_config, 287 .enable_hw_sec = rtl92se_enable_hw_security_config,
274 .set_key = rtl92se_set_key, 288 .set_key = rtl92se_set_key,
@@ -306,6 +320,8 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
306 .maps[MAC_RCR_ACRC32] = RCR_ACRC32, 320 .maps[MAC_RCR_ACRC32] = RCR_ACRC32,
307 .maps[MAC_RCR_ACF] = RCR_ACF, 321 .maps[MAC_RCR_ACF] = RCR_ACF,
308 .maps[MAC_RCR_AAP] = RCR_AAP, 322 .maps[MAC_RCR_AAP] = RCR_AAP,
323 .maps[MAC_HIMR] = INTA_MASK,
324 .maps[MAC_HIMRE] = INTA_MASK + 4,
309 325
310 .maps[EFUSE_TEST] = REG_EFUSE_TEST, 326 .maps[EFUSE_TEST] = REG_EFUSE_TEST,
311 .maps[EFUSE_CTRL] = REG_EFUSE_CTRL, 327 .maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
index 310d3163dc5b..8ec8200002c7 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
@@ -3672,8 +3672,9 @@ static void rtl8821ae_update_hal_rate_mask(struct ieee80211_hw *hw,
3672 mac->opmode == NL80211_IFTYPE_ADHOC) 3672 mac->opmode == NL80211_IFTYPE_ADHOC)
3673 macid = sta->aid + 1; 3673 macid = sta->aid + 1;
3674 if (wirelessmode == WIRELESS_MODE_N_5G || 3674 if (wirelessmode == WIRELESS_MODE_N_5G ||
3675 wirelessmode == WIRELESS_MODE_AC_5G) 3675 wirelessmode == WIRELESS_MODE_AC_5G ||
3676 ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ]; 3676 wirelessmode == WIRELESS_MODE_A)
3677 ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ] << 4;
3677 else 3678 else
3678 ratr_bitmap = sta->supp_rates[NL80211_BAND_2GHZ]; 3679 ratr_bitmap = sta->supp_rates[NL80211_BAND_2GHZ];
3679 3680
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 4e56a27f9689..fab0d4b42f58 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -39,7 +39,7 @@ struct backend_info {
39static int connect_rings(struct backend_info *be, struct xenvif_queue *queue); 39static int connect_rings(struct backend_info *be, struct xenvif_queue *queue);
40static void connect(struct backend_info *be); 40static void connect(struct backend_info *be);
41static int read_xenbus_vif_flags(struct backend_info *be); 41static int read_xenbus_vif_flags(struct backend_info *be);
42static void backend_create_xenvif(struct backend_info *be); 42static int backend_create_xenvif(struct backend_info *be);
43static void unregister_hotplug_status_watch(struct backend_info *be); 43static void unregister_hotplug_status_watch(struct backend_info *be);
44static void set_backend_state(struct backend_info *be, 44static void set_backend_state(struct backend_info *be,
45 enum xenbus_state state); 45 enum xenbus_state state);
@@ -352,7 +352,9 @@ static int netback_probe(struct xenbus_device *dev,
352 be->state = XenbusStateInitWait; 352 be->state = XenbusStateInitWait;
353 353
354 /* This kicks hotplug scripts, so do it immediately. */ 354 /* This kicks hotplug scripts, so do it immediately. */
355 backend_create_xenvif(be); 355 err = backend_create_xenvif(be);
356 if (err)
357 goto fail;
356 358
357 return 0; 359 return 0;
358 360
@@ -397,19 +399,19 @@ static int netback_uevent(struct xenbus_device *xdev,
397} 399}
398 400
399 401
400static void backend_create_xenvif(struct backend_info *be) 402static int backend_create_xenvif(struct backend_info *be)
401{ 403{
402 int err; 404 int err;
403 long handle; 405 long handle;
404 struct xenbus_device *dev = be->dev; 406 struct xenbus_device *dev = be->dev;
405 407
406 if (be->vif != NULL) 408 if (be->vif != NULL)
407 return; 409 return 0;
408 410
409 err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle); 411 err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%li", &handle);
410 if (err != 1) { 412 if (err != 1) {
411 xenbus_dev_fatal(dev, err, "reading handle"); 413 xenbus_dev_fatal(dev, err, "reading handle");
412 return; 414 return (err < 0) ? err : -EINVAL;
413 } 415 }
414 416
415 be->vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle); 417 be->vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
@@ -417,10 +419,11 @@ static void backend_create_xenvif(struct backend_info *be)
417 err = PTR_ERR(be->vif); 419 err = PTR_ERR(be->vif);
418 be->vif = NULL; 420 be->vif = NULL;
419 xenbus_dev_fatal(dev, err, "creating interface"); 421 xenbus_dev_fatal(dev, err, "creating interface");
420 return; 422 return err;
421 } 423 }
422 424
423 kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE); 425 kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
426 return 0;
424} 427}
425 428
426static void backend_disconnect(struct backend_info *be) 429static void backend_disconnect(struct backend_info *be)
diff --git a/drivers/of/address.c b/drivers/of/address.c
index afdb78299f61..06af494184d6 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -450,6 +450,21 @@ static struct of_bus *of_match_bus(struct device_node *np)
450 return NULL; 450 return NULL;
451} 451}
452 452
453static int of_empty_ranges_quirk(void)
454{
455 if (IS_ENABLED(CONFIG_PPC)) {
456 /* To save cycles, we cache the result */
457 static int quirk_state = -1;
458
459 if (quirk_state < 0)
460 quirk_state =
461 of_machine_is_compatible("Power Macintosh") ||
462 of_machine_is_compatible("MacRISC");
463 return quirk_state;
464 }
465 return false;
466}
467
453static int of_translate_one(struct device_node *parent, struct of_bus *bus, 468static int of_translate_one(struct device_node *parent, struct of_bus *bus,
454 struct of_bus *pbus, __be32 *addr, 469 struct of_bus *pbus, __be32 *addr,
455 int na, int ns, int pna, const char *rprop) 470 int na, int ns, int pna, const char *rprop)
@@ -475,12 +490,10 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
475 * This code is only enabled on powerpc. --gcl 490 * This code is only enabled on powerpc. --gcl
476 */ 491 */
477 ranges = of_get_property(parent, rprop, &rlen); 492 ranges = of_get_property(parent, rprop, &rlen);
478#if !defined(CONFIG_PPC) 493 if (ranges == NULL && !of_empty_ranges_quirk()) {
479 if (ranges == NULL) {
480 pr_err("OF: no ranges; cannot translate\n"); 494 pr_err("OF: no ranges; cannot translate\n");
481 return 1; 495 return 1;
482 } 496 }
483#endif /* !defined(CONFIG_PPC) */
484 if (ranges == NULL || rlen == 0) { 497 if (ranges == NULL || rlen == 0) {
485 offset = of_read_number(addr, na); 498 offset = of_read_number(addr, na);
486 memset(addr, 0, pna * 4); 499 memset(addr, 0, pna * 4);
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index f297891d8529..d4994177dec2 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -247,7 +247,7 @@ void of_node_release(struct kobject *kobj)
247 * @allocflags: Allocation flags (typically pass GFP_KERNEL) 247 * @allocflags: Allocation flags (typically pass GFP_KERNEL)
248 * 248 *
249 * Copy a property by dynamically allocating the memory of both the 249 * Copy a property by dynamically allocating the memory of both the
250 * property stucture and the property name & contents. The property's 250 * property structure and the property name & contents. The property's
251 * flags have the OF_DYNAMIC bit set so that we can differentiate between 251 * flags have the OF_DYNAMIC bit set so that we can differentiate between
252 * dynamically allocated properties and not. 252 * dynamically allocated properties and not.
253 * Returns the newly allocated property or NULL on out of memory error. 253 * Returns the newly allocated property or NULL on out of memory error.
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1ffca8b34ea..30e97bcc4f88 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -773,7 +773,7 @@ int __init early_init_dt_scan_chosen_serial(void)
773 if (offset < 0) 773 if (offset < 0)
774 return -ENODEV; 774 return -ENODEV;
775 775
776 while (match->compatible) { 776 while (match->compatible[0]) {
777 unsigned long addr; 777 unsigned long addr;
778 if (fdt_node_check_compatible(fdt, offset, match->compatible)) { 778 if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
779 match++; 779 match++;
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 11b873c54a77..e2d79afa9dc6 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -896,10 +896,14 @@ static void selftest_data_remove(void)
896 return; 896 return;
897 } 897 }
898 898
899 while (last_node_index >= 0) { 899 while (last_node_index-- > 0) {
900 if (nodes[last_node_index]) { 900 if (nodes[last_node_index]) {
901 np = of_find_node_by_path(nodes[last_node_index]->full_name); 901 np = of_find_node_by_path(nodes[last_node_index]->full_name);
902 if (strcmp(np->full_name, "/aliases") != 0) { 902 if (np == nodes[last_node_index]) {
903 if (of_aliases == np) {
904 of_node_put(of_aliases);
905 of_aliases = NULL;
906 }
903 detach_node_and_children(np); 907 detach_node_and_children(np);
904 } else { 908 } else {
905 for_each_property_of_node(np, prop) { 909 for_each_property_of_node(np, prop) {
@@ -908,7 +912,6 @@ static void selftest_data_remove(void)
908 } 912 }
909 } 913 }
910 } 914 }
911 last_node_index--;
912 } 915 }
913} 916}
914 917
@@ -921,6 +924,8 @@ static int __init of_selftest(void)
921 res = selftest_data_add(); 924 res = selftest_data_add();
922 if (res) 925 if (res)
923 return res; 926 return res;
927 if (!of_aliases)
928 of_aliases = of_find_node_by_path("/aliases");
924 929
925 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); 930 np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a");
926 if (!np) { 931 if (!np) {
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index d292d7cb3417..49dd766852ba 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -444,7 +444,7 @@ static inline int pcie_cap_version(const struct pci_dev *dev)
444 return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS; 444 return pcie_caps_reg(dev) & PCI_EXP_FLAGS_VERS;
445} 445}
446 446
447static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev) 447bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
448{ 448{
449 int type = pci_pcie_type(dev); 449 int type = pci_pcie_type(dev);
450 450
diff --git a/drivers/pci/host/pci-xgene.c b/drivers/pci/host/pci-xgene.c
index 9ecabfa8c634..2988fe136c1e 100644
--- a/drivers/pci/host/pci-xgene.c
+++ b/drivers/pci/host/pci-xgene.c
@@ -631,10 +631,15 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
631 if (ret) 631 if (ret)
632 return ret; 632 return ret;
633 633
634 bus = pci_scan_root_bus(&pdev->dev, 0, &xgene_pcie_ops, port, &res); 634 bus = pci_create_root_bus(&pdev->dev, 0,
635 &xgene_pcie_ops, port, &res);
635 if (!bus) 636 if (!bus)
636 return -ENOMEM; 637 return -ENOMEM;
637 638
639 pci_scan_child_bus(bus);
640 pci_assign_unassigned_bus_resources(bus);
641 pci_bus_add_devices(bus);
642
638 platform_set_drvdata(pdev, port); 643 platform_set_drvdata(pdev, port);
639 return 0; 644 return 0;
640} 645}
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9fab30af0e75..084587d7cd13 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -590,6 +590,20 @@ static struct msi_desc *msi_setup_entry(struct pci_dev *dev)
590 return entry; 590 return entry;
591} 591}
592 592
593static int msi_verify_entries(struct pci_dev *dev)
594{
595 struct msi_desc *entry;
596
597 list_for_each_entry(entry, &dev->msi_list, list) {
598 if (!dev->no_64bit_msi || !entry->msg.address_hi)
599 continue;
600 dev_err(&dev->dev, "Device has broken 64-bit MSI but arch"
601 " tried to assign one above 4G\n");
602 return -EIO;
603 }
604 return 0;
605}
606
593/** 607/**
594 * msi_capability_init - configure device's MSI capability structure 608 * msi_capability_init - configure device's MSI capability structure
595 * @dev: pointer to the pci_dev data structure of MSI device function 609 * @dev: pointer to the pci_dev data structure of MSI device function
@@ -627,6 +641,13 @@ static int msi_capability_init(struct pci_dev *dev, int nvec)
627 return ret; 641 return ret;
628 } 642 }
629 643
644 ret = msi_verify_entries(dev);
645 if (ret) {
646 msi_mask_irq(entry, mask, ~mask);
647 free_msi_irqs(dev);
648 return ret;
649 }
650
630 ret = populate_msi_sysfs(dev); 651 ret = populate_msi_sysfs(dev);
631 if (ret) { 652 if (ret) {
632 msi_mask_irq(entry, mask, ~mask); 653 msi_mask_irq(entry, mask, ~mask);
@@ -739,6 +760,11 @@ static int msix_capability_init(struct pci_dev *dev,
739 if (ret) 760 if (ret)
740 goto out_avail; 761 goto out_avail;
741 762
763 /* Check if all MSI entries honor device restrictions */
764 ret = msi_verify_entries(dev);
765 if (ret)
766 goto out_free;
767
742 /* 768 /*
743 * Some devices require MSI-X to be enabled before we can touch the 769 * Some devices require MSI-X to be enabled before we can touch the
744 * MSI-X registers. We need to mask all the vectors to prevent 770 * MSI-X registers. We need to mask all the vectors to prevent
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 0601890db22d..4a3902d8e6fe 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -6,6 +6,8 @@
6 6
7extern const unsigned char pcie_link_speed[]; 7extern const unsigned char pcie_link_speed[];
8 8
9bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
10
9/* Functions internal to the PCI core code */ 11/* Functions internal to the PCI core code */
10 12
11int pci_create_sysfs_dev_files(struct pci_dev *pdev); 13int pci_create_sysfs_dev_files(struct pci_dev *pdev);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 5ed99309c758..c8ca98c2b480 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -407,15 +407,16 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child)
407{ 407{
408 struct pci_dev *dev = child->self; 408 struct pci_dev *dev = child->self;
409 u16 mem_base_lo, mem_limit_lo; 409 u16 mem_base_lo, mem_limit_lo;
410 unsigned long base, limit; 410 u64 base64, limit64;
411 dma_addr_t base, limit;
411 struct pci_bus_region region; 412 struct pci_bus_region region;
412 struct resource *res; 413 struct resource *res;
413 414
414 res = child->resource[2]; 415 res = child->resource[2];
415 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); 416 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo);
416 pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo); 417 pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo);
417 base = ((unsigned long) mem_base_lo & PCI_PREF_RANGE_MASK) << 16; 418 base64 = (mem_base_lo & PCI_PREF_RANGE_MASK) << 16;
418 limit = ((unsigned long) mem_limit_lo & PCI_PREF_RANGE_MASK) << 16; 419 limit64 = (mem_limit_lo & PCI_PREF_RANGE_MASK) << 16;
419 420
420 if ((mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) { 421 if ((mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
421 u32 mem_base_hi, mem_limit_hi; 422 u32 mem_base_hi, mem_limit_hi;
@@ -429,17 +430,20 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child)
429 * this, just assume they are not being used. 430 * this, just assume they are not being used.
430 */ 431 */
431 if (mem_base_hi <= mem_limit_hi) { 432 if (mem_base_hi <= mem_limit_hi) {
432#if BITS_PER_LONG == 64 433 base64 |= (u64) mem_base_hi << 32;
433 base |= ((unsigned long) mem_base_hi) << 32; 434 limit64 |= (u64) mem_limit_hi << 32;
434 limit |= ((unsigned long) mem_limit_hi) << 32;
435#else
436 if (mem_base_hi || mem_limit_hi) {
437 dev_err(&dev->dev, "can't handle 64-bit address space for bridge\n");
438 return;
439 }
440#endif
441 } 435 }
442 } 436 }
437
438 base = (dma_addr_t) base64;
439 limit = (dma_addr_t) limit64;
440
441 if (base != base64) {
442 dev_err(&dev->dev, "can't handle bridge window above 4GB (bus address %#010llx)\n",
443 (unsigned long long) base64);
444 return;
445 }
446
443 if (base <= limit) { 447 if (base <= limit) {
444 res->flags = (mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) | 448 res->flags = (mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) |
445 IORESOURCE_MEM | IORESOURCE_PREFETCH; 449 IORESOURCE_MEM | IORESOURCE_PREFETCH;
@@ -1323,7 +1327,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
1323 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or); 1327 ~hpp->pci_exp_devctl_and, hpp->pci_exp_devctl_or);
1324 1328
1325 /* Initialize Link Control Register */ 1329 /* Initialize Link Control Register */
1326 if (dev->subordinate) 1330 if (pcie_cap_has_lnkctl(dev))
1327 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL, 1331 pcie_capability_clear_and_set_word(dev, PCI_EXP_LNKCTL,
1328 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or); 1332 ~hpp->pci_exp_lnkctl_and, hpp->pci_exp_lnkctl_or);
1329 1333
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 4dcfb7116a04..a2eabe6ff9ad 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -202,6 +202,7 @@ config TC1100_WMI
202config HP_ACCEL 202config HP_ACCEL
203 tristate "HP laptop accelerometer" 203 tristate "HP laptop accelerometer"
204 depends on INPUT && ACPI 204 depends on INPUT && ACPI
205 depends on SERIO_I8042
205 select SENSORS_LIS3LV02D 206 select SENSORS_LIS3LV02D
206 select NEW_LEDS 207 select NEW_LEDS
207 select LEDS_CLASS 208 select LEDS_CLASS
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index 13e14ec1d3d7..6bec745b6b92 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -37,6 +37,8 @@
37#include <linux/leds.h> 37#include <linux/leds.h>
38#include <linux/atomic.h> 38#include <linux/atomic.h>
39#include <linux/acpi.h> 39#include <linux/acpi.h>
40#include <linux/i8042.h>
41#include <linux/serio.h>
40#include "../../misc/lis3lv02d/lis3lv02d.h" 42#include "../../misc/lis3lv02d/lis3lv02d.h"
41 43
42#define DRIVER_NAME "hp_accel" 44#define DRIVER_NAME "hp_accel"
@@ -73,6 +75,13 @@ static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
73 75
74/* HP-specific accelerometer driver ------------------------------------ */ 76/* HP-specific accelerometer driver ------------------------------------ */
75 77
78/* e0 25, e0 26, e0 27, e0 28 are scan codes that the accelerometer with acpi id
79 * HPQ6000 sends through the keyboard bus */
80#define ACCEL_1 0x25
81#define ACCEL_2 0x26
82#define ACCEL_3 0x27
83#define ACCEL_4 0x28
84
76/* For automatic insertion of the module */ 85/* For automatic insertion of the module */
77static const struct acpi_device_id lis3lv02d_device_ids[] = { 86static const struct acpi_device_id lis3lv02d_device_ids[] = {
78 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */ 87 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
@@ -294,6 +303,35 @@ static void lis3lv02d_enum_resources(struct acpi_device *device)
294 printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n"); 303 printk(KERN_DEBUG DRIVER_NAME ": Error getting resources\n");
295} 304}
296 305
306static bool hp_accel_i8042_filter(unsigned char data, unsigned char str,
307 struct serio *port)
308{
309 static bool extended;
310
311 if (str & I8042_STR_AUXDATA)
312 return false;
313
314 if (data == 0xe0) {
315 extended = true;
316 return true;
317 } else if (unlikely(extended)) {
318 extended = false;
319
320 switch (data) {
321 case ACCEL_1:
322 case ACCEL_2:
323 case ACCEL_3:
324 case ACCEL_4:
325 return true;
326 default:
327 serio_interrupt(port, 0xe0, 0);
328 return false;
329 }
330 }
331
332 return false;
333}
334
297static int lis3lv02d_add(struct acpi_device *device) 335static int lis3lv02d_add(struct acpi_device *device)
298{ 336{
299 int ret; 337 int ret;
@@ -326,6 +364,11 @@ static int lis3lv02d_add(struct acpi_device *device)
326 if (ret) 364 if (ret)
327 return ret; 365 return ret;
328 366
367 /* filter to remove HPQ6000 accelerometer data
368 * from keyboard bus stream */
369 if (strstr(dev_name(&device->dev), "HPQ6000"))
370 i8042_install_filter(hp_accel_i8042_filter);
371
329 INIT_WORK(&hpled_led.work, delayed_set_status_worker); 372 INIT_WORK(&hpled_led.work, delayed_set_status_worker);
330 ret = led_classdev_register(NULL, &hpled_led.led_classdev); 373 ret = led_classdev_register(NULL, &hpled_led.led_classdev);
331 if (ret) { 374 if (ret) {
@@ -343,6 +386,7 @@ static int lis3lv02d_remove(struct acpi_device *device)
343 if (!device) 386 if (!device)
344 return -EINVAL; 387 return -EINVAL;
345 388
389 i8042_remove_filter(hp_accel_i8042_filter);
346 lis3lv02d_joystick_disable(&lis3_dev); 390 lis3lv02d_joystick_disable(&lis3_dev);
347 lis3lv02d_poweroff(&lis3_dev); 391 lis3lv02d_poweroff(&lis3_dev);
348 392
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index 217da4b2ca86..99a78d365ceb 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -25,6 +25,7 @@
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/time.h> 27#include <linux/time.h>
28#include <linux/time64.h>
28#include <linux/of.h> 29#include <linux/of.h>
29#include <linux/completion.h> 30#include <linux/completion.h>
30#include <linux/mfd/core.h> 31#include <linux/mfd/core.h>
@@ -108,7 +109,7 @@ enum ab8500_fg_calibration_state {
108struct ab8500_fg_avg_cap { 109struct ab8500_fg_avg_cap {
109 int avg; 110 int avg;
110 int samples[NBR_AVG_SAMPLES]; 111 int samples[NBR_AVG_SAMPLES];
111 __kernel_time_t time_stamps[NBR_AVG_SAMPLES]; 112 time64_t time_stamps[NBR_AVG_SAMPLES];
112 int pos; 113 int pos;
113 int nbr_samples; 114 int nbr_samples;
114 int sum; 115 int sum;
@@ -386,15 +387,15 @@ static int ab8500_fg_is_low_curr(struct ab8500_fg *di, int curr)
386 */ 387 */
387static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample) 388static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
388{ 389{
389 struct timespec ts; 390 struct timespec64 ts64;
390 struct ab8500_fg_avg_cap *avg = &di->avg_cap; 391 struct ab8500_fg_avg_cap *avg = &di->avg_cap;
391 392
392 getnstimeofday(&ts); 393 getnstimeofday64(&ts64);
393 394
394 do { 395 do {
395 avg->sum += sample - avg->samples[avg->pos]; 396 avg->sum += sample - avg->samples[avg->pos];
396 avg->samples[avg->pos] = sample; 397 avg->samples[avg->pos] = sample;
397 avg->time_stamps[avg->pos] = ts.tv_sec; 398 avg->time_stamps[avg->pos] = ts64.tv_sec;
398 avg->pos++; 399 avg->pos++;
399 400
400 if (avg->pos == NBR_AVG_SAMPLES) 401 if (avg->pos == NBR_AVG_SAMPLES)
@@ -407,7 +408,7 @@ static int ab8500_fg_add_cap_sample(struct ab8500_fg *di, int sample)
407 * Check the time stamp for each sample. If too old, 408 * Check the time stamp for each sample. If too old,
408 * replace with latest sample 409 * replace with latest sample
409 */ 410 */
410 } while (ts.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]); 411 } while (ts64.tv_sec - VALID_CAPACITY_SEC > avg->time_stamps[avg->pos]);
411 412
412 avg->avg = avg->sum / avg->nbr_samples; 413 avg->avg = avg->sum / avg->nbr_samples;
413 414
@@ -446,14 +447,14 @@ static void ab8500_fg_clear_cap_samples(struct ab8500_fg *di)
446static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) 447static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample)
447{ 448{
448 int i; 449 int i;
449 struct timespec ts; 450 struct timespec64 ts64;
450 struct ab8500_fg_avg_cap *avg = &di->avg_cap; 451 struct ab8500_fg_avg_cap *avg = &di->avg_cap;
451 452
452 getnstimeofday(&ts); 453 getnstimeofday64(&ts64);
453 454
454 for (i = 0; i < NBR_AVG_SAMPLES; i++) { 455 for (i = 0; i < NBR_AVG_SAMPLES; i++) {
455 avg->samples[i] = sample; 456 avg->samples[i] = sample;
456 avg->time_stamps[i] = ts.tv_sec; 457 avg->time_stamps[i] = ts64.tv_sec;
457 } 458 }
458 459
459 avg->pos = 0; 460 avg->pos = 0;
diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index e384844a1ae1..1f49986fc605 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -1579,8 +1579,15 @@ static int bq2415x_probe(struct i2c_client *client,
1579 if (np) { 1579 if (np) {
1580 bq->notify_psy = power_supply_get_by_phandle(np, "ti,usb-charger-detection"); 1580 bq->notify_psy = power_supply_get_by_phandle(np, "ti,usb-charger-detection");
1581 1581
1582 if (!bq->notify_psy) 1582 if (IS_ERR(bq->notify_psy)) {
1583 return -EPROBE_DEFER; 1583 dev_info(&client->dev,
1584 "no 'ti,usb-charger-detection' property (err=%ld)\n",
1585 PTR_ERR(bq->notify_psy));
1586 bq->notify_psy = NULL;
1587 } else if (!bq->notify_psy) {
1588 ret = -EPROBE_DEFER;
1589 goto error_2;
1590 }
1584 } 1591 }
1585 else if (pdata->notify_device) 1592 else if (pdata->notify_device)
1586 bq->notify_psy = power_supply_get_by_name(pdata->notify_device); 1593 bq->notify_psy = power_supply_get_by_name(pdata->notify_device);
@@ -1602,27 +1609,27 @@ static int bq2415x_probe(struct i2c_client *client,
1602 ret = of_property_read_u32(np, "ti,current-limit", 1609 ret = of_property_read_u32(np, "ti,current-limit",
1603 &bq->init_data.current_limit); 1610 &bq->init_data.current_limit);
1604 if (ret) 1611 if (ret)
1605 return ret; 1612 goto error_2;
1606 ret = of_property_read_u32(np, "ti,weak-battery-voltage", 1613 ret = of_property_read_u32(np, "ti,weak-battery-voltage",
1607 &bq->init_data.weak_battery_voltage); 1614 &bq->init_data.weak_battery_voltage);
1608 if (ret) 1615 if (ret)
1609 return ret; 1616 goto error_2;
1610 ret = of_property_read_u32(np, "ti,battery-regulation-voltage", 1617 ret = of_property_read_u32(np, "ti,battery-regulation-voltage",
1611 &bq->init_data.battery_regulation_voltage); 1618 &bq->init_data.battery_regulation_voltage);
1612 if (ret) 1619 if (ret)
1613 return ret; 1620 goto error_2;
1614 ret = of_property_read_u32(np, "ti,charge-current", 1621 ret = of_property_read_u32(np, "ti,charge-current",
1615 &bq->init_data.charge_current); 1622 &bq->init_data.charge_current);
1616 if (ret) 1623 if (ret)
1617 return ret; 1624 goto error_2;
1618 ret = of_property_read_u32(np, "ti,termination-current", 1625 ret = of_property_read_u32(np, "ti,termination-current",
1619 &bq->init_data.termination_current); 1626 &bq->init_data.termination_current);
1620 if (ret) 1627 if (ret)
1621 return ret; 1628 goto error_2;
1622 ret = of_property_read_u32(np, "ti,resistor-sense", 1629 ret = of_property_read_u32(np, "ti,resistor-sense",
1623 &bq->init_data.resistor_sense); 1630 &bq->init_data.resistor_sense);
1624 if (ret) 1631 if (ret)
1625 return ret; 1632 goto error_2;
1626 } else { 1633 } else {
1627 memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); 1634 memcpy(&bq->init_data, pdata, sizeof(bq->init_data));
1628 } 1635 }
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 7098a1ce2d3c..ef8094a61f1e 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -97,6 +97,7 @@ static struct charger_global_desc *g_desc; /* init with setup_charger_manager */
97static bool is_batt_present(struct charger_manager *cm) 97static bool is_batt_present(struct charger_manager *cm)
98{ 98{
99 union power_supply_propval val; 99 union power_supply_propval val;
100 struct power_supply *psy;
100 bool present = false; 101 bool present = false;
101 int i, ret; 102 int i, ret;
102 103
@@ -107,16 +108,27 @@ static bool is_batt_present(struct charger_manager *cm)
107 case CM_NO_BATTERY: 108 case CM_NO_BATTERY:
108 break; 109 break;
109 case CM_FUEL_GAUGE: 110 case CM_FUEL_GAUGE:
110 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 111 psy = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
112 if (!psy)
113 break;
114
115 ret = psy->get_property(psy,
111 POWER_SUPPLY_PROP_PRESENT, &val); 116 POWER_SUPPLY_PROP_PRESENT, &val);
112 if (ret == 0 && val.intval) 117 if (ret == 0 && val.intval)
113 present = true; 118 present = true;
114 break; 119 break;
115 case CM_CHARGER_STAT: 120 case CM_CHARGER_STAT:
116 for (i = 0; cm->charger_stat[i]; i++) { 121 for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
117 ret = cm->charger_stat[i]->get_property( 122 psy = power_supply_get_by_name(
118 cm->charger_stat[i], 123 cm->desc->psy_charger_stat[i]);
119 POWER_SUPPLY_PROP_PRESENT, &val); 124 if (!psy) {
125 dev_err(cm->dev, "Cannot find power supply \"%s\"\n",
126 cm->desc->psy_charger_stat[i]);
127 continue;
128 }
129
130 ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT,
131 &val);
120 if (ret == 0 && val.intval) { 132 if (ret == 0 && val.intval) {
121 present = true; 133 present = true;
122 break; 134 break;
@@ -139,14 +151,20 @@ static bool is_batt_present(struct charger_manager *cm)
139static bool is_ext_pwr_online(struct charger_manager *cm) 151static bool is_ext_pwr_online(struct charger_manager *cm)
140{ 152{
141 union power_supply_propval val; 153 union power_supply_propval val;
154 struct power_supply *psy;
142 bool online = false; 155 bool online = false;
143 int i, ret; 156 int i, ret;
144 157
145 /* If at least one of them has one, it's yes. */ 158 /* If at least one of them has one, it's yes. */
146 for (i = 0; cm->charger_stat[i]; i++) { 159 for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
147 ret = cm->charger_stat[i]->get_property( 160 psy = power_supply_get_by_name(cm->desc->psy_charger_stat[i]);
148 cm->charger_stat[i], 161 if (!psy) {
149 POWER_SUPPLY_PROP_ONLINE, &val); 162 dev_err(cm->dev, "Cannot find power supply \"%s\"\n",
163 cm->desc->psy_charger_stat[i]);
164 continue;
165 }
166
167 ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
150 if (ret == 0 && val.intval) { 168 if (ret == 0 && val.intval) {
151 online = true; 169 online = true;
152 break; 170 break;
@@ -167,12 +185,14 @@ static bool is_ext_pwr_online(struct charger_manager *cm)
167static int get_batt_uV(struct charger_manager *cm, int *uV) 185static int get_batt_uV(struct charger_manager *cm, int *uV)
168{ 186{
169 union power_supply_propval val; 187 union power_supply_propval val;
188 struct power_supply *fuel_gauge;
170 int ret; 189 int ret;
171 190
172 if (!cm->fuel_gauge) 191 fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
192 if (!fuel_gauge)
173 return -ENODEV; 193 return -ENODEV;
174 194
175 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 195 ret = fuel_gauge->get_property(fuel_gauge,
176 POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); 196 POWER_SUPPLY_PROP_VOLTAGE_NOW, &val);
177 if (ret) 197 if (ret)
178 return ret; 198 return ret;
@@ -189,6 +209,7 @@ static bool is_charging(struct charger_manager *cm)
189{ 209{
190 int i, ret; 210 int i, ret;
191 bool charging = false; 211 bool charging = false;
212 struct power_supply *psy;
192 union power_supply_propval val; 213 union power_supply_propval val;
193 214
194 /* If there is no battery, it cannot be charged */ 215 /* If there is no battery, it cannot be charged */
@@ -196,17 +217,22 @@ static bool is_charging(struct charger_manager *cm)
196 return false; 217 return false;
197 218
198 /* If at least one of the charger is charging, return yes */ 219 /* If at least one of the charger is charging, return yes */
199 for (i = 0; cm->charger_stat[i]; i++) { 220 for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
200 /* 1. The charger sholuld not be DISABLED */ 221 /* 1. The charger sholuld not be DISABLED */
201 if (cm->emergency_stop) 222 if (cm->emergency_stop)
202 continue; 223 continue;
203 if (!cm->charger_enabled) 224 if (!cm->charger_enabled)
204 continue; 225 continue;
205 226
227 psy = power_supply_get_by_name(cm->desc->psy_charger_stat[i]);
228 if (!psy) {
229 dev_err(cm->dev, "Cannot find power supply \"%s\"\n",
230 cm->desc->psy_charger_stat[i]);
231 continue;
232 }
233
206 /* 2. The charger should be online (ext-power) */ 234 /* 2. The charger should be online (ext-power) */
207 ret = cm->charger_stat[i]->get_property( 235 ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
208 cm->charger_stat[i],
209 POWER_SUPPLY_PROP_ONLINE, &val);
210 if (ret) { 236 if (ret) {
211 dev_warn(cm->dev, "Cannot read ONLINE value from %s\n", 237 dev_warn(cm->dev, "Cannot read ONLINE value from %s\n",
212 cm->desc->psy_charger_stat[i]); 238 cm->desc->psy_charger_stat[i]);
@@ -219,9 +245,7 @@ static bool is_charging(struct charger_manager *cm)
219 * 3. The charger should not be FULL, DISCHARGING, 245 * 3. The charger should not be FULL, DISCHARGING,
220 * or NOT_CHARGING. 246 * or NOT_CHARGING.
221 */ 247 */
222 ret = cm->charger_stat[i]->get_property( 248 ret = psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &val);
223 cm->charger_stat[i],
224 POWER_SUPPLY_PROP_STATUS, &val);
225 if (ret) { 249 if (ret) {
226 dev_warn(cm->dev, "Cannot read STATUS value from %s\n", 250 dev_warn(cm->dev, "Cannot read STATUS value from %s\n",
227 cm->desc->psy_charger_stat[i]); 251 cm->desc->psy_charger_stat[i]);
@@ -248,6 +272,7 @@ static bool is_full_charged(struct charger_manager *cm)
248{ 272{
249 struct charger_desc *desc = cm->desc; 273 struct charger_desc *desc = cm->desc;
250 union power_supply_propval val; 274 union power_supply_propval val;
275 struct power_supply *fuel_gauge;
251 int ret = 0; 276 int ret = 0;
252 int uV; 277 int uV;
253 278
@@ -255,11 +280,15 @@ static bool is_full_charged(struct charger_manager *cm)
255 if (!is_batt_present(cm)) 280 if (!is_batt_present(cm))
256 return false; 281 return false;
257 282
258 if (cm->fuel_gauge && desc->fullbatt_full_capacity > 0) { 283 fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
284 if (!fuel_gauge)
285 return false;
286
287 if (desc->fullbatt_full_capacity > 0) {
259 val.intval = 0; 288 val.intval = 0;
260 289
261 /* Not full if capacity of fuel gauge isn't full */ 290 /* Not full if capacity of fuel gauge isn't full */
262 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 291 ret = fuel_gauge->get_property(fuel_gauge,
263 POWER_SUPPLY_PROP_CHARGE_FULL, &val); 292 POWER_SUPPLY_PROP_CHARGE_FULL, &val);
264 if (!ret && val.intval > desc->fullbatt_full_capacity) 293 if (!ret && val.intval > desc->fullbatt_full_capacity)
265 return true; 294 return true;
@@ -273,10 +302,10 @@ static bool is_full_charged(struct charger_manager *cm)
273 } 302 }
274 303
275 /* Full, if the capacity is more than fullbatt_soc */ 304 /* Full, if the capacity is more than fullbatt_soc */
276 if (cm->fuel_gauge && desc->fullbatt_soc > 0) { 305 if (desc->fullbatt_soc > 0) {
277 val.intval = 0; 306 val.intval = 0;
278 307
279 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 308 ret = fuel_gauge->get_property(fuel_gauge,
280 POWER_SUPPLY_PROP_CAPACITY, &val); 309 POWER_SUPPLY_PROP_CAPACITY, &val);
281 if (!ret && val.intval >= desc->fullbatt_soc) 310 if (!ret && val.intval >= desc->fullbatt_soc)
282 return true; 311 return true;
@@ -551,6 +580,20 @@ static int check_charging_duration(struct charger_manager *cm)
551 return ret; 580 return ret;
552} 581}
553 582
583static int cm_get_battery_temperature_by_psy(struct charger_manager *cm,
584 int *temp)
585{
586 struct power_supply *fuel_gauge;
587
588 fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
589 if (!fuel_gauge)
590 return -ENODEV;
591
592 return fuel_gauge->get_property(fuel_gauge,
593 POWER_SUPPLY_PROP_TEMP,
594 (union power_supply_propval *)temp);
595}
596
554static int cm_get_battery_temperature(struct charger_manager *cm, 597static int cm_get_battery_temperature(struct charger_manager *cm,
555 int *temp) 598 int *temp)
556{ 599{
@@ -560,15 +603,18 @@ static int cm_get_battery_temperature(struct charger_manager *cm,
560 return -ENODEV; 603 return -ENODEV;
561 604
562#ifdef CONFIG_THERMAL 605#ifdef CONFIG_THERMAL
563 ret = thermal_zone_get_temp(cm->tzd_batt, (unsigned long *)temp); 606 if (cm->tzd_batt) {
564 if (!ret) 607 ret = thermal_zone_get_temp(cm->tzd_batt, (unsigned long *)temp);
565 /* Calibrate temperature unit */ 608 if (!ret)
566 *temp /= 100; 609 /* Calibrate temperature unit */
567#else 610 *temp /= 100;
568 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 611 } else
569 POWER_SUPPLY_PROP_TEMP,
570 (union power_supply_propval *)temp);
571#endif 612#endif
613 {
614 /* if-else continued from CONFIG_THERMAL */
615 ret = cm_get_battery_temperature_by_psy(cm, temp);
616 }
617
572 return ret; 618 return ret;
573} 619}
574 620
@@ -827,6 +873,7 @@ static int charger_get_property(struct power_supply *psy,
827 struct charger_manager *cm = container_of(psy, 873 struct charger_manager *cm = container_of(psy,
828 struct charger_manager, charger_psy); 874 struct charger_manager, charger_psy);
829 struct charger_desc *desc = cm->desc; 875 struct charger_desc *desc = cm->desc;
876 struct power_supply *fuel_gauge;
830 int ret = 0; 877 int ret = 0;
831 int uV; 878 int uV;
832 879
@@ -857,14 +904,20 @@ static int charger_get_property(struct power_supply *psy,
857 ret = get_batt_uV(cm, &val->intval); 904 ret = get_batt_uV(cm, &val->intval);
858 break; 905 break;
859 case POWER_SUPPLY_PROP_CURRENT_NOW: 906 case POWER_SUPPLY_PROP_CURRENT_NOW:
860 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 907 fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
908 if (!fuel_gauge) {
909 ret = -ENODEV;
910 break;
911 }
912 ret = fuel_gauge->get_property(fuel_gauge,
861 POWER_SUPPLY_PROP_CURRENT_NOW, val); 913 POWER_SUPPLY_PROP_CURRENT_NOW, val);
862 break; 914 break;
863 case POWER_SUPPLY_PROP_TEMP: 915 case POWER_SUPPLY_PROP_TEMP:
864 case POWER_SUPPLY_PROP_TEMP_AMBIENT: 916 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
865 return cm_get_battery_temperature(cm, &val->intval); 917 return cm_get_battery_temperature(cm, &val->intval);
866 case POWER_SUPPLY_PROP_CAPACITY: 918 case POWER_SUPPLY_PROP_CAPACITY:
867 if (!cm->fuel_gauge) { 919 fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
920 if (!fuel_gauge) {
868 ret = -ENODEV; 921 ret = -ENODEV;
869 break; 922 break;
870 } 923 }
@@ -875,7 +928,7 @@ static int charger_get_property(struct power_supply *psy,
875 break; 928 break;
876 } 929 }
877 930
878 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 931 ret = fuel_gauge->get_property(fuel_gauge,
879 POWER_SUPPLY_PROP_CAPACITY, val); 932 POWER_SUPPLY_PROP_CAPACITY, val);
880 if (ret) 933 if (ret)
881 break; 934 break;
@@ -924,7 +977,14 @@ static int charger_get_property(struct power_supply *psy,
924 break; 977 break;
925 case POWER_SUPPLY_PROP_CHARGE_NOW: 978 case POWER_SUPPLY_PROP_CHARGE_NOW:
926 if (is_charging(cm)) { 979 if (is_charging(cm)) {
927 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 980 fuel_gauge = power_supply_get_by_name(
981 cm->desc->psy_fuel_gauge);
982 if (!fuel_gauge) {
983 ret = -ENODEV;
984 break;
985 }
986
987 ret = fuel_gauge->get_property(fuel_gauge,
928 POWER_SUPPLY_PROP_CHARGE_NOW, 988 POWER_SUPPLY_PROP_CHARGE_NOW,
929 val); 989 val);
930 if (ret) { 990 if (ret) {
@@ -970,6 +1030,7 @@ static struct power_supply psy_default = {
970 .properties = default_charger_props, 1030 .properties = default_charger_props,
971 .num_properties = ARRAY_SIZE(default_charger_props), 1031 .num_properties = ARRAY_SIZE(default_charger_props),
972 .get_property = charger_get_property, 1032 .get_property = charger_get_property,
1033 .no_thermal = true,
973}; 1034};
974 1035
975/** 1036/**
@@ -1485,14 +1546,15 @@ err:
1485 return ret; 1546 return ret;
1486} 1547}
1487 1548
1488static int cm_init_thermal_data(struct charger_manager *cm) 1549static int cm_init_thermal_data(struct charger_manager *cm,
1550 struct power_supply *fuel_gauge)
1489{ 1551{
1490 struct charger_desc *desc = cm->desc; 1552 struct charger_desc *desc = cm->desc;
1491 union power_supply_propval val; 1553 union power_supply_propval val;
1492 int ret; 1554 int ret;
1493 1555
1494 /* Verify whether fuel gauge provides battery temperature */ 1556 /* Verify whether fuel gauge provides battery temperature */
1495 ret = cm->fuel_gauge->get_property(cm->fuel_gauge, 1557 ret = fuel_gauge->get_property(fuel_gauge,
1496 POWER_SUPPLY_PROP_TEMP, &val); 1558 POWER_SUPPLY_PROP_TEMP, &val);
1497 1559
1498 if (!ret) { 1560 if (!ret) {
@@ -1502,8 +1564,6 @@ static int cm_init_thermal_data(struct charger_manager *cm)
1502 cm->desc->measure_battery_temp = true; 1564 cm->desc->measure_battery_temp = true;
1503 } 1565 }
1504#ifdef CONFIG_THERMAL 1566#ifdef CONFIG_THERMAL
1505 cm->tzd_batt = cm->fuel_gauge->tzd;
1506
1507 if (ret && desc->thermal_zone) { 1567 if (ret && desc->thermal_zone) {
1508 cm->tzd_batt = 1568 cm->tzd_batt =
1509 thermal_zone_get_zone_by_name(desc->thermal_zone); 1569 thermal_zone_get_zone_by_name(desc->thermal_zone);
@@ -1666,6 +1726,7 @@ static int charger_manager_probe(struct platform_device *pdev)
1666 int ret = 0, i = 0; 1726 int ret = 0, i = 0;
1667 int j = 0; 1727 int j = 0;
1668 union power_supply_propval val; 1728 union power_supply_propval val;
1729 struct power_supply *fuel_gauge;
1669 1730
1670 if (g_desc && !rtc_dev && g_desc->rtc_name) { 1731 if (g_desc && !rtc_dev && g_desc->rtc_name) {
1671 rtc_dev = rtc_class_open(g_desc->rtc_name); 1732 rtc_dev = rtc_class_open(g_desc->rtc_name);
@@ -1729,23 +1790,20 @@ static int charger_manager_probe(struct platform_device *pdev)
1729 while (desc->psy_charger_stat[i]) 1790 while (desc->psy_charger_stat[i])
1730 i++; 1791 i++;
1731 1792
1732 cm->charger_stat = devm_kzalloc(&pdev->dev, 1793 /* Check if charger's supplies are present at probe */
1733 sizeof(struct power_supply *) * i, GFP_KERNEL);
1734 if (!cm->charger_stat)
1735 return -ENOMEM;
1736
1737 for (i = 0; desc->psy_charger_stat[i]; i++) { 1794 for (i = 0; desc->psy_charger_stat[i]; i++) {
1738 cm->charger_stat[i] = power_supply_get_by_name( 1795 struct power_supply *psy;
1739 desc->psy_charger_stat[i]); 1796
1740 if (!cm->charger_stat[i]) { 1797 psy = power_supply_get_by_name(desc->psy_charger_stat[i]);
1798 if (!psy) {
1741 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n", 1799 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n",
1742 desc->psy_charger_stat[i]); 1800 desc->psy_charger_stat[i]);
1743 return -ENODEV; 1801 return -ENODEV;
1744 } 1802 }
1745 } 1803 }
1746 1804
1747 cm->fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge); 1805 fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge);
1748 if (!cm->fuel_gauge) { 1806 if (!fuel_gauge) {
1749 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n", 1807 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n",
1750 desc->psy_fuel_gauge); 1808 desc->psy_fuel_gauge);
1751 return -ENODEV; 1809 return -ENODEV;
@@ -1788,13 +1846,13 @@ static int charger_manager_probe(struct platform_device *pdev)
1788 cm->charger_psy.num_properties = psy_default.num_properties; 1846 cm->charger_psy.num_properties = psy_default.num_properties;
1789 1847
1790 /* Find which optional psy-properties are available */ 1848 /* Find which optional psy-properties are available */
1791 if (!cm->fuel_gauge->get_property(cm->fuel_gauge, 1849 if (!fuel_gauge->get_property(fuel_gauge,
1792 POWER_SUPPLY_PROP_CHARGE_NOW, &val)) { 1850 POWER_SUPPLY_PROP_CHARGE_NOW, &val)) {
1793 cm->charger_psy.properties[cm->charger_psy.num_properties] = 1851 cm->charger_psy.properties[cm->charger_psy.num_properties] =
1794 POWER_SUPPLY_PROP_CHARGE_NOW; 1852 POWER_SUPPLY_PROP_CHARGE_NOW;
1795 cm->charger_psy.num_properties++; 1853 cm->charger_psy.num_properties++;
1796 } 1854 }
1797 if (!cm->fuel_gauge->get_property(cm->fuel_gauge, 1855 if (!fuel_gauge->get_property(fuel_gauge,
1798 POWER_SUPPLY_PROP_CURRENT_NOW, 1856 POWER_SUPPLY_PROP_CURRENT_NOW,
1799 &val)) { 1857 &val)) {
1800 cm->charger_psy.properties[cm->charger_psy.num_properties] = 1858 cm->charger_psy.properties[cm->charger_psy.num_properties] =
@@ -1802,7 +1860,7 @@ static int charger_manager_probe(struct platform_device *pdev)
1802 cm->charger_psy.num_properties++; 1860 cm->charger_psy.num_properties++;
1803 } 1861 }
1804 1862
1805 ret = cm_init_thermal_data(cm); 1863 ret = cm_init_thermal_data(cm, fuel_gauge);
1806 if (ret) { 1864 if (ret) {
1807 dev_err(&pdev->dev, "Failed to initialize thermal data\n"); 1865 dev_err(&pdev->dev, "Failed to initialize thermal data\n");
1808 cm->desc->measure_battery_temp = false; 1866 cm->desc->measure_battery_temp = false;
@@ -2066,8 +2124,8 @@ static bool find_power_supply(struct charger_manager *cm,
2066 int i; 2124 int i;
2067 bool found = false; 2125 bool found = false;
2068 2126
2069 for (i = 0; cm->charger_stat[i]; i++) { 2127 for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
2070 if (psy == cm->charger_stat[i]) { 2128 if (!strcmp(psy->name, cm->desc->psy_charger_stat[i])) {
2071 found = true; 2129 found = true;
2072 break; 2130 break;
2073 } 2131 }
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 6cb7fe5c022d..694e8cddd5c1 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -417,6 +417,9 @@ static int psy_register_thermal(struct power_supply *psy)
417{ 417{
418 int i; 418 int i;
419 419
420 if (psy->no_thermal)
421 return 0;
422
420 /* Register battery zone device psy reports temperature */ 423 /* Register battery zone device psy reports temperature */
421 for (i = 0; i < psy->num_properties; i++) { 424 for (i = 0; i < psy->num_properties; i++) {
422 if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) { 425 if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) {
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 6cbe6ef3c889..bda52f18e967 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -888,7 +888,6 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,
888 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev); 888 struct virtio_ccw_device *vcdev = dev_get_drvdata(&cdev->dev);
889 int i; 889 int i;
890 struct virtqueue *vq; 890 struct virtqueue *vq;
891 struct virtio_driver *drv;
892 891
893 if (!vcdev) 892 if (!vcdev)
894 return; 893 return;
diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c b/drivers/scsi/bnx2fc/bnx2fc_els.c
index ca75c7ca2559..ef355c13ccc4 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_els.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
@@ -480,9 +480,7 @@ void bnx2fc_rec_compl(struct bnx2fc_els_cb_arg *cb_arg)
480 bnx2fc_initiate_cleanup(orig_io_req); 480 bnx2fc_initiate_cleanup(orig_io_req);
481 /* Post a new IO req with the same sc_cmd */ 481 /* Post a new IO req with the same sc_cmd */
482 BNX2FC_IO_DBG(rec_req, "Post IO request again\n"); 482 BNX2FC_IO_DBG(rec_req, "Post IO request again\n");
483 spin_unlock_bh(&tgt->tgt_lock);
484 rc = bnx2fc_post_io_req(tgt, new_io_req); 483 rc = bnx2fc_post_io_req(tgt, new_io_req);
485 spin_lock_bh(&tgt->tgt_lock);
486 if (!rc) 484 if (!rc)
487 goto free_frame; 485 goto free_frame;
488 BNX2FC_IO_DBG(rec_req, "REC: io post err\n"); 486 BNX2FC_IO_DBG(rec_req, "REC: io post err\n");
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 79e5c94107a9..72533c58c1f3 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -412,6 +412,7 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
412 struct fc_frame_header *fh; 412 struct fc_frame_header *fh;
413 struct fcoe_rcv_info *fr; 413 struct fcoe_rcv_info *fr;
414 struct fcoe_percpu_s *bg; 414 struct fcoe_percpu_s *bg;
415 struct sk_buff *tmp_skb;
415 unsigned short oxid; 416 unsigned short oxid;
416 417
417 interface = container_of(ptype, struct bnx2fc_interface, 418 interface = container_of(ptype, struct bnx2fc_interface,
@@ -424,6 +425,12 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
424 goto err; 425 goto err;
425 } 426 }
426 427
428 tmp_skb = skb_share_check(skb, GFP_ATOMIC);
429 if (!tmp_skb)
430 goto err;
431
432 skb = tmp_skb;
433
427 if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) { 434 if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
428 printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n"); 435 printk(KERN_ERR PFX "bnx2fc_rcv: Wrong FC type frame\n");
429 goto err; 436 goto err;
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0679782d9d15..5b99844ef6bf 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1894,18 +1894,24 @@ int bnx2fc_queuecommand(struct Scsi_Host *host,
1894 goto exit_qcmd; 1894 goto exit_qcmd;
1895 } 1895 }
1896 } 1896 }
1897
1898 spin_lock_bh(&tgt->tgt_lock);
1899
1897 io_req = bnx2fc_cmd_alloc(tgt); 1900 io_req = bnx2fc_cmd_alloc(tgt);
1898 if (!io_req) { 1901 if (!io_req) {
1899 rc = SCSI_MLQUEUE_HOST_BUSY; 1902 rc = SCSI_MLQUEUE_HOST_BUSY;
1900 goto exit_qcmd; 1903 goto exit_qcmd_tgtlock;
1901 } 1904 }
1902 io_req->sc_cmd = sc_cmd; 1905 io_req->sc_cmd = sc_cmd;
1903 1906
1904 if (bnx2fc_post_io_req(tgt, io_req)) { 1907 if (bnx2fc_post_io_req(tgt, io_req)) {
1905 printk(KERN_ERR PFX "Unable to post io_req\n"); 1908 printk(KERN_ERR PFX "Unable to post io_req\n");
1906 rc = SCSI_MLQUEUE_HOST_BUSY; 1909 rc = SCSI_MLQUEUE_HOST_BUSY;
1907 goto exit_qcmd; 1910 goto exit_qcmd_tgtlock;
1908 } 1911 }
1912
1913exit_qcmd_tgtlock:
1914 spin_unlock_bh(&tgt->tgt_lock);
1909exit_qcmd: 1915exit_qcmd:
1910 return rc; 1916 return rc;
1911} 1917}
@@ -2020,6 +2026,8 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2020 int task_idx, index; 2026 int task_idx, index;
2021 u16 xid; 2027 u16 xid;
2022 2028
2029 /* bnx2fc_post_io_req() is called with the tgt_lock held */
2030
2023 /* Initialize rest of io_req fields */ 2031 /* Initialize rest of io_req fields */
2024 io_req->cmd_type = BNX2FC_SCSI_CMD; 2032 io_req->cmd_type = BNX2FC_SCSI_CMD;
2025 io_req->port = port; 2033 io_req->port = port;
@@ -2047,9 +2055,7 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2047 /* Build buffer descriptor list for firmware from sg list */ 2055 /* Build buffer descriptor list for firmware from sg list */
2048 if (bnx2fc_build_bd_list_from_sg(io_req)) { 2056 if (bnx2fc_build_bd_list_from_sg(io_req)) {
2049 printk(KERN_ERR PFX "BD list creation failed\n"); 2057 printk(KERN_ERR PFX "BD list creation failed\n");
2050 spin_lock_bh(&tgt->tgt_lock);
2051 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2058 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2052 spin_unlock_bh(&tgt->tgt_lock);
2053 return -EAGAIN; 2059 return -EAGAIN;
2054 } 2060 }
2055 2061
@@ -2061,19 +2067,15 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2061 task = &(task_page[index]); 2067 task = &(task_page[index]);
2062 bnx2fc_init_task(io_req, task); 2068 bnx2fc_init_task(io_req, task);
2063 2069
2064 spin_lock_bh(&tgt->tgt_lock);
2065
2066 if (tgt->flush_in_prog) { 2070 if (tgt->flush_in_prog) {
2067 printk(KERN_ERR PFX "Flush in progress..Host Busy\n"); 2071 printk(KERN_ERR PFX "Flush in progress..Host Busy\n");
2068 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2072 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2069 spin_unlock_bh(&tgt->tgt_lock);
2070 return -EAGAIN; 2073 return -EAGAIN;
2071 } 2074 }
2072 2075
2073 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) { 2076 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) {
2074 printk(KERN_ERR PFX "Session not ready...post_io\n"); 2077 printk(KERN_ERR PFX "Session not ready...post_io\n");
2075 kref_put(&io_req->refcount, bnx2fc_cmd_release); 2078 kref_put(&io_req->refcount, bnx2fc_cmd_release);
2076 spin_unlock_bh(&tgt->tgt_lock);
2077 return -EAGAIN; 2079 return -EAGAIN;
2078 } 2080 }
2079 2081
@@ -2091,6 +2093,5 @@ int bnx2fc_post_io_req(struct bnx2fc_rport *tgt,
2091 2093
2092 /* Ring doorbell */ 2094 /* Ring doorbell */
2093 bnx2fc_ring_doorbell(tgt); 2095 bnx2fc_ring_doorbell(tgt);
2094 spin_unlock_bh(&tgt->tgt_lock);
2095 return 0; 2096 return 0;
2096} 2097}
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 3e0a0d315f72..15081257cfc8 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -828,6 +828,8 @@ static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
828 if (status == CPL_ERR_RTX_NEG_ADVICE) 828 if (status == CPL_ERR_RTX_NEG_ADVICE)
829 goto rel_skb; 829 goto rel_skb;
830 830
831 module_put(THIS_MODULE);
832
831 if (status && status != CPL_ERR_TCAM_FULL && 833 if (status && status != CPL_ERR_TCAM_FULL &&
832 status != CPL_ERR_CONN_EXIST && 834 status != CPL_ERR_CONN_EXIST &&
833 status != CPL_ERR_ARP_MISS) 835 status != CPL_ERR_ARP_MISS)
@@ -936,20 +938,23 @@ static void do_abort_req_rss(struct cxgbi_device *cdev, struct sk_buff *skb)
936 cxgbi_sock_get(csk); 938 cxgbi_sock_get(csk);
937 spin_lock_bh(&csk->lock); 939 spin_lock_bh(&csk->lock);
938 940
939 if (!cxgbi_sock_flag(csk, CTPF_ABORT_REQ_RCVD)) { 941 cxgbi_sock_clear_flag(csk, CTPF_ABORT_REQ_RCVD);
940 cxgbi_sock_set_flag(csk, CTPF_ABORT_REQ_RCVD); 942
941 cxgbi_sock_set_state(csk, CTP_ABORTING); 943 if (!cxgbi_sock_flag(csk, CTPF_TX_DATA_SENT)) {
942 goto done; 944 send_tx_flowc_wr(csk);
945 cxgbi_sock_set_flag(csk, CTPF_TX_DATA_SENT);
943 } 946 }
944 947
945 cxgbi_sock_clear_flag(csk, CTPF_ABORT_REQ_RCVD); 948 cxgbi_sock_set_flag(csk, CTPF_ABORT_REQ_RCVD);
949 cxgbi_sock_set_state(csk, CTP_ABORTING);
950
946 send_abort_rpl(csk, rst_status); 951 send_abort_rpl(csk, rst_status);
947 952
948 if (!cxgbi_sock_flag(csk, CTPF_ABORT_RPL_PENDING)) { 953 if (!cxgbi_sock_flag(csk, CTPF_ABORT_RPL_PENDING)) {
949 csk->err = abort_status_to_errno(csk, req->status, &rst_status); 954 csk->err = abort_status_to_errno(csk, req->status, &rst_status);
950 cxgbi_sock_closed(csk); 955 cxgbi_sock_closed(csk);
951 } 956 }
952done: 957
953 spin_unlock_bh(&csk->lock); 958 spin_unlock_bh(&csk->lock);
954 cxgbi_sock_put(csk); 959 cxgbi_sock_put(csk);
955rel_skb: 960rel_skb:
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 674d498b46ab..7da59c38a69e 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -816,7 +816,7 @@ static void cxgbi_inform_iscsi_conn_closing(struct cxgbi_sock *csk)
816 read_lock_bh(&csk->callback_lock); 816 read_lock_bh(&csk->callback_lock);
817 if (csk->user_data) 817 if (csk->user_data)
818 iscsi_conn_failure(csk->user_data, 818 iscsi_conn_failure(csk->user_data,
819 ISCSI_ERR_CONN_FAILED); 819 ISCSI_ERR_TCP_CONN_CLOSE);
820 read_unlock_bh(&csk->callback_lock); 820 read_unlock_bh(&csk->callback_lock);
821 } 821 }
822} 822}
@@ -905,18 +905,16 @@ void cxgbi_sock_rcv_abort_rpl(struct cxgbi_sock *csk)
905{ 905{
906 cxgbi_sock_get(csk); 906 cxgbi_sock_get(csk);
907 spin_lock_bh(&csk->lock); 907 spin_lock_bh(&csk->lock);
908
909 cxgbi_sock_set_flag(csk, CTPF_ABORT_RPL_RCVD);
908 if (cxgbi_sock_flag(csk, CTPF_ABORT_RPL_PENDING)) { 910 if (cxgbi_sock_flag(csk, CTPF_ABORT_RPL_PENDING)) {
909 if (!cxgbi_sock_flag(csk, CTPF_ABORT_RPL_RCVD)) 911 cxgbi_sock_clear_flag(csk, CTPF_ABORT_RPL_PENDING);
910 cxgbi_sock_set_flag(csk, CTPF_ABORT_RPL_RCVD); 912 if (cxgbi_sock_flag(csk, CTPF_ABORT_REQ_RCVD))
911 else { 913 pr_err("csk 0x%p,%u,0x%lx,%u,ABT_RPL_RSS.\n",
912 cxgbi_sock_clear_flag(csk, CTPF_ABORT_RPL_RCVD); 914 csk, csk->state, csk->flags, csk->tid);
913 cxgbi_sock_clear_flag(csk, CTPF_ABORT_RPL_PENDING); 915 cxgbi_sock_closed(csk);
914 if (cxgbi_sock_flag(csk, CTPF_ABORT_REQ_RCVD))
915 pr_err("csk 0x%p,%u,0x%lx,%u,ABT_RPL_RSS.\n",
916 csk, csk->state, csk->flags, csk->tid);
917 cxgbi_sock_closed(csk);
918 }
919 } 916 }
917
920 spin_unlock_bh(&csk->lock); 918 spin_unlock_bh(&csk->lock);
921 cxgbi_sock_put(csk); 919 cxgbi_sock_put(csk);
922} 920}
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index e99507ed0e3c..fd78bdc53528 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -474,6 +474,13 @@ static int alua_check_sense(struct scsi_device *sdev,
474 * LUN Not Ready -- Offline 474 * LUN Not Ready -- Offline
475 */ 475 */
476 return SUCCESS; 476 return SUCCESS;
477 if (sdev->allow_restart &&
478 sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x02)
479 /*
480 * if the device is not started, we need to wake
481 * the error handler to start the motor
482 */
483 return FAILED;
477 break; 484 break;
478 case UNIT_ATTENTION: 485 case UNIT_ATTENTION:
479 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00) 486 if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index f6a69a3b1b3f..5640ad1c8214 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4453,7 +4453,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
4453 instance->msixentry[i].entry = i; 4453 instance->msixentry[i].entry = i;
4454 i = pci_enable_msix_range(instance->pdev, instance->msixentry, 4454 i = pci_enable_msix_range(instance->pdev, instance->msixentry,
4455 1, instance->msix_vectors); 4455 1, instance->msix_vectors);
4456 if (i) 4456 if (i > 0)
4457 instance->msix_vectors = i; 4457 instance->msix_vectors = i;
4458 else 4458 else
4459 instance->msix_vectors = 0; 4459 instance->msix_vectors = 0;
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 49014a143c6a..c1d04d4d3c6c 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -202,6 +202,7 @@ static struct {
202 {"IOMEGA", "Io20S *F", NULL, BLIST_KEY}, 202 {"IOMEGA", "Io20S *F", NULL, BLIST_KEY},
203 {"INSITE", "Floptical F*8I", NULL, BLIST_KEY}, 203 {"INSITE", "Floptical F*8I", NULL, BLIST_KEY},
204 {"INSITE", "I325VM", NULL, BLIST_KEY}, 204 {"INSITE", "I325VM", NULL, BLIST_KEY},
205 {"Intel", "Multi-Flex", NULL, BLIST_NO_RSOC},
205 {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36}, 206 {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
206 {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN}, 207 {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
207 {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 208 {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 9a6f8468225f..bc5ff6ff9c79 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -459,14 +459,6 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
459 if (! scsi_command_normalize_sense(scmd, &sshdr)) 459 if (! scsi_command_normalize_sense(scmd, &sshdr))
460 return FAILED; /* no valid sense data */ 460 return FAILED; /* no valid sense data */
461 461
462 if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
463 /*
464 * nasty: for mid-layer issued TURs, we need to return the
465 * actual sense data without any recovery attempt. For eh
466 * issued ones, we need to try to recover and interpret
467 */
468 return SUCCESS;
469
470 scsi_report_sense(sdev, &sshdr); 462 scsi_report_sense(sdev, &sshdr);
471 463
472 if (scsi_sense_is_deferred(&sshdr)) 464 if (scsi_sense_is_deferred(&sshdr))
@@ -482,6 +474,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
482 /* handler does not care. Drop down to default handling */ 474 /* handler does not care. Drop down to default handling */
483 } 475 }
484 476
477 if (scmd->cmnd[0] == TEST_UNIT_READY && scmd->scsi_done != scsi_eh_done)
478 /*
479 * nasty: for mid-layer issued TURs, we need to return the
480 * actual sense data without any recovery attempt. For eh
481 * issued ones, we need to try to recover and interpret
482 */
483 return SUCCESS;
484
485 /* 485 /*
486 * Previous logic looked for FILEMARK, EOM or ILI which are 486 * Previous logic looked for FILEMARK, EOM or ILI which are
487 * mainly associated with tapes and returned SUCCESS. 487 * mainly associated with tapes and returned SUCCESS.
@@ -2001,8 +2001,10 @@ static void scsi_restart_operations(struct Scsi_Host *shost)
2001 * is no point trying to lock the door of an off-line device. 2001 * is no point trying to lock the door of an off-line device.
2002 */ 2002 */
2003 shost_for_each_device(sdev, shost) { 2003 shost_for_each_device(sdev, shost) {
2004 if (scsi_device_online(sdev) && sdev->locked) 2004 if (scsi_device_online(sdev) && sdev->was_reset && sdev->locked) {
2005 scsi_eh_lock_door(sdev); 2005 scsi_eh_lock_door(sdev);
2006 sdev->was_reset = 0;
2007 }
2006 } 2008 }
2007 2009
2008 /* 2010 /*
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 8adf067ff019..1c3467b82566 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -102,7 +102,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
102 clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq), 102 clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
103 GFP_KERNEL); 103 GFP_KERNEL);
104 if (!clkfreq) { 104 if (!clkfreq) {
105 dev_err(dev, "%s: no memory\n", "freq-table-hz");
106 ret = -ENOMEM; 105 ret = -ENOMEM;
107 goto out; 106 goto out;
108 } 107 }
@@ -112,19 +111,19 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
112 if (ret && (ret != -EINVAL)) { 111 if (ret && (ret != -EINVAL)) {
113 dev_err(dev, "%s: error reading array %d\n", 112 dev_err(dev, "%s: error reading array %d\n",
114 "freq-table-hz", ret); 113 "freq-table-hz", ret);
115 goto free_clkfreq; 114 return ret;
116 } 115 }
117 116
118 for (i = 0; i < sz; i += 2) { 117 for (i = 0; i < sz; i += 2) {
119 ret = of_property_read_string_index(np, 118 ret = of_property_read_string_index(np,
120 "clock-names", i/2, (const char **)&name); 119 "clock-names", i/2, (const char **)&name);
121 if (ret) 120 if (ret)
122 goto free_clkfreq; 121 goto out;
123 122
124 clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL); 123 clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL);
125 if (!clki) { 124 if (!clki) {
126 ret = -ENOMEM; 125 ret = -ENOMEM;
127 goto free_clkfreq; 126 goto out;
128 } 127 }
129 128
130 clki->min_freq = clkfreq[i]; 129 clki->min_freq = clkfreq[i];
@@ -134,8 +133,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
134 clki->min_freq, clki->max_freq, clki->name); 133 clki->min_freq, clki->max_freq, clki->name);
135 list_add_tail(&clki->list, &hba->clk_list_head); 134 list_add_tail(&clki->list, &hba->clk_list_head);
136 } 135 }
137free_clkfreq:
138 kfree(clkfreq);
139out: 136out:
140 return ret; 137 return ret;
141} 138}
@@ -162,10 +159,8 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
162 } 159 }
163 160
164 vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); 161 vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
165 if (!vreg) { 162 if (!vreg)
166 dev_err(dev, "No memory for %s regulator\n", name); 163 return -ENOMEM;
167 goto out;
168 }
169 164
170 vreg->name = kstrdup(name, GFP_KERNEL); 165 vreg->name = kstrdup(name, GFP_KERNEL);
171 166
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 497c38a4a866..605ca60e8a10 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -744,6 +744,8 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
744 if (!ufshcd_is_clkgating_allowed(hba)) 744 if (!ufshcd_is_clkgating_allowed(hba))
745 return; 745 return;
746 device_remove_file(hba->dev, &hba->clk_gating.delay_attr); 746 device_remove_file(hba->dev, &hba->clk_gating.delay_attr);
747 cancel_work_sync(&hba->clk_gating.ungate_work);
748 cancel_delayed_work_sync(&hba->clk_gating.gate_work);
747} 749}
748 750
749/* Must be called with host lock acquired */ 751/* Must be called with host lock acquired */
@@ -2246,6 +2248,22 @@ static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
2246 return ret; 2248 return ret;
2247} 2249}
2248 2250
2251 /**
2252 * ufshcd_init_pwr_info - setting the POR (power on reset)
2253 * values in hba power info
2254 * @hba: per-adapter instance
2255 */
2256static void ufshcd_init_pwr_info(struct ufs_hba *hba)
2257{
2258 hba->pwr_info.gear_rx = UFS_PWM_G1;
2259 hba->pwr_info.gear_tx = UFS_PWM_G1;
2260 hba->pwr_info.lane_rx = 1;
2261 hba->pwr_info.lane_tx = 1;
2262 hba->pwr_info.pwr_rx = SLOWAUTO_MODE;
2263 hba->pwr_info.pwr_tx = SLOWAUTO_MODE;
2264 hba->pwr_info.hs_rate = 0;
2265}
2266
2249/** 2267/**
2250 * ufshcd_get_max_pwr_mode - reads the max power mode negotiated with device 2268 * ufshcd_get_max_pwr_mode - reads the max power mode negotiated with device
2251 * @hba: per-adapter instance 2269 * @hba: per-adapter instance
@@ -2844,8 +2862,13 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev)
2844 hba = shost_priv(sdev->host); 2862 hba = shost_priv(sdev->host);
2845 scsi_deactivate_tcq(sdev, hba->nutrs); 2863 scsi_deactivate_tcq(sdev, hba->nutrs);
2846 /* Drop the reference as it won't be needed anymore */ 2864 /* Drop the reference as it won't be needed anymore */
2847 if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) 2865 if (ufshcd_scsi_to_upiu_lun(sdev->lun) == UFS_UPIU_UFS_DEVICE_WLUN) {
2866 unsigned long flags;
2867
2868 spin_lock_irqsave(hba->host->host_lock, flags);
2848 hba->sdev_ufs_device = NULL; 2869 hba->sdev_ufs_device = NULL;
2870 spin_unlock_irqrestore(hba->host->host_lock, flags);
2871 }
2849} 2872}
2850 2873
2851/** 2874/**
@@ -4062,6 +4085,8 @@ static void ufshcd_init_icc_levels(struct ufs_hba *hba)
4062static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) 4085static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
4063{ 4086{
4064 int ret = 0; 4087 int ret = 0;
4088 struct scsi_device *sdev_rpmb;
4089 struct scsi_device *sdev_boot;
4065 4090
4066 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0, 4091 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,
4067 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL); 4092 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
@@ -4070,26 +4095,27 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
4070 hba->sdev_ufs_device = NULL; 4095 hba->sdev_ufs_device = NULL;
4071 goto out; 4096 goto out;
4072 } 4097 }
4098 scsi_device_put(hba->sdev_ufs_device);
4073 4099
4074 hba->sdev_boot = __scsi_add_device(hba->host, 0, 0, 4100 sdev_boot = __scsi_add_device(hba->host, 0, 0,
4075 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL); 4101 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL);
4076 if (IS_ERR(hba->sdev_boot)) { 4102 if (IS_ERR(sdev_boot)) {
4077 ret = PTR_ERR(hba->sdev_boot); 4103 ret = PTR_ERR(sdev_boot);
4078 hba->sdev_boot = NULL;
4079 goto remove_sdev_ufs_device; 4104 goto remove_sdev_ufs_device;
4080 } 4105 }
4106 scsi_device_put(sdev_boot);
4081 4107
4082 hba->sdev_rpmb = __scsi_add_device(hba->host, 0, 0, 4108 sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
4083 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL); 4109 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
4084 if (IS_ERR(hba->sdev_rpmb)) { 4110 if (IS_ERR(sdev_rpmb)) {
4085 ret = PTR_ERR(hba->sdev_rpmb); 4111 ret = PTR_ERR(sdev_rpmb);
4086 hba->sdev_rpmb = NULL;
4087 goto remove_sdev_boot; 4112 goto remove_sdev_boot;
4088 } 4113 }
4114 scsi_device_put(sdev_rpmb);
4089 goto out; 4115 goto out;
4090 4116
4091remove_sdev_boot: 4117remove_sdev_boot:
4092 scsi_remove_device(hba->sdev_boot); 4118 scsi_remove_device(sdev_boot);
4093remove_sdev_ufs_device: 4119remove_sdev_ufs_device:
4094 scsi_remove_device(hba->sdev_ufs_device); 4120 scsi_remove_device(hba->sdev_ufs_device);
4095out: 4121out:
@@ -4097,30 +4123,6 @@ out:
4097} 4123}
4098 4124
4099/** 4125/**
4100 * ufshcd_scsi_remove_wlus - Removes the W-LUs which were added by
4101 * ufshcd_scsi_add_wlus()
4102 * @hba: per-adapter instance
4103 *
4104 */
4105static void ufshcd_scsi_remove_wlus(struct ufs_hba *hba)
4106{
4107 if (hba->sdev_ufs_device) {
4108 scsi_remove_device(hba->sdev_ufs_device);
4109 hba->sdev_ufs_device = NULL;
4110 }
4111
4112 if (hba->sdev_boot) {
4113 scsi_remove_device(hba->sdev_boot);
4114 hba->sdev_boot = NULL;
4115 }
4116
4117 if (hba->sdev_rpmb) {
4118 scsi_remove_device(hba->sdev_rpmb);
4119 hba->sdev_rpmb = NULL;
4120 }
4121}
4122
4123/**
4124 * ufshcd_probe_hba - probe hba to detect device and initialize 4126 * ufshcd_probe_hba - probe hba to detect device and initialize
4125 * @hba: per-adapter instance 4127 * @hba: per-adapter instance
4126 * 4128 *
@@ -4134,6 +4136,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
4134 if (ret) 4136 if (ret)
4135 goto out; 4137 goto out;
4136 4138
4139 ufshcd_init_pwr_info(hba);
4140
4137 /* UniPro link is active now */ 4141 /* UniPro link is active now */
4138 ufshcd_set_link_active(hba); 4142 ufshcd_set_link_active(hba);
4139 4143
@@ -4264,12 +4268,18 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
4264static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, 4268static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
4265 struct ufs_vreg *vreg) 4269 struct ufs_vreg *vreg)
4266{ 4270{
4271 if (!vreg)
4272 return 0;
4273
4267 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA); 4274 return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
4268} 4275}
4269 4276
4270static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, 4277static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
4271 struct ufs_vreg *vreg) 4278 struct ufs_vreg *vreg)
4272{ 4279{
4280 if (!vreg)
4281 return 0;
4282
4273 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA); 4283 return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
4274} 4284}
4275 4285
@@ -4471,7 +4481,7 @@ out:
4471 if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled) 4481 if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
4472 clk_disable_unprepare(clki->clk); 4482 clk_disable_unprepare(clki->clk);
4473 } 4483 }
4474 } else if (!ret && on) { 4484 } else if (on) {
4475 spin_lock_irqsave(hba->host->host_lock, flags); 4485 spin_lock_irqsave(hba->host->host_lock, flags);
4476 hba->clk_gating.state = CLKS_ON; 4486 hba->clk_gating.state = CLKS_ON;
4477 spin_unlock_irqrestore(hba->host->host_lock, flags); 4487 spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -4675,11 +4685,25 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
4675{ 4685{
4676 unsigned char cmd[6] = { START_STOP }; 4686 unsigned char cmd[6] = { START_STOP };
4677 struct scsi_sense_hdr sshdr; 4687 struct scsi_sense_hdr sshdr;
4678 struct scsi_device *sdp = hba->sdev_ufs_device; 4688 struct scsi_device *sdp;
4689 unsigned long flags;
4679 int ret; 4690 int ret;
4680 4691
4681 if (!sdp || !scsi_device_online(sdp)) 4692 spin_lock_irqsave(hba->host->host_lock, flags);
4682 return -ENODEV; 4693 sdp = hba->sdev_ufs_device;
4694 if (sdp) {
4695 ret = scsi_device_get(sdp);
4696 if (!ret && !scsi_device_online(sdp)) {
4697 ret = -ENODEV;
4698 scsi_device_put(sdp);
4699 }
4700 } else {
4701 ret = -ENODEV;
4702 }
4703 spin_unlock_irqrestore(hba->host->host_lock, flags);
4704
4705 if (ret)
4706 return ret;
4683 4707
4684 /* 4708 /*
4685 * If scsi commands fail, the scsi mid-layer schedules scsi error- 4709 * If scsi commands fail, the scsi mid-layer schedules scsi error-
@@ -4718,6 +4742,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
4718 if (!ret) 4742 if (!ret)
4719 hba->curr_dev_pwr_mode = pwr_mode; 4743 hba->curr_dev_pwr_mode = pwr_mode;
4720out: 4744out:
4745 scsi_device_put(sdp);
4721 hba->host->eh_noresume = 0; 4746 hba->host->eh_noresume = 0;
4722 return ret; 4747 return ret;
4723} 4748}
@@ -5087,7 +5112,7 @@ int ufshcd_system_suspend(struct ufs_hba *hba)
5087 int ret = 0; 5112 int ret = 0;
5088 5113
5089 if (!hba || !hba->is_powered) 5114 if (!hba || !hba->is_powered)
5090 goto out; 5115 return 0;
5091 5116
5092 if (pm_runtime_suspended(hba->dev)) { 5117 if (pm_runtime_suspended(hba->dev)) {
5093 if (hba->rpm_lvl == hba->spm_lvl) 5118 if (hba->rpm_lvl == hba->spm_lvl)
@@ -5231,7 +5256,6 @@ EXPORT_SYMBOL(ufshcd_shutdown);
5231void ufshcd_remove(struct ufs_hba *hba) 5256void ufshcd_remove(struct ufs_hba *hba)
5232{ 5257{
5233 scsi_remove_host(hba->host); 5258 scsi_remove_host(hba->host);
5234 ufshcd_scsi_remove_wlus(hba);
5235 /* disable interrupts */ 5259 /* disable interrupts */
5236 ufshcd_disable_intr(hba, hba->intr_mask); 5260 ufshcd_disable_intr(hba, hba->intr_mask);
5237 ufshcd_hba_stop(hba); 5261 ufshcd_hba_stop(hba);
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 58ecdff5065c..4a574aa45855 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -392,8 +392,6 @@ struct ufs_hba {
392 * "UFS device" W-LU. 392 * "UFS device" W-LU.
393 */ 393 */
394 struct scsi_device *sdev_ufs_device; 394 struct scsi_device *sdev_ufs_device;
395 struct scsi_device *sdev_rpmb;
396 struct scsi_device *sdev_boot;
397 395
398 enum ufs_dev_pwr_mode curr_dev_pwr_mode; 396 enum ufs_dev_pwr_mode curr_dev_pwr_mode;
399 enum uic_link_state uic_link_state; 397 enum uic_link_state uic_link_state;
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 72e12bad14b9..d0d5542efc06 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -376,9 +376,6 @@ static void pump_transfers(unsigned long data)
376 chip = dws->cur_chip; 376 chip = dws->cur_chip;
377 spi = message->spi; 377 spi = message->spi;
378 378
379 if (unlikely(!chip->clk_div))
380 chip->clk_div = dws->max_freq / chip->speed_hz;
381
382 if (message->state == ERROR_STATE) { 379 if (message->state == ERROR_STATE) {
383 message->status = -EIO; 380 message->status = -EIO;
384 goto early_exit; 381 goto early_exit;
@@ -419,7 +416,7 @@ static void pump_transfers(unsigned long data)
419 if (transfer->speed_hz) { 416 if (transfer->speed_hz) {
420 speed = chip->speed_hz; 417 speed = chip->speed_hz;
421 418
422 if (transfer->speed_hz != speed) { 419 if ((transfer->speed_hz != speed) || (!chip->clk_div)) {
423 speed = transfer->speed_hz; 420 speed = transfer->speed_hz;
424 421
425 /* clk_div doesn't support odd number */ 422 /* clk_div doesn't support odd number */
@@ -581,7 +578,6 @@ static int dw_spi_setup(struct spi_device *spi)
581 dev_err(&spi->dev, "No max speed HZ parameter\n"); 578 dev_err(&spi->dev, "No max speed HZ parameter\n");
582 return -EINVAL; 579 return -EINVAL;
583 } 580 }
584 chip->speed_hz = spi->max_speed_hz;
585 581
586 chip->tmode = 0; /* Tx & Rx */ 582 chip->tmode = 0; /* Tx & Rx */
587 /* Default SPI mode is SCPOL = 0, SCPH = 0 */ 583 /* Default SPI mode is SCPOL = 0, SCPH = 0 */
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 39e2c0a55a28..f63de781c729 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -562,9 +562,9 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
562 562
563 sspi->word_width = DIV_ROUND_UP(bits_per_word, 8); 563 sspi->word_width = DIV_ROUND_UP(bits_per_word, 8);
564 txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | 564 txfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) |
565 sspi->word_width; 565 (sspi->word_width >> 1);
566 rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) | 566 rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) |
567 sspi->word_width; 567 (sspi->word_width >> 1);
568 568
569 if (!(spi->mode & SPI_CS_HIGH)) 569 if (!(spi->mode & SPI_CS_HIGH))
570 regval |= SIRFSOC_SPI_CS_IDLE_STAT; 570 regval |= SIRFSOC_SPI_CS_IDLE_STAT;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ebcb33df2eb2..50f20f243981 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -615,13 +615,13 @@ static int spi_map_buf(struct spi_master *master, struct device *dev,
615 sg_free_table(sgt); 615 sg_free_table(sgt);
616 return -ENOMEM; 616 return -ENOMEM;
617 } 617 }
618 sg_buf = page_address(vm_page) + 618 sg_set_page(&sgt->sgl[i], vm_page,
619 ((size_t)buf & ~PAGE_MASK); 619 min, offset_in_page(buf));
620 } else { 620 } else {
621 sg_buf = buf; 621 sg_buf = buf;
622 sg_set_buf(&sgt->sgl[i], sg_buf, min);
622 } 623 }
623 624
624 sg_set_buf(&sgt->sgl[i], sg_buf, min);
625 625
626 buf += min; 626 buf += min;
627 len -= min; 627 len -= min;
diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c
index 9935e66935af..eddef9cd2e16 100644
--- a/drivers/staging/rtl8188eu/core/rtw_cmd.c
+++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c
@@ -275,11 +275,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
275 if (check_fwstate(pmlmepriv, _FW_LINKED) == true) 275 if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
276 rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); 276 rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
277 277
278 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 278 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
279 if (ph2c == NULL) 279 if (ph2c == NULL)
280 return _FAIL; 280 return _FAIL;
281 281
282 psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_KERNEL); 282 psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
283 if (psurveyPara == NULL) { 283 if (psurveyPara == NULL) {
284 kfree(ph2c); 284 kfree(ph2c);
285 return _FAIL; 285 return _FAIL;
@@ -405,7 +405,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
405 else 405 else
406 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); 406 RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid));
407 407
408 pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 408 pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
409 if (pcmd == NULL) { 409 if (pcmd == NULL) {
410 res = _FAIL; 410 res = _FAIL;
411 RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); 411 RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n"));
@@ -755,13 +755,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
755 u8 res = _SUCCESS; 755 u8 res = _SUCCESS;
756 756
757 757
758 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 758 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
759 if (ph2c == NULL) { 759 if (ph2c == NULL) {
760 res = _FAIL; 760 res = _FAIL;
761 goto exit; 761 goto exit;
762 } 762 }
763 763
764 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); 764 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
765 if (pdrvextra_cmd_parm == NULL) { 765 if (pdrvextra_cmd_parm == NULL) {
766 kfree(ph2c); 766 kfree(ph2c);
767 res = _FAIL; 767 res = _FAIL;
@@ -967,13 +967,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
967 u8 res = _SUCCESS; 967 u8 res = _SUCCESS;
968 968
969 if (enqueue) { 969 if (enqueue) {
970 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 970 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
971 if (ph2c == NULL) { 971 if (ph2c == NULL) {
972 res = _FAIL; 972 res = _FAIL;
973 goto exit; 973 goto exit;
974 } 974 }
975 975
976 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); 976 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
977 if (pdrvextra_cmd_parm == NULL) { 977 if (pdrvextra_cmd_parm == NULL) {
978 kfree(ph2c); 978 kfree(ph2c);
979 res = _FAIL; 979 res = _FAIL;
@@ -1010,13 +1010,13 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
1010 1010
1011 u8 res = _SUCCESS; 1011 u8 res = _SUCCESS;
1012 1012
1013 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 1013 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
1014 if (ph2c == NULL) { 1014 if (ph2c == NULL) {
1015 res = _FAIL; 1015 res = _FAIL;
1016 goto exit; 1016 goto exit;
1017 } 1017 }
1018 1018
1019 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); 1019 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
1020 if (pdrvextra_cmd_parm == NULL) { 1020 if (pdrvextra_cmd_parm == NULL) {
1021 kfree(ph2c); 1021 kfree(ph2c);
1022 res = _FAIL; 1022 res = _FAIL;
@@ -1088,13 +1088,13 @@ u8 rtw_ps_cmd(struct adapter *padapter)
1088 1088
1089 u8 res = _SUCCESS; 1089 u8 res = _SUCCESS;
1090 1090
1091 ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 1091 ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
1092 if (ppscmd == NULL) { 1092 if (ppscmd == NULL) {
1093 res = _FAIL; 1093 res = _FAIL;
1094 goto exit; 1094 goto exit;
1095 } 1095 }
1096 1096
1097 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); 1097 pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
1098 if (pdrvextra_cmd_parm == NULL) { 1098 if (pdrvextra_cmd_parm == NULL) {
1099 kfree(ppscmd); 1099 kfree(ppscmd);
1100 res = _FAIL; 1100 res = _FAIL;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 5ba5099ec20d..70b1bc3e0e63 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -4241,12 +4241,12 @@ void report_survey_event(struct adapter *padapter,
4241 pcmdpriv = &padapter->cmdpriv; 4241 pcmdpriv = &padapter->cmdpriv;
4242 4242
4243 4243
4244 pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 4244 pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
4245 if (pcmd_obj == NULL) 4245 if (pcmd_obj == NULL)
4246 return; 4246 return;
4247 4247
4248 cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); 4248 cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header));
4249 pevtcmd = kzalloc(cmdsz, GFP_KERNEL); 4249 pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
4250 if (pevtcmd == NULL) { 4250 if (pevtcmd == NULL) {
4251 kfree(pcmd_obj); 4251 kfree(pcmd_obj);
4252 return; 4252 return;
@@ -4339,12 +4339,12 @@ void report_join_res(struct adapter *padapter, int res)
4339 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); 4339 struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
4340 struct cmd_priv *pcmdpriv = &padapter->cmdpriv; 4340 struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
4341 4341
4342 pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 4342 pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
4343 if (pcmd_obj == NULL) 4343 if (pcmd_obj == NULL)
4344 return; 4344 return;
4345 4345
4346 cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); 4346 cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header));
4347 pevtcmd = kzalloc(cmdsz, GFP_KERNEL); 4347 pevtcmd = kzalloc(cmdsz, GFP_ATOMIC);
4348 if (pevtcmd == NULL) { 4348 if (pevtcmd == NULL) {
4349 kfree(pcmd_obj); 4349 kfree(pcmd_obj);
4350 return; 4350 return;
@@ -4854,11 +4854,11 @@ void survey_timer_hdl(void *function_context)
4854 pmlmeext->scan_abort = false;/* reset */ 4854 pmlmeext->scan_abort = false;/* reset */
4855 } 4855 }
4856 4856
4857 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); 4857 ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
4858 if (ph2c == NULL) 4858 if (ph2c == NULL)
4859 goto exit_survey_timer_hdl; 4859 goto exit_survey_timer_hdl;
4860 4860
4861 psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_KERNEL); 4861 psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
4862 if (psurveyPara == NULL) { 4862 if (psurveyPara == NULL) {
4863 kfree(ph2c); 4863 kfree(ph2c);
4864 goto exit_survey_timer_hdl; 4864 goto exit_survey_timer_hdl;
diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
index 33ccbbbd8ed6..d300369977fa 100644
--- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
@@ -935,7 +935,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
935 return true; 935 return true;
936 } 936 }
937 937
938 bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL); 938 bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC);
939 939
940 subtype = GetFrameSubType(pframe) >> 4; 940 subtype = GetFrameSubType(pframe) >> 4;
941 941
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 407a318b09db..2f87150a21b7 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -47,6 +47,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
47 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ 47 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
48 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ 48 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
49 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ 49 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
50 {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
50 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ 51 {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
51 {} /* Terminating entry */ 52 {} /* Terminating entry */
52}; 53};
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index b19e4329ba00..73e58d22e325 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -3491,7 +3491,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3491 len = sprintf(buf, "TargetAddress=" 3491 len = sprintf(buf, "TargetAddress="
3492 "%s:%hu,%hu", 3492 "%s:%hu,%hu",
3493 inaddr_any ? conn->local_ip : np->np_ip, 3493 inaddr_any ? conn->local_ip : np->np_ip,
3494 inaddr_any ? conn->local_port : np->np_port, 3494 np->np_port,
3495 tpg->tpgt); 3495 tpg->tpgt);
3496 len += 1; 3496 len += 1;
3497 3497
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 8c60a1a1ae8d..9f93b8234095 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -2738,7 +2738,8 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2738 struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; 2738 struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder;
2739 struct t10_reservation *pr_tmpl = &dev->t10_pr; 2739 struct t10_reservation *pr_tmpl = &dev->t10_pr;
2740 u32 pr_res_mapped_lun = 0; 2740 u32 pr_res_mapped_lun = 0;
2741 int all_reg = 0, calling_it_nexus = 0, released_regs = 0; 2741 int all_reg = 0, calling_it_nexus = 0;
2742 bool sa_res_key_unmatched = sa_res_key != 0;
2742 int prh_type = 0, prh_scope = 0; 2743 int prh_type = 0, prh_scope = 0;
2743 2744
2744 if (!se_sess) 2745 if (!se_sess)
@@ -2813,6 +2814,7 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2813 if (!all_reg) { 2814 if (!all_reg) {
2814 if (pr_reg->pr_res_key != sa_res_key) 2815 if (pr_reg->pr_res_key != sa_res_key)
2815 continue; 2816 continue;
2817 sa_res_key_unmatched = false;
2816 2818
2817 calling_it_nexus = (pr_reg_n == pr_reg) ? 1 : 0; 2819 calling_it_nexus = (pr_reg_n == pr_reg) ? 1 : 0;
2818 pr_reg_nacl = pr_reg->pr_reg_nacl; 2820 pr_reg_nacl = pr_reg->pr_reg_nacl;
@@ -2820,7 +2822,6 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2820 __core_scsi3_free_registration(dev, pr_reg, 2822 __core_scsi3_free_registration(dev, pr_reg,
2821 (preempt_type == PREEMPT_AND_ABORT) ? &preempt_and_abort_list : 2823 (preempt_type == PREEMPT_AND_ABORT) ? &preempt_and_abort_list :
2822 NULL, calling_it_nexus); 2824 NULL, calling_it_nexus);
2823 released_regs++;
2824 } else { 2825 } else {
2825 /* 2826 /*
2826 * Case for any existing all registrants type 2827 * Case for any existing all registrants type
@@ -2838,6 +2839,7 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2838 if ((sa_res_key) && 2839 if ((sa_res_key) &&
2839 (pr_reg->pr_res_key != sa_res_key)) 2840 (pr_reg->pr_res_key != sa_res_key))
2840 continue; 2841 continue;
2842 sa_res_key_unmatched = false;
2841 2843
2842 calling_it_nexus = (pr_reg_n == pr_reg) ? 1 : 0; 2844 calling_it_nexus = (pr_reg_n == pr_reg) ? 1 : 0;
2843 if (calling_it_nexus) 2845 if (calling_it_nexus)
@@ -2848,7 +2850,6 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2848 __core_scsi3_free_registration(dev, pr_reg, 2850 __core_scsi3_free_registration(dev, pr_reg,
2849 (preempt_type == PREEMPT_AND_ABORT) ? &preempt_and_abort_list : 2851 (preempt_type == PREEMPT_AND_ABORT) ? &preempt_and_abort_list :
2850 NULL, 0); 2852 NULL, 0);
2851 released_regs++;
2852 } 2853 }
2853 if (!calling_it_nexus) 2854 if (!calling_it_nexus)
2854 core_scsi3_ua_allocate(pr_reg_nacl, 2855 core_scsi3_ua_allocate(pr_reg_nacl,
@@ -2863,7 +2864,7 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key,
2863 * registered reservation key, then the device server shall 2864 * registered reservation key, then the device server shall
2864 * complete the command with RESERVATION CONFLICT status. 2865 * complete the command with RESERVATION CONFLICT status.
2865 */ 2866 */
2866 if (!released_regs) { 2867 if (sa_res_key_unmatched) {
2867 spin_unlock(&dev->dev_reservation_lock); 2868 spin_unlock(&dev->dev_reservation_lock);
2868 core_scsi3_put_pr_reg(pr_reg_n); 2869 core_scsi3_put_pr_reg(pr_reg_n);
2869 return TCM_RESERVATION_CONFLICT; 2870 return TCM_RESERVATION_CONFLICT;
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 9ea0d5f03f7a..be877bf6f730 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2292,7 +2292,7 @@ transport_generic_new_cmd(struct se_cmd *cmd)
2292 * and let it call back once the write buffers are ready. 2292 * and let it call back once the write buffers are ready.
2293 */ 2293 */
2294 target_add_to_state_list(cmd); 2294 target_add_to_state_list(cmd);
2295 if (cmd->data_direction != DMA_TO_DEVICE) { 2295 if (cmd->data_direction != DMA_TO_DEVICE || cmd->data_length == 0) {
2296 target_execute_cmd(cmd); 2296 target_execute_cmd(cmd);
2297 return 0; 2297 return 0;
2298 } 2298 }
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 1ab0018271c5..ad09e51ffae4 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -50,15 +50,14 @@ struct cpufreq_cooling_device {
50 unsigned int cpufreq_state; 50 unsigned int cpufreq_state;
51 unsigned int cpufreq_val; 51 unsigned int cpufreq_val;
52 struct cpumask allowed_cpus; 52 struct cpumask allowed_cpus;
53 struct list_head node;
53}; 54};
54static DEFINE_IDR(cpufreq_idr); 55static DEFINE_IDR(cpufreq_idr);
55static DEFINE_MUTEX(cooling_cpufreq_lock); 56static DEFINE_MUTEX(cooling_cpufreq_lock);
56 57
57static unsigned int cpufreq_dev_count; 58static unsigned int cpufreq_dev_count;
58 59
59/* notify_table passes value to the CPUFREQ_ADJUST callback function. */ 60static LIST_HEAD(cpufreq_dev_list);
60#define NOTIFY_INVALID NULL
61static struct cpufreq_cooling_device *notify_device;
62 61
63/** 62/**
64 * get_idr - function to get a unique id. 63 * get_idr - function to get a unique id.
@@ -287,15 +286,12 @@ static int cpufreq_apply_cooling(struct cpufreq_cooling_device *cpufreq_device,
287 286
288 cpufreq_device->cpufreq_state = cooling_state; 287 cpufreq_device->cpufreq_state = cooling_state;
289 cpufreq_device->cpufreq_val = clip_freq; 288 cpufreq_device->cpufreq_val = clip_freq;
290 notify_device = cpufreq_device;
291 289
292 for_each_cpu(cpuid, mask) { 290 for_each_cpu(cpuid, mask) {
293 if (is_cpufreq_valid(cpuid)) 291 if (is_cpufreq_valid(cpuid))
294 cpufreq_update_policy(cpuid); 292 cpufreq_update_policy(cpuid);
295 } 293 }
296 294
297 notify_device = NOTIFY_INVALID;
298
299 return 0; 295 return 0;
300} 296}
301 297
@@ -316,21 +312,28 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,
316{ 312{
317 struct cpufreq_policy *policy = data; 313 struct cpufreq_policy *policy = data;
318 unsigned long max_freq = 0; 314 unsigned long max_freq = 0;
315 struct cpufreq_cooling_device *cpufreq_dev;
319 316
320 if (event != CPUFREQ_ADJUST || notify_device == NOTIFY_INVALID) 317 if (event != CPUFREQ_ADJUST)
321 return 0; 318 return 0;
322 319
323 if (cpumask_test_cpu(policy->cpu, &notify_device->allowed_cpus)) 320 mutex_lock(&cooling_cpufreq_lock);
324 max_freq = notify_device->cpufreq_val; 321 list_for_each_entry(cpufreq_dev, &cpufreq_dev_list, node) {
325 else 322 if (!cpumask_test_cpu(policy->cpu,
326 return 0; 323 &cpufreq_dev->allowed_cpus))
324 continue;
325
326 if (!cpufreq_dev->cpufreq_val)
327 cpufreq_dev->cpufreq_val = get_cpu_frequency(
328 cpumask_any(&cpufreq_dev->allowed_cpus),
329 cpufreq_dev->cpufreq_state);
327 330
328 /* Never exceed user_policy.max */ 331 max_freq = cpufreq_dev->cpufreq_val;
329 if (max_freq > policy->user_policy.max)
330 max_freq = policy->user_policy.max;
331 332
332 if (policy->max != max_freq) 333 if (policy->max != max_freq)
333 cpufreq_verify_within_limits(policy, 0, max_freq); 334 cpufreq_verify_within_limits(policy, 0, max_freq);
335 }
336 mutex_unlock(&cooling_cpufreq_lock);
334 337
335 return 0; 338 return 0;
336} 339}
@@ -486,6 +489,7 @@ __cpufreq_cooling_register(struct device_node *np,
486 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 489 cpufreq_register_notifier(&thermal_cpufreq_notifier_block,
487 CPUFREQ_POLICY_NOTIFIER); 490 CPUFREQ_POLICY_NOTIFIER);
488 cpufreq_dev_count++; 491 cpufreq_dev_count++;
492 list_add(&cpufreq_dev->node, &cpufreq_dev_list);
489 493
490 mutex_unlock(&cooling_cpufreq_lock); 494 mutex_unlock(&cooling_cpufreq_lock);
491 495
@@ -549,6 +553,7 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
549 553
550 cpufreq_dev = cdev->devdata; 554 cpufreq_dev = cdev->devdata;
551 mutex_lock(&cooling_cpufreq_lock); 555 mutex_lock(&cooling_cpufreq_lock);
556 list_del(&cpufreq_dev->node);
552 cpufreq_dev_count--; 557 cpufreq_dev_count--;
553 558
554 /* Unregister the notifier for the last cpufreq cooling device */ 559 /* Unregister the notifier for the last cpufreq cooling device */
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 461bf3d033a0..5a1f1070b702 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -459,6 +459,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
459 int measure_freq; 459 int measure_freq;
460 int ret; 460 int ret;
461 461
462 if (!cpufreq_get_current_driver()) {
463 dev_dbg(&pdev->dev, "no cpufreq driver!");
464 return -EPROBE_DEFER;
465 }
462 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 466 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
463 if (!data) 467 if (!data)
464 return -ENOMEM; 468 return -ENOMEM;
@@ -521,6 +525,30 @@ static int imx_thermal_probe(struct platform_device *pdev)
521 return ret; 525 return ret;
522 } 526 }
523 527
528 data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
529 if (IS_ERR(data->thermal_clk)) {
530 ret = PTR_ERR(data->thermal_clk);
531 if (ret != -EPROBE_DEFER)
532 dev_err(&pdev->dev,
533 "failed to get thermal clk: %d\n", ret);
534 cpufreq_cooling_unregister(data->cdev);
535 return ret;
536 }
537
538 /*
539 * Thermal sensor needs clk on to get correct value, normally
540 * we should enable its clk before taking measurement and disable
541 * clk after measurement is done, but if alarm function is enabled,
542 * hardware will auto measure the temperature periodically, so we
543 * need to keep the clk always on for alarm function.
544 */
545 ret = clk_prepare_enable(data->thermal_clk);
546 if (ret) {
547 dev_err(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
548 cpufreq_cooling_unregister(data->cdev);
549 return ret;
550 }
551
524 data->tz = thermal_zone_device_register("imx_thermal_zone", 552 data->tz = thermal_zone_device_register("imx_thermal_zone",
525 IMX_TRIP_NUM, 553 IMX_TRIP_NUM,
526 BIT(IMX_TRIP_PASSIVE), data, 554 BIT(IMX_TRIP_PASSIVE), data,
@@ -531,26 +559,11 @@ static int imx_thermal_probe(struct platform_device *pdev)
531 ret = PTR_ERR(data->tz); 559 ret = PTR_ERR(data->tz);
532 dev_err(&pdev->dev, 560 dev_err(&pdev->dev,
533 "failed to register thermal zone device %d\n", ret); 561 "failed to register thermal zone device %d\n", ret);
562 clk_disable_unprepare(data->thermal_clk);
534 cpufreq_cooling_unregister(data->cdev); 563 cpufreq_cooling_unregister(data->cdev);
535 return ret; 564 return ret;
536 } 565 }
537 566
538 data->thermal_clk = devm_clk_get(&pdev->dev, NULL);
539 if (IS_ERR(data->thermal_clk)) {
540 dev_warn(&pdev->dev, "failed to get thermal clk!\n");
541 } else {
542 /*
543 * Thermal sensor needs clk on to get correct value, normally
544 * we should enable its clk before taking measurement and disable
545 * clk after measurement is done, but if alarm function is enabled,
546 * hardware will auto measure the temperature periodically, so we
547 * need to keep the clk always on for alarm function.
548 */
549 ret = clk_prepare_enable(data->thermal_clk);
550 if (ret)
551 dev_warn(&pdev->dev, "failed to enable thermal clk: %d\n", ret);
552 }
553
554 /* Enable measurements at ~ 10 Hz */ 567 /* Enable measurements at ~ 10 Hz */
555 regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ); 568 regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
556 measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */ 569 measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
diff --git a/drivers/thermal/int340x_thermal/int3403_thermal.c b/drivers/thermal/int340x_thermal/int3403_thermal.c
index d20dba986f0f..6e9fb62eb817 100644
--- a/drivers/thermal/int340x_thermal/int3403_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3403_thermal.c
@@ -92,7 +92,13 @@ static int sys_get_trip_hyst(struct thermal_zone_device *tzone,
92 if (ACPI_FAILURE(status)) 92 if (ACPI_FAILURE(status))
93 return -EIO; 93 return -EIO;
94 94
95 *temp = DECI_KELVIN_TO_MILLI_CELSIUS(hyst, KELVIN_OFFSET); 95 /*
96 * Thermal hysteresis represents a temperature difference.
97 * Kelvin and Celsius have same degree size. So the
98 * conversion here between tenths of degree Kelvin unit
99 * and Milli-Celsius unit is just to multiply 100.
100 */
101 *temp = hyst * 100;
96 102
97 return 0; 103 return 0;
98} 104}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 3f5ad25ddca8..b6be572704a4 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -417,13 +417,10 @@ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf)
417 417
418 th_zone = sensor_conf->pzone_data; 418 th_zone = sensor_conf->pzone_data;
419 419
420 if (th_zone->therm_dev) 420 thermal_zone_device_unregister(th_zone->therm_dev);
421 thermal_zone_device_unregister(th_zone->therm_dev);
422 421
423 for (i = 0; i < th_zone->cool_dev_size; i++) { 422 for (i = 0; i < th_zone->cool_dev_size; ++i)
424 if (th_zone->cool_dev[i]) 423 cpufreq_cooling_unregister(th_zone->cool_dev[i]);
425 cpufreq_cooling_unregister(th_zone->cool_dev[i]);
426 }
427 424
428 dev_info(sensor_conf->dev, 425 dev_info(sensor_conf->dev,
429 "Exynos: Kernel Thermal management unregistered\n"); 426 "Exynos: Kernel Thermal management unregistered\n");
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 2683d2897e90..1724f6cdaef8 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -264,7 +264,6 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
264static const struct exynos_tmu_registers exynos5260_tmu_registers = { 264static const struct exynos_tmu_registers exynos5260_tmu_registers = {
265 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 265 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
266 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 266 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
267 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL1,
268 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 267 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
269 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 268 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
270 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 269 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h
index 65e2ea6a9579..63de598c9c2c 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -75,7 +75,6 @@
75#define EXYNOS_MAX_TRIGGER_PER_REG 4 75#define EXYNOS_MAX_TRIGGER_PER_REG 4
76 76
77/* Exynos5260 specific */ 77/* Exynos5260 specific */
78#define EXYNOS_TMU_REG_CONTROL1 0x24
79#define EXYNOS5260_TMU_REG_INTEN 0xC0 78#define EXYNOS5260_TMU_REG_INTEN 0xC0
80#define EXYNOS5260_TMU_REG_INTSTAT 0xC4 79#define EXYNOS5260_TMU_REG_INTSTAT 0xC4
81#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8 80#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8
diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
index 90163b384660..d1ec5804c0bb 100644
--- a/drivers/thermal/st/st_thermal.c
+++ b/drivers/thermal/st/st_thermal.c
@@ -275,6 +275,7 @@ int st_thermal_unregister(struct platform_device *pdev)
275} 275}
276EXPORT_SYMBOL_GPL(st_thermal_unregister); 276EXPORT_SYMBOL_GPL(st_thermal_unregister);
277 277
278#ifdef CONFIG_PM_SLEEP
278static int st_thermal_suspend(struct device *dev) 279static int st_thermal_suspend(struct device *dev)
279{ 280{
280 struct platform_device *pdev = to_platform_device(dev); 281 struct platform_device *pdev = to_platform_device(dev);
@@ -305,6 +306,8 @@ static int st_thermal_resume(struct device *dev)
305 306
306 return 0; 307 return 0;
307} 308}
309#endif
310
308SIMPLE_DEV_PM_OPS(st_thermal_pm_ops, st_thermal_suspend, st_thermal_resume); 311SIMPLE_DEV_PM_OPS(st_thermal_pm_ops, st_thermal_suspend, st_thermal_resume);
309EXPORT_SYMBOL_GPL(st_thermal_pm_ops); 312EXPORT_SYMBOL_GPL(st_thermal_pm_ops);
310 313
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 56982da4a9e9..bf355050eab6 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -240,32 +240,6 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
240 return 0; 240 return 0;
241} 241}
242 242
243#ifdef CONFIG_PM_SLEEP
244static int of_serial_suspend(struct device *dev)
245{
246 struct of_serial_info *info = dev_get_drvdata(dev);
247
248 serial8250_suspend_port(info->line);
249 if (info->clk)
250 clk_disable_unprepare(info->clk);
251
252 return 0;
253}
254
255static int of_serial_resume(struct device *dev)
256{
257 struct of_serial_info *info = dev_get_drvdata(dev);
258
259 if (info->clk)
260 clk_prepare_enable(info->clk);
261
262 serial8250_resume_port(info->line);
263
264 return 0;
265}
266#endif
267static SIMPLE_DEV_PM_OPS(of_serial_pm_ops, of_serial_suspend, of_serial_resume);
268
269/* 243/*
270 * A few common types, add more as needed. 244 * A few common types, add more as needed.
271 */ 245 */
@@ -297,7 +271,6 @@ static struct platform_driver of_platform_serial_driver = {
297 .name = "of_serial", 271 .name = "of_serial",
298 .owner = THIS_MODULE, 272 .owner = THIS_MODULE,
299 .of_match_table = of_platform_serial_table, 273 .of_match_table = of_platform_serial_table,
300 .pm = &of_serial_pm_ops,
301 }, 274 },
302 .probe = of_platform_serial_probe, 275 .probe = of_platform_serial_probe,
303 .remove = of_platform_serial_remove, 276 .remove = of_platform_serial_remove,
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 39b4081b632d..96fafed92b76 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -44,6 +44,9 @@ static const struct usb_device_id usb_quirk_list[] = {
44 /* Creative SB Audigy 2 NX */ 44 /* Creative SB Audigy 2 NX */
45 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, 45 { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME },
46 46
47 /* Microsoft Wireless Laser Mouse 6000 Receiver */
48 { USB_DEVICE(0x045e, 0x00e1), .driver_info = USB_QUIRK_RESET_RESUME },
49
47 /* Microsoft LifeCam-VX700 v2.0 */ 50 /* Microsoft LifeCam-VX700 v2.0 */
48 { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, 51 { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
49 52
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 711b23019d54..df38e7ef4976 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -791,6 +791,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
791 791
792 trb = dwc->ep0_trb; 792 trb = dwc->ep0_trb;
793 793
794 r = next_request(&ep0->request_list);
795 if (!r)
796 return;
797
794 status = DWC3_TRB_SIZE_TRBSTS(trb->size); 798 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
795 if (status == DWC3_TRBSTS_SETUP_PENDING) { 799 if (status == DWC3_TRBSTS_SETUP_PENDING) {
796 dwc3_trace(trace_dwc3_ep0, "Setup Pending received"); 800 dwc3_trace(trace_dwc3_ep0, "Setup Pending received");
@@ -801,10 +805,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
801 return; 805 return;
802 } 806 }
803 807
804 r = next_request(&ep0->request_list);
805 if (!r)
806 return;
807
808 ur = &r->request; 808 ur = &r->request;
809 809
810 length = trb->size & DWC3_TRB_SIZE_MASK; 810 length = trb->size & DWC3_TRB_SIZE_MASK;
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 696160d48ae8..388cfd83b6b6 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -22,7 +22,6 @@
22 22
23 23
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/device.h>
26#include <asm/unaligned.h> 25#include <asm/unaligned.h>
27 26
28#include "xhci.h" 27#include "xhci.h"
@@ -1149,9 +1148,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
1149 * including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME 1148 * including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME
1150 * is enabled, so also enable remote wake here. 1149 * is enabled, so also enable remote wake here.
1151 */ 1150 */
1152 if (hcd->self.root_hub->do_remote_wakeup 1151 if (hcd->self.root_hub->do_remote_wakeup) {
1153 && device_may_wakeup(hcd->self.controller)) {
1154
1155 if (t1 & PORT_CONNECT) { 1152 if (t1 & PORT_CONNECT) {
1156 t2 |= PORT_WKOC_E | PORT_WKDISC_E; 1153 t2 |= PORT_WKOC_E | PORT_WKDISC_E;
1157 t2 &= ~PORT_WKCONN_E; 1154 t2 &= ~PORT_WKCONN_E;
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 9a69b1f1b300..142b601f9563 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -281,7 +281,7 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
281 if (xhci->quirks & XHCI_COMP_MODE_QUIRK) 281 if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
282 pdev->no_d3cold = true; 282 pdev->no_d3cold = true;
283 283
284 return xhci_suspend(xhci); 284 return xhci_suspend(xhci, do_wakeup);
285} 285}
286 286
287static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) 287static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 3d78b0cd674b..646300cbe5f7 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -204,7 +204,15 @@ static int xhci_plat_suspend(struct device *dev)
204 struct usb_hcd *hcd = dev_get_drvdata(dev); 204 struct usb_hcd *hcd = dev_get_drvdata(dev);
205 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 205 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
206 206
207 return xhci_suspend(xhci); 207 /*
208 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
209 * to do wakeup during suspend. Since xhci_plat_suspend is currently
210 * only designed for system suspend, device_may_wakeup() is enough
211 * to dertermine whether host is allowed to do wakeup. Need to
212 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
213 * also applies to runtime suspend.
214 */
215 return xhci_suspend(xhci, device_may_wakeup(dev));
208} 216}
209 217
210static int xhci_plat_resume(struct device *dev) 218static int xhci_plat_resume(struct device *dev)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index bc6fcbc16f61..06433aec81d7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1067,9 +1067,8 @@ static void xhci_handle_cmd_reset_ep(struct xhci_hcd *xhci, int slot_id,
1067 false); 1067 false);
1068 xhci_ring_cmd_db(xhci); 1068 xhci_ring_cmd_db(xhci);
1069 } else { 1069 } else {
1070 /* Clear our internal halted state and restart the ring(s) */ 1070 /* Clear our internal halted state */
1071 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_HALTED; 1071 xhci->devs[slot_id]->eps[ep_index].ep_state &= ~EP_HALTED;
1072 ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
1073 } 1072 }
1074} 1073}
1075 1074
@@ -1823,22 +1822,13 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td,
1823 ep->stopped_td = td; 1822 ep->stopped_td = td;
1824 return 0; 1823 return 0;
1825 } else { 1824 } else {
1826 if (trb_comp_code == COMP_STALL) { 1825 if (trb_comp_code == COMP_STALL ||
1827 /* The transfer is completed from the driver's 1826 xhci_requires_manual_halt_cleanup(xhci, ep_ctx,
1828 * perspective, but we need to issue a set dequeue 1827 trb_comp_code)) {
1829 * command for this stalled endpoint to move the dequeue 1828 /* Issue a reset endpoint command to clear the host side
1830 * pointer past the TD. We can't do that here because 1829 * halt, followed by a set dequeue command to move the
1831 * the halt condition must be cleared first. Let the 1830 * dequeue pointer past the TD.
1832 * USB class driver clear the stall later. 1831 * The class driver clears the device side halt later.
1833 */
1834 ep->stopped_td = td;
1835 ep->stopped_stream = ep_ring->stream_id;
1836 } else if (xhci_requires_manual_halt_cleanup(xhci,
1837 ep_ctx, trb_comp_code)) {
1838 /* Other types of errors halt the endpoint, but the
1839 * class driver doesn't call usb_reset_endpoint() unless
1840 * the error is -EPIPE. Clear the halted status in the
1841 * xHCI hardware manually.
1842 */ 1832 */
1843 xhci_cleanup_halted_endpoint(xhci, 1833 xhci_cleanup_halted_endpoint(xhci,
1844 slot_id, ep_index, ep_ring->stream_id, 1834 slot_id, ep_index, ep_ring->stream_id,
@@ -1958,9 +1948,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
1958 else 1948 else
1959 td->urb->actual_length = 0; 1949 td->urb->actual_length = 0;
1960 1950
1961 xhci_cleanup_halted_endpoint(xhci, 1951 return finish_td(xhci, td, event_trb, event, ep, status, false);
1962 slot_id, ep_index, 0, td, event_trb);
1963 return finish_td(xhci, td, event_trb, event, ep, status, true);
1964 } 1952 }
1965 /* 1953 /*
1966 * Did we transfer any data, despite the errors that might have 1954 * Did we transfer any data, despite the errors that might have
@@ -2519,17 +2507,8 @@ cleanup:
2519 if (ret) { 2507 if (ret) {
2520 urb = td->urb; 2508 urb = td->urb;
2521 urb_priv = urb->hcpriv; 2509 urb_priv = urb->hcpriv;
2522 /* Leave the TD around for the reset endpoint function 2510
2523 * to use(but only if it's not a control endpoint, 2511 xhci_urb_free_priv(xhci, urb_priv);
2524 * since we already queued the Set TR dequeue pointer
2525 * command for stalled control endpoints).
2526 */
2527 if (usb_endpoint_xfer_control(&urb->ep->desc) ||
2528 (trb_comp_code != COMP_STALL &&
2529 trb_comp_code != COMP_BABBLE))
2530 xhci_urb_free_priv(xhci, urb_priv);
2531 else
2532 kfree(urb_priv);
2533 2512
2534 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); 2513 usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb);
2535 if ((urb->actual_length != urb->transfer_buffer_length && 2514 if ((urb->actual_length != urb->transfer_buffer_length &&
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2a5d45b4cb15..033b46c470bd 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -35,6 +35,8 @@
35#define DRIVER_AUTHOR "Sarah Sharp" 35#define DRIVER_AUTHOR "Sarah Sharp"
36#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver" 36#define DRIVER_DESC "'eXtensible' Host Controller (xHC) Driver"
37 37
38#define PORT_WAKE_BITS (PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E)
39
38/* Some 0.95 hardware can't handle the chain bit on a Link TRB being cleared */ 40/* Some 0.95 hardware can't handle the chain bit on a Link TRB being cleared */
39static int link_quirk; 41static int link_quirk;
40module_param(link_quirk, int, S_IRUGO | S_IWUSR); 42module_param(link_quirk, int, S_IRUGO | S_IWUSR);
@@ -851,13 +853,47 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci)
851 xhci_set_cmd_ring_deq(xhci); 853 xhci_set_cmd_ring_deq(xhci);
852} 854}
853 855
856static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci)
857{
858 int port_index;
859 __le32 __iomem **port_array;
860 unsigned long flags;
861 u32 t1, t2;
862
863 spin_lock_irqsave(&xhci->lock, flags);
864
865 /* disble usb3 ports Wake bits*/
866 port_index = xhci->num_usb3_ports;
867 port_array = xhci->usb3_ports;
868 while (port_index--) {
869 t1 = readl(port_array[port_index]);
870 t1 = xhci_port_state_to_neutral(t1);
871 t2 = t1 & ~PORT_WAKE_BITS;
872 if (t1 != t2)
873 writel(t2, port_array[port_index]);
874 }
875
876 /* disble usb2 ports Wake bits*/
877 port_index = xhci->num_usb2_ports;
878 port_array = xhci->usb2_ports;
879 while (port_index--) {
880 t1 = readl(port_array[port_index]);
881 t1 = xhci_port_state_to_neutral(t1);
882 t2 = t1 & ~PORT_WAKE_BITS;
883 if (t1 != t2)
884 writel(t2, port_array[port_index]);
885 }
886
887 spin_unlock_irqrestore(&xhci->lock, flags);
888}
889
854/* 890/*
855 * Stop HC (not bus-specific) 891 * Stop HC (not bus-specific)
856 * 892 *
857 * This is called when the machine transition into S3/S4 mode. 893 * This is called when the machine transition into S3/S4 mode.
858 * 894 *
859 */ 895 */
860int xhci_suspend(struct xhci_hcd *xhci) 896int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
861{ 897{
862 int rc = 0; 898 int rc = 0;
863 unsigned int delay = XHCI_MAX_HALT_USEC; 899 unsigned int delay = XHCI_MAX_HALT_USEC;
@@ -868,6 +904,10 @@ int xhci_suspend(struct xhci_hcd *xhci)
868 xhci->shared_hcd->state != HC_STATE_SUSPENDED) 904 xhci->shared_hcd->state != HC_STATE_SUSPENDED)
869 return -EINVAL; 905 return -EINVAL;
870 906
907 /* Clear root port wake on bits if wakeup not allowed. */
908 if (!do_wakeup)
909 xhci_disable_port_wake_on_bits(xhci);
910
871 /* Don't poll the roothubs on bus suspend. */ 911 /* Don't poll the roothubs on bus suspend. */
872 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); 912 xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
873 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); 913 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
@@ -2912,68 +2952,33 @@ void xhci_cleanup_stalled_ring(struct xhci_hcd *xhci,
2912 } 2952 }
2913} 2953}
2914 2954
2915/* Deal with stalled endpoints. The core should have sent the control message 2955/* Called when clearing halted device. The core should have sent the control
2916 * to clear the halt condition. However, we need to make the xHCI hardware 2956 * message to clear the device halt condition. The host side of the halt should
2917 * reset its sequence number, since a device will expect a sequence number of 2957 * already be cleared with a reset endpoint command issued when the STALL tx
2918 * zero after the halt condition is cleared. 2958 * event was received.
2959 *
2919 * Context: in_interrupt 2960 * Context: in_interrupt
2920 */ 2961 */
2962
2921void xhci_endpoint_reset(struct usb_hcd *hcd, 2963void xhci_endpoint_reset(struct usb_hcd *hcd,
2922 struct usb_host_endpoint *ep) 2964 struct usb_host_endpoint *ep)
2923{ 2965{
2924 struct xhci_hcd *xhci; 2966 struct xhci_hcd *xhci;
2925 struct usb_device *udev;
2926 unsigned int ep_index;
2927 unsigned long flags;
2928 int ret;
2929 struct xhci_virt_ep *virt_ep;
2930 struct xhci_command *command;
2931 2967
2932 xhci = hcd_to_xhci(hcd); 2968 xhci = hcd_to_xhci(hcd);
2933 udev = (struct usb_device *) ep->hcpriv;
2934 /* Called with a root hub endpoint (or an endpoint that wasn't added
2935 * with xhci_add_endpoint()
2936 */
2937 if (!ep->hcpriv)
2938 return;
2939 ep_index = xhci_get_endpoint_index(&ep->desc);
2940 virt_ep = &xhci->devs[udev->slot_id]->eps[ep_index];
2941 if (!virt_ep->stopped_td) {
2942 xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep,
2943 "Endpoint 0x%x not halted, refusing to reset.",
2944 ep->desc.bEndpointAddress);
2945 return;
2946 }
2947 if (usb_endpoint_xfer_control(&ep->desc)) {
2948 xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep,
2949 "Control endpoint stall already handled.");
2950 return;
2951 }
2952 2969
2953 command = xhci_alloc_command(xhci, false, false, GFP_ATOMIC);
2954 if (!command)
2955 return;
2956
2957 xhci_dbg_trace(xhci, trace_xhci_dbg_reset_ep,
2958 "Queueing reset endpoint command");
2959 spin_lock_irqsave(&xhci->lock, flags);
2960 ret = xhci_queue_reset_ep(xhci, command, udev->slot_id, ep_index);
2961 /* 2970 /*
2962 * Can't change the ring dequeue pointer until it's transitioned to the 2971 * We might need to implement the config ep cmd in xhci 4.8.1 note:
2963 * stopped state, which is only upon a successful reset endpoint 2972 * The Reset Endpoint Command may only be issued to endpoints in the
2964 * command. Better hope that last command worked! 2973 * Halted state. If software wishes reset the Data Toggle or Sequence
2974 * Number of an endpoint that isn't in the Halted state, then software
2975 * may issue a Configure Endpoint Command with the Drop and Add bits set
2976 * for the target endpoint. that is in the Stopped state.
2965 */ 2977 */
2966 if (!ret) {
2967 xhci_cleanup_stalled_ring(xhci, udev, ep_index);
2968 kfree(virt_ep->stopped_td);
2969 xhci_ring_cmd_db(xhci);
2970 }
2971 virt_ep->stopped_td = NULL;
2972 virt_ep->stopped_stream = 0;
2973 spin_unlock_irqrestore(&xhci->lock, flags);
2974 2978
2975 if (ret) 2979 /* For now just print debug to follow the situation */
2976 xhci_warn(xhci, "FIXME allocate a new ring segment\n"); 2980 xhci_dbg(xhci, "Endpoint 0x%x ep reset callback called\n",
2981 ep->desc.bEndpointAddress);
2977} 2982}
2978 2983
2979static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, 2984static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index df76d642e719..d745715a1e2f 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1746,7 +1746,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
1746void xhci_init_driver(struct hc_driver *drv, int (*setup_fn)(struct usb_hcd *)); 1746void xhci_init_driver(struct hc_driver *drv, int (*setup_fn)(struct usb_hcd *));
1747 1747
1748#ifdef CONFIG_PM 1748#ifdef CONFIG_PM
1749int xhci_suspend(struct xhci_hcd *xhci); 1749int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup);
1750int xhci_resume(struct xhci_hcd *xhci, bool hibernated); 1750int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
1751#else 1751#else
1752#define xhci_suspend NULL 1752#define xhci_suspend NULL
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index cfd009dc4018..6c4eb3cf5efd 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -120,6 +120,7 @@ static const struct usb_device_id id_table[] = {
120 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */ 120 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
121 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ 121 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
122 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ 122 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
123 { USB_DEVICE(0x10C4, 0x8875) }, /* CEL MeshConnect USB Stick */
123 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ 124 { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */
124 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ 125 { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */
125 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ 126 { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0dad8ce5a609..1ebb351b9e9a 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -470,6 +470,39 @@ static const struct usb_device_id id_table_combined[] = {
470 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) }, 470 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
471 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) }, 471 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
472 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) }, 472 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
473 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_4701_PID) },
474 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9300_PID) },
475 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9301_PID) },
476 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9302_PID) },
477 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9303_PID) },
478 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9304_PID) },
479 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9305_PID) },
480 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9306_PID) },
481 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9307_PID) },
482 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9308_PID) },
483 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9309_PID) },
484 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930A_PID) },
485 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930B_PID) },
486 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930C_PID) },
487 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930D_PID) },
488 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930E_PID) },
489 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_930F_PID) },
490 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9310_PID) },
491 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9311_PID) },
492 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9312_PID) },
493 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9313_PID) },
494 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9314_PID) },
495 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9315_PID) },
496 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9316_PID) },
497 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9317_PID) },
498 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9318_PID) },
499 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_9319_PID) },
500 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931A_PID) },
501 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931B_PID) },
502 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931C_PID) },
503 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931D_PID) },
504 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931E_PID) },
505 { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_931F_PID) },
473 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) }, 506 { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
474 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) }, 507 { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
475 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) }, 508 { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 6786b705ccf6..e52409c9be99 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -926,8 +926,8 @@
926#define BAYER_CONTOUR_CABLE_PID 0x6001 926#define BAYER_CONTOUR_CABLE_PID 0x6001
927 927
928/* 928/*
929 * The following are the values for the Matrix Orbital FTDI Range 929 * Matrix Orbital Intelligent USB displays.
930 * Anything in this range will use an FT232RL. 930 * http://www.matrixorbital.com
931 */ 931 */
932#define MTXORB_VID 0x1B3D 932#define MTXORB_VID 0x1B3D
933#define MTXORB_FTDI_RANGE_0100_PID 0x0100 933#define MTXORB_FTDI_RANGE_0100_PID 0x0100
@@ -1186,8 +1186,39 @@
1186#define MTXORB_FTDI_RANGE_01FD_PID 0x01FD 1186#define MTXORB_FTDI_RANGE_01FD_PID 0x01FD
1187#define MTXORB_FTDI_RANGE_01FE_PID 0x01FE 1187#define MTXORB_FTDI_RANGE_01FE_PID 0x01FE
1188#define MTXORB_FTDI_RANGE_01FF_PID 0x01FF 1188#define MTXORB_FTDI_RANGE_01FF_PID 0x01FF
1189 1189#define MTXORB_FTDI_RANGE_4701_PID 0x4701
1190 1190#define MTXORB_FTDI_RANGE_9300_PID 0x9300
1191#define MTXORB_FTDI_RANGE_9301_PID 0x9301
1192#define MTXORB_FTDI_RANGE_9302_PID 0x9302
1193#define MTXORB_FTDI_RANGE_9303_PID 0x9303
1194#define MTXORB_FTDI_RANGE_9304_PID 0x9304
1195#define MTXORB_FTDI_RANGE_9305_PID 0x9305
1196#define MTXORB_FTDI_RANGE_9306_PID 0x9306
1197#define MTXORB_FTDI_RANGE_9307_PID 0x9307
1198#define MTXORB_FTDI_RANGE_9308_PID 0x9308
1199#define MTXORB_FTDI_RANGE_9309_PID 0x9309
1200#define MTXORB_FTDI_RANGE_930A_PID 0x930A
1201#define MTXORB_FTDI_RANGE_930B_PID 0x930B
1202#define MTXORB_FTDI_RANGE_930C_PID 0x930C
1203#define MTXORB_FTDI_RANGE_930D_PID 0x930D
1204#define MTXORB_FTDI_RANGE_930E_PID 0x930E
1205#define MTXORB_FTDI_RANGE_930F_PID 0x930F
1206#define MTXORB_FTDI_RANGE_9310_PID 0x9310
1207#define MTXORB_FTDI_RANGE_9311_PID 0x9311
1208#define MTXORB_FTDI_RANGE_9312_PID 0x9312
1209#define MTXORB_FTDI_RANGE_9313_PID 0x9313
1210#define MTXORB_FTDI_RANGE_9314_PID 0x9314
1211#define MTXORB_FTDI_RANGE_9315_PID 0x9315
1212#define MTXORB_FTDI_RANGE_9316_PID 0x9316
1213#define MTXORB_FTDI_RANGE_9317_PID 0x9317
1214#define MTXORB_FTDI_RANGE_9318_PID 0x9318
1215#define MTXORB_FTDI_RANGE_9319_PID 0x9319
1216#define MTXORB_FTDI_RANGE_931A_PID 0x931A
1217#define MTXORB_FTDI_RANGE_931B_PID 0x931B
1218#define MTXORB_FTDI_RANGE_931C_PID 0x931C
1219#define MTXORB_FTDI_RANGE_931D_PID 0x931D
1220#define MTXORB_FTDI_RANGE_931E_PID 0x931E
1221#define MTXORB_FTDI_RANGE_931F_PID 0x931F
1191 1222
1192/* 1223/*
1193 * The Mobility Lab (TML) 1224 * The Mobility Lab (TML)
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 93cb7cebda62..077c714f1285 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -311,24 +311,30 @@ static void usa26_indat_callback(struct urb *urb)
311 if ((data[0] & 0x80) == 0) { 311 if ((data[0] & 0x80) == 0) {
312 /* no errors on individual bytes, only 312 /* no errors on individual bytes, only
313 possible overrun err */ 313 possible overrun err */
314 if (data[0] & RXERROR_OVERRUN) 314 if (data[0] & RXERROR_OVERRUN) {
315 err = TTY_OVERRUN; 315 tty_insert_flip_char(&port->port, 0,
316 else 316 TTY_OVERRUN);
317 err = 0; 317 }
318 for (i = 1; i < urb->actual_length ; ++i) 318 for (i = 1; i < urb->actual_length ; ++i)
319 tty_insert_flip_char(&port->port, data[i], err); 319 tty_insert_flip_char(&port->port, data[i],
320 TTY_NORMAL);
320 } else { 321 } else {
321 /* some bytes had errors, every byte has status */ 322 /* some bytes had errors, every byte has status */
322 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 323 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
323 for (i = 0; i + 1 < urb->actual_length; i += 2) { 324 for (i = 0; i + 1 < urb->actual_length; i += 2) {
324 int stat = data[i], flag = 0; 325 int stat = data[i];
325 if (stat & RXERROR_OVERRUN) 326 int flag = TTY_NORMAL;
326 flag |= TTY_OVERRUN; 327
327 if (stat & RXERROR_FRAMING) 328 if (stat & RXERROR_OVERRUN) {
328 flag |= TTY_FRAME; 329 tty_insert_flip_char(&port->port, 0,
329 if (stat & RXERROR_PARITY) 330 TTY_OVERRUN);
330 flag |= TTY_PARITY; 331 }
331 /* XXX should handle break (0x10) */ 332 /* XXX should handle break (0x10) */
333 if (stat & RXERROR_PARITY)
334 flag = TTY_PARITY;
335 else if (stat & RXERROR_FRAMING)
336 flag = TTY_FRAME;
337
332 tty_insert_flip_char(&port->port, data[i+1], 338 tty_insert_flip_char(&port->port, data[i+1],
333 flag); 339 flag);
334 } 340 }
@@ -649,14 +655,19 @@ static void usa49_indat_callback(struct urb *urb)
649 } else { 655 } else {
650 /* some bytes had errors, every byte has status */ 656 /* some bytes had errors, every byte has status */
651 for (i = 0; i + 1 < urb->actual_length; i += 2) { 657 for (i = 0; i + 1 < urb->actual_length; i += 2) {
652 int stat = data[i], flag = 0; 658 int stat = data[i];
653 if (stat & RXERROR_OVERRUN) 659 int flag = TTY_NORMAL;
654 flag |= TTY_OVERRUN; 660
655 if (stat & RXERROR_FRAMING) 661 if (stat & RXERROR_OVERRUN) {
656 flag |= TTY_FRAME; 662 tty_insert_flip_char(&port->port, 0,
657 if (stat & RXERROR_PARITY) 663 TTY_OVERRUN);
658 flag |= TTY_PARITY; 664 }
659 /* XXX should handle break (0x10) */ 665 /* XXX should handle break (0x10) */
666 if (stat & RXERROR_PARITY)
667 flag = TTY_PARITY;
668 else if (stat & RXERROR_FRAMING)
669 flag = TTY_FRAME;
670
660 tty_insert_flip_char(&port->port, data[i+1], 671 tty_insert_flip_char(&port->port, data[i+1],
661 flag); 672 flag);
662 } 673 }
@@ -713,15 +724,19 @@ static void usa49wg_indat_callback(struct urb *urb)
713 */ 724 */
714 for (x = 0; x + 1 < len && 725 for (x = 0; x + 1 < len &&
715 i + 1 < urb->actual_length; x += 2) { 726 i + 1 < urb->actual_length; x += 2) {
716 int stat = data[i], flag = 0; 727 int stat = data[i];
728 int flag = TTY_NORMAL;
717 729
718 if (stat & RXERROR_OVERRUN) 730 if (stat & RXERROR_OVERRUN) {
719 flag |= TTY_OVERRUN; 731 tty_insert_flip_char(&port->port, 0,
720 if (stat & RXERROR_FRAMING) 732 TTY_OVERRUN);
721 flag |= TTY_FRAME; 733 }
722 if (stat & RXERROR_PARITY)
723 flag |= TTY_PARITY;
724 /* XXX should handle break (0x10) */ 734 /* XXX should handle break (0x10) */
735 if (stat & RXERROR_PARITY)
736 flag = TTY_PARITY;
737 else if (stat & RXERROR_FRAMING)
738 flag = TTY_FRAME;
739
725 tty_insert_flip_char(&port->port, data[i+1], 740 tty_insert_flip_char(&port->port, data[i+1],
726 flag); 741 flag);
727 i += 2; 742 i += 2;
@@ -773,25 +788,31 @@ static void usa90_indat_callback(struct urb *urb)
773 if ((data[0] & 0x80) == 0) { 788 if ((data[0] & 0x80) == 0) {
774 /* no errors on individual bytes, only 789 /* no errors on individual bytes, only
775 possible overrun err*/ 790 possible overrun err*/
776 if (data[0] & RXERROR_OVERRUN) 791 if (data[0] & RXERROR_OVERRUN) {
777 err = TTY_OVERRUN; 792 tty_insert_flip_char(&port->port, 0,
778 else 793 TTY_OVERRUN);
779 err = 0; 794 }
780 for (i = 1; i < urb->actual_length ; ++i) 795 for (i = 1; i < urb->actual_length ; ++i)
781 tty_insert_flip_char(&port->port, 796 tty_insert_flip_char(&port->port,
782 data[i], err); 797 data[i], TTY_NORMAL);
783 } else { 798 } else {
784 /* some bytes had errors, every byte has status */ 799 /* some bytes had errors, every byte has status */
785 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__); 800 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
786 for (i = 0; i + 1 < urb->actual_length; i += 2) { 801 for (i = 0; i + 1 < urb->actual_length; i += 2) {
787 int stat = data[i], flag = 0; 802 int stat = data[i];
788 if (stat & RXERROR_OVERRUN) 803 int flag = TTY_NORMAL;
789 flag |= TTY_OVERRUN; 804
790 if (stat & RXERROR_FRAMING) 805 if (stat & RXERROR_OVERRUN) {
791 flag |= TTY_FRAME; 806 tty_insert_flip_char(
792 if (stat & RXERROR_PARITY) 807 &port->port, 0,
793 flag |= TTY_PARITY; 808 TTY_OVERRUN);
809 }
794 /* XXX should handle break (0x10) */ 810 /* XXX should handle break (0x10) */
811 if (stat & RXERROR_PARITY)
812 flag = TTY_PARITY;
813 else if (stat & RXERROR_FRAMING)
814 flag = TTY_FRAME;
815
795 tty_insert_flip_char(&port->port, 816 tty_insert_flip_char(&port->port,
796 data[i+1], flag); 817 data[i+1], flag);
797 } 818 }
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index a7fe664b6b7d..70a098de429f 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -490,10 +490,9 @@ static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr,
490 if (*tty_flag == TTY_NORMAL) 490 if (*tty_flag == TTY_NORMAL)
491 *tty_flag = TTY_FRAME; 491 *tty_flag = TTY_FRAME;
492 } 492 }
493 if (lsr & UART_LSR_OE){ 493 if (lsr & UART_LSR_OE) {
494 port->icount.overrun++; 494 port->icount.overrun++;
495 if (*tty_flag == TTY_NORMAL) 495 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
496 *tty_flag = TTY_OVERRUN;
497 } 496 }
498 } 497 }
499 498
@@ -511,12 +510,8 @@ static void ssu100_process_read_urb(struct urb *urb)
511 if ((len >= 4) && 510 if ((len >= 4) &&
512 (packet[0] == 0x1b) && (packet[1] == 0x1b) && 511 (packet[0] == 0x1b) && (packet[1] == 0x1b) &&
513 ((packet[2] == 0x00) || (packet[2] == 0x01))) { 512 ((packet[2] == 0x00) || (packet[2] == 0x01))) {
514 if (packet[2] == 0x00) { 513 if (packet[2] == 0x00)
515 ssu100_update_lsr(port, packet[3], &flag); 514 ssu100_update_lsr(port, packet[3], &flag);
516 if (flag == TTY_OVERRUN)
517 tty_insert_flip_char(&port->port, 0,
518 TTY_OVERRUN);
519 }
520 if (packet[2] == 0x01) 515 if (packet[2] == 0x01)
521 ssu100_update_msr(port, packet[3]); 516 ssu100_update_msr(port, packet[3]);
522 517
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index 2fefaf923e4a..18a283d6de1c 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -103,3 +103,10 @@ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
103 "VL711", 103 "VL711",
104 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 104 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
105 US_FL_NO_ATA_1X), 105 US_FL_NO_ATA_1X),
106
107/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
108UNUSUAL_DEV(0x4971, 0x1012, 0x0000, 0x9999,
109 "Hitachi",
110 "External HDD",
111 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
112 US_FL_IGNORE_UAS),
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 69906cacd04f..a17f11850669 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1312,6 +1312,7 @@ static int
1312vhost_scsi_set_endpoint(struct vhost_scsi *vs, 1312vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1313 struct vhost_scsi_target *t) 1313 struct vhost_scsi_target *t)
1314{ 1314{
1315 struct se_portal_group *se_tpg;
1315 struct tcm_vhost_tport *tv_tport; 1316 struct tcm_vhost_tport *tv_tport;
1316 struct tcm_vhost_tpg *tpg; 1317 struct tcm_vhost_tpg *tpg;
1317 struct tcm_vhost_tpg **vs_tpg; 1318 struct tcm_vhost_tpg **vs_tpg;
@@ -1359,6 +1360,21 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs,
1359 ret = -EEXIST; 1360 ret = -EEXIST;
1360 goto out; 1361 goto out;
1361 } 1362 }
1363 /*
1364 * In order to ensure individual vhost-scsi configfs
1365 * groups cannot be removed while in use by vhost ioctl,
1366 * go ahead and take an explicit se_tpg->tpg_group.cg_item
1367 * dependency now.
1368 */
1369 se_tpg = &tpg->se_tpg;
1370 ret = configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys,
1371 &se_tpg->tpg_group.cg_item);
1372 if (ret) {
1373 pr_warn("configfs_depend_item() failed: %d\n", ret);
1374 kfree(vs_tpg);
1375 mutex_unlock(&tpg->tv_tpg_mutex);
1376 goto out;
1377 }
1362 tpg->tv_tpg_vhost_count++; 1378 tpg->tv_tpg_vhost_count++;
1363 tpg->vhost_scsi = vs; 1379 tpg->vhost_scsi = vs;
1364 vs_tpg[tpg->tport_tpgt] = tpg; 1380 vs_tpg[tpg->tport_tpgt] = tpg;
@@ -1401,6 +1417,7 @@ static int
1401vhost_scsi_clear_endpoint(struct vhost_scsi *vs, 1417vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1402 struct vhost_scsi_target *t) 1418 struct vhost_scsi_target *t)
1403{ 1419{
1420 struct se_portal_group *se_tpg;
1404 struct tcm_vhost_tport *tv_tport; 1421 struct tcm_vhost_tport *tv_tport;
1405 struct tcm_vhost_tpg *tpg; 1422 struct tcm_vhost_tpg *tpg;
1406 struct vhost_virtqueue *vq; 1423 struct vhost_virtqueue *vq;
@@ -1449,6 +1466,13 @@ vhost_scsi_clear_endpoint(struct vhost_scsi *vs,
1449 vs->vs_tpg[target] = NULL; 1466 vs->vs_tpg[target] = NULL;
1450 match = true; 1467 match = true;
1451 mutex_unlock(&tpg->tv_tpg_mutex); 1468 mutex_unlock(&tpg->tv_tpg_mutex);
1469 /*
1470 * Release se_tpg->tpg_group.cg_item configfs dependency now
1471 * to allow vhost-scsi WWPN se_tpg->tpg_group shutdown to occur.
1472 */
1473 se_tpg = &tpg->se_tpg;
1474 configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys,
1475 &se_tpg->tpg_group.cg_item);
1452 } 1476 }
1453 if (match) { 1477 if (match) {
1454 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) { 1478 for (i = 0; i < VHOST_SCSI_MAX_VQ; i++) {
diff --git a/fs/Makefile b/fs/Makefile
index 34a1b9dea6dd..da0bbb456d3f 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -104,7 +104,7 @@ obj-$(CONFIG_QNX6FS_FS) += qnx6/
104obj-$(CONFIG_AUTOFS4_FS) += autofs4/ 104obj-$(CONFIG_AUTOFS4_FS) += autofs4/
105obj-$(CONFIG_ADFS_FS) += adfs/ 105obj-$(CONFIG_ADFS_FS) += adfs/
106obj-$(CONFIG_FUSE_FS) += fuse/ 106obj-$(CONFIG_FUSE_FS) += fuse/
107obj-$(CONFIG_OVERLAYFS_FS) += overlayfs/ 107obj-$(CONFIG_OVERLAY_FS) += overlayfs/
108obj-$(CONFIG_UDF_FS) += udf/ 108obj-$(CONFIG_UDF_FS) += udf/
109obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/ 109obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
110obj-$(CONFIG_OMFS_FS) += omfs/ 110obj-$(CONFIG_OMFS_FS) += omfs/
diff --git a/fs/aio.c b/fs/aio.c
index 84a751005f5b..14b93159ef83 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -165,6 +165,15 @@ static struct vfsmount *aio_mnt;
165static const struct file_operations aio_ring_fops; 165static const struct file_operations aio_ring_fops;
166static const struct address_space_operations aio_ctx_aops; 166static const struct address_space_operations aio_ctx_aops;
167 167
168/* Backing dev info for aio fs.
169 * -no dirty page accounting or writeback happens
170 */
171static struct backing_dev_info aio_fs_backing_dev_info = {
172 .name = "aiofs",
173 .state = 0,
174 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_MAP_COPY,
175};
176
168static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages) 177static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
169{ 178{
170 struct qstr this = QSTR_INIT("[aio]", 5); 179 struct qstr this = QSTR_INIT("[aio]", 5);
@@ -176,6 +185,7 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
176 185
177 inode->i_mapping->a_ops = &aio_ctx_aops; 186 inode->i_mapping->a_ops = &aio_ctx_aops;
178 inode->i_mapping->private_data = ctx; 187 inode->i_mapping->private_data = ctx;
188 inode->i_mapping->backing_dev_info = &aio_fs_backing_dev_info;
179 inode->i_size = PAGE_SIZE * nr_pages; 189 inode->i_size = PAGE_SIZE * nr_pages;
180 190
181 path.dentry = d_alloc_pseudo(aio_mnt->mnt_sb, &this); 191 path.dentry = d_alloc_pseudo(aio_mnt->mnt_sb, &this);
@@ -220,6 +230,9 @@ static int __init aio_setup(void)
220 if (IS_ERR(aio_mnt)) 230 if (IS_ERR(aio_mnt))
221 panic("Failed to create aio fs mount."); 231 panic("Failed to create aio fs mount.");
222 232
233 if (bdi_init(&aio_fs_backing_dev_info))
234 panic("Failed to init aio fs backing dev info.");
235
223 kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC); 236 kiocb_cachep = KMEM_CACHE(kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
224 kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC); 237 kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
225 238
@@ -281,11 +294,6 @@ static const struct file_operations aio_ring_fops = {
281 .mmap = aio_ring_mmap, 294 .mmap = aio_ring_mmap,
282}; 295};
283 296
284static int aio_set_page_dirty(struct page *page)
285{
286 return 0;
287}
288
289#if IS_ENABLED(CONFIG_MIGRATION) 297#if IS_ENABLED(CONFIG_MIGRATION)
290static int aio_migratepage(struct address_space *mapping, struct page *new, 298static int aio_migratepage(struct address_space *mapping, struct page *new,
291 struct page *old, enum migrate_mode mode) 299 struct page *old, enum migrate_mode mode)
@@ -357,7 +365,7 @@ out:
357#endif 365#endif
358 366
359static const struct address_space_operations aio_ctx_aops = { 367static const struct address_space_operations aio_ctx_aops = {
360 .set_page_dirty = aio_set_page_dirty, 368 .set_page_dirty = __set_page_dirty_no_writeback,
361#if IS_ENABLED(CONFIG_MIGRATION) 369#if IS_ENABLED(CONFIG_MIGRATION)
362 .migratepage = aio_migratepage, 370 .migratepage = aio_migratepage,
363#endif 371#endif
@@ -412,7 +420,6 @@ static int aio_setup_ring(struct kioctx *ctx)
412 pr_debug("pid(%d) page[%d]->count=%d\n", 420 pr_debug("pid(%d) page[%d]->count=%d\n",
413 current->pid, i, page_count(page)); 421 current->pid, i, page_count(page));
414 SetPageUptodate(page); 422 SetPageUptodate(page);
415 SetPageDirty(page);
416 unlock_page(page); 423 unlock_page(page);
417 424
418 ctx->ring_pages[i] = page; 425 ctx->ring_pages[i] = page;
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index d3220d31d3cb..dcd9be32ac57 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1011,8 +1011,6 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
1011 bytes = min(bytes, working_bytes); 1011 bytes = min(bytes, working_bytes);
1012 kaddr = kmap_atomic(page_out); 1012 kaddr = kmap_atomic(page_out);
1013 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes); 1013 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes);
1014 if (*pg_index == (vcnt - 1) && *pg_offset == 0)
1015 memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1016 kunmap_atomic(kaddr); 1014 kunmap_atomic(kaddr);
1017 flush_dcache_page(page_out); 1015 flush_dcache_page(page_out);
1018 1016
@@ -1054,3 +1052,34 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
1054 1052
1055 return 1; 1053 return 1;
1056} 1054}
1055
1056/*
1057 * When uncompressing data, we need to make sure and zero any parts of
1058 * the biovec that were not filled in by the decompression code. pg_index
1059 * and pg_offset indicate the last page and the last offset of that page
1060 * that have been filled in. This will zero everything remaining in the
1061 * biovec.
1062 */
1063void btrfs_clear_biovec_end(struct bio_vec *bvec, int vcnt,
1064 unsigned long pg_index,
1065 unsigned long pg_offset)
1066{
1067 while (pg_index < vcnt) {
1068 struct page *page = bvec[pg_index].bv_page;
1069 unsigned long off = bvec[pg_index].bv_offset;
1070 unsigned long len = bvec[pg_index].bv_len;
1071
1072 if (pg_offset < off)
1073 pg_offset = off;
1074 if (pg_offset < off + len) {
1075 unsigned long bytes = off + len - pg_offset;
1076 char *kaddr;
1077
1078 kaddr = kmap_atomic(page);
1079 memset(kaddr + pg_offset, 0, bytes);
1080 kunmap_atomic(kaddr);
1081 }
1082 pg_index++;
1083 pg_offset = 0;
1084 }
1085}
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 0c803b4fbf93..d181f70caae0 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -45,7 +45,9 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
45 unsigned long nr_pages); 45 unsigned long nr_pages);
46int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, 46int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
47 int mirror_num, unsigned long bio_flags); 47 int mirror_num, unsigned long bio_flags);
48 48void btrfs_clear_biovec_end(struct bio_vec *bvec, int vcnt,
49 unsigned long pg_index,
50 unsigned long pg_offset);
49struct btrfs_compress_op { 51struct btrfs_compress_op {
50 struct list_head *(*alloc_workspace)(void); 52 struct list_head *(*alloc_workspace)(void);
51 53
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 19bc6162fb8e..150822ee0a0b 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -80,13 +80,6 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
80{ 80{
81 int i; 81 int i;
82 82
83#ifdef CONFIG_DEBUG_LOCK_ALLOC
84 /* lockdep really cares that we take all of these spinlocks
85 * in the right order. If any of the locks in the path are not
86 * currently blocking, it is going to complain. So, make really
87 * really sure by forcing the path to blocking before we clear
88 * the path blocking.
89 */
90 if (held) { 83 if (held) {
91 btrfs_set_lock_blocking_rw(held, held_rw); 84 btrfs_set_lock_blocking_rw(held, held_rw);
92 if (held_rw == BTRFS_WRITE_LOCK) 85 if (held_rw == BTRFS_WRITE_LOCK)
@@ -95,7 +88,6 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
95 held_rw = BTRFS_READ_LOCK_BLOCKING; 88 held_rw = BTRFS_READ_LOCK_BLOCKING;
96 } 89 }
97 btrfs_set_path_blocking(p); 90 btrfs_set_path_blocking(p);
98#endif
99 91
100 for (i = BTRFS_MAX_LEVEL - 1; i >= 0; i--) { 92 for (i = BTRFS_MAX_LEVEL - 1; i >= 0; i--) {
101 if (p->nodes[i] && p->locks[i]) { 93 if (p->nodes[i] && p->locks[i]) {
@@ -107,10 +99,8 @@ noinline void btrfs_clear_path_blocking(struct btrfs_path *p,
107 } 99 }
108 } 100 }
109 101
110#ifdef CONFIG_DEBUG_LOCK_ALLOC
111 if (held) 102 if (held)
112 btrfs_clear_lock_blocking_rw(held, held_rw); 103 btrfs_clear_lock_blocking_rw(held, held_rw);
113#endif
114} 104}
115 105
116/* this also releases the path */ 106/* this also releases the path */
@@ -2893,7 +2883,7 @@ cow_done:
2893 } 2883 }
2894 p->locks[level] = BTRFS_WRITE_LOCK; 2884 p->locks[level] = BTRFS_WRITE_LOCK;
2895 } else { 2885 } else {
2896 err = btrfs_try_tree_read_lock(b); 2886 err = btrfs_tree_read_lock_atomic(b);
2897 if (!err) { 2887 if (!err) {
2898 btrfs_set_path_blocking(p); 2888 btrfs_set_path_blocking(p);
2899 btrfs_tree_read_lock(b); 2889 btrfs_tree_read_lock(b);
@@ -3025,7 +3015,7 @@ again:
3025 } 3015 }
3026 3016
3027 level = btrfs_header_level(b); 3017 level = btrfs_header_level(b);
3028 err = btrfs_try_tree_read_lock(b); 3018 err = btrfs_tree_read_lock_atomic(b);
3029 if (!err) { 3019 if (!err) {
3030 btrfs_set_path_blocking(p); 3020 btrfs_set_path_blocking(p);
3031 btrfs_tree_read_lock(b); 3021 btrfs_tree_read_lock(b);
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 5665d2149249..f8229ef1b46d 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -128,6 +128,26 @@ again:
128} 128}
129 129
130/* 130/*
131 * take a spinning read lock.
132 * returns 1 if we get the read lock and 0 if we don't
133 * this won't wait for blocking writers
134 */
135int btrfs_tree_read_lock_atomic(struct extent_buffer *eb)
136{
137 if (atomic_read(&eb->blocking_writers))
138 return 0;
139
140 read_lock(&eb->lock);
141 if (atomic_read(&eb->blocking_writers)) {
142 read_unlock(&eb->lock);
143 return 0;
144 }
145 atomic_inc(&eb->read_locks);
146 atomic_inc(&eb->spinning_readers);
147 return 1;
148}
149
150/*
131 * returns 1 if we get the read lock and 0 if we don't 151 * returns 1 if we get the read lock and 0 if we don't
132 * this won't wait for blocking writers 152 * this won't wait for blocking writers
133 */ 153 */
@@ -158,9 +178,7 @@ int btrfs_try_tree_write_lock(struct extent_buffer *eb)
158 atomic_read(&eb->blocking_readers)) 178 atomic_read(&eb->blocking_readers))
159 return 0; 179 return 0;
160 180
161 if (!write_trylock(&eb->lock)) 181 write_lock(&eb->lock);
162 return 0;
163
164 if (atomic_read(&eb->blocking_writers) || 182 if (atomic_read(&eb->blocking_writers) ||
165 atomic_read(&eb->blocking_readers)) { 183 atomic_read(&eb->blocking_readers)) {
166 write_unlock(&eb->lock); 184 write_unlock(&eb->lock);
diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h
index b81e0e9a4894..c44a9d5f5362 100644
--- a/fs/btrfs/locking.h
+++ b/fs/btrfs/locking.h
@@ -35,6 +35,8 @@ void btrfs_clear_lock_blocking_rw(struct extent_buffer *eb, int rw);
35void btrfs_assert_tree_locked(struct extent_buffer *eb); 35void btrfs_assert_tree_locked(struct extent_buffer *eb);
36int btrfs_try_tree_read_lock(struct extent_buffer *eb); 36int btrfs_try_tree_read_lock(struct extent_buffer *eb);
37int btrfs_try_tree_write_lock(struct extent_buffer *eb); 37int btrfs_try_tree_write_lock(struct extent_buffer *eb);
38int btrfs_tree_read_lock_atomic(struct extent_buffer *eb);
39
38 40
39static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw) 41static inline void btrfs_tree_unlock_rw(struct extent_buffer *eb, int rw)
40{ 42{
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 78285f30909e..617553cdb7d3 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -373,6 +373,8 @@ cont:
373 } 373 }
374done: 374done:
375 kunmap(pages_in[page_in_index]); 375 kunmap(pages_in[page_in_index]);
376 if (!ret)
377 btrfs_clear_biovec_end(bvec, vcnt, page_out_index, pg_offset);
376 return ret; 378 return ret;
377} 379}
378 380
@@ -410,10 +412,23 @@ static int lzo_decompress(struct list_head *ws, unsigned char *data_in,
410 goto out; 412 goto out;
411 } 413 }
412 414
415 /*
416 * the caller is already checking against PAGE_SIZE, but lets
417 * move this check closer to the memcpy/memset
418 */
419 destlen = min_t(unsigned long, destlen, PAGE_SIZE);
413 bytes = min_t(unsigned long, destlen, out_len - start_byte); 420 bytes = min_t(unsigned long, destlen, out_len - start_byte);
414 421
415 kaddr = kmap_atomic(dest_page); 422 kaddr = kmap_atomic(dest_page);
416 memcpy(kaddr, workspace->buf + start_byte, bytes); 423 memcpy(kaddr, workspace->buf + start_byte, bytes);
424
425 /*
426 * btrfs_getblock is doing a zero on the tail of the page too,
427 * but this will cover anything missing from the decompressed
428 * data.
429 */
430 if (bytes < destlen)
431 memset(kaddr+bytes, 0, destlen-bytes);
417 kunmap_atomic(kaddr); 432 kunmap_atomic(kaddr);
418out: 433out:
419 return ret; 434 return ret;
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index 759fa4e2de8f..fb22fd8d8fb8 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -299,6 +299,8 @@ done:
299 zlib_inflateEnd(&workspace->strm); 299 zlib_inflateEnd(&workspace->strm);
300 if (data_in) 300 if (data_in)
301 kunmap(pages_in[page_in_index]); 301 kunmap(pages_in[page_in_index]);
302 if (!ret)
303 btrfs_clear_biovec_end(bvec, vcnt, page_out_index, pg_offset);
302 return ret; 304 return ret;
303} 305}
304 306
@@ -310,10 +312,14 @@ static int zlib_decompress(struct list_head *ws, unsigned char *data_in,
310 struct workspace *workspace = list_entry(ws, struct workspace, list); 312 struct workspace *workspace = list_entry(ws, struct workspace, list);
311 int ret = 0; 313 int ret = 0;
312 int wbits = MAX_WBITS; 314 int wbits = MAX_WBITS;
313 unsigned long bytes_left = destlen; 315 unsigned long bytes_left;
314 unsigned long total_out = 0; 316 unsigned long total_out = 0;
317 unsigned long pg_offset = 0;
315 char *kaddr; 318 char *kaddr;
316 319
320 destlen = min_t(unsigned long, destlen, PAGE_SIZE);
321 bytes_left = destlen;
322
317 workspace->strm.next_in = data_in; 323 workspace->strm.next_in = data_in;
318 workspace->strm.avail_in = srclen; 324 workspace->strm.avail_in = srclen;
319 workspace->strm.total_in = 0; 325 workspace->strm.total_in = 0;
@@ -341,7 +347,6 @@ static int zlib_decompress(struct list_head *ws, unsigned char *data_in,
341 unsigned long buf_start; 347 unsigned long buf_start;
342 unsigned long buf_offset; 348 unsigned long buf_offset;
343 unsigned long bytes; 349 unsigned long bytes;
344 unsigned long pg_offset = 0;
345 350
346 ret = zlib_inflate(&workspace->strm, Z_NO_FLUSH); 351 ret = zlib_inflate(&workspace->strm, Z_NO_FLUSH);
347 if (ret != Z_OK && ret != Z_STREAM_END) 352 if (ret != Z_OK && ret != Z_STREAM_END)
@@ -384,6 +389,17 @@ next:
384 ret = 0; 389 ret = 0;
385 390
386 zlib_inflateEnd(&workspace->strm); 391 zlib_inflateEnd(&workspace->strm);
392
393 /*
394 * this should only happen if zlib returned fewer bytes than we
395 * expected. btrfs_get_block is responsible for zeroing from the
396 * end of the inline extent (destlen) to the end of the page
397 */
398 if (pg_offset < destlen) {
399 kaddr = kmap_atomic(dest_page);
400 memset(kaddr + pg_offset, 0, destlen - pg_offset);
401 kunmap_atomic(kaddr);
402 }
387 return ret; 403 return ret;
388} 404}
389 405
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 659f2ea9e6f7..cefca661464b 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2638,7 +2638,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,
2638 2638
2639 for (i = 0; i < CEPH_CAP_BITS; i++) 2639 for (i = 0; i < CEPH_CAP_BITS; i++)
2640 if ((dirty & (1 << i)) && 2640 if ((dirty & (1 << i)) &&
2641 flush_tid == ci->i_cap_flush_tid[i]) 2641 (u16)flush_tid == ci->i_cap_flush_tid[i])
2642 cleaned |= 1 << i; 2642 cleaned |= 1 << i;
2643 2643
2644 dout("handle_cap_flush_ack inode %p mds%d seq %d on %s cleaned %s," 2644 dout("handle_cap_flush_ack inode %p mds%d seq %d on %s cleaned %s,"
diff --git a/fs/dcache.c b/fs/dcache.c
index 3ffef7f4e5cd..5bc72b07fde2 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -778,6 +778,7 @@ restart:
778 struct dentry *parent = lock_parent(dentry); 778 struct dentry *parent = lock_parent(dentry);
779 if (likely(!dentry->d_lockref.count)) { 779 if (likely(!dentry->d_lockref.count)) {
780 __dentry_kill(dentry); 780 __dentry_kill(dentry);
781 dput(parent);
781 goto restart; 782 goto restart;
782 } 783 }
783 if (parent) 784 if (parent)
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index fe839b915116..d67a16f2a45d 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -174,27 +174,6 @@ struct iso9660_options{
174 * Compute the hash for the isofs name corresponding to the dentry. 174 * Compute the hash for the isofs name corresponding to the dentry.
175 */ 175 */
176static int 176static int
177isofs_hash_common(struct qstr *qstr, int ms)
178{
179 const char *name;
180 int len;
181
182 len = qstr->len;
183 name = qstr->name;
184 if (ms) {
185 while (len && name[len-1] == '.')
186 len--;
187 }
188
189 qstr->hash = full_name_hash(name, len);
190
191 return 0;
192}
193
194/*
195 * Compute the hash for the isofs name corresponding to the dentry.
196 */
197static int
198isofs_hashi_common(struct qstr *qstr, int ms) 177isofs_hashi_common(struct qstr *qstr, int ms)
199{ 178{
200 const char *name; 179 const char *name;
@@ -263,6 +242,27 @@ isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry,
263} 242}
264 243
265#ifdef CONFIG_JOLIET 244#ifdef CONFIG_JOLIET
245/*
246 * Compute the hash for the isofs name corresponding to the dentry.
247 */
248static int
249isofs_hash_common(struct qstr *qstr, int ms)
250{
251 const char *name;
252 int len;
253
254 len = qstr->len;
255 name = qstr->name;
256 if (ms) {
257 while (len && name[len-1] == '.')
258 len--;
259 }
260
261 qstr->hash = full_name_hash(name, len);
262
263 return 0;
264}
265
266static int 266static int
267isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr) 267isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr)
268{ 268{
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 5228f201d3d5..4f46f7a05289 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -378,7 +378,7 @@ bl_write_pagelist(struct nfs_pgio_header *header, int sync)
378 loff_t offset = header->args.offset; 378 loff_t offset = header->args.offset;
379 size_t count = header->args.count; 379 size_t count = header->args.count;
380 struct page **pages = header->args.pages; 380 struct page **pages = header->args.pages;
381 int pg_index = pg_index = header->args.pgbase >> PAGE_CACHE_SHIFT; 381 int pg_index = header->args.pgbase >> PAGE_CACHE_SHIFT;
382 unsigned int pg_len; 382 unsigned int pg_len;
383 struct blk_plug plug; 383 struct blk_plug plug;
384 int i; 384 int i;
diff --git a/fs/nfs/blocklayout/rpc_pipefs.c b/fs/nfs/blocklayout/rpc_pipefs.c
index e966c023b1b7..acbf9ca4018c 100644
--- a/fs/nfs/blocklayout/rpc_pipefs.c
+++ b/fs/nfs/blocklayout/rpc_pipefs.c
@@ -65,17 +65,18 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
65 65
66 dprintk("%s CREATING PIPEFS MESSAGE\n", __func__); 66 dprintk("%s CREATING PIPEFS MESSAGE\n", __func__);
67 67
68 mutex_lock(&nn->bl_mutex);
68 bl_pipe_msg.bl_wq = &nn->bl_wq; 69 bl_pipe_msg.bl_wq = &nn->bl_wq;
69 70
70 b->simple.len += 4; /* single volume */ 71 b->simple.len += 4; /* single volume */
71 if (b->simple.len > PAGE_SIZE) 72 if (b->simple.len > PAGE_SIZE)
72 return -EIO; 73 goto out_unlock;
73 74
74 memset(msg, 0, sizeof(*msg)); 75 memset(msg, 0, sizeof(*msg));
75 msg->len = sizeof(*bl_msg) + b->simple.len; 76 msg->len = sizeof(*bl_msg) + b->simple.len;
76 msg->data = kzalloc(msg->len, gfp_mask); 77 msg->data = kzalloc(msg->len, gfp_mask);
77 if (!msg->data) 78 if (!msg->data)
78 goto out; 79 goto out_free_data;
79 80
80 bl_msg = msg->data; 81 bl_msg = msg->data;
81 bl_msg->type = BL_DEVICE_MOUNT, 82 bl_msg->type = BL_DEVICE_MOUNT,
@@ -87,7 +88,7 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
87 rc = rpc_queue_upcall(nn->bl_device_pipe, msg); 88 rc = rpc_queue_upcall(nn->bl_device_pipe, msg);
88 if (rc < 0) { 89 if (rc < 0) {
89 remove_wait_queue(&nn->bl_wq, &wq); 90 remove_wait_queue(&nn->bl_wq, &wq);
90 goto out; 91 goto out_free_data;
91 } 92 }
92 93
93 set_current_state(TASK_UNINTERRUPTIBLE); 94 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -97,12 +98,14 @@ bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
97 if (reply->status != BL_DEVICE_REQUEST_PROC) { 98 if (reply->status != BL_DEVICE_REQUEST_PROC) {
98 printk(KERN_WARNING "%s failed to decode device: %d\n", 99 printk(KERN_WARNING "%s failed to decode device: %d\n",
99 __func__, reply->status); 100 __func__, reply->status);
100 goto out; 101 goto out_free_data;
101 } 102 }
102 103
103 dev = MKDEV(reply->major, reply->minor); 104 dev = MKDEV(reply->major, reply->minor);
104out: 105out_free_data:
105 kfree(msg->data); 106 kfree(msg->data);
107out_unlock:
108 mutex_unlock(&nn->bl_mutex);
106 return dev; 109 return dev;
107} 110}
108 111
@@ -232,6 +235,7 @@ static int nfs4blocklayout_net_init(struct net *net)
232 struct nfs_net *nn = net_generic(net, nfs_net_id); 235 struct nfs_net *nn = net_generic(net, nfs_net_id);
233 struct dentry *dentry; 236 struct dentry *dentry;
234 237
238 mutex_init(&nn->bl_mutex);
235 init_waitqueue_head(&nn->bl_wq); 239 init_waitqueue_head(&nn->bl_wq);
236 nn->bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0); 240 nn->bl_device_pipe = rpc_mkpipe_data(&bl_upcall_ops, 0);
237 if (IS_ERR(nn->bl_device_pipe)) 241 if (IS_ERR(nn->bl_device_pipe))
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 5853f53db732..7f3f60641344 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -125,6 +125,8 @@ again:
125 continue; 125 continue;
126 if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) 126 if (!test_bit(NFS_DELEGATED_STATE, &state->flags))
127 continue; 127 continue;
128 if (!nfs4_valid_open_stateid(state))
129 continue;
128 if (!nfs4_stateid_match(&state->stateid, stateid)) 130 if (!nfs4_stateid_match(&state->stateid, stateid))
129 continue; 131 continue;
130 get_nfs_open_context(ctx); 132 get_nfs_open_context(ctx);
@@ -193,7 +195,11 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *
193{ 195{
194 int res = 0; 196 int res = 0;
195 197
196 res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid, issync); 198 if (!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
199 res = nfs4_proc_delegreturn(inode,
200 delegation->cred,
201 &delegation->stateid,
202 issync);
197 nfs_free_delegation(delegation); 203 nfs_free_delegation(delegation);
198 return res; 204 return res;
199} 205}
@@ -380,11 +386,13 @@ static int nfs_end_delegation_return(struct inode *inode, struct nfs_delegation
380{ 386{
381 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; 387 struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
382 struct nfs_inode *nfsi = NFS_I(inode); 388 struct nfs_inode *nfsi = NFS_I(inode);
383 int err; 389 int err = 0;
384 390
385 if (delegation == NULL) 391 if (delegation == NULL)
386 return 0; 392 return 0;
387 do { 393 do {
394 if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags))
395 break;
388 err = nfs_delegation_claim_opens(inode, &delegation->stateid); 396 err = nfs_delegation_claim_opens(inode, &delegation->stateid);
389 if (!issync || err != -EAGAIN) 397 if (!issync || err != -EAGAIN)
390 break; 398 break;
@@ -605,10 +613,23 @@ static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *cl
605 rcu_read_unlock(); 613 rcu_read_unlock();
606} 614}
607 615
616static void nfs_revoke_delegation(struct inode *inode)
617{
618 struct nfs_delegation *delegation;
619 rcu_read_lock();
620 delegation = rcu_dereference(NFS_I(inode)->delegation);
621 if (delegation != NULL) {
622 set_bit(NFS_DELEGATION_REVOKED, &delegation->flags);
623 nfs_mark_return_delegation(NFS_SERVER(inode), delegation);
624 }
625 rcu_read_unlock();
626}
627
608void nfs_remove_bad_delegation(struct inode *inode) 628void nfs_remove_bad_delegation(struct inode *inode)
609{ 629{
610 struct nfs_delegation *delegation; 630 struct nfs_delegation *delegation;
611 631
632 nfs_revoke_delegation(inode);
612 delegation = nfs_inode_detach_delegation(inode); 633 delegation = nfs_inode_detach_delegation(inode);
613 if (delegation) { 634 if (delegation) {
614 nfs_inode_find_state_and_recover(inode, &delegation->stateid); 635 nfs_inode_find_state_and_recover(inode, &delegation->stateid);
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 5c1cce39297f..e3c20a3ccc93 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -31,6 +31,7 @@ enum {
31 NFS_DELEGATION_RETURN_IF_CLOSED, 31 NFS_DELEGATION_RETURN_IF_CLOSED,
32 NFS_DELEGATION_REFERENCED, 32 NFS_DELEGATION_REFERENCED,
33 NFS_DELEGATION_RETURNING, 33 NFS_DELEGATION_RETURNING,
34 NFS_DELEGATION_REVOKED,
34}; 35};
35 36
36int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); 37int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 06e8cfcbb670..6e62155abf26 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1527,6 +1527,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1527 case -ENOENT: 1527 case -ENOENT:
1528 d_drop(dentry); 1528 d_drop(dentry);
1529 d_add(dentry, NULL); 1529 d_add(dentry, NULL);
1530 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1530 break; 1531 break;
1531 case -EISDIR: 1532 case -EISDIR:
1532 case -ENOTDIR: 1533 case -ENOTDIR:
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 20cffc830468..10bf07280f4a 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -266,6 +266,7 @@ static void nfs_direct_req_free(struct kref *kref)
266{ 266{
267 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); 267 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref);
268 268
269 nfs_free_pnfs_ds_cinfo(&dreq->ds_cinfo);
269 if (dreq->l_ctx != NULL) 270 if (dreq->l_ctx != NULL)
270 nfs_put_lock_context(dreq->l_ctx); 271 nfs_put_lock_context(dreq->l_ctx);
271 if (dreq->ctx != NULL) 272 if (dreq->ctx != NULL)
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 46fab1cb455a..7afb52f6a25a 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -145,9 +145,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,
145 case -NFS4ERR_DELEG_REVOKED: 145 case -NFS4ERR_DELEG_REVOKED:
146 case -NFS4ERR_ADMIN_REVOKED: 146 case -NFS4ERR_ADMIN_REVOKED:
147 case -NFS4ERR_BAD_STATEID: 147 case -NFS4ERR_BAD_STATEID:
148 if (state == NULL)
149 break;
150 nfs_remove_bad_delegation(state->inode);
151 case -NFS4ERR_OPENMODE: 148 case -NFS4ERR_OPENMODE:
152 if (state == NULL) 149 if (state == NULL)
153 break; 150 break;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6388a59f2add..00689a8a85e4 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -626,7 +626,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
626{ 626{
627 struct inode *inode = dentry->d_inode; 627 struct inode *inode = dentry->d_inode;
628 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; 628 int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
629 int err; 629 int err = 0;
630 630
631 trace_nfs_getattr_enter(inode); 631 trace_nfs_getattr_enter(inode);
632 /* Flush out writes to the server in order to update c/mtime. */ 632 /* Flush out writes to the server in order to update c/mtime. */
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index ef221fb8a183..f0e06e4acbef 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -19,6 +19,7 @@ struct nfs_net {
19 struct rpc_pipe *bl_device_pipe; 19 struct rpc_pipe *bl_device_pipe;
20 struct bl_dev_msg bl_mount_reply; 20 struct bl_dev_msg bl_mount_reply;
21 wait_queue_head_t bl_wq; 21 wait_queue_head_t bl_wq;
22 struct mutex bl_mutex;
22 struct list_head nfs_client_list; 23 struct list_head nfs_client_list;
23 struct list_head nfs_volume_list; 24 struct list_head nfs_volume_list;
24#if IS_ENABLED(CONFIG_NFS_V4) 25#if IS_ENABLED(CONFIG_NFS_V4)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 405bd95c1f58..69dc20a743f9 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -370,11 +370,6 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
370 case -NFS4ERR_DELEG_REVOKED: 370 case -NFS4ERR_DELEG_REVOKED:
371 case -NFS4ERR_ADMIN_REVOKED: 371 case -NFS4ERR_ADMIN_REVOKED:
372 case -NFS4ERR_BAD_STATEID: 372 case -NFS4ERR_BAD_STATEID:
373 if (inode != NULL && nfs4_have_delegation(inode, FMODE_READ)) {
374 nfs_remove_bad_delegation(inode);
375 exception->retry = 1;
376 break;
377 }
378 if (state == NULL) 373 if (state == NULL)
379 break; 374 break;
380 ret = nfs4_schedule_stateid_recovery(server, state); 375 ret = nfs4_schedule_stateid_recovery(server, state);
@@ -1654,7 +1649,7 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct
1654 nfs_inode_find_state_and_recover(state->inode, 1649 nfs_inode_find_state_and_recover(state->inode,
1655 stateid); 1650 stateid);
1656 nfs4_schedule_stateid_recovery(server, state); 1651 nfs4_schedule_stateid_recovery(server, state);
1657 return 0; 1652 return -EAGAIN;
1658 case -NFS4ERR_DELAY: 1653 case -NFS4ERR_DELAY:
1659 case -NFS4ERR_GRACE: 1654 case -NFS4ERR_GRACE:
1660 set_bit(NFS_DELEGATED_STATE, &state->flags); 1655 set_bit(NFS_DELEGATED_STATE, &state->flags);
@@ -2109,46 +2104,60 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *sta
2109 return ret; 2104 return ret;
2110} 2105}
2111 2106
2107static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state)
2108{
2109 nfs_remove_bad_delegation(state->inode);
2110 write_seqlock(&state->seqlock);
2111 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2112 write_sequnlock(&state->seqlock);
2113 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2114}
2115
2116static void nfs40_clear_delegation_stateid(struct nfs4_state *state)
2117{
2118 if (rcu_access_pointer(NFS_I(state->inode)->delegation) != NULL)
2119 nfs_finish_clear_delegation_stateid(state);
2120}
2121
2122static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state)
2123{
2124 /* NFSv4.0 doesn't allow for delegation recovery on open expire */
2125 nfs40_clear_delegation_stateid(state);
2126 return nfs4_open_expired(sp, state);
2127}
2128
2112#if defined(CONFIG_NFS_V4_1) 2129#if defined(CONFIG_NFS_V4_1)
2113static void nfs41_clear_delegation_stateid(struct nfs4_state *state) 2130static void nfs41_check_delegation_stateid(struct nfs4_state *state)
2114{ 2131{
2115 struct nfs_server *server = NFS_SERVER(state->inode); 2132 struct nfs_server *server = NFS_SERVER(state->inode);
2116 nfs4_stateid *stateid = &state->stateid; 2133 nfs4_stateid stateid;
2117 struct nfs_delegation *delegation; 2134 struct nfs_delegation *delegation;
2118 struct rpc_cred *cred = NULL; 2135 struct rpc_cred *cred;
2119 int status = -NFS4ERR_BAD_STATEID; 2136 int status;
2120
2121 /* If a state reset has been done, test_stateid is unneeded */
2122 if (test_bit(NFS_DELEGATED_STATE, &state->flags) == 0)
2123 return;
2124 2137
2125 /* Get the delegation credential for use by test/free_stateid */ 2138 /* Get the delegation credential for use by test/free_stateid */
2126 rcu_read_lock(); 2139 rcu_read_lock();
2127 delegation = rcu_dereference(NFS_I(state->inode)->delegation); 2140 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
2128 if (delegation != NULL && 2141 if (delegation == NULL) {
2129 nfs4_stateid_match(&delegation->stateid, stateid)) {
2130 cred = get_rpccred(delegation->cred);
2131 rcu_read_unlock();
2132 status = nfs41_test_stateid(server, stateid, cred);
2133 trace_nfs4_test_delegation_stateid(state, NULL, status);
2134 } else
2135 rcu_read_unlock(); 2142 rcu_read_unlock();
2143 return;
2144 }
2145
2146 nfs4_stateid_copy(&stateid, &delegation->stateid);
2147 cred = get_rpccred(delegation->cred);
2148 rcu_read_unlock();
2149 status = nfs41_test_stateid(server, &stateid, cred);
2150 trace_nfs4_test_delegation_stateid(state, NULL, status);
2136 2151
2137 if (status != NFS_OK) { 2152 if (status != NFS_OK) {
2138 /* Free the stateid unless the server explicitly 2153 /* Free the stateid unless the server explicitly
2139 * informs us the stateid is unrecognized. */ 2154 * informs us the stateid is unrecognized. */
2140 if (status != -NFS4ERR_BAD_STATEID) 2155 if (status != -NFS4ERR_BAD_STATEID)
2141 nfs41_free_stateid(server, stateid, cred); 2156 nfs41_free_stateid(server, &stateid, cred);
2142 nfs_remove_bad_delegation(state->inode); 2157 nfs_finish_clear_delegation_stateid(state);
2143
2144 write_seqlock(&state->seqlock);
2145 nfs4_stateid_copy(&state->stateid, &state->open_stateid);
2146 write_sequnlock(&state->seqlock);
2147 clear_bit(NFS_DELEGATED_STATE, &state->flags);
2148 } 2158 }
2149 2159
2150 if (cred != NULL) 2160 put_rpccred(cred);
2151 put_rpccred(cred);
2152} 2161}
2153 2162
2154/** 2163/**
@@ -2192,7 +2201,7 @@ static int nfs41_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st
2192{ 2201{
2193 int status; 2202 int status;
2194 2203
2195 nfs41_clear_delegation_stateid(state); 2204 nfs41_check_delegation_stateid(state);
2196 status = nfs41_check_open_stateid(state); 2205 status = nfs41_check_open_stateid(state);
2197 if (status != NFS_OK) 2206 if (status != NFS_OK)
2198 status = nfs4_open_expired(sp, state); 2207 status = nfs4_open_expired(sp, state);
@@ -2231,19 +2240,8 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2231 seq = raw_seqcount_begin(&sp->so_reclaim_seqcount); 2240 seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
2232 2241
2233 ret = _nfs4_proc_open(opendata); 2242 ret = _nfs4_proc_open(opendata);
2234 if (ret != 0) { 2243 if (ret != 0)
2235 if (ret == -ENOENT) {
2236 dentry = opendata->dentry;
2237 if (dentry->d_inode)
2238 d_delete(dentry);
2239 else if (d_unhashed(dentry))
2240 d_add(dentry, NULL);
2241
2242 nfs_set_verifier(dentry,
2243 nfs_save_change_attribute(opendata->dir->d_inode));
2244 }
2245 goto out; 2244 goto out;
2246 }
2247 2245
2248 state = nfs4_opendata_to_nfs4_state(opendata); 2246 state = nfs4_opendata_to_nfs4_state(opendata);
2249 ret = PTR_ERR(state); 2247 ret = PTR_ERR(state);
@@ -4841,9 +4839,6 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
4841 case -NFS4ERR_DELEG_REVOKED: 4839 case -NFS4ERR_DELEG_REVOKED:
4842 case -NFS4ERR_ADMIN_REVOKED: 4840 case -NFS4ERR_ADMIN_REVOKED:
4843 case -NFS4ERR_BAD_STATEID: 4841 case -NFS4ERR_BAD_STATEID:
4844 if (state == NULL)
4845 break;
4846 nfs_remove_bad_delegation(state->inode);
4847 case -NFS4ERR_OPENMODE: 4842 case -NFS4ERR_OPENMODE:
4848 if (state == NULL) 4843 if (state == NULL)
4849 break; 4844 break;
@@ -8341,7 +8336,7 @@ static const struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = {
8341static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = { 8336static const struct nfs4_state_recovery_ops nfs40_nograce_recovery_ops = {
8342 .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE, 8337 .owner_flag_bit = NFS_OWNER_RECLAIM_NOGRACE,
8343 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, 8338 .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE,
8344 .recover_open = nfs4_open_expired, 8339 .recover_open = nfs40_open_expired,
8345 .recover_lock = nfs4_lock_expired, 8340 .recover_lock = nfs4_lock_expired,
8346 .establish_clid = nfs4_init_clientid, 8341 .establish_clid = nfs4_init_clientid,
8347}; 8342};
@@ -8408,8 +8403,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
8408 | NFS_CAP_CHANGE_ATTR 8403 | NFS_CAP_CHANGE_ATTR
8409 | NFS_CAP_POSIX_LOCK 8404 | NFS_CAP_POSIX_LOCK
8410 | NFS_CAP_STATEID_NFSV41 8405 | NFS_CAP_STATEID_NFSV41
8411 | NFS_CAP_ATOMIC_OPEN_V1 8406 | NFS_CAP_ATOMIC_OPEN_V1,
8412 | NFS_CAP_SEEK,
8413 .init_client = nfs41_init_client, 8407 .init_client = nfs41_init_client,
8414 .shutdown_client = nfs41_shutdown_client, 8408 .shutdown_client = nfs41_shutdown_client,
8415 .match_stateid = nfs41_match_stateid, 8409 .match_stateid = nfs41_match_stateid,
@@ -8431,7 +8425,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
8431 | NFS_CAP_CHANGE_ATTR 8425 | NFS_CAP_CHANGE_ATTR
8432 | NFS_CAP_POSIX_LOCK 8426 | NFS_CAP_POSIX_LOCK
8433 | NFS_CAP_STATEID_NFSV41 8427 | NFS_CAP_STATEID_NFSV41
8434 | NFS_CAP_ATOMIC_OPEN_V1, 8428 | NFS_CAP_ATOMIC_OPEN_V1
8429 | NFS_CAP_SEEK,
8435 .init_client = nfs41_init_client, 8430 .init_client = nfs41_init_client,
8436 .shutdown_client = nfs41_shutdown_client, 8431 .shutdown_client = nfs41_shutdown_client,
8437 .match_stateid = nfs41_match_stateid, 8432 .match_stateid = nfs41_match_stateid,
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 12493846a2d3..f83b02dc9166 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -715,8 +715,6 @@ static void nfs_inode_remove_request(struct nfs_page *req)
715 715
716 if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) 716 if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags))
717 nfs_release_request(req); 717 nfs_release_request(req);
718 else
719 WARN_ON_ONCE(1);
720} 718}
721 719
722static void 720static void
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index ed2b1151b171..7cbdf1b2e4ab 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -774,8 +774,12 @@ static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task)
774{ 774{
775 if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) { 775 if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
776 rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); 776 rpc_sleep_on(&clp->cl_cb_waitq, task, NULL);
777 dprintk("%s slot is busy\n", __func__); 777 /* Race breaker */
778 return false; 778 if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
779 dprintk("%s slot is busy\n", __func__);
780 return false;
781 }
782 rpc_wake_up_queued_task(&clp->cl_cb_waitq, task);
779 } 783 }
780 return true; 784 return true;
781} 785}
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 747f3b95bd11..33a46a8dfaf7 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -335,12 +335,15 @@ void nfsd_lockd_shutdown(void);
335 (NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT) 335 (NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT)
336 336
337#ifdef CONFIG_NFSD_V4_SECURITY_LABEL 337#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
338#define NFSD4_2_SUPPORTED_ATTRS_WORD2 \ 338#define NFSD4_2_SECURITY_ATTRS FATTR4_WORD2_SECURITY_LABEL
339 (NFSD4_1_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SECURITY_LABEL)
340#else 339#else
341#define NFSD4_2_SUPPORTED_ATTRS_WORD2 0 340#define NFSD4_2_SECURITY_ATTRS 0
342#endif 341#endif
343 342
343#define NFSD4_2_SUPPORTED_ATTRS_WORD2 \
344 (NFSD4_1_SUPPORTED_ATTRS_WORD2 | \
345 NFSD4_2_SECURITY_ATTRS)
346
344static inline u32 nfsd_suppattrs0(u32 minorversion) 347static inline u32 nfsd_suppattrs0(u32 minorversion)
345{ 348{
346 return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD0 349 return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD0
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 9d3e9c50066a..89326acd4561 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -229,8 +229,16 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
229 &fsnotify_mark_srcu); 229 &fsnotify_mark_srcu);
230 } 230 }
231 231
232 /*
233 * We need to merge inode & vfsmount mark lists so that inode mark
234 * ignore masks are properly reflected for mount mark notifications.
235 * That's why this traversal is so complicated...
236 */
232 while (inode_node || vfsmount_node) { 237 while (inode_node || vfsmount_node) {
233 inode_group = vfsmount_group = NULL; 238 inode_group = NULL;
239 inode_mark = NULL;
240 vfsmount_group = NULL;
241 vfsmount_mark = NULL;
234 242
235 if (inode_node) { 243 if (inode_node) {
236 inode_mark = hlist_entry(srcu_dereference(inode_node, &fsnotify_mark_srcu), 244 inode_mark = hlist_entry(srcu_dereference(inode_node, &fsnotify_mark_srcu),
@@ -244,21 +252,19 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
244 vfsmount_group = vfsmount_mark->group; 252 vfsmount_group = vfsmount_mark->group;
245 } 253 }
246 254
247 if (inode_group > vfsmount_group) { 255 if (inode_group && vfsmount_group) {
248 /* handle inode */ 256 int cmp = fsnotify_compare_groups(inode_group,
249 ret = send_to_group(to_tell, inode_mark, NULL, mask, 257 vfsmount_group);
250 data, data_is, cookie, file_name); 258 if (cmp > 0) {
251 /* we didn't use the vfsmount_mark */ 259 inode_group = NULL;
252 vfsmount_group = NULL; 260 inode_mark = NULL;
253 } else if (vfsmount_group > inode_group) { 261 } else if (cmp < 0) {
254 ret = send_to_group(to_tell, NULL, vfsmount_mark, mask, 262 vfsmount_group = NULL;
255 data, data_is, cookie, file_name); 263 vfsmount_mark = NULL;
256 inode_group = NULL; 264 }
257 } else {
258 ret = send_to_group(to_tell, inode_mark, vfsmount_mark,
259 mask, data, data_is, cookie,
260 file_name);
261 } 265 }
266 ret = send_to_group(to_tell, inode_mark, vfsmount_mark, mask,
267 data, data_is, cookie, file_name);
262 268
263 if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS)) 269 if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS))
264 goto out; 270 goto out;
diff --git a/fs/notify/fsnotify.h b/fs/notify/fsnotify.h
index 9c0898c4cfe1..3b68b0ae0a97 100644
--- a/fs/notify/fsnotify.h
+++ b/fs/notify/fsnotify.h
@@ -12,6 +12,10 @@ extern void fsnotify_flush_notify(struct fsnotify_group *group);
12/* protects reads of inode and vfsmount marks list */ 12/* protects reads of inode and vfsmount marks list */
13extern struct srcu_struct fsnotify_mark_srcu; 13extern struct srcu_struct fsnotify_mark_srcu;
14 14
15/* compare two groups for sorting of marks lists */
16extern int fsnotify_compare_groups(struct fsnotify_group *a,
17 struct fsnotify_group *b);
18
15extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark, 19extern void fsnotify_set_inode_mark_mask_locked(struct fsnotify_mark *fsn_mark,
16 __u32 mask); 20 __u32 mask);
17/* add a mark to an inode */ 21/* add a mark to an inode */
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index e8497144b323..dfbf5447eea4 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -194,6 +194,7 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
194{ 194{
195 struct fsnotify_mark *lmark, *last = NULL; 195 struct fsnotify_mark *lmark, *last = NULL;
196 int ret = 0; 196 int ret = 0;
197 int cmp;
197 198
198 mark->flags |= FSNOTIFY_MARK_FLAG_INODE; 199 mark->flags |= FSNOTIFY_MARK_FLAG_INODE;
199 200
@@ -219,11 +220,8 @@ int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
219 goto out; 220 goto out;
220 } 221 }
221 222
222 if (mark->group->priority < lmark->group->priority) 223 cmp = fsnotify_compare_groups(lmark->group, mark->group);
223 continue; 224 if (cmp < 0)
224
225 if ((mark->group->priority == lmark->group->priority) &&
226 (mark->group < lmark->group))
227 continue; 225 continue;
228 226
229 hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list); 227 hlist_add_before_rcu(&mark->i.i_list, &lmark->i.i_list);
diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index d90deaa08e78..34c38fabf514 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -210,6 +210,42 @@ void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mas
210} 210}
211 211
212/* 212/*
213 * Sorting function for lists of fsnotify marks.
214 *
215 * Fanotify supports different notification classes (reflected as priority of
216 * notification group). Events shall be passed to notification groups in
217 * decreasing priority order. To achieve this marks in notification lists for
218 * inodes and vfsmounts are sorted so that priorities of corresponding groups
219 * are descending.
220 *
221 * Furthermore correct handling of the ignore mask requires processing inode
222 * and vfsmount marks of each group together. Using the group address as
223 * further sort criterion provides a unique sorting order and thus we can
224 * merge inode and vfsmount lists of marks in linear time and find groups
225 * present in both lists.
226 *
227 * A return value of 1 signifies that b has priority over a.
228 * A return value of 0 signifies that the two marks have to be handled together.
229 * A return value of -1 signifies that a has priority over b.
230 */
231int fsnotify_compare_groups(struct fsnotify_group *a, struct fsnotify_group *b)
232{
233 if (a == b)
234 return 0;
235 if (!a)
236 return 1;
237 if (!b)
238 return -1;
239 if (a->priority < b->priority)
240 return 1;
241 if (a->priority > b->priority)
242 return -1;
243 if (a < b)
244 return 1;
245 return -1;
246}
247
248/*
213 * Attach an initialized mark to a given group and fs object. 249 * Attach an initialized mark to a given group and fs object.
214 * These marks may be used for the fsnotify backend to determine which 250 * These marks may be used for the fsnotify backend to determine which
215 * event types should be delivered to which group. 251 * event types should be delivered to which group.
diff --git a/fs/notify/vfsmount_mark.c b/fs/notify/vfsmount_mark.c
index ac851e8376b1..faefa72a11eb 100644
--- a/fs/notify/vfsmount_mark.c
+++ b/fs/notify/vfsmount_mark.c
@@ -153,6 +153,7 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
153 struct mount *m = real_mount(mnt); 153 struct mount *m = real_mount(mnt);
154 struct fsnotify_mark *lmark, *last = NULL; 154 struct fsnotify_mark *lmark, *last = NULL;
155 int ret = 0; 155 int ret = 0;
156 int cmp;
156 157
157 mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT; 158 mark->flags |= FSNOTIFY_MARK_FLAG_VFSMOUNT;
158 159
@@ -178,11 +179,8 @@ int fsnotify_add_vfsmount_mark(struct fsnotify_mark *mark,
178 goto out; 179 goto out;
179 } 180 }
180 181
181 if (mark->group->priority < lmark->group->priority) 182 cmp = fsnotify_compare_groups(lmark->group, mark->group);
182 continue; 183 if (cmp < 0)
183
184 if ((mark->group->priority == lmark->group->priority) &&
185 (mark->group < lmark->group))
186 continue; 184 continue;
187 185
188 hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list); 186 hlist_add_before_rcu(&mark->m.m_list, &lmark->m.m_list);
diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig
index e60125976873..34355818a2e0 100644
--- a/fs/overlayfs/Kconfig
+++ b/fs/overlayfs/Kconfig
@@ -1,4 +1,4 @@
1config OVERLAYFS_FS 1config OVERLAY_FS
2 tristate "Overlay filesystem support" 2 tristate "Overlay filesystem support"
3 help 3 help
4 An overlay filesystem combines two filesystems - an 'upper' filesystem 4 An overlay filesystem combines two filesystems - an 'upper' filesystem
diff --git a/fs/overlayfs/Makefile b/fs/overlayfs/Makefile
index 8f91889480d0..900daed3e91d 100644
--- a/fs/overlayfs/Makefile
+++ b/fs/overlayfs/Makefile
@@ -2,6 +2,6 @@
2# Makefile for the overlay filesystem. 2# Makefile for the overlay filesystem.
3# 3#
4 4
5obj-$(CONFIG_OVERLAYFS_FS) += overlayfs.o 5obj-$(CONFIG_OVERLAY_FS) += overlay.o
6 6
7overlayfs-objs := super.o inode.o dir.o readdir.o copy_up.o 7overlay-objs := super.o inode.o dir.o readdir.o copy_up.o
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 15cd91ad9940..8ffc4b980f1b 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -284,8 +284,7 @@ out:
284 return ERR_PTR(err); 284 return ERR_PTR(err);
285} 285}
286 286
287static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry, 287static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry)
288 enum ovl_path_type type)
289{ 288{
290 int err; 289 int err;
291 struct dentry *ret = NULL; 290 struct dentry *ret = NULL;
@@ -294,8 +293,17 @@ static struct dentry *ovl_check_empty_and_clear(struct dentry *dentry,
294 err = ovl_check_empty_dir(dentry, &list); 293 err = ovl_check_empty_dir(dentry, &list);
295 if (err) 294 if (err)
296 ret = ERR_PTR(err); 295 ret = ERR_PTR(err);
297 else if (type == OVL_PATH_MERGE) 296 else {
298 ret = ovl_clear_empty(dentry, &list); 297 /*
298 * If no upperdentry then skip clearing whiteouts.
299 *
300 * Can race with copy-up, since we don't hold the upperdir
301 * mutex. Doesn't matter, since copy-up can't create a
302 * non-empty directory from an empty one.
303 */
304 if (ovl_dentry_upper(dentry))
305 ret = ovl_clear_empty(dentry, &list);
306 }
299 307
300 ovl_cache_free(&list); 308 ovl_cache_free(&list);
301 309
@@ -487,8 +495,7 @@ out:
487 return err; 495 return err;
488} 496}
489 497
490static int ovl_remove_and_whiteout(struct dentry *dentry, 498static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
491 enum ovl_path_type type, bool is_dir)
492{ 499{
493 struct dentry *workdir = ovl_workdir(dentry); 500 struct dentry *workdir = ovl_workdir(dentry);
494 struct inode *wdir = workdir->d_inode; 501 struct inode *wdir = workdir->d_inode;
@@ -500,7 +507,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
500 int err; 507 int err;
501 508
502 if (is_dir) { 509 if (is_dir) {
503 opaquedir = ovl_check_empty_and_clear(dentry, type); 510 opaquedir = ovl_check_empty_and_clear(dentry);
504 err = PTR_ERR(opaquedir); 511 err = PTR_ERR(opaquedir);
505 if (IS_ERR(opaquedir)) 512 if (IS_ERR(opaquedir))
506 goto out; 513 goto out;
@@ -515,9 +522,10 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
515 if (IS_ERR(whiteout)) 522 if (IS_ERR(whiteout))
516 goto out_unlock; 523 goto out_unlock;
517 524
518 if (type == OVL_PATH_LOWER) { 525 upper = ovl_dentry_upper(dentry);
526 if (!upper) {
519 upper = lookup_one_len(dentry->d_name.name, upperdir, 527 upper = lookup_one_len(dentry->d_name.name, upperdir,
520 dentry->d_name.len); 528 dentry->d_name.len);
521 err = PTR_ERR(upper); 529 err = PTR_ERR(upper);
522 if (IS_ERR(upper)) 530 if (IS_ERR(upper))
523 goto kill_whiteout; 531 goto kill_whiteout;
@@ -529,7 +537,6 @@ static int ovl_remove_and_whiteout(struct dentry *dentry,
529 } else { 537 } else {
530 int flags = 0; 538 int flags = 0;
531 539
532 upper = ovl_dentry_upper(dentry);
533 if (opaquedir) 540 if (opaquedir)
534 upper = opaquedir; 541 upper = opaquedir;
535 err = -ESTALE; 542 err = -ESTALE;
@@ -648,7 +655,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
648 cap_raise(override_cred->cap_effective, CAP_CHOWN); 655 cap_raise(override_cred->cap_effective, CAP_CHOWN);
649 old_cred = override_creds(override_cred); 656 old_cred = override_creds(override_cred);
650 657
651 err = ovl_remove_and_whiteout(dentry, type, is_dir); 658 err = ovl_remove_and_whiteout(dentry, is_dir);
652 659
653 revert_creds(old_cred); 660 revert_creds(old_cred);
654 put_cred(override_cred); 661 put_cred(override_cred);
@@ -781,7 +788,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
781 } 788 }
782 789
783 if (overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) { 790 if (overwrite && (new_type == OVL_PATH_LOWER || new_type == OVL_PATH_MERGE) && new_is_dir) {
784 opaquedir = ovl_check_empty_and_clear(new, new_type); 791 opaquedir = ovl_check_empty_and_clear(new);
785 err = PTR_ERR(opaquedir); 792 err = PTR_ERR(opaquedir);
786 if (IS_ERR(opaquedir)) { 793 if (IS_ERR(opaquedir)) {
787 opaquedir = NULL; 794 opaquedir = NULL;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index af2d18c9fcee..07d74b24913b 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -235,26 +235,36 @@ out:
235 return err; 235 return err;
236} 236}
237 237
238static bool ovl_need_xattr_filter(struct dentry *dentry,
239 enum ovl_path_type type)
240{
241 return type == OVL_PATH_UPPER && S_ISDIR(dentry->d_inode->i_mode);
242}
243
238ssize_t ovl_getxattr(struct dentry *dentry, const char *name, 244ssize_t ovl_getxattr(struct dentry *dentry, const char *name,
239 void *value, size_t size) 245 void *value, size_t size)
240{ 246{
241 if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE && 247 struct path realpath;
242 ovl_is_private_xattr(name)) 248 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
249
250 if (ovl_need_xattr_filter(dentry, type) && ovl_is_private_xattr(name))
243 return -ENODATA; 251 return -ENODATA;
244 252
245 return vfs_getxattr(ovl_dentry_real(dentry), name, value, size); 253 return vfs_getxattr(realpath.dentry, name, value, size);
246} 254}
247 255
248ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size) 256ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
249{ 257{
258 struct path realpath;
259 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
250 ssize_t res; 260 ssize_t res;
251 int off; 261 int off;
252 262
253 res = vfs_listxattr(ovl_dentry_real(dentry), list, size); 263 res = vfs_listxattr(realpath.dentry, list, size);
254 if (res <= 0 || size == 0) 264 if (res <= 0 || size == 0)
255 return res; 265 return res;
256 266
257 if (ovl_path_type(dentry->d_parent) != OVL_PATH_MERGE) 267 if (!ovl_need_xattr_filter(dentry, type))
258 return res; 268 return res;
259 269
260 /* filter out private xattrs */ 270 /* filter out private xattrs */
@@ -279,17 +289,16 @@ int ovl_removexattr(struct dentry *dentry, const char *name)
279{ 289{
280 int err; 290 int err;
281 struct path realpath; 291 struct path realpath;
282 enum ovl_path_type type; 292 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
283 293
284 err = ovl_want_write(dentry); 294 err = ovl_want_write(dentry);
285 if (err) 295 if (err)
286 goto out; 296 goto out;
287 297
288 if (ovl_path_type(dentry->d_parent) == OVL_PATH_MERGE && 298 err = -ENODATA;
289 ovl_is_private_xattr(name)) 299 if (ovl_need_xattr_filter(dentry, type) && ovl_is_private_xattr(name))
290 goto out_drop_write; 300 goto out_drop_write;
291 301
292 type = ovl_path_real(dentry, &realpath);
293 if (type == OVL_PATH_LOWER) { 302 if (type == OVL_PATH_LOWER) {
294 err = vfs_getxattr(realpath.dentry, name, NULL, 0); 303 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
295 if (err < 0) 304 if (err < 0)
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 2a7ef4f8e2a6..ab1e3dcbed95 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -274,11 +274,11 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
274 return 0; 274 return 0;
275} 275}
276 276
277static inline int ovl_dir_read_merged(struct path *upperpath, 277static int ovl_dir_read_merged(struct dentry *dentry, struct list_head *list)
278 struct path *lowerpath,
279 struct list_head *list)
280{ 278{
281 int err; 279 int err;
280 struct path lowerpath;
281 struct path upperpath;
282 struct ovl_readdir_data rdd = { 282 struct ovl_readdir_data rdd = {
283 .ctx.actor = ovl_fill_merge, 283 .ctx.actor = ovl_fill_merge,
284 .list = list, 284 .list = list,
@@ -286,25 +286,28 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
286 .is_merge = false, 286 .is_merge = false,
287 }; 287 };
288 288
289 if (upperpath->dentry) { 289 ovl_path_lower(dentry, &lowerpath);
290 err = ovl_dir_read(upperpath, &rdd); 290 ovl_path_upper(dentry, &upperpath);
291
292 if (upperpath.dentry) {
293 err = ovl_dir_read(&upperpath, &rdd);
291 if (err) 294 if (err)
292 goto out; 295 goto out;
293 296
294 if (lowerpath->dentry) { 297 if (lowerpath.dentry) {
295 err = ovl_dir_mark_whiteouts(upperpath->dentry, &rdd); 298 err = ovl_dir_mark_whiteouts(upperpath.dentry, &rdd);
296 if (err) 299 if (err)
297 goto out; 300 goto out;
298 } 301 }
299 } 302 }
300 if (lowerpath->dentry) { 303 if (lowerpath.dentry) {
301 /* 304 /*
302 * Insert lowerpath entries before upperpath ones, this allows 305 * Insert lowerpath entries before upperpath ones, this allows
303 * offsets to be reasonably constant 306 * offsets to be reasonably constant
304 */ 307 */
305 list_add(&rdd.middle, rdd.list); 308 list_add(&rdd.middle, rdd.list);
306 rdd.is_merge = true; 309 rdd.is_merge = true;
307 err = ovl_dir_read(lowerpath, &rdd); 310 err = ovl_dir_read(&lowerpath, &rdd);
308 list_del(&rdd.middle); 311 list_del(&rdd.middle);
309 } 312 }
310out: 313out:
@@ -329,8 +332,6 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
329static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry) 332static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
330{ 333{
331 int res; 334 int res;
332 struct path lowerpath;
333 struct path upperpath;
334 struct ovl_dir_cache *cache; 335 struct ovl_dir_cache *cache;
335 336
336 cache = ovl_dir_cache(dentry); 337 cache = ovl_dir_cache(dentry);
@@ -347,10 +348,7 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
347 cache->refcount = 1; 348 cache->refcount = 1;
348 INIT_LIST_HEAD(&cache->entries); 349 INIT_LIST_HEAD(&cache->entries);
349 350
350 ovl_path_lower(dentry, &lowerpath); 351 res = ovl_dir_read_merged(dentry, &cache->entries);
351 ovl_path_upper(dentry, &upperpath);
352
353 res = ovl_dir_read_merged(&upperpath, &lowerpath, &cache->entries);
354 if (res) { 352 if (res) {
355 ovl_cache_free(&cache->entries); 353 ovl_cache_free(&cache->entries);
356 kfree(cache); 354 kfree(cache);
@@ -452,10 +450,10 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
452 /* 450 /*
453 * Need to check if we started out being a lower dir, but got copied up 451 * Need to check if we started out being a lower dir, but got copied up
454 */ 452 */
455 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) { 453 if (!od->is_upper && ovl_path_type(dentry) != OVL_PATH_LOWER) {
456 struct inode *inode = file_inode(file); 454 struct inode *inode = file_inode(file);
457 455
458 realfile =lockless_dereference(od->upperfile); 456 realfile = lockless_dereference(od->upperfile);
459 if (!realfile) { 457 if (!realfile) {
460 struct path upperpath; 458 struct path upperpath;
461 459
@@ -538,14 +536,9 @@ const struct file_operations ovl_dir_operations = {
538int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list) 536int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
539{ 537{
540 int err; 538 int err;
541 struct path lowerpath;
542 struct path upperpath;
543 struct ovl_cache_entry *p; 539 struct ovl_cache_entry *p;
544 540
545 ovl_path_upper(dentry, &upperpath); 541 err = ovl_dir_read_merged(dentry, list);
546 ovl_path_lower(dentry, &lowerpath);
547
548 err = ovl_dir_read_merged(&upperpath, &lowerpath, list);
549 if (err) 542 if (err)
550 return err; 543 return err;
551 544
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 08b704cebfc4..f16d318b71f8 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -24,7 +24,7 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
24MODULE_DESCRIPTION("Overlay filesystem"); 24MODULE_DESCRIPTION("Overlay filesystem");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27#define OVERLAYFS_SUPER_MAGIC 0x794c764f 27#define OVERLAYFS_SUPER_MAGIC 0x794c7630
28 28
29struct ovl_config { 29struct ovl_config {
30 char *lowerdir; 30 char *lowerdir;
@@ -84,12 +84,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
84 84
85static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe) 85static struct dentry *ovl_upperdentry_dereference(struct ovl_entry *oe)
86{ 86{
87 struct dentry *upperdentry = ACCESS_ONCE(oe->__upperdentry); 87 return lockless_dereference(oe->__upperdentry);
88 /*
89 * Make sure to order reads to upperdentry wrt ovl_dentry_update()
90 */
91 smp_read_barrier_depends();
92 return upperdentry;
93} 88}
94 89
95void ovl_path_upper(struct dentry *dentry, struct path *path) 90void ovl_path_upper(struct dentry *dentry, struct path *path)
@@ -462,11 +457,34 @@ static const match_table_t ovl_tokens = {
462 {OPT_ERR, NULL} 457 {OPT_ERR, NULL}
463}; 458};
464 459
460static char *ovl_next_opt(char **s)
461{
462 char *sbegin = *s;
463 char *p;
464
465 if (sbegin == NULL)
466 return NULL;
467
468 for (p = sbegin; *p; p++) {
469 if (*p == '\\') {
470 p++;
471 if (!*p)
472 break;
473 } else if (*p == ',') {
474 *p = '\0';
475 *s = p + 1;
476 return sbegin;
477 }
478 }
479 *s = NULL;
480 return sbegin;
481}
482
465static int ovl_parse_opt(char *opt, struct ovl_config *config) 483static int ovl_parse_opt(char *opt, struct ovl_config *config)
466{ 484{
467 char *p; 485 char *p;
468 486
469 while ((p = strsep(&opt, ",")) != NULL) { 487 while ((p = ovl_next_opt(&opt)) != NULL) {
470 int token; 488 int token;
471 substring_t args[MAX_OPT_ARGS]; 489 substring_t args[MAX_OPT_ARGS];
472 490
@@ -554,15 +572,34 @@ out_dput:
554 goto out_unlock; 572 goto out_unlock;
555} 573}
556 574
575static void ovl_unescape(char *s)
576{
577 char *d = s;
578
579 for (;; s++, d++) {
580 if (*s == '\\')
581 s++;
582 *d = *s;
583 if (!*s)
584 break;
585 }
586}
587
557static int ovl_mount_dir(const char *name, struct path *path) 588static int ovl_mount_dir(const char *name, struct path *path)
558{ 589{
559 int err; 590 int err;
591 char *tmp = kstrdup(name, GFP_KERNEL);
592
593 if (!tmp)
594 return -ENOMEM;
560 595
561 err = kern_path(name, LOOKUP_FOLLOW, path); 596 ovl_unescape(tmp);
597 err = kern_path(tmp, LOOKUP_FOLLOW, path);
562 if (err) { 598 if (err) {
563 pr_err("overlayfs: failed to resolve '%s': %i\n", name, err); 599 pr_err("overlayfs: failed to resolve '%s': %i\n", tmp, err);
564 err = -EINVAL; 600 err = -EINVAL;
565 } 601 }
602 kfree(tmp);
566 return err; 603 return err;
567} 604}
568 605
@@ -776,11 +813,11 @@ static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
776 813
777static struct file_system_type ovl_fs_type = { 814static struct file_system_type ovl_fs_type = {
778 .owner = THIS_MODULE, 815 .owner = THIS_MODULE,
779 .name = "overlayfs", 816 .name = "overlay",
780 .mount = ovl_mount, 817 .mount = ovl_mount,
781 .kill_sb = kill_anon_super, 818 .kill_sb = kill_anon_super,
782}; 819};
783MODULE_ALIAS_FS("overlayfs"); 820MODULE_ALIAS_FS("overlay");
784 821
785static int __init ovl_init(void) 822static int __init ovl_init(void)
786{ 823{
diff --git a/include/dt-bindings/clock/qcom,mmcc-apq8084.h b/include/dt-bindings/clock/qcom,mmcc-apq8084.h
index a929f86d0ddd..d72b5b35f15e 100644
--- a/include/dt-bindings/clock/qcom,mmcc-apq8084.h
+++ b/include/dt-bindings/clock/qcom,mmcc-apq8084.h
@@ -60,7 +60,7 @@
60#define ESC1_CLK_SRC 43 60#define ESC1_CLK_SRC 43
61#define HDMI_CLK_SRC 44 61#define HDMI_CLK_SRC 44
62#define VSYNC_CLK_SRC 45 62#define VSYNC_CLK_SRC 45
63#define RBCPR_CLK_SRC 46 63#define MMSS_RBCPR_CLK_SRC 46
64#define RBBMTIMER_CLK_SRC 47 64#define RBBMTIMER_CLK_SRC 47
65#define MAPLE_CLK_SRC 48 65#define MAPLE_CLK_SRC 48
66#define VDP_CLK_SRC 49 66#define VDP_CLK_SRC 49
diff --git a/include/dt-bindings/pinctrl/dra.h b/include/dt-bindings/pinctrl/dra.h
index 3d33794e4f3e..7448edff4723 100644
--- a/include/dt-bindings/pinctrl/dra.h
+++ b/include/dt-bindings/pinctrl/dra.h
@@ -40,8 +40,8 @@
40 40
41/* Active pin states */ 41/* Active pin states */
42#define PIN_OUTPUT (0 | PULL_DIS) 42#define PIN_OUTPUT (0 | PULL_DIS)
43#define PIN_OUTPUT_PULLUP (PIN_OUTPUT | PULL_ENA | PULL_UP) 43#define PIN_OUTPUT_PULLUP (PULL_UP)
44#define PIN_OUTPUT_PULLDOWN (PIN_OUTPUT | PULL_ENA) 44#define PIN_OUTPUT_PULLDOWN (0)
45#define PIN_INPUT (INPUT_EN | PULL_DIS) 45#define PIN_INPUT (INPUT_EN | PULL_DIS)
46#define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL) 46#define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL)
47#define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP) 47#define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index be5fd38bd5a0..5d858e02997f 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -18,8 +18,11 @@
18 * position @h. For example 18 * position @h. For example
19 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. 19 * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
20 */ 20 */
21#define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l)) 21#define GENMASK(h, l) \
22#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l)) 22 (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
23
24#define GENMASK_ULL(h, l) \
25 (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
23 26
24extern unsigned int __sw_hweight8(unsigned int w); 27extern unsigned int __sw_hweight8(unsigned int w);
25extern unsigned int __sw_hweight16(unsigned int w); 28extern unsigned int __sw_hweight16(unsigned int w);
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 4e2bd4c95b66..0995c2de8162 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -46,6 +46,7 @@ extern unsigned long init_bootmem_node(pg_data_t *pgdat,
46extern unsigned long init_bootmem(unsigned long addr, unsigned long memend); 46extern unsigned long init_bootmem(unsigned long addr, unsigned long memend);
47 47
48extern unsigned long free_all_bootmem(void); 48extern unsigned long free_all_bootmem(void);
49extern void reset_node_managed_pages(pg_data_t *pgdat);
49extern void reset_all_zones_managed_pages(void); 50extern void reset_all_zones_managed_pages(void);
50 51
51extern void free_bootmem_node(pg_data_t *pgdat, 52extern void free_bootmem_node(pg_data_t *pgdat,
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 6992afc6ba7f..b37ea95bc348 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -99,6 +99,12 @@ inval_skb:
99 return 1; 99 return 1;
100} 100}
101 101
102static inline bool can_is_canfd_skb(const struct sk_buff *skb)
103{
104 /* the CAN specific type of skb is identified by its data length */
105 return skb->len == CANFD_MTU;
106}
107
102/* get data length from can_dlc with sanitized can_dlc */ 108/* get data length from can_dlc with sanitized can_dlc */
103u8 can_dlc2len(u8 can_dlc); 109u8 can_dlc2len(u8 can_dlc);
104 110
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index be21af149f11..2839c639f092 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -352,7 +352,6 @@ struct clk_divider {
352#define CLK_DIVIDER_READ_ONLY BIT(5) 352#define CLK_DIVIDER_READ_ONLY BIT(5)
353 353
354extern const struct clk_ops clk_divider_ops; 354extern const struct clk_ops clk_divider_ops;
355extern const struct clk_ops clk_divider_ro_ops;
356struct clk *clk_register_divider(struct device *dev, const char *name, 355struct clk *clk_register_divider(struct device *dev, const char *name,
357 const char *parent_name, unsigned long flags, 356 const char *parent_name, unsigned long flags,
358 void __iomem *reg, u8 shift, u8 width, 357 void __iomem *reg, u8 shift, u8 width,
diff --git a/include/linux/iio/events.h b/include/linux/iio/events.h
index 8bbd7bc1043d..03fa332ad2a8 100644
--- a/include/linux/iio/events.h
+++ b/include/linux/iio/events.h
@@ -72,7 +72,7 @@ struct iio_event_data {
72 72
73#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) 73#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
74 74
75#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF) 75#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
76 76
77#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF) 77#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
78 78
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 0068708161ff..0a21fbefdfbe 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -242,7 +242,7 @@ static inline void in_dev_put(struct in_device *idev)
242static __inline__ __be32 inet_make_mask(int logmask) 242static __inline__ __be32 inet_make_mask(int logmask)
243{ 243{
244 if (logmask) 244 if (logmask)
245 return htonl(~((1<<(32-logmask))-1)); 245 return htonl(~((1U<<(32-logmask))-1));
246 return 0; 246 return 0;
247} 247}
248 248
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 8422b4ed6882..b9376cd5a187 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -77,11 +77,6 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
77 return kstat_cpu(cpu).irqs_sum; 77 return kstat_cpu(cpu).irqs_sum;
78} 78}
79 79
80/*
81 * Lock/unlock the current runqueue - to extract task statistics:
82 */
83extern unsigned long long task_delta_exec(struct task_struct *);
84
85extern void account_user_time(struct task_struct *, cputime_t, cputime_t); 80extern void account_user_time(struct task_struct *, cputime_t, cputime_t);
86extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t); 81extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t);
87extern void account_steal_time(cputime_t); 82extern void account_steal_time(cputime_t);
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index ea53b04993f2..a6059bdf7b03 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -703,7 +703,7 @@ void kvm_arch_sync_events(struct kvm *kvm);
703int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu); 703int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
704void kvm_vcpu_kick(struct kvm_vcpu *vcpu); 704void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
705 705
706bool kvm_is_mmio_pfn(pfn_t pfn); 706bool kvm_is_reserved_pfn(pfn_t pfn);
707 707
708struct kvm_irq_ack_notifier { 708struct kvm_irq_ack_notifier {
709 struct hlist_node link; 709 struct hlist_node link;
diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h
index fc17d56581b2..582e67f34054 100644
--- a/include/linux/mfd/max77693-private.h
+++ b/include/linux/mfd/max77693-private.h
@@ -330,6 +330,13 @@ enum max77693_irq_source {
330 MAX77693_IRQ_GROUP_NR, 330 MAX77693_IRQ_GROUP_NR,
331}; 331};
332 332
333#define SRC_IRQ_CHARGER BIT(0)
334#define SRC_IRQ_TOP BIT(1)
335#define SRC_IRQ_FLASH BIT(2)
336#define SRC_IRQ_MUIC BIT(3)
337#define SRC_IRQ_ALL (SRC_IRQ_CHARGER | SRC_IRQ_TOP \
338 | SRC_IRQ_FLASH | SRC_IRQ_MUIC)
339
333#define LED_IRQ_FLED2_OPEN BIT(0) 340#define LED_IRQ_FLED2_OPEN BIT(0)
334#define LED_IRQ_FLED2_SHORT BIT(1) 341#define LED_IRQ_FLED2_SHORT BIT(1)
335#define LED_IRQ_FLED1_OPEN BIT(2) 342#define LED_IRQ_FLED1_OPEN BIT(2)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 48bf12ef6620..ffe66e381c04 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -431,6 +431,15 @@ struct zone {
431 */ 431 */
432 int nr_migrate_reserve_block; 432 int nr_migrate_reserve_block;
433 433
434#ifdef CONFIG_MEMORY_ISOLATION
435 /*
436 * Number of isolated pageblock. It is used to solve incorrect
437 * freepage counting problem due to racy retrieving migratetype
438 * of pageblock. Protected by zone->lock.
439 */
440 unsigned long nr_isolate_pageblock;
441#endif
442
434#ifdef CONFIG_MEMORY_HOTPLUG 443#ifdef CONFIG_MEMORY_HOTPLUG
435 /* see spanned/present_pages for more description */ 444 /* see spanned/present_pages for more description */
436 seqlock_t span_seqlock; 445 seqlock_t span_seqlock;
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 983876f24aed..47ebb4fafd87 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1224,11 +1224,22 @@ struct nfs41_free_stateid_res {
1224 unsigned int status; 1224 unsigned int status;
1225}; 1225};
1226 1226
1227static inline void
1228nfs_free_pnfs_ds_cinfo(struct pnfs_ds_commit_info *cinfo)
1229{
1230 kfree(cinfo->buckets);
1231}
1232
1227#else 1233#else
1228 1234
1229struct pnfs_ds_commit_info { 1235struct pnfs_ds_commit_info {
1230}; 1236};
1231 1237
1238static inline void
1239nfs_free_pnfs_ds_cinfo(struct pnfs_ds_commit_info *cinfo)
1240{
1241}
1242
1232#endif /* CONFIG_NFS_V4_1 */ 1243#endif /* CONFIG_NFS_V4_1 */
1233 1244
1234#ifdef CONFIG_NFS_V4_2 1245#ifdef CONFIG_NFS_V4_2
diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h
index 3fff8e774067..2dc1e1697b45 100644
--- a/include/linux/page-isolation.h
+++ b/include/linux/page-isolation.h
@@ -2,6 +2,10 @@
2#define __LINUX_PAGEISOLATION_H 2#define __LINUX_PAGEISOLATION_H
3 3
4#ifdef CONFIG_MEMORY_ISOLATION 4#ifdef CONFIG_MEMORY_ISOLATION
5static inline bool has_isolate_pageblock(struct zone *zone)
6{
7 return zone->nr_isolate_pageblock;
8}
5static inline bool is_migrate_isolate_page(struct page *page) 9static inline bool is_migrate_isolate_page(struct page *page)
6{ 10{
7 return get_pageblock_migratetype(page) == MIGRATE_ISOLATE; 11 return get_pageblock_migratetype(page) == MIGRATE_ISOLATE;
@@ -11,6 +15,10 @@ static inline bool is_migrate_isolate(int migratetype)
11 return migratetype == MIGRATE_ISOLATE; 15 return migratetype == MIGRATE_ISOLATE;
12} 16}
13#else 17#else
18static inline bool has_isolate_pageblock(struct zone *zone)
19{
20 return false;
21}
14static inline bool is_migrate_isolate_page(struct page *page) 22static inline bool is_migrate_isolate_page(struct page *page)
15{ 23{
16 return false; 24 return false;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5be8db45e368..4c8ac5fcc224 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -331,6 +331,7 @@ struct pci_dev {
331 unsigned int is_added:1; 331 unsigned int is_added:1;
332 unsigned int is_busmaster:1; /* device is busmaster */ 332 unsigned int is_busmaster:1; /* device is busmaster */
333 unsigned int no_msi:1; /* device may not use msi */ 333 unsigned int no_msi:1; /* device may not use msi */
334 unsigned int no_64bit_msi:1; /* device may only use 32-bit MSIs */
334 unsigned int block_cfg_access:1; /* config space access is blocked */ 335 unsigned int block_cfg_access:1; /* config space access is blocked */
335 unsigned int broken_parity_status:1; /* Device generates false positive parity */ 336 unsigned int broken_parity_status:1; /* Device generates false positive parity */
336 unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */ 337 unsigned int irq_reroute_variant:2; /* device needs IRQ rerouting variant */
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index d5c89e0dd0e6..51ce60c35f4c 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -133,7 +133,13 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref,
133 /* paired with smp_store_release() in percpu_ref_reinit() */ 133 /* paired with smp_store_release() in percpu_ref_reinit() */
134 smp_read_barrier_depends(); 134 smp_read_barrier_depends();
135 135
136 if (unlikely(percpu_ptr & __PERCPU_REF_ATOMIC)) 136 /*
137 * Theoretically, the following could test just ATOMIC; however,
138 * then we'd have to mask off DEAD separately as DEAD may be
139 * visible without ATOMIC if we race with percpu_ref_kill(). DEAD
140 * implies ATOMIC anyway. Test them together.
141 */
142 if (unlikely(percpu_ptr & __PERCPU_REF_ATOMIC_DEAD))
137 return false; 143 return false;
138 144
139 *percpu_countp = (unsigned long __percpu *)percpu_ptr; 145 *percpu_countp = (unsigned long __percpu *)percpu_ptr;
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 73e938b7e937..2e0e06daf8c0 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -72,8 +72,10 @@ struct generic_pm_domain {
72 bool max_off_time_changed; 72 bool max_off_time_changed;
73 bool cached_power_down_ok; 73 bool cached_power_down_ok;
74 struct gpd_cpuidle_data *cpuidle_data; 74 struct gpd_cpuidle_data *cpuidle_data;
75 void (*attach_dev)(struct device *dev); 75 int (*attach_dev)(struct generic_pm_domain *domain,
76 void (*detach_dev)(struct device *dev); 76 struct device *dev);
77 void (*detach_dev)(struct generic_pm_domain *domain,
78 struct device *dev);
77}; 79};
78 80
79static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) 81static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -104,7 +106,7 @@ struct generic_pm_domain_data {
104 struct notifier_block nb; 106 struct notifier_block nb;
105 struct mutex lock; 107 struct mutex lock;
106 unsigned int refcount; 108 unsigned int refcount;
107 bool need_restore; 109 int need_restore;
108}; 110};
109 111
110#ifdef CONFIG_PM_GENERIC_DOMAINS 112#ifdef CONFIG_PM_GENERIC_DOMAINS
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
index 07e7945a1ff2..e97fc656a058 100644
--- a/include/linux/power/charger-manager.h
+++ b/include/linux/power/charger-manager.h
@@ -253,9 +253,6 @@ struct charger_manager {
253 struct device *dev; 253 struct device *dev;
254 struct charger_desc *desc; 254 struct charger_desc *desc;
255 255
256 struct power_supply *fuel_gauge;
257 struct power_supply **charger_stat;
258
259#ifdef CONFIG_THERMAL 256#ifdef CONFIG_THERMAL
260 struct thermal_zone_device *tzd_batt; 257 struct thermal_zone_device *tzd_batt;
261#endif 258#endif
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 3ed049673022..096dbced02ac 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -200,6 +200,12 @@ struct power_supply {
200 void (*external_power_changed)(struct power_supply *psy); 200 void (*external_power_changed)(struct power_supply *psy);
201 void (*set_charged)(struct power_supply *psy); 201 void (*set_charged)(struct power_supply *psy);
202 202
203 /*
204 * Set if thermal zone should not be created for this power supply.
205 * For example for virtual supplies forwarding calls to actual
206 * sensors or other supplies.
207 */
208 bool no_thermal;
203 /* For APM emulation, think legacy userspace. */ 209 /* For APM emulation, think legacy userspace. */
204 int use_for_apm; 210 int use_for_apm;
205 211
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 49a4d6f59108..e2c13cd863bd 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -97,7 +97,7 @@ __ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *k
97 __ring_buffer_alloc((size), (flags), &__key); \ 97 __ring_buffer_alloc((size), (flags), &__key); \
98}) 98})
99 99
100int ring_buffer_wait(struct ring_buffer *buffer, int cpu); 100int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full);
101int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu, 101int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu,
102 struct file *filp, poll_table *poll_table); 102 struct file *filp, poll_table *poll_table);
103 103
diff --git a/include/linux/socket.h b/include/linux/socket.h
index ec538fc287a6..bb9b83640070 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -256,7 +256,7 @@ struct ucred {
256#define MSG_EOF MSG_FIN 256#define MSG_EOF MSG_FIN
257 257
258#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */ 258#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
259#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exit for file 259#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file
260 descriptor received through 260 descriptor received through
261 SCM_RIGHTS */ 261 SCM_RIGHTS */
262#if defined(CONFIG_COMPAT) 262#if defined(CONFIG_COMPAT)
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index d9fa68f26c41..2a25dec30211 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -34,7 +34,6 @@
34 * @list: used to maintain a list of currently available transports 34 * @list: used to maintain a list of currently available transports
35 * @name: the human-readable name of the transport 35 * @name: the human-readable name of the transport
36 * @maxsize: transport provided maximum packet size 36 * @maxsize: transport provided maximum packet size
37 * @pref: Preferences of this transport
38 * @def: set if this transport should be considered the default 37 * @def: set if this transport should be considered the default
39 * @create: member function to create a new connection on this transport 38 * @create: member function to create a new connection on this transport
40 * @close: member function to discard a connection on this transport 39 * @close: member function to discard a connection on this transport
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index fe7994c48b75..b2828a06a5a6 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -37,6 +37,8 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
37int inet_ctl_sock_create(struct sock **sk, unsigned short family, 37int inet_ctl_sock_create(struct sock **sk, unsigned short family,
38 unsigned short type, unsigned char protocol, 38 unsigned short type, unsigned char protocol,
39 struct net *net); 39 struct net *net);
40int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
41 int *addr_len);
40 42
41static inline void inet_ctl_sock_destroy(struct sock *sk) 43static inline void inet_ctl_sock_destroy(struct sock *sk)
42{ 44{
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 845c596bf594..3ae969e3acf0 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -396,14 +396,12 @@ struct nft_rule {
396/** 396/**
397 * struct nft_trans - nf_tables object update in transaction 397 * struct nft_trans - nf_tables object update in transaction
398 * 398 *
399 * @rcu_head: rcu head to defer release of transaction data
400 * @list: used internally 399 * @list: used internally
401 * @msg_type: message type 400 * @msg_type: message type
402 * @ctx: transaction context 401 * @ctx: transaction context
403 * @data: internal information related to the transaction 402 * @data: internal information related to the transaction
404 */ 403 */
405struct nft_trans { 404struct nft_trans {
406 struct rcu_head rcu_head;
407 struct list_head list; 405 struct list_head list;
408 int msg_type; 406 int msg_type;
409 struct nft_ctx ctx; 407 struct nft_ctx ctx;
diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
index a47790bcaa38..2a50a70ef587 100644
--- a/include/net/udp_tunnel.h
+++ b/include/net/udp_tunnel.h
@@ -100,6 +100,15 @@ static inline struct sk_buff *udp_tunnel_handle_offloads(struct sk_buff *skb,
100 return iptunnel_handle_offloads(skb, udp_csum, type); 100 return iptunnel_handle_offloads(skb, udp_csum, type);
101} 101}
102 102
103static inline void udp_tunnel_gro_complete(struct sk_buff *skb, int nhoff)
104{
105 struct udphdr *uh;
106
107 uh = (struct udphdr *)(skb->data + nhoff - sizeof(struct udphdr));
108 skb_shinfo(skb)->gso_type |= uh->check ?
109 SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;
110}
111
103static inline void udp_tunnel_encap_enable(struct socket *sock) 112static inline void udp_tunnel_encap_enable(struct socket *sock)
104{ 113{
105#if IS_ENABLED(CONFIG_IPV6) 114#if IS_ENABLED(CONFIG_IPV6)
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index d5f59f3fc35d..57cccd0052e5 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -8,6 +8,12 @@
8#define VNI_HASH_BITS 10 8#define VNI_HASH_BITS 10
9#define VNI_HASH_SIZE (1<<VNI_HASH_BITS) 9#define VNI_HASH_SIZE (1<<VNI_HASH_BITS)
10 10
11/* VXLAN protocol header */
12struct vxlanhdr {
13 __be32 vx_flags;
14 __be32 vx_vni;
15};
16
11struct vxlan_sock; 17struct vxlan_sock;
12typedef void (vxlan_rcv_t)(struct vxlan_sock *vh, struct sk_buff *skb, __be32 key); 18typedef void (vxlan_rcv_t)(struct vxlan_sock *vh, struct sk_buff *skb, __be32 key);
13 19
@@ -45,6 +51,18 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
45 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df, 51 __be32 src, __be32 dst, __u8 tos, __u8 ttl, __be16 df,
46 __be16 src_port, __be16 dst_port, __be32 vni, bool xnet); 52 __be16 src_port, __be16 dst_port, __be32 vni, bool xnet);
47 53
54static inline bool vxlan_gso_check(struct sk_buff *skb)
55{
56 if ((skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) &&
57 (skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
58 skb->inner_protocol != htons(ETH_P_TEB) ||
59 (skb_inner_mac_header(skb) - skb_transport_header(skb) !=
60 sizeof(struct udphdr) + sizeof(struct vxlanhdr))))
61 return false;
62
63 return true;
64}
65
48/* IP header + UDP + VXLAN + Ethernet header */ 66/* IP header + UDP + VXLAN + Ethernet header */
49#define VXLAN_HEADROOM (20 + 8 + 8 + 14) 67#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
50/* IPv6 header + UDP + VXLAN + Ethernet header */ 68/* IPv6 header + UDP + VXLAN + Ethernet header */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index e862497f7556..8bb00a27e219 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -184,6 +184,8 @@ struct snd_pcm_ops {
184#define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8) 184#define SNDRV_PCM_FMTBIT_DSD_U8 _SNDRV_PCM_FMTBIT(DSD_U8)
185#define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE) 185#define SNDRV_PCM_FMTBIT_DSD_U16_LE _SNDRV_PCM_FMTBIT(DSD_U16_LE)
186#define SNDRV_PCM_FMTBIT_DSD_U32_LE _SNDRV_PCM_FMTBIT(DSD_U32_LE) 186#define SNDRV_PCM_FMTBIT_DSD_U32_LE _SNDRV_PCM_FMTBIT(DSD_U32_LE)
187#define SNDRV_PCM_FMTBIT_DSD_U16_BE _SNDRV_PCM_FMTBIT(DSD_U16_BE)
188#define SNDRV_PCM_FMTBIT_DSD_U32_BE _SNDRV_PCM_FMTBIT(DSD_U32_BE)
187 189
188#ifdef SNDRV_LITTLE_ENDIAN 190#ifdef SNDRV_LITTLE_ENDIAN
189#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE 191#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h
index 2883a7a6f9f3..98f2ade0266e 100644
--- a/include/sound/soc-dpcm.h
+++ b/include/sound/soc-dpcm.h
@@ -102,6 +102,8 @@ struct snd_soc_dpcm_runtime {
102 /* state and update */ 102 /* state and update */
103 enum snd_soc_dpcm_update runtime_update; 103 enum snd_soc_dpcm_update runtime_update;
104 enum snd_soc_dpcm_state state; 104 enum snd_soc_dpcm_state state;
105
106 int trigger_pending; /* trigger cmd + 1 if pending, 0 if not */
105}; 107};
106 108
107/* can this BE stop and free */ 109/* can this BE stop and free */
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild
index b70237e8bc37..4c94f31a8c99 100644
--- a/include/uapi/linux/Kbuild
+++ b/include/uapi/linux/Kbuild
@@ -125,6 +125,7 @@ header-y += filter.h
125header-y += firewire-cdev.h 125header-y += firewire-cdev.h
126header-y += firewire-constants.h 126header-y += firewire-constants.h
127header-y += flat.h 127header-y += flat.h
128header-y += fou.h
128header-y += fs.h 129header-y += fs.h
129header-y += fsl_hypervisor.h 130header-y += fsl_hypervisor.h
130header-y += fuse.h 131header-y += fuse.h
@@ -141,6 +142,7 @@ header-y += hid.h
141header-y += hiddev.h 142header-y += hiddev.h
142header-y += hidraw.h 143header-y += hidraw.h
143header-y += hpet.h 144header-y += hpet.h
145header-y += hsr_netlink.h
144header-y += hyperv.h 146header-y += hyperv.h
145header-y += hysdn_if.h 147header-y += hysdn_if.h
146header-y += i2c-dev.h 148header-y += i2c-dev.h
@@ -251,6 +253,7 @@ header-y += mii.h
251header-y += minix_fs.h 253header-y += minix_fs.h
252header-y += mman.h 254header-y += mman.h
253header-y += mmtimer.h 255header-y += mmtimer.h
256header-y += mpls.h
254header-y += mqueue.h 257header-y += mqueue.h
255header-y += mroute.h 258header-y += mroute.h
256header-y += mroute6.h 259header-y += mroute6.h
@@ -424,6 +427,7 @@ header-y += virtio_net.h
424header-y += virtio_pci.h 427header-y += virtio_pci.h
425header-y += virtio_ring.h 428header-y += virtio_ring.h
426header-y += virtio_rng.h 429header-y += virtio_rng.h
430header=y += vm_sockets.h
427header-y += vt.h 431header-y += vt.h
428header-y += wait.h 432header-y += wait.h
429header-y += wanrouter.h 433header-y += wanrouter.h
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index 39f621a9fe82..da17e456908d 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/if_ether.h> 17#include <linux/if_ether.h>
18#include <linux/in6.h>
18 19
19#define SYSFS_BRIDGE_ATTR "bridge" 20#define SYSFS_BRIDGE_ATTR "bridge"
20#define SYSFS_BRIDGE_FDB "brforward" 21#define SYSFS_BRIDGE_FDB "brforward"
diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
index 6ee586728df9..941d32f007dc 100644
--- a/include/uapi/sound/asound.h
+++ b/include/uapi/sound/asound.h
@@ -220,7 +220,9 @@ typedef int __bitwise snd_pcm_format_t;
220#define SNDRV_PCM_FORMAT_DSD_U8 ((__force snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */ 220#define SNDRV_PCM_FORMAT_DSD_U8 ((__force snd_pcm_format_t) 48) /* DSD, 1-byte samples DSD (x8) */
221#define SNDRV_PCM_FORMAT_DSD_U16_LE ((__force snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */ 221#define SNDRV_PCM_FORMAT_DSD_U16_LE ((__force snd_pcm_format_t) 49) /* DSD, 2-byte samples DSD (x16), little endian */
222#define SNDRV_PCM_FORMAT_DSD_U32_LE ((__force snd_pcm_format_t) 50) /* DSD, 4-byte samples DSD (x32), little endian */ 222#define SNDRV_PCM_FORMAT_DSD_U32_LE ((__force snd_pcm_format_t) 50) /* DSD, 4-byte samples DSD (x32), little endian */
223#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_LE 223#define SNDRV_PCM_FORMAT_DSD_U16_BE ((__force snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */
224#define SNDRV_PCM_FORMAT_DSD_U32_BE ((__force snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */
225#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE
224 226
225#ifdef SNDRV_LITTLE_ENDIAN 227#ifdef SNDRV_LITTLE_ENDIAN
226#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE 228#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE
diff --git a/init/main.c b/init/main.c
index 800a0daede7e..321d0ceb26d3 100644
--- a/init/main.c
+++ b/init/main.c
@@ -544,7 +544,7 @@ asmlinkage __visible void __init start_kernel(void)
544 static_command_line, __start___param, 544 static_command_line, __start___param,
545 __stop___param - __start___param, 545 __stop___param - __start___param,
546 -1, -1, &unknown_bootoption); 546 -1, -1, &unknown_bootoption);
547 if (after_dashes) 547 if (!IS_ERR_OR_NULL(after_dashes))
548 parse_args("Setting init args", after_dashes, NULL, 0, -1, -1, 548 parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
549 set_init_arg); 549 set_init_arg);
550 550
diff --git a/kernel/audit.c b/kernel/audit.c
index 80983df92cd4..cebb11db4d34 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -739,7 +739,7 @@ static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature
739 739
740 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_FEATURE_CHANGE); 740 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_FEATURE_CHANGE);
741 audit_log_task_info(ab, current); 741 audit_log_task_info(ab, current);
742 audit_log_format(ab, "feature=%s old=%u new=%u old_lock=%u new_lock=%u res=%d", 742 audit_log_format(ab, " feature=%s old=%u new=%u old_lock=%u new_lock=%u res=%d",
743 audit_feature_names[which], !!old_feature, !!new_feature, 743 audit_feature_names[which], !!old_feature, !!new_feature,
744 !!old_lock, !!new_lock, res); 744 !!old_lock, !!new_lock, res);
745 audit_log_end(ab); 745 audit_log_end(ab);
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index e242e3a9864a..80f29e015570 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -154,6 +154,7 @@ static struct audit_chunk *alloc_chunk(int count)
154 chunk->owners[i].index = i; 154 chunk->owners[i].index = i;
155 } 155 }
156 fsnotify_init_mark(&chunk->mark, audit_tree_destroy_watch); 156 fsnotify_init_mark(&chunk->mark, audit_tree_destroy_watch);
157 chunk->mark.mask = FS_IN_IGNORED;
157 return chunk; 158 return chunk;
158} 159}
159 160
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 2b02c9fda790..1cd5eef1fcdd 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1562,8 +1562,10 @@ static void perf_remove_from_context(struct perf_event *event, bool detach_group
1562 1562
1563 if (!task) { 1563 if (!task) {
1564 /* 1564 /*
1565 * Per cpu events are removed via an smp call and 1565 * Per cpu events are removed via an smp call. The removal can
1566 * the removal is always successful. 1566 * fail if the CPU is currently offline, but in that case we
1567 * already called __perf_remove_from_context from
1568 * perf_event_exit_cpu.
1567 */ 1569 */
1568 cpu_function_call(event->cpu, __perf_remove_from_context, &re); 1570 cpu_function_call(event->cpu, __perf_remove_from_context, &re);
1569 return; 1571 return;
@@ -8117,7 +8119,7 @@ static void perf_pmu_rotate_stop(struct pmu *pmu)
8117 8119
8118static void __perf_event_exit_context(void *__info) 8120static void __perf_event_exit_context(void *__info)
8119{ 8121{
8120 struct remove_event re = { .detach_group = false }; 8122 struct remove_event re = { .detach_group = true };
8121 struct perf_event_context *ctx = __info; 8123 struct perf_event_context *ctx = __info;
8122 8124
8123 perf_pmu_rotate_stop(ctx->pmu); 8125 perf_pmu_rotate_stop(ctx->pmu);
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index bc143cf56cab..d2a5689a6b2e 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1640,7 +1640,6 @@ bool uprobe_deny_signal(void)
1640 if (__fatal_signal_pending(t) || arch_uprobe_xol_was_trapped(t)) { 1640 if (__fatal_signal_pending(t) || arch_uprobe_xol_was_trapped(t)) {
1641 utask->state = UTASK_SSTEP_TRAPPED; 1641 utask->state = UTASK_SSTEP_TRAPPED;
1642 set_tsk_thread_flag(t, TIF_UPROBE); 1642 set_tsk_thread_flag(t, TIF_UPROBE);
1643 set_tsk_thread_flag(t, TIF_NOTIFY_RESUME);
1644 } 1643 }
1645 } 1644 }
1646 1645
diff --git a/kernel/panic.c b/kernel/panic.c
index d09dc5c32c67..cf80672b7924 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -244,6 +244,7 @@ static const struct tnt tnts[] = {
244 * 'I' - Working around severe firmware bug. 244 * 'I' - Working around severe firmware bug.
245 * 'O' - Out-of-tree module has been loaded. 245 * 'O' - Out-of-tree module has been loaded.
246 * 'E' - Unsigned module has been loaded. 246 * 'E' - Unsigned module has been loaded.
247 * 'L' - A soft lockup has previously occurred.
247 * 248 *
248 * The string is overwritten by the next call to print_tainted(). 249 * The string is overwritten by the next call to print_tainted().
249 */ 250 */
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 4ca9a33ff620..c347e3ce3a55 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -146,7 +146,7 @@ static int platform_suspend_prepare(suspend_state_t state)
146 146
147static int platform_suspend_prepare_late(suspend_state_t state) 147static int platform_suspend_prepare_late(suspend_state_t state)
148{ 148{
149 return state == PM_SUSPEND_FREEZE && freeze_ops->prepare ? 149 return state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->prepare ?
150 freeze_ops->prepare() : 0; 150 freeze_ops->prepare() : 0;
151} 151}
152 152
@@ -164,7 +164,7 @@ static void platform_resume_noirq(suspend_state_t state)
164 164
165static void platform_resume_early(suspend_state_t state) 165static void platform_resume_early(suspend_state_t state)
166{ 166{
167 if (state == PM_SUSPEND_FREEZE && freeze_ops->restore) 167 if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->restore)
168 freeze_ops->restore(); 168 freeze_ops->restore();
169} 169}
170 170
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 240157c13ddc..24beb9bb4c3e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2475,44 +2475,6 @@ EXPORT_PER_CPU_SYMBOL(kstat);
2475EXPORT_PER_CPU_SYMBOL(kernel_cpustat); 2475EXPORT_PER_CPU_SYMBOL(kernel_cpustat);
2476 2476
2477/* 2477/*
2478 * Return any ns on the sched_clock that have not yet been accounted in
2479 * @p in case that task is currently running.
2480 *
2481 * Called with task_rq_lock() held on @rq.
2482 */
2483static u64 do_task_delta_exec(struct task_struct *p, struct rq *rq)
2484{
2485 u64 ns = 0;
2486
2487 /*
2488 * Must be ->curr _and_ ->on_rq. If dequeued, we would
2489 * project cycles that may never be accounted to this
2490 * thread, breaking clock_gettime().
2491 */
2492 if (task_current(rq, p) && task_on_rq_queued(p)) {
2493 update_rq_clock(rq);
2494 ns = rq_clock_task(rq) - p->se.exec_start;
2495 if ((s64)ns < 0)
2496 ns = 0;
2497 }
2498
2499 return ns;
2500}
2501
2502unsigned long long task_delta_exec(struct task_struct *p)
2503{
2504 unsigned long flags;
2505 struct rq *rq;
2506 u64 ns = 0;
2507
2508 rq = task_rq_lock(p, &flags);
2509 ns = do_task_delta_exec(p, rq);
2510 task_rq_unlock(rq, p, &flags);
2511
2512 return ns;
2513}
2514
2515/*
2516 * Return accounted runtime for the task. 2478 * Return accounted runtime for the task.
2517 * In case the task is currently running, return the runtime plus current's 2479 * In case the task is currently running, return the runtime plus current's
2518 * pending runtime that have not been accounted yet. 2480 * pending runtime that have not been accounted yet.
@@ -2521,7 +2483,7 @@ unsigned long long task_sched_runtime(struct task_struct *p)
2521{ 2483{
2522 unsigned long flags; 2484 unsigned long flags;
2523 struct rq *rq; 2485 struct rq *rq;
2524 u64 ns = 0; 2486 u64 ns;
2525 2487
2526#if defined(CONFIG_64BIT) && defined(CONFIG_SMP) 2488#if defined(CONFIG_64BIT) && defined(CONFIG_SMP)
2527 /* 2489 /*
@@ -2540,7 +2502,16 @@ unsigned long long task_sched_runtime(struct task_struct *p)
2540#endif 2502#endif
2541 2503
2542 rq = task_rq_lock(p, &flags); 2504 rq = task_rq_lock(p, &flags);
2543 ns = p->se.sum_exec_runtime + do_task_delta_exec(p, rq); 2505 /*
2506 * Must be ->curr _and_ ->on_rq. If dequeued, we would
2507 * project cycles that may never be accounted to this
2508 * thread, breaking clock_gettime().
2509 */
2510 if (task_current(rq, p) && task_on_rq_queued(p)) {
2511 update_rq_clock(rq);
2512 p->sched_class->update_curr(rq);
2513 }
2514 ns = p->se.sum_exec_runtime;
2544 task_rq_unlock(rq, p, &flags); 2515 task_rq_unlock(rq, p, &flags);
2545 2516
2546 return ns; 2517 return ns;
@@ -6368,6 +6339,10 @@ static void sched_init_numa(void)
6368 if (!sched_debug()) 6339 if (!sched_debug())
6369 break; 6340 break;
6370 } 6341 }
6342
6343 if (!level)
6344 return;
6345
6371 /* 6346 /*
6372 * 'level' contains the number of unique distances, excluding the 6347 * 'level' contains the number of unique distances, excluding the
6373 * identity distance node_distance(i,i). 6348 * identity distance node_distance(i,i).
@@ -7444,8 +7419,12 @@ void sched_move_task(struct task_struct *tsk)
7444 if (unlikely(running)) 7419 if (unlikely(running))
7445 put_prev_task(rq, tsk); 7420 put_prev_task(rq, tsk);
7446 7421
7447 tg = container_of(task_css_check(tsk, cpu_cgrp_id, 7422 /*
7448 lockdep_is_held(&tsk->sighand->siglock)), 7423 * All callers are synchronized by task_rq_lock(); we do not use RCU
7424 * which is pointless here. Thus, we pass "true" to task_css_check()
7425 * to prevent lockdep warnings.
7426 */
7427 tg = container_of(task_css_check(tsk, cpu_cgrp_id, true),
7449 struct task_group, css); 7428 struct task_group, css);
7450 tg = autogroup_task_group(tsk, tg); 7429 tg = autogroup_task_group(tsk, tg);
7451 tsk->sched_task_group = tg; 7430 tsk->sched_task_group = tg;
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 5285332392d5..28fa9d9e9201 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1701,4 +1701,6 @@ const struct sched_class dl_sched_class = {
1701 .prio_changed = prio_changed_dl, 1701 .prio_changed = prio_changed_dl,
1702 .switched_from = switched_from_dl, 1702 .switched_from = switched_from_dl,
1703 .switched_to = switched_to_dl, 1703 .switched_to = switched_to_dl,
1704
1705 .update_curr = update_curr_dl,
1704}; 1706};
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 34baa60f8a7b..ef2b104b254c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -726,6 +726,11 @@ static void update_curr(struct cfs_rq *cfs_rq)
726 account_cfs_rq_runtime(cfs_rq, delta_exec); 726 account_cfs_rq_runtime(cfs_rq, delta_exec);
727} 727}
728 728
729static void update_curr_fair(struct rq *rq)
730{
731 update_curr(cfs_rq_of(&rq->curr->se));
732}
733
729static inline void 734static inline void
730update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) 735update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
731{ 736{
@@ -1180,6 +1185,13 @@ static void task_numa_compare(struct task_numa_env *env,
1180 raw_spin_unlock_irq(&dst_rq->lock); 1185 raw_spin_unlock_irq(&dst_rq->lock);
1181 1186
1182 /* 1187 /*
1188 * Because we have preemption enabled we can get migrated around and
1189 * end try selecting ourselves (current == env->p) as a swap candidate.
1190 */
1191 if (cur == env->p)
1192 goto unlock;
1193
1194 /*
1183 * "imp" is the fault differential for the source task between the 1195 * "imp" is the fault differential for the source task between the
1184 * source and destination node. Calculate the total differential for 1196 * source and destination node. Calculate the total differential for
1185 * the source task and potential destination task. The more negative 1197 * the source task and potential destination task. The more negative
@@ -7949,6 +7961,8 @@ const struct sched_class fair_sched_class = {
7949 7961
7950 .get_rr_interval = get_rr_interval_fair, 7962 .get_rr_interval = get_rr_interval_fair,
7951 7963
7964 .update_curr = update_curr_fair,
7965
7952#ifdef CONFIG_FAIR_GROUP_SCHED 7966#ifdef CONFIG_FAIR_GROUP_SCHED
7953 .task_move_group = task_move_group_fair, 7967 .task_move_group = task_move_group_fair,
7954#endif 7968#endif
diff --git a/kernel/sched/idle_task.c b/kernel/sched/idle_task.c
index 67ad4e7f506a..c65dac8c97cd 100644
--- a/kernel/sched/idle_task.c
+++ b/kernel/sched/idle_task.c
@@ -75,6 +75,10 @@ static unsigned int get_rr_interval_idle(struct rq *rq, struct task_struct *task
75 return 0; 75 return 0;
76} 76}
77 77
78static void update_curr_idle(struct rq *rq)
79{
80}
81
78/* 82/*
79 * Simple, special scheduling class for the per-CPU idle tasks: 83 * Simple, special scheduling class for the per-CPU idle tasks:
80 */ 84 */
@@ -101,4 +105,5 @@ const struct sched_class idle_sched_class = {
101 105
102 .prio_changed = prio_changed_idle, 106 .prio_changed = prio_changed_idle,
103 .switched_to = switched_to_idle, 107 .switched_to = switched_to_idle,
108 .update_curr = update_curr_idle,
104}; 109};
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index d024e6ce30ba..20bca398084a 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2128,6 +2128,8 @@ const struct sched_class rt_sched_class = {
2128 2128
2129 .prio_changed = prio_changed_rt, 2129 .prio_changed = prio_changed_rt,
2130 .switched_to = switched_to_rt, 2130 .switched_to = switched_to_rt,
2131
2132 .update_curr = update_curr_rt,
2131}; 2133};
2132 2134
2133#ifdef CONFIG_SCHED_DEBUG 2135#ifdef CONFIG_SCHED_DEBUG
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 24156c8434d1..2df8ef067cc5 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1135,6 +1135,8 @@ struct sched_class {
1135 unsigned int (*get_rr_interval) (struct rq *rq, 1135 unsigned int (*get_rr_interval) (struct rq *rq,
1136 struct task_struct *task); 1136 struct task_struct *task);
1137 1137
1138 void (*update_curr) (struct rq *rq);
1139
1138#ifdef CONFIG_FAIR_GROUP_SCHED 1140#ifdef CONFIG_FAIR_GROUP_SCHED
1139 void (*task_move_group) (struct task_struct *p, int on_rq); 1141 void (*task_move_group) (struct task_struct *p, int on_rq);
1140#endif 1142#endif
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index 67426e529f59..79ffec45a6ac 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -102,6 +102,10 @@ get_rr_interval_stop(struct rq *rq, struct task_struct *task)
102 return 0; 102 return 0;
103} 103}
104 104
105static void update_curr_stop(struct rq *rq)
106{
107}
108
105/* 109/*
106 * Simple, special scheduling class for the per-CPU stop tasks: 110 * Simple, special scheduling class for the per-CPU stop tasks:
107 */ 111 */
@@ -128,4 +132,5 @@ const struct sched_class stop_sched_class = {
128 132
129 .prio_changed = prio_changed_stop, 133 .prio_changed = prio_changed_stop,
130 .switched_to = switched_to_stop, 134 .switched_to = switched_to_stop,
135 .update_curr = update_curr_stop,
131}; 136};
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 492b986195d5..a16b67859e2a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -553,7 +553,7 @@ static int cpu_timer_sample_group(const clockid_t which_clock,
553 *sample = cputime_to_expires(cputime.utime); 553 *sample = cputime_to_expires(cputime.utime);
554 break; 554 break;
555 case CPUCLOCK_SCHED: 555 case CPUCLOCK_SCHED:
556 *sample = cputime.sum_exec_runtime + task_delta_exec(p); 556 *sample = cputime.sum_exec_runtime;
557 break; 557 break;
558 } 558 }
559 return 0; 559 return 0;
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2d75c94ae87d..a56e07c8d15b 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -538,16 +538,18 @@ static void rb_wake_up_waiters(struct irq_work *work)
538 * ring_buffer_wait - wait for input to the ring buffer 538 * ring_buffer_wait - wait for input to the ring buffer
539 * @buffer: buffer to wait on 539 * @buffer: buffer to wait on
540 * @cpu: the cpu buffer to wait on 540 * @cpu: the cpu buffer to wait on
541 * @full: wait until a full page is available, if @cpu != RING_BUFFER_ALL_CPUS
541 * 542 *
542 * If @cpu == RING_BUFFER_ALL_CPUS then the task will wake up as soon 543 * If @cpu == RING_BUFFER_ALL_CPUS then the task will wake up as soon
543 * as data is added to any of the @buffer's cpu buffers. Otherwise 544 * as data is added to any of the @buffer's cpu buffers. Otherwise
544 * it will wait for data to be added to a specific cpu buffer. 545 * it will wait for data to be added to a specific cpu buffer.
545 */ 546 */
546int ring_buffer_wait(struct ring_buffer *buffer, int cpu) 547int ring_buffer_wait(struct ring_buffer *buffer, int cpu, bool full)
547{ 548{
548 struct ring_buffer_per_cpu *cpu_buffer; 549 struct ring_buffer_per_cpu *uninitialized_var(cpu_buffer);
549 DEFINE_WAIT(wait); 550 DEFINE_WAIT(wait);
550 struct rb_irq_work *work; 551 struct rb_irq_work *work;
552 int ret = 0;
551 553
552 /* 554 /*
553 * Depending on what the caller is waiting for, either any 555 * Depending on what the caller is waiting for, either any
@@ -564,36 +566,61 @@ int ring_buffer_wait(struct ring_buffer *buffer, int cpu)
564 } 566 }
565 567
566 568
567 prepare_to_wait(&work->waiters, &wait, TASK_INTERRUPTIBLE); 569 while (true) {
570 prepare_to_wait(&work->waiters, &wait, TASK_INTERRUPTIBLE);
568 571
569 /* 572 /*
570 * The events can happen in critical sections where 573 * The events can happen in critical sections where
571 * checking a work queue can cause deadlocks. 574 * checking a work queue can cause deadlocks.
572 * After adding a task to the queue, this flag is set 575 * After adding a task to the queue, this flag is set
573 * only to notify events to try to wake up the queue 576 * only to notify events to try to wake up the queue
574 * using irq_work. 577 * using irq_work.
575 * 578 *
576 * We don't clear it even if the buffer is no longer 579 * We don't clear it even if the buffer is no longer
577 * empty. The flag only causes the next event to run 580 * empty. The flag only causes the next event to run
578 * irq_work to do the work queue wake up. The worse 581 * irq_work to do the work queue wake up. The worse
579 * that can happen if we race with !trace_empty() is that 582 * that can happen if we race with !trace_empty() is that
580 * an event will cause an irq_work to try to wake up 583 * an event will cause an irq_work to try to wake up
581 * an empty queue. 584 * an empty queue.
582 * 585 *
583 * There's no reason to protect this flag either, as 586 * There's no reason to protect this flag either, as
584 * the work queue and irq_work logic will do the necessary 587 * the work queue and irq_work logic will do the necessary
585 * synchronization for the wake ups. The only thing 588 * synchronization for the wake ups. The only thing
586 * that is necessary is that the wake up happens after 589 * that is necessary is that the wake up happens after
587 * a task has been queued. It's OK for spurious wake ups. 590 * a task has been queued. It's OK for spurious wake ups.
588 */ 591 */
589 work->waiters_pending = true; 592 work->waiters_pending = true;
593
594 if (signal_pending(current)) {
595 ret = -EINTR;
596 break;
597 }
598
599 if (cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer))
600 break;
601
602 if (cpu != RING_BUFFER_ALL_CPUS &&
603 !ring_buffer_empty_cpu(buffer, cpu)) {
604 unsigned long flags;
605 bool pagebusy;
606
607 if (!full)
608 break;
609
610 raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
611 pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page;
612 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
613
614 if (!pagebusy)
615 break;
616 }
590 617
591 if ((cpu == RING_BUFFER_ALL_CPUS && ring_buffer_empty(buffer)) ||
592 (cpu != RING_BUFFER_ALL_CPUS && ring_buffer_empty_cpu(buffer, cpu)))
593 schedule(); 618 schedule();
619 }
594 620
595 finish_wait(&work->waiters, &wait); 621 finish_wait(&work->waiters, &wait);
596 return 0; 622
623 return ret;
597} 624}
598 625
599/** 626/**
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8a528392b1f4..92f4a6cee172 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1076,13 +1076,14 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
1076} 1076}
1077#endif /* CONFIG_TRACER_MAX_TRACE */ 1077#endif /* CONFIG_TRACER_MAX_TRACE */
1078 1078
1079static int wait_on_pipe(struct trace_iterator *iter) 1079static int wait_on_pipe(struct trace_iterator *iter, bool full)
1080{ 1080{
1081 /* Iterators are static, they should be filled or empty */ 1081 /* Iterators are static, they should be filled or empty */
1082 if (trace_buffer_iter(iter, iter->cpu_file)) 1082 if (trace_buffer_iter(iter, iter->cpu_file))
1083 return 0; 1083 return 0;
1084 1084
1085 return ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file); 1085 return ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file,
1086 full);
1086} 1087}
1087 1088
1088#ifdef CONFIG_FTRACE_STARTUP_TEST 1089#ifdef CONFIG_FTRACE_STARTUP_TEST
@@ -4434,15 +4435,12 @@ static int tracing_wait_pipe(struct file *filp)
4434 4435
4435 mutex_unlock(&iter->mutex); 4436 mutex_unlock(&iter->mutex);
4436 4437
4437 ret = wait_on_pipe(iter); 4438 ret = wait_on_pipe(iter, false);
4438 4439
4439 mutex_lock(&iter->mutex); 4440 mutex_lock(&iter->mutex);
4440 4441
4441 if (ret) 4442 if (ret)
4442 return ret; 4443 return ret;
4443
4444 if (signal_pending(current))
4445 return -EINTR;
4446 } 4444 }
4447 4445
4448 return 1; 4446 return 1;
@@ -5372,16 +5370,12 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
5372 goto out_unlock; 5370 goto out_unlock;
5373 } 5371 }
5374 mutex_unlock(&trace_types_lock); 5372 mutex_unlock(&trace_types_lock);
5375 ret = wait_on_pipe(iter); 5373 ret = wait_on_pipe(iter, false);
5376 mutex_lock(&trace_types_lock); 5374 mutex_lock(&trace_types_lock);
5377 if (ret) { 5375 if (ret) {
5378 size = ret; 5376 size = ret;
5379 goto out_unlock; 5377 goto out_unlock;
5380 } 5378 }
5381 if (signal_pending(current)) {
5382 size = -EINTR;
5383 goto out_unlock;
5384 }
5385 goto again; 5379 goto again;
5386 } 5380 }
5387 size = 0; 5381 size = 0;
@@ -5500,7 +5494,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5500 }; 5494 };
5501 struct buffer_ref *ref; 5495 struct buffer_ref *ref;
5502 int entries, size, i; 5496 int entries, size, i;
5503 ssize_t ret; 5497 ssize_t ret = 0;
5504 5498
5505 mutex_lock(&trace_types_lock); 5499 mutex_lock(&trace_types_lock);
5506 5500
@@ -5538,13 +5532,16 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5538 int r; 5532 int r;
5539 5533
5540 ref = kzalloc(sizeof(*ref), GFP_KERNEL); 5534 ref = kzalloc(sizeof(*ref), GFP_KERNEL);
5541 if (!ref) 5535 if (!ref) {
5536 ret = -ENOMEM;
5542 break; 5537 break;
5538 }
5543 5539
5544 ref->ref = 1; 5540 ref->ref = 1;
5545 ref->buffer = iter->trace_buffer->buffer; 5541 ref->buffer = iter->trace_buffer->buffer;
5546 ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file); 5542 ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
5547 if (!ref->page) { 5543 if (!ref->page) {
5544 ret = -ENOMEM;
5548 kfree(ref); 5545 kfree(ref);
5549 break; 5546 break;
5550 } 5547 }
@@ -5582,19 +5579,19 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
5582 5579
5583 /* did we read anything? */ 5580 /* did we read anything? */
5584 if (!spd.nr_pages) { 5581 if (!spd.nr_pages) {
5582 if (ret)
5583 goto out;
5584
5585 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) { 5585 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) {
5586 ret = -EAGAIN; 5586 ret = -EAGAIN;
5587 goto out; 5587 goto out;
5588 } 5588 }
5589 mutex_unlock(&trace_types_lock); 5589 mutex_unlock(&trace_types_lock);
5590 ret = wait_on_pipe(iter); 5590 ret = wait_on_pipe(iter, true);
5591 mutex_lock(&trace_types_lock); 5591 mutex_lock(&trace_types_lock);
5592 if (ret) 5592 if (ret)
5593 goto out; 5593 goto out;
5594 if (signal_pending(current)) { 5594
5595 ret = -EINTR;
5596 goto out;
5597 }
5598 goto again; 5595 goto again;
5599 } 5596 }
5600 5597
diff --git a/lib/Makefile b/lib/Makefile
index 7512dc978f18..0211d2bd5e17 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -10,7 +10,7 @@ endif
10lib-y := ctype.o string.o vsprintf.o cmdline.o \ 10lib-y := ctype.o string.o vsprintf.o cmdline.o \
11 rbtree.o radix-tree.o dump_stack.o timerqueue.o\ 11 rbtree.o radix-tree.o dump_stack.o timerqueue.o\
12 idr.o int_sqrt.o extable.o \ 12 idr.o int_sqrt.o extable.o \
13 sha1.o md5.o irq_regs.o reciprocal_div.o argv_split.o \ 13 sha1.o md5.o irq_regs.o argv_split.o \
14 proportions.o flex_proportions.o ratelimit.o show_mem.o \ 14 proportions.o flex_proportions.o ratelimit.o show_mem.o \
15 is_single_threaded.o plist.o decompress.o kobject_uevent.o \ 15 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
16 earlycpio.o 16 earlycpio.o
@@ -26,7 +26,7 @@ obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
26 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ 26 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
27 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \ 27 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
28 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \ 28 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
29 percpu-refcount.o percpu_ida.o hash.o rhashtable.o 29 percpu-refcount.o percpu_ida.o hash.o rhashtable.o reciprocal_div.o
30obj-y += string_helpers.o 30obj-y += string_helpers.o
31obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o 31obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
32obj-y += kstrtox.o 32obj-y += kstrtox.o
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 081be3ba9ea8..624a0b7c05ef 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -230,7 +230,7 @@ int rhashtable_expand(struct rhashtable *ht, gfp_t flags)
230 ht->shift++; 230 ht->shift++;
231 231
232 /* For each new bucket, search the corresponding old bucket 232 /* For each new bucket, search the corresponding old bucket
233 * for the rst entry that hashes to the new bucket, and 233 * for the first entry that hashes to the new bucket, and
234 * link the new bucket to that entry. Since all the entries 234 * link the new bucket to that entry. Since all the entries
235 * which will end up in the new bucket appear in the same 235 * which will end up in the new bucket appear in the same
236 * old bucket, this constructs an entirely valid new hash 236 * old bucket, this constructs an entirely valid new hash
@@ -248,8 +248,8 @@ int rhashtable_expand(struct rhashtable *ht, gfp_t flags)
248 } 248 }
249 249
250 /* Publish the new table pointer. Lookups may now traverse 250 /* Publish the new table pointer. Lookups may now traverse
251 * the new table, but they will not benet from any 251 * the new table, but they will not benefit from any
252 * additional efciency until later steps unzip the buckets. 252 * additional efficiency until later steps unzip the buckets.
253 */ 253 */
254 rcu_assign_pointer(ht->tbl, new_tbl); 254 rcu_assign_pointer(ht->tbl, new_tbl);
255 255
@@ -306,14 +306,14 @@ int rhashtable_shrink(struct rhashtable *ht, gfp_t flags)
306 306
307 ht->shift--; 307 ht->shift--;
308 308
309 /* Link each bucket in the new table to the rst bucket 309 /* Link each bucket in the new table to the first bucket
310 * in the old table that contains entries which will hash 310 * in the old table that contains entries which will hash
311 * to the new bucket. 311 * to the new bucket.
312 */ 312 */
313 for (i = 0; i < ntbl->size; i++) { 313 for (i = 0; i < ntbl->size; i++) {
314 ntbl->buckets[i] = tbl->buckets[i]; 314 ntbl->buckets[i] = tbl->buckets[i];
315 315
316 /* Link each bucket in the new table to the rst bucket 316 /* Link each bucket in the new table to the first bucket
317 * in the old table that contains entries which will hash 317 * in the old table that contains entries which will hash
318 * to the new bucket. 318 * to the new bucket.
319 */ 319 */
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 8a000cebb0d7..477be696511d 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -243,13 +243,10 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
243 243
244static int reset_managed_pages_done __initdata; 244static int reset_managed_pages_done __initdata;
245 245
246static inline void __init reset_node_managed_pages(pg_data_t *pgdat) 246void reset_node_managed_pages(pg_data_t *pgdat)
247{ 247{
248 struct zone *z; 248 struct zone *z;
249 249
250 if (reset_managed_pages_done)
251 return;
252
253 for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) 250 for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
254 z->managed_pages = 0; 251 z->managed_pages = 0;
255} 252}
@@ -258,8 +255,12 @@ void __init reset_all_zones_managed_pages(void)
258{ 255{
259 struct pglist_data *pgdat; 256 struct pglist_data *pgdat;
260 257
258 if (reset_managed_pages_done)
259 return;
260
261 for_each_online_pgdat(pgdat) 261 for_each_online_pgdat(pgdat)
262 reset_node_managed_pages(pgdat); 262 reset_node_managed_pages(pgdat);
263
263 reset_managed_pages_done = 1; 264 reset_managed_pages_done = 1;
264} 265}
265 266
diff --git a/mm/compaction.c b/mm/compaction.c
index ec74cf0123ef..f9792ba3537c 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -479,6 +479,16 @@ isolate_freepages_range(struct compact_control *cc,
479 479
480 block_end_pfn = min(block_end_pfn, end_pfn); 480 block_end_pfn = min(block_end_pfn, end_pfn);
481 481
482 /*
483 * pfn could pass the block_end_pfn if isolated freepage
484 * is more than pageblock order. In this case, we adjust
485 * scanning range to right one.
486 */
487 if (pfn >= block_end_pfn) {
488 block_end_pfn = ALIGN(pfn + 1, pageblock_nr_pages);
489 block_end_pfn = min(block_end_pfn, end_pfn);
490 }
491
482 if (!pageblock_pfn_to_page(pfn, block_end_pfn, cc->zone)) 492 if (!pageblock_pfn_to_page(pfn, block_end_pfn, cc->zone))
483 break; 493 break;
484 494
@@ -1029,8 +1039,12 @@ static isolate_migrate_t isolate_migratepages(struct zone *zone,
1029 } 1039 }
1030 1040
1031 acct_isolated(zone, cc); 1041 acct_isolated(zone, cc);
1032 /* Record where migration scanner will be restarted */ 1042 /*
1033 cc->migrate_pfn = low_pfn; 1043 * Record where migration scanner will be restarted. If we end up in
1044 * the same pageblock as the free scanner, make the scanners fully
1045 * meet so that compact_finished() terminates compaction.
1046 */
1047 cc->migrate_pfn = (end_pfn <= cc->free_pfn) ? low_pfn : cc->free_pfn;
1034 1048
1035 return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE; 1049 return cc->nr_migratepages ? ISOLATE_SUCCESS : ISOLATE_NONE;
1036} 1050}
diff --git a/mm/internal.h b/mm/internal.h
index 829304090b90..a4f90ba7068e 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -108,6 +108,31 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
108/* 108/*
109 * in mm/page_alloc.c 109 * in mm/page_alloc.c
110 */ 110 */
111
112/*
113 * Locate the struct page for both the matching buddy in our
114 * pair (buddy1) and the combined O(n+1) page they form (page).
115 *
116 * 1) Any buddy B1 will have an order O twin B2 which satisfies
117 * the following equation:
118 * B2 = B1 ^ (1 << O)
119 * For example, if the starting buddy (buddy2) is #8 its order
120 * 1 buddy is #10:
121 * B2 = 8 ^ (1 << 1) = 8 ^ 2 = 10
122 *
123 * 2) Any buddy B will have an order O+1 parent P which
124 * satisfies the following equation:
125 * P = B & ~(1 << O)
126 *
127 * Assumption: *_mem_map is contiguous at least up to MAX_ORDER
128 */
129static inline unsigned long
130__find_buddy_index(unsigned long page_idx, unsigned int order)
131{
132 return page_idx ^ (1 << order);
133}
134
135extern int __isolate_free_page(struct page *page, unsigned int order);
111extern void __free_pages_bootmem(struct page *page, unsigned int order); 136extern void __free_pages_bootmem(struct page *page, unsigned int order);
112extern void prep_compound_page(struct page *page, unsigned long order); 137extern void prep_compound_page(struct page *page, unsigned long order);
113#ifdef CONFIG_MEMORY_FAILURE 138#ifdef CONFIG_MEMORY_FAILURE
diff --git a/mm/iov_iter.c b/mm/iov_iter.c
index eafcf60f6b83..e34a3cb6aad6 100644
--- a/mm/iov_iter.c
+++ b/mm/iov_iter.c
@@ -911,9 +911,9 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i)
911 if (i->nr_segs == 1) 911 if (i->nr_segs == 1)
912 return i->count; 912 return i->count;
913 else if (i->type & ITER_BVEC) 913 else if (i->type & ITER_BVEC)
914 return min(i->count, i->iov->iov_len - i->iov_offset);
915 else
916 return min(i->count, i->bvec->bv_len - i->iov_offset); 914 return min(i->count, i->bvec->bv_len - i->iov_offset);
915 else
916 return min(i->count, i->iov->iov_len - i->iov_offset);
917} 917}
918EXPORT_SYMBOL(iov_iter_single_seg_count); 918EXPORT_SYMBOL(iov_iter_single_seg_count);
919 919
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 252e1dbbed86..1bf4807cb21e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -31,6 +31,7 @@
31#include <linux/stop_machine.h> 31#include <linux/stop_machine.h>
32#include <linux/hugetlb.h> 32#include <linux/hugetlb.h>
33#include <linux/memblock.h> 33#include <linux/memblock.h>
34#include <linux/bootmem.h>
34 35
35#include <asm/tlbflush.h> 36#include <asm/tlbflush.h>
36 37
@@ -1066,6 +1067,16 @@ out:
1066} 1067}
1067#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ 1068#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
1068 1069
1070static void reset_node_present_pages(pg_data_t *pgdat)
1071{
1072 struct zone *z;
1073
1074 for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
1075 z->present_pages = 0;
1076
1077 pgdat->node_present_pages = 0;
1078}
1079
1069/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */ 1080/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */
1070static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start) 1081static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
1071{ 1082{
@@ -1096,6 +1107,21 @@ static pg_data_t __ref *hotadd_new_pgdat(int nid, u64 start)
1096 build_all_zonelists(pgdat, NULL); 1107 build_all_zonelists(pgdat, NULL);
1097 mutex_unlock(&zonelists_mutex); 1108 mutex_unlock(&zonelists_mutex);
1098 1109
1110 /*
1111 * zone->managed_pages is set to an approximate value in
1112 * free_area_init_core(), which will cause
1113 * /sys/device/system/node/nodeX/meminfo has wrong data.
1114 * So reset it to 0 before any memory is onlined.
1115 */
1116 reset_node_managed_pages(pgdat);
1117
1118 /*
1119 * When memory is hot-added, all the memory is in offline state. So
1120 * clear all zones' present_pages because they will be updated in
1121 * online_pages() and offline_pages().
1122 */
1123 reset_node_present_pages(pgdat);
1124
1099 return pgdat; 1125 return pgdat;
1100} 1126}
1101 1127
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 7c7ab32ee503..90b50468333e 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -145,12 +145,10 @@ static unsigned long __init free_low_memory_core_early(void)
145 145
146static int reset_managed_pages_done __initdata; 146static int reset_managed_pages_done __initdata;
147 147
148static inline void __init reset_node_managed_pages(pg_data_t *pgdat) 148void reset_node_managed_pages(pg_data_t *pgdat)
149{ 149{
150 struct zone *z; 150 struct zone *z;
151 151
152 if (reset_managed_pages_done)
153 return;
154 for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++) 152 for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
155 z->managed_pages = 0; 153 z->managed_pages = 0;
156} 154}
@@ -159,8 +157,12 @@ void __init reset_all_zones_managed_pages(void)
159{ 157{
160 struct pglist_data *pgdat; 158 struct pglist_data *pgdat;
161 159
160 if (reset_managed_pages_done)
161 return;
162
162 for_each_online_pgdat(pgdat) 163 for_each_online_pgdat(pgdat)
163 reset_node_managed_pages(pgdat); 164 reset_node_managed_pages(pgdat);
165
164 reset_managed_pages_done = 1; 166 reset_managed_pages_done = 1;
165} 167}
166 168
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9cd36b822444..616a2c956b4b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -467,29 +467,6 @@ static inline void rmv_page_order(struct page *page)
467} 467}
468 468
469/* 469/*
470 * Locate the struct page for both the matching buddy in our
471 * pair (buddy1) and the combined O(n+1) page they form (page).
472 *
473 * 1) Any buddy B1 will have an order O twin B2 which satisfies
474 * the following equation:
475 * B2 = B1 ^ (1 << O)
476 * For example, if the starting buddy (buddy2) is #8 its order
477 * 1 buddy is #10:
478 * B2 = 8 ^ (1 << 1) = 8 ^ 2 = 10
479 *
480 * 2) Any buddy B will have an order O+1 parent P which
481 * satisfies the following equation:
482 * P = B & ~(1 << O)
483 *
484 * Assumption: *_mem_map is contiguous at least up to MAX_ORDER
485 */
486static inline unsigned long
487__find_buddy_index(unsigned long page_idx, unsigned int order)
488{
489 return page_idx ^ (1 << order);
490}
491
492/*
493 * This function checks whether a page is free && is the buddy 470 * This function checks whether a page is free && is the buddy
494 * we can do coalesce a page and its buddy if 471 * we can do coalesce a page and its buddy if
495 * (a) the buddy is not in a hole && 472 * (a) the buddy is not in a hole &&
@@ -569,6 +546,7 @@ static inline void __free_one_page(struct page *page,
569 unsigned long combined_idx; 546 unsigned long combined_idx;
570 unsigned long uninitialized_var(buddy_idx); 547 unsigned long uninitialized_var(buddy_idx);
571 struct page *buddy; 548 struct page *buddy;
549 int max_order = MAX_ORDER;
572 550
573 VM_BUG_ON(!zone_is_initialized(zone)); 551 VM_BUG_ON(!zone_is_initialized(zone));
574 552
@@ -577,13 +555,24 @@ static inline void __free_one_page(struct page *page,
577 return; 555 return;
578 556
579 VM_BUG_ON(migratetype == -1); 557 VM_BUG_ON(migratetype == -1);
558 if (is_migrate_isolate(migratetype)) {
559 /*
560 * We restrict max order of merging to prevent merge
561 * between freepages on isolate pageblock and normal
562 * pageblock. Without this, pageblock isolation
563 * could cause incorrect freepage accounting.
564 */
565 max_order = min(MAX_ORDER, pageblock_order + 1);
566 } else {
567 __mod_zone_freepage_state(zone, 1 << order, migratetype);
568 }
580 569
581 page_idx = pfn & ((1 << MAX_ORDER) - 1); 570 page_idx = pfn & ((1 << max_order) - 1);
582 571
583 VM_BUG_ON_PAGE(page_idx & ((1 << order) - 1), page); 572 VM_BUG_ON_PAGE(page_idx & ((1 << order) - 1), page);
584 VM_BUG_ON_PAGE(bad_range(zone, page), page); 573 VM_BUG_ON_PAGE(bad_range(zone, page), page);
585 574
586 while (order < MAX_ORDER-1) { 575 while (order < max_order - 1) {
587 buddy_idx = __find_buddy_index(page_idx, order); 576 buddy_idx = __find_buddy_index(page_idx, order);
588 buddy = page + (buddy_idx - page_idx); 577 buddy = page + (buddy_idx - page_idx);
589 if (!page_is_buddy(page, buddy, order)) 578 if (!page_is_buddy(page, buddy, order))
@@ -594,9 +583,11 @@ static inline void __free_one_page(struct page *page,
594 */ 583 */
595 if (page_is_guard(buddy)) { 584 if (page_is_guard(buddy)) {
596 clear_page_guard_flag(buddy); 585 clear_page_guard_flag(buddy);
597 set_page_private(page, 0); 586 set_page_private(buddy, 0);
598 __mod_zone_freepage_state(zone, 1 << order, 587 if (!is_migrate_isolate(migratetype)) {
599 migratetype); 588 __mod_zone_freepage_state(zone, 1 << order,
589 migratetype);
590 }
600 } else { 591 } else {
601 list_del(&buddy->lru); 592 list_del(&buddy->lru);
602 zone->free_area[order].nr_free--; 593 zone->free_area[order].nr_free--;
@@ -715,14 +706,12 @@ static void free_pcppages_bulk(struct zone *zone, int count,
715 /* must delete as __free_one_page list manipulates */ 706 /* must delete as __free_one_page list manipulates */
716 list_del(&page->lru); 707 list_del(&page->lru);
717 mt = get_freepage_migratetype(page); 708 mt = get_freepage_migratetype(page);
709 if (unlikely(has_isolate_pageblock(zone)))
710 mt = get_pageblock_migratetype(page);
711
718 /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */ 712 /* MIGRATE_MOVABLE list may include MIGRATE_RESERVEs */
719 __free_one_page(page, page_to_pfn(page), zone, 0, mt); 713 __free_one_page(page, page_to_pfn(page), zone, 0, mt);
720 trace_mm_page_pcpu_drain(page, 0, mt); 714 trace_mm_page_pcpu_drain(page, 0, mt);
721 if (likely(!is_migrate_isolate_page(page))) {
722 __mod_zone_page_state(zone, NR_FREE_PAGES, 1);
723 if (is_migrate_cma(mt))
724 __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, 1);
725 }
726 } while (--to_free && --batch_free && !list_empty(list)); 715 } while (--to_free && --batch_free && !list_empty(list));
727 } 716 }
728 spin_unlock(&zone->lock); 717 spin_unlock(&zone->lock);
@@ -739,9 +728,11 @@ static void free_one_page(struct zone *zone,
739 if (nr_scanned) 728 if (nr_scanned)
740 __mod_zone_page_state(zone, NR_PAGES_SCANNED, -nr_scanned); 729 __mod_zone_page_state(zone, NR_PAGES_SCANNED, -nr_scanned);
741 730
731 if (unlikely(has_isolate_pageblock(zone) ||
732 is_migrate_isolate(migratetype))) {
733 migratetype = get_pfnblock_migratetype(page, pfn);
734 }
742 __free_one_page(page, pfn, zone, order, migratetype); 735 __free_one_page(page, pfn, zone, order, migratetype);
743 if (unlikely(!is_migrate_isolate(migratetype)))
744 __mod_zone_freepage_state(zone, 1 << order, migratetype);
745 spin_unlock(&zone->lock); 736 spin_unlock(&zone->lock);
746} 737}
747 738
@@ -1484,7 +1475,7 @@ void split_page(struct page *page, unsigned int order)
1484} 1475}
1485EXPORT_SYMBOL_GPL(split_page); 1476EXPORT_SYMBOL_GPL(split_page);
1486 1477
1487static int __isolate_free_page(struct page *page, unsigned int order) 1478int __isolate_free_page(struct page *page, unsigned int order)
1488{ 1479{
1489 unsigned long watermark; 1480 unsigned long watermark;
1490 struct zone *zone; 1481 struct zone *zone;
@@ -6408,13 +6399,12 @@ int alloc_contig_range(unsigned long start, unsigned long end,
6408 6399
6409 /* Make sure the range is really isolated. */ 6400 /* Make sure the range is really isolated. */
6410 if (test_pages_isolated(outer_start, end, false)) { 6401 if (test_pages_isolated(outer_start, end, false)) {
6411 pr_warn("alloc_contig_range test_pages_isolated(%lx, %lx) failed\n", 6402 pr_info("%s: [%lx, %lx) PFNs busy\n",
6412 outer_start, end); 6403 __func__, outer_start, end);
6413 ret = -EBUSY; 6404 ret = -EBUSY;
6414 goto done; 6405 goto done;
6415 } 6406 }
6416 6407
6417
6418 /* Grab isolated pages from freelists. */ 6408 /* Grab isolated pages from freelists. */
6419 outer_end = isolate_freepages_range(&cc, outer_start, end); 6409 outer_end = isolate_freepages_range(&cc, outer_start, end);
6420 if (!outer_end) { 6410 if (!outer_end) {
diff --git a/mm/page_isolation.c b/mm/page_isolation.c
index d1473b2e9481..c8778f7e208e 100644
--- a/mm/page_isolation.c
+++ b/mm/page_isolation.c
@@ -60,6 +60,7 @@ out:
60 int migratetype = get_pageblock_migratetype(page); 60 int migratetype = get_pageblock_migratetype(page);
61 61
62 set_pageblock_migratetype(page, MIGRATE_ISOLATE); 62 set_pageblock_migratetype(page, MIGRATE_ISOLATE);
63 zone->nr_isolate_pageblock++;
63 nr_pages = move_freepages_block(zone, page, MIGRATE_ISOLATE); 64 nr_pages = move_freepages_block(zone, page, MIGRATE_ISOLATE);
64 65
65 __mod_zone_freepage_state(zone, -nr_pages, migratetype); 66 __mod_zone_freepage_state(zone, -nr_pages, migratetype);
@@ -75,16 +76,54 @@ void unset_migratetype_isolate(struct page *page, unsigned migratetype)
75{ 76{
76 struct zone *zone; 77 struct zone *zone;
77 unsigned long flags, nr_pages; 78 unsigned long flags, nr_pages;
79 struct page *isolated_page = NULL;
80 unsigned int order;
81 unsigned long page_idx, buddy_idx;
82 struct page *buddy;
78 83
79 zone = page_zone(page); 84 zone = page_zone(page);
80 spin_lock_irqsave(&zone->lock, flags); 85 spin_lock_irqsave(&zone->lock, flags);
81 if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE) 86 if (get_pageblock_migratetype(page) != MIGRATE_ISOLATE)
82 goto out; 87 goto out;
83 nr_pages = move_freepages_block(zone, page, migratetype); 88
84 __mod_zone_freepage_state(zone, nr_pages, migratetype); 89 /*
90 * Because freepage with more than pageblock_order on isolated
91 * pageblock is restricted to merge due to freepage counting problem,
92 * it is possible that there is free buddy page.
93 * move_freepages_block() doesn't care of merge so we need other
94 * approach in order to merge them. Isolation and free will make
95 * these pages to be merged.
96 */
97 if (PageBuddy(page)) {
98 order = page_order(page);
99 if (order >= pageblock_order) {
100 page_idx = page_to_pfn(page) & ((1 << MAX_ORDER) - 1);
101 buddy_idx = __find_buddy_index(page_idx, order);
102 buddy = page + (buddy_idx - page_idx);
103
104 if (!is_migrate_isolate_page(buddy)) {
105 __isolate_free_page(page, order);
106 set_page_refcounted(page);
107 isolated_page = page;
108 }
109 }
110 }
111
112 /*
113 * If we isolate freepage with more than pageblock_order, there
114 * should be no freepage in the range, so we could avoid costly
115 * pageblock scanning for freepage moving.
116 */
117 if (!isolated_page) {
118 nr_pages = move_freepages_block(zone, page, migratetype);
119 __mod_zone_freepage_state(zone, nr_pages, migratetype);
120 }
85 set_pageblock_migratetype(page, migratetype); 121 set_pageblock_migratetype(page, migratetype);
122 zone->nr_isolate_pageblock--;
86out: 123out:
87 spin_unlock_irqrestore(&zone->lock, flags); 124 spin_unlock_irqrestore(&zone->lock, flags);
125 if (isolated_page)
126 __free_pages(isolated_page, order);
88} 127}
89 128
90static inline struct page * 129static inline struct page *
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 406944207b61..dcdab81bd240 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -259,6 +259,10 @@ struct kmem_cache *find_mergeable(size_t size, size_t align,
259 if (s->size - size >= sizeof(void *)) 259 if (s->size - size >= sizeof(void *))
260 continue; 260 continue;
261 261
262 if (IS_ENABLED(CONFIG_SLAB) && align &&
263 (align > s->align || s->align % align))
264 continue;
265
262 return s; 266 return s;
263 } 267 }
264 return NULL; 268 return NULL;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 648d79ccf462..c465876c7861 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -813,10 +813,9 @@ static void __br_multicast_send_query(struct net_bridge *br,
813 return; 813 return;
814 814
815 if (port) { 815 if (port) {
816 __skb_push(skb, sizeof(struct ethhdr));
817 skb->dev = port->dev; 816 skb->dev = port->dev;
818 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 817 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
819 dev_queue_xmit); 818 br_dev_queue_push_xmit);
820 } else { 819 } else {
821 br_multicast_select_own_querier(br, ip, skb); 820 br_multicast_select_own_querier(br, ip, skb);
822 netif_rx(skb); 821 netif_rx(skb);
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 2ff9706647f2..e5ec470b851f 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -280,6 +280,7 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = {
280 [IFLA_BRPORT_MODE] = { .type = NLA_U8 }, 280 [IFLA_BRPORT_MODE] = { .type = NLA_U8 },
281 [IFLA_BRPORT_GUARD] = { .type = NLA_U8 }, 281 [IFLA_BRPORT_GUARD] = { .type = NLA_U8 },
282 [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 }, 282 [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 },
283 [IFLA_BRPORT_FAST_LEAVE]= { .type = NLA_U8 },
283 [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 }, 284 [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 },
284 [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 }, 285 [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 },
285}; 286};
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index 654c9018e3e7..48da2c54a69e 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -18,6 +18,7 @@
18#include <net/netfilter/ipv6/nf_reject.h> 18#include <net/netfilter/ipv6/nf_reject.h>
19#include <linux/ip.h> 19#include <linux/ip.h>
20#include <net/ip.h> 20#include <net/ip.h>
21#include <net/ip6_checksum.h>
21#include <linux/netfilter_bridge.h> 22#include <linux/netfilter_bridge.h>
22#include "../br_private.h" 23#include "../br_private.h"
23 24
diff --git a/net/ceph/crypto.c b/net/ceph/crypto.c
index 62fc5e7a9acf..790fe89d90c0 100644
--- a/net/ceph/crypto.c
+++ b/net/ceph/crypto.c
@@ -90,11 +90,82 @@ static struct crypto_blkcipher *ceph_crypto_alloc_cipher(void)
90 90
91static const u8 *aes_iv = (u8 *)CEPH_AES_IV; 91static const u8 *aes_iv = (u8 *)CEPH_AES_IV;
92 92
93/*
94 * Should be used for buffers allocated with ceph_kvmalloc().
95 * Currently these are encrypt out-buffer (ceph_buffer) and decrypt
96 * in-buffer (msg front).
97 *
98 * Dispose of @sgt with teardown_sgtable().
99 *
100 * @prealloc_sg is to avoid memory allocation inside sg_alloc_table()
101 * in cases where a single sg is sufficient. No attempt to reduce the
102 * number of sgs by squeezing physically contiguous pages together is
103 * made though, for simplicity.
104 */
105static int setup_sgtable(struct sg_table *sgt, struct scatterlist *prealloc_sg,
106 const void *buf, unsigned int buf_len)
107{
108 struct scatterlist *sg;
109 const bool is_vmalloc = is_vmalloc_addr(buf);
110 unsigned int off = offset_in_page(buf);
111 unsigned int chunk_cnt = 1;
112 unsigned int chunk_len = PAGE_ALIGN(off + buf_len);
113 int i;
114 int ret;
115
116 if (buf_len == 0) {
117 memset(sgt, 0, sizeof(*sgt));
118 return -EINVAL;
119 }
120
121 if (is_vmalloc) {
122 chunk_cnt = chunk_len >> PAGE_SHIFT;
123 chunk_len = PAGE_SIZE;
124 }
125
126 if (chunk_cnt > 1) {
127 ret = sg_alloc_table(sgt, chunk_cnt, GFP_NOFS);
128 if (ret)
129 return ret;
130 } else {
131 WARN_ON(chunk_cnt != 1);
132 sg_init_table(prealloc_sg, 1);
133 sgt->sgl = prealloc_sg;
134 sgt->nents = sgt->orig_nents = 1;
135 }
136
137 for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
138 struct page *page;
139 unsigned int len = min(chunk_len - off, buf_len);
140
141 if (is_vmalloc)
142 page = vmalloc_to_page(buf);
143 else
144 page = virt_to_page(buf);
145
146 sg_set_page(sg, page, len, off);
147
148 off = 0;
149 buf += len;
150 buf_len -= len;
151 }
152 WARN_ON(buf_len != 0);
153
154 return 0;
155}
156
157static void teardown_sgtable(struct sg_table *sgt)
158{
159 if (sgt->orig_nents > 1)
160 sg_free_table(sgt);
161}
162
93static int ceph_aes_encrypt(const void *key, int key_len, 163static int ceph_aes_encrypt(const void *key, int key_len,
94 void *dst, size_t *dst_len, 164 void *dst, size_t *dst_len,
95 const void *src, size_t src_len) 165 const void *src, size_t src_len)
96{ 166{
97 struct scatterlist sg_in[2], sg_out[1]; 167 struct scatterlist sg_in[2], prealloc_sg;
168 struct sg_table sg_out;
98 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); 169 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
99 struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 }; 170 struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 };
100 int ret; 171 int ret;
@@ -110,16 +181,18 @@ static int ceph_aes_encrypt(const void *key, int key_len,
110 181
111 *dst_len = src_len + zero_padding; 182 *dst_len = src_len + zero_padding;
112 183
113 crypto_blkcipher_setkey((void *)tfm, key, key_len);
114 sg_init_table(sg_in, 2); 184 sg_init_table(sg_in, 2);
115 sg_set_buf(&sg_in[0], src, src_len); 185 sg_set_buf(&sg_in[0], src, src_len);
116 sg_set_buf(&sg_in[1], pad, zero_padding); 186 sg_set_buf(&sg_in[1], pad, zero_padding);
117 sg_init_table(sg_out, 1); 187 ret = setup_sgtable(&sg_out, &prealloc_sg, dst, *dst_len);
118 sg_set_buf(sg_out, dst, *dst_len); 188 if (ret)
189 goto out_tfm;
190
191 crypto_blkcipher_setkey((void *)tfm, key, key_len);
119 iv = crypto_blkcipher_crt(tfm)->iv; 192 iv = crypto_blkcipher_crt(tfm)->iv;
120 ivsize = crypto_blkcipher_ivsize(tfm); 193 ivsize = crypto_blkcipher_ivsize(tfm);
121
122 memcpy(iv, aes_iv, ivsize); 194 memcpy(iv, aes_iv, ivsize);
195
123 /* 196 /*
124 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, 197 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1,
125 key, key_len, 1); 198 key, key_len, 1);
@@ -128,16 +201,22 @@ static int ceph_aes_encrypt(const void *key, int key_len,
128 print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1, 201 print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1,
129 pad, zero_padding, 1); 202 pad, zero_padding, 1);
130 */ 203 */
131 ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in, 204 ret = crypto_blkcipher_encrypt(&desc, sg_out.sgl, sg_in,
132 src_len + zero_padding); 205 src_len + zero_padding);
133 crypto_free_blkcipher(tfm); 206 if (ret < 0) {
134 if (ret < 0)
135 pr_err("ceph_aes_crypt failed %d\n", ret); 207 pr_err("ceph_aes_crypt failed %d\n", ret);
208 goto out_sg;
209 }
136 /* 210 /*
137 print_hex_dump(KERN_ERR, "enc out: ", DUMP_PREFIX_NONE, 16, 1, 211 print_hex_dump(KERN_ERR, "enc out: ", DUMP_PREFIX_NONE, 16, 1,
138 dst, *dst_len, 1); 212 dst, *dst_len, 1);
139 */ 213 */
140 return 0; 214
215out_sg:
216 teardown_sgtable(&sg_out);
217out_tfm:
218 crypto_free_blkcipher(tfm);
219 return ret;
141} 220}
142 221
143static int ceph_aes_encrypt2(const void *key, int key_len, void *dst, 222static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
@@ -145,7 +224,8 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
145 const void *src1, size_t src1_len, 224 const void *src1, size_t src1_len,
146 const void *src2, size_t src2_len) 225 const void *src2, size_t src2_len)
147{ 226{
148 struct scatterlist sg_in[3], sg_out[1]; 227 struct scatterlist sg_in[3], prealloc_sg;
228 struct sg_table sg_out;
149 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); 229 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
150 struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 }; 230 struct blkcipher_desc desc = { .tfm = tfm, .flags = 0 };
151 int ret; 231 int ret;
@@ -161,17 +241,19 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
161 241
162 *dst_len = src1_len + src2_len + zero_padding; 242 *dst_len = src1_len + src2_len + zero_padding;
163 243
164 crypto_blkcipher_setkey((void *)tfm, key, key_len);
165 sg_init_table(sg_in, 3); 244 sg_init_table(sg_in, 3);
166 sg_set_buf(&sg_in[0], src1, src1_len); 245 sg_set_buf(&sg_in[0], src1, src1_len);
167 sg_set_buf(&sg_in[1], src2, src2_len); 246 sg_set_buf(&sg_in[1], src2, src2_len);
168 sg_set_buf(&sg_in[2], pad, zero_padding); 247 sg_set_buf(&sg_in[2], pad, zero_padding);
169 sg_init_table(sg_out, 1); 248 ret = setup_sgtable(&sg_out, &prealloc_sg, dst, *dst_len);
170 sg_set_buf(sg_out, dst, *dst_len); 249 if (ret)
250 goto out_tfm;
251
252 crypto_blkcipher_setkey((void *)tfm, key, key_len);
171 iv = crypto_blkcipher_crt(tfm)->iv; 253 iv = crypto_blkcipher_crt(tfm)->iv;
172 ivsize = crypto_blkcipher_ivsize(tfm); 254 ivsize = crypto_blkcipher_ivsize(tfm);
173
174 memcpy(iv, aes_iv, ivsize); 255 memcpy(iv, aes_iv, ivsize);
256
175 /* 257 /*
176 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1, 258 print_hex_dump(KERN_ERR, "enc key: ", DUMP_PREFIX_NONE, 16, 1,
177 key, key_len, 1); 259 key, key_len, 1);
@@ -182,23 +264,30 @@ static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
182 print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1, 264 print_hex_dump(KERN_ERR, "enc pad: ", DUMP_PREFIX_NONE, 16, 1,
183 pad, zero_padding, 1); 265 pad, zero_padding, 1);
184 */ 266 */
185 ret = crypto_blkcipher_encrypt(&desc, sg_out, sg_in, 267 ret = crypto_blkcipher_encrypt(&desc, sg_out.sgl, sg_in,
186 src1_len + src2_len + zero_padding); 268 src1_len + src2_len + zero_padding);
187 crypto_free_blkcipher(tfm); 269 if (ret < 0) {
188 if (ret < 0)
189 pr_err("ceph_aes_crypt2 failed %d\n", ret); 270 pr_err("ceph_aes_crypt2 failed %d\n", ret);
271 goto out_sg;
272 }
190 /* 273 /*
191 print_hex_dump(KERN_ERR, "enc out: ", DUMP_PREFIX_NONE, 16, 1, 274 print_hex_dump(KERN_ERR, "enc out: ", DUMP_PREFIX_NONE, 16, 1,
192 dst, *dst_len, 1); 275 dst, *dst_len, 1);
193 */ 276 */
194 return 0; 277
278out_sg:
279 teardown_sgtable(&sg_out);
280out_tfm:
281 crypto_free_blkcipher(tfm);
282 return ret;
195} 283}
196 284
197static int ceph_aes_decrypt(const void *key, int key_len, 285static int ceph_aes_decrypt(const void *key, int key_len,
198 void *dst, size_t *dst_len, 286 void *dst, size_t *dst_len,
199 const void *src, size_t src_len) 287 const void *src, size_t src_len)
200{ 288{
201 struct scatterlist sg_in[1], sg_out[2]; 289 struct sg_table sg_in;
290 struct scatterlist sg_out[2], prealloc_sg;
202 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); 291 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
203 struct blkcipher_desc desc = { .tfm = tfm }; 292 struct blkcipher_desc desc = { .tfm = tfm };
204 char pad[16]; 293 char pad[16];
@@ -210,16 +299,16 @@ static int ceph_aes_decrypt(const void *key, int key_len,
210 if (IS_ERR(tfm)) 299 if (IS_ERR(tfm))
211 return PTR_ERR(tfm); 300 return PTR_ERR(tfm);
212 301
213 crypto_blkcipher_setkey((void *)tfm, key, key_len);
214 sg_init_table(sg_in, 1);
215 sg_init_table(sg_out, 2); 302 sg_init_table(sg_out, 2);
216 sg_set_buf(sg_in, src, src_len);
217 sg_set_buf(&sg_out[0], dst, *dst_len); 303 sg_set_buf(&sg_out[0], dst, *dst_len);
218 sg_set_buf(&sg_out[1], pad, sizeof(pad)); 304 sg_set_buf(&sg_out[1], pad, sizeof(pad));
305 ret = setup_sgtable(&sg_in, &prealloc_sg, src, src_len);
306 if (ret)
307 goto out_tfm;
219 308
309 crypto_blkcipher_setkey((void *)tfm, key, key_len);
220 iv = crypto_blkcipher_crt(tfm)->iv; 310 iv = crypto_blkcipher_crt(tfm)->iv;
221 ivsize = crypto_blkcipher_ivsize(tfm); 311 ivsize = crypto_blkcipher_ivsize(tfm);
222
223 memcpy(iv, aes_iv, ivsize); 312 memcpy(iv, aes_iv, ivsize);
224 313
225 /* 314 /*
@@ -228,12 +317,10 @@ static int ceph_aes_decrypt(const void *key, int key_len,
228 print_hex_dump(KERN_ERR, "dec in: ", DUMP_PREFIX_NONE, 16, 1, 317 print_hex_dump(KERN_ERR, "dec in: ", DUMP_PREFIX_NONE, 16, 1,
229 src, src_len, 1); 318 src, src_len, 1);
230 */ 319 */
231 320 ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in.sgl, src_len);
232 ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, src_len);
233 crypto_free_blkcipher(tfm);
234 if (ret < 0) { 321 if (ret < 0) {
235 pr_err("ceph_aes_decrypt failed %d\n", ret); 322 pr_err("ceph_aes_decrypt failed %d\n", ret);
236 return ret; 323 goto out_sg;
237 } 324 }
238 325
239 if (src_len <= *dst_len) 326 if (src_len <= *dst_len)
@@ -251,7 +338,12 @@ static int ceph_aes_decrypt(const void *key, int key_len,
251 print_hex_dump(KERN_ERR, "dec out: ", DUMP_PREFIX_NONE, 16, 1, 338 print_hex_dump(KERN_ERR, "dec out: ", DUMP_PREFIX_NONE, 16, 1,
252 dst, *dst_len, 1); 339 dst, *dst_len, 1);
253 */ 340 */
254 return 0; 341
342out_sg:
343 teardown_sgtable(&sg_in);
344out_tfm:
345 crypto_free_blkcipher(tfm);
346 return ret;
255} 347}
256 348
257static int ceph_aes_decrypt2(const void *key, int key_len, 349static int ceph_aes_decrypt2(const void *key, int key_len,
@@ -259,7 +351,8 @@ static int ceph_aes_decrypt2(const void *key, int key_len,
259 void *dst2, size_t *dst2_len, 351 void *dst2, size_t *dst2_len,
260 const void *src, size_t src_len) 352 const void *src, size_t src_len)
261{ 353{
262 struct scatterlist sg_in[1], sg_out[3]; 354 struct sg_table sg_in;
355 struct scatterlist sg_out[3], prealloc_sg;
263 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher(); 356 struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
264 struct blkcipher_desc desc = { .tfm = tfm }; 357 struct blkcipher_desc desc = { .tfm = tfm };
265 char pad[16]; 358 char pad[16];
@@ -271,17 +364,17 @@ static int ceph_aes_decrypt2(const void *key, int key_len,
271 if (IS_ERR(tfm)) 364 if (IS_ERR(tfm))
272 return PTR_ERR(tfm); 365 return PTR_ERR(tfm);
273 366
274 sg_init_table(sg_in, 1);
275 sg_set_buf(sg_in, src, src_len);
276 sg_init_table(sg_out, 3); 367 sg_init_table(sg_out, 3);
277 sg_set_buf(&sg_out[0], dst1, *dst1_len); 368 sg_set_buf(&sg_out[0], dst1, *dst1_len);
278 sg_set_buf(&sg_out[1], dst2, *dst2_len); 369 sg_set_buf(&sg_out[1], dst2, *dst2_len);
279 sg_set_buf(&sg_out[2], pad, sizeof(pad)); 370 sg_set_buf(&sg_out[2], pad, sizeof(pad));
371 ret = setup_sgtable(&sg_in, &prealloc_sg, src, src_len);
372 if (ret)
373 goto out_tfm;
280 374
281 crypto_blkcipher_setkey((void *)tfm, key, key_len); 375 crypto_blkcipher_setkey((void *)tfm, key, key_len);
282 iv = crypto_blkcipher_crt(tfm)->iv; 376 iv = crypto_blkcipher_crt(tfm)->iv;
283 ivsize = crypto_blkcipher_ivsize(tfm); 377 ivsize = crypto_blkcipher_ivsize(tfm);
284
285 memcpy(iv, aes_iv, ivsize); 378 memcpy(iv, aes_iv, ivsize);
286 379
287 /* 380 /*
@@ -290,12 +383,10 @@ static int ceph_aes_decrypt2(const void *key, int key_len,
290 print_hex_dump(KERN_ERR, "dec in: ", DUMP_PREFIX_NONE, 16, 1, 383 print_hex_dump(KERN_ERR, "dec in: ", DUMP_PREFIX_NONE, 16, 1,
291 src, src_len, 1); 384 src, src_len, 1);
292 */ 385 */
293 386 ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in.sgl, src_len);
294 ret = crypto_blkcipher_decrypt(&desc, sg_out, sg_in, src_len);
295 crypto_free_blkcipher(tfm);
296 if (ret < 0) { 387 if (ret < 0) {
297 pr_err("ceph_aes_decrypt failed %d\n", ret); 388 pr_err("ceph_aes_decrypt failed %d\n", ret);
298 return ret; 389 goto out_sg;
299 } 390 }
300 391
301 if (src_len <= *dst1_len) 392 if (src_len <= *dst1_len)
@@ -325,7 +416,11 @@ static int ceph_aes_decrypt2(const void *key, int key_len,
325 dst2, *dst2_len, 1); 416 dst2, *dst2_len, 1);
326 */ 417 */
327 418
328 return 0; 419out_sg:
420 teardown_sgtable(&sg_in);
421out_tfm:
422 crypto_free_blkcipher(tfm);
423 return ret;
329} 424}
330 425
331 426
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index f3fc54eac09d..6f164289bde8 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1007,8 +1007,8 @@ static void put_osd(struct ceph_osd *osd)
1007static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd) 1007static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
1008{ 1008{
1009 dout("__remove_osd %p\n", osd); 1009 dout("__remove_osd %p\n", osd);
1010 BUG_ON(!list_empty(&osd->o_requests)); 1010 WARN_ON(!list_empty(&osd->o_requests));
1011 BUG_ON(!list_empty(&osd->o_linger_requests)); 1011 WARN_ON(!list_empty(&osd->o_linger_requests));
1012 1012
1013 rb_erase(&osd->o_node, &osdc->osds); 1013 rb_erase(&osd->o_node, &osdc->osds);
1014 list_del_init(&osd->o_osd_lru); 1014 list_del_init(&osd->o_osd_lru);
@@ -1254,6 +1254,8 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc,
1254 if (list_empty(&req->r_osd_item)) 1254 if (list_empty(&req->r_osd_item))
1255 req->r_osd = NULL; 1255 req->r_osd = NULL;
1256 } 1256 }
1257
1258 list_del_init(&req->r_req_lru_item); /* can be on notarget */
1257 ceph_osdc_put_request(req); 1259 ceph_osdc_put_request(req);
1258} 1260}
1259 1261
@@ -1395,6 +1397,7 @@ static int __map_request(struct ceph_osd_client *osdc,
1395 if (req->r_osd) { 1397 if (req->r_osd) {
1396 __cancel_request(req); 1398 __cancel_request(req);
1397 list_del_init(&req->r_osd_item); 1399 list_del_init(&req->r_osd_item);
1400 list_del_init(&req->r_linger_osd_item);
1398 req->r_osd = NULL; 1401 req->r_osd = NULL;
1399 } 1402 }
1400 1403
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a6882686ca3a..b9b7dfaf202b 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2685,13 +2685,20 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
2685 int idx = 0; 2685 int idx = 0;
2686 u32 portid = NETLINK_CB(cb->skb).portid; 2686 u32 portid = NETLINK_CB(cb->skb).portid;
2687 u32 seq = cb->nlh->nlmsg_seq; 2687 u32 seq = cb->nlh->nlmsg_seq;
2688 struct nlattr *extfilt;
2689 u32 filter_mask = 0; 2688 u32 filter_mask = 0;
2690 2689
2691 extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg), 2690 if (nlmsg_len(cb->nlh) > sizeof(struct ifinfomsg)) {
2692 IFLA_EXT_MASK); 2691 struct nlattr *extfilt;
2693 if (extfilt) 2692
2694 filter_mask = nla_get_u32(extfilt); 2693 extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
2694 IFLA_EXT_MASK);
2695 if (extfilt) {
2696 if (nla_len(extfilt) < sizeof(filter_mask))
2697 return -EINVAL;
2698
2699 filter_mask = nla_get_u32(extfilt);
2700 }
2701 }
2695 2702
2696 rcu_read_lock(); 2703 rcu_read_lock();
2697 for_each_netdev_rcu(net, dev) { 2704 for_each_netdev_rcu(net, dev) {
@@ -2798,6 +2805,9 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh)
2798 if (br_spec) { 2805 if (br_spec) {
2799 nla_for_each_nested(attr, br_spec, rem) { 2806 nla_for_each_nested(attr, br_spec, rem) {
2800 if (nla_type(attr) == IFLA_BRIDGE_FLAGS) { 2807 if (nla_type(attr) == IFLA_BRIDGE_FLAGS) {
2808 if (nla_len(attr) < sizeof(flags))
2809 return -EINVAL;
2810
2801 have_flags = true; 2811 have_flags = true;
2802 flags = nla_get_u16(attr); 2812 flags = nla_get_u16(attr);
2803 break; 2813 break;
@@ -2868,6 +2878,9 @@ static int rtnl_bridge_dellink(struct sk_buff *skb, struct nlmsghdr *nlh)
2868 if (br_spec) { 2878 if (br_spec) {
2869 nla_for_each_nested(attr, br_spec, rem) { 2879 nla_for_each_nested(attr, br_spec, rem) {
2870 if (nla_type(attr) == IFLA_BRIDGE_FLAGS) { 2880 if (nla_type(attr) == IFLA_BRIDGE_FLAGS) {
2881 if (nla_len(attr) < sizeof(flags))
2882 return -EINVAL;
2883
2871 have_flags = true; 2884 have_flags = true;
2872 flags = nla_get_u16(attr); 2885 flags = nla_get_u16(attr);
2873 break; 2886 break;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c16615bfb61e..32e31c299631 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -552,20 +552,13 @@ static void kfree_skbmem(struct sk_buff *skb)
552 case SKB_FCLONE_CLONE: 552 case SKB_FCLONE_CLONE:
553 fclones = container_of(skb, struct sk_buff_fclones, skb2); 553 fclones = container_of(skb, struct sk_buff_fclones, skb2);
554 554
555 /* Warning : We must perform the atomic_dec_and_test() before 555 /* The clone portion is available for
556 * setting skb->fclone back to SKB_FCLONE_FREE, otherwise 556 * fast-cloning again.
557 * skb_clone() could set clone_ref to 2 before our decrement.
558 * Anyway, if we are going to free the structure, no need to
559 * rewrite skb->fclone.
560 */ 557 */
561 if (atomic_dec_and_test(&fclones->fclone_ref)) { 558 skb->fclone = SKB_FCLONE_FREE;
559
560 if (atomic_dec_and_test(&fclones->fclone_ref))
562 kmem_cache_free(skbuff_fclone_cache, fclones); 561 kmem_cache_free(skbuff_fclone_cache, fclones);
563 } else {
564 /* The clone portion is available for
565 * fast-cloning again.
566 */
567 skb->fclone = SKB_FCLONE_FREE;
568 }
569 break; 562 break;
570 } 563 }
571} 564}
@@ -887,11 +880,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
887 if (skb->fclone == SKB_FCLONE_ORIG && 880 if (skb->fclone == SKB_FCLONE_ORIG &&
888 n->fclone == SKB_FCLONE_FREE) { 881 n->fclone == SKB_FCLONE_FREE) {
889 n->fclone = SKB_FCLONE_CLONE; 882 n->fclone = SKB_FCLONE_CLONE;
890 /* As our fastclone was free, clone_ref must be 1 at this point. 883 atomic_inc(&fclones->fclone_ref);
891 * We could use atomic_inc() here, but it is faster
892 * to set the final value.
893 */
894 atomic_set(&fclones->fclone_ref, 2);
895 } else { 884 } else {
896 if (skb_pfmemalloc(skb)) 885 if (skb_pfmemalloc(skb))
897 gfp_mask |= __GFP_MEMALLOC; 886 gfp_mask |= __GFP_MEMALLOC;
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index ca11d283bbeb..93ea80196f0e 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1080,13 +1080,13 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
1080 if (!app) 1080 if (!app)
1081 return -EMSGSIZE; 1081 return -EMSGSIZE;
1082 1082
1083 spin_lock(&dcb_lock); 1083 spin_lock_bh(&dcb_lock);
1084 list_for_each_entry(itr, &dcb_app_list, list) { 1084 list_for_each_entry(itr, &dcb_app_list, list) {
1085 if (itr->ifindex == netdev->ifindex) { 1085 if (itr->ifindex == netdev->ifindex) {
1086 err = nla_put(skb, DCB_ATTR_IEEE_APP, sizeof(itr->app), 1086 err = nla_put(skb, DCB_ATTR_IEEE_APP, sizeof(itr->app),
1087 &itr->app); 1087 &itr->app);
1088 if (err) { 1088 if (err) {
1089 spin_unlock(&dcb_lock); 1089 spin_unlock_bh(&dcb_lock);
1090 return -EMSGSIZE; 1090 return -EMSGSIZE;
1091 } 1091 }
1092 } 1092 }
@@ -1097,7 +1097,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
1097 else 1097 else
1098 dcbx = -EOPNOTSUPP; 1098 dcbx = -EOPNOTSUPP;
1099 1099
1100 spin_unlock(&dcb_lock); 1100 spin_unlock_bh(&dcb_lock);
1101 nla_nest_end(skb, app); 1101 nla_nest_end(skb, app);
1102 1102
1103 /* get peer info if available */ 1103 /* get peer info if available */
@@ -1234,7 +1234,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1234 } 1234 }
1235 1235
1236 /* local app */ 1236 /* local app */
1237 spin_lock(&dcb_lock); 1237 spin_lock_bh(&dcb_lock);
1238 app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE); 1238 app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE);
1239 if (!app) 1239 if (!app)
1240 goto dcb_unlock; 1240 goto dcb_unlock;
@@ -1271,7 +1271,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1271 else 1271 else
1272 dcbx = -EOPNOTSUPP; 1272 dcbx = -EOPNOTSUPP;
1273 1273
1274 spin_unlock(&dcb_lock); 1274 spin_unlock_bh(&dcb_lock);
1275 1275
1276 /* features flags */ 1276 /* features flags */
1277 if (ops->getfeatcfg) { 1277 if (ops->getfeatcfg) {
@@ -1326,7 +1326,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
1326 return 0; 1326 return 0;
1327 1327
1328dcb_unlock: 1328dcb_unlock:
1329 spin_unlock(&dcb_lock); 1329 spin_unlock_bh(&dcb_lock);
1330nla_put_failure: 1330nla_put_failure:
1331 return err; 1331 return err;
1332} 1332}
@@ -1762,10 +1762,10 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
1762 struct dcb_app_type *itr; 1762 struct dcb_app_type *itr;
1763 u8 prio = 0; 1763 u8 prio = 0;
1764 1764
1765 spin_lock(&dcb_lock); 1765 spin_lock_bh(&dcb_lock);
1766 if ((itr = dcb_app_lookup(app, dev->ifindex, 0))) 1766 if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
1767 prio = itr->app.priority; 1767 prio = itr->app.priority;
1768 spin_unlock(&dcb_lock); 1768 spin_unlock_bh(&dcb_lock);
1769 1769
1770 return prio; 1770 return prio;
1771} 1771}
@@ -1789,7 +1789,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
1789 if (dev->dcbnl_ops->getdcbx) 1789 if (dev->dcbnl_ops->getdcbx)
1790 event.dcbx = dev->dcbnl_ops->getdcbx(dev); 1790 event.dcbx = dev->dcbnl_ops->getdcbx(dev);
1791 1791
1792 spin_lock(&dcb_lock); 1792 spin_lock_bh(&dcb_lock);
1793 /* Search for existing match and replace */ 1793 /* Search for existing match and replace */
1794 if ((itr = dcb_app_lookup(new, dev->ifindex, 0))) { 1794 if ((itr = dcb_app_lookup(new, dev->ifindex, 0))) {
1795 if (new->priority) 1795 if (new->priority)
@@ -1804,7 +1804,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
1804 if (new->priority) 1804 if (new->priority)
1805 err = dcb_app_add(new, dev->ifindex); 1805 err = dcb_app_add(new, dev->ifindex);
1806out: 1806out:
1807 spin_unlock(&dcb_lock); 1807 spin_unlock_bh(&dcb_lock);
1808 if (!err) 1808 if (!err)
1809 call_dcbevent_notifiers(DCB_APP_EVENT, &event); 1809 call_dcbevent_notifiers(DCB_APP_EVENT, &event);
1810 return err; 1810 return err;
@@ -1823,10 +1823,10 @@ u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
1823 struct dcb_app_type *itr; 1823 struct dcb_app_type *itr;
1824 u8 prio = 0; 1824 u8 prio = 0;
1825 1825
1826 spin_lock(&dcb_lock); 1826 spin_lock_bh(&dcb_lock);
1827 if ((itr = dcb_app_lookup(app, dev->ifindex, 0))) 1827 if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
1828 prio |= 1 << itr->app.priority; 1828 prio |= 1 << itr->app.priority;
1829 spin_unlock(&dcb_lock); 1829 spin_unlock_bh(&dcb_lock);
1830 1830
1831 return prio; 1831 return prio;
1832} 1832}
@@ -1850,7 +1850,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
1850 if (dev->dcbnl_ops->getdcbx) 1850 if (dev->dcbnl_ops->getdcbx)
1851 event.dcbx = dev->dcbnl_ops->getdcbx(dev); 1851 event.dcbx = dev->dcbnl_ops->getdcbx(dev);
1852 1852
1853 spin_lock(&dcb_lock); 1853 spin_lock_bh(&dcb_lock);
1854 /* Search for existing match and abort if found */ 1854 /* Search for existing match and abort if found */
1855 if (dcb_app_lookup(new, dev->ifindex, new->priority)) { 1855 if (dcb_app_lookup(new, dev->ifindex, new->priority)) {
1856 err = -EEXIST; 1856 err = -EEXIST;
@@ -1859,7 +1859,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
1859 1859
1860 err = dcb_app_add(new, dev->ifindex); 1860 err = dcb_app_add(new, dev->ifindex);
1861out: 1861out:
1862 spin_unlock(&dcb_lock); 1862 spin_unlock_bh(&dcb_lock);
1863 if (!err) 1863 if (!err)
1864 call_dcbevent_notifiers(DCB_APP_EVENT, &event); 1864 call_dcbevent_notifiers(DCB_APP_EVENT, &event);
1865 return err; 1865 return err;
@@ -1882,7 +1882,7 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
1882 if (dev->dcbnl_ops->getdcbx) 1882 if (dev->dcbnl_ops->getdcbx)
1883 event.dcbx = dev->dcbnl_ops->getdcbx(dev); 1883 event.dcbx = dev->dcbnl_ops->getdcbx(dev);
1884 1884
1885 spin_lock(&dcb_lock); 1885 spin_lock_bh(&dcb_lock);
1886 /* Search for existing match and remove it. */ 1886 /* Search for existing match and remove it. */
1887 if ((itr = dcb_app_lookup(del, dev->ifindex, del->priority))) { 1887 if ((itr = dcb_app_lookup(del, dev->ifindex, del->priority))) {
1888 list_del(&itr->list); 1888 list_del(&itr->list);
@@ -1890,7 +1890,7 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
1890 err = 0; 1890 err = 0;
1891 } 1891 }
1892 1892
1893 spin_unlock(&dcb_lock); 1893 spin_unlock_bh(&dcb_lock);
1894 if (!err) 1894 if (!err)
1895 call_dcbevent_notifiers(DCB_APP_EVENT, &event); 1895 call_dcbevent_notifiers(DCB_APP_EVENT, &event);
1896 return err; 1896 return err;
@@ -1902,12 +1902,12 @@ static void dcb_flushapp(void)
1902 struct dcb_app_type *app; 1902 struct dcb_app_type *app;
1903 struct dcb_app_type *tmp; 1903 struct dcb_app_type *tmp;
1904 1904
1905 spin_lock(&dcb_lock); 1905 spin_lock_bh(&dcb_lock);
1906 list_for_each_entry_safe(app, tmp, &dcb_app_list, list) { 1906 list_for_each_entry_safe(app, tmp, &dcb_app_list, list) {
1907 list_del(&app->list); 1907 list_del(&app->list);
1908 kfree(app); 1908 kfree(app);
1909 } 1909 }
1910 spin_unlock(&dcb_lock); 1910 spin_unlock_bh(&dcb_lock);
1911} 1911}
1912 1912
1913static int __init dcbnl_init(void) 1913static int __init dcbnl_init(void)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6d1817449c36..ab03e00ffe8f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -489,11 +489,14 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
489 /* We could not connect to a designated PHY, so use the switch internal 489 /* We could not connect to a designated PHY, so use the switch internal
490 * MDIO bus instead 490 * MDIO bus instead
491 */ 491 */
492 if (!p->phy) 492 if (!p->phy) {
493 p->phy = ds->slave_mii_bus->phy_map[p->port]; 493 p->phy = ds->slave_mii_bus->phy_map[p->port];
494 else 494 phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
495 p->phy_interface);
496 } else {
495 pr_info("attached PHY at address %d [%s]\n", 497 pr_info("attached PHY at address %d [%s]\n",
496 p->phy->addr, p->phy->drv->name); 498 p->phy->addr, p->phy->drv->name);
499 }
497} 500}
498 501
499int dsa_slave_suspend(struct net_device *slave_dev) 502int dsa_slave_suspend(struct net_device *slave_dev)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 8b7fe5b03906..e67da4e6c324 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1386,6 +1386,17 @@ out:
1386 return pp; 1386 return pp;
1387} 1387}
1388 1388
1389int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
1390{
1391 if (sk->sk_family == AF_INET)
1392 return ip_recv_error(sk, msg, len, addr_len);
1393#if IS_ENABLED(CONFIG_IPV6)
1394 if (sk->sk_family == AF_INET6)
1395 return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
1396#endif
1397 return -EINVAL;
1398}
1399
1389static int inet_gro_complete(struct sk_buff *skb, int nhoff) 1400static int inet_gro_complete(struct sk_buff *skb, int nhoff)
1390{ 1401{
1391 __be16 newlen = htons(skb->len - nhoff); 1402 __be16 newlen = htons(skb->len - nhoff);
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index f2e15738534d..8f7bd56955b0 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -62,6 +62,10 @@ int __fib_lookup(struct net *net, struct flowi4 *flp, struct fib_result *res)
62 else 62 else
63 res->tclassid = 0; 63 res->tclassid = 0;
64#endif 64#endif
65
66 if (err == -ESRCH)
67 err = -ENETUNREACH;
68
65 return err; 69 return err;
66} 70}
67EXPORT_SYMBOL_GPL(__fib_lookup); 71EXPORT_SYMBOL_GPL(__fib_lookup);
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index 32e78924e246..606c520ffd5a 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -133,6 +133,8 @@ static int fou_gro_complete(struct sk_buff *skb, int nhoff)
133 int err = -ENOSYS; 133 int err = -ENOSYS;
134 const struct net_offload **offloads; 134 const struct net_offload **offloads;
135 135
136 udp_tunnel_gro_complete(skb, nhoff);
137
136 rcu_read_lock(); 138 rcu_read_lock();
137 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; 139 offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
138 ops = rcu_dereference(offloads[proto]); 140 ops = rcu_dereference(offloads[proto]);
diff --git a/net/ipv4/geneve.c b/net/ipv4/geneve.c
index 065cd94c640c..dedb21e99914 100644
--- a/net/ipv4/geneve.c
+++ b/net/ipv4/geneve.c
@@ -144,6 +144,8 @@ int geneve_xmit_skb(struct geneve_sock *gs, struct rtable *rt,
144 gnvh = (struct genevehdr *)__skb_push(skb, sizeof(*gnvh) + opt_len); 144 gnvh = (struct genevehdr *)__skb_push(skb, sizeof(*gnvh) + opt_len);
145 geneve_build_header(gnvh, tun_flags, vni, opt_len, opt); 145 geneve_build_header(gnvh, tun_flags, vni, opt_len, opt);
146 146
147 skb_set_inner_protocol(skb, htons(ETH_P_TEB));
148
147 return udp_tunnel_xmit_skb(gs->sock, rt, skb, src, dst, 149 return udp_tunnel_xmit_skb(gs->sock, rt, skb, src, dst,
148 tos, ttl, df, src_port, dst_port, xnet); 150 tos, ttl, df, src_port, dst_port, xnet);
149} 151}
@@ -364,6 +366,7 @@ late_initcall(geneve_init_module);
364static void __exit geneve_cleanup_module(void) 366static void __exit geneve_cleanup_module(void)
365{ 367{
366 destroy_workqueue(geneve_wq); 368 destroy_workqueue(geneve_wq);
369 unregister_pernet_subsys(&geneve_net_ops);
367} 370}
368module_exit(geneve_cleanup_module); 371module_exit(geneve_cleanup_module);
369 372
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index fb70e3ecc3e4..bb15d0e03d4f 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -318,9 +318,7 @@ igmp_scount(struct ip_mc_list *pmc, int type, int gdeleted, int sdeleted)
318 return scount; 318 return scount;
319} 319}
320 320
321#define igmp_skb_size(skb) (*(unsigned int *)((skb)->cb)) 321static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
322
323static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
324{ 322{
325 struct sk_buff *skb; 323 struct sk_buff *skb;
326 struct rtable *rt; 324 struct rtable *rt;
@@ -330,6 +328,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
330 struct flowi4 fl4; 328 struct flowi4 fl4;
331 int hlen = LL_RESERVED_SPACE(dev); 329 int hlen = LL_RESERVED_SPACE(dev);
332 int tlen = dev->needed_tailroom; 330 int tlen = dev->needed_tailroom;
331 unsigned int size = mtu;
333 332
334 while (1) { 333 while (1) {
335 skb = alloc_skb(size + hlen + tlen, 334 skb = alloc_skb(size + hlen + tlen,
@@ -341,7 +340,6 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
341 return NULL; 340 return NULL;
342 } 341 }
343 skb->priority = TC_PRIO_CONTROL; 342 skb->priority = TC_PRIO_CONTROL;
344 igmp_skb_size(skb) = size;
345 343
346 rt = ip_route_output_ports(net, &fl4, NULL, IGMPV3_ALL_MCR, 0, 344 rt = ip_route_output_ports(net, &fl4, NULL, IGMPV3_ALL_MCR, 0,
347 0, 0, 345 0, 0,
@@ -354,6 +352,8 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
354 skb_dst_set(skb, &rt->dst); 352 skb_dst_set(skb, &rt->dst);
355 skb->dev = dev; 353 skb->dev = dev;
356 354
355 skb->reserved_tailroom = skb_end_offset(skb) -
356 min(mtu, skb_end_offset(skb));
357 skb_reserve(skb, hlen); 357 skb_reserve(skb, hlen);
358 358
359 skb_reset_network_header(skb); 359 skb_reset_network_header(skb);
@@ -423,8 +423,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
423 return skb; 423 return skb;
424} 424}
425 425
426#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? igmp_skb_size(skb) - (skb)->len : \ 426#define AVAILABLE(skb) ((skb) ? skb_availroom(skb) : 0)
427 skb_tailroom(skb)) : 0)
428 427
429static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, 428static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
430 int type, int gdeleted, int sdeleted) 429 int type, int gdeleted, int sdeleted)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index c373a9ad4555..9daf2177dc00 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -195,7 +195,7 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc,
195 for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) { 195 for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
196 if (!CMSG_OK(msg, cmsg)) 196 if (!CMSG_OK(msg, cmsg))
197 return -EINVAL; 197 return -EINVAL;
198#if defined(CONFIG_IPV6) 198#if IS_ENABLED(CONFIG_IPV6)
199 if (allow_ipv6 && 199 if (allow_ipv6 &&
200 cmsg->cmsg_level == SOL_IPV6 && 200 cmsg->cmsg_level == SOL_IPV6 &&
201 cmsg->cmsg_type == IPV6_PKTINFO) { 201 cmsg->cmsg_type == IPV6_PKTINFO) {
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 3e861011e4a3..1a7e979e80ba 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -528,6 +528,7 @@ static struct rtnl_link_ops vti_link_ops __read_mostly = {
528 .validate = vti_tunnel_validate, 528 .validate = vti_tunnel_validate,
529 .newlink = vti_newlink, 529 .newlink = vti_newlink,
530 .changelink = vti_changelink, 530 .changelink = vti_changelink,
531 .dellink = ip_tunnel_dellink,
531 .get_size = vti_get_size, 532 .get_size = vti_get_size,
532 .fill_info = vti_fill_info, 533 .fill_info = vti_fill_info,
533}; 534};
diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c
index c1023c445920..665de06561cd 100644
--- a/net/ipv4/netfilter/nft_masq_ipv4.c
+++ b/net/ipv4/netfilter/nft_masq_ipv4.c
@@ -24,6 +24,7 @@ static void nft_masq_ipv4_eval(const struct nft_expr *expr,
24 struct nf_nat_range range; 24 struct nf_nat_range range;
25 unsigned int verdict; 25 unsigned int verdict;
26 26
27 memset(&range, 0, sizeof(range));
27 range.flags = priv->flags; 28 range.flags = priv->flags;
28 29
29 verdict = nf_nat_masquerade_ipv4(pkt->skb, pkt->ops->hooknum, 30 verdict = nf_nat_masquerade_ipv4(pkt->skb, pkt->ops->hooknum,
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 57f7c9804139..5d740cccf69e 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -217,6 +217,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident)
217 &ipv6_hdr(skb)->daddr)) 217 &ipv6_hdr(skb)->daddr))
218 continue; 218 continue;
219#endif 219#endif
220 } else {
221 continue;
220 } 222 }
221 223
222 if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif) 224 if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)
@@ -853,16 +855,8 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
853 if (flags & MSG_OOB) 855 if (flags & MSG_OOB)
854 goto out; 856 goto out;
855 857
856 if (flags & MSG_ERRQUEUE) { 858 if (flags & MSG_ERRQUEUE)
857 if (family == AF_INET) { 859 return inet_recv_error(sk, msg, len, addr_len);
858 return ip_recv_error(sk, msg, len, addr_len);
859#if IS_ENABLED(CONFIG_IPV6)
860 } else if (family == AF_INET6) {
861 return pingv6_ops.ipv6_recv_error(sk, msg, len,
862 addr_len);
863#endif
864 }
865 }
866 860
867 skb = skb_recv_datagram(sk, flags, noblock, &err); 861 skb = skb_recv_datagram(sk, flags, noblock, &err);
868 if (!skb) 862 if (!skb)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 39ec0c379545..38c2bcb8dd5d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1598,7 +1598,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1598 u32 urg_hole = 0; 1598 u32 urg_hole = 0;
1599 1599
1600 if (unlikely(flags & MSG_ERRQUEUE)) 1600 if (unlikely(flags & MSG_ERRQUEUE))
1601 return ip_recv_error(sk, msg, len, addr_len); 1601 return inet_recv_error(sk, msg, len, addr_len);
1602 1602
1603 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) && 1603 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&
1604 (sk->sk_state == TCP_ESTABLISHED)) 1604 (sk->sk_state == TCP_ESTABLISHED))
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a12b455928e5..d107ee246a1d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2315,6 +2315,35 @@ static inline bool tcp_packet_delayed(const struct tcp_sock *tp)
2315 2315
2316/* Undo procedures. */ 2316/* Undo procedures. */
2317 2317
2318/* We can clear retrans_stamp when there are no retransmissions in the
2319 * window. It would seem that it is trivially available for us in
2320 * tp->retrans_out, however, that kind of assumptions doesn't consider
2321 * what will happen if errors occur when sending retransmission for the
2322 * second time. ...It could the that such segment has only
2323 * TCPCB_EVER_RETRANS set at the present time. It seems that checking
2324 * the head skb is enough except for some reneging corner cases that
2325 * are not worth the effort.
2326 *
2327 * Main reason for all this complexity is the fact that connection dying
2328 * time now depends on the validity of the retrans_stamp, in particular,
2329 * that successive retransmissions of a segment must not advance
2330 * retrans_stamp under any conditions.
2331 */
2332static bool tcp_any_retrans_done(const struct sock *sk)
2333{
2334 const struct tcp_sock *tp = tcp_sk(sk);
2335 struct sk_buff *skb;
2336
2337 if (tp->retrans_out)
2338 return true;
2339
2340 skb = tcp_write_queue_head(sk);
2341 if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS))
2342 return true;
2343
2344 return false;
2345}
2346
2318#if FASTRETRANS_DEBUG > 1 2347#if FASTRETRANS_DEBUG > 1
2319static void DBGUNDO(struct sock *sk, const char *msg) 2348static void DBGUNDO(struct sock *sk, const char *msg)
2320{ 2349{
@@ -2410,6 +2439,8 @@ static bool tcp_try_undo_recovery(struct sock *sk)
2410 * is ACKed. For Reno it is MUST to prevent false 2439 * is ACKed. For Reno it is MUST to prevent false
2411 * fast retransmits (RFC2582). SACK TCP is safe. */ 2440 * fast retransmits (RFC2582). SACK TCP is safe. */
2412 tcp_moderate_cwnd(tp); 2441 tcp_moderate_cwnd(tp);
2442 if (!tcp_any_retrans_done(sk))
2443 tp->retrans_stamp = 0;
2413 return true; 2444 return true;
2414 } 2445 }
2415 tcp_set_ca_state(sk, TCP_CA_Open); 2446 tcp_set_ca_state(sk, TCP_CA_Open);
@@ -2430,35 +2461,6 @@ static bool tcp_try_undo_dsack(struct sock *sk)
2430 return false; 2461 return false;
2431} 2462}
2432 2463
2433/* We can clear retrans_stamp when there are no retransmissions in the
2434 * window. It would seem that it is trivially available for us in
2435 * tp->retrans_out, however, that kind of assumptions doesn't consider
2436 * what will happen if errors occur when sending retransmission for the
2437 * second time. ...It could the that such segment has only
2438 * TCPCB_EVER_RETRANS set at the present time. It seems that checking
2439 * the head skb is enough except for some reneging corner cases that
2440 * are not worth the effort.
2441 *
2442 * Main reason for all this complexity is the fact that connection dying
2443 * time now depends on the validity of the retrans_stamp, in particular,
2444 * that successive retransmissions of a segment must not advance
2445 * retrans_stamp under any conditions.
2446 */
2447static bool tcp_any_retrans_done(const struct sock *sk)
2448{
2449 const struct tcp_sock *tp = tcp_sk(sk);
2450 struct sk_buff *skb;
2451
2452 if (tp->retrans_out)
2453 return true;
2454
2455 skb = tcp_write_queue_head(sk);
2456 if (unlikely(skb && TCP_SKB_CB(skb)->sacked & TCPCB_EVER_RETRANS))
2457 return true;
2458
2459 return false;
2460}
2461
2462/* Undo during loss recovery after partial ACK or using F-RTO. */ 2464/* Undo during loss recovery after partial ACK or using F-RTO. */
2463static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo) 2465static bool tcp_try_undo_loss(struct sock *sk, bool frto_undo)
2464{ 2466{
@@ -5229,7 +5231,7 @@ slow_path:
5229 if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb)) 5231 if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb))
5230 goto csum_error; 5232 goto csum_error;
5231 5233
5232 if (!th->ack && !th->rst) 5234 if (!th->ack && !th->rst && !th->syn)
5233 goto discard; 5235 goto discard;
5234 5236
5235 /* 5237 /*
@@ -5648,7 +5650,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
5648 goto discard; 5650 goto discard;
5649 } 5651 }
5650 5652
5651 if (!th->ack && !th->rst) 5653 if (!th->ack && !th->rst && !th->syn)
5652 goto discard; 5654 goto discard;
5653 5655
5654 if (!tcp_validate_incoming(sk, skb, th, 0)) 5656 if (!tcp_validate_incoming(sk, skb, th, 0))
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 9c7d7621466b..147be2024290 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -598,7 +598,10 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
598 if (th->rst) 598 if (th->rst)
599 return; 599 return;
600 600
601 if (skb_rtable(skb)->rt_type != RTN_LOCAL) 601 /* If sk not NULL, it means we did a successful lookup and incoming
602 * route had to be correct. prequeue might have dropped our dst.
603 */
604 if (!sk && skb_rtable(skb)->rt_type != RTN_LOCAL)
602 return; 605 return;
603 606
604 /* Swap the send and the receive. */ 607 /* Swap the send and the receive. */
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 12c3c8ef3849..0e32d2e1bdbf 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -502,11 +502,11 @@ static int ip6gre_rcv(struct sk_buff *skb)
502 502
503 skb->protocol = gre_proto; 503 skb->protocol = gre_proto;
504 /* WCCP version 1 and 2 protocol decoding. 504 /* WCCP version 1 and 2 protocol decoding.
505 * - Change protocol to IP 505 * - Change protocol to IPv6
506 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header 506 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
507 */ 507 */
508 if (flags == 0 && gre_proto == htons(ETH_P_WCCP)) { 508 if (flags == 0 && gre_proto == htons(ETH_P_WCCP)) {
509 skb->protocol = htons(ETH_P_IP); 509 skb->protocol = htons(ETH_P_IPV6);
510 if ((*(h + offset) & 0xF0) != 0x40) 510 if ((*(h + offset) & 0xF0) != 0x40)
511 offset += 4; 511 offset += 4;
512 } 512 }
@@ -961,8 +961,6 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
961 else 961 else
962 dev->flags &= ~IFF_POINTOPOINT; 962 dev->flags &= ~IFF_POINTOPOINT;
963 963
964 dev->iflink = p->link;
965
966 /* Precalculate GRE options length */ 964 /* Precalculate GRE options length */
967 if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) { 965 if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) {
968 if (t->parms.o_flags&GRE_CSUM) 966 if (t->parms.o_flags&GRE_CSUM)
@@ -1272,6 +1270,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
1272 u64_stats_init(&ip6gre_tunnel_stats->syncp); 1270 u64_stats_init(&ip6gre_tunnel_stats->syncp);
1273 } 1271 }
1274 1272
1273 dev->iflink = tunnel->parms.link;
1275 1274
1276 return 0; 1275 return 0;
1277} 1276}
@@ -1481,6 +1480,8 @@ static int ip6gre_tap_init(struct net_device *dev)
1481 if (!dev->tstats) 1480 if (!dev->tstats)
1482 return -ENOMEM; 1481 return -ENOMEM;
1483 1482
1483 dev->iflink = tunnel->parms.link;
1484
1484 return 0; 1485 return 0;
1485} 1486}
1486 1487
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index a071563a7e6e..01e12d0d8fcc 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -69,7 +69,8 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
69 int nhoff; 69 int nhoff;
70 70
71 if (unlikely(skb_shinfo(skb)->gso_type & 71 if (unlikely(skb_shinfo(skb)->gso_type &
72 ~(SKB_GSO_UDP | 72 ~(SKB_GSO_TCPV4 |
73 SKB_GSO_UDP |
73 SKB_GSO_DODGY | 74 SKB_GSO_DODGY |
74 SKB_GSO_TCP_ECN | 75 SKB_GSO_TCP_ECN |
75 SKB_GSO_GRE | 76 SKB_GSO_GRE |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 9409887fb664..9cb94cfa0ae7 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -272,9 +272,6 @@ static int ip6_tnl_create2(struct net_device *dev)
272 int err; 272 int err;
273 273
274 t = netdev_priv(dev); 274 t = netdev_priv(dev);
275 err = ip6_tnl_dev_init(dev);
276 if (err < 0)
277 goto out;
278 275
279 err = register_netdevice(dev); 276 err = register_netdevice(dev);
280 if (err < 0) 277 if (err < 0)
@@ -1462,6 +1459,7 @@ ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
1462 1459
1463 1460
1464static const struct net_device_ops ip6_tnl_netdev_ops = { 1461static const struct net_device_ops ip6_tnl_netdev_ops = {
1462 .ndo_init = ip6_tnl_dev_init,
1465 .ndo_uninit = ip6_tnl_dev_uninit, 1463 .ndo_uninit = ip6_tnl_dev_uninit,
1466 .ndo_start_xmit = ip6_tnl_xmit, 1464 .ndo_start_xmit = ip6_tnl_xmit,
1467 .ndo_do_ioctl = ip6_tnl_ioctl, 1465 .ndo_do_ioctl = ip6_tnl_ioctl,
@@ -1546,16 +1544,10 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
1546 struct ip6_tnl *t = netdev_priv(dev); 1544 struct ip6_tnl *t = netdev_priv(dev);
1547 struct net *net = dev_net(dev); 1545 struct net *net = dev_net(dev);
1548 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 1546 struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
1549 int err = ip6_tnl_dev_init_gen(dev);
1550
1551 if (err)
1552 return err;
1553 1547
1554 t->parms.proto = IPPROTO_IPV6; 1548 t->parms.proto = IPPROTO_IPV6;
1555 dev_hold(dev); 1549 dev_hold(dev);
1556 1550
1557 ip6_tnl_link_config(t);
1558
1559 rcu_assign_pointer(ip6n->tnls_wc[0], t); 1551 rcu_assign_pointer(ip6n->tnls_wc[0], t);
1560 return 0; 1552 return 0;
1561} 1553}
diff --git a/net/ipv6/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c
index b04ed72c4542..8db6c98fe218 100644
--- a/net/ipv6/ip6_udp_tunnel.c
+++ b/net/ipv6/ip6_udp_tunnel.c
@@ -79,15 +79,13 @@ int udp_tunnel6_xmit_skb(struct socket *sock, struct dst_entry *dst,
79 uh->source = src_port; 79 uh->source = src_port;
80 80
81 uh->len = htons(skb->len); 81 uh->len = htons(skb->len);
82 uh->check = 0;
83 82
84 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 83 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
85 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED 84 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
86 | IPSKB_REROUTED); 85 | IPSKB_REROUTED);
87 skb_dst_set(skb, dst); 86 skb_dst_set(skb, dst);
88 87
89 udp6_set_csum(udp_get_no_check6_tx(sk), skb, &inet6_sk(sk)->saddr, 88 udp6_set_csum(udp_get_no_check6_tx(sk), skb, saddr, daddr, skb->len);
90 &sk->sk_v6_daddr, skb->len);
91 89
92 __skb_push(skb, sizeof(*ip6h)); 90 __skb_push(skb, sizeof(*ip6h));
93 skb_reset_network_header(skb); 91 skb_reset_network_header(skb);
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index d440bb585524..bcda14de7f84 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -172,10 +172,6 @@ static int vti6_tnl_create2(struct net_device *dev)
172 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 172 struct vti6_net *ip6n = net_generic(net, vti6_net_id);
173 int err; 173 int err;
174 174
175 err = vti6_dev_init(dev);
176 if (err < 0)
177 goto out;
178
179 err = register_netdevice(dev); 175 err = register_netdevice(dev);
180 if (err < 0) 176 if (err < 0)
181 goto out; 177 goto out;
@@ -783,6 +779,7 @@ static int vti6_change_mtu(struct net_device *dev, int new_mtu)
783} 779}
784 780
785static const struct net_device_ops vti6_netdev_ops = { 781static const struct net_device_ops vti6_netdev_ops = {
782 .ndo_init = vti6_dev_init,
786 .ndo_uninit = vti6_dev_uninit, 783 .ndo_uninit = vti6_dev_uninit,
787 .ndo_start_xmit = vti6_tnl_xmit, 784 .ndo_start_xmit = vti6_tnl_xmit,
788 .ndo_do_ioctl = vti6_ioctl, 785 .ndo_do_ioctl = vti6_ioctl,
@@ -852,16 +849,10 @@ static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
852 struct ip6_tnl *t = netdev_priv(dev); 849 struct ip6_tnl *t = netdev_priv(dev);
853 struct net *net = dev_net(dev); 850 struct net *net = dev_net(dev);
854 struct vti6_net *ip6n = net_generic(net, vti6_net_id); 851 struct vti6_net *ip6n = net_generic(net, vti6_net_id);
855 int err = vti6_dev_init_gen(dev);
856
857 if (err)
858 return err;
859 852
860 t->parms.proto = IPPROTO_IPV6; 853 t->parms.proto = IPPROTO_IPV6;
861 dev_hold(dev); 854 dev_hold(dev);
862 855
863 vti6_link_config(t);
864
865 rcu_assign_pointer(ip6n->tnls_wc[0], t); 856 rcu_assign_pointer(ip6n->tnls_wc[0], t);
866 return 0; 857 return 0;
867} 858}
@@ -914,6 +905,15 @@ static int vti6_newlink(struct net *src_net, struct net_device *dev,
914 return vti6_tnl_create2(dev); 905 return vti6_tnl_create2(dev);
915} 906}
916 907
908static void vti6_dellink(struct net_device *dev, struct list_head *head)
909{
910 struct net *net = dev_net(dev);
911 struct vti6_net *ip6n = net_generic(net, vti6_net_id);
912
913 if (dev != ip6n->fb_tnl_dev)
914 unregister_netdevice_queue(dev, head);
915}
916
917static int vti6_changelink(struct net_device *dev, struct nlattr *tb[], 917static int vti6_changelink(struct net_device *dev, struct nlattr *tb[],
918 struct nlattr *data[]) 918 struct nlattr *data[])
919{ 919{
@@ -989,6 +989,7 @@ static struct rtnl_link_ops vti6_link_ops __read_mostly = {
989 .setup = vti6_dev_setup, 989 .setup = vti6_dev_setup,
990 .validate = vti6_validate, 990 .validate = vti6_validate,
991 .newlink = vti6_newlink, 991 .newlink = vti6_newlink,
992 .dellink = vti6_dellink,
992 .changelink = vti6_changelink, 993 .changelink = vti6_changelink,
993 .get_size = vti6_get_size, 994 .get_size = vti6_get_size,
994 .fill_info = vti6_fill_info, 995 .fill_info = vti6_fill_info,
@@ -1029,6 +1030,7 @@ static int __net_init vti6_init_net(struct net *net)
1029 if (!ip6n->fb_tnl_dev) 1030 if (!ip6n->fb_tnl_dev)
1030 goto err_alloc_dev; 1031 goto err_alloc_dev;
1031 dev_net_set(ip6n->fb_tnl_dev, net); 1032 dev_net_set(ip6n->fb_tnl_dev, net);
1033 ip6n->fb_tnl_dev->rtnl_link_ops = &vti6_link_ops;
1032 1034
1033 err = vti6_fb_tnl_dev_init(ip6n->fb_tnl_dev); 1035 err = vti6_fb_tnl_dev_init(ip6n->fb_tnl_dev);
1034 if (err < 0) 1036 if (err < 0)
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 0171f08325c3..1a01d79b8698 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1439,6 +1439,10 @@ reg_pernet_fail:
1439 1439
1440void ip6_mr_cleanup(void) 1440void ip6_mr_cleanup(void)
1441{ 1441{
1442 rtnl_unregister(RTNL_FAMILY_IP6MR, RTM_GETROUTE);
1443#ifdef CONFIG_IPV6_PIMSM_V2
1444 inet6_del_protocol(&pim6_protocol, IPPROTO_PIM);
1445#endif
1442 unregister_netdevice_notifier(&ip6_mr_notifier); 1446 unregister_netdevice_notifier(&ip6_mr_notifier);
1443 unregister_pernet_subsys(&ip6mr_net_ops); 1447 unregister_pernet_subsys(&ip6mr_net_ops);
1444 kmem_cache_destroy(mrt_cachep); 1448 kmem_cache_destroy(mrt_cachep);
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 9648de2b6745..ed2c4e400b46 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1550,7 +1550,7 @@ static void ip6_mc_hdr(struct sock *sk, struct sk_buff *skb,
1550 hdr->daddr = *daddr; 1550 hdr->daddr = *daddr;
1551} 1551}
1552 1552
1553static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size) 1553static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu)
1554{ 1554{
1555 struct net_device *dev = idev->dev; 1555 struct net_device *dev = idev->dev;
1556 struct net *net = dev_net(dev); 1556 struct net *net = dev_net(dev);
@@ -1561,13 +1561,13 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
1561 const struct in6_addr *saddr; 1561 const struct in6_addr *saddr;
1562 int hlen = LL_RESERVED_SPACE(dev); 1562 int hlen = LL_RESERVED_SPACE(dev);
1563 int tlen = dev->needed_tailroom; 1563 int tlen = dev->needed_tailroom;
1564 unsigned int size = mtu + hlen + tlen;
1564 int err; 1565 int err;
1565 u8 ra[8] = { IPPROTO_ICMPV6, 0, 1566 u8 ra[8] = { IPPROTO_ICMPV6, 0,
1566 IPV6_TLV_ROUTERALERT, 2, 0, 0, 1567 IPV6_TLV_ROUTERALERT, 2, 0, 0,
1567 IPV6_TLV_PADN, 0 }; 1568 IPV6_TLV_PADN, 0 };
1568 1569
1569 /* we assume size > sizeof(ra) here */ 1570 /* we assume size > sizeof(ra) here */
1570 size += hlen + tlen;
1571 /* limit our allocations to order-0 page */ 1571 /* limit our allocations to order-0 page */
1572 size = min_t(int, size, SKB_MAX_ORDER(0, 0)); 1572 size = min_t(int, size, SKB_MAX_ORDER(0, 0));
1573 skb = sock_alloc_send_skb(sk, size, 1, &err); 1573 skb = sock_alloc_send_skb(sk, size, 1, &err);
@@ -1576,6 +1576,8 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, int size)
1576 return NULL; 1576 return NULL;
1577 1577
1578 skb->priority = TC_PRIO_CONTROL; 1578 skb->priority = TC_PRIO_CONTROL;
1579 skb->reserved_tailroom = skb_end_offset(skb) -
1580 min(mtu, skb_end_offset(skb));
1579 skb_reserve(skb, hlen); 1581 skb_reserve(skb, hlen);
1580 1582
1581 if (__ipv6_get_lladdr(idev, &addr_buf, IFA_F_TENTATIVE)) { 1583 if (__ipv6_get_lladdr(idev, &addr_buf, IFA_F_TENTATIVE)) {
@@ -1690,8 +1692,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc,
1690 return skb; 1692 return skb;
1691} 1693}
1692 1694
1693#define AVAILABLE(skb) ((skb) ? ((skb)->dev ? (skb)->dev->mtu - (skb)->len : \ 1695#define AVAILABLE(skb) ((skb) ? skb_availroom(skb) : 0)
1694 skb_tailroom(skb)) : 0)
1695 1696
1696static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc, 1697static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
1697 int type, int gdeleted, int sdeleted, int crsend) 1698 int type, int gdeleted, int sdeleted, int crsend)
diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c
index 8a7ac685076d..529c119cbb14 100644
--- a/net/ipv6/netfilter/nft_masq_ipv6.c
+++ b/net/ipv6/netfilter/nft_masq_ipv6.c
@@ -25,6 +25,7 @@ static void nft_masq_ipv6_eval(const struct nft_expr *expr,
25 struct nf_nat_range range; 25 struct nf_nat_range range;
26 unsigned int verdict; 26 unsigned int verdict;
27 27
28 memset(&range, 0, sizeof(range));
28 range.flags = priv->flags; 29 range.flags = priv->flags;
29 30
30 verdict = nf_nat_masquerade_ipv6(pkt->skb, &range, pkt->out); 31 verdict = nf_nat_masquerade_ipv6(pkt->skb, &range, pkt->out);
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 58e5b4710127..a24557a1c1d8 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -195,10 +195,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
195 struct sit_net *sitn = net_generic(net, sit_net_id); 195 struct sit_net *sitn = net_generic(net, sit_net_id);
196 int err; 196 int err;
197 197
198 err = ipip6_tunnel_init(dev); 198 memcpy(dev->dev_addr, &t->parms.iph.saddr, 4);
199 if (err < 0) 199 memcpy(dev->broadcast, &t->parms.iph.daddr, 4);
200 goto out;
201 ipip6_tunnel_clone_6rd(dev, sitn);
202 200
203 if ((__force u16)t->parms.i_flags & SIT_ISATAP) 201 if ((__force u16)t->parms.i_flags & SIT_ISATAP)
204 dev->priv_flags |= IFF_ISATAP; 202 dev->priv_flags |= IFF_ISATAP;
@@ -207,7 +205,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
207 if (err < 0) 205 if (err < 0)
208 goto out; 206 goto out;
209 207
210 strcpy(t->parms.name, dev->name); 208 ipip6_tunnel_clone_6rd(dev, sitn);
209
211 dev->rtnl_link_ops = &sit_link_ops; 210 dev->rtnl_link_ops = &sit_link_ops;
212 211
213 dev_hold(dev); 212 dev_hold(dev);
@@ -1330,6 +1329,7 @@ static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu)
1330} 1329}
1331 1330
1332static const struct net_device_ops ipip6_netdev_ops = { 1331static const struct net_device_ops ipip6_netdev_ops = {
1332 .ndo_init = ipip6_tunnel_init,
1333 .ndo_uninit = ipip6_tunnel_uninit, 1333 .ndo_uninit = ipip6_tunnel_uninit,
1334 .ndo_start_xmit = sit_tunnel_xmit, 1334 .ndo_start_xmit = sit_tunnel_xmit,
1335 .ndo_do_ioctl = ipip6_tunnel_ioctl, 1335 .ndo_do_ioctl = ipip6_tunnel_ioctl,
@@ -1378,9 +1378,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
1378 1378
1379 tunnel->dev = dev; 1379 tunnel->dev = dev;
1380 tunnel->net = dev_net(dev); 1380 tunnel->net = dev_net(dev);
1381 1381 strcpy(tunnel->parms.name, dev->name);
1382 memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
1383 memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
1384 1382
1385 ipip6_tunnel_bind_dev(dev); 1383 ipip6_tunnel_bind_dev(dev);
1386 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 1384 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
@@ -1405,7 +1403,6 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1405 1403
1406 tunnel->dev = dev; 1404 tunnel->dev = dev;
1407 tunnel->net = dev_net(dev); 1405 tunnel->net = dev_net(dev);
1408 strcpy(tunnel->parms.name, dev->name);
1409 1406
1410 iph->version = 4; 1407 iph->version = 4;
1411 iph->protocol = IPPROTO_IPV6; 1408 iph->protocol = IPPROTO_IPV6;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index ace29b60813c..dc495ae2ead0 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -903,7 +903,10 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
903 if (th->rst) 903 if (th->rst)
904 return; 904 return;
905 905
906 if (!ipv6_unicast_destination(skb)) 906 /* If sk not NULL, it means we did a successful lookup and incoming
907 * route had to be correct. prequeue might have dropped our dst.
908 */
909 if (!sk && !ipv6_unicast_destination(skb))
907 return; 910 return;
908 911
909#ifdef CONFIG_TCP_MD5SIG 912#ifdef CONFIG_TCP_MD5SIG
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index 91729b807c7d..1b095ca37aa4 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -1764,6 +1764,7 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
1764 struct ipxhdr *ipx = NULL; 1764 struct ipxhdr *ipx = NULL;
1765 struct sk_buff *skb; 1765 struct sk_buff *skb;
1766 int copied, rc; 1766 int copied, rc;
1767 bool locked = true;
1767 1768
1768 lock_sock(sk); 1769 lock_sock(sk);
1769 /* put the autobinding in */ 1770 /* put the autobinding in */
@@ -1790,6 +1791,8 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
1790 if (sock_flag(sk, SOCK_ZAPPED)) 1791 if (sock_flag(sk, SOCK_ZAPPED))
1791 goto out; 1792 goto out;
1792 1793
1794 release_sock(sk);
1795 locked = false;
1793 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1796 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1794 flags & MSG_DONTWAIT, &rc); 1797 flags & MSG_DONTWAIT, &rc);
1795 if (!skb) { 1798 if (!skb) {
@@ -1826,7 +1829,8 @@ static int ipx_recvmsg(struct kiocb *iocb, struct socket *sock,
1826out_free: 1829out_free:
1827 skb_free_datagram(sk, skb); 1830 skb_free_datagram(sk, skb);
1828out: 1831out:
1829 release_sock(sk); 1832 if (locked)
1833 release_sock(sk);
1830 return rc; 1834 return rc;
1831} 1835}
1832 1836
diff --git a/net/mac80211/aes_ccm.c b/net/mac80211/aes_ccm.c
index ec24378caaaf..09d9caaec591 100644
--- a/net/mac80211/aes_ccm.c
+++ b/net/mac80211/aes_ccm.c
@@ -53,6 +53,9 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
53 __aligned(__alignof__(struct aead_request)); 53 __aligned(__alignof__(struct aead_request));
54 struct aead_request *aead_req = (void *) aead_req_data; 54 struct aead_request *aead_req = (void *) aead_req_data;
55 55
56 if (data_len == 0)
57 return -EINVAL;
58
56 memset(aead_req, 0, sizeof(aead_req_data)); 59 memset(aead_req, 0, sizeof(aead_req_data));
57 60
58 sg_init_one(&pt, data, data_len); 61 sg_init_one(&pt, data, data_len);
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 56b53571c807..509bc157ce55 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -805,7 +805,7 @@ ieee80211_ibss_process_chanswitch(struct ieee80211_sub_if_data *sdata,
805 805
806 memset(&params, 0, sizeof(params)); 806 memset(&params, 0, sizeof(params));
807 memset(&csa_ie, 0, sizeof(csa_ie)); 807 memset(&csa_ie, 0, sizeof(csa_ie));
808 err = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, 808 err = ieee80211_parse_ch_switch_ie(sdata, elems,
809 ifibss->chandef.chan->band, 809 ifibss->chandef.chan->band,
810 sta_flags, ifibss->bssid, &csa_ie); 810 sta_flags, ifibss->bssid, &csa_ie);
811 /* can't switch to destination channel, fail */ 811 /* can't switch to destination channel, fail */
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index c2aaec4dfcf0..8c68da30595d 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1642,7 +1642,6 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1642 * ieee80211_parse_ch_switch_ie - parses channel switch IEs 1642 * ieee80211_parse_ch_switch_ie - parses channel switch IEs
1643 * @sdata: the sdata of the interface which has received the frame 1643 * @sdata: the sdata of the interface which has received the frame
1644 * @elems: parsed 802.11 elements received with the frame 1644 * @elems: parsed 802.11 elements received with the frame
1645 * @beacon: indicates if the frame was a beacon or probe response
1646 * @current_band: indicates the current band 1645 * @current_band: indicates the current band
1647 * @sta_flags: contains information about own capabilities and restrictions 1646 * @sta_flags: contains information about own capabilities and restrictions
1648 * to decide which channel switch announcements can be accepted. Only the 1647 * to decide which channel switch announcements can be accepted. Only the
@@ -1656,7 +1655,7 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
1656 * Return: 0 on success, <0 on error and >0 if there is nothing to parse. 1655 * Return: 0 on success, <0 on error and >0 if there is nothing to parse.
1657 */ 1656 */
1658int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, 1657int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
1659 struct ieee802_11_elems *elems, bool beacon, 1658 struct ieee802_11_elems *elems,
1660 enum ieee80211_band current_band, 1659 enum ieee80211_band current_band,
1661 u32 sta_flags, u8 *bssid, 1660 u32 sta_flags, u8 *bssid,
1662 struct ieee80211_csa_ie *csa_ie); 1661 struct ieee80211_csa_ie *csa_ie);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index af237223a8cd..653f5eb07a27 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -766,10 +766,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
766 int i, flushed; 766 int i, flushed;
767 struct ps_data *ps; 767 struct ps_data *ps;
768 struct cfg80211_chan_def chandef; 768 struct cfg80211_chan_def chandef;
769 bool cancel_scan;
769 770
770 clear_bit(SDATA_STATE_RUNNING, &sdata->state); 771 clear_bit(SDATA_STATE_RUNNING, &sdata->state);
771 772
772 if (rcu_access_pointer(local->scan_sdata) == sdata) 773 cancel_scan = rcu_access_pointer(local->scan_sdata) == sdata;
774 if (cancel_scan)
773 ieee80211_scan_cancel(local); 775 ieee80211_scan_cancel(local);
774 776
775 /* 777 /*
@@ -898,6 +900,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
898 list_del(&sdata->u.vlan.list); 900 list_del(&sdata->u.vlan.list);
899 mutex_unlock(&local->mtx); 901 mutex_unlock(&local->mtx);
900 RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL); 902 RCU_INIT_POINTER(sdata->vif.chanctx_conf, NULL);
903 /* see comment in the default case below */
904 ieee80211_free_keys(sdata, true);
901 /* no need to tell driver */ 905 /* no need to tell driver */
902 break; 906 break;
903 case NL80211_IFTYPE_MONITOR: 907 case NL80211_IFTYPE_MONITOR:
@@ -923,17 +927,16 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
923 /* 927 /*
924 * When we get here, the interface is marked down. 928 * When we get here, the interface is marked down.
925 * Free the remaining keys, if there are any 929 * Free the remaining keys, if there are any
926 * (shouldn't be, except maybe in WDS mode?) 930 * (which can happen in AP mode if userspace sets
931 * keys before the interface is operating, and maybe
932 * also in WDS mode)
927 * 933 *
928 * Force the key freeing to always synchronize_net() 934 * Force the key freeing to always synchronize_net()
929 * to wait for the RX path in case it is using this 935 * to wait for the RX path in case it is using this
930 * interface enqueuing frames * at this very time on 936 * interface enqueuing frames at this very time on
931 * another CPU. 937 * another CPU.
932 */ 938 */
933 ieee80211_free_keys(sdata, true); 939 ieee80211_free_keys(sdata, true);
934
935 /* fall through */
936 case NL80211_IFTYPE_AP:
937 skb_queue_purge(&sdata->skb_queue); 940 skb_queue_purge(&sdata->skb_queue);
938 } 941 }
939 942
@@ -991,6 +994,9 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
991 994
992 ieee80211_recalc_ps(local, -1); 995 ieee80211_recalc_ps(local, -1);
993 996
997 if (cancel_scan)
998 flush_delayed_work(&local->scan_work);
999
994 if (local->open_count == 0) { 1000 if (local->open_count == 0) {
995 ieee80211_stop_device(local); 1001 ieee80211_stop_device(local);
996 1002
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index e9f99c1e3fad..0c8b2a77d312 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -874,7 +874,7 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
874 874
875 memset(&params, 0, sizeof(params)); 875 memset(&params, 0, sizeof(params));
876 memset(&csa_ie, 0, sizeof(csa_ie)); 876 memset(&csa_ie, 0, sizeof(csa_ie));
877 err = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, band, 877 err = ieee80211_parse_ch_switch_ie(sdata, elems, band,
878 sta_flags, sdata->vif.addr, 878 sta_flags, sdata->vif.addr,
879 &csa_ie); 879 &csa_ie);
880 if (err < 0) 880 if (err < 0)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2de88704278b..93af0f1c9d99 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1072,7 +1072,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1072 1072
1073 current_band = cbss->channel->band; 1073 current_band = cbss->channel->band;
1074 memset(&csa_ie, 0, sizeof(csa_ie)); 1074 memset(&csa_ie, 0, sizeof(csa_ie));
1075 res = ieee80211_parse_ch_switch_ie(sdata, elems, beacon, current_band, 1075 res = ieee80211_parse_ch_switch_ie(sdata, elems, current_band,
1076 ifmgd->flags, 1076 ifmgd->flags,
1077 ifmgd->associated->bssid, &csa_ie); 1077 ifmgd->associated->bssid, &csa_ie);
1078 if (res < 0) 1078 if (res < 0)
@@ -1168,7 +1168,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_sub_if_data *sdata,
1168 ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work); 1168 ieee80211_queue_work(&local->hw, &ifmgd->chswitch_work);
1169 else 1169 else
1170 mod_timer(&ifmgd->chswitch_timer, 1170 mod_timer(&ifmgd->chswitch_timer,
1171 TU_TO_EXP_TIME(csa_ie.count * cbss->beacon_interval)); 1171 TU_TO_EXP_TIME((csa_ie.count - 1) *
1172 cbss->beacon_interval));
1172} 1173}
1173 1174
1174static bool 1175static bool
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index df90ce2db00c..408fd8ab4eef 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -252,19 +252,16 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
252 cur_thr = mi->groups[cur_group].rates[cur_idx].cur_tp; 252 cur_thr = mi->groups[cur_group].rates[cur_idx].cur_tp;
253 cur_prob = mi->groups[cur_group].rates[cur_idx].probability; 253 cur_prob = mi->groups[cur_group].rates[cur_idx].probability;
254 254
255 tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; 255 do {
256 tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES;
257 tmp_thr = mi->groups[tmp_group].rates[tmp_idx].cur_tp;
258 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].probability;
259
260 while (j > 0 && (cur_thr > tmp_thr ||
261 (cur_thr == tmp_thr && cur_prob > tmp_prob))) {
262 j--;
263 tmp_group = tp_list[j - 1] / MCS_GROUP_RATES; 256 tmp_group = tp_list[j - 1] / MCS_GROUP_RATES;
264 tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES; 257 tmp_idx = tp_list[j - 1] % MCS_GROUP_RATES;
265 tmp_thr = mi->groups[tmp_group].rates[tmp_idx].cur_tp; 258 tmp_thr = mi->groups[tmp_group].rates[tmp_idx].cur_tp;
266 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].probability; 259 tmp_prob = mi->groups[tmp_group].rates[tmp_idx].probability;
267 } 260 if (cur_thr < tmp_thr ||
261 (cur_thr == tmp_thr && cur_prob <= tmp_prob))
262 break;
263 j--;
264 } while (j > 0);
268 265
269 if (j < MAX_THR_RATES - 1) { 266 if (j < MAX_THR_RATES - 1) {
270 memmove(&tp_list[j + 1], &tp_list[j], (sizeof(*tp_list) * 267 memmove(&tp_list[j + 1], &tp_list[j], (sizeof(*tp_list) *
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index b04ca4049c95..a37f9af634cb 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1678,11 +1678,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1678 sc = le16_to_cpu(hdr->seq_ctrl); 1678 sc = le16_to_cpu(hdr->seq_ctrl);
1679 frag = sc & IEEE80211_SCTL_FRAG; 1679 frag = sc & IEEE80211_SCTL_FRAG;
1680 1680
1681 if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || 1681 if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
1682 is_multicast_ether_addr(hdr->addr1))) { 1682 goto out;
1683 /* not fragmented */ 1683
1684 if (is_multicast_ether_addr(hdr->addr1)) {
1685 rx->local->dot11MulticastReceivedFrameCount++;
1684 goto out; 1686 goto out;
1685 } 1687 }
1688
1686 I802_DEBUG_INC(rx->local->rx_handlers_fragments); 1689 I802_DEBUG_INC(rx->local->rx_handlers_fragments);
1687 1690
1688 if (skb_linearize(rx->skb)) 1691 if (skb_linearize(rx->skb))
@@ -1775,10 +1778,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1775 out: 1778 out:
1776 if (rx->sta) 1779 if (rx->sta)
1777 rx->sta->rx_packets++; 1780 rx->sta->rx_packets++;
1778 if (is_multicast_ether_addr(hdr->addr1)) 1781 ieee80211_led_rx(rx->local);
1779 rx->local->dot11MulticastReceivedFrameCount++;
1780 else
1781 ieee80211_led_rx(rx->local);
1782 return RX_CONTINUE; 1782 return RX_CONTINUE;
1783} 1783}
1784 1784
diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c
index 6ab009070084..efeba56c913b 100644
--- a/net/mac80211/spectmgmt.c
+++ b/net/mac80211/spectmgmt.c
@@ -22,7 +22,7 @@
22#include "wme.h" 22#include "wme.h"
23 23
24int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata, 24int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
25 struct ieee802_11_elems *elems, bool beacon, 25 struct ieee802_11_elems *elems,
26 enum ieee80211_band current_band, 26 enum ieee80211_band current_band,
27 u32 sta_flags, u8 *bssid, 27 u32 sta_flags, u8 *bssid,
28 struct ieee80211_csa_ie *csa_ie) 28 struct ieee80211_csa_ie *csa_ie)
@@ -91,19 +91,13 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
91 return -EINVAL; 91 return -EINVAL;
92 } 92 }
93 93
94 if (!beacon && sec_chan_offs) { 94 if (sec_chan_offs) {
95 secondary_channel_offset = sec_chan_offs->sec_chan_offs; 95 secondary_channel_offset = sec_chan_offs->sec_chan_offs;
96 } else if (beacon && ht_oper) {
97 secondary_channel_offset =
98 ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
99 } else if (!(sta_flags & IEEE80211_STA_DISABLE_HT)) { 96 } else if (!(sta_flags & IEEE80211_STA_DISABLE_HT)) {
100 /* If it's not a beacon, HT is enabled and the IE not present, 97 /* If the secondary channel offset IE is not present,
101 * it's 20 MHz, 802.11-2012 8.5.2.6: 98 * we can't know what's the post-CSA offset, so the
102 * This element [the Secondary Channel Offset Element] is 99 * best we can do is use 20MHz.
103 * present when switching to a 40 MHz channel. It may be 100 */
104 * present when switching to a 20 MHz channel (in which
105 * case the secondary channel offset is set to SCN).
106 */
107 secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE; 101 secondary_channel_offset = IEEE80211_HT_PARAM_CHA_SEC_NONE;
108 } 102 }
109 103
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 86f9d76b1464..d259da3ce67a 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1863,6 +1863,12 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
1863 if (*op < IP_SET_OP_VERSION) { 1863 if (*op < IP_SET_OP_VERSION) {
1864 /* Check the version at the beginning of operations */ 1864 /* Check the version at the beginning of operations */
1865 struct ip_set_req_version *req_version = data; 1865 struct ip_set_req_version *req_version = data;
1866
1867 if (*len < sizeof(struct ip_set_req_version)) {
1868 ret = -EINVAL;
1869 goto done;
1870 }
1871
1866 if (req_version->version != IPSET_PROTOCOL) { 1872 if (req_version->version != IPSET_PROTOCOL) {
1867 ret = -EPROTO; 1873 ret = -EPROTO;
1868 goto done; 1874 goto done;
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 437a3663ad03..bd90bf8107da 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -846,6 +846,8 @@ ip_vs_prepare_tunneled_skb(struct sk_buff *skb, int skb_af,
846 new_skb = skb_realloc_headroom(skb, max_headroom); 846 new_skb = skb_realloc_headroom(skb, max_headroom);
847 if (!new_skb) 847 if (!new_skb)
848 goto error; 848 goto error;
849 if (skb->sk)
850 skb_set_owner_w(new_skb, skb->sk);
849 consume_skb(skb); 851 consume_skb(skb);
850 skb = new_skb; 852 skb = new_skb;
851 } 853 }
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 11ab4b078f3b..66e8425dbfe7 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3484,13 +3484,8 @@ static void nft_chain_commit_update(struct nft_trans *trans)
3484 } 3484 }
3485} 3485}
3486 3486
3487/* Schedule objects for release via rcu to make sure no packets are accesing 3487static void nf_tables_commit_release(struct nft_trans *trans)
3488 * removed rules.
3489 */
3490static void nf_tables_commit_release_rcu(struct rcu_head *rt)
3491{ 3488{
3492 struct nft_trans *trans = container_of(rt, struct nft_trans, rcu_head);
3493
3494 switch (trans->msg_type) { 3489 switch (trans->msg_type) {
3495 case NFT_MSG_DELTABLE: 3490 case NFT_MSG_DELTABLE:
3496 nf_tables_table_destroy(&trans->ctx); 3491 nf_tables_table_destroy(&trans->ctx);
@@ -3612,10 +3607,11 @@ static int nf_tables_commit(struct sk_buff *skb)
3612 } 3607 }
3613 } 3608 }
3614 3609
3610 synchronize_rcu();
3611
3615 list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { 3612 list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) {
3616 list_del(&trans->list); 3613 list_del(&trans->list);
3617 trans->ctx.nla = NULL; 3614 nf_tables_commit_release(trans);
3618 call_rcu(&trans->rcu_head, nf_tables_commit_release_rcu);
3619 } 3615 }
3620 3616
3621 nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN); 3617 nf_tables_gen_notify(net, skb, NFT_MSG_NEWGEN);
@@ -3623,13 +3619,8 @@ static int nf_tables_commit(struct sk_buff *skb)
3623 return 0; 3619 return 0;
3624} 3620}
3625 3621
3626/* Schedule objects for release via rcu to make sure no packets are accesing 3622static void nf_tables_abort_release(struct nft_trans *trans)
3627 * aborted rules.
3628 */
3629static void nf_tables_abort_release_rcu(struct rcu_head *rt)
3630{ 3623{
3631 struct nft_trans *trans = container_of(rt, struct nft_trans, rcu_head);
3632
3633 switch (trans->msg_type) { 3624 switch (trans->msg_type) {
3634 case NFT_MSG_NEWTABLE: 3625 case NFT_MSG_NEWTABLE:
3635 nf_tables_table_destroy(&trans->ctx); 3626 nf_tables_table_destroy(&trans->ctx);
@@ -3725,11 +3716,12 @@ static int nf_tables_abort(struct sk_buff *skb)
3725 } 3716 }
3726 } 3717 }
3727 3718
3719 synchronize_rcu();
3720
3728 list_for_each_entry_safe_reverse(trans, next, 3721 list_for_each_entry_safe_reverse(trans, next,
3729 &net->nft.commit_list, list) { 3722 &net->nft.commit_list, list) {
3730 list_del(&trans->list); 3723 list_del(&trans->list);
3731 trans->ctx.nla = NULL; 3724 nf_tables_abort_release(trans);
3732 call_rcu(&trans->rcu_head, nf_tables_abort_release_rcu);
3733 } 3725 }
3734 3726
3735 return 0; 3727 return 0;
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 6c5a915cfa75..13c2e17bbe27 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -47,6 +47,8 @@ static const int nfnl_group2type[NFNLGRP_MAX+1] = {
47 [NFNLGRP_CONNTRACK_EXP_NEW] = NFNL_SUBSYS_CTNETLINK_EXP, 47 [NFNLGRP_CONNTRACK_EXP_NEW] = NFNL_SUBSYS_CTNETLINK_EXP,
48 [NFNLGRP_CONNTRACK_EXP_UPDATE] = NFNL_SUBSYS_CTNETLINK_EXP, 48 [NFNLGRP_CONNTRACK_EXP_UPDATE] = NFNL_SUBSYS_CTNETLINK_EXP,
49 [NFNLGRP_CONNTRACK_EXP_DESTROY] = NFNL_SUBSYS_CTNETLINK_EXP, 49 [NFNLGRP_CONNTRACK_EXP_DESTROY] = NFNL_SUBSYS_CTNETLINK_EXP,
50 [NFNLGRP_NFTABLES] = NFNL_SUBSYS_NFTABLES,
51 [NFNLGRP_ACCT_QUOTA] = NFNL_SUBSYS_ACCT,
50}; 52};
51 53
52void nfnl_lock(__u8 subsys_id) 54void nfnl_lock(__u8 subsys_id)
@@ -464,7 +466,12 @@ static void nfnetlink_rcv(struct sk_buff *skb)
464static int nfnetlink_bind(int group) 466static int nfnetlink_bind(int group)
465{ 467{
466 const struct nfnetlink_subsystem *ss; 468 const struct nfnetlink_subsystem *ss;
467 int type = nfnl_group2type[group]; 469 int type;
470
471 if (group <= NFNLGRP_NONE || group > NFNLGRP_MAX)
472 return -EINVAL;
473
474 type = nfnl_group2type[group];
468 475
469 rcu_read_lock(); 476 rcu_read_lock();
470 ss = nfnetlink_get_subsys(type); 477 ss = nfnetlink_get_subsys(type);
@@ -514,6 +521,9 @@ static int __init nfnetlink_init(void)
514{ 521{
515 int i; 522 int i;
516 523
524 for (i = NFNLGRP_NONE + 1; i <= NFNLGRP_MAX; i++)
525 BUG_ON(nfnl_group2type[i] == NFNL_SUBSYS_NONE);
526
517 for (i=0; i<NFNL_SUBSYS_COUNT; i++) 527 for (i=0; i<NFNL_SUBSYS_COUNT; i++)
518 mutex_init(&table[i].mutex); 528 mutex_init(&table[i].mutex);
519 529
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 9d6d6f60a80f..265e190f2218 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -21,45 +21,17 @@
21#include <linux/netfilter_ipv6/ip6_tables.h> 21#include <linux/netfilter_ipv6/ip6_tables.h>
22#include <net/netfilter/nf_tables.h> 22#include <net/netfilter/nf_tables.h>
23 23
24static const struct {
25 const char *name;
26 u8 type;
27} table_to_chaintype[] = {
28 { "filter", NFT_CHAIN_T_DEFAULT },
29 { "raw", NFT_CHAIN_T_DEFAULT },
30 { "security", NFT_CHAIN_T_DEFAULT },
31 { "mangle", NFT_CHAIN_T_ROUTE },
32 { "nat", NFT_CHAIN_T_NAT },
33 { },
34};
35
36static int nft_compat_table_to_chaintype(const char *table)
37{
38 int i;
39
40 for (i = 0; table_to_chaintype[i].name != NULL; i++) {
41 if (strcmp(table_to_chaintype[i].name, table) == 0)
42 return table_to_chaintype[i].type;
43 }
44
45 return -1;
46}
47
48static int nft_compat_chain_validate_dependency(const char *tablename, 24static int nft_compat_chain_validate_dependency(const char *tablename,
49 const struct nft_chain *chain) 25 const struct nft_chain *chain)
50{ 26{
51 enum nft_chain_type type;
52 const struct nft_base_chain *basechain; 27 const struct nft_base_chain *basechain;
53 28
54 if (!tablename || !(chain->flags & NFT_BASE_CHAIN)) 29 if (!tablename || !(chain->flags & NFT_BASE_CHAIN))
55 return 0; 30 return 0;
56 31
57 type = nft_compat_table_to_chaintype(tablename);
58 if (type < 0)
59 return -EINVAL;
60
61 basechain = nft_base_chain(chain); 32 basechain = nft_base_chain(chain);
62 if (basechain->type->type != type) 33 if (strcmp(tablename, "nat") == 0 &&
34 basechain->type->type != NFT_CHAIN_T_NAT)
63 return -EINVAL; 35 return -EINVAL;
64 36
65 return 0; 37 return 0;
@@ -117,7 +89,7 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
117 struct xt_target *target, void *info, 89 struct xt_target *target, void *info,
118 union nft_entry *entry, u8 proto, bool inv) 90 union nft_entry *entry, u8 proto, bool inv)
119{ 91{
120 par->net = &init_net; 92 par->net = ctx->net;
121 par->table = ctx->table->name; 93 par->table = ctx->table->name;
122 switch (ctx->afi->family) { 94 switch (ctx->afi->family) {
123 case AF_INET: 95 case AF_INET:
@@ -324,7 +296,7 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
324 struct xt_match *match, void *info, 296 struct xt_match *match, void *info,
325 union nft_entry *entry, u8 proto, bool inv) 297 union nft_entry *entry, u8 proto, bool inv)
326{ 298{
327 par->net = &init_net; 299 par->net = ctx->net;
328 par->table = ctx->table->name; 300 par->table = ctx->table->name;
329 switch (ctx->afi->family) { 301 switch (ctx->afi->family) {
330 case AF_INET: 302 case AF_INET:
@@ -374,7 +346,7 @@ nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
374 union nft_entry e = {}; 346 union nft_entry e = {};
375 int ret; 347 int ret;
376 348
377 ret = nft_compat_chain_validate_dependency(match->name, ctx->chain); 349 ret = nft_compat_chain_validate_dependency(match->table, ctx->chain);
378 if (ret < 0) 350 if (ret < 0)
379 goto err; 351 goto err;
380 352
@@ -448,7 +420,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
448 if (!(hook_mask & match->hooks)) 420 if (!(hook_mask & match->hooks))
449 return -EINVAL; 421 return -EINVAL;
450 422
451 ret = nft_compat_chain_validate_dependency(match->name, 423 ret = nft_compat_chain_validate_dependency(match->table,
452 ctx->chain); 424 ctx->chain);
453 if (ret < 0) 425 if (ret < 0)
454 return ret; 426 return ret;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72de273e..0007b8180397 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1440,7 +1440,7 @@ static void netlink_unbind(int group, long unsigned int groups,
1440 return; 1440 return;
1441 1441
1442 for (undo = 0; undo < group; undo++) 1442 for (undo = 0; undo < group; undo++)
1443 if (test_bit(group, &groups)) 1443 if (test_bit(undo, &groups))
1444 nlk->netlink_unbind(undo); 1444 nlk->netlink_unbind(undo);
1445} 1445}
1446 1446
@@ -1492,7 +1492,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
1492 netlink_insert(sk, net, nladdr->nl_pid) : 1492 netlink_insert(sk, net, nladdr->nl_pid) :
1493 netlink_autobind(sock); 1493 netlink_autobind(sock);
1494 if (err) { 1494 if (err) {
1495 netlink_unbind(nlk->ngroups - 1, groups, nlk); 1495 netlink_unbind(nlk->ngroups, groups, nlk);
1496 return err; 1496 return err;
1497 } 1497 }
1498 } 1498 }
@@ -2509,6 +2509,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
2509 nl_table[unit].module = module; 2509 nl_table[unit].module = module;
2510 if (cfg) { 2510 if (cfg) {
2511 nl_table[unit].bind = cfg->bind; 2511 nl_table[unit].bind = cfg->bind;
2512 nl_table[unit].unbind = cfg->unbind;
2512 nl_table[unit].flags = cfg->flags; 2513 nl_table[unit].flags = cfg->flags;
2513 if (cfg->compare) 2514 if (cfg->compare)
2514 nl_table[unit].compare = cfg->compare; 2515 nl_table[unit].compare = cfg->compare;
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 006886dbee36..8c4229b11c34 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -246,11 +246,11 @@ static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto,
246{ 246{
247 int transport_len = skb->len - skb_transport_offset(skb); 247 int transport_len = skb->len - skb_transport_offset(skb);
248 248
249 if (l4_proto == IPPROTO_TCP) { 249 if (l4_proto == NEXTHDR_TCP) {
250 if (likely(transport_len >= sizeof(struct tcphdr))) 250 if (likely(transport_len >= sizeof(struct tcphdr)))
251 inet_proto_csum_replace16(&tcp_hdr(skb)->check, skb, 251 inet_proto_csum_replace16(&tcp_hdr(skb)->check, skb,
252 addr, new_addr, 1); 252 addr, new_addr, 1);
253 } else if (l4_proto == IPPROTO_UDP) { 253 } else if (l4_proto == NEXTHDR_UDP) {
254 if (likely(transport_len >= sizeof(struct udphdr))) { 254 if (likely(transport_len >= sizeof(struct udphdr))) {
255 struct udphdr *uh = udp_hdr(skb); 255 struct udphdr *uh = udp_hdr(skb);
256 256
@@ -261,6 +261,10 @@ static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto,
261 uh->check = CSUM_MANGLED_0; 261 uh->check = CSUM_MANGLED_0;
262 } 262 }
263 } 263 }
264 } else if (l4_proto == NEXTHDR_ICMP) {
265 if (likely(transport_len >= sizeof(struct icmp6hdr)))
266 inet_proto_csum_replace16(&icmp6_hdr(skb)->icmp6_cksum,
267 skb, addr, new_addr, 1);
264 } 268 }
265} 269}
266 270
@@ -722,8 +726,6 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
722 726
723 case OVS_ACTION_ATTR_SAMPLE: 727 case OVS_ACTION_ATTR_SAMPLE:
724 err = sample(dp, skb, key, a); 728 err = sample(dp, skb, key, a);
725 if (unlikely(err)) /* skb already freed. */
726 return err;
727 break; 729 break;
728 } 730 }
729 731
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index e6d7255183eb..f9e556b56086 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1265,7 +1265,7 @@ static size_t ovs_dp_cmd_msg_size(void)
1265 return msgsize; 1265 return msgsize;
1266} 1266}
1267 1267
1268/* Called with ovs_mutex or RCU read lock. */ 1268/* Called with ovs_mutex. */
1269static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb, 1269static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,
1270 u32 portid, u32 seq, u32 flags, u8 cmd) 1270 u32 portid, u32 seq, u32 flags, u8 cmd)
1271{ 1271{
@@ -1555,7 +1555,7 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct genl_info *info)
1555 if (!reply) 1555 if (!reply)
1556 return -ENOMEM; 1556 return -ENOMEM;
1557 1557
1558 rcu_read_lock(); 1558 ovs_lock();
1559 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs); 1559 dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
1560 if (IS_ERR(dp)) { 1560 if (IS_ERR(dp)) {
1561 err = PTR_ERR(dp); 1561 err = PTR_ERR(dp);
@@ -1564,12 +1564,12 @@ static int ovs_dp_cmd_get(struct sk_buff *skb, struct genl_info *info)
1564 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid, 1564 err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
1565 info->snd_seq, 0, OVS_DP_CMD_NEW); 1565 info->snd_seq, 0, OVS_DP_CMD_NEW);
1566 BUG_ON(err < 0); 1566 BUG_ON(err < 0);
1567 rcu_read_unlock(); 1567 ovs_unlock();
1568 1568
1569 return genlmsg_reply(reply, info); 1569 return genlmsg_reply(reply, info);
1570 1570
1571err_unlock_free: 1571err_unlock_free:
1572 rcu_read_unlock(); 1572 ovs_unlock();
1573 kfree_skb(reply); 1573 kfree_skb(reply);
1574 return err; 1574 return err;
1575} 1575}
@@ -1581,8 +1581,8 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1581 int skip = cb->args[0]; 1581 int skip = cb->args[0];
1582 int i = 0; 1582 int i = 0;
1583 1583
1584 rcu_read_lock(); 1584 ovs_lock();
1585 list_for_each_entry_rcu(dp, &ovs_net->dps, list_node) { 1585 list_for_each_entry(dp, &ovs_net->dps, list_node) {
1586 if (i >= skip && 1586 if (i >= skip &&
1587 ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid, 1587 ovs_dp_cmd_fill_info(dp, skb, NETLINK_CB(cb->skb).portid,
1588 cb->nlh->nlmsg_seq, NLM_F_MULTI, 1588 cb->nlh->nlmsg_seq, NLM_F_MULTI,
@@ -1590,7 +1590,7 @@ static int ovs_dp_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
1590 break; 1590 break;
1591 i++; 1591 i++;
1592 } 1592 }
1593 rcu_read_unlock(); 1593 ovs_unlock();
1594 1594
1595 cb->args[0] = i; 1595 cb->args[0] = i;
1596 1596
diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 939bcb32100f..089b195c064a 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -145,7 +145,7 @@ static bool match_validate(const struct sw_flow_match *match,
145 if (match->key->eth.type == htons(ETH_P_ARP) 145 if (match->key->eth.type == htons(ETH_P_ARP)
146 || match->key->eth.type == htons(ETH_P_RARP)) { 146 || match->key->eth.type == htons(ETH_P_RARP)) {
147 key_expected |= 1 << OVS_KEY_ATTR_ARP; 147 key_expected |= 1 << OVS_KEY_ATTR_ARP;
148 if (match->mask && (match->mask->key.eth.type == htons(0xffff))) 148 if (match->mask && (match->mask->key.tp.src == htons(0xff)))
149 mask_allowed |= 1 << OVS_KEY_ATTR_ARP; 149 mask_allowed |= 1 << OVS_KEY_ATTR_ARP;
150 } 150 }
151 151
@@ -689,6 +689,13 @@ static int ovs_key_from_nlattrs(struct sw_flow_match *match, u64 attrs,
689 ipv6_key->ipv6_frag, OVS_FRAG_TYPE_MAX); 689 ipv6_key->ipv6_frag, OVS_FRAG_TYPE_MAX);
690 return -EINVAL; 690 return -EINVAL;
691 } 691 }
692
693 if (!is_mask && ipv6_key->ipv6_label & htonl(0xFFF00000)) {
694 OVS_NLERR("IPv6 flow label %x is out of range (max=%x).\n",
695 ntohl(ipv6_key->ipv6_label), (1 << 20) - 1);
696 return -EINVAL;
697 }
698
692 SW_FLOW_KEY_PUT(match, ipv6.label, 699 SW_FLOW_KEY_PUT(match, ipv6.label,
693 ipv6_key->ipv6_label, is_mask); 700 ipv6_key->ipv6_label, is_mask);
694 SW_FLOW_KEY_PUT(match, ip.proto, 701 SW_FLOW_KEY_PUT(match, ip.proto,
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 87d20f48ff06..07c04a841ba0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -378,7 +378,7 @@ static void unregister_prot_hook(struct sock *sk, bool sync)
378 __unregister_prot_hook(sk, sync); 378 __unregister_prot_hook(sk, sync);
379} 379}
380 380
381static inline __pure struct page *pgv_to_page(void *addr) 381static inline struct page * __pure pgv_to_page(void *addr)
382{ 382{
383 if (is_vmalloc_addr(addr)) 383 if (is_vmalloc_addr(addr))
384 return vmalloc_to_page(addr); 384 return vmalloc_to_page(addr);
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index 0e8529113dc5..fb7976aee61c 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -862,8 +862,6 @@ int sctp_auth_set_key(struct sctp_endpoint *ep,
862 list_add(&cur_key->key_list, sh_keys); 862 list_add(&cur_key->key_list, sh_keys);
863 863
864 cur_key->key = key; 864 cur_key->key = key;
865 sctp_auth_key_hold(key);
866
867 return 0; 865 return 0;
868nomem: 866nomem:
869 if (!replace) 867 if (!replace)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index ab734be8cb20..9f32741abb1c 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2609,6 +2609,9 @@ do_addr_param:
2609 addr_param = param.v + sizeof(sctp_addip_param_t); 2609 addr_param = param.v + sizeof(sctp_addip_param_t);
2610 2610
2611 af = sctp_get_af_specific(param_type2af(param.p->type)); 2611 af = sctp_get_af_specific(param_type2af(param.p->type));
2612 if (af == NULL)
2613 break;
2614
2612 af->from_addr_param(&addr, addr_param, 2615 af->from_addr_param(&addr, addr_param,
2613 htons(asoc->peer.port), 0); 2616 htons(asoc->peer.port), 0);
2614 2617
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index afb292cd797d..53ed8d3f8897 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -1353,6 +1353,7 @@ gss_stringify_acceptor(struct rpc_cred *cred)
1353 char *string = NULL; 1353 char *string = NULL;
1354 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base); 1354 struct gss_cred *gss_cred = container_of(cred, struct gss_cred, gc_base);
1355 struct gss_cl_ctx *ctx; 1355 struct gss_cl_ctx *ctx;
1356 unsigned int len;
1356 struct xdr_netobj *acceptor; 1357 struct xdr_netobj *acceptor;
1357 1358
1358 rcu_read_lock(); 1359 rcu_read_lock();
@@ -1360,15 +1361,39 @@ gss_stringify_acceptor(struct rpc_cred *cred)
1360 if (!ctx) 1361 if (!ctx)
1361 goto out; 1362 goto out;
1362 1363
1363 acceptor = &ctx->gc_acceptor; 1364 len = ctx->gc_acceptor.len;
1365 rcu_read_unlock();
1364 1366
1365 /* no point if there's no string */ 1367 /* no point if there's no string */
1366 if (!acceptor->len) 1368 if (!len)
1367 goto out; 1369 return NULL;
1368 1370realloc:
1369 string = kmalloc(acceptor->len + 1, GFP_KERNEL); 1371 string = kmalloc(len + 1, GFP_KERNEL);
1370 if (!string) 1372 if (!string)
1373 return NULL;
1374
1375 rcu_read_lock();
1376 ctx = rcu_dereference(gss_cred->gc_ctx);
1377
1378 /* did the ctx disappear or was it replaced by one with no acceptor? */
1379 if (!ctx || !ctx->gc_acceptor.len) {
1380 kfree(string);
1381 string = NULL;
1371 goto out; 1382 goto out;
1383 }
1384
1385 acceptor = &ctx->gc_acceptor;
1386
1387 /*
1388 * Did we find a new acceptor that's longer than the original? Allocate
1389 * a longer buffer and try again.
1390 */
1391 if (len < acceptor->len) {
1392 len = acceptor->len;
1393 rcu_read_unlock();
1394 kfree(string);
1395 goto realloc;
1396 }
1372 1397
1373 memcpy(string, acceptor->data, acceptor->len); 1398 memcpy(string, acceptor->data, acceptor->len);
1374 string[acceptor->len] = '\0'; 1399 string[acceptor->len] = '\0';
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 3f959c681885..f9c052d508f0 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -1019,17 +1019,12 @@ static int receive_cb_reply(struct svc_sock *svsk, struct svc_rqst *rqstp)
1019 xid = *p++; 1019 xid = *p++;
1020 calldir = *p; 1020 calldir = *p;
1021 1021
1022 if (bc_xprt) 1022 if (!bc_xprt)
1023 req = xprt_lookup_rqst(bc_xprt, xid);
1024
1025 if (!req) {
1026 printk(KERN_NOTICE
1027 "%s: Got unrecognized reply: "
1028 "calldir 0x%x xpt_bc_xprt %p xid %08x\n",
1029 __func__, ntohl(calldir),
1030 bc_xprt, ntohl(xid));
1031 return -EAGAIN; 1023 return -EAGAIN;
1032 } 1024 spin_lock_bh(&bc_xprt->transport_lock);
1025 req = xprt_lookup_rqst(bc_xprt, xid);
1026 if (!req)
1027 goto unlock_notfound;
1033 1028
1034 memcpy(&req->rq_private_buf, &req->rq_rcv_buf, sizeof(struct xdr_buf)); 1029 memcpy(&req->rq_private_buf, &req->rq_rcv_buf, sizeof(struct xdr_buf));
1035 /* 1030 /*
@@ -1040,11 +1035,21 @@ static int receive_cb_reply(struct svc_sock *svsk, struct svc_rqst *rqstp)
1040 dst = &req->rq_private_buf.head[0]; 1035 dst = &req->rq_private_buf.head[0];
1041 src = &rqstp->rq_arg.head[0]; 1036 src = &rqstp->rq_arg.head[0];
1042 if (dst->iov_len < src->iov_len) 1037 if (dst->iov_len < src->iov_len)
1043 return -EAGAIN; /* whatever; just giving up. */ 1038 goto unlock_eagain; /* whatever; just giving up. */
1044 memcpy(dst->iov_base, src->iov_base, src->iov_len); 1039 memcpy(dst->iov_base, src->iov_base, src->iov_len);
1045 xprt_complete_rqst(req->rq_task, rqstp->rq_arg.len); 1040 xprt_complete_rqst(req->rq_task, rqstp->rq_arg.len);
1046 rqstp->rq_arg.len = 0; 1041 rqstp->rq_arg.len = 0;
1042 spin_unlock_bh(&bc_xprt->transport_lock);
1047 return 0; 1043 return 0;
1044unlock_notfound:
1045 printk(KERN_NOTICE
1046 "%s: Got unrecognized reply: "
1047 "calldir 0x%x xpt_bc_xprt %p xid %08x\n",
1048 __func__, ntohl(calldir),
1049 bc_xprt, ntohl(xid));
1050unlock_eagain:
1051 spin_unlock_bh(&bc_xprt->transport_lock);
1052 return -EAGAIN;
1048} 1053}
1049 1054
1050static int copy_pages_to_kvecs(struct kvec *vec, struct page **pages, int len) 1055static int copy_pages_to_kvecs(struct kvec *vec, struct page **pages, int len)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e66314138b38..c603b20356ad 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4725,9 +4725,10 @@ static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb)
4725 err = selinux_nlmsg_lookup(sksec->sclass, nlh->nlmsg_type, &perm); 4725 err = selinux_nlmsg_lookup(sksec->sclass, nlh->nlmsg_type, &perm);
4726 if (err) { 4726 if (err) {
4727 if (err == -EINVAL) { 4727 if (err == -EINVAL) {
4728 WARN_ONCE(1, "selinux_nlmsg_perm: unrecognized netlink message:" 4728 printk(KERN_WARNING
4729 " protocol=%hu nlmsg_type=%hu sclass=%hu\n", 4729 "SELinux: unrecognized netlink message:"
4730 sk->sk_protocol, nlh->nlmsg_type, sksec->sclass); 4730 " protocol=%hu nlmsg_type=%hu sclass=%hu\n",
4731 sk->sk_protocol, nlh->nlmsg_type, sksec->sclass);
4731 if (!selinux_enforcing || security_get_allow_unknown()) 4732 if (!selinux_enforcing || security_get_allow_unknown())
4732 err = 0; 4733 err = 0;
4733 } 4734 }
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 42ded997b223..c6ff94ab1ad6 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -216,6 +216,8 @@ static char *snd_pcm_format_names[] = {
216 FORMAT(DSD_U8), 216 FORMAT(DSD_U8),
217 FORMAT(DSD_U16_LE), 217 FORMAT(DSD_U16_LE),
218 FORMAT(DSD_U32_LE), 218 FORMAT(DSD_U32_LE),
219 FORMAT(DSD_U16_BE),
220 FORMAT(DSD_U32_BE),
219}; 221};
220 222
221const char *snd_pcm_format_name(snd_pcm_format_t format) 223const char *snd_pcm_format_name(snd_pcm_format_t format)
diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
index ae7a0feb3b76..ebe8444de6c6 100644
--- a/sound/core/pcm_misc.c
+++ b/sound/core/pcm_misc.c
@@ -152,6 +152,14 @@ static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
152 .width = 32, .phys = 32, .le = 1, .signd = 0, 152 .width = 32, .phys = 32, .le = 1, .signd = 0,
153 .silence = { 0x69, 0x69, 0x69, 0x69 }, 153 .silence = { 0x69, 0x69, 0x69, 0x69 },
154 }, 154 },
155 [SNDRV_PCM_FORMAT_DSD_U16_BE] = {
156 .width = 16, .phys = 16, .le = 0, .signd = 0,
157 .silence = { 0x69, 0x69 },
158 },
159 [SNDRV_PCM_FORMAT_DSD_U32_BE] = {
160 .width = 32, .phys = 32, .le = 0, .signd = 0,
161 .silence = { 0x69, 0x69, 0x69, 0x69 },
162 },
155 /* FIXME: the following three formats are not defined properly yet */ 163 /* FIXME: the following three formats are not defined properly yet */
156 [SNDRV_PCM_FORMAT_MPEG] = { 164 [SNDRV_PCM_FORMAT_MPEG] = {
157 .le = -1, .signd = -1, 165 .le = -1, .signd = -1,
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 9ab1e631cb32..48b6c5a3884f 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -219,6 +219,7 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
219 "{Intel, LPT_LP}," 219 "{Intel, LPT_LP},"
220 "{Intel, WPT_LP}," 220 "{Intel, WPT_LP},"
221 "{Intel, SPT}," 221 "{Intel, SPT},"
222 "{Intel, SPT_LP},"
222 "{Intel, HPT}," 223 "{Intel, HPT},"
223 "{Intel, PBG}," 224 "{Intel, PBG},"
224 "{Intel, SCH}," 225 "{Intel, SCH},"
@@ -297,7 +298,8 @@ enum {
297 298
298/* quirks for ATI/AMD HDMI */ 299/* quirks for ATI/AMD HDMI */
299#define AZX_DCAPS_PRESET_ATI_HDMI \ 300#define AZX_DCAPS_PRESET_ATI_HDMI \
300 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB) 301 (AZX_DCAPS_NO_TCSEL | AZX_DCAPS_SYNC_WRITE | AZX_DCAPS_POSFIX_LPIB|\
302 AZX_DCAPS_NO_MSI64)
301 303
302/* quirks for Nvidia */ 304/* quirks for Nvidia */
303#define AZX_DCAPS_PRESET_NVIDIA \ 305#define AZX_DCAPS_PRESET_NVIDIA \
@@ -1485,6 +1487,7 @@ static int azx_first_init(struct azx *chip)
1485 struct snd_card *card = chip->card; 1487 struct snd_card *card = chip->card;
1486 int err; 1488 int err;
1487 unsigned short gcap; 1489 unsigned short gcap;
1490 unsigned int dma_bits = 64;
1488 1491
1489#if BITS_PER_LONG != 64 1492#if BITS_PER_LONG != 64
1490 /* Fix up base address on ULI M5461 */ 1493 /* Fix up base address on ULI M5461 */
@@ -1508,9 +1511,14 @@ static int azx_first_init(struct azx *chip)
1508 return -ENXIO; 1511 return -ENXIO;
1509 } 1512 }
1510 1513
1511 if (chip->msi) 1514 if (chip->msi) {
1515 if (chip->driver_caps & AZX_DCAPS_NO_MSI64) {
1516 dev_dbg(card->dev, "Disabling 64bit MSI\n");
1517 pci->no_64bit_msi = true;
1518 }
1512 if (pci_enable_msi(pci) < 0) 1519 if (pci_enable_msi(pci) < 0)
1513 chip->msi = 0; 1520 chip->msi = 0;
1521 }
1514 1522
1515 if (azx_acquire_irq(chip, 0) < 0) 1523 if (azx_acquire_irq(chip, 0) < 0)
1516 return -EBUSY; 1524 return -EBUSY;
@@ -1521,9 +1529,14 @@ static int azx_first_init(struct azx *chip)
1521 gcap = azx_readw(chip, GCAP); 1529 gcap = azx_readw(chip, GCAP);
1522 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); 1530 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap);
1523 1531
1532 /* AMD devices support 40 or 48bit DMA, take the safe one */
1533 if (chip->pci->vendor == PCI_VENDOR_ID_AMD)
1534 dma_bits = 40;
1535
1524 /* disable SB600 64bit support for safety */ 1536 /* disable SB600 64bit support for safety */
1525 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { 1537 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
1526 struct pci_dev *p_smbus; 1538 struct pci_dev *p_smbus;
1539 dma_bits = 40;
1527 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI, 1540 p_smbus = pci_get_device(PCI_VENDOR_ID_ATI,
1528 PCI_DEVICE_ID_ATI_SBX00_SMBUS, 1541 PCI_DEVICE_ID_ATI_SBX00_SMBUS,
1529 NULL); 1542 NULL);
@@ -1553,9 +1566,11 @@ static int azx_first_init(struct azx *chip)
1553 } 1566 }
1554 1567
1555 /* allow 64bit DMA address if supported by H/W */ 1568 /* allow 64bit DMA address if supported by H/W */
1556 if ((gcap & AZX_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) 1569 if (!(gcap & AZX_GCAP_64OK))
1557 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); 1570 dma_bits = 32;
1558 else { 1571 if (!pci_set_dma_mask(pci, DMA_BIT_MASK(dma_bits))) {
1572 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(dma_bits));
1573 } else {
1559 pci_set_dma_mask(pci, DMA_BIT_MASK(32)); 1574 pci_set_dma_mask(pci, DMA_BIT_MASK(32));
1560 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)); 1575 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32));
1561 } 1576 }
@@ -2004,6 +2019,9 @@ static const struct pci_device_id azx_ids[] = {
2004 /* Sunrise Point */ 2019 /* Sunrise Point */
2005 { PCI_DEVICE(0x8086, 0xa170), 2020 { PCI_DEVICE(0x8086, 0xa170),
2006 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, 2021 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
2022 /* Sunrise Point-LP */
2023 { PCI_DEVICE(0x8086, 0x9d70),
2024 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
2007 /* Haswell */ 2025 /* Haswell */
2008 { PCI_DEVICE(0x8086, 0x0a0c), 2026 { PCI_DEVICE(0x8086, 0x0a0c),
2009 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, 2027 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL },
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
index 949cd437eeb2..5016014e57f2 100644
--- a/sound/pci/hda/hda_priv.h
+++ b/sound/pci/hda/hda_priv.h
@@ -171,6 +171,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
171#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */ 171#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
172#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */ 172#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */
173#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */ 173#define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28) /* CORBRP clears itself after reset */
174#define AZX_DCAPS_NO_MSI64 (1 << 29) /* Stick to 32-bit MSIs */
174 175
175/* HD Audio class code */ 176/* HD Audio class code */
176#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403 177#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 71e4bad06345..e9ebc7bd752c 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -43,6 +43,7 @@ struct conexant_spec {
43 unsigned int num_eapds; 43 unsigned int num_eapds;
44 hda_nid_t eapds[4]; 44 hda_nid_t eapds[4];
45 bool dynamic_eapd; 45 bool dynamic_eapd;
46 hda_nid_t mute_led_eapd;
46 47
47 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 48 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
48 49
@@ -163,6 +164,17 @@ static void cx_auto_vmaster_hook(void *private_data, int enabled)
163 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled); 164 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
164} 165}
165 166
167/* turn on/off EAPD according to Master switch (inversely!) for mute LED */
168static void cx_auto_vmaster_hook_mute_led(void *private_data, int enabled)
169{
170 struct hda_codec *codec = private_data;
171 struct conexant_spec *spec = codec->spec;
172
173 snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
174 AC_VERB_SET_EAPD_BTLENABLE,
175 enabled ? 0x00 : 0x02);
176}
177
166static int cx_auto_build_controls(struct hda_codec *codec) 178static int cx_auto_build_controls(struct hda_codec *codec)
167{ 179{
168 int err; 180 int err;
@@ -223,6 +235,7 @@ enum {
223 CXT_FIXUP_TOSHIBA_P105, 235 CXT_FIXUP_TOSHIBA_P105,
224 CXT_FIXUP_HP_530, 236 CXT_FIXUP_HP_530,
225 CXT_FIXUP_CAP_MIX_AMP_5047, 237 CXT_FIXUP_CAP_MIX_AMP_5047,
238 CXT_FIXUP_MUTE_LED_EAPD,
226}; 239};
227 240
228/* for hda_fixup_thinkpad_acpi() */ 241/* for hda_fixup_thinkpad_acpi() */
@@ -557,6 +570,18 @@ static void cxt_fixup_olpc_xo(struct hda_codec *codec,
557 } 570 }
558} 571}
559 572
573static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
574 const struct hda_fixup *fix, int action)
575{
576 struct conexant_spec *spec = codec->spec;
577
578 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
579 spec->mute_led_eapd = 0x1b;
580 spec->dynamic_eapd = 1;
581 spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook_mute_led;
582 }
583}
584
560/* 585/*
561 * Fix max input level on mixer widget to 0dB 586 * Fix max input level on mixer widget to 0dB
562 * (originally it has 0x2b steps with 0dB offset 0x14) 587 * (originally it has 0x2b steps with 0dB offset 0x14)
@@ -705,6 +730,10 @@ static const struct hda_fixup cxt_fixups[] = {
705 .type = HDA_FIXUP_FUNC, 730 .type = HDA_FIXUP_FUNC,
706 .v.func = cxt_fixup_cap_mix_amp_5047, 731 .v.func = cxt_fixup_cap_mix_amp_5047,
707 }, 732 },
733 [CXT_FIXUP_MUTE_LED_EAPD] = {
734 .type = HDA_FIXUP_FUNC,
735 .v.func = cxt_fixup_mute_led_eapd,
736 },
708}; 737};
709 738
710static const struct snd_pci_quirk cxt5045_fixups[] = { 739static const struct snd_pci_quirk cxt5045_fixups[] = {
@@ -762,6 +791,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
762 SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410), 791 SND_PCI_QUIRK(0x17aa, 0x21cf, "Lenovo T520", CXT_PINCFG_LENOVO_TP410),
763 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410), 792 SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
764 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410), 793 SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
794 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
765 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC), 795 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
766 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC), 796 SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
767 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC), 797 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
@@ -780,6 +810,7 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = {
780 { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" }, 810 { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
781 { .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" }, 811 { .id = CXT_PINCFG_LEMOTE_A1205, .name = "lemote-a1205" },
782 { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" }, 812 { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
813 { .id = CXT_FIXUP_MUTE_LED_EAPD, .name = "mute-led-eapd" },
783 {} 814 {}
784}; 815};
785 816
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index da03693099eb..14f16be3f374 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -288,6 +288,80 @@ static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
288 snd_hda_jack_unsol_event(codec, res >> 2); 288 snd_hda_jack_unsol_event(codec, res >> 2);
289} 289}
290 290
291/* Change EAPD to verb control */
292static void alc_fill_eapd_coef(struct hda_codec *codec)
293{
294 int coef;
295
296 coef = alc_get_coef0(codec);
297
298 switch (codec->vendor_id) {
299 case 0x10ec0262:
300 alc_update_coef_idx(codec, 0x7, 0, 1<<5);
301 break;
302 case 0x10ec0267:
303 case 0x10ec0268:
304 alc_update_coef_idx(codec, 0x7, 0, 1<<13);
305 break;
306 case 0x10ec0269:
307 if ((coef & 0x00f0) == 0x0010)
308 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
309 if ((coef & 0x00f0) == 0x0020)
310 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
311 if ((coef & 0x00f0) == 0x0030)
312 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
313 break;
314 case 0x10ec0280:
315 case 0x10ec0284:
316 case 0x10ec0290:
317 case 0x10ec0292:
318 alc_update_coef_idx(codec, 0x4, 1<<15, 0);
319 break;
320 case 0x10ec0233:
321 case 0x10ec0255:
322 case 0x10ec0282:
323 case 0x10ec0283:
324 case 0x10ec0286:
325 case 0x10ec0288:
326 alc_update_coef_idx(codec, 0x10, 1<<9, 0);
327 break;
328 case 0x10ec0285:
329 case 0x10ec0293:
330 alc_update_coef_idx(codec, 0xa, 1<<13, 0);
331 break;
332 case 0x10ec0662:
333 if ((coef & 0x00f0) == 0x0030)
334 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
335 break;
336 case 0x10ec0272:
337 case 0x10ec0273:
338 case 0x10ec0663:
339 case 0x10ec0665:
340 case 0x10ec0670:
341 case 0x10ec0671:
342 case 0x10ec0672:
343 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
344 break;
345 case 0x10ec0668:
346 alc_update_coef_idx(codec, 0x7, 3<<13, 0);
347 break;
348 case 0x10ec0867:
349 alc_update_coef_idx(codec, 0x4, 1<<10, 0);
350 break;
351 case 0x10ec0888:
352 if ((coef & 0x00f0) == 0x0020 || (coef & 0x00f0) == 0x0030)
353 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
354 break;
355 case 0x10ec0892:
356 alc_update_coef_idx(codec, 0x7, 1<<5, 0);
357 break;
358 case 0x10ec0899:
359 case 0x10ec0900:
360 alc_update_coef_idx(codec, 0x7, 1<<1, 0);
361 break;
362 }
363}
364
291/* additional initialization for ALC888 variants */ 365/* additional initialization for ALC888 variants */
292static void alc888_coef_init(struct hda_codec *codec) 366static void alc888_coef_init(struct hda_codec *codec)
293{ 367{
@@ -339,6 +413,7 @@ static void alc_eapd_shutup(struct hda_codec *codec)
339/* generic EAPD initialization */ 413/* generic EAPD initialization */
340static void alc_auto_init_amp(struct hda_codec *codec, int type) 414static void alc_auto_init_amp(struct hda_codec *codec, int type)
341{ 415{
416 alc_fill_eapd_coef(codec);
342 alc_auto_setup_eapd(codec, true); 417 alc_auto_setup_eapd(codec, true);
343 switch (type) { 418 switch (type) {
344 case ALC_INIT_GPIO1: 419 case ALC_INIT_GPIO1:
@@ -4445,6 +4520,8 @@ static const struct hda_fixup alc269_fixups[] = {
4445 [ALC269_FIXUP_HEADSET_MODE] = { 4520 [ALC269_FIXUP_HEADSET_MODE] = {
4446 .type = HDA_FIXUP_FUNC, 4521 .type = HDA_FIXUP_FUNC,
4447 .v.func = alc_fixup_headset_mode, 4522 .v.func = alc_fixup_headset_mode,
4523 .chained = true,
4524 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
4448 }, 4525 },
4449 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = { 4526 [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4450 .type = HDA_FIXUP_FUNC, 4527 .type = HDA_FIXUP_FUNC,
@@ -4634,6 +4711,8 @@ static const struct hda_fixup alc269_fixups[] = {
4634 [ALC255_FIXUP_HEADSET_MODE] = { 4711 [ALC255_FIXUP_HEADSET_MODE] = {
4635 .type = HDA_FIXUP_FUNC, 4712 .type = HDA_FIXUP_FUNC,
4636 .v.func = alc_fixup_headset_mode_alc255, 4713 .v.func = alc_fixup_headset_mode_alc255,
4714 .chained = true,
4715 .chain_id = ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED
4637 }, 4716 },
4638 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = { 4717 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4639 .type = HDA_FIXUP_FUNC, 4718 .type = HDA_FIXUP_FUNC,
@@ -4669,8 +4748,6 @@ static const struct hda_fixup alc269_fixups[] = {
4669 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = { 4748 [ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED] = {
4670 .type = HDA_FIXUP_FUNC, 4749 .type = HDA_FIXUP_FUNC,
4671 .v.func = alc_fixup_dell_wmi, 4750 .v.func = alc_fixup_dell_wmi,
4672 .chained_before = true,
4673 .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
4674 }, 4751 },
4675 [ALC282_FIXUP_ASPIRE_V5_PINS] = { 4752 [ALC282_FIXUP_ASPIRE_V5_PINS] = {
4676 .type = HDA_FIXUP_PINS, 4753 .type = HDA_FIXUP_PINS,
@@ -4708,10 +4785,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4708 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4785 SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4709 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4786 SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4710 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4787 SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4711 SND_PCI_QUIRK(0x1028, 0x0610, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
4712 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4788 SND_PCI_QUIRK(0x1028, 0x0615, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4713 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4789 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4714 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED),
4715 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK), 4790 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
4716 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4791 SND_PCI_QUIRK(0x1028, 0x064a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
4717 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 4792 SND_PCI_QUIRK(0x1028, 0x064b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
@@ -4743,7 +4818,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4743 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4818 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4744 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4819 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4745 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4820 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4746 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4747 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4821 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4748 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4822 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4749 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4823 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
@@ -5212,9 +5286,6 @@ static void alc269_fill_coef(struct hda_codec *codec)
5212 } 5286 }
5213 } 5287 }
5214 5288
5215 /* Class D */
5216 alc_update_coef_idx(codec, 0xd, 0, 1<<14);
5217
5218 /* HP */ 5289 /* HP */
5219 alc_update_coef_idx(codec, 0x4, 0, 1<<11); 5290 alc_update_coef_idx(codec, 0x4, 0, 1<<11);
5220} 5291}
@@ -6124,29 +6195,6 @@ static const struct snd_hda_pin_quirk alc662_pin_fixup_tbl[] = {
6124 {} 6195 {}
6125}; 6196};
6126 6197
6127static void alc662_fill_coef(struct hda_codec *codec)
6128{
6129 int coef;
6130
6131 coef = alc_get_coef0(codec);
6132
6133 switch (codec->vendor_id) {
6134 case 0x10ec0662:
6135 if ((coef & 0x00f0) == 0x0030)
6136 alc_update_coef_idx(codec, 0x4, 1<<10, 0); /* EAPD Ctrl */
6137 break;
6138 case 0x10ec0272:
6139 case 0x10ec0273:
6140 case 0x10ec0663:
6141 case 0x10ec0665:
6142 case 0x10ec0670:
6143 case 0x10ec0671:
6144 case 0x10ec0672:
6145 alc_update_coef_idx(codec, 0xd, 0, 1<<14); /* EAPD Ctrl */
6146 break;
6147 }
6148}
6149
6150/* 6198/*
6151 */ 6199 */
6152static int patch_alc662(struct hda_codec *codec) 6200static int patch_alc662(struct hda_codec *codec)
@@ -6169,10 +6217,6 @@ static int patch_alc662(struct hda_codec *codec)
6169 case 0x10ec0668: 6217 case 0x10ec0668:
6170 spec->init_hook = alc668_restore_default_value; 6218 spec->init_hook = alc668_restore_default_value;
6171 break; 6219 break;
6172 default:
6173 spec->init_hook = alc662_fill_coef;
6174 alc662_fill_coef(codec);
6175 break;
6176 } 6220 }
6177 6221
6178 snd_hda_pick_fixup(codec, alc662_fixup_models, 6222 snd_hda_pick_fixup(codec, alc662_fixup_models,
diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c
index cee51ae177c1..c40428f25ba5 100644
--- a/sound/soc/codecs/cs42l51-i2c.c
+++ b/sound/soc/codecs/cs42l51-i2c.c
@@ -46,6 +46,7 @@ static struct i2c_driver cs42l51_i2c_driver = {
46 .driver = { 46 .driver = {
47 .name = "cs42l51", 47 .name = "cs42l51",
48 .owner = THIS_MODULE, 48 .owner = THIS_MODULE,
49 .of_match_table = cs42l51_of_match,
49 }, 50 },
50 .probe = cs42l51_i2c_probe, 51 .probe = cs42l51_i2c_probe,
51 .remove = cs42l51_i2c_remove, 52 .remove = cs42l51_i2c_remove,
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index 09488d97de60..669c38fc3034 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -558,11 +558,13 @@ error:
558} 558}
559EXPORT_SYMBOL_GPL(cs42l51_probe); 559EXPORT_SYMBOL_GPL(cs42l51_probe);
560 560
561static const struct of_device_id cs42l51_of_match[] = { 561const struct of_device_id cs42l51_of_match[] = {
562 { .compatible = "cirrus,cs42l51", }, 562 { .compatible = "cirrus,cs42l51", },
563 { } 563 { }
564}; 564};
565MODULE_DEVICE_TABLE(of, cs42l51_of_match); 565MODULE_DEVICE_TABLE(of, cs42l51_of_match);
566EXPORT_SYMBOL_GPL(cs42l51_of_match);
567
566MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); 568MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
567MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver"); 569MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver");
568MODULE_LICENSE("GPL"); 570MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/cs42l51.h b/sound/soc/codecs/cs42l51.h
index 8c55bf384bc6..0ca805492ac4 100644
--- a/sound/soc/codecs/cs42l51.h
+++ b/sound/soc/codecs/cs42l51.h
@@ -22,6 +22,7 @@ struct device;
22 22
23extern const struct regmap_config cs42l51_regmap; 23extern const struct regmap_config cs42l51_regmap;
24int cs42l51_probe(struct device *dev, struct regmap *regmap); 24int cs42l51_probe(struct device *dev, struct regmap *regmap);
25extern const struct of_device_id cs42l51_of_match[];
25 26
26#define CS42L51_CHIP_ID 0x1B 27#define CS42L51_CHIP_ID 0x1B
27#define CS42L51_CHIP_REV_A 0x00 28#define CS42L51_CHIP_REV_A 0x00
diff --git a/sound/soc/codecs/es8328-i2c.c b/sound/soc/codecs/es8328-i2c.c
index aae410d122ee..2d05b5d3a6ce 100644
--- a/sound/soc/codecs/es8328-i2c.c
+++ b/sound/soc/codecs/es8328-i2c.c
@@ -19,7 +19,7 @@
19#include "es8328.h" 19#include "es8328.h"
20 20
21static const struct i2c_device_id es8328_id[] = { 21static const struct i2c_device_id es8328_id[] = {
22 { "everest,es8328", 0 }, 22 { "es8328", 0 },
23 { } 23 { }
24}; 24};
25MODULE_DEVICE_TABLE(i2c, es8328_id); 25MODULE_DEVICE_TABLE(i2c, es8328_id);
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index d519294f57c7..1229554f1464 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -1941,13 +1941,13 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
1941 * 0x02 (when master clk is 20MHz to 40MHz).. 1941 * 0x02 (when master clk is 20MHz to 40MHz)..
1942 * 0x03 (when master clk is 40MHz to 60MHz).. 1942 * 0x03 (when master clk is 40MHz to 60MHz)..
1943 */ 1943 */
1944 if ((freq >= 10000000) && (freq < 20000000)) { 1944 if ((freq >= 10000000) && (freq <= 20000000)) {
1945 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, 1945 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
1946 M98090_PSCLK_DIV1); 1946 M98090_PSCLK_DIV1);
1947 } else if ((freq >= 20000000) && (freq < 40000000)) { 1947 } else if ((freq > 20000000) && (freq <= 40000000)) {
1948 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, 1948 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
1949 M98090_PSCLK_DIV2); 1949 M98090_PSCLK_DIV2);
1950 } else if ((freq >= 40000000) && (freq < 60000000)) { 1950 } else if ((freq > 40000000) && (freq <= 60000000)) {
1951 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, 1951 snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK,
1952 M98090_PSCLK_DIV4); 1952 M98090_PSCLK_DIV4);
1953 } else { 1953 } else {
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 3fb83bf09768..d16331e0b64d 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -139,6 +139,7 @@ static const struct reg_default rt5645_reg[] = {
139 { 0x76, 0x000a }, 139 { 0x76, 0x000a },
140 { 0x77, 0x0c00 }, 140 { 0x77, 0x0c00 },
141 { 0x78, 0x0000 }, 141 { 0x78, 0x0000 },
142 { 0x79, 0x0123 },
142 { 0x80, 0x0000 }, 143 { 0x80, 0x0000 },
143 { 0x81, 0x0000 }, 144 { 0x81, 0x0000 },
144 { 0x82, 0x0000 }, 145 { 0x82, 0x0000 },
@@ -334,6 +335,7 @@ static bool rt5645_readable_register(struct device *dev, unsigned int reg)
334 case RT5645_DMIC_CTRL2: 335 case RT5645_DMIC_CTRL2:
335 case RT5645_TDM_CTRL_1: 336 case RT5645_TDM_CTRL_1:
336 case RT5645_TDM_CTRL_2: 337 case RT5645_TDM_CTRL_2:
338 case RT5645_TDM_CTRL_3:
337 case RT5645_GLB_CLK: 339 case RT5645_GLB_CLK:
338 case RT5645_PLL_CTRL1: 340 case RT5645_PLL_CTRL1:
339 case RT5645_PLL_CTRL2: 341 case RT5645_PLL_CTRL2:
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index ba9d9b4d4857..9bd8b4f63303 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -100,18 +100,18 @@ static const struct reg_default rt5670_reg[] = {
100 { 0x4c, 0x5380 }, 100 { 0x4c, 0x5380 },
101 { 0x4f, 0x0073 }, 101 { 0x4f, 0x0073 },
102 { 0x52, 0x00d3 }, 102 { 0x52, 0x00d3 },
103 { 0x53, 0xf0f0 }, 103 { 0x53, 0xf000 },
104 { 0x61, 0x0000 }, 104 { 0x61, 0x0000 },
105 { 0x62, 0x0001 }, 105 { 0x62, 0x0001 },
106 { 0x63, 0x00c3 }, 106 { 0x63, 0x00c3 },
107 { 0x64, 0x0000 }, 107 { 0x64, 0x0000 },
108 { 0x65, 0x0000 }, 108 { 0x65, 0x0001 },
109 { 0x66, 0x0000 }, 109 { 0x66, 0x0000 },
110 { 0x6f, 0x8000 }, 110 { 0x6f, 0x8000 },
111 { 0x70, 0x8000 }, 111 { 0x70, 0x8000 },
112 { 0x71, 0x8000 }, 112 { 0x71, 0x8000 },
113 { 0x72, 0x8000 }, 113 { 0x72, 0x8000 },
114 { 0x73, 0x1110 }, 114 { 0x73, 0x7770 },
115 { 0x74, 0x0e00 }, 115 { 0x74, 0x0e00 },
116 { 0x75, 0x1505 }, 116 { 0x75, 0x1505 },
117 { 0x76, 0x0015 }, 117 { 0x76, 0x0015 },
@@ -125,21 +125,21 @@ static const struct reg_default rt5670_reg[] = {
125 { 0x83, 0x0000 }, 125 { 0x83, 0x0000 },
126 { 0x84, 0x0000 }, 126 { 0x84, 0x0000 },
127 { 0x85, 0x0000 }, 127 { 0x85, 0x0000 },
128 { 0x86, 0x0008 }, 128 { 0x86, 0x0004 },
129 { 0x87, 0x0000 }, 129 { 0x87, 0x0000 },
130 { 0x88, 0x0000 }, 130 { 0x88, 0x0000 },
131 { 0x89, 0x0000 }, 131 { 0x89, 0x0000 },
132 { 0x8a, 0x0000 }, 132 { 0x8a, 0x0000 },
133 { 0x8b, 0x0000 }, 133 { 0x8b, 0x0000 },
134 { 0x8c, 0x0007 }, 134 { 0x8c, 0x0003 },
135 { 0x8d, 0x0000 }, 135 { 0x8d, 0x0000 },
136 { 0x8e, 0x0004 }, 136 { 0x8e, 0x0004 },
137 { 0x8f, 0x1100 }, 137 { 0x8f, 0x1100 },
138 { 0x90, 0x0646 }, 138 { 0x90, 0x0646 },
139 { 0x91, 0x0c06 }, 139 { 0x91, 0x0c06 },
140 { 0x93, 0x0000 }, 140 { 0x93, 0x0000 },
141 { 0x94, 0x0000 }, 141 { 0x94, 0x1270 },
142 { 0x95, 0x0000 }, 142 { 0x95, 0x1000 },
143 { 0x97, 0x0000 }, 143 { 0x97, 0x0000 },
144 { 0x98, 0x0000 }, 144 { 0x98, 0x0000 },
145 { 0x99, 0x0000 }, 145 { 0x99, 0x0000 },
@@ -150,11 +150,11 @@ static const struct reg_default rt5670_reg[] = {
150 { 0x9e, 0x0400 }, 150 { 0x9e, 0x0400 },
151 { 0xae, 0x7000 }, 151 { 0xae, 0x7000 },
152 { 0xaf, 0x0000 }, 152 { 0xaf, 0x0000 },
153 { 0xb0, 0x6000 }, 153 { 0xb0, 0x7000 },
154 { 0xb1, 0x0000 }, 154 { 0xb1, 0x0000 },
155 { 0xb2, 0x0000 }, 155 { 0xb2, 0x0000 },
156 { 0xb3, 0x001f }, 156 { 0xb3, 0x001f },
157 { 0xb4, 0x2206 }, 157 { 0xb4, 0x220c },
158 { 0xb5, 0x1f00 }, 158 { 0xb5, 0x1f00 },
159 { 0xb6, 0x0000 }, 159 { 0xb6, 0x0000 },
160 { 0xb7, 0x0000 }, 160 { 0xb7, 0x0000 },
@@ -171,25 +171,25 @@ static const struct reg_default rt5670_reg[] = {
171 { 0xcf, 0x1813 }, 171 { 0xcf, 0x1813 },
172 { 0xd0, 0x0690 }, 172 { 0xd0, 0x0690 },
173 { 0xd1, 0x1c17 }, 173 { 0xd1, 0x1c17 },
174 { 0xd3, 0xb320 }, 174 { 0xd3, 0xa220 },
175 { 0xd4, 0x0000 }, 175 { 0xd4, 0x0000 },
176 { 0xd6, 0x0400 }, 176 { 0xd6, 0x0400 },
177 { 0xd9, 0x0809 }, 177 { 0xd9, 0x0809 },
178 { 0xda, 0x0000 }, 178 { 0xda, 0x0000 },
179 { 0xdb, 0x0001 }, 179 { 0xdb, 0x0001 },
180 { 0xdc, 0x0049 }, 180 { 0xdc, 0x0049 },
181 { 0xdd, 0x0009 }, 181 { 0xdd, 0x0024 },
182 { 0xe6, 0x8000 }, 182 { 0xe6, 0x8000 },
183 { 0xe7, 0x0000 }, 183 { 0xe7, 0x0000 },
184 { 0xec, 0xb300 }, 184 { 0xec, 0xa200 },
185 { 0xed, 0x0000 }, 185 { 0xed, 0x0000 },
186 { 0xee, 0xb300 }, 186 { 0xee, 0xa200 },
187 { 0xef, 0x0000 }, 187 { 0xef, 0x0000 },
188 { 0xf8, 0x0000 }, 188 { 0xf8, 0x0000 },
189 { 0xf9, 0x0000 }, 189 { 0xf9, 0x0000 },
190 { 0xfa, 0x8010 }, 190 { 0xfa, 0x8010 },
191 { 0xfb, 0x0033 }, 191 { 0xfb, 0x0033 },
192 { 0xfc, 0x0080 }, 192 { 0xfc, 0x0100 },
193}; 193};
194 194
195static bool rt5670_volatile_register(struct device *dev, unsigned int reg) 195static bool rt5670_volatile_register(struct device *dev, unsigned int reg)
@@ -1877,6 +1877,10 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
1877 { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" }, 1877 { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" },
1878 { "DAC1 MIXR", NULL, "DAC Stereo1 Filter" }, 1878 { "DAC1 MIXR", NULL, "DAC Stereo1 Filter" },
1879 1879
1880 { "DAC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll },
1881 { "DAC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
1882 { "DAC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
1883
1880 { "DAC MIX", NULL, "DAC1 MIXL" }, 1884 { "DAC MIX", NULL, "DAC1 MIXL" },
1881 { "DAC MIX", NULL, "DAC1 MIXR" }, 1885 { "DAC MIX", NULL, "DAC1 MIXR" },
1882 1886
@@ -1926,14 +1930,10 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
1926 1930
1927 { "DAC L1", NULL, "DAC L1 Power" }, 1931 { "DAC L1", NULL, "DAC L1 Power" },
1928 { "DAC L1", NULL, "Stereo DAC MIXL" }, 1932 { "DAC L1", NULL, "Stereo DAC MIXL" },
1929 { "DAC L1", NULL, "PLL1", is_sys_clk_from_pll },
1930 { "DAC R1", NULL, "DAC R1 Power" }, 1933 { "DAC R1", NULL, "DAC R1 Power" },
1931 { "DAC R1", NULL, "Stereo DAC MIXR" }, 1934 { "DAC R1", NULL, "Stereo DAC MIXR" },
1932 { "DAC R1", NULL, "PLL1", is_sys_clk_from_pll },
1933 { "DAC L2", NULL, "Mono DAC MIXL" }, 1935 { "DAC L2", NULL, "Mono DAC MIXL" },
1934 { "DAC L2", NULL, "PLL1", is_sys_clk_from_pll },
1935 { "DAC R2", NULL, "Mono DAC MIXR" }, 1936 { "DAC R2", NULL, "Mono DAC MIXR" },
1936 { "DAC R2", NULL, "PLL1", is_sys_clk_from_pll },
1937 1937
1938 { "OUT MIXL", "BST1 Switch", "BST1" }, 1938 { "OUT MIXL", "BST1 Switch", "BST1" },
1939 { "OUT MIXL", "INL Switch", "INL VOL" }, 1939 { "OUT MIXL", "INL Switch", "INL VOL" },
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 6bb77d76561b..dab9b15304af 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1299,8 +1299,7 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
1299 1299
1300 /* enable small pop, introduce 400ms delay in turning off */ 1300 /* enable small pop, introduce 400ms delay in turning off */
1301 snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, 1301 snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL,
1302 SGTL5000_SMALL_POP, 1302 SGTL5000_SMALL_POP, 1);
1303 SGTL5000_SMALL_POP);
1304 1303
1305 /* disable short cut detector */ 1304 /* disable short cut detector */
1306 snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0); 1305 snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0);
diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h
index 2f8c88931f69..bd7a344bf8c5 100644
--- a/sound/soc/codecs/sgtl5000.h
+++ b/sound/soc/codecs/sgtl5000.h
@@ -275,7 +275,7 @@
275#define SGTL5000_BIAS_CTRL_MASK 0x000e 275#define SGTL5000_BIAS_CTRL_MASK 0x000e
276#define SGTL5000_BIAS_CTRL_SHIFT 1 276#define SGTL5000_BIAS_CTRL_SHIFT 1
277#define SGTL5000_BIAS_CTRL_WIDTH 3 277#define SGTL5000_BIAS_CTRL_WIDTH 3
278#define SGTL5000_SMALL_POP 0x0001 278#define SGTL5000_SMALL_POP 0
279 279
280/* 280/*
281 * SGTL5000_CHIP_MIC_CTRL 281 * SGTL5000_CHIP_MIC_CTRL
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f412a9911a75..67124783558a 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1355,6 +1355,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
1355 file, blocks, pos - firmware->size); 1355 file, blocks, pos - firmware->size);
1356 1356
1357out_fw: 1357out_fw:
1358 regmap_async_complete(regmap);
1358 release_firmware(firmware); 1359 release_firmware(firmware);
1359 wm_adsp_buf_free(&buf_list); 1360 wm_adsp_buf_free(&buf_list);
1360out: 1361out:
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index ed866e9a2928..9deabdd2b1a2 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -684,12 +684,38 @@ static bool fsl_asrc_writeable_reg(struct device *dev, unsigned int reg)
684 } 684 }
685} 685}
686 686
687static struct reg_default fsl_asrc_reg[] = {
688 { REG_ASRCTR, 0x0000 }, { REG_ASRIER, 0x0000 },
689 { REG_ASRCNCR, 0x0000 }, { REG_ASRCFG, 0x0000 },
690 { REG_ASRCSR, 0x0000 }, { REG_ASRCDR1, 0x0000 },
691 { REG_ASRCDR2, 0x0000 }, { REG_ASRSTR, 0x0000 },
692 { REG_ASRRA, 0x0000 }, { REG_ASRRB, 0x0000 },
693 { REG_ASRRC, 0x0000 }, { REG_ASRPM1, 0x0000 },
694 { REG_ASRPM2, 0x0000 }, { REG_ASRPM3, 0x0000 },
695 { REG_ASRPM4, 0x0000 }, { REG_ASRPM5, 0x0000 },
696 { REG_ASRTFR1, 0x0000 }, { REG_ASRCCR, 0x0000 },
697 { REG_ASRDIA, 0x0000 }, { REG_ASRDOA, 0x0000 },
698 { REG_ASRDIB, 0x0000 }, { REG_ASRDOB, 0x0000 },
699 { REG_ASRDIC, 0x0000 }, { REG_ASRDOC, 0x0000 },
700 { REG_ASRIDRHA, 0x0000 }, { REG_ASRIDRLA, 0x0000 },
701 { REG_ASRIDRHB, 0x0000 }, { REG_ASRIDRLB, 0x0000 },
702 { REG_ASRIDRHC, 0x0000 }, { REG_ASRIDRLC, 0x0000 },
703 { REG_ASR76K, 0x0A47 }, { REG_ASR56K, 0x0DF3 },
704 { REG_ASRMCRA, 0x0000 }, { REG_ASRFSTA, 0x0000 },
705 { REG_ASRMCRB, 0x0000 }, { REG_ASRFSTB, 0x0000 },
706 { REG_ASRMCRC, 0x0000 }, { REG_ASRFSTC, 0x0000 },
707 { REG_ASRMCR1A, 0x0000 }, { REG_ASRMCR1B, 0x0000 },
708 { REG_ASRMCR1C, 0x0000 },
709};
710
687static const struct regmap_config fsl_asrc_regmap_config = { 711static const struct regmap_config fsl_asrc_regmap_config = {
688 .reg_bits = 32, 712 .reg_bits = 32,
689 .reg_stride = 4, 713 .reg_stride = 4,
690 .val_bits = 32, 714 .val_bits = 32,
691 715
692 .max_register = REG_ASRMCR1C, 716 .max_register = REG_ASRMCR1C,
717 .reg_defaults = fsl_asrc_reg,
718 .num_reg_defaults = ARRAY_SIZE(fsl_asrc_reg),
693 .readable_reg = fsl_asrc_readable_reg, 719 .readable_reg = fsl_asrc_readable_reg,
694 .volatile_reg = fsl_asrc_volatile_reg, 720 .volatile_reg = fsl_asrc_volatile_reg,
695 .writeable_reg = fsl_asrc_writeable_reg, 721 .writeable_reg = fsl_asrc_writeable_reg,
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index f373e37f8305..c74ba37f862c 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -154,8 +154,10 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on)
154 while (val) { 154 while (val) {
155 regmap_read(i2s->regmap, I2S_CLR, &val); 155 regmap_read(i2s->regmap, I2S_CLR, &val);
156 retry--; 156 retry--;
157 if (!retry) 157 if (!retry) {
158 dev_warn(i2s->dev, "fail to clear\n"); 158 dev_warn(i2s->dev, "fail to clear\n");
159 break;
160 }
159 } 161 }
160 } 162 }
161 } 163 }
diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c
index 0acf5d0eed53..72118a77dd5b 100644
--- a/sound/soc/samsung/snow.c
+++ b/sound/soc/samsung/snow.c
@@ -110,6 +110,7 @@ static const struct of_device_id snow_of_match[] = {
110 { .compatible = "google,snow-audio-max98095", }, 110 { .compatible = "google,snow-audio-max98095", },
111 {}, 111 {},
112}; 112};
113MODULE_DEVICE_TABLE(of, snow_of_match);
113 114
114static struct platform_driver snow_driver = { 115static struct platform_driver snow_driver = {
115 .driver = { 116 .driver = {
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 66fddec9543d..88e5df474ccf 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -1711,8 +1711,7 @@ static const struct snd_soc_dai_ops fsi_dai_ops = {
1711static struct snd_pcm_hardware fsi_pcm_hardware = { 1711static struct snd_pcm_hardware fsi_pcm_hardware = {
1712 .info = SNDRV_PCM_INFO_INTERLEAVED | 1712 .info = SNDRV_PCM_INFO_INTERLEAVED |
1713 SNDRV_PCM_INFO_MMAP | 1713 SNDRV_PCM_INFO_MMAP |
1714 SNDRV_PCM_INFO_MMAP_VALID | 1714 SNDRV_PCM_INFO_MMAP_VALID,
1715 SNDRV_PCM_INFO_PAUSE,
1716 .buffer_bytes_max = 64 * 1024, 1715 .buffer_bytes_max = 64 * 1024,
1717 .period_bytes_min = 32, 1716 .period_bytes_min = 32,
1718 .period_bytes_max = 8192, 1717 .period_bytes_max = 8192,
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 1922ec57d10a..70042197f9e2 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -886,8 +886,7 @@ static int rsnd_dai_probe(struct platform_device *pdev,
886static struct snd_pcm_hardware rsnd_pcm_hardware = { 886static struct snd_pcm_hardware rsnd_pcm_hardware = {
887 .info = SNDRV_PCM_INFO_INTERLEAVED | 887 .info = SNDRV_PCM_INFO_INTERLEAVED |
888 SNDRV_PCM_INFO_MMAP | 888 SNDRV_PCM_INFO_MMAP |
889 SNDRV_PCM_INFO_MMAP_VALID | 889 SNDRV_PCM_INFO_MMAP_VALID,
890 SNDRV_PCM_INFO_PAUSE,
891 .buffer_bytes_max = 64 * 1024, 890 .buffer_bytes_max = 64 * 1024,
892 .period_bytes_min = 32, 891 .period_bytes_min = 32,
893 .period_bytes_max = 8192, 892 .period_bytes_max = 8192,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4c8f8a23a0e9..b60ff56ebc0f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -884,7 +884,7 @@ static struct snd_soc_dai *snd_soc_find_dai(
884 list_for_each_entry(component, &component_list, list) { 884 list_for_each_entry(component, &component_list, list) {
885 if (dlc->of_node && component->dev->of_node != dlc->of_node) 885 if (dlc->of_node && component->dev->of_node != dlc->of_node)
886 continue; 886 continue;
887 if (dlc->name && strcmp(dev_name(component->dev), dlc->name)) 887 if (dlc->name && strcmp(component->name, dlc->name))
888 continue; 888 continue;
889 list_for_each_entry(dai, &component->dai_list, list) { 889 list_for_each_entry(dai, &component->dai_list, list) {
890 if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)) 890 if (dlc->dai_name && strcmp(dai->name, dlc->dai_name))
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 002311afdeaa..57277dd79e11 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1522,13 +1522,36 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
1522 dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture); 1522 dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture);
1523} 1523}
1524 1524
1525static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd);
1526
1527/* Set FE's runtime_update state; the state is protected via PCM stream lock
1528 * for avoiding the race with trigger callback.
1529 * If the state is unset and a trigger is pending while the previous operation,
1530 * process the pending trigger action here.
1531 */
1532static void dpcm_set_fe_update_state(struct snd_soc_pcm_runtime *fe,
1533 int stream, enum snd_soc_dpcm_update state)
1534{
1535 struct snd_pcm_substream *substream =
1536 snd_soc_dpcm_get_substream(fe, stream);
1537
1538 snd_pcm_stream_lock_irq(substream);
1539 if (state == SND_SOC_DPCM_UPDATE_NO && fe->dpcm[stream].trigger_pending) {
1540 dpcm_fe_dai_do_trigger(substream,
1541 fe->dpcm[stream].trigger_pending - 1);
1542 fe->dpcm[stream].trigger_pending = 0;
1543 }
1544 fe->dpcm[stream].runtime_update = state;
1545 snd_pcm_stream_unlock_irq(substream);
1546}
1547
1525static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream) 1548static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
1526{ 1549{
1527 struct snd_soc_pcm_runtime *fe = fe_substream->private_data; 1550 struct snd_soc_pcm_runtime *fe = fe_substream->private_data;
1528 struct snd_pcm_runtime *runtime = fe_substream->runtime; 1551 struct snd_pcm_runtime *runtime = fe_substream->runtime;
1529 int stream = fe_substream->stream, ret = 0; 1552 int stream = fe_substream->stream, ret = 0;
1530 1553
1531 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1554 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1532 1555
1533 ret = dpcm_be_dai_startup(fe, fe_substream->stream); 1556 ret = dpcm_be_dai_startup(fe, fe_substream->stream);
1534 if (ret < 0) { 1557 if (ret < 0) {
@@ -1550,13 +1573,13 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
1550 dpcm_set_fe_runtime(fe_substream); 1573 dpcm_set_fe_runtime(fe_substream);
1551 snd_pcm_limit_hw_rates(runtime); 1574 snd_pcm_limit_hw_rates(runtime);
1552 1575
1553 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1576 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1554 return 0; 1577 return 0;
1555 1578
1556unwind: 1579unwind:
1557 dpcm_be_dai_startup_unwind(fe, fe_substream->stream); 1580 dpcm_be_dai_startup_unwind(fe, fe_substream->stream);
1558be_err: 1581be_err:
1559 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1582 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1560 return ret; 1583 return ret;
1561} 1584}
1562 1585
@@ -1603,7 +1626,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
1603 struct snd_soc_pcm_runtime *fe = substream->private_data; 1626 struct snd_soc_pcm_runtime *fe = substream->private_data;
1604 int stream = substream->stream; 1627 int stream = substream->stream;
1605 1628
1606 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1629 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1607 1630
1608 /* shutdown the BEs */ 1631 /* shutdown the BEs */
1609 dpcm_be_dai_shutdown(fe, substream->stream); 1632 dpcm_be_dai_shutdown(fe, substream->stream);
@@ -1617,7 +1640,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
1617 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP); 1640 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_STOP);
1618 1641
1619 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE; 1642 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_CLOSE;
1620 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1643 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1621 return 0; 1644 return 0;
1622} 1645}
1623 1646
@@ -1665,7 +1688,7 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
1665 int err, stream = substream->stream; 1688 int err, stream = substream->stream;
1666 1689
1667 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 1690 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
1668 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1691 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1669 1692
1670 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name); 1693 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name);
1671 1694
@@ -1680,7 +1703,7 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
1680 err = dpcm_be_dai_hw_free(fe, stream); 1703 err = dpcm_be_dai_hw_free(fe, stream);
1681 1704
1682 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; 1705 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE;
1683 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1706 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1684 1707
1685 mutex_unlock(&fe->card->mutex); 1708 mutex_unlock(&fe->card->mutex);
1686 return 0; 1709 return 0;
@@ -1773,7 +1796,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
1773 int ret, stream = substream->stream; 1796 int ret, stream = substream->stream;
1774 1797
1775 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 1798 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
1776 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1799 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
1777 1800
1778 memcpy(&fe->dpcm[substream->stream].hw_params, params, 1801 memcpy(&fe->dpcm[substream->stream].hw_params, params,
1779 sizeof(struct snd_pcm_hw_params)); 1802 sizeof(struct snd_pcm_hw_params));
@@ -1796,7 +1819,7 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
1796 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; 1819 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS;
1797 1820
1798out: 1821out:
1799 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1822 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
1800 mutex_unlock(&fe->card->mutex); 1823 mutex_unlock(&fe->card->mutex);
1801 return ret; 1824 return ret;
1802} 1825}
@@ -1910,7 +1933,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream,
1910} 1933}
1911EXPORT_SYMBOL_GPL(dpcm_be_dai_trigger); 1934EXPORT_SYMBOL_GPL(dpcm_be_dai_trigger);
1912 1935
1913static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd) 1936static int dpcm_fe_dai_do_trigger(struct snd_pcm_substream *substream, int cmd)
1914{ 1937{
1915 struct snd_soc_pcm_runtime *fe = substream->private_data; 1938 struct snd_soc_pcm_runtime *fe = substream->private_data;
1916 int stream = substream->stream, ret; 1939 int stream = substream->stream, ret;
@@ -1984,6 +2007,23 @@ out:
1984 return ret; 2007 return ret;
1985} 2008}
1986 2009
2010static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd)
2011{
2012 struct snd_soc_pcm_runtime *fe = substream->private_data;
2013 int stream = substream->stream;
2014
2015 /* if FE's runtime_update is already set, we're in race;
2016 * process this trigger later at exit
2017 */
2018 if (fe->dpcm[stream].runtime_update != SND_SOC_DPCM_UPDATE_NO) {
2019 fe->dpcm[stream].trigger_pending = cmd + 1;
2020 return 0; /* delayed, assuming it's successful */
2021 }
2022
2023 /* we're alone, let's trigger */
2024 return dpcm_fe_dai_do_trigger(substream, cmd);
2025}
2026
1987int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream) 2027int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
1988{ 2028{
1989 struct snd_soc_dpcm *dpcm; 2029 struct snd_soc_dpcm *dpcm;
@@ -2027,7 +2067,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
2027 2067
2028 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name); 2068 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name);
2029 2069
2030 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 2070 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
2031 2071
2032 /* there is no point preparing this FE if there are no BEs */ 2072 /* there is no point preparing this FE if there are no BEs */
2033 if (list_empty(&fe->dpcm[stream].be_clients)) { 2073 if (list_empty(&fe->dpcm[stream].be_clients)) {
@@ -2054,7 +2094,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
2054 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE; 2094 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_PREPARE;
2055 2095
2056out: 2096out:
2057 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 2097 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2058 mutex_unlock(&fe->card->mutex); 2098 mutex_unlock(&fe->card->mutex);
2059 2099
2060 return ret; 2100 return ret;
@@ -2201,11 +2241,11 @@ static int dpcm_run_new_update(struct snd_soc_pcm_runtime *fe, int stream)
2201{ 2241{
2202 int ret; 2242 int ret;
2203 2243
2204 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE; 2244 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE);
2205 ret = dpcm_run_update_startup(fe, stream); 2245 ret = dpcm_run_update_startup(fe, stream);
2206 if (ret < 0) 2246 if (ret < 0)
2207 dev_err(fe->dev, "ASoC: failed to startup some BEs\n"); 2247 dev_err(fe->dev, "ASoC: failed to startup some BEs\n");
2208 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 2248 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2209 2249
2210 return ret; 2250 return ret;
2211} 2251}
@@ -2214,11 +2254,11 @@ static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)
2214{ 2254{
2215 int ret; 2255 int ret;
2216 2256
2217 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE; 2257 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_BE);
2218 ret = dpcm_run_update_shutdown(fe, stream); 2258 ret = dpcm_run_update_shutdown(fe, stream);
2219 if (ret < 0) 2259 if (ret < 0)
2220 dev_err(fe->dev, "ASoC: failed to shutdown some BEs\n"); 2260 dev_err(fe->dev, "ASoC: failed to shutdown some BEs\n");
2221 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 2261 dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
2222 2262
2223 return ret; 2263 return ret;
2224} 2264}
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 2e4a9dbc51fa..6e354d326858 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2033,10 +2033,11 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
2033 cval->res = 1; 2033 cval->res = 1;
2034 cval->initialized = 1; 2034 cval->initialized = 1;
2035 2035
2036 if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) 2036 if (state->mixer->protocol == UAC_VERSION_1)
2037 cval->control = UAC2_CX_CLOCK_SELECTOR;
2038 else
2039 cval->control = 0; 2037 cval->control = 0;
2038 else /* UAC_VERSION_2 */
2039 cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ?
2040 UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR;
2040 2041
2041 namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); 2042 namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
2042 if (!namelist) { 2043 if (!namelist) {
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index f119a41ed9a9..8c9bf4b7aaf0 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -593,10 +593,10 @@ static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
593 if (mixer->chip->shutdown) 593 if (mixer->chip->shutdown)
594 ret = -ENODEV; 594 ret = -ENODEV;
595 else 595 else
596 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, 596 ret = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
597 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 597 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
598 0, wIndex, 598 0, wIndex,
599 &tmp, sizeof(tmp), 1000); 599 &tmp, sizeof(tmp));
600 up_read(&mixer->chip->shutdown_rwsem); 600 up_read(&mixer->chip->shutdown_rwsem);
601 601
602 if (ret < 0) { 602 if (ret < 0) {
@@ -885,6 +885,11 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
885 return changed; 885 return changed;
886} 886}
887 887
888static void kctl_private_value_free(struct snd_kcontrol *kctl)
889{
890 kfree((void *)kctl->private_value);
891}
892
888static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer, 893static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
889 int validx, int bUnitID) 894 int validx, int bUnitID)
890{ 895{
@@ -919,6 +924,7 @@ static int snd_ftu_create_effect_switch(struct usb_mixer_interface *mixer,
919 return -ENOMEM; 924 return -ENOMEM;
920 } 925 }
921 926
927 kctl->private_free = kctl_private_value_free;
922 err = snd_ctl_add(mixer->chip->card, kctl); 928 err = snd_ctl_add(mixer->chip->card, kctl);
923 if (err < 0) 929 if (err < 0)
924 return err; 930 return err;
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index d2aa45a8d895..60dfe0d28771 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1146,6 +1146,20 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
1146 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) && 1146 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) &&
1147 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) 1147 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1148 mdelay(20); 1148 mdelay(20);
1149
1150 /* Marantz/Denon devices with USB DAC functionality need a delay
1151 * after each class compliant request
1152 */
1153 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x154e) &&
1154 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) {
1155
1156 switch (le16_to_cpu(dev->descriptor.idProduct)) {
1157 case 0x3005: /* Marantz HD-DAC1 */
1158 case 0x3006: /* Marantz SA-14S1 */
1159 mdelay(20);
1160 break;
1161 }
1162 }
1149} 1163}
1150 1164
1151/* 1165/*
@@ -1179,12 +1193,12 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1179 /* iFi Audio micro/nano iDSD */ 1193 /* iFi Audio micro/nano iDSD */
1180 case USB_ID(0x20b1, 0x3008): 1194 case USB_ID(0x20b1, 0x3008):
1181 if (fp->altsetting == 2) 1195 if (fp->altsetting == 2)
1182 return SNDRV_PCM_FMTBIT_DSD_U32_LE; 1196 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1183 break; 1197 break;
1184 /* DIYINHK DSD DXD 384kHz USB to I2S/DSD */ 1198 /* DIYINHK DSD DXD 384kHz USB to I2S/DSD */
1185 case USB_ID(0x20b1, 0x2009): 1199 case USB_ID(0x20b1, 0x2009):
1186 if (fp->altsetting == 3) 1200 if (fp->altsetting == 3)
1187 return SNDRV_PCM_FMTBIT_DSD_U32_LE; 1201 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1188 break; 1202 break;
1189 default: 1203 default:
1190 break; 1204 break;
diff --git a/tools/testing/selftests/net/psock_fanout.c b/tools/testing/selftests/net/psock_fanout.c
index 57b9c2b7c4ff..6f6733331d95 100644
--- a/tools/testing/selftests/net/psock_fanout.c
+++ b/tools/testing/selftests/net/psock_fanout.c
@@ -128,7 +128,7 @@ static int sock_fanout_read_ring(int fd, void *ring)
128 struct tpacket2_hdr *header = ring; 128 struct tpacket2_hdr *header = ring;
129 int count = 0; 129 int count = 0;
130 130
131 while (header->tp_status & TP_STATUS_USER && count < RING_NUM_FRAMES) { 131 while (count < RING_NUM_FRAMES && header->tp_status & TP_STATUS_USER) {
132 count++; 132 count++;
133 header = ring + (count * getpagesize()); 133 header = ring + (count * getpagesize());
134 } 134 }
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 3aaca49de325..aacdb59f30de 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1933,7 +1933,7 @@ out:
1933 1933
1934int kvm_vgic_create(struct kvm *kvm) 1934int kvm_vgic_create(struct kvm *kvm)
1935{ 1935{
1936 int i, vcpu_lock_idx = -1, ret = 0; 1936 int i, vcpu_lock_idx = -1, ret;
1937 struct kvm_vcpu *vcpu; 1937 struct kvm_vcpu *vcpu;
1938 1938
1939 mutex_lock(&kvm->lock); 1939 mutex_lock(&kvm->lock);
@@ -1948,6 +1948,7 @@ int kvm_vgic_create(struct kvm *kvm)
1948 * vcpu->mutex. By grabbing the vcpu->mutex of all VCPUs we ensure 1948 * vcpu->mutex. By grabbing the vcpu->mutex of all VCPUs we ensure
1949 * that no other VCPUs are run while we create the vgic. 1949 * that no other VCPUs are run while we create the vgic.
1950 */ 1950 */
1951 ret = -EBUSY;
1951 kvm_for_each_vcpu(i, vcpu, kvm) { 1952 kvm_for_each_vcpu(i, vcpu, kvm) {
1952 if (!mutex_trylock(&vcpu->mutex)) 1953 if (!mutex_trylock(&vcpu->mutex))
1953 goto out_unlock; 1954 goto out_unlock;
@@ -1955,11 +1956,10 @@ int kvm_vgic_create(struct kvm *kvm)
1955 } 1956 }
1956 1957
1957 kvm_for_each_vcpu(i, vcpu, kvm) { 1958 kvm_for_each_vcpu(i, vcpu, kvm) {
1958 if (vcpu->arch.has_run_once) { 1959 if (vcpu->arch.has_run_once)
1959 ret = -EBUSY;
1960 goto out_unlock; 1960 goto out_unlock;
1961 }
1962 } 1961 }
1962 ret = 0;
1963 1963
1964 spin_lock_init(&kvm->arch.vgic.lock); 1964 spin_lock_init(&kvm->arch.vgic.lock);
1965 kvm->arch.vgic.in_kernel = true; 1965 kvm->arch.vgic.in_kernel = true;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 25ffac9e947d..3cee7b167052 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -107,10 +107,10 @@ EXPORT_SYMBOL_GPL(kvm_rebooting);
107 107
108static bool largepages_enabled = true; 108static bool largepages_enabled = true;
109 109
110bool kvm_is_mmio_pfn(pfn_t pfn) 110bool kvm_is_reserved_pfn(pfn_t pfn)
111{ 111{
112 if (pfn_valid(pfn)) 112 if (pfn_valid(pfn))
113 return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn)); 113 return PageReserved(pfn_to_page(pfn));
114 114
115 return true; 115 return true;
116} 116}
@@ -1321,7 +1321,7 @@ static pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
1321 else if ((vma->vm_flags & VM_PFNMAP)) { 1321 else if ((vma->vm_flags & VM_PFNMAP)) {
1322 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) + 1322 pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) +
1323 vma->vm_pgoff; 1323 vma->vm_pgoff;
1324 BUG_ON(!kvm_is_mmio_pfn(pfn)); 1324 BUG_ON(!kvm_is_reserved_pfn(pfn));
1325 } else { 1325 } else {
1326 if (async && vma_is_valid(vma, write_fault)) 1326 if (async && vma_is_valid(vma, write_fault))
1327 *async = true; 1327 *async = true;
@@ -1427,7 +1427,7 @@ static struct page *kvm_pfn_to_page(pfn_t pfn)
1427 if (is_error_noslot_pfn(pfn)) 1427 if (is_error_noslot_pfn(pfn))
1428 return KVM_ERR_PTR_BAD_PAGE; 1428 return KVM_ERR_PTR_BAD_PAGE;
1429 1429
1430 if (kvm_is_mmio_pfn(pfn)) { 1430 if (kvm_is_reserved_pfn(pfn)) {
1431 WARN_ON(1); 1431 WARN_ON(1);
1432 return KVM_ERR_PTR_BAD_PAGE; 1432 return KVM_ERR_PTR_BAD_PAGE;
1433 } 1433 }
@@ -1456,7 +1456,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean);
1456 1456
1457void kvm_release_pfn_clean(pfn_t pfn) 1457void kvm_release_pfn_clean(pfn_t pfn)
1458{ 1458{
1459 if (!is_error_noslot_pfn(pfn) && !kvm_is_mmio_pfn(pfn)) 1459 if (!is_error_noslot_pfn(pfn) && !kvm_is_reserved_pfn(pfn))
1460 put_page(pfn_to_page(pfn)); 1460 put_page(pfn_to_page(pfn));
1461} 1461}
1462EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); 1462EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);
@@ -1477,7 +1477,7 @@ static void kvm_release_pfn_dirty(pfn_t pfn)
1477 1477
1478void kvm_set_pfn_dirty(pfn_t pfn) 1478void kvm_set_pfn_dirty(pfn_t pfn)
1479{ 1479{
1480 if (!kvm_is_mmio_pfn(pfn)) { 1480 if (!kvm_is_reserved_pfn(pfn)) {
1481 struct page *page = pfn_to_page(pfn); 1481 struct page *page = pfn_to_page(pfn);
1482 if (!PageReserved(page)) 1482 if (!PageReserved(page))
1483 SetPageDirty(page); 1483 SetPageDirty(page);
@@ -1487,14 +1487,14 @@ EXPORT_SYMBOL_GPL(kvm_set_pfn_dirty);
1487 1487
1488void kvm_set_pfn_accessed(pfn_t pfn) 1488void kvm_set_pfn_accessed(pfn_t pfn)
1489{ 1489{
1490 if (!kvm_is_mmio_pfn(pfn)) 1490 if (!kvm_is_reserved_pfn(pfn))
1491 mark_page_accessed(pfn_to_page(pfn)); 1491 mark_page_accessed(pfn_to_page(pfn));
1492} 1492}
1493EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed); 1493EXPORT_SYMBOL_GPL(kvm_set_pfn_accessed);
1494 1494
1495void kvm_get_pfn(pfn_t pfn) 1495void kvm_get_pfn(pfn_t pfn)
1496{ 1496{
1497 if (!kvm_is_mmio_pfn(pfn)) 1497 if (!kvm_is_reserved_pfn(pfn))
1498 get_page(pfn_to_page(pfn)); 1498 get_page(pfn_to_page(pfn));
1499} 1499}
1500EXPORT_SYMBOL_GPL(kvm_get_pfn); 1500EXPORT_SYMBOL_GPL(kvm_get_pfn);