aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-11 05:36:43 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-11 05:37:35 -0500
commit47a09af68ba50695c46511b8ed7f036d249bba48 (patch)
tree051c4b70501a9f360729ecc9a9493a2f8ba33b6f
parenta23547374215422017239af32094e1aacc5d435e (diff)
parent206c5f60a3d902bc4b56dab2de3e88de5eb06108 (diff)
Merge tag 'v3.18-rc4' into patchwork
Needed due to some important regression fixes at RC core. * commit 'v3.18-rc4': (587 commits) Linux 3.18-rc4 ARM: dts: zynq: Enable PL clocks for Parallella tiny: rename ENABLE_DEV_COREDUMP to ALLOW_DEV_COREDUMP tiny: reverse logic for DISABLE_DEV_COREDUMP i2c: core: Dispose OF IRQ mapping at client removal time i2c: at91: don't account as iowait i2c: remove FSF address USB: Update default usb-storage delay_use value in kernel-parameters.txt sysfs: driver core: Fix glue dir race condition by gdp_mutex MIPS: Fix build with binutils 2.24.51+ xfs: track bulkstat progress by agino xfs: bulkstat error handling is broken xfs: bulkstat main loop logic is a mess xfs: bulkstat chunk-formatter has issues xfs: bulkstat chunk formatting cursor is broken xfs: bulkstat btree walk doesn't terminate mm: Fix comment before truncate_setsize() USB: cdc-acm: add quirk for control-line state requests tty: Fix pty master poll() after slave closes v2 MIPS: R3000: Fix debug output for Virtual page number ... Conflicts: drivers/media/rc/rc-main.c
-rw-r--r--Documentation/ABI/testing/sysfs-ibft2
-rw-r--r--Documentation/DocBook/media/Makefile2
-rw-r--r--Documentation/HOWTO1
-rw-r--r--Documentation/SubmittingPatches10
-rw-r--r--Documentation/development-process/2.Process4
-rw-r--r--Documentation/development-process/8.Conclusion4
-rw-r--r--Documentation/devicetree/bindings/net/smsc-lan91c111.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/sgtl5000.txt10
-rw-r--r--Documentation/devicetree/bindings/submitting-patches.txt3
-rw-r--r--Documentation/devicetree/bindings/thermal/rcar-thermal.txt5
-rw-r--r--Documentation/kernel-parameters.txt18
-rw-r--r--Documentation/kmemleak.txt4
-rw-r--r--Documentation/prctl/Makefile2
-rw-r--r--Documentation/ptp/testptp.mk33
-rw-r--r--Documentation/vDSO/Makefile3
-rw-r--r--Documentation/vDSO/vdso_standalone_test_x86.c2
-rw-r--r--Documentation/video4linux/vivid.txt12
-rw-r--r--Documentation/vm/hugetlbpage.txt2
-rw-r--r--MAINTAINERS23
-rw-r--r--Makefile4
-rw-r--r--arch/arm/Kconfig.debug2
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/boot/dts/vf610-cosmic.dts19
-rw-r--r--arch/arm/boot/dts/zynq-parallella.dts4
-rw-r--r--arch/arm/common/edma.c9
-rw-r--r--arch/arm/configs/imx_v4_v5_defconfig1
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig1
-rw-r--r--arch/arm/configs/multi_v7_defconfig2
-rw-r--r--arch/arm/configs/omap2plus_defconfig4
-rw-r--r--arch/arm/configs/socfpga_defconfig71
-rw-r--r--arch/arm/include/uapi/asm/unistd.h1
-rw-r--r--arch/arm/kernel/asm-offsets.c12
-rw-r--r--arch/arm/kernel/calls.S1
-rw-r--r--arch/arm/mach-imx/clk-vf610.c134
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/io.h4
-rw-r--r--arch/arm/mach-omap2/omap_device.c4
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c3
-rw-r--r--arch/arm/mach-pxa/include/mach/addr-map.h5
-rw-r--r--arch/arm/mm/cache-l2x0.c26
-rw-r--r--arch/arm/mm/dma-mapping.c1
-rw-r--r--arch/arm/mm/highmem.c3
-rw-r--r--arch/arm/mm/init.c8
-rw-r--r--arch/arm64/configs/defconfig26
-rw-r--r--arch/arm64/include/asm/unistd32.h2
-rw-r--r--arch/arm64/kernel/psci.c2
-rw-r--r--arch/m68k/include/asm/unistd.h2
-rw-r--r--arch/m68k/include/uapi/asm/unistd.h1
-rw-r--r--arch/m68k/kernel/syscalltable.S1
-rw-r--r--arch/microblaze/Kconfig4
-rw-r--r--arch/microblaze/include/asm/unistd.h2
-rw-r--r--arch/microblaze/include/uapi/asm/unistd.h1
-rw-r--r--arch/microblaze/kernel/syscall_table.S1
-rw-r--r--arch/microblaze/pci/pci-common.c9
-rw-r--r--arch/mips/Makefile9
-rw-r--r--arch/mips/cavium-octeon/octeon-irq.c2
-rw-r--r--arch/mips/include/asm/asmmacro-32.h6
-rw-r--r--arch/mips/include/asm/asmmacro.h18
-rw-r--r--arch/mips/include/asm/fpregdef.h14
-rw-r--r--arch/mips/include/asm/fpu.h4
-rw-r--r--arch/mips/include/asm/mipsregs.h11
-rw-r--r--arch/mips/include/uapi/asm/unistd.h15
-rw-r--r--arch/mips/kernel/branch.c8
-rw-r--r--arch/mips/kernel/genex.S1
-rw-r--r--arch/mips/kernel/r2300_fpu.S6
-rw-r--r--arch/mips/kernel/r2300_switch.S5
-rw-r--r--arch/mips/kernel/r4k_fpu.S27
-rw-r--r--arch/mips/kernel/r4k_switch.S15
-rw-r--r--arch/mips/kernel/r6000_fpu.S5
-rw-r--r--arch/mips/kernel/scall32-o32.S1
-rw-r--r--arch/mips/kernel/scall64-64.S1
-rw-r--r--arch/mips/kernel/scall64-n32.S1
-rw-r--r--arch/mips/kernel/scall64-o32.S1
-rw-r--r--arch/mips/kernel/setup.c3
-rw-r--r--arch/mips/lib/r3k_dump_tlb.c4
-rw-r--r--arch/mips/lib/strnlen_user.S6
-rw-r--r--arch/mips/math-emu/cp1emu.c6
-rw-r--r--arch/mips/pci/msi-xlp.c4
-rw-r--r--arch/powerpc/include/asm/fadump.h52
-rw-r--r--arch/powerpc/include/asm/hugetlb.h2
-rw-r--r--arch/powerpc/include/asm/systbl.h1
-rw-r--r--arch/powerpc/include/asm/unistd.h2
-rw-r--r--arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--arch/powerpc/kernel/entry_64.S6
-rw-r--r--arch/powerpc/kernel/fadump.c114
-rw-r--r--arch/powerpc/mm/copro_fault.c3
-rw-r--r--arch/powerpc/mm/init_32.c2
-rw-r--r--arch/powerpc/mm/numa.c7
-rw-r--r--arch/powerpc/mm/slice.c3
-rw-r--r--arch/powerpc/perf/hv-24x7.c6
-rw-r--r--arch/powerpc/perf/hv-gpci.c6
-rw-r--r--arch/powerpc/platforms/powernv/opal-lpc.c63
-rw-r--r--arch/powerpc/platforms/powernv/opal-wrappers.S2
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c4
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c14
-rw-r--r--arch/s390/configs/default_defconfig36
-rw-r--r--arch/s390/configs/gcov_defconfig25
-rw-r--r--arch/s390/configs/performance_defconfig30
-rw-r--r--arch/s390/configs/zfcpdump_defconfig10
-rw-r--r--arch/s390/defconfig5
-rw-r--r--arch/s390/kernel/ftrace.c2
-rw-r--r--arch/s390/kernel/perf_cpum_sf.c6
-rw-r--r--arch/s390/kernel/vdso32/clock_gettime.S12
-rw-r--r--arch/s390/kernel/vdso32/gettimeofday.S14
-rw-r--r--arch/s390/kernel/vdso64/clock_gettime.S13
-rw-r--r--arch/s390/kernel/vdso64/gettimeofday.S6
-rw-r--r--arch/s390/kernel/vtime.c4
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c6
-rw-r--r--arch/sparc/include/uapi/asm/unistd.h3
-rw-r--r--arch/sparc/kernel/systbls_32.S2
-rw-r--r--arch/sparc/kernel/systbls_64.S4
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--arch/x86/ia32/ia32entry.S2
-rw-r--r--arch/x86/include/asm/preempt.h1
-rw-r--r--arch/x86/kernel/acpi/boot.c16
-rw-r--r--arch/x86/kernel/apb_timer.c2
-rw-r--r--arch/x86/kernel/apic/apic.c4
-rw-r--r--arch/x86/kernel/cpu/Makefile7
-rw-r--r--arch/x86/kernel/cpu/intel.c5
-rw-r--r--arch/x86/kernel/cpu/perf_event.c14
-rw-r--r--arch/x86/kernel/cpu/perf_event.h1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c173
-rw-r--r--arch/x86/kernel/entry_32.S15
-rw-r--r--arch/x86/kernel/i8259.c3
-rw-r--r--arch/x86/kernel/irqinit.c3
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/smpboot.c4
-rw-r--r--arch/x86/kernel/tsc.c5
-rw-r--r--arch/x86/kvm/emulate.c55
-rw-r--r--arch/x86/kvm/vmx.c6
-rw-r--r--arch/x86/mm/pageattr.c2
-rw-r--r--arch/x86/platform/intel-mid/sfi.c2
-rw-r--r--block/blk-merge.c5
-rw-r--r--block/elevator.c4
-rw-r--r--block/scsi_ioctl.c3
-rw-r--r--drivers/acpi/ec.c31
-rw-r--r--drivers/acpi/scan.c70
-rw-r--r--drivers/base/Kconfig19
-rw-r--r--drivers/base/core.c4
-rw-r--r--drivers/base/dma-contiguous.c3
-rw-r--r--drivers/base/power/main.c2
-rw-r--r--drivers/bcma/host_pci.c5
-rw-r--r--drivers/bcma/main.c2
-rw-r--r--drivers/block/null_blk.c14
-rw-r--r--drivers/block/rbd.c35
-rw-r--r--drivers/block/sunvdc.c9
-rw-r--r--drivers/block/zram/zram_drv.c10
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/clocksource/arm_arch_timer.c6
-rw-r--r--drivers/cpufreq/cpufreq-dt.c68
-rw-r--r--drivers/dma/edma.c40
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c21
-rw-r--r--drivers/gpu/drm/armada/armada_drv.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dpi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c43
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c5
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c24
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c4
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c24
-rw-r--r--drivers/hid/hid-debug.c6
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-input.c12
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c5
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c5
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c5
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.h7
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c4
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756.c4
-rw-r--r--drivers/i2c/busses/i2c-at91.c2
-rw-r--r--drivers/i2c/busses/i2c-au1550.c4
-rw-r--r--drivers/i2c/busses/i2c-cpm.c4
-rw-r--r--drivers/i2c/busses/i2c-davinci.c4
-rw-r--r--drivers/i2c/busses/i2c-designware-core.c4
-rw-r--r--drivers/i2c/busses/i2c-designware-core.h4
-rw-r--r--drivers/i2c/busses/i2c-designware-pcidrv.c4
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c4
-rw-r--r--drivers/i2c/busses/i2c-eg20t.c4
-rw-r--r--drivers/i2c/busses/i2c-elektor.c6
-rw-r--r--drivers/i2c/busses/i2c-hydra.c4
-rw-r--r--drivers/i2c/busses/i2c-i801.c4
-rw-r--r--drivers/i2c/busses/i2c-imx.c5
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.h6
-rw-r--r--drivers/i2c/busses/i2c-isch.c4
-rw-r--r--drivers/i2c/busses/i2c-ismt.c4
-rw-r--r--drivers/i2c/busses/i2c-nforce2-s4985.c4
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c4
-rw-r--r--drivers/i2c/busses/i2c-omap.c4
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c4
-rw-r--r--drivers/i2c/busses/i2c-parport.c4
-rw-r--r--drivers/i2c/busses/i2c-parport.h4
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c4
-rw-r--r--drivers/i2c/busses/i2c-pca-isa.c4
-rw-r--r--drivers/i2c/busses/i2c-piix4.c4
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c4
-rw-r--r--drivers/i2c/busses/i2c-powermac.c4
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c4
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c4
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c4
-rw-r--r--drivers/i2c/busses/i2c-simtec.c4
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c4
-rw-r--r--drivers/i2c/busses/i2c-sis630.c4
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c4
-rw-r--r--drivers/i2c/busses/i2c-taos-evm.c4
-rw-r--r--drivers/i2c/busses/i2c-via.c4
-rw-r--r--drivers/i2c/busses/i2c-viapro.c4
-rw-r--r--drivers/i2c/busses/i2c-xiic.c4
-rw-r--r--drivers/i2c/busses/scx200_acb.c4
-rw-r--r--drivers/i2c/i2c-boardinfo.c5
-rw-r--r--drivers/i2c/i2c-core.c10
-rw-r--r--drivers/i2c/i2c-core.h5
-rw-r--r--drivers/i2c/i2c-dev.c5
-rw-r--r--drivers/i2c/i2c-smbus.c5
-rw-r--r--drivers/i2c/i2c-stub.c4
-rw-r--r--drivers/iio/accel/kxcjk-1013.c2
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_buffer.c2
-rw-r--r--drivers/iio/light/tsl4531.c7
-rw-r--r--drivers/iio/proximity/as3935.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c10
-rw-r--r--drivers/input/keyboard/opencores-kbd.c2
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c2
-rw-r--r--drivers/input/misc/ims-pcu.c2
-rw-r--r--drivers/input/misc/max77693-haptic.c5
-rw-r--r--drivers/input/misc/soc_button_array.c2
-rw-r--r--drivers/input/mouse/psmouse-base.c7
-rw-r--r--drivers/input/mouse/vsxxxaa.c2
-rw-r--r--drivers/input/serio/altera_ps2.c4
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h297
-rw-r--r--drivers/input/serio/i8042.c2
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c4
-rw-r--r--drivers/irqchip/irq-armada-370-xp.c23
-rw-r--r--drivers/media/dvb-core/dvb_frontend.c6
-rw-r--r--drivers/media/dvb-frontends/ds3000.c7
-rw-r--r--drivers/media/dvb-frontends/sp2.c4
-rw-r--r--drivers/media/dvb-frontends/tc90522.c18
-rw-r--r--drivers/media/platform/vivid/vivid-core.c11
-rw-r--r--drivers/media/rc/imon.c3
-rw-r--r--drivers/media/rc/ir-hix5hd2.c2
-rw-r--r--drivers/media/rc/ir-rc5-decoder.c2
-rw-r--r--drivers/media/rc/rc-ir-raw.c1
-rw-r--r--drivers/media/rc/rc-main.c2
-rw-r--r--drivers/misc/cxl/fault.c74
-rw-r--r--drivers/misc/cxl/native.c4
-rw-r--r--drivers/mmc/core/host.c21
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/devices/m25p80.c64
-rw-r--r--drivers/mtd/nand/omap_elm.c2
-rw-r--r--drivers/mtd/spi-nor/fsl-quadspi.c7
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c16
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/dsa/mv88e6171.c2
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c22
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c16
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c11
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c5
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c55
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c7
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c16
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_clsf.c12
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-fec.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-scc.c3
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c5
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c4
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c1
-rw-r--r--drivers/net/ethernet/sfc/tx.c4
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c58
-rw-r--r--drivers/net/ethernet/smsc/smc91x.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c7
-rw-r--r--drivers/net/ethernet/ti/cpsw.c48
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.c29
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.h2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c1
-rw-r--r--drivers/net/macvlan.c10
-rw-r--r--drivers/net/macvtap.c16
-rw-r--r--drivers/net/phy/marvell.c19
-rw-r--r--drivers/net/tun.c25
-rw-r--r--drivers/net/usb/ax88179_178a.c7
-rw-r--r--drivers/net/usb/cdc_ether.c47
-rw-r--r--drivers/net/usb/r8152.c17
-rw-r--r--drivers/net/usb/usbnet.c20
-rw-r--r--drivers/net/virtio_net.c24
-rw-r--r--drivers/net/wireless/ath/ath.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c55
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c10
-rw-r--r--drivers/net/wireless/ath/regd.c14
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c25
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-8000.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/coex.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/coex_legacy.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api-power.h35
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw.c9
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c32
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/ops.c1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/time-event.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/tx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c22
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.c52
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.h2
-rw-r--r--drivers/net/wireless/mwifiex/main.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c1
-rw-r--r--drivers/net/wireless/rtlwifi/base.c2
-rw-r--r--drivers/net/wireless/rtlwifi/core.c6
-rw-r--r--drivers/net/wireless/rtlwifi/core.h1
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c17
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ee/hw.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c22
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8821ae/phy.c15
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c11
-rw-r--r--drivers/net/xen-netback/common.h39
-rw-r--r--drivers/net/xen-netback/interface.c74
-rw-r--r--drivers/net/xen-netback/netback.c319
-rw-r--r--drivers/net/xen-netback/xenbus.c22
-rw-r--r--drivers/of/base.c88
-rw-r--r--drivers/of/of_reserved_mem.c14
-rw-r--r--drivers/of/selftest.c66
-rw-r--r--drivers/of/testcase-data/tests-phandle.dtsi2
-rw-r--r--drivers/pci/host/pci-imx6.c13
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
-rw-r--r--drivers/pci/pci-sysfs.c8
-rw-r--r--drivers/phy/phy-omap-usb2.c6
-rw-r--r--drivers/pinctrl/pinctrl-baytrail.c8
-rw-r--r--drivers/platform/x86/acer-wmi.c11
-rw-r--r--drivers/platform/x86/asus-nb-wmi.c9
-rw-r--r--drivers/platform/x86/ideapad-laptop.c7
-rw-r--r--drivers/platform/x86/samsung-laptop.c10
-rw-r--r--drivers/platform/x86/toshiba_acpi.c6
-rw-r--r--drivers/regulator/max1586.c2
-rw-r--r--drivers/regulator/max77686.c2
-rw-r--r--drivers/regulator/max77693.c2
-rw-r--r--drivers/regulator/max77802.c2
-rw-r--r--drivers/regulator/max8660.c2
-rw-r--r--drivers/regulator/of_regulator.c3
-rw-r--r--drivers/regulator/s2mpa01.c2
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-bq32k.c2
-rw-r--r--drivers/rtc/rtc-pm8xxx.c222
-rw-r--r--drivers/rtc/rtc-s3c.c14
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c42
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.h5
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/soc/versatile/soc-realview.c1
-rw-r--r--drivers/spi/spi-fsl-dspi.c4
-rw-r--r--drivers/spi/spi-pxa2xx.c7
-rw-r--r--drivers/staging/android/logger.c13
-rw-r--r--drivers/staging/comedi/Kconfig2
-rw-r--r--drivers/staging/comedi/comedi_fops.c26
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c12
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c15
-rw-r--r--drivers/staging/iio/meter/ade7758.h1
-rw-r--r--drivers/staging/iio/meter/ade7758_core.c57
-rw-r--r--drivers/staging/iio/meter/ade7758_ring.c5
-rw-r--r--drivers/staging/rtl8723au/include/rtw_eeprom.h2
-rw-r--r--drivers/thermal/of-thermal.c40
-rw-r--r--drivers/thermal/samsung/exynos_thermal_common.h2
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c170
-rw-r--r--drivers/thermal/samsung/exynos_tmu.h89
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c104
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.h54
-rw-r--r--drivers/thermal/thermal_core.c3
-rw-r--r--drivers/tty/n_tty.c9
-rw-r--r--drivers/tty/serial/8250/8250_mtk.c2
-rw-r--r--drivers/tty/serial/of_serial.c2
-rw-r--r--drivers/tty/serial/serial_core.c2
-rw-r--r--drivers/tty/tty_io.c15
-rw-r--r--drivers/tty/vt/consolemap.c7
-rw-r--r--drivers/usb/chipidea/core.c1
-rw-r--r--drivers/usb/class/cdc-acm.c25
-rw-r--r--drivers/usb/class/cdc-acm.h2
-rw-r--r--drivers/usb/core/hcd.c2
-rw-r--r--drivers/usb/core/hub.c10
-rw-r--r--drivers/usb/core/quirks.c6
-rw-r--r--drivers/usb/dwc2/core.h2
-rw-r--r--drivers/usb/dwc2/gadget.c16
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c15
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/ep0.c48
-rw-r--r--drivers/usb/dwc3/gadget.c39
-rw-r--r--drivers/usb/dwc3/gadget.h3
-rw-r--r--drivers/usb/dwc3/trace.h53
-rw-r--r--drivers/usb/gadget/composite.c2
-rw-r--r--drivers/usb/gadget/function/f_acm.c8
-rw-r--r--drivers/usb/gadget/function/f_eem.c1
-rw-r--r--drivers/usb/gadget/function/f_fs.c42
-rw-r--r--drivers/usb/gadget/function/f_hid.c5
-rw-r--r--drivers/usb/gadget/function/f_loopback.c87
-rw-r--r--drivers/usb/gadget/function/f_ncm.c1
-rw-r--r--drivers/usb/gadget/function/f_obex.c9
-rw-r--r--drivers/usb/gadget/function/f_phonet.c2
-rw-r--r--drivers/usb/gadget/function/f_rndis.c9
-rw-r--r--drivers/usb/gadget/function/f_subset.c1
-rw-r--r--drivers/usb/gadget/function/f_uac2.c23
-rw-r--r--drivers/usb/gadget/function/f_uvc.c54
-rw-r--r--drivers/usb/gadget/function/uvc_video.c3
-rw-r--r--drivers/usb/gadget/udc/Kconfig1
-rw-r--r--drivers/usb/gadget/udc/udc-core.c5
-rw-r--r--drivers/usb/host/Kconfig4
-rw-r--r--drivers/usb/host/hwa-hc.c2
-rw-r--r--drivers/usb/host/xhci-pci.c18
-rw-r--r--drivers/usb/musb/musb_cppi41.c3
-rw-r--r--drivers/usb/musb/musb_dsps.c18
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h12
-rw-r--r--drivers/usb/serial/kobil_sct.c20
-rw-r--r--drivers/usb/serial/opticon.c2
-rw-r--r--drivers/usb/serial/option.c10
-rw-r--r--drivers/usb/storage/initializers.c4
-rw-r--r--drivers/usb/storage/realtek_cr.c2
-rw-r--r--drivers/usb/storage/transport.c26
-rw-r--r--drivers/usb/storage/unusual_uas.h28
-rw-r--r--drivers/video/console/fbcon.c19
-rw-r--r--drivers/video/console/vgacon.c24
-rw-r--r--drivers/video/fbdev/atmel_lcdfb.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c3
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-dvi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-hdmi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-dpi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/apply.c2
-rw-r--r--drivers/video/fbdev/omap2/dss/dispc.c8
-rw-r--r--drivers/video/fbdev/omap2/dss/dispc.h3
-rw-r--r--drivers/video/fbdev/omap2/dss/dpi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/dsi.c3
-rw-r--r--drivers/video/fbdev/omap2/dss/dss.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi4.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi5.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi_pll.c13
-rw-r--r--drivers/video/fbdev/omap2/dss/rfbi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/sdi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/venc.c1
-rw-r--r--drivers/video/fbdev/omap2/omapfb/omapfb-main.c18
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c43
-rw-r--r--fs/btrfs/extent-tree.c18
-rw-r--r--fs/btrfs/file-item.c2
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/btrfs/tree-log.c2
-rw-r--r--fs/buffer.c38
-rw-r--r--fs/ext3/super.c7
-rw-r--r--fs/ext4/extents.c9
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/ialloc.c4
-rw-r--r--fs/ext4/inode.c7
-rw-r--r--fs/ext4/namei.c28
-rw-r--r--fs/ext4/resize.c2
-rw-r--r--fs/ext4/super.c17
-rw-r--r--fs/isofs/inode.c24
-rw-r--r--fs/isofs/namei.c22
-rw-r--r--fs/jbd/revoke.c7
-rw-r--r--fs/jbd2/revoke.c10
-rw-r--r--fs/namei.c5
-rw-r--r--fs/nfsd/nfs4proc.c7
-rw-r--r--fs/notify/inode_mark.c17
-rw-r--r--fs/ocfs2/cluster/tcp.c2
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/overlayfs/readdir.c19
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--fs/xfs/xfs_bmap_util.c72
-rw-r--r--fs/xfs/xfs_itable.c250
-rw-r--r--fs/xfs/xfs_itable.h16
-rw-r--r--include/drm/drm_pciids.h1
-rw-r--r--include/dt-bindings/clock/vf610-clock.h39
-rw-r--r--include/linux/blkdev.h7
-rw-r--r--include/linux/cma.h8
-rw-r--r--include/linux/compiler-gcc4.h1
-rw-r--r--include/linux/compiler-gcc5.h1
-rw-r--r--include/linux/fs.h10
-rw-r--r--include/linux/khugepaged.h17
-rw-r--r--include/linux/memcontrol.h58
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/mtd/spi-nor.h21
-rw-r--r--include/linux/of.h84
-rw-r--r--include/linux/of_reserved_mem.h9
-rw-r--r--include/linux/pci-acpi.h7
-rw-r--r--include/linux/rcupdate.h15
-rw-r--r--include/linux/skbuff.h12
-rw-r--r--include/linux/usb/usbnet.h4
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/netfilter/ipv4/nf_reject.h10
-rw-r--r--include/net/netfilter/ipv6/nf_reject.h10
-rw-r--r--include/net/netfilter/nf_tables.h3
-rw-r--r--include/net/netfilter/nft_masq.h3
-rw-r--r--include/scsi/scsi_tcq.h8
-rw-r--r--include/trace/events/rcu.h18
-rw-r--r--include/uapi/linux/input.h7
-rw-r--r--include/uapi/linux/perf_event.h14
-rw-r--r--include/uapi/linux/sched.h2
-rw-r--r--init/Kconfig14
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/bpf/Makefile6
-rw-r--r--kernel/bpf/core.c9
-rw-r--r--kernel/bpf/verifier.c3
-rw-r--r--kernel/context_tracking.c40
-rw-r--r--kernel/cpu.c14
-rw-r--r--kernel/events/core.c15
-rw-r--r--kernel/events/hw_breakpoint.c7
-rw-r--r--kernel/futex.c36
-rw-r--r--kernel/gcov/Kconfig2
-rw-r--r--kernel/kmod.c76
-rw-r--r--kernel/power/hibernate.c8
-rw-r--r--kernel/rcu/tree.c15
-rw-r--r--kernel/rcu/tree.h1
-rw-r--r--kernel/rcu/tree_plugin.h33
-rw-r--r--kernel/sched/core.c47
-rw-r--r--kernel/sched/deadline.c41
-rw-r--r--kernel/sched/fair.c21
-rw-r--r--kernel/sysctl.c3
-rw-r--r--kernel/time/clockevents.c2
-rw-r--r--kernel/time/posix-timers.c1
-rw-r--r--kernel/trace/ftrace.c54
-rw-r--r--kernel/trace/trace_syscalls.c8
-rw-r--r--lib/bitmap.c8
-rw-r--r--lib/scatterlist.c6
-rw-r--r--mm/balloon_compaction.c2
-rw-r--r--mm/cma.c68
-rw-r--r--mm/compaction.c3
-rw-r--r--mm/huge_memory.c15
-rw-r--r--mm/memcontrol.c105
-rw-r--r--mm/memory.c1
-rw-r--r--mm/memory_hotplug.c5
-rw-r--r--mm/mmap.c8
-rw-r--r--mm/page-writeback.c43
-rw-r--r--mm/page_cgroup.c1
-rw-r--r--mm/rmap.c88
-rw-r--r--mm/slab_common.c10
-rw-r--r--mm/truncate.c6
-rw-r--r--net/Kconfig2
-rw-r--r--net/bridge/br_forward.c1
-rw-r--r--net/bridge/br_netfilter.c24
-rw-r--r--net/bridge/netfilter/nf_tables_bridge.c6
-rw-r--r--net/bridge/netfilter/nft_reject_bridge.c296
-rw-r--r--net/ceph/auth_x.c25
-rw-r--r--net/ceph/messenger.c10
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/ethtool.c6
-rw-r--r--net/core/skbuff.c13
-rw-r--r--net/core/tso.c3
-rw-r--r--net/dsa/dsa.c5
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/gre_offload.c4
-rw-r--r--net/ipv4/inet_fragment.c4
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/netfilter/nf_reject_ipv4.c91
-rw-r--r--net/ipv4/netfilter/nft_masq_ipv4.c1
-rw-r--r--net/ipv4/route.c1
-rw-r--r--net/ipv4/tcp.c59
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_output.c2
-rw-r--r--net/ipv4/udp_offload.c2
-rw-r--r--net/ipv6/addrconf.c1
-rw-r--r--net/ipv6/ip6_offload.c2
-rw-r--r--net/ipv6/netfilter/nf_reject_ipv6.c179
-rw-r--r--net/ipv6/netfilter/nft_masq_ipv6.c1
-rw-r--r--net/ipv6/output_core.c34
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/ipv6/xfrm6_policy.c11
-rw-r--r--net/irda/af_irda.c2
-rw-r--r--net/mac80211/cfg.c2
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c12
-rw-r--r--net/mac80211/rc80211_minstrel_ht_debugfs.c13
-rw-r--r--net/mac80211/sta_info.h1
-rw-r--r--net/mpls/Makefile2
-rw-r--r--net/mpls/mpls_gso.c5
-rw-r--r--net/netfilter/ipset/ip_set_core.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c4
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c4
-rw-r--r--net/netfilter/nf_tables_api.c18
-rw-r--r--net/netfilter/nfnetlink_log.c31
-rw-r--r--net/netfilter/nfnetlink_queue_core.c2
-rw-r--r--net/netfilter/nft_compat.c81
-rw-r--r--net/netfilter/nft_masq.c12
-rw-r--r--net/netfilter/nft_nat.c86
-rw-r--r--net/netlink/af_netlink.c37
-rw-r--r--net/openvswitch/datapath.c2
-rw-r--r--net/sched/sch_api.c2
-rw-r--r--net/sched/sch_pie.c2
-rw-r--r--net/tipc/node.c46
-rw-r--r--net/tipc/node.h7
-rw-r--r--net/tipc/socket.c6
-rw-r--r--net/wireless/nl80211.c10
-rw-r--r--net/xfrm/xfrm_output.c2
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--samples/bpf/test_verifier.c11
-rw-r--r--security/integrity/evm/evm_main.c9
-rw-r--r--security/integrity/ima/ima_appraise.c2
-rw-r--r--security/integrity/integrity.h1
-rw-r--r--sound/core/pcm_compat.c2
-rw-r--r--sound/firewire/bebob/bebob_focusrite.c62
-rw-r--r--sound/firewire/bebob/bebob_stream.c18
-rw-r--r--sound/firewire/bebob/bebob_terratec.c7
-rw-r--r--sound/pci/ad1889.c8
-rw-r--r--sound/pci/hda/hda_intel.c4
-rw-r--r--sound/pci/hda/patch_realtek.c128
-rw-r--r--sound/soc/Kconfig1
-rw-r--r--sound/soc/Makefile1
-rw-r--r--sound/soc/codecs/adau1761.c4
-rw-r--r--sound/soc/fsl/fsl_asrc.c2
-rw-r--r--sound/soc/fsl/fsl_esai.c2
-rw-r--r--sound/soc/intel/sst-haswell-pcm.c4
-rw-r--r--sound/soc/s6000/Kconfig26
-rw-r--r--sound/soc/s6000/Makefile11
-rw-r--r--sound/soc/s6000/s6000-i2s.c617
-rw-r--r--sound/soc/s6000/s6000-i2s.h23
-rw-r--r--sound/soc/s6000/s6000-pcm.c521
-rw-r--r--sound/soc/s6000/s6000-pcm.h33
-rw-r--r--sound/soc/s6000/s6105-ipcam.c221
-rw-r--r--sound/usb/card.c9
-rw-r--r--tools/perf/builtin-diff.c5
-rw-r--r--tools/perf/builtin-probe.c2
-rw-r--r--tools/perf/perf-sys.h30
-rw-r--r--tools/perf/util/header.c27
-rw-r--r--tools/perf/util/sort.c102
-rw-r--r--tools/perf/util/thread.c3
-rw-r--r--tools/perf/util/unwind-libunwind.c12
-rw-r--r--tools/perf/util/unwind.h3
-rwxr-xr-xtools/testing/selftests/ftrace/ftracetest2
667 files changed, 5899 insertions, 5308 deletions
diff --git a/Documentation/ABI/testing/sysfs-ibft b/Documentation/ABI/testing/sysfs-ibft
index c2b7d1154bec..cac3930bdb04 100644
--- a/Documentation/ABI/testing/sysfs-ibft
+++ b/Documentation/ABI/testing/sysfs-ibft
@@ -20,4 +20,4 @@ Date: November 2007
20Contact: Konrad Rzeszutek <ketuzsezr@darnok.org> 20Contact: Konrad Rzeszutek <ketuzsezr@darnok.org>
21Description: The /sys/firmware/ibft/ethernetX directory will contain 21Description: The /sys/firmware/ibft/ethernetX directory will contain
22 files that expose the iSCSI Boot Firmware Table NIC data. 22 files that expose the iSCSI Boot Firmware Table NIC data.
23 This can this can the IP address, MAC, and gateway of the NIC. 23 Usually this contains the IP address, MAC, and gateway of the NIC.
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index df2962d9e11e..8bf7c6191296 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -25,7 +25,7 @@ GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
25PHONY += cleanmediadocs 25PHONY += cleanmediadocs
26 26
27cleanmediadocs: 27cleanmediadocs:
28 -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(OBJIMGFILES) 2>/dev/null 28 -@rm -f `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(OBJIMGFILES) 2>/dev/null
29 29
30$(obj)/media_api.xml: $(GENFILES) FORCE 30$(obj)/media_api.xml: $(GENFILES) FORCE
31 31
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 57cf5efb044d..93aa8604630e 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -324,7 +324,6 @@ tree, they need to be integration-tested. For this purpose, a special
324testing repository exists into which virtually all subsystem trees are 324testing repository exists into which virtually all subsystem trees are
325pulled on an almost daily basis: 325pulled on an almost daily basis:
326 http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 326 http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
327 http://linux.f-seidel.de/linux-next/pmwiki/
328 327
329This way, the -next kernel gives a summary outlook onto what will be 328This way, the -next kernel gives a summary outlook onto what will be
330expected to go into the mainline kernel at the next merge period. 329expected to go into the mainline kernel at the next merge period.
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 482c74947de0..1fa1caa198eb 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -483,12 +483,10 @@ have been included in the discussion
483 483
48414) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: 48414) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes:
485 485
486If this patch fixes a problem reported by somebody else, consider adding a 486The Reported-by tag gives credit to people who find bugs and report them and it
487Reported-by: tag to credit the reporter for their contribution. Please 487hopefully inspires them to help us again in the future. Please note that if
488note that this tag should not be added without the reporter's permission, 488the bug was reported in private, then ask for permission first before using the
489especially if the problem was not reported in a public forum. That said, 489Reported-by tag.
490if we diligently credit our bug reporters, they will, hopefully, be
491inspired to help us again in the future.
492 490
493A Tested-by: tag indicates that the patch has been successfully tested (in 491A Tested-by: tag indicates that the patch has been successfully tested (in
494some environment) by the person named. This tag informs maintainers that 492some environment) by the person named. This tag informs maintainers that
diff --git a/Documentation/development-process/2.Process b/Documentation/development-process/2.Process
index 2e0617936e8f..c24e156a6118 100644
--- a/Documentation/development-process/2.Process
+++ b/Documentation/development-process/2.Process
@@ -289,10 +289,6 @@ lists when they are assembled; they can be downloaded from:
289 289
290 http://www.kernel.org/pub/linux/kernel/next/ 290 http://www.kernel.org/pub/linux/kernel/next/
291 291
292Some information about linux-next has been gathered at:
293
294 http://linux.f-seidel.de/linux-next/pmwiki/
295
296Linux-next has become an integral part of the kernel development process; 292Linux-next has become an integral part of the kernel development process;
297all patches merged during a given merge window should really have found 293all patches merged during a given merge window should really have found
298their way into linux-next some time before the merge window opens. 294their way into linux-next some time before the merge window opens.
diff --git a/Documentation/development-process/8.Conclusion b/Documentation/development-process/8.Conclusion
index 1990ab4b4949..caef69022e9c 100644
--- a/Documentation/development-process/8.Conclusion
+++ b/Documentation/development-process/8.Conclusion
@@ -22,10 +22,6 @@ Beyond that, a valuable resource for kernel developers is:
22 22
23 http://kernelnewbies.org/ 23 http://kernelnewbies.org/
24 24
25Information about the linux-next tree gathers at:
26
27 http://linux.f-seidel.de/linux-next/pmwiki/
28
29And, of course, one should not forget http://kernel.org/, the definitive 25And, of course, one should not forget http://kernel.org/, the definitive
30location for kernel release information. 26location for kernel release information.
31 27
diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index 0f8487b88822..e77e167593db 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -11,3 +11,5 @@ Optional properties:
11 are supported on the device. Valid value for SMSC LAN91c111 are 11 are supported on the device. Valid value for SMSC LAN91c111 are
12 1, 2 or 4. If it's omitted or invalid, the size would be 2 meaning 12 1, 2 or 4. If it's omitted or invalid, the size would be 2 meaning
13 16-bit access only. 13 16-bit access only.
14- power-gpios: GPIO to control the PWRDWN pin
15- reset-gpios: GPIO to control the RESET pin
diff --git a/Documentation/devicetree/bindings/sound/sgtl5000.txt b/Documentation/devicetree/bindings/sound/sgtl5000.txt
index 955df60a118c..d556dcb8816b 100644
--- a/Documentation/devicetree/bindings/sound/sgtl5000.txt
+++ b/Documentation/devicetree/bindings/sound/sgtl5000.txt
@@ -7,10 +7,20 @@ Required properties:
7 7
8- clocks : the clock provider of SYS_MCLK 8- clocks : the clock provider of SYS_MCLK
9 9
10- VDDA-supply : the regulator provider of VDDA
11
12- VDDIO-supply: the regulator provider of VDDIO
13
14Optional properties:
15
16- VDDD-supply : the regulator provider of VDDD
17
10Example: 18Example:
11 19
12codec: sgtl5000@0a { 20codec: sgtl5000@0a {
13 compatible = "fsl,sgtl5000"; 21 compatible = "fsl,sgtl5000";
14 reg = <0x0a>; 22 reg = <0x0a>;
15 clocks = <&clks 150>; 23 clocks = <&clks 150>;
24 VDDA-supply = <&reg_3p3v>;
25 VDDIO-supply = <&reg_3p3v>;
16}; 26};
diff --git a/Documentation/devicetree/bindings/submitting-patches.txt b/Documentation/devicetree/bindings/submitting-patches.txt
index 042a0273b8ba..b7ba01ad1426 100644
--- a/Documentation/devicetree/bindings/submitting-patches.txt
+++ b/Documentation/devicetree/bindings/submitting-patches.txt
@@ -12,6 +12,9 @@ I. For patch submitters
12 12
13 devicetree@vger.kernel.org 13 devicetree@vger.kernel.org
14 14
15 3) The Documentation/ portion of the patch should come in the series before
16 the code implementing the binding.
17
15II. For kernel maintainers 18II. For kernel maintainers
16 19
17 1) If you aren't comfortable reviewing a given binding, reply to it and ask 20 1) If you aren't comfortable reviewing a given binding, reply to it and ask
diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
index 0ef00be44b01..43404b197933 100644
--- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
@@ -7,7 +7,10 @@ Required properties:
7 - "renesas,thermal-r8a73a4" (R-Mobile AP6) 7 - "renesas,thermal-r8a73a4" (R-Mobile AP6)
8 - "renesas,thermal-r8a7779" (R-Car H1) 8 - "renesas,thermal-r8a7779" (R-Car H1)
9 - "renesas,thermal-r8a7790" (R-Car H2) 9 - "renesas,thermal-r8a7790" (R-Car H2)
10 - "renesas,thermal-r8a7791" (R-Car M2) 10 - "renesas,thermal-r8a7791" (R-Car M2-W)
11 - "renesas,thermal-r8a7792" (R-Car V2H)
12 - "renesas,thermal-r8a7793" (R-Car M2-N)
13 - "renesas,thermal-r8a7794" (R-Car E2)
11- reg : Address range of the thermal registers. 14- reg : Address range of the thermal registers.
12 The 1st reg will be recognized as common register 15 The 1st reg will be recognized as common register
13 if it has "interrupts". 16 if it has "interrupts".
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 74339c57b914..479f33204a37 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1264,7 +1264,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1264 i8042.noloop [HW] Disable the AUX Loopback command while probing 1264 i8042.noloop [HW] Disable the AUX Loopback command while probing
1265 for the AUX port 1265 for the AUX port
1266 i8042.nomux [HW] Don't check presence of an active multiplexing 1266 i8042.nomux [HW] Don't check presence of an active multiplexing
1267 controller. Default: true. 1267 controller
1268 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX 1268 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
1269 controllers 1269 controllers
1270 i8042.notimeout [HW] Ignore timeout condition signalled by controller 1270 i8042.notimeout [HW] Ignore timeout condition signalled by controller
@@ -1307,6 +1307,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1307 .cdrom .chs .ignore_cable are additional options 1307 .cdrom .chs .ignore_cable are additional options
1308 See Documentation/ide/ide.txt. 1308 See Documentation/ide/ide.txt.
1309 1309
1310 ide-generic.probe-mask= [HW] (E)IDE subsystem
1311 Format: <int>
1312 Probe mask for legacy ISA IDE ports. Depending on
1313 platform up to 6 ports are supported, enabled by
1314 setting corresponding bits in the mask to 1. The
1315 default value is 0x0, which has a special meaning.
1316 On systems that have PCI, it triggers scanning the
1317 PCI bus for the first and the second port, which
1318 are then probed. On systems without PCI the value
1319 of 0x0 enables probing the two first ports as if it
1320 was 0x3.
1321
1310 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem 1322 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem
1311 Claim all unknown PCI IDE storage controllers. 1323 Claim all unknown PCI IDE storage controllers.
1312 1324
@@ -1587,6 +1599,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1587 kmemleak= [KNL] Boot-time kmemleak enable/disable 1599 kmemleak= [KNL] Boot-time kmemleak enable/disable
1588 Valid arguments: on, off 1600 Valid arguments: on, off
1589 Default: on 1601 Default: on
1602 Built with CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y,
1603 the default is off.
1590 1604
1591 kmemcheck= [X86] Boot-time kmemcheck enable/disable/one-shot mode 1605 kmemcheck= [X86] Boot-time kmemcheck enable/disable/one-shot mode
1592 Valid arguments: 0, 1, 2 1606 Valid arguments: 0, 1, 2
@@ -3607,7 +3621,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
3607 3621
3608 usb-storage.delay_use= 3622 usb-storage.delay_use=
3609 [UMS] The delay in seconds before a new device is 3623 [UMS] The delay in seconds before a new device is
3610 scanned for Logical Units (default 5). 3624 scanned for Logical Units (default 1).
3611 3625
3612 usb-storage.quirks= 3626 usb-storage.quirks=
3613 [UMS] A list of quirks entries to supplement or 3627 [UMS] A list of quirks entries to supplement or
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index f4f033c8d856..45e777f4e41d 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -62,6 +62,10 @@ Memory may be allocated or freed before kmemleak is initialised and
62these actions are stored in an early log buffer. The size of this buffer 62these actions are stored in an early log buffer. The size of this buffer
63is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option. 63is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option.
64 64
65If CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF are enabled, the kmemleak is
66disabled by default. Passing "kmemleak=on" on the kernel command
67line enables the function.
68
65Basic Algorithm 69Basic Algorithm
66--------------- 70---------------
67 71
diff --git a/Documentation/prctl/Makefile b/Documentation/prctl/Makefile
index 3e3232dcb2b8..2948b7b124b9 100644
--- a/Documentation/prctl/Makefile
+++ b/Documentation/prctl/Makefile
@@ -1,5 +1,5 @@
1# List of programs to build 1# List of programs to build
2hostprogs-y := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test disable-tsc-test 2hostprogs-$(CONFIG_X86) := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test disable-tsc-test
3# Tell kbuild to always build the programs 3# Tell kbuild to always build the programs
4always := $(hostprogs-y) 4always := $(hostprogs-y)
5 5
diff --git a/Documentation/ptp/testptp.mk b/Documentation/ptp/testptp.mk
new file mode 100644
index 000000000000..4ef2d9755421
--- /dev/null
+++ b/Documentation/ptp/testptp.mk
@@ -0,0 +1,33 @@
1# PTP 1588 clock support - User space test program
2#
3# Copyright (C) 2010 OMICRON electronics GmbH
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19CC = $(CROSS_COMPILE)gcc
20INC = -I$(KBUILD_OUTPUT)/usr/include
21CFLAGS = -Wall $(INC)
22LDLIBS = -lrt
23PROGS = testptp
24
25all: $(PROGS)
26
27testptp: testptp.o
28
29clean:
30 rm -f testptp.o
31
32distclean: clean
33 rm -f $(PROGS)
diff --git a/Documentation/vDSO/Makefile b/Documentation/vDSO/Makefile
index 2b99e57207c1..ee075c3d2124 100644
--- a/Documentation/vDSO/Makefile
+++ b/Documentation/vDSO/Makefile
@@ -10,3 +10,6 @@ always := $(hostprogs-y)
10HOSTCFLAGS := -I$(objtree)/usr/include -std=gnu99 10HOSTCFLAGS := -I$(objtree)/usr/include -std=gnu99
11HOSTCFLAGS_vdso_standalone_test_x86.o := -fno-asynchronous-unwind-tables -fno-stack-protector 11HOSTCFLAGS_vdso_standalone_test_x86.o := -fno-asynchronous-unwind-tables -fno-stack-protector
12HOSTLOADLIBES_vdso_standalone_test_x86 := -nostdlib 12HOSTLOADLIBES_vdso_standalone_test_x86 := -nostdlib
13ifeq ($(CONFIG_X86_32),y)
14HOSTLOADLIBES_vdso_standalone_test_x86 += -lgcc_s
15endif
diff --git a/Documentation/vDSO/vdso_standalone_test_x86.c b/Documentation/vDSO/vdso_standalone_test_x86.c
index d46240265c50..93b0ebf8cc38 100644
--- a/Documentation/vDSO/vdso_standalone_test_x86.c
+++ b/Documentation/vDSO/vdso_standalone_test_x86.c
@@ -63,7 +63,7 @@ static inline void linux_exit(int code)
63 x86_syscall3(__NR_exit, code, 0, 0); 63 x86_syscall3(__NR_exit, code, 0, 0);
64} 64}
65 65
66void to_base10(char *lastdig, uint64_t n) 66void to_base10(char *lastdig, time_t n)
67{ 67{
68 while (n) { 68 while (n) {
69 *lastdig = (n % 10) + '0'; 69 *lastdig = (n % 10) + '0';
diff --git a/Documentation/video4linux/vivid.txt b/Documentation/video4linux/vivid.txt
index eeb11a28e4fc..e5a940e3d304 100644
--- a/Documentation/video4linux/vivid.txt
+++ b/Documentation/video4linux/vivid.txt
@@ -221,12 +221,11 @@ ccs_out_mode: specify the allowed video output crop/compose/scaling combination
221 key, not quality. 221 key, not quality.
222 222
223multiplanar: select whether each device instance supports multi-planar formats, 223multiplanar: select whether each device instance supports multi-planar formats,
224 and thus the V4L2 multi-planar API. By default the first device instance 224 and thus the V4L2 multi-planar API. By default device instances are
225 is single-planar, the second multi-planar, and it keeps alternating. 225 single-planar.
226 226
227 This module option can override that for each instance. Values are: 227 This module option can override that for each instance. Values are:
228 228
229 0: use alternating single and multi-planar devices.
230 1: this is a single-planar instance. 229 1: this is a single-planar instance.
231 2: this is a multi-planar instance. 230 2: this is a multi-planar instance.
232 231
@@ -975,9 +974,8 @@ is set, then the alpha component is only used for the color red and set to
9750 otherwise. 9740 otherwise.
976 975
977The driver has to be configured to support the multiplanar formats. By default 976The driver has to be configured to support the multiplanar formats. By default
978the first driver instance is single-planar, the second is multi-planar, and it 977the driver instances are single-planar. This can be changed by setting the
979keeps alternating. This can be changed by setting the multiplanar module option, 978multiplanar module option, see section 1 for more details on that option.
980see section 1 for more details on that option.
981 979
982If the driver instance is using the multiplanar formats/API, then the first 980If the driver instance is using the multiplanar formats/API, then the first
983single planar format (YUYV) and the multiplanar NV16M and NV61M formats the 981single planar format (YUYV) and the multiplanar NV16M and NV61M formats the
@@ -1021,7 +1019,7 @@ the output overlay for the video output, turn on video looping and capture
1021to see the blended framebuffer overlay that's being written to by the second 1019to see the blended framebuffer overlay that's being written to by the second
1022instance. This setup would require the following commands: 1020instance. This setup would require the following commands:
1023 1021
1024 $ sudo modprobe vivid n_devs=2 node_types=0x10101,0x1 multiplanar=1,1 1022 $ sudo modprobe vivid n_devs=2 node_types=0x10101,0x1
1025 $ v4l2-ctl -d1 --find-fb 1023 $ v4l2-ctl -d1 --find-fb
1026 /dev/fb1 is the framebuffer associated with base address 0x12800000 1024 /dev/fb1 is the framebuffer associated with base address 0x12800000
1027 $ sudo v4l2-ctl -d2 --set-fbuf fb=1 1025 $ sudo v4l2-ctl -d2 --set-fbuf fb=1
diff --git a/Documentation/vm/hugetlbpage.txt b/Documentation/vm/hugetlbpage.txt
index bdd4bb97fff7..b64e0af9cc56 100644
--- a/Documentation/vm/hugetlbpage.txt
+++ b/Documentation/vm/hugetlbpage.txt
@@ -274,7 +274,7 @@ This command mounts a (pseudo) filesystem of type hugetlbfs on the directory
274/mnt/huge. Any files created on /mnt/huge uses huge pages. The uid and gid 274/mnt/huge. Any files created on /mnt/huge uses huge pages. The uid and gid
275options sets the owner and group of the root of the file system. By default 275options sets the owner and group of the root of the file system. By default
276the uid and gid of the current process are taken. The mode option sets the 276the uid and gid of the current process are taken. The mode option sets the
277mode of root of file system to value & 0777. This value is given in octal. 277mode of root of file system to value & 01777. This value is given in octal.
278By default the value 0755 is picked. The size option sets the maximum value of 278By default the value 0755 is picked. The size option sets the maximum value of
279memory (huge pages) allowed for that filesystem (/mnt/huge). The size is 279memory (huge pages) allowed for that filesystem (/mnt/huge). The size is
280rounded down to HPAGE_SIZE. The option nr_inodes sets the maximum number of 280rounded down to HPAGE_SIZE. The option nr_inodes sets the maximum number of
diff --git a/MAINTAINERS b/MAINTAINERS
index 39e3f9155ebb..2a9cff1da54b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1543,6 +1543,7 @@ F: arch/arm/mach-pxa/include/mach/z2.h
1543 1543
1544ARM/ZYNQ ARCHITECTURE 1544ARM/ZYNQ ARCHITECTURE
1545M: Michal Simek <michal.simek@xilinx.com> 1545M: Michal Simek <michal.simek@xilinx.com>
1546R: Sören Brinkmann <soren.brinkmann@xilinx.com>
1546L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1547L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1547W: http://wiki.xilinx.com 1548W: http://wiki.xilinx.com
1548T: git git://git.xilinx.com/linux-xlnx.git 1549T: git git://git.xilinx.com/linux-xlnx.git
@@ -2071,8 +2072,9 @@ F: drivers/clocksource/bcm_kona_timer.c
2071 2072
2072BROADCOM BCM2835 ARM ARCHITECTURE 2073BROADCOM BCM2835 ARM ARCHITECTURE
2073M: Stephen Warren <swarren@wwwdotorg.org> 2074M: Stephen Warren <swarren@wwwdotorg.org>
2075M: Lee Jones <lee@kernel.org>
2074L: linux-rpi-kernel@lists.infradead.org (moderated for non-subscribers) 2076L: linux-rpi-kernel@lists.infradead.org (moderated for non-subscribers)
2075T: git git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-rpi.git 2077T: git git://git.kernel.org/pub/scm/linux/kernel/git/rpi/linux-rpi.git
2076S: Maintained 2078S: Maintained
2077N: bcm2835 2079N: bcm2835
2078 2080
@@ -4319,8 +4321,10 @@ F: Documentation/blockdev/cpqarray.txt
4319F: drivers/block/cpqarray.* 4321F: drivers/block/cpqarray.*
4320 4322
4321HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa) 4323HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa)
4322M: "Stephen M. Cameron" <scameron@beardog.cce.hp.com> 4324M: Don Brace <don.brace@pmcs.com>
4323L: iss_storagedev@hp.com 4325L: iss_storagedev@hp.com
4326L: storagedev@pmcs.com
4327L: linux-scsi@vger.kernel.org
4324S: Supported 4328S: Supported
4325F: Documentation/scsi/hpsa.txt 4329F: Documentation/scsi/hpsa.txt
4326F: drivers/scsi/hpsa*.[ch] 4330F: drivers/scsi/hpsa*.[ch]
@@ -4328,8 +4332,10 @@ F: include/linux/cciss*.h
4328F: include/uapi/linux/cciss*.h 4332F: include/uapi/linux/cciss*.h
4329 4333
4330HEWLETT-PACKARD SMART CISS RAID DRIVER (cciss) 4334HEWLETT-PACKARD SMART CISS RAID DRIVER (cciss)
4331M: Mike Miller <mike.miller@hp.com> 4335M: Don Brace <don.brace@pmcs.com>
4332L: iss_storagedev@hp.com 4336L: iss_storagedev@hp.com
4337L: storagedev@pmcs.com
4338L: linux-scsi@vger.kernel.org
4333S: Supported 4339S: Supported
4334F: Documentation/blockdev/cciss.txt 4340F: Documentation/blockdev/cciss.txt
4335F: drivers/block/cciss* 4341F: drivers/block/cciss*
@@ -4615,7 +4621,7 @@ S: Supported
4615F: drivers/crypto/nx/ 4621F: drivers/crypto/nx/
4616 4622
4617IBM Power 842 compression accelerator 4623IBM Power 842 compression accelerator
4618M: Nathan Fontenot <nfont@linux.vnet.ibm.com> 4624M: Dan Streetman <ddstreet@us.ibm.com>
4619S: Supported 4625S: Supported
4620F: drivers/crypto/nx/nx-842.c 4626F: drivers/crypto/nx/nx-842.c
4621F: include/linux/nx842.h 4627F: include/linux/nx842.h
@@ -7188,6 +7194,7 @@ F: drivers/crypto/picoxcell*
7188 7194
7189PIN CONTROL SUBSYSTEM 7195PIN CONTROL SUBSYSTEM
7190M: Linus Walleij <linus.walleij@linaro.org> 7196M: Linus Walleij <linus.walleij@linaro.org>
7197L: linux-gpio@vger.kernel.org
7191S: Maintained 7198S: Maintained
7192F: drivers/pinctrl/ 7199F: drivers/pinctrl/
7193F: include/linux/pinctrl/ 7200F: include/linux/pinctrl/
@@ -8492,7 +8499,6 @@ F: arch/arm/mach-s3c24xx/bast-irq.c
8492TI DAVINCI MACHINE SUPPORT 8499TI DAVINCI MACHINE SUPPORT
8493M: Sekhar Nori <nsekhar@ti.com> 8500M: Sekhar Nori <nsekhar@ti.com>
8494M: Kevin Hilman <khilman@deeprootsystems.com> 8501M: Kevin Hilman <khilman@deeprootsystems.com>
8495L: davinci-linux-open-source@linux.davincidsp.com (moderated for non-subscribers)
8496T: git git://gitorious.org/linux-davinci/linux-davinci.git 8502T: git git://gitorious.org/linux-davinci/linux-davinci.git
8497Q: http://patchwork.kernel.org/project/linux-davinci/list/ 8503Q: http://patchwork.kernel.org/project/linux-davinci/list/
8498S: Supported 8504S: Supported
@@ -8502,7 +8508,6 @@ F: drivers/i2c/busses/i2c-davinci.c
8502TI DAVINCI SERIES MEDIA DRIVER 8508TI DAVINCI SERIES MEDIA DRIVER
8503M: Lad, Prabhakar <prabhakar.csengg@gmail.com> 8509M: Lad, Prabhakar <prabhakar.csengg@gmail.com>
8504L: linux-media@vger.kernel.org 8510L: linux-media@vger.kernel.org
8505L: davinci-linux-open-source@linux.davincidsp.com (moderated for non-subscribers)
8506W: http://linuxtv.org/ 8511W: http://linuxtv.org/
8507Q: http://patchwork.linuxtv.org/project/linux-media/list/ 8512Q: http://patchwork.linuxtv.org/project/linux-media/list/
8508T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git 8513T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
@@ -9619,7 +9624,6 @@ F: drivers/staging/unisys/
9619 9624
9620UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER 9625UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
9621M: Vinayak Holikatti <vinholikatti@gmail.com> 9626M: Vinayak Holikatti <vinholikatti@gmail.com>
9622M: Santosh Y <santoshsy@gmail.com>
9623L: linux-scsi@vger.kernel.org 9627L: linux-scsi@vger.kernel.org
9624S: Supported 9628S: Supported
9625F: Documentation/scsi/ufs.txt 9629F: Documentation/scsi/ufs.txt
@@ -9713,11 +9717,6 @@ S: Maintained
9713F: Documentation/hid/hiddev.txt 9717F: Documentation/hid/hiddev.txt
9714F: drivers/hid/usbhid/ 9718F: drivers/hid/usbhid/
9715 9719
9716USB/IP DRIVERS
9717L: linux-usb@vger.kernel.org
9718S: Orphan
9719F: drivers/staging/usbip/
9720
9721USB ISP116X DRIVER 9720USB ISP116X DRIVER
9722M: Olav Kongas <ok@artecdesign.ee> 9721M: Olav Kongas <ok@artecdesign.ee>
9723L: linux-usb@vger.kernel.org 9722L: linux-usb@vger.kernel.org
diff --git a/Makefile b/Makefile
index 52c129725270..bc7eb6ada966 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 18 2PATCHLEVEL = 18
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc4
5NAME = Shuffling Zombie Juror 5NAME = Diseased Newt
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 03dc4c1a8736..d8f6a2ec3d4e 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1187,7 +1187,7 @@ config DEBUG_UART_VIRT
1187 default 0xf1c28000 if DEBUG_SUNXI_UART0 1187 default 0xf1c28000 if DEBUG_SUNXI_UART0
1188 default 0xf1c28400 if DEBUG_SUNXI_UART1 1188 default 0xf1c28400 if DEBUG_SUNXI_UART1
1189 default 0xf1f02800 if DEBUG_SUNXI_R_UART 1189 default 0xf1f02800 if DEBUG_SUNXI_R_UART
1190 default 0xf2100000 if DEBUG_PXA_UART1 1190 default 0xf6200000 if DEBUG_PXA_UART1
1191 default 0xf4090000 if ARCH_LPC32XX 1191 default 0xf4090000 if ARCH_LPC32XX
1192 default 0xf4200000 if ARCH_GEMINI 1192 default 0xf4200000 if ARCH_GEMINI
1193 default 0xf7000000 if DEBUG_S3C24XX_UART && (DEBUG_S3C_UART0 || \ 1193 default 0xf7000000 if DEBUG_S3C24XX_UART && (DEBUG_S3C_UART0 || \
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 739fcf29c643..bc82a12d4c2c 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -668,6 +668,8 @@
668 bank-width = <2>; 668 bank-width = <2>;
669 pinctrl-names = "default"; 669 pinctrl-names = "default";
670 pinctrl-0 = <&ethernet_pins>; 670 pinctrl-0 = <&ethernet_pins>;
671 power-gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>; /* gpio86 */
672 reset-gpios = <&gpio6 4 GPIO_ACTIVE_HIGH>; /* gpio164 */
671 gpmc,device-width = <2>; 673 gpmc,device-width = <2>;
672 gpmc,sync-clk-ps = <0>; 674 gpmc,sync-clk-ps = <0>;
673 gpmc,cs-on-ns = <0>; 675 gpmc,cs-on-ns = <0>;
diff --git a/arch/arm/boot/dts/vf610-cosmic.dts b/arch/arm/boot/dts/vf610-cosmic.dts
index 3fd1b74e1216..de1b453c2932 100644
--- a/arch/arm/boot/dts/vf610-cosmic.dts
+++ b/arch/arm/boot/dts/vf610-cosmic.dts
@@ -33,6 +33,13 @@
33 33
34}; 34};
35 35
36&esdhc1 {
37 pinctrl-names = "default";
38 pinctrl-0 = <&pinctrl_esdhc1>;
39 bus-width = <4>;
40 status = "okay";
41};
42
36&fec1 { 43&fec1 {
37 phy-mode = "rmii"; 44 phy-mode = "rmii";
38 pinctrl-names = "default"; 45 pinctrl-names = "default";
@@ -42,6 +49,18 @@
42 49
43&iomuxc { 50&iomuxc {
44 vf610-cosmic { 51 vf610-cosmic {
52 pinctrl_esdhc1: esdhc1grp {
53 fsl,pins = <
54 VF610_PAD_PTA24__ESDHC1_CLK 0x31ef
55 VF610_PAD_PTA25__ESDHC1_CMD 0x31ef
56 VF610_PAD_PTA26__ESDHC1_DAT0 0x31ef
57 VF610_PAD_PTA27__ESDHC1_DAT1 0x31ef
58 VF610_PAD_PTA28__ESDHC1_DATA2 0x31ef
59 VF610_PAD_PTA29__ESDHC1_DAT3 0x31ef
60 VF610_PAD_PTB28__GPIO_98 0x219d
61 >;
62 };
63
45 pinctrl_fec1: fec1grp { 64 pinctrl_fec1: fec1grp {
46 fsl,pins = < 65 fsl,pins = <
47 VF610_PAD_PTC9__ENET_RMII1_MDC 0x30d2 66 VF610_PAD_PTC9__ENET_RMII1_MDC 0x30d2
diff --git a/arch/arm/boot/dts/zynq-parallella.dts b/arch/arm/boot/dts/zynq-parallella.dts
index e1f51ca127fe..0429bbd89fba 100644
--- a/arch/arm/boot/dts/zynq-parallella.dts
+++ b/arch/arm/boot/dts/zynq-parallella.dts
@@ -34,6 +34,10 @@
34 }; 34 };
35}; 35};
36 36
37&clkc {
38 fclk-enable = <0xf>;
39};
40
37&gem0 { 41&gem0 {
38 status = "okay"; 42 status = "okay";
39 phy-mode = "rgmii-id"; 43 phy-mode = "rgmii-id";
diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c
index d86771abbf57..72041f002b7e 100644
--- a/arch/arm/common/edma.c
+++ b/arch/arm/common/edma.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/edma.h> 28#include <linux/edma.h>
29#include <linux/dma-mapping.h>
29#include <linux/of_address.h> 30#include <linux/of_address.h>
30#include <linux/of_device.h> 31#include <linux/of_device.h>
31#include <linux/of_dma.h> 32#include <linux/of_dma.h>
@@ -1623,6 +1624,11 @@ static int edma_probe(struct platform_device *pdev)
1623 struct device_node *node = pdev->dev.of_node; 1624 struct device_node *node = pdev->dev.of_node;
1624 struct device *dev = &pdev->dev; 1625 struct device *dev = &pdev->dev;
1625 int ret; 1626 int ret;
1627 struct platform_device_info edma_dev_info = {
1628 .name = "edma-dma-engine",
1629 .dma_mask = DMA_BIT_MASK(32),
1630 .parent = &pdev->dev,
1631 };
1626 1632
1627 if (node) { 1633 if (node) {
1628 /* Check if this is a second instance registered */ 1634 /* Check if this is a second instance registered */
@@ -1793,6 +1799,9 @@ static int edma_probe(struct platform_device *pdev)
1793 edma_write_array(j, EDMA_QRAE, i, 0x0); 1799 edma_write_array(j, EDMA_QRAE, i, 0x0);
1794 } 1800 }
1795 arch_num_cc++; 1801 arch_num_cc++;
1802
1803 edma_dev_info.id = j;
1804 platform_device_register_full(&edma_dev_info);
1796 } 1805 }
1797 1806
1798 return 0; 1807 return 0;
diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
index e688741c89aa..e6b0007355f8 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -97,6 +97,7 @@ CONFIG_SERIAL_IMX_CONSOLE=y
97# CONFIG_HW_RANDOM is not set 97# CONFIG_HW_RANDOM is not set
98CONFIG_I2C_CHARDEV=y 98CONFIG_I2C_CHARDEV=y
99CONFIG_I2C_IMX=y 99CONFIG_I2C_IMX=y
100CONFIG_SPI=y
100CONFIG_SPI_IMX=y 101CONFIG_SPI_IMX=y
101CONFIG_SPI_SPIDEV=y 102CONFIG_SPI_SPIDEV=y
102CONFIG_GPIO_SYSFS=y 103CONFIG_GPIO_SYSFS=y
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 8fca6e276b69..6790f1b3f3a1 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -158,6 +158,7 @@ CONFIG_I2C_CHARDEV=y
158CONFIG_I2C_ALGOPCF=m 158CONFIG_I2C_ALGOPCF=m
159CONFIG_I2C_ALGOPCA=m 159CONFIG_I2C_ALGOPCA=m
160CONFIG_I2C_IMX=y 160CONFIG_I2C_IMX=y
161CONFIG_SPI=y
161CONFIG_SPI_IMX=y 162CONFIG_SPI_IMX=y
162CONFIG_GPIO_SYSFS=y 163CONFIG_GPIO_SYSFS=y
163CONFIG_GPIO_MC9S08DZ60=y 164CONFIG_GPIO_MC9S08DZ60=y
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index f1dc7fc668f3..3487046d8a78 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -235,6 +235,7 @@ CONFIG_SPI_TEGRA20_SLINK=y
235CONFIG_SPI_XILINX=y 235CONFIG_SPI_XILINX=y
236CONFIG_PINCTRL_AS3722=y 236CONFIG_PINCTRL_AS3722=y
237CONFIG_PINCTRL_PALMAS=y 237CONFIG_PINCTRL_PALMAS=y
238CONFIG_PINCTRL_APQ8084=y
238CONFIG_GPIO_SYSFS=y 239CONFIG_GPIO_SYSFS=y
239CONFIG_GPIO_GENERIC_PLATFORM=y 240CONFIG_GPIO_GENERIC_PLATFORM=y
240CONFIG_GPIO_DWAPB=y 241CONFIG_GPIO_DWAPB=y
@@ -411,6 +412,7 @@ CONFIG_NVEC_POWER=y
411CONFIG_NVEC_PAZ00=y 412CONFIG_NVEC_PAZ00=y
412CONFIG_QCOM_GSBI=y 413CONFIG_QCOM_GSBI=y
413CONFIG_COMMON_CLK_QCOM=y 414CONFIG_COMMON_CLK_QCOM=y
415CONFIG_APQ_MMCC_8084=y
414CONFIG_MSM_GCC_8660=y 416CONFIG_MSM_GCC_8660=y
415CONFIG_MSM_MMCC_8960=y 417CONFIG_MSM_MMCC_8960=y
416CONFIG_MSM_MMCC_8974=y 418CONFIG_MSM_MMCC_8974=y
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 16e719c268dd..b3f86670d2eb 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -86,7 +86,6 @@ CONFIG_IP_PNP_DHCP=y
86CONFIG_IP_PNP_BOOTP=y 86CONFIG_IP_PNP_BOOTP=y
87CONFIG_IP_PNP_RARP=y 87CONFIG_IP_PNP_RARP=y
88# CONFIG_INET_LRO is not set 88# CONFIG_INET_LRO is not set
89CONFIG_IPV6=y
90CONFIG_NETFILTER=y 89CONFIG_NETFILTER=y
91CONFIG_CAN=m 90CONFIG_CAN=m
92CONFIG_CAN_C_CAN=m 91CONFIG_CAN_C_CAN=m
@@ -112,6 +111,7 @@ CONFIG_MTD_OOPS=y
112CONFIG_MTD_CFI=y 111CONFIG_MTD_CFI=y
113CONFIG_MTD_CFI_INTELEXT=y 112CONFIG_MTD_CFI_INTELEXT=y
114CONFIG_MTD_NAND=y 113CONFIG_MTD_NAND=y
114CONFIG_MTD_NAND_ECC_BCH=y
115CONFIG_MTD_NAND_OMAP2=y 115CONFIG_MTD_NAND_OMAP2=y
116CONFIG_MTD_ONENAND=y 116CONFIG_MTD_ONENAND=y
117CONFIG_MTD_ONENAND_VERIFY_WRITE=y 117CONFIG_MTD_ONENAND_VERIFY_WRITE=y
@@ -317,7 +317,7 @@ CONFIG_EXT4_FS=y
317CONFIG_FANOTIFY=y 317CONFIG_FANOTIFY=y
318CONFIG_QUOTA=y 318CONFIG_QUOTA=y
319CONFIG_QFMT_V2=y 319CONFIG_QFMT_V2=y
320CONFIG_AUTOFS4_FS=y 320CONFIG_AUTOFS4_FS=m
321CONFIG_MSDOS_FS=y 321CONFIG_MSDOS_FS=y
322CONFIG_VFAT_FS=y 322CONFIG_VFAT_FS=y
323CONFIG_TMPFS=y 323CONFIG_TMPFS=y
diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
index d7a5855a5db8..a2956c3112f1 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -1,5 +1,6 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
2CONFIG_FHANDLE=y
3CONFIG_HIGH_RES_TIMERS=y
3CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
@@ -11,23 +12,17 @@ CONFIG_PROFILING=y
11CONFIG_OPROFILE=y 12CONFIG_OPROFILE=y
12CONFIG_MODULES=y 13CONFIG_MODULES=y
13CONFIG_MODULE_UNLOAD=y 14CONFIG_MODULE_UNLOAD=y
14CONFIG_HOTPLUG=y
15# CONFIG_LBDAF is not set 15# CONFIG_LBDAF is not set
16# CONFIG_BLK_DEV_BSG is not set 16# CONFIG_BLK_DEV_BSG is not set
17# CONFIG_IOSCHED_DEADLINE is not set 17# CONFIG_IOSCHED_DEADLINE is not set
18# CONFIG_IOSCHED_CFQ is not set 18# CONFIG_IOSCHED_CFQ is not set
19CONFIG_ARCH_SOCFPGA=y 19CONFIG_ARCH_SOCFPGA=y
20CONFIG_MACH_SOCFPGA_CYCLONE5=y
21CONFIG_ARM_THUMBEE=y 20CONFIG_ARM_THUMBEE=y
22# CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set
23# CONFIG_CACHE_L2X0 is not set
24CONFIG_HIGH_RES_TIMERS=y
25CONFIG_SMP=y 21CONFIG_SMP=y
26CONFIG_NR_CPUS=2 22CONFIG_NR_CPUS=2
27CONFIG_AEABI=y 23CONFIG_AEABI=y
28CONFIG_ZBOOT_ROM_TEXT=0x0 24CONFIG_ZBOOT_ROM_TEXT=0x0
29CONFIG_ZBOOT_ROM_BSS=0x0 25CONFIG_ZBOOT_ROM_BSS=0x0
30CONFIG_CMDLINE=""
31CONFIG_VFP=y 26CONFIG_VFP=y
32CONFIG_NEON=y 27CONFIG_NEON=y
33CONFIG_NET=y 28CONFIG_NET=y
@@ -41,38 +36,30 @@ CONFIG_IP_PNP=y
41CONFIG_IP_PNP_DHCP=y 36CONFIG_IP_PNP_DHCP=y
42CONFIG_IP_PNP_BOOTP=y 37CONFIG_IP_PNP_BOOTP=y
43CONFIG_IP_PNP_RARP=y 38CONFIG_IP_PNP_RARP=y
39CONFIG_IPV6=y
40CONFIG_NETWORK_PHY_TIMESTAMPING=y
41CONFIG_VLAN_8021Q=y
42CONFIG_VLAN_8021Q_GVRP=y
44CONFIG_CAN=y 43CONFIG_CAN=y
45CONFIG_CAN_RAW=y
46CONFIG_CAN_BCM=y
47CONFIG_CAN_GW=y
48CONFIG_CAN_DEV=y
49CONFIG_CAN_CALC_BITTIMING=y
50CONFIG_CAN_C_CAN=y 44CONFIG_CAN_C_CAN=y
51CONFIG_CAN_C_CAN_PLATFORM=y 45CONFIG_CAN_C_CAN_PLATFORM=y
52CONFIG_CAN_DEBUG_DEVICES=y 46CONFIG_CAN_DEBUG_DEVICES=y
53CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
54CONFIG_DEVTMPFS=y 48CONFIG_DEVTMPFS=y
55CONFIG_PROC_DEVICETREE=y 49CONFIG_DEVTMPFS_MOUNT=y
56CONFIG_BLK_DEV_RAM=y 50CONFIG_BLK_DEV_RAM=y
57CONFIG_BLK_DEV_RAM_COUNT=2 51CONFIG_BLK_DEV_RAM_COUNT=2
58CONFIG_BLK_DEV_RAM_SIZE=8192 52CONFIG_BLK_DEV_RAM_SIZE=8192
53CONFIG_SRAM=y
59CONFIG_SCSI=y 54CONFIG_SCSI=y
60# CONFIG_SCSI_PROC_FS is not set 55# CONFIG_SCSI_PROC_FS is not set
61CONFIG_BLK_DEV_SD=y 56CONFIG_BLK_DEV_SD=y
62# CONFIG_SCSI_LOWLEVEL is not set 57# CONFIG_SCSI_LOWLEVEL is not set
63CONFIG_NETDEVICES=y 58CONFIG_NETDEVICES=y
64CONFIG_STMMAC_ETH=y 59CONFIG_STMMAC_ETH=y
60CONFIG_DWMAC_SOCFPGA=y
65CONFIG_MICREL_PHY=y 61CONFIG_MICREL_PHY=y
66# CONFIG_STMMAC_PHY_ID_ZERO_WORKAROUND is not set
67CONFIG_INPUT_EVDEV=y 62CONFIG_INPUT_EVDEV=y
68CONFIG_DWMAC_SOCFPGA=y
69CONFIG_PPS=y
70CONFIG_NETWORK_PHY_TIMESTAMPING=y
71CONFIG_PTP_1588_CLOCK=y
72CONFIG_VLAN_8021Q=y
73CONFIG_VLAN_8021Q_GVRP=y
74CONFIG_GARP=y
75CONFIG_IPV6=y
76# CONFIG_SERIO_SERPORT is not set 63# CONFIG_SERIO_SERPORT is not set
77CONFIG_SERIO_AMBAKMI=y 64CONFIG_SERIO_AMBAKMI=y
78CONFIG_LEGACY_PTY_COUNT=16 65CONFIG_LEGACY_PTY_COUNT=16
@@ -81,45 +68,43 @@ CONFIG_SERIAL_8250_CONSOLE=y
81CONFIG_SERIAL_8250_NR_UARTS=2 68CONFIG_SERIAL_8250_NR_UARTS=2
82CONFIG_SERIAL_8250_RUNTIME_UARTS=2 69CONFIG_SERIAL_8250_RUNTIME_UARTS=2
83CONFIG_SERIAL_8250_DW=y 70CONFIG_SERIAL_8250_DW=y
71CONFIG_I2C=y
72CONFIG_I2C_CHARDEV=y
73CONFIG_I2C_DESIGNWARE_PLATFORM=y
84CONFIG_GPIOLIB=y 74CONFIG_GPIOLIB=y
85CONFIG_GPIO_SYSFS=y 75CONFIG_GPIO_SYSFS=y
86CONFIG_GPIO_DWAPB=y 76CONFIG_GPIO_DWAPB=y
87# CONFIG_RTC_HCTOSYS is not set 77CONFIG_PMBUS=y
78CONFIG_SENSORS_LTC2978=y
79CONFIG_SENSORS_LTC2978_REGULATOR=y
88CONFIG_WATCHDOG=y 80CONFIG_WATCHDOG=y
89CONFIG_DW_WATCHDOG=y 81CONFIG_DW_WATCHDOG=y
82CONFIG_REGULATOR=y
83CONFIG_REGULATOR_FIXED_VOLTAGE=y
84CONFIG_USB=y
85CONFIG_USB_DWC2=y
86CONFIG_USB_DWC2_HOST=y
87CONFIG_MMC=y
88CONFIG_MMC_DW=y
90CONFIG_EXT2_FS=y 89CONFIG_EXT2_FS=y
91CONFIG_EXT2_FS_XATTR=y 90CONFIG_EXT2_FS_XATTR=y
92CONFIG_EXT2_FS_POSIX_ACL=y 91CONFIG_EXT2_FS_POSIX_ACL=y
93CONFIG_EXT3_FS=y 92CONFIG_EXT3_FS=y
94CONFIG_NFS_FS=y 93CONFIG_EXT4_FS=y
95CONFIG_ROOT_NFS=y
96# CONFIG_DNOTIFY is not set
97# CONFIG_INOTIFY_USER is not set
98CONFIG_FHANDLE=y
99CONFIG_VFAT_FS=y 94CONFIG_VFAT_FS=y
100CONFIG_NTFS_FS=y 95CONFIG_NTFS_FS=y
101CONFIG_NTFS_RW=y 96CONFIG_NTFS_RW=y
102CONFIG_TMPFS=y 97CONFIG_TMPFS=y
103CONFIG_JFFS2_FS=y 98CONFIG_CONFIGFS_FS=y
99CONFIG_NFS_FS=y
100CONFIG_ROOT_NFS=y
104CONFIG_NLS_CODEPAGE_437=y 101CONFIG_NLS_CODEPAGE_437=y
105CONFIG_NLS_ISO8859_1=y 102CONFIG_NLS_ISO8859_1=y
103CONFIG_PRINTK_TIME=y
104CONFIG_DEBUG_INFO=y
106CONFIG_MAGIC_SYSRQ=y 105CONFIG_MAGIC_SYSRQ=y
107CONFIG_DETECT_HUNG_TASK=y 106CONFIG_DETECT_HUNG_TASK=y
108# CONFIG_SCHED_DEBUG is not set 107# CONFIG_SCHED_DEBUG is not set
109CONFIG_DEBUG_INFO=y
110CONFIG_ENABLE_DEFAULT_TRACERS=y 108CONFIG_ENABLE_DEFAULT_TRACERS=y
111CONFIG_DEBUG_USER=y 109CONFIG_DEBUG_USER=y
112CONFIG_XZ_DEC=y 110CONFIG_XZ_DEC=y
113CONFIG_I2C=y
114CONFIG_I2C_DESIGNWARE_CORE=y
115CONFIG_I2C_DESIGNWARE_PLATFORM=y
116CONFIG_I2C_CHARDEV=y
117CONFIG_MMC=y
118CONFIG_MMC_DW=y
119CONFIG_PM=y
120CONFIG_SUSPEND=y
121CONFIG_MMC_UNSAFE_RESUME=y
122CONFIG_USB=y
123CONFIG_USB_DWC2=y
124CONFIG_USB_DWC2_HOST=y
125CONFIG_USB_DWC2_PLATFORM=y
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index 3aaa75cae90c..705bb7620673 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -412,6 +412,7 @@
412#define __NR_seccomp (__NR_SYSCALL_BASE+383) 412#define __NR_seccomp (__NR_SYSCALL_BASE+383)
413#define __NR_getrandom (__NR_SYSCALL_BASE+384) 413#define __NR_getrandom (__NR_SYSCALL_BASE+384)
414#define __NR_memfd_create (__NR_SYSCALL_BASE+385) 414#define __NR_memfd_create (__NR_SYSCALL_BASE+385)
415#define __NR_bpf (__NR_SYSCALL_BASE+386)
415 416
416/* 417/*
417 * The following SWIs are ARM private. 418 * The following SWIs are ARM private.
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 713e807621d2..2d2d6087b9b1 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -10,6 +10,7 @@
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13#include <linux/compiler.h>
13#include <linux/sched.h> 14#include <linux/sched.h>
14#include <linux/mm.h> 15#include <linux/mm.h>
15#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -39,10 +40,19 @@
39 * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c 40 * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c
40 * (http://gcc.gnu.org/PR8896) and incorrect structure 41 * (http://gcc.gnu.org/PR8896) and incorrect structure
41 * initialisation in fs/jffs2/erase.c 42 * initialisation in fs/jffs2/erase.c
43 * GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854
44 * miscompiles find_get_entry(), and can result in EXT3 and EXT4
45 * filesystem corruption (possibly other FS too).
42 */ 46 */
47#ifdef __GNUC__
43#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3) 48#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
44#error Your compiler is too buggy; it is known to miscompile kernels. 49#error Your compiler is too buggy; it is known to miscompile kernels.
45#error Known good compilers: 3.3 50#error Known good compilers: 3.3, 4.x
51#endif
52#if GCC_VERSION >= 40800 && GCC_VERSION < 40803
53#error Your compiler is too buggy; it is known to miscompile kernels
54#error and result in filesystem corruption and oopses.
55#endif
46#endif 56#endif
47 57
48int main(void) 58int main(void)
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 9f899d8fdcca..e51833f8cc38 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -395,6 +395,7 @@
395 CALL(sys_seccomp) 395 CALL(sys_seccomp)
396 CALL(sys_getrandom) 396 CALL(sys_getrandom)
397/* 385 */ CALL(sys_memfd_create) 397/* 385 */ CALL(sys_memfd_create)
398 CALL(sys_bpf)
398#ifndef syscalls_counted 399#ifndef syscalls_counted
399.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 400.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
400#define syscalls_counted 401#define syscalls_counted
diff --git a/arch/arm/mach-imx/clk-vf610.c b/arch/arm/mach-imx/clk-vf610.c
index a17818475050..409637254594 100644
--- a/arch/arm/mach-imx/clk-vf610.c
+++ b/arch/arm/mach-imx/clk-vf610.c
@@ -58,8 +58,14 @@
58#define PFD_PLL1_BASE (anatop_base + 0x2b0) 58#define PFD_PLL1_BASE (anatop_base + 0x2b0)
59#define PFD_PLL2_BASE (anatop_base + 0x100) 59#define PFD_PLL2_BASE (anatop_base + 0x100)
60#define PFD_PLL3_BASE (anatop_base + 0xf0) 60#define PFD_PLL3_BASE (anatop_base + 0xf0)
61#define PLL1_CTRL (anatop_base + 0x270)
62#define PLL2_CTRL (anatop_base + 0x30)
61#define PLL3_CTRL (anatop_base + 0x10) 63#define PLL3_CTRL (anatop_base + 0x10)
64#define PLL4_CTRL (anatop_base + 0x70)
65#define PLL5_CTRL (anatop_base + 0xe0)
66#define PLL6_CTRL (anatop_base + 0xa0)
62#define PLL7_CTRL (anatop_base + 0x20) 67#define PLL7_CTRL (anatop_base + 0x20)
68#define ANA_MISC1 (anatop_base + 0x160)
63 69
64static void __iomem *anatop_base; 70static void __iomem *anatop_base;
65static void __iomem *ccm_base; 71static void __iomem *ccm_base;
@@ -67,25 +73,34 @@ static void __iomem *ccm_base;
67/* sources for multiplexer clocks, this is used multiple times */ 73/* sources for multiplexer clocks, this is used multiple times */
68static const char *fast_sels[] = { "firc", "fxosc", }; 74static const char *fast_sels[] = { "firc", "fxosc", };
69static const char *slow_sels[] = { "sirc_32k", "sxosc", }; 75static const char *slow_sels[] = { "sirc_32k", "sxosc", };
70static const char *pll1_sels[] = { "pll1_main", "pll1_pfd1", "pll1_pfd2", "pll1_pfd3", "pll1_pfd4", }; 76static const char *pll1_sels[] = { "pll1_sys", "pll1_pfd1", "pll1_pfd2", "pll1_pfd3", "pll1_pfd4", };
71static const char *pll2_sels[] = { "pll2_main", "pll2_pfd1", "pll2_pfd2", "pll2_pfd3", "pll2_pfd4", }; 77static const char *pll2_sels[] = { "pll2_bus", "pll2_pfd1", "pll2_pfd2", "pll2_pfd3", "pll2_pfd4", };
72static const char *sys_sels[] = { "fast_clk_sel", "slow_clk_sel", "pll2_pfd_sel", "pll2_main", "pll1_pfd_sel", "pll3_main", }; 78static const char *pll_bypass_src_sels[] = { "fast_clk_sel", "lvds1_in", };
79static const char *pll1_bypass_sels[] = { "pll1", "pll1_bypass_src", };
80static const char *pll2_bypass_sels[] = { "pll2", "pll2_bypass_src", };
81static const char *pll3_bypass_sels[] = { "pll3", "pll3_bypass_src", };
82static const char *pll4_bypass_sels[] = { "pll4", "pll4_bypass_src", };
83static const char *pll5_bypass_sels[] = { "pll5", "pll5_bypass_src", };
84static const char *pll6_bypass_sels[] = { "pll6", "pll6_bypass_src", };
85static const char *pll7_bypass_sels[] = { "pll7", "pll7_bypass_src", };
86static const char *sys_sels[] = { "fast_clk_sel", "slow_clk_sel", "pll2_pfd_sel", "pll2_bus", "pll1_pfd_sel", "pll3_usb_otg", };
73static const char *ddr_sels[] = { "pll2_pfd2", "sys_sel", }; 87static const char *ddr_sels[] = { "pll2_pfd2", "sys_sel", };
74static const char *rmii_sels[] = { "enet_ext", "audio_ext", "enet_50m", "enet_25m", }; 88static const char *rmii_sels[] = { "enet_ext", "audio_ext", "enet_50m", "enet_25m", };
75static const char *enet_ts_sels[] = { "enet_ext", "fxosc", "audio_ext", "usb", "enet_ts", "enet_25m", "enet_50m", }; 89static const char *enet_ts_sels[] = { "enet_ext", "fxosc", "audio_ext", "usb", "enet_ts", "enet_25m", "enet_50m", };
76static const char *esai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", }; 90static const char *esai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_audio_div", };
77static const char *sai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", }; 91static const char *sai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_audio_div", };
78static const char *nfc_sels[] = { "platform_bus", "pll1_pfd1", "pll3_pfd1", "pll3_pfd3", }; 92static const char *nfc_sels[] = { "platform_bus", "pll1_pfd1", "pll3_pfd1", "pll3_pfd3", };
79static const char *qspi_sels[] = { "pll3_main", "pll3_pfd4", "pll2_pfd4", "pll1_pfd4", }; 93static const char *qspi_sels[] = { "pll3_usb_otg", "pll3_pfd4", "pll2_pfd4", "pll1_pfd4", };
80static const char *esdhc_sels[] = { "pll3_main", "pll3_pfd3", "pll1_pfd3", "platform_bus", }; 94static const char *esdhc_sels[] = { "pll3_usb_otg", "pll3_pfd3", "pll1_pfd3", "platform_bus", };
81static const char *dcu_sels[] = { "pll1_pfd2", "pll3_main", }; 95static const char *dcu_sels[] = { "pll1_pfd2", "pll3_usb_otg", };
82static const char *gpu_sels[] = { "pll2_pfd2", "pll3_pfd2", }; 96static const char *gpu_sels[] = { "pll2_pfd2", "pll3_pfd2", };
83static const char *vadc_sels[] = { "pll6_main_div", "pll3_main_div", "pll3_main", }; 97static const char *vadc_sels[] = { "pll6_video_div", "pll3_usb_otg_div", "pll3_usb_otg", };
84/* FTM counter clock source, not module clock */ 98/* FTM counter clock source, not module clock */
85static const char *ftm_ext_sels[] = {"sirc_128k", "sxosc", "fxosc_half", "audio_ext", }; 99static const char *ftm_ext_sels[] = {"sirc_128k", "sxosc", "fxosc_half", "audio_ext", };
86static const char *ftm_fix_sels[] = { "sxosc", "ipg_bus", }; 100static const char *ftm_fix_sels[] = { "sxosc", "ipg_bus", };
87 101
88static struct clk_div_table pll4_main_div_table[] = { 102
103static struct clk_div_table pll4_audio_div_table[] = {
89 { .val = 0, .div = 1 }, 104 { .val = 0, .div = 1 },
90 { .val = 1, .div = 2 }, 105 { .val = 1, .div = 2 },
91 { .val = 2, .div = 6 }, 106 { .val = 2, .div = 6 },
@@ -120,6 +135,9 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
120 clk[VF610_CLK_AUDIO_EXT] = imx_obtain_fixed_clock("audio_ext", 0); 135 clk[VF610_CLK_AUDIO_EXT] = imx_obtain_fixed_clock("audio_ext", 0);
121 clk[VF610_CLK_ENET_EXT] = imx_obtain_fixed_clock("enet_ext", 0); 136 clk[VF610_CLK_ENET_EXT] = imx_obtain_fixed_clock("enet_ext", 0);
122 137
138 /* Clock source from external clock via LVDs PAD */
139 clk[VF610_CLK_ANACLK1] = imx_obtain_fixed_clock("anaclk1", 0);
140
123 clk[VF610_CLK_FXOSC_HALF] = imx_clk_fixed_factor("fxosc_half", "fxosc", 1, 2); 141 clk[VF610_CLK_FXOSC_HALF] = imx_clk_fixed_factor("fxosc_half", "fxosc", 1, 2);
124 142
125 np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop"); 143 np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop");
@@ -133,31 +151,63 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
133 clk[VF610_CLK_SLOW_CLK_SEL] = imx_clk_mux("slow_clk_sel", CCM_CCSR, 4, 1, slow_sels, ARRAY_SIZE(slow_sels)); 151 clk[VF610_CLK_SLOW_CLK_SEL] = imx_clk_mux("slow_clk_sel", CCM_CCSR, 4, 1, slow_sels, ARRAY_SIZE(slow_sels));
134 clk[VF610_CLK_FASK_CLK_SEL] = imx_clk_mux("fast_clk_sel", CCM_CCSR, 5, 1, fast_sels, ARRAY_SIZE(fast_sels)); 152 clk[VF610_CLK_FASK_CLK_SEL] = imx_clk_mux("fast_clk_sel", CCM_CCSR, 5, 1, fast_sels, ARRAY_SIZE(fast_sels));
135 153
136 clk[VF610_CLK_PLL1_MAIN] = imx_clk_fixed_factor("pll1_main", "fast_clk_sel", 22, 1); 154 clk[VF610_CLK_PLL1_BYPASS_SRC] = imx_clk_mux("pll1_bypass_src", PLL1_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
137 clk[VF610_CLK_PLL1_PFD1] = imx_clk_pfd("pll1_pfd1", "pll1_main", PFD_PLL1_BASE, 0); 155 clk[VF610_CLK_PLL2_BYPASS_SRC] = imx_clk_mux("pll2_bypass_src", PLL2_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
138 clk[VF610_CLK_PLL1_PFD2] = imx_clk_pfd("pll1_pfd2", "pll1_main", PFD_PLL1_BASE, 1); 156 clk[VF610_CLK_PLL3_BYPASS_SRC] = imx_clk_mux("pll3_bypass_src", PLL3_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
139 clk[VF610_CLK_PLL1_PFD3] = imx_clk_pfd("pll1_pfd3", "pll1_main", PFD_PLL1_BASE, 2); 157 clk[VF610_CLK_PLL4_BYPASS_SRC] = imx_clk_mux("pll4_bypass_src", PLL4_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
140 clk[VF610_CLK_PLL1_PFD4] = imx_clk_pfd("pll1_pfd4", "pll1_main", PFD_PLL1_BASE, 3); 158 clk[VF610_CLK_PLL5_BYPASS_SRC] = imx_clk_mux("pll5_bypass_src", PLL5_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
141 159 clk[VF610_CLK_PLL6_BYPASS_SRC] = imx_clk_mux("pll6_bypass_src", PLL6_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
142 clk[VF610_CLK_PLL2_MAIN] = imx_clk_fixed_factor("pll2_main", "fast_clk_sel", 22, 1); 160 clk[VF610_CLK_PLL7_BYPASS_SRC] = imx_clk_mux("pll7_bypass_src", PLL7_CTRL, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
143 clk[VF610_CLK_PLL2_PFD1] = imx_clk_pfd("pll2_pfd1", "pll2_main", PFD_PLL2_BASE, 0); 161
144 clk[VF610_CLK_PLL2_PFD2] = imx_clk_pfd("pll2_pfd2", "pll2_main", PFD_PLL2_BASE, 1); 162 clk[VF610_CLK_PLL1] = imx_clk_pllv3(IMX_PLLV3_GENERIC, "pll1", "pll1_bypass_src", PLL1_CTRL, 0x1);
145 clk[VF610_CLK_PLL2_PFD3] = imx_clk_pfd("pll2_pfd3", "pll2_main", PFD_PLL2_BASE, 2); 163 clk[VF610_CLK_PLL2] = imx_clk_pllv3(IMX_PLLV3_GENERIC, "pll2", "pll2_bypass_src", PLL2_CTRL, 0x1);
146 clk[VF610_CLK_PLL2_PFD4] = imx_clk_pfd("pll2_pfd4", "pll2_main", PFD_PLL2_BASE, 3); 164 clk[VF610_CLK_PLL3] = imx_clk_pllv3(IMX_PLLV3_USB, "pll3", "pll3_bypass_src", PLL3_CTRL, 0x1);
147 165 clk[VF610_CLK_PLL4] = imx_clk_pllv3(IMX_PLLV3_AV, "pll4", "pll4_bypass_src", PLL4_CTRL, 0x7f);
148 clk[VF610_CLK_PLL3_MAIN] = imx_clk_fixed_factor("pll3_main", "fast_clk_sel", 20, 1); 166 clk[VF610_CLK_PLL5] = imx_clk_pllv3(IMX_PLLV3_ENET, "pll5", "pll5_bypass_src", PLL5_CTRL, 0x3);
149 clk[VF610_CLK_PLL3_PFD1] = imx_clk_pfd("pll3_pfd1", "pll3_main", PFD_PLL3_BASE, 0); 167 clk[VF610_CLK_PLL6] = imx_clk_pllv3(IMX_PLLV3_AV, "pll6", "pll6_bypass_src", PLL6_CTRL, 0x7f);
150 clk[VF610_CLK_PLL3_PFD2] = imx_clk_pfd("pll3_pfd2", "pll3_main", PFD_PLL3_BASE, 1); 168 clk[VF610_CLK_PLL7] = imx_clk_pllv3(IMX_PLLV3_USB, "pll7", "pll7_bypass_src", PLL7_CTRL, 0x1);
151 clk[VF610_CLK_PLL3_PFD3] = imx_clk_pfd("pll3_pfd3", "pll3_main", PFD_PLL3_BASE, 2); 169
152 clk[VF610_CLK_PLL3_PFD4] = imx_clk_pfd("pll3_pfd4", "pll3_main", PFD_PLL3_BASE, 3); 170 clk[VF610_PLL1_BYPASS] = imx_clk_mux_flags("pll1_bypass", PLL1_CTRL, 16, 1, pll1_bypass_sels, ARRAY_SIZE(pll1_bypass_sels), CLK_SET_RATE_PARENT);
153 171 clk[VF610_PLL2_BYPASS] = imx_clk_mux_flags("pll2_bypass", PLL2_CTRL, 16, 1, pll2_bypass_sels, ARRAY_SIZE(pll2_bypass_sels), CLK_SET_RATE_PARENT);
154 clk[VF610_CLK_PLL4_MAIN] = imx_clk_fixed_factor("pll4_main", "fast_clk_sel", 25, 1); 172 clk[VF610_PLL3_BYPASS] = imx_clk_mux_flags("pll3_bypass", PLL3_CTRL, 16, 1, pll3_bypass_sels, ARRAY_SIZE(pll3_bypass_sels), CLK_SET_RATE_PARENT);
155 /* Enet pll: fixed 50Mhz */ 173 clk[VF610_PLL4_BYPASS] = imx_clk_mux_flags("pll4_bypass", PLL4_CTRL, 16, 1, pll4_bypass_sels, ARRAY_SIZE(pll4_bypass_sels), CLK_SET_RATE_PARENT);
156 clk[VF610_CLK_PLL5_MAIN] = imx_clk_fixed_factor("pll5_main", "fast_clk_sel", 125, 6); 174 clk[VF610_PLL5_BYPASS] = imx_clk_mux_flags("pll5_bypass", PLL5_CTRL, 16, 1, pll5_bypass_sels, ARRAY_SIZE(pll5_bypass_sels), CLK_SET_RATE_PARENT);
157 /* pll6: default 960Mhz */ 175 clk[VF610_PLL6_BYPASS] = imx_clk_mux_flags("pll6_bypass", PLL6_CTRL, 16, 1, pll6_bypass_sels, ARRAY_SIZE(pll6_bypass_sels), CLK_SET_RATE_PARENT);
158 clk[VF610_CLK_PLL6_MAIN] = imx_clk_fixed_factor("pll6_main", "fast_clk_sel", 40, 1); 176 clk[VF610_PLL7_BYPASS] = imx_clk_mux_flags("pll7_bypass", PLL7_CTRL, 16, 1, pll7_bypass_sels, ARRAY_SIZE(pll7_bypass_sels), CLK_SET_RATE_PARENT);
159 /* pll7: USB1 PLL at 480MHz */ 177
160 clk[VF610_CLK_PLL7_MAIN] = imx_clk_pllv3(IMX_PLLV3_USB, "pll7_main", "fast_clk_sel", PLL7_CTRL, 0x2); 178 /* Do not bypass PLLs initially */
179 clk_set_parent(clk[VF610_PLL1_BYPASS], clk[VF610_CLK_PLL1]);
180 clk_set_parent(clk[VF610_PLL2_BYPASS], clk[VF610_CLK_PLL2]);
181 clk_set_parent(clk[VF610_PLL3_BYPASS], clk[VF610_CLK_PLL3]);
182 clk_set_parent(clk[VF610_PLL4_BYPASS], clk[VF610_CLK_PLL4]);
183 clk_set_parent(clk[VF610_PLL5_BYPASS], clk[VF610_CLK_PLL5]);
184 clk_set_parent(clk[VF610_PLL6_BYPASS], clk[VF610_CLK_PLL6]);
185 clk_set_parent(clk[VF610_PLL7_BYPASS], clk[VF610_CLK_PLL7]);
186
187 clk[VF610_CLK_PLL1_SYS] = imx_clk_gate("pll1_sys", "pll1_bypass", PLL1_CTRL, 13);
188 clk[VF610_CLK_PLL2_BUS] = imx_clk_gate("pll2_bus", "pll2_bypass", PLL2_CTRL, 13);
189 clk[VF610_CLK_PLL3_USB_OTG] = imx_clk_gate("pll3_usb_otg", "pll3_bypass", PLL3_CTRL, 13);
190 clk[VF610_CLK_PLL4_AUDIO] = imx_clk_gate("pll4_audio", "pll4_bypass", PLL4_CTRL, 13);
191 clk[VF610_CLK_PLL5_ENET] = imx_clk_gate("pll5_enet", "pll5_bypass", PLL5_CTRL, 13);
192 clk[VF610_CLK_PLL6_VIDEO] = imx_clk_gate("pll6_video", "pll6_bypass", PLL6_CTRL, 13);
193 clk[VF610_CLK_PLL7_USB_HOST] = imx_clk_gate("pll7_usb_host", "pll7_bypass", PLL7_CTRL, 13);
194
195 clk[VF610_CLK_LVDS1_IN] = imx_clk_gate_exclusive("lvds1_in", "anaclk1", ANA_MISC1, 12, BIT(10));
196
197 clk[VF610_CLK_PLL1_PFD1] = imx_clk_pfd("pll1_pfd1", "pll1_sys", PFD_PLL1_BASE, 0);
198 clk[VF610_CLK_PLL1_PFD2] = imx_clk_pfd("pll1_pfd2", "pll1_sys", PFD_PLL1_BASE, 1);
199 clk[VF610_CLK_PLL1_PFD3] = imx_clk_pfd("pll1_pfd3", "pll1_sys", PFD_PLL1_BASE, 2);
200 clk[VF610_CLK_PLL1_PFD4] = imx_clk_pfd("pll1_pfd4", "pll1_sys", PFD_PLL1_BASE, 3);
201
202 clk[VF610_CLK_PLL2_PFD1] = imx_clk_pfd("pll2_pfd1", "pll2_bus", PFD_PLL2_BASE, 0);
203 clk[VF610_CLK_PLL2_PFD2] = imx_clk_pfd("pll2_pfd2", "pll2_bus", PFD_PLL2_BASE, 1);
204 clk[VF610_CLK_PLL2_PFD3] = imx_clk_pfd("pll2_pfd3", "pll2_bus", PFD_PLL2_BASE, 2);
205 clk[VF610_CLK_PLL2_PFD4] = imx_clk_pfd("pll2_pfd4", "pll2_bus", PFD_PLL2_BASE, 3);
206
207 clk[VF610_CLK_PLL3_PFD1] = imx_clk_pfd("pll3_pfd1", "pll3_usb_otg", PFD_PLL3_BASE, 0);
208 clk[VF610_CLK_PLL3_PFD2] = imx_clk_pfd("pll3_pfd2", "pll3_usb_otg", PFD_PLL3_BASE, 1);
209 clk[VF610_CLK_PLL3_PFD3] = imx_clk_pfd("pll3_pfd3", "pll3_usb_otg", PFD_PLL3_BASE, 2);
210 clk[VF610_CLK_PLL3_PFD4] = imx_clk_pfd("pll3_pfd4", "pll3_usb_otg", PFD_PLL3_BASE, 3);
161 211
162 clk[VF610_CLK_PLL1_PFD_SEL] = imx_clk_mux("pll1_pfd_sel", CCM_CCSR, 16, 3, pll1_sels, 5); 212 clk[VF610_CLK_PLL1_PFD_SEL] = imx_clk_mux("pll1_pfd_sel", CCM_CCSR, 16, 3, pll1_sels, 5);
163 clk[VF610_CLK_PLL2_PFD_SEL] = imx_clk_mux("pll2_pfd_sel", CCM_CCSR, 19, 3, pll2_sels, 5); 213 clk[VF610_CLK_PLL2_PFD_SEL] = imx_clk_mux("pll2_pfd_sel", CCM_CCSR, 19, 3, pll2_sels, 5);
@@ -167,12 +217,12 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
167 clk[VF610_CLK_PLATFORM_BUS] = imx_clk_divider("platform_bus", "sys_bus", CCM_CACRR, 3, 3); 217 clk[VF610_CLK_PLATFORM_BUS] = imx_clk_divider("platform_bus", "sys_bus", CCM_CACRR, 3, 3);
168 clk[VF610_CLK_IPG_BUS] = imx_clk_divider("ipg_bus", "platform_bus", CCM_CACRR, 11, 2); 218 clk[VF610_CLK_IPG_BUS] = imx_clk_divider("ipg_bus", "platform_bus", CCM_CACRR, 11, 2);
169 219
170 clk[VF610_CLK_PLL3_MAIN_DIV] = imx_clk_divider("pll3_main_div", "pll3_main", CCM_CACRR, 20, 1); 220 clk[VF610_CLK_PLL3_MAIN_DIV] = imx_clk_divider("pll3_usb_otg_div", "pll3_usb_otg", CCM_CACRR, 20, 1);
171 clk[VF610_CLK_PLL4_MAIN_DIV] = clk_register_divider_table(NULL, "pll4_main_div", "pll4_main", 0, CCM_CACRR, 6, 3, 0, pll4_main_div_table, &imx_ccm_lock); 221 clk[VF610_CLK_PLL4_MAIN_DIV] = clk_register_divider_table(NULL, "pll4_audio_div", "pll4_audio", 0, CCM_CACRR, 6, 3, 0, pll4_audio_div_table, &imx_ccm_lock);
172 clk[VF610_CLK_PLL6_MAIN_DIV] = imx_clk_divider("pll6_main_div", "pll6_main", CCM_CACRR, 21, 1); 222 clk[VF610_CLK_PLL6_MAIN_DIV] = imx_clk_divider("pll6_video_div", "pll6_video", CCM_CACRR, 21, 1);
173 223
174 clk[VF610_CLK_USBPHY0] = imx_clk_gate("usbphy0", "pll3_main", PLL3_CTRL, 6); 224 clk[VF610_CLK_USBPHY0] = imx_clk_gate("usbphy0", "pll3_usb_otg", PLL3_CTRL, 6);
175 clk[VF610_CLK_USBPHY1] = imx_clk_gate("usbphy1", "pll7_main", PLL7_CTRL, 6); 225 clk[VF610_CLK_USBPHY1] = imx_clk_gate("usbphy1", "pll7_usb_host", PLL7_CTRL, 6);
176 226
177 clk[VF610_CLK_USBC0] = imx_clk_gate2("usbc0", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(4)); 227 clk[VF610_CLK_USBC0] = imx_clk_gate2("usbc0", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(4));
178 clk[VF610_CLK_USBC1] = imx_clk_gate2("usbc1", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(4)); 228 clk[VF610_CLK_USBC1] = imx_clk_gate2("usbc1", "ipg_bus", CCM_CCGR7, CCM_CCGRx_CGn(4));
@@ -191,8 +241,8 @@ static void __init vf610_clocks_init(struct device_node *ccm_node)
191 clk[VF610_CLK_QSPI1_X1_DIV] = imx_clk_divider("qspi1_x1", "qspi1_x2", CCM_CSCDR3, 11, 1); 241 clk[VF610_CLK_QSPI1_X1_DIV] = imx_clk_divider("qspi1_x1", "qspi1_x2", CCM_CSCDR3, 11, 1);
192 clk[VF610_CLK_QSPI1] = imx_clk_gate2("qspi1", "qspi1_x1", CCM_CCGR8, CCM_CCGRx_CGn(4)); 242 clk[VF610_CLK_QSPI1] = imx_clk_gate2("qspi1", "qspi1_x1", CCM_CCGR8, CCM_CCGRx_CGn(4));
193 243
194 clk[VF610_CLK_ENET_50M] = imx_clk_fixed_factor("enet_50m", "pll5_main", 1, 10); 244 clk[VF610_CLK_ENET_50M] = imx_clk_fixed_factor("enet_50m", "pll5_enet", 1, 10);
195 clk[VF610_CLK_ENET_25M] = imx_clk_fixed_factor("enet_25m", "pll5_main", 1, 20); 245 clk[VF610_CLK_ENET_25M] = imx_clk_fixed_factor("enet_25m", "pll5_enet", 1, 20);
196 clk[VF610_CLK_ENET_SEL] = imx_clk_mux("enet_sel", CCM_CSCMR2, 4, 2, rmii_sels, 4); 246 clk[VF610_CLK_ENET_SEL] = imx_clk_mux("enet_sel", CCM_CSCMR2, 4, 2, rmii_sels, 4);
197 clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7); 247 clk[VF610_CLK_ENET_TS_SEL] = imx_clk_mux("enet_ts_sel", CCM_CSCMR2, 0, 3, enet_ts_sels, 7);
198 clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24); 248 clk[VF610_CLK_ENET] = imx_clk_gate("enet", "enet_sel", CCM_CSCDR1, 24);
diff --git a/arch/arm/mach-ixp4xx/include/mach/io.h b/arch/arm/mach-ixp4xx/include/mach/io.h
index 559c69a47731..7d11979da030 100644
--- a/arch/arm/mach-ixp4xx/include/mach/io.h
+++ b/arch/arm/mach-ixp4xx/include/mach/io.h
@@ -76,7 +76,7 @@ static inline void __indirect_writeb(u8 value, volatile void __iomem *p)
76 u32 n, byte_enables, data; 76 u32 n, byte_enables, data;
77 77
78 if (!is_pci_memory(addr)) { 78 if (!is_pci_memory(addr)) {
79 __raw_writeb(value, addr); 79 __raw_writeb(value, p);
80 return; 80 return;
81 } 81 }
82 82
@@ -141,7 +141,7 @@ static inline unsigned char __indirect_readb(const volatile void __iomem *p)
141 u32 n, byte_enables, data; 141 u32 n, byte_enables, data;
142 142
143 if (!is_pci_memory(addr)) 143 if (!is_pci_memory(addr))
144 return __raw_readb(addr); 144 return __raw_readb(p);
145 145
146 n = addr % 4; 146 n = addr % 4;
147 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL; 147 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d3ccfa..8c58b71c2727 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -917,6 +917,10 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
917static int __init omap_device_late_init(void) 917static int __init omap_device_late_init(void)
918{ 918{
919 bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle); 919 bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle);
920
921 WARN(!of_have_populated_dt(),
922 "legacy booting deprecated, please update to boot with .dts\n");
923
920 return 0; 924 return 0;
921} 925}
922omap_late_initcall_sync(omap_device_late_init); 926omap_late_initcall_sync(omap_device_late_init);
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index c95346c94829..cec9d6c6442c 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -252,9 +252,6 @@ static void __init nokia_n900_legacy_init(void)
252 platform_device_register(&omap3_rom_rng_device); 252 platform_device_register(&omap3_rom_rng_device);
253 253
254 } 254 }
255
256 /* Only on some development boards */
257 gpio_request_one(164, GPIOF_OUT_INIT_LOW, "smc91x reset");
258} 255}
259 256
260static void __init omap3_tao3530_legacy_init(void) 257static void __init omap3_tao3530_legacy_init(void)
diff --git a/arch/arm/mach-pxa/include/mach/addr-map.h b/arch/arm/mach-pxa/include/mach/addr-map.h
index bbf9df37ad4b..d28fe291233a 100644
--- a/arch/arm/mach-pxa/include/mach/addr-map.h
+++ b/arch/arm/mach-pxa/include/mach/addr-map.h
@@ -39,6 +39,11 @@
39#define DMEMC_SIZE 0x00100000 39#define DMEMC_SIZE 0x00100000
40 40
41/* 41/*
42 * Reserved space for low level debug virtual addresses within
43 * 0xf6200000..0xf6201000
44 */
45
46/*
42 * Internal Memory Controller (PXA27x and later) 47 * Internal Memory Controller (PXA27x and later)
43 */ 48 */
44#define IMEMC_PHYS 0x58000000 49#define IMEMC_PHYS 0x58000000
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 55f9d6e0cc88..5e65ca8dea62 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -956,7 +956,7 @@ static u32 cache_id_part_number_from_dt;
956 * @associativity: variable to return the calculated associativity in 956 * @associativity: variable to return the calculated associativity in
957 * @max_way_size: the maximum size in bytes for the cache ways 957 * @max_way_size: the maximum size in bytes for the cache ways
958 */ 958 */
959static void __init l2x0_cache_size_of_parse(const struct device_node *np, 959static int __init l2x0_cache_size_of_parse(const struct device_node *np,
960 u32 *aux_val, u32 *aux_mask, 960 u32 *aux_val, u32 *aux_mask,
961 u32 *associativity, 961 u32 *associativity,
962 u32 max_way_size) 962 u32 max_way_size)
@@ -974,7 +974,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
974 of_property_read_u32(np, "cache-line-size", &line_size); 974 of_property_read_u32(np, "cache-line-size", &line_size);
975 975
976 if (!cache_size || !sets) 976 if (!cache_size || !sets)
977 return; 977 return -ENODEV;
978 978
979 /* All these l2 caches have the same line = block size actually */ 979 /* All these l2 caches have the same line = block size actually */
980 if (!line_size) { 980 if (!line_size) {
@@ -1009,7 +1009,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1009 1009
1010 if (way_size > max_way_size) { 1010 if (way_size > max_way_size) {
1011 pr_err("L2C OF: set size %dKB is too large\n", way_size); 1011 pr_err("L2C OF: set size %dKB is too large\n", way_size);
1012 return; 1012 return -EINVAL;
1013 } 1013 }
1014 1014
1015 pr_info("L2C OF: override cache size: %d bytes (%dKB)\n", 1015 pr_info("L2C OF: override cache size: %d bytes (%dKB)\n",
@@ -1027,7 +1027,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1027 if (way_size_bits < 1 || way_size_bits > 6) { 1027 if (way_size_bits < 1 || way_size_bits > 6) {
1028 pr_err("L2C OF: cache way size illegal: %dKB is not mapped\n", 1028 pr_err("L2C OF: cache way size illegal: %dKB is not mapped\n",
1029 way_size); 1029 way_size);
1030 return; 1030 return -EINVAL;
1031 } 1031 }
1032 1032
1033 mask |= L2C_AUX_CTRL_WAY_SIZE_MASK; 1033 mask |= L2C_AUX_CTRL_WAY_SIZE_MASK;
@@ -1036,6 +1036,8 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1036 *aux_val &= ~mask; 1036 *aux_val &= ~mask;
1037 *aux_val |= val; 1037 *aux_val |= val;
1038 *aux_mask &= ~mask; 1038 *aux_mask &= ~mask;
1039
1040 return 0;
1039} 1041}
1040 1042
1041static void __init l2x0_of_parse(const struct device_node *np, 1043static void __init l2x0_of_parse(const struct device_node *np,
@@ -1046,6 +1048,7 @@ static void __init l2x0_of_parse(const struct device_node *np,
1046 u32 dirty = 0; 1048 u32 dirty = 0;
1047 u32 val = 0, mask = 0; 1049 u32 val = 0, mask = 0;
1048 u32 assoc; 1050 u32 assoc;
1051 int ret;
1049 1052
1050 of_property_read_u32(np, "arm,tag-latency", &tag); 1053 of_property_read_u32(np, "arm,tag-latency", &tag);
1051 if (tag) { 1054 if (tag) {
@@ -1068,7 +1071,10 @@ static void __init l2x0_of_parse(const struct device_node *np,
1068 val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT; 1071 val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT;
1069 } 1072 }
1070 1073
1071 l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_256K); 1074 ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_256K);
1075 if (ret)
1076 return;
1077
1072 if (assoc > 8) { 1078 if (assoc > 8) {
1073 pr_err("l2x0 of: cache setting yield too high associativity\n"); 1079 pr_err("l2x0 of: cache setting yield too high associativity\n");
1074 pr_err("l2x0 of: %d calculated, max 8\n", assoc); 1080 pr_err("l2x0 of: %d calculated, max 8\n", assoc);
@@ -1125,6 +1131,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
1125 u32 tag[3] = { 0, 0, 0 }; 1131 u32 tag[3] = { 0, 0, 0 };
1126 u32 filter[2] = { 0, 0 }; 1132 u32 filter[2] = { 0, 0 };
1127 u32 assoc; 1133 u32 assoc;
1134 int ret;
1128 1135
1129 of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag)); 1136 of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag));
1130 if (tag[0] && tag[1] && tag[2]) 1137 if (tag[0] && tag[1] && tag[2])
@@ -1152,7 +1159,10 @@ static void __init l2c310_of_parse(const struct device_node *np,
1152 l2x0_base + L310_ADDR_FILTER_START); 1159 l2x0_base + L310_ADDR_FILTER_START);
1153 } 1160 }
1154 1161
1155 l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_512K); 1162 ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_512K);
1163 if (ret)
1164 return;
1165
1156 switch (assoc) { 1166 switch (assoc) {
1157 case 16: 1167 case 16:
1158 *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK; 1168 *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK;
@@ -1164,8 +1174,8 @@ static void __init l2c310_of_parse(const struct device_node *np,
1164 *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK; 1174 *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK;
1165 break; 1175 break;
1166 default: 1176 default:
1167 pr_err("PL310 OF: cache setting yield illegal associativity\n"); 1177 pr_err("L2C-310 OF cache associativity %d invalid, only 8 or 16 permitted\n",
1168 pr_err("PL310 OF: %d calculated, only 8 and 16 legal\n", assoc); 1178 assoc);
1169 break; 1179 break;
1170 } 1180 }
1171} 1181}
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c245d903927f..e8907117861e 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1198,7 +1198,6 @@ __iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot,
1198{ 1198{
1199 return dma_common_pages_remap(pages, size, 1199 return dma_common_pages_remap(pages, size,
1200 VM_ARM_DMA_CONSISTENT | VM_USERMAP, prot, caller); 1200 VM_ARM_DMA_CONSISTENT | VM_USERMAP, prot, caller);
1201 return NULL;
1202} 1201}
1203 1202
1204/* 1203/*
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index 45aeaaca9052..e17ed00828d7 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -127,8 +127,11 @@ void *kmap_atomic_pfn(unsigned long pfn)
127{ 127{
128 unsigned long vaddr; 128 unsigned long vaddr;
129 int idx, type; 129 int idx, type;
130 struct page *page = pfn_to_page(pfn);
130 131
131 pagefault_disable(); 132 pagefault_disable();
133 if (!PageHighMem(page))
134 return page_address(page);
132 135
133 type = kmap_atomic_idx_push(); 136 type = kmap_atomic_idx_push();
134 idx = type + KM_TYPE_NR * smp_processor_id(); 137 idx = type + KM_TYPE_NR * smp_processor_id();
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 92bba32d9230..9481f85c56e6 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -559,10 +559,10 @@ void __init mem_init(void)
559#ifdef CONFIG_MODULES 559#ifdef CONFIG_MODULES
560 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n" 560 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
561#endif 561#endif
562 " .text : 0x%p" " - 0x%p" " (%4d kB)\n" 562 " .text : 0x%p" " - 0x%p" " (%4td kB)\n"
563 " .init : 0x%p" " - 0x%p" " (%4d kB)\n" 563 " .init : 0x%p" " - 0x%p" " (%4td kB)\n"
564 " .data : 0x%p" " - 0x%p" " (%4d kB)\n" 564 " .data : 0x%p" " - 0x%p" " (%4td kB)\n"
565 " .bss : 0x%p" " - 0x%p" " (%4d kB)\n", 565 " .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
566 566
567 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) + 567 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
568 (PAGE_SIZE)), 568 (PAGE_SIZE)),
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 4ce602c2c6de..dd301be89ecc 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -35,6 +35,9 @@ CONFIG_MODULE_UNLOAD=y
35CONFIG_ARCH_THUNDER=y 35CONFIG_ARCH_THUNDER=y
36CONFIG_ARCH_VEXPRESS=y 36CONFIG_ARCH_VEXPRESS=y
37CONFIG_ARCH_XGENE=y 37CONFIG_ARCH_XGENE=y
38CONFIG_PCI=y
39CONFIG_PCI_MSI=y
40CONFIG_PCI_XGENE=y
38CONFIG_SMP=y 41CONFIG_SMP=y
39CONFIG_PREEMPT=y 42CONFIG_PREEMPT=y
40CONFIG_KSM=y 43CONFIG_KSM=y
@@ -52,6 +55,7 @@ CONFIG_IP_PNP_DHCP=y
52CONFIG_IP_PNP_BOOTP=y 55CONFIG_IP_PNP_BOOTP=y
53# CONFIG_INET_LRO is not set 56# CONFIG_INET_LRO is not set
54# CONFIG_IPV6 is not set 57# CONFIG_IPV6 is not set
58CONFIG_BPF_JIT=y
55# CONFIG_WIRELESS is not set 59# CONFIG_WIRELESS is not set
56CONFIG_NET_9P=y 60CONFIG_NET_9P=y
57CONFIG_NET_9P_VIRTIO=y 61CONFIG_NET_9P_VIRTIO=y
@@ -65,16 +69,17 @@ CONFIG_VIRTIO_BLK=y
65CONFIG_BLK_DEV_SD=y 69CONFIG_BLK_DEV_SD=y
66# CONFIG_SCSI_LOWLEVEL is not set 70# CONFIG_SCSI_LOWLEVEL is not set
67CONFIG_ATA=y 71CONFIG_ATA=y
72CONFIG_SATA_AHCI=y
73CONFIG_SATA_AHCI_PLATFORM=y
68CONFIG_AHCI_XGENE=y 74CONFIG_AHCI_XGENE=y
69CONFIG_PHY_XGENE=y
70CONFIG_PATA_PLATFORM=y 75CONFIG_PATA_PLATFORM=y
71CONFIG_PATA_OF_PLATFORM=y 76CONFIG_PATA_OF_PLATFORM=y
72CONFIG_NETDEVICES=y 77CONFIG_NETDEVICES=y
73CONFIG_TUN=y 78CONFIG_TUN=y
74CONFIG_VIRTIO_NET=y 79CONFIG_VIRTIO_NET=y
80CONFIG_NET_XGENE=y
75CONFIG_SMC91X=y 81CONFIG_SMC91X=y
76CONFIG_SMSC911X=y 82CONFIG_SMSC911X=y
77CONFIG_NET_XGENE=y
78# CONFIG_WLAN is not set 83# CONFIG_WLAN is not set
79CONFIG_INPUT_EVDEV=y 84CONFIG_INPUT_EVDEV=y
80# CONFIG_SERIO_SERPORT is not set 85# CONFIG_SERIO_SERPORT is not set
@@ -87,6 +92,11 @@ CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
87CONFIG_SERIAL_OF_PLATFORM=y 92CONFIG_SERIAL_OF_PLATFORM=y
88CONFIG_VIRTIO_CONSOLE=y 93CONFIG_VIRTIO_CONSOLE=y
89# CONFIG_HW_RANDOM is not set 94# CONFIG_HW_RANDOM is not set
95# CONFIG_HMC_DRV is not set
96CONFIG_SPI=y
97CONFIG_SPI_PL022=y
98CONFIG_GPIO_PL061=y
99CONFIG_GPIO_XGENE=y
90# CONFIG_HWMON is not set 100# CONFIG_HWMON is not set
91CONFIG_REGULATOR=y 101CONFIG_REGULATOR=y
92CONFIG_REGULATOR_FIXED_VOLTAGE=y 102CONFIG_REGULATOR_FIXED_VOLTAGE=y
@@ -97,13 +107,25 @@ CONFIG_LOGO=y
97# CONFIG_LOGO_LINUX_MONO is not set 107# CONFIG_LOGO_LINUX_MONO is not set
98# CONFIG_LOGO_LINUX_VGA16 is not set 108# CONFIG_LOGO_LINUX_VGA16 is not set
99CONFIG_USB=y 109CONFIG_USB=y
110CONFIG_USB_EHCI_HCD=y
111CONFIG_USB_EHCI_HCD_PLATFORM=y
100CONFIG_USB_ISP1760_HCD=y 112CONFIG_USB_ISP1760_HCD=y
113CONFIG_USB_OHCI_HCD=y
114CONFIG_USB_OHCI_HCD_PLATFORM=y
101CONFIG_USB_STORAGE=y 115CONFIG_USB_STORAGE=y
116CONFIG_USB_ULPI=y
102CONFIG_MMC=y 117CONFIG_MMC=y
103CONFIG_MMC_ARMMMCI=y 118CONFIG_MMC_ARMMMCI=y
119CONFIG_MMC_SDHCI=y
120CONFIG_MMC_SDHCI_PLTFM=y
121CONFIG_MMC_SPI=y
122CONFIG_RTC_CLASS=y
123CONFIG_RTC_DRV_EFI=y
124CONFIG_RTC_DRV_XGENE=y
104CONFIG_VIRTIO_BALLOON=y 125CONFIG_VIRTIO_BALLOON=y
105CONFIG_VIRTIO_MMIO=y 126CONFIG_VIRTIO_MMIO=y
106# CONFIG_IOMMU_SUPPORT is not set 127# CONFIG_IOMMU_SUPPORT is not set
128CONFIG_PHY_XGENE=y
107CONFIG_EXT2_FS=y 129CONFIG_EXT2_FS=y
108CONFIG_EXT3_FS=y 130CONFIG_EXT3_FS=y
109# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 131# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index da1f06b535e3..9dfdac4a74a1 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -792,3 +792,5 @@ __SYSCALL(__NR_renameat2, sys_renameat2)
792__SYSCALL(__NR_getrandom, sys_getrandom) 792__SYSCALL(__NR_getrandom, sys_getrandom)
793#define __NR_memfd_create 385 793#define __NR_memfd_create 385
794__SYSCALL(__NR_memfd_create, sys_memfd_create) 794__SYSCALL(__NR_memfd_create, sys_memfd_create)
795#define __NR_bpf 386
796__SYSCALL(__NR_bpf, sys_bpf)
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 866c1c821860..663da771580a 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -528,7 +528,7 @@ static int __maybe_unused cpu_psci_cpu_suspend(unsigned long index)
528 if (WARN_ON_ONCE(!index)) 528 if (WARN_ON_ONCE(!index))
529 return -EINVAL; 529 return -EINVAL;
530 530
531 if (state->type == PSCI_POWER_STATE_TYPE_STANDBY) 531 if (state[index - 1].type == PSCI_POWER_STATE_TYPE_STANDBY)
532 ret = psci_ops.cpu_suspend(state[index - 1], 0); 532 ret = psci_ops.cpu_suspend(state[index - 1], 0);
533 else 533 else
534 ret = __cpu_suspend(index, psci_suspend_finisher); 534 ret = __cpu_suspend(index, psci_suspend_finisher);
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 4ef7a54813e6..75e75d7b1702 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,7 +4,7 @@
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6 6
7#define NR_syscalls 354 7#define NR_syscalls 355
8 8
9#define __ARCH_WANT_OLD_READDIR 9#define __ARCH_WANT_OLD_READDIR
10#define __ARCH_WANT_OLD_STAT 10#define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
index b419c6b7ac37..2c1bec9a14b6 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -359,5 +359,6 @@
359#define __NR_renameat2 351 359#define __NR_renameat2 351
360#define __NR_getrandom 352 360#define __NR_getrandom 352
361#define __NR_memfd_create 353 361#define __NR_memfd_create 353
362#define __NR_bpf 354
362 363
363#endif /* _UAPI_ASM_M68K_UNISTD_H_ */ 364#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index 05b46c2b08b8..2ca219e184cd 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -374,4 +374,5 @@ ENTRY(sys_call_table)
374 .long sys_renameat2 374 .long sys_renameat2
375 .long sys_getrandom 375 .long sys_getrandom
376 .long sys_memfd_create 376 .long sys_memfd_create
377 .long sys_bpf
377 378
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 6feded3b0c4c..a7736fa0580c 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -129,6 +129,10 @@ endmenu
129 129
130menu "Kernel features" 130menu "Kernel features"
131 131
132config NR_CPUS
133 int
134 default "1"
135
132config ADVANCED_OPTIONS 136config ADVANCED_OPTIONS
133 bool "Prompt for advanced kernel configuration options" 137 bool "Prompt for advanced kernel configuration options"
134 help 138 help
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index ea4b233647c1..0a53362d5548 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -38,6 +38,6 @@
38 38
39#endif /* __ASSEMBLY__ */ 39#endif /* __ASSEMBLY__ */
40 40
41#define __NR_syscalls 387 41#define __NR_syscalls 388
42 42
43#endif /* _ASM_MICROBLAZE_UNISTD_H */ 43#endif /* _ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
index 1c2380bf8fe6..c712677f8a2a 100644
--- a/arch/microblaze/include/uapi/asm/unistd.h
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -402,5 +402,6 @@
402#define __NR_seccomp 384 402#define __NR_seccomp 384
403#define __NR_getrandom 385 403#define __NR_getrandom 385
404#define __NR_memfd_create 386 404#define __NR_memfd_create 386
405#define __NR_bpf 387
405 406
406#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */ 407#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index de59ee1d7010..0166e890486c 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -387,3 +387,4 @@ ENTRY(sys_call_table)
387 .long sys_seccomp 387 .long sys_seccomp
388 .long sys_getrandom /* 385 */ 388 .long sys_getrandom /* 385 */
389 .long sys_memfd_create 389 .long sys_memfd_create
390 .long sys_bpf
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9037914f6985..b30e41c0c033 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -660,8 +660,13 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose,
660 res = &hose->mem_resources[memno++]; 660 res = &hose->mem_resources[memno++];
661 break; 661 break;
662 } 662 }
663 if (res != NULL) 663 if (res != NULL) {
664 of_pci_range_to_resource(&range, dev, res); 664 res->name = dev->full_name;
665 res->flags = range.flags;
666 res->start = range.cpu_addr;
667 res->end = range.cpu_addr + range.size - 1;
668 res->parent = res->child = res->sibling = NULL;
669 }
665 } 670 }
666 671
667 /* If there's an ISA hole and the pci_mem_offset is -not- matching 672 /* If there's an ISA hole and the pci_mem_offset is -not- matching
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 23cb94806fbc..58076472bdd8 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -93,6 +93,15 @@ LDFLAGS_vmlinux += -G 0 -static -n -nostdlib
93KBUILD_AFLAGS_MODULE += -mlong-calls 93KBUILD_AFLAGS_MODULE += -mlong-calls
94KBUILD_CFLAGS_MODULE += -mlong-calls 94KBUILD_CFLAGS_MODULE += -mlong-calls
95 95
96#
97# pass -msoft-float to GAS if it supports it. However on newer binutils
98# (specifically newer than 2.24.51.20140728) we then also need to explicitly
99# set ".set hardfloat" in all files which manipulate floating point registers.
100#
101ifneq ($(call as-option,-Wa$(comma)-msoft-float,),)
102 cflags-y += -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float
103endif
104
96cflags-y += -ffreestanding 105cflags-y += -ffreestanding
97 106
98# 107#
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index 741734049675..2bc4aa95944e 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -809,6 +809,7 @@ static struct irq_chip octeon_irq_chip_ciu_gpio_v2 = {
809 .irq_set_type = octeon_irq_ciu_gpio_set_type, 809 .irq_set_type = octeon_irq_ciu_gpio_set_type,
810#ifdef CONFIG_SMP 810#ifdef CONFIG_SMP
811 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2, 811 .irq_set_affinity = octeon_irq_ciu_set_affinity_v2,
812 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
812#endif 813#endif
813 .flags = IRQCHIP_SET_TYPE_MASKED, 814 .flags = IRQCHIP_SET_TYPE_MASKED,
814}; 815};
@@ -823,6 +824,7 @@ static struct irq_chip octeon_irq_chip_ciu_gpio = {
823 .irq_set_type = octeon_irq_ciu_gpio_set_type, 824 .irq_set_type = octeon_irq_ciu_gpio_set_type,
824#ifdef CONFIG_SMP 825#ifdef CONFIG_SMP
825 .irq_set_affinity = octeon_irq_ciu_set_affinity, 826 .irq_set_affinity = octeon_irq_ciu_set_affinity,
827 .irq_cpu_offline = octeon_irq_cpu_offline_ciu,
826#endif 828#endif
827 .flags = IRQCHIP_SET_TYPE_MASKED, 829 .flags = IRQCHIP_SET_TYPE_MASKED,
828}; 830};
diff --git a/arch/mips/include/asm/asmmacro-32.h b/arch/mips/include/asm/asmmacro-32.h
index e38c2811d4e2..cdac7b3eeaf7 100644
--- a/arch/mips/include/asm/asmmacro-32.h
+++ b/arch/mips/include/asm/asmmacro-32.h
@@ -13,6 +13,8 @@
13#include <asm/mipsregs.h> 13#include <asm/mipsregs.h>
14 14
15 .macro fpu_save_single thread tmp=t0 15 .macro fpu_save_single thread tmp=t0
16 .set push
17 SET_HARDFLOAT
16 cfc1 \tmp, fcr31 18 cfc1 \tmp, fcr31
17 swc1 $f0, THREAD_FPR0_LS64(\thread) 19 swc1 $f0, THREAD_FPR0_LS64(\thread)
18 swc1 $f1, THREAD_FPR1_LS64(\thread) 20 swc1 $f1, THREAD_FPR1_LS64(\thread)
@@ -47,9 +49,12 @@
47 swc1 $f30, THREAD_FPR30_LS64(\thread) 49 swc1 $f30, THREAD_FPR30_LS64(\thread)
48 swc1 $f31, THREAD_FPR31_LS64(\thread) 50 swc1 $f31, THREAD_FPR31_LS64(\thread)
49 sw \tmp, THREAD_FCR31(\thread) 51 sw \tmp, THREAD_FCR31(\thread)
52 .set pop
50 .endm 53 .endm
51 54
52 .macro fpu_restore_single thread tmp=t0 55 .macro fpu_restore_single thread tmp=t0
56 .set push
57 SET_HARDFLOAT
53 lw \tmp, THREAD_FCR31(\thread) 58 lw \tmp, THREAD_FCR31(\thread)
54 lwc1 $f0, THREAD_FPR0_LS64(\thread) 59 lwc1 $f0, THREAD_FPR0_LS64(\thread)
55 lwc1 $f1, THREAD_FPR1_LS64(\thread) 60 lwc1 $f1, THREAD_FPR1_LS64(\thread)
@@ -84,6 +89,7 @@
84 lwc1 $f30, THREAD_FPR30_LS64(\thread) 89 lwc1 $f30, THREAD_FPR30_LS64(\thread)
85 lwc1 $f31, THREAD_FPR31_LS64(\thread) 90 lwc1 $f31, THREAD_FPR31_LS64(\thread)
86 ctc1 \tmp, fcr31 91 ctc1 \tmp, fcr31
92 .set pop
87 .endm 93 .endm
88 94
89 .macro cpu_save_nonscratch thread 95 .macro cpu_save_nonscratch thread
diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h
index cd9a98bc8f60..6caf8766b80f 100644
--- a/arch/mips/include/asm/asmmacro.h
+++ b/arch/mips/include/asm/asmmacro.h
@@ -57,6 +57,8 @@
57#endif /* CONFIG_CPU_MIPSR2 */ 57#endif /* CONFIG_CPU_MIPSR2 */
58 58
59 .macro fpu_save_16even thread tmp=t0 59 .macro fpu_save_16even thread tmp=t0
60 .set push
61 SET_HARDFLOAT
60 cfc1 \tmp, fcr31 62 cfc1 \tmp, fcr31
61 sdc1 $f0, THREAD_FPR0_LS64(\thread) 63 sdc1 $f0, THREAD_FPR0_LS64(\thread)
62 sdc1 $f2, THREAD_FPR2_LS64(\thread) 64 sdc1 $f2, THREAD_FPR2_LS64(\thread)
@@ -75,11 +77,13 @@
75 sdc1 $f28, THREAD_FPR28_LS64(\thread) 77 sdc1 $f28, THREAD_FPR28_LS64(\thread)
76 sdc1 $f30, THREAD_FPR30_LS64(\thread) 78 sdc1 $f30, THREAD_FPR30_LS64(\thread)
77 sw \tmp, THREAD_FCR31(\thread) 79 sw \tmp, THREAD_FCR31(\thread)
80 .set pop
78 .endm 81 .endm
79 82
80 .macro fpu_save_16odd thread 83 .macro fpu_save_16odd thread
81 .set push 84 .set push
82 .set mips64r2 85 .set mips64r2
86 SET_HARDFLOAT
83 sdc1 $f1, THREAD_FPR1_LS64(\thread) 87 sdc1 $f1, THREAD_FPR1_LS64(\thread)
84 sdc1 $f3, THREAD_FPR3_LS64(\thread) 88 sdc1 $f3, THREAD_FPR3_LS64(\thread)
85 sdc1 $f5, THREAD_FPR5_LS64(\thread) 89 sdc1 $f5, THREAD_FPR5_LS64(\thread)
@@ -110,6 +114,8 @@
110 .endm 114 .endm
111 115
112 .macro fpu_restore_16even thread tmp=t0 116 .macro fpu_restore_16even thread tmp=t0
117 .set push
118 SET_HARDFLOAT
113 lw \tmp, THREAD_FCR31(\thread) 119 lw \tmp, THREAD_FCR31(\thread)
114 ldc1 $f0, THREAD_FPR0_LS64(\thread) 120 ldc1 $f0, THREAD_FPR0_LS64(\thread)
115 ldc1 $f2, THREAD_FPR2_LS64(\thread) 121 ldc1 $f2, THREAD_FPR2_LS64(\thread)
@@ -133,6 +139,7 @@
133 .macro fpu_restore_16odd thread 139 .macro fpu_restore_16odd thread
134 .set push 140 .set push
135 .set mips64r2 141 .set mips64r2
142 SET_HARDFLOAT
136 ldc1 $f1, THREAD_FPR1_LS64(\thread) 143 ldc1 $f1, THREAD_FPR1_LS64(\thread)
137 ldc1 $f3, THREAD_FPR3_LS64(\thread) 144 ldc1 $f3, THREAD_FPR3_LS64(\thread)
138 ldc1 $f5, THREAD_FPR5_LS64(\thread) 145 ldc1 $f5, THREAD_FPR5_LS64(\thread)
@@ -277,6 +284,7 @@
277 .macro cfcmsa rd, cs 284 .macro cfcmsa rd, cs
278 .set push 285 .set push
279 .set noat 286 .set noat
287 SET_HARDFLOAT
280 .insn 288 .insn
281 .word CFC_MSA_INSN | (\cs << 11) 289 .word CFC_MSA_INSN | (\cs << 11)
282 move \rd, $1 290 move \rd, $1
@@ -286,6 +294,7 @@
286 .macro ctcmsa cd, rs 294 .macro ctcmsa cd, rs
287 .set push 295 .set push
288 .set noat 296 .set noat
297 SET_HARDFLOAT
289 move $1, \rs 298 move $1, \rs
290 .word CTC_MSA_INSN | (\cd << 6) 299 .word CTC_MSA_INSN | (\cd << 6)
291 .set pop 300 .set pop
@@ -294,6 +303,7 @@
294 .macro ld_d wd, off, base 303 .macro ld_d wd, off, base
295 .set push 304 .set push
296 .set noat 305 .set noat
306 SET_HARDFLOAT
297 add $1, \base, \off 307 add $1, \base, \off
298 .word LDD_MSA_INSN | (\wd << 6) 308 .word LDD_MSA_INSN | (\wd << 6)
299 .set pop 309 .set pop
@@ -302,6 +312,7 @@
302 .macro st_d wd, off, base 312 .macro st_d wd, off, base
303 .set push 313 .set push
304 .set noat 314 .set noat
315 SET_HARDFLOAT
305 add $1, \base, \off 316 add $1, \base, \off
306 .word STD_MSA_INSN | (\wd << 6) 317 .word STD_MSA_INSN | (\wd << 6)
307 .set pop 318 .set pop
@@ -310,6 +321,7 @@
310 .macro copy_u_w rd, ws, n 321 .macro copy_u_w rd, ws, n
311 .set push 322 .set push
312 .set noat 323 .set noat
324 SET_HARDFLOAT
313 .insn 325 .insn
314 .word COPY_UW_MSA_INSN | (\n << 16) | (\ws << 11) 326 .word COPY_UW_MSA_INSN | (\n << 16) | (\ws << 11)
315 /* move triggers an assembler bug... */ 327 /* move triggers an assembler bug... */
@@ -320,6 +332,7 @@
320 .macro copy_u_d rd, ws, n 332 .macro copy_u_d rd, ws, n
321 .set push 333 .set push
322 .set noat 334 .set noat
335 SET_HARDFLOAT
323 .insn 336 .insn
324 .word COPY_UD_MSA_INSN | (\n << 16) | (\ws << 11) 337 .word COPY_UD_MSA_INSN | (\n << 16) | (\ws << 11)
325 /* move triggers an assembler bug... */ 338 /* move triggers an assembler bug... */
@@ -330,6 +343,7 @@
330 .macro insert_w wd, n, rs 343 .macro insert_w wd, n, rs
331 .set push 344 .set push
332 .set noat 345 .set noat
346 SET_HARDFLOAT
333 /* move triggers an assembler bug... */ 347 /* move triggers an assembler bug... */
334 or $1, \rs, zero 348 or $1, \rs, zero
335 .word INSERT_W_MSA_INSN | (\n << 16) | (\wd << 6) 349 .word INSERT_W_MSA_INSN | (\n << 16) | (\wd << 6)
@@ -339,6 +353,7 @@
339 .macro insert_d wd, n, rs 353 .macro insert_d wd, n, rs
340 .set push 354 .set push
341 .set noat 355 .set noat
356 SET_HARDFLOAT
342 /* move triggers an assembler bug... */ 357 /* move triggers an assembler bug... */
343 or $1, \rs, zero 358 or $1, \rs, zero
344 .word INSERT_D_MSA_INSN | (\n << 16) | (\wd << 6) 359 .word INSERT_D_MSA_INSN | (\n << 16) | (\wd << 6)
@@ -381,6 +396,7 @@
381 st_d 31, THREAD_FPR31, \thread 396 st_d 31, THREAD_FPR31, \thread
382 .set push 397 .set push
383 .set noat 398 .set noat
399 SET_HARDFLOAT
384 cfcmsa $1, MSA_CSR 400 cfcmsa $1, MSA_CSR
385 sw $1, THREAD_MSA_CSR(\thread) 401 sw $1, THREAD_MSA_CSR(\thread)
386 .set pop 402 .set pop
@@ -389,6 +405,7 @@
389 .macro msa_restore_all thread 405 .macro msa_restore_all thread
390 .set push 406 .set push
391 .set noat 407 .set noat
408 SET_HARDFLOAT
392 lw $1, THREAD_MSA_CSR(\thread) 409 lw $1, THREAD_MSA_CSR(\thread)
393 ctcmsa MSA_CSR, $1 410 ctcmsa MSA_CSR, $1
394 .set pop 411 .set pop
@@ -441,6 +458,7 @@
441 .macro msa_init_all_upper 458 .macro msa_init_all_upper
442 .set push 459 .set push
443 .set noat 460 .set noat
461 SET_HARDFLOAT
444 not $1, zero 462 not $1, zero
445 msa_init_upper 0 463 msa_init_upper 0
446 .set pop 464 .set pop
diff --git a/arch/mips/include/asm/fpregdef.h b/arch/mips/include/asm/fpregdef.h
index 429481f9028d..f184ba088532 100644
--- a/arch/mips/include/asm/fpregdef.h
+++ b/arch/mips/include/asm/fpregdef.h
@@ -14,6 +14,20 @@
14 14
15#include <asm/sgidefs.h> 15#include <asm/sgidefs.h>
16 16
17/*
18 * starting with binutils 2.24.51.20140729, MIPS binutils warn about mixing
19 * hardfloat and softfloat object files. The kernel build uses soft-float by
20 * default, so we also need to pass -msoft-float along to GAS if it supports it.
21 * But this in turn causes assembler errors in files which access hardfloat
22 * registers. We detect if GAS supports "-msoft-float" in the Makefile and
23 * explicitly put ".set hardfloat" where floating point registers are touched.
24 */
25#ifdef GAS_HAS_SET_HARDFLOAT
26#define SET_HARDFLOAT .set hardfloat
27#else
28#define SET_HARDFLOAT
29#endif
30
17#if _MIPS_SIM == _MIPS_SIM_ABI32 31#if _MIPS_SIM == _MIPS_SIM_ABI32
18 32
19/* 33/*
diff --git a/arch/mips/include/asm/fpu.h b/arch/mips/include/asm/fpu.h
index 4d0aeda68397..dd562414cd5e 100644
--- a/arch/mips/include/asm/fpu.h
+++ b/arch/mips/include/asm/fpu.h
@@ -145,8 +145,8 @@ static inline void lose_fpu(int save)
145 if (is_msa_enabled()) { 145 if (is_msa_enabled()) {
146 if (save) { 146 if (save) {
147 save_msa(current); 147 save_msa(current);
148 asm volatile("cfc1 %0, $31" 148 current->thread.fpu.fcr31 =
149 : "=r"(current->thread.fpu.fcr31)); 149 read_32bit_cp1_register(CP1_STATUS);
150 } 150 }
151 disable_msa(); 151 disable_msa();
152 clear_thread_flag(TIF_USEDMSA); 152 clear_thread_flag(TIF_USEDMSA);
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index cf3b580c3df6..b46cd220a018 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -1324,7 +1324,7 @@ do { \
1324/* 1324/*
1325 * Macros to access the floating point coprocessor control registers 1325 * Macros to access the floating point coprocessor control registers
1326 */ 1326 */
1327#define read_32bit_cp1_register(source) \ 1327#define _read_32bit_cp1_register(source, gas_hardfloat) \
1328({ \ 1328({ \
1329 int __res; \ 1329 int __res; \
1330 \ 1330 \
@@ -1334,12 +1334,21 @@ do { \
1334 " # gas fails to assemble cfc1 for some archs, \n" \ 1334 " # gas fails to assemble cfc1 for some archs, \n" \
1335 " # like Octeon. \n" \ 1335 " # like Octeon. \n" \
1336 " .set mips1 \n" \ 1336 " .set mips1 \n" \
1337 " "STR(gas_hardfloat)" \n" \
1337 " cfc1 %0,"STR(source)" \n" \ 1338 " cfc1 %0,"STR(source)" \n" \
1338 " .set pop \n" \ 1339 " .set pop \n" \
1339 : "=r" (__res)); \ 1340 : "=r" (__res)); \
1340 __res; \ 1341 __res; \
1341}) 1342})
1342 1343
1344#ifdef GAS_HAS_SET_HARDFLOAT
1345#define read_32bit_cp1_register(source) \
1346 _read_32bit_cp1_register(source, .set hardfloat)
1347#else
1348#define read_32bit_cp1_register(source) \
1349 _read_32bit_cp1_register(source, )
1350#endif
1351
1343#ifdef HAVE_AS_DSP 1352#ifdef HAVE_AS_DSP
1344#define rddsp(mask) \ 1353#define rddsp(mask) \
1345({ \ 1354({ \
diff --git a/arch/mips/include/uapi/asm/unistd.h b/arch/mips/include/uapi/asm/unistd.h
index fdb4923777d1..9dc58568f230 100644
--- a/arch/mips/include/uapi/asm/unistd.h
+++ b/arch/mips/include/uapi/asm/unistd.h
@@ -375,16 +375,17 @@
375#define __NR_seccomp (__NR_Linux + 352) 375#define __NR_seccomp (__NR_Linux + 352)
376#define __NR_getrandom (__NR_Linux + 353) 376#define __NR_getrandom (__NR_Linux + 353)
377#define __NR_memfd_create (__NR_Linux + 354) 377#define __NR_memfd_create (__NR_Linux + 354)
378#define __NR_bpf (__NR_Linux + 355)
378 379
379/* 380/*
380 * Offset of the last Linux o32 flavoured syscall 381 * Offset of the last Linux o32 flavoured syscall
381 */ 382 */
382#define __NR_Linux_syscalls 354 383#define __NR_Linux_syscalls 355
383 384
384#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 385#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
385 386
386#define __NR_O32_Linux 4000 387#define __NR_O32_Linux 4000
387#define __NR_O32_Linux_syscalls 354 388#define __NR_O32_Linux_syscalls 355
388 389
389#if _MIPS_SIM == _MIPS_SIM_ABI64 390#if _MIPS_SIM == _MIPS_SIM_ABI64
390 391
@@ -707,16 +708,17 @@
707#define __NR_seccomp (__NR_Linux + 312) 708#define __NR_seccomp (__NR_Linux + 312)
708#define __NR_getrandom (__NR_Linux + 313) 709#define __NR_getrandom (__NR_Linux + 313)
709#define __NR_memfd_create (__NR_Linux + 314) 710#define __NR_memfd_create (__NR_Linux + 314)
711#define __NR_bpf (__NR_Linux + 315)
710 712
711/* 713/*
712 * Offset of the last Linux 64-bit flavoured syscall 714 * Offset of the last Linux 64-bit flavoured syscall
713 */ 715 */
714#define __NR_Linux_syscalls 314 716#define __NR_Linux_syscalls 315
715 717
716#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 718#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
717 719
718#define __NR_64_Linux 5000 720#define __NR_64_Linux 5000
719#define __NR_64_Linux_syscalls 314 721#define __NR_64_Linux_syscalls 315
720 722
721#if _MIPS_SIM == _MIPS_SIM_NABI32 723#if _MIPS_SIM == _MIPS_SIM_NABI32
722 724
@@ -1043,15 +1045,16 @@
1043#define __NR_seccomp (__NR_Linux + 316) 1045#define __NR_seccomp (__NR_Linux + 316)
1044#define __NR_getrandom (__NR_Linux + 317) 1046#define __NR_getrandom (__NR_Linux + 317)
1045#define __NR_memfd_create (__NR_Linux + 318) 1047#define __NR_memfd_create (__NR_Linux + 318)
1048#define __NR_memfd_create (__NR_Linux + 319)
1046 1049
1047/* 1050/*
1048 * Offset of the last N32 flavoured syscall 1051 * Offset of the last N32 flavoured syscall
1049 */ 1052 */
1050#define __NR_Linux_syscalls 318 1053#define __NR_Linux_syscalls 319
1051 1054
1052#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 1055#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
1053 1056
1054#define __NR_N32_Linux 6000 1057#define __NR_N32_Linux 6000
1055#define __NR_N32_Linux_syscalls 318 1058#define __NR_N32_Linux_syscalls 319
1056 1059
1057#endif /* _UAPI_ASM_UNISTD_H */ 1060#endif /* _UAPI_ASM_UNISTD_H */
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index 7b2df224f041..4d7d99d601cc 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -144,7 +144,7 @@ int __mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
144 case mm_bc1t_op: 144 case mm_bc1t_op:
145 preempt_disable(); 145 preempt_disable();
146 if (is_fpu_owner()) 146 if (is_fpu_owner())
147 asm volatile("cfc1\t%0,$31" : "=r" (fcr31)); 147 fcr31 = read_32bit_cp1_register(CP1_STATUS);
148 else 148 else
149 fcr31 = current->thread.fpu.fcr31; 149 fcr31 = current->thread.fpu.fcr31;
150 preempt_enable(); 150 preempt_enable();
@@ -562,11 +562,7 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
562 case cop1_op: 562 case cop1_op:
563 preempt_disable(); 563 preempt_disable();
564 if (is_fpu_owner()) 564 if (is_fpu_owner())
565 asm volatile( 565 fcr31 = read_32bit_cp1_register(CP1_STATUS);
566 ".set push\n"
567 "\t.set mips1\n"
568 "\tcfc1\t%0,$31\n"
569 "\t.set pop" : "=r" (fcr31));
570 else 566 else
571 fcr31 = current->thread.fpu.fcr31; 567 fcr31 = current->thread.fpu.fcr31;
572 preempt_enable(); 568 preempt_enable();
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index ac35e12cb1f3..a5e26dd90592 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -358,6 +358,7 @@ NESTED(nmi_handler, PT_SIZE, sp)
358 .set push 358 .set push
359 /* gas fails to assemble cfc1 for some archs (octeon).*/ \ 359 /* gas fails to assemble cfc1 for some archs (octeon).*/ \
360 .set mips1 360 .set mips1
361 SET_HARDFLOAT
361 cfc1 a1, fcr31 362 cfc1 a1, fcr31
362 li a2, ~(0x3f << 12) 363 li a2, ~(0x3f << 12)
363 and a2, a1 364 and a2, a1
diff --git a/arch/mips/kernel/r2300_fpu.S b/arch/mips/kernel/r2300_fpu.S
index f31063dbdaeb..5ce3b746cedc 100644
--- a/arch/mips/kernel/r2300_fpu.S
+++ b/arch/mips/kernel/r2300_fpu.S
@@ -28,6 +28,8 @@
28 .set mips1 28 .set mips1
29 /* Save floating point context */ 29 /* Save floating point context */
30LEAF(_save_fp_context) 30LEAF(_save_fp_context)
31 .set push
32 SET_HARDFLOAT
31 li v0, 0 # assume success 33 li v0, 0 # assume success
32 cfc1 t1,fcr31 34 cfc1 t1,fcr31
33 EX(swc1 $f0,(SC_FPREGS+0)(a0)) 35 EX(swc1 $f0,(SC_FPREGS+0)(a0))
@@ -65,6 +67,7 @@ LEAF(_save_fp_context)
65 EX(sw t1,(SC_FPC_CSR)(a0)) 67 EX(sw t1,(SC_FPC_CSR)(a0))
66 cfc1 t0,$0 # implementation/version 68 cfc1 t0,$0 # implementation/version
67 jr ra 69 jr ra
70 .set pop
68 .set nomacro 71 .set nomacro
69 EX(sw t0,(SC_FPC_EIR)(a0)) 72 EX(sw t0,(SC_FPC_EIR)(a0))
70 .set macro 73 .set macro
@@ -80,6 +83,8 @@ LEAF(_save_fp_context)
80 * stack frame which might have been changed by the user. 83 * stack frame which might have been changed by the user.
81 */ 84 */
82LEAF(_restore_fp_context) 85LEAF(_restore_fp_context)
86 .set push
87 SET_HARDFLOAT
83 li v0, 0 # assume success 88 li v0, 0 # assume success
84 EX(lw t0,(SC_FPC_CSR)(a0)) 89 EX(lw t0,(SC_FPC_CSR)(a0))
85 EX(lwc1 $f0,(SC_FPREGS+0)(a0)) 90 EX(lwc1 $f0,(SC_FPREGS+0)(a0))
@@ -116,6 +121,7 @@ LEAF(_restore_fp_context)
116 EX(lwc1 $f31,(SC_FPREGS+248)(a0)) 121 EX(lwc1 $f31,(SC_FPREGS+248)(a0))
117 jr ra 122 jr ra
118 ctc1 t0,fcr31 123 ctc1 t0,fcr31
124 .set pop
119 END(_restore_fp_context) 125 END(_restore_fp_context)
120 .set reorder 126 .set reorder
121 127
diff --git a/arch/mips/kernel/r2300_switch.S b/arch/mips/kernel/r2300_switch.S
index 20b7b040e76f..435ea652f5fa 100644
--- a/arch/mips/kernel/r2300_switch.S
+++ b/arch/mips/kernel/r2300_switch.S
@@ -120,6 +120,9 @@ LEAF(_restore_fp)
120 120
121#define FPU_DEFAULT 0x00000000 121#define FPU_DEFAULT 0x00000000
122 122
123 .set push
124 SET_HARDFLOAT
125
123LEAF(_init_fpu) 126LEAF(_init_fpu)
124 mfc0 t0, CP0_STATUS 127 mfc0 t0, CP0_STATUS
125 li t1, ST0_CU1 128 li t1, ST0_CU1
@@ -165,3 +168,5 @@ LEAF(_init_fpu)
165 mtc1 t0, $f31 168 mtc1 t0, $f31
166 jr ra 169 jr ra
167 END(_init_fpu) 170 END(_init_fpu)
171
172 .set pop
diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S
index 8352523568e6..6c160c67984c 100644
--- a/arch/mips/kernel/r4k_fpu.S
+++ b/arch/mips/kernel/r4k_fpu.S
@@ -19,8 +19,12 @@
19#include <asm/asm-offsets.h> 19#include <asm/asm-offsets.h>
20#include <asm/regdef.h> 20#include <asm/regdef.h>
21 21
22/* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
23#undef fp
24
22 .macro EX insn, reg, src 25 .macro EX insn, reg, src
23 .set push 26 .set push
27 SET_HARDFLOAT
24 .set nomacro 28 .set nomacro
25.ex\@: \insn \reg, \src 29.ex\@: \insn \reg, \src
26 .set pop 30 .set pop
@@ -33,12 +37,17 @@
33 .set arch=r4000 37 .set arch=r4000
34 38
35LEAF(_save_fp_context) 39LEAF(_save_fp_context)
40 .set push
41 SET_HARDFLOAT
36 cfc1 t1, fcr31 42 cfc1 t1, fcr31
43 .set pop
37 44
38#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) 45#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2)
39 .set push 46 .set push
47 SET_HARDFLOAT
40#ifdef CONFIG_CPU_MIPS32_R2 48#ifdef CONFIG_CPU_MIPS32_R2
41 .set mips64r2 49 .set mips32r2
50 .set fp=64
42 mfc0 t0, CP0_STATUS 51 mfc0 t0, CP0_STATUS
43 sll t0, t0, 5 52 sll t0, t0, 5
44 bgez t0, 1f # skip storing odd if FR=0 53 bgez t0, 1f # skip storing odd if FR=0
@@ -64,6 +73,8 @@ LEAF(_save_fp_context)
641: .set pop 731: .set pop
65#endif 74#endif
66 75
76 .set push
77 SET_HARDFLOAT
67 /* Store the 16 even double precision registers */ 78 /* Store the 16 even double precision registers */
68 EX sdc1 $f0, SC_FPREGS+0(a0) 79 EX sdc1 $f0, SC_FPREGS+0(a0)
69 EX sdc1 $f2, SC_FPREGS+16(a0) 80 EX sdc1 $f2, SC_FPREGS+16(a0)
@@ -84,11 +95,14 @@ LEAF(_save_fp_context)
84 EX sw t1, SC_FPC_CSR(a0) 95 EX sw t1, SC_FPC_CSR(a0)
85 jr ra 96 jr ra
86 li v0, 0 # success 97 li v0, 0 # success
98 .set pop
87 END(_save_fp_context) 99 END(_save_fp_context)
88 100
89#ifdef CONFIG_MIPS32_COMPAT 101#ifdef CONFIG_MIPS32_COMPAT
90 /* Save 32-bit process floating point context */ 102 /* Save 32-bit process floating point context */
91LEAF(_save_fp_context32) 103LEAF(_save_fp_context32)
104 .set push
105 SET_HARDFLOAT
92 cfc1 t1, fcr31 106 cfc1 t1, fcr31
93 107
94 mfc0 t0, CP0_STATUS 108 mfc0 t0, CP0_STATUS
@@ -134,6 +148,7 @@ LEAF(_save_fp_context32)
134 EX sw t1, SC32_FPC_CSR(a0) 148 EX sw t1, SC32_FPC_CSR(a0)
135 cfc1 t0, $0 # implementation/version 149 cfc1 t0, $0 # implementation/version
136 EX sw t0, SC32_FPC_EIR(a0) 150 EX sw t0, SC32_FPC_EIR(a0)
151 .set pop
137 152
138 jr ra 153 jr ra
139 li v0, 0 # success 154 li v0, 0 # success
@@ -150,8 +165,10 @@ LEAF(_restore_fp_context)
150 165
151#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2) 166#if defined(CONFIG_64BIT) || defined(CONFIG_CPU_MIPS32_R2)
152 .set push 167 .set push
168 SET_HARDFLOAT
153#ifdef CONFIG_CPU_MIPS32_R2 169#ifdef CONFIG_CPU_MIPS32_R2
154 .set mips64r2 170 .set mips32r2
171 .set fp=64
155 mfc0 t0, CP0_STATUS 172 mfc0 t0, CP0_STATUS
156 sll t0, t0, 5 173 sll t0, t0, 5
157 bgez t0, 1f # skip loading odd if FR=0 174 bgez t0, 1f # skip loading odd if FR=0
@@ -175,6 +192,8 @@ LEAF(_restore_fp_context)
175 EX ldc1 $f31, SC_FPREGS+248(a0) 192 EX ldc1 $f31, SC_FPREGS+248(a0)
1761: .set pop 1931: .set pop
177#endif 194#endif
195 .set push
196 SET_HARDFLOAT
178 EX ldc1 $f0, SC_FPREGS+0(a0) 197 EX ldc1 $f0, SC_FPREGS+0(a0)
179 EX ldc1 $f2, SC_FPREGS+16(a0) 198 EX ldc1 $f2, SC_FPREGS+16(a0)
180 EX ldc1 $f4, SC_FPREGS+32(a0) 199 EX ldc1 $f4, SC_FPREGS+32(a0)
@@ -192,6 +211,7 @@ LEAF(_restore_fp_context)
192 EX ldc1 $f28, SC_FPREGS+224(a0) 211 EX ldc1 $f28, SC_FPREGS+224(a0)
193 EX ldc1 $f30, SC_FPREGS+240(a0) 212 EX ldc1 $f30, SC_FPREGS+240(a0)
194 ctc1 t1, fcr31 213 ctc1 t1, fcr31
214 .set pop
195 jr ra 215 jr ra
196 li v0, 0 # success 216 li v0, 0 # success
197 END(_restore_fp_context) 217 END(_restore_fp_context)
@@ -199,6 +219,8 @@ LEAF(_restore_fp_context)
199#ifdef CONFIG_MIPS32_COMPAT 219#ifdef CONFIG_MIPS32_COMPAT
200LEAF(_restore_fp_context32) 220LEAF(_restore_fp_context32)
201 /* Restore an o32 sigcontext. */ 221 /* Restore an o32 sigcontext. */
222 .set push
223 SET_HARDFLOAT
202 EX lw t1, SC32_FPC_CSR(a0) 224 EX lw t1, SC32_FPC_CSR(a0)
203 225
204 mfc0 t0, CP0_STATUS 226 mfc0 t0, CP0_STATUS
@@ -242,6 +264,7 @@ LEAF(_restore_fp_context32)
242 ctc1 t1, fcr31 264 ctc1 t1, fcr31
243 jr ra 265 jr ra
244 li v0, 0 # success 266 li v0, 0 # success
267 .set pop
245 END(_restore_fp_context32) 268 END(_restore_fp_context32)
246#endif 269#endif
247 270
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index 4c4ec1812420..64591e671878 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -22,6 +22,9 @@
22 22
23#include <asm/asmmacro.h> 23#include <asm/asmmacro.h>
24 24
25/* preprocessor replaces the fp in ".set fp=64" with $30 otherwise */
26#undef fp
27
25/* 28/*
26 * Offset to the current process status flags, the first 32 bytes of the 29 * Offset to the current process status flags, the first 32 bytes of the
27 * stack are not used. 30 * stack are not used.
@@ -65,8 +68,12 @@
65 bgtz a3, 1f 68 bgtz a3, 1f
66 69
67 /* Save 128b MSA vector context + scalar FP control & status. */ 70 /* Save 128b MSA vector context + scalar FP control & status. */
71 .set push
72 SET_HARDFLOAT
68 cfc1 t1, fcr31 73 cfc1 t1, fcr31
69 msa_save_all a0 74 msa_save_all a0
75 .set pop /* SET_HARDFLOAT */
76
70 sw t1, THREAD_FCR31(a0) 77 sw t1, THREAD_FCR31(a0)
71 b 2f 78 b 2f
72 79
@@ -161,6 +168,9 @@ LEAF(_init_msa_upper)
161 168
162#define FPU_DEFAULT 0x00000000 169#define FPU_DEFAULT 0x00000000
163 170
171 .set push
172 SET_HARDFLOAT
173
164LEAF(_init_fpu) 174LEAF(_init_fpu)
165 mfc0 t0, CP0_STATUS 175 mfc0 t0, CP0_STATUS
166 li t1, ST0_CU1 176 li t1, ST0_CU1
@@ -232,7 +242,8 @@ LEAF(_init_fpu)
232 242
233#ifdef CONFIG_CPU_MIPS32_R2 243#ifdef CONFIG_CPU_MIPS32_R2
234 .set push 244 .set push
235 .set mips64r2 245 .set mips32r2
246 .set fp=64
236 sll t0, t0, 5 # is Status.FR set? 247 sll t0, t0, 5 # is Status.FR set?
237 bgez t0, 1f # no: skip setting upper 32b 248 bgez t0, 1f # no: skip setting upper 32b
238 249
@@ -291,3 +302,5 @@ LEAF(_init_fpu)
291#endif 302#endif
292 jr ra 303 jr ra
293 END(_init_fpu) 304 END(_init_fpu)
305
306 .set pop /* SET_HARDFLOAT */
diff --git a/arch/mips/kernel/r6000_fpu.S b/arch/mips/kernel/r6000_fpu.S
index da0fbe46d83b..47077380c15c 100644
--- a/arch/mips/kernel/r6000_fpu.S
+++ b/arch/mips/kernel/r6000_fpu.S
@@ -18,6 +18,9 @@
18 18
19 .set noreorder 19 .set noreorder
20 .set mips2 20 .set mips2
21 .set push
22 SET_HARDFLOAT
23
21 /* Save floating point context */ 24 /* Save floating point context */
22 LEAF(_save_fp_context) 25 LEAF(_save_fp_context)
23 mfc0 t0,CP0_STATUS 26 mfc0 t0,CP0_STATUS
@@ -85,3 +88,5 @@
851: jr ra 881: jr ra
86 nop 89 nop
87 END(_restore_fp_context) 90 END(_restore_fp_context)
91
92 .set pop /* SET_HARDFLOAT */
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 744cd10ba599..00cad1005a16 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -579,3 +579,4 @@ EXPORT(sys_call_table)
579 PTR sys_seccomp 579 PTR sys_seccomp
580 PTR sys_getrandom 580 PTR sys_getrandom
581 PTR sys_memfd_create 581 PTR sys_memfd_create
582 PTR sys_bpf /* 4355 */
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 002b1bc09c38..5251565e344b 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -434,4 +434,5 @@ EXPORT(sys_call_table)
434 PTR sys_seccomp 434 PTR sys_seccomp
435 PTR sys_getrandom 435 PTR sys_getrandom
436 PTR sys_memfd_create 436 PTR sys_memfd_create
437 PTR sys_bpf /* 5315 */
437 .size sys_call_table,.-sys_call_table 438 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index ca6cbbe9805b..77e74398b828 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -427,4 +427,5 @@ EXPORT(sysn32_call_table)
427 PTR sys_seccomp 427 PTR sys_seccomp
428 PTR sys_getrandom 428 PTR sys_getrandom
429 PTR sys_memfd_create 429 PTR sys_memfd_create
430 PTR sys_bpf
430 .size sysn32_call_table,.-sysn32_call_table 431 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 9e10d11fbb84..6f8db9f728e8 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -564,4 +564,5 @@ EXPORT(sys32_call_table)
564 PTR sys_seccomp 564 PTR sys_seccomp
565 PTR sys_getrandom 565 PTR sys_getrandom
566 PTR sys_memfd_create 566 PTR sys_memfd_create
567 PTR sys_bpf /* 4355 */
567 .size sys32_call_table,.-sys32_call_table 568 .size sys32_call_table,.-sys32_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index b3b8f0d9d4a7..d21ec57b6e95 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -683,7 +683,8 @@ static void __init arch_mem_init(char **cmdline_p)
683 dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); 683 dma_contiguous_reserve(PFN_PHYS(max_low_pfn));
684 /* Tell bootmem about cma reserved memblock section */ 684 /* Tell bootmem about cma reserved memblock section */
685 for_each_memblock(reserved, reg) 685 for_each_memblock(reserved, reg)
686 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); 686 if (reg->size != 0)
687 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
687} 688}
688 689
689static void __init resource_init(void) 690static void __init resource_init(void)
diff --git a/arch/mips/lib/r3k_dump_tlb.c b/arch/mips/lib/r3k_dump_tlb.c
index 91615c2ef0cf..1ef365ab3cd3 100644
--- a/arch/mips/lib/r3k_dump_tlb.c
+++ b/arch/mips/lib/r3k_dump_tlb.c
@@ -34,7 +34,7 @@ static void dump_tlb(int first, int last)
34 entrylo0 = read_c0_entrylo0(); 34 entrylo0 = read_c0_entrylo0();
35 35
36 /* Unused entries have a virtual address of KSEG0. */ 36 /* Unused entries have a virtual address of KSEG0. */
37 if ((entryhi & 0xffffe000) != 0x80000000 37 if ((entryhi & 0xfffff000) != 0x80000000
38 && (entryhi & 0xfc0) == asid) { 38 && (entryhi & 0xfc0) == asid) {
39 /* 39 /*
40 * Only print entries in use 40 * Only print entries in use
@@ -43,7 +43,7 @@ static void dump_tlb(int first, int last)
43 43
44 printk("va=%08lx asid=%08lx" 44 printk("va=%08lx asid=%08lx"
45 " [pa=%06lx n=%d d=%d v=%d g=%d]", 45 " [pa=%06lx n=%d d=%d v=%d g=%d]",
46 (entryhi & 0xffffe000), 46 (entryhi & 0xfffff000),
47 entryhi & 0xfc0, 47 entryhi & 0xfc0,
48 entrylo0 & PAGE_MASK, 48 entrylo0 & PAGE_MASK,
49 (entrylo0 & (1 << 11)) ? 1 : 0, 49 (entrylo0 & (1 << 11)) ? 1 : 0,
diff --git a/arch/mips/lib/strnlen_user.S b/arch/mips/lib/strnlen_user.S
index f3af6995e2a6..7d12c0dded3d 100644
--- a/arch/mips/lib/strnlen_user.S
+++ b/arch/mips/lib/strnlen_user.S
@@ -40,9 +40,11 @@ FEXPORT(__strnlen_\func\()_nocheck_asm)
40.else 40.else
41 EX(lbe, t0, (v0), .Lfault\@) 41 EX(lbe, t0, (v0), .Lfault\@)
42.endif 42.endif
43 PTR_ADDIU v0, 1 43 .set noreorder
44 bnez t0, 1b 44 bnez t0, 1b
451: PTR_SUBU v0, a0 451: PTR_ADDIU v0, 1
46 .set reorder
47 PTR_SUBU v0, a0
46 jr ra 48 jr ra
47 END(__strnlen_\func\()_asm) 49 END(__strnlen_\func\()_asm)
48 50
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 51a0fde4bec1..cac529a405b8 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -584,11 +584,7 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
584 if (insn.i_format.rs == bc_op) { 584 if (insn.i_format.rs == bc_op) {
585 preempt_disable(); 585 preempt_disable();
586 if (is_fpu_owner()) 586 if (is_fpu_owner())
587 asm volatile( 587 fcr31 = read_32bit_cp1_register(CP1_STATUS);
588 ".set push\n"
589 "\t.set mips1\n"
590 "\tcfc1\t%0,$31\n"
591 "\t.set pop" : "=r" (fcr31));
592 else 588 else
593 fcr31 = current->thread.fpu.fcr31; 589 fcr31 = current->thread.fpu.fcr31;
594 preempt_enable(); 590 preempt_enable();
diff --git a/arch/mips/pci/msi-xlp.c b/arch/mips/pci/msi-xlp.c
index fa374fe3746b..f7ac3edda1b2 100644
--- a/arch/mips/pci/msi-xlp.c
+++ b/arch/mips/pci/msi-xlp.c
@@ -443,10 +443,8 @@ static int xlp_setup_msix(uint64_t lnkbase, int node, int link,
443 msg.data = 0xc00 | msixvec; 443 msg.data = 0xc00 | msixvec;
444 444
445 ret = irq_set_msi_desc(xirq, desc); 445 ret = irq_set_msi_desc(xirq, desc);
446 if (ret < 0) { 446 if (ret < 0)
447 destroy_irq(xirq);
448 return ret; 447 return ret;
449 }
450 448
451 write_msi_msg(xirq, &msg); 449 write_msi_msg(xirq, &msg);
452 return 0; 450 return 0;
diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
index a6774560afe3..493e72f64b35 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -70,39 +70,39 @@
70#define CPU_UNKNOWN (~((u32)0)) 70#define CPU_UNKNOWN (~((u32)0))
71 71
72/* Utility macros */ 72/* Utility macros */
73#define SKIP_TO_NEXT_CPU(reg_entry) \ 73#define SKIP_TO_NEXT_CPU(reg_entry) \
74({ \ 74({ \
75 while (reg_entry->reg_id != REG_ID("CPUEND")) \ 75 while (be64_to_cpu(reg_entry->reg_id) != REG_ID("CPUEND")) \
76 reg_entry++; \ 76 reg_entry++; \
77 reg_entry++; \ 77 reg_entry++; \
78}) 78})
79 79
80/* Kernel Dump section info */ 80/* Kernel Dump section info */
81struct fadump_section { 81struct fadump_section {
82 u32 request_flag; 82 __be32 request_flag;
83 u16 source_data_type; 83 __be16 source_data_type;
84 u16 error_flags; 84 __be16 error_flags;
85 u64 source_address; 85 __be64 source_address;
86 u64 source_len; 86 __be64 source_len;
87 u64 bytes_dumped; 87 __be64 bytes_dumped;
88 u64 destination_address; 88 __be64 destination_address;
89}; 89};
90 90
91/* ibm,configure-kernel-dump header. */ 91/* ibm,configure-kernel-dump header. */
92struct fadump_section_header { 92struct fadump_section_header {
93 u32 dump_format_version; 93 __be32 dump_format_version;
94 u16 dump_num_sections; 94 __be16 dump_num_sections;
95 u16 dump_status_flag; 95 __be16 dump_status_flag;
96 u32 offset_first_dump_section; 96 __be32 offset_first_dump_section;
97 97
98 /* Fields for disk dump option. */ 98 /* Fields for disk dump option. */
99 u32 dd_block_size; 99 __be32 dd_block_size;
100 u64 dd_block_offset; 100 __be64 dd_block_offset;
101 u64 dd_num_blocks; 101 __be64 dd_num_blocks;
102 u32 dd_offset_disk_path; 102 __be32 dd_offset_disk_path;
103 103
104 /* Maximum time allowed to prevent an automatic dump-reboot. */ 104 /* Maximum time allowed to prevent an automatic dump-reboot. */
105 u32 max_time_auto; 105 __be32 max_time_auto;
106}; 106};
107 107
108/* 108/*
@@ -174,15 +174,15 @@ static inline u64 str_to_u64(const char *str)
174 174
175/* Register save area header. */ 175/* Register save area header. */
176struct fadump_reg_save_area_header { 176struct fadump_reg_save_area_header {
177 u64 magic_number; 177 __be64 magic_number;
178 u32 version; 178 __be32 version;
179 u32 num_cpu_offset; 179 __be32 num_cpu_offset;
180}; 180};
181 181
182/* Register entry. */ 182/* Register entry. */
183struct fadump_reg_entry { 183struct fadump_reg_entry {
184 u64 reg_id; 184 __be64 reg_id;
185 u64 reg_value; 185 __be64 reg_value;
186}; 186};
187 187
188/* fadump crash info structure */ 188/* fadump crash info structure */
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index 623f2971ce0e..766b77d527ac 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -71,7 +71,7 @@ pte_t *huge_pte_offset_and_shift(struct mm_struct *mm,
71 71
72void flush_dcache_icache_hugepage(struct page *page); 72void flush_dcache_icache_hugepage(struct page *page);
73 73
74#if defined(CONFIG_PPC_MM_SLICES) || defined(CONFIG_PPC_SUBPAGE_PROT) 74#if defined(CONFIG_PPC_MM_SLICES)
75int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, 75int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
76 unsigned long len); 76 unsigned long len);
77#else 77#else
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 7d8a60068805..ce9577d693be 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -365,3 +365,4 @@ SYSCALL_SPU(renameat2)
365SYSCALL_SPU(seccomp) 365SYSCALL_SPU(seccomp)
366SYSCALL_SPU(getrandom) 366SYSCALL_SPU(getrandom)
367SYSCALL_SPU(memfd_create) 367SYSCALL_SPU(memfd_create)
368SYSCALL_SPU(bpf)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 4e9af3fd43e7..e0da021caa00 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
12#include <uapi/asm/unistd.h> 12#include <uapi/asm/unistd.h>
13 13
14 14
15#define __NR_syscalls 361 15#define __NR_syscalls 362
16 16
17#define __NR__exit __NR_exit 17#define __NR__exit __NR_exit
18#define NR_syscalls __NR_syscalls 18#define NR_syscalls __NR_syscalls
diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h
index 0688fc06e183..f55351f2e66e 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -383,5 +383,6 @@
383#define __NR_seccomp 358 383#define __NR_seccomp 358
384#define __NR_getrandom 359 384#define __NR_getrandom 359
385#define __NR_memfd_create 360 385#define __NR_memfd_create 360
386#define __NR_bpf 361
386 387
387#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 388#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 5bbd1bc8c3b0..0905c8da90f1 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -659,7 +659,13 @@ _GLOBAL(ret_from_except_lite)
6593: 6593:
660#endif 660#endif
661 bl save_nvgprs 661 bl save_nvgprs
662 /*
663 * Use a non volatile GPR to save and restore our thread_info flags
664 * across the call to restore_interrupts.
665 */
666 mr r30,r4
662 bl restore_interrupts 667 bl restore_interrupts
668 mr r4,r30
663 addi r3,r1,STACK_FRAME_OVERHEAD 669 addi r3,r1,STACK_FRAME_OVERHEAD
664 bl do_notify_resume 670 bl do_notify_resume
665 b ret_from_except 671 b ret_from_except
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 742694c1d852..26d091a1a54c 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -58,7 +58,7 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
58 const __be32 *sections; 58 const __be32 *sections;
59 int i, num_sections; 59 int i, num_sections;
60 int size; 60 int size;
61 const int *token; 61 const __be32 *token;
62 62
63 if (depth != 1 || strcmp(uname, "rtas") != 0) 63 if (depth != 1 || strcmp(uname, "rtas") != 0)
64 return 0; 64 return 0;
@@ -72,7 +72,7 @@ int __init early_init_dt_scan_fw_dump(unsigned long node,
72 return 1; 72 return 1;
73 73
74 fw_dump.fadump_supported = 1; 74 fw_dump.fadump_supported = 1;
75 fw_dump.ibm_configure_kernel_dump = *token; 75 fw_dump.ibm_configure_kernel_dump = be32_to_cpu(*token);
76 76
77 /* 77 /*
78 * The 'ibm,kernel-dump' rtas node is present only if there is 78 * The 'ibm,kernel-dump' rtas node is present only if there is
@@ -147,11 +147,11 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
147 memset(fdm, 0, sizeof(struct fadump_mem_struct)); 147 memset(fdm, 0, sizeof(struct fadump_mem_struct));
148 addr = addr & PAGE_MASK; 148 addr = addr & PAGE_MASK;
149 149
150 fdm->header.dump_format_version = 0x00000001; 150 fdm->header.dump_format_version = cpu_to_be32(0x00000001);
151 fdm->header.dump_num_sections = 3; 151 fdm->header.dump_num_sections = cpu_to_be16(3);
152 fdm->header.dump_status_flag = 0; 152 fdm->header.dump_status_flag = 0;
153 fdm->header.offset_first_dump_section = 153 fdm->header.offset_first_dump_section =
154 (u32)offsetof(struct fadump_mem_struct, cpu_state_data); 154 cpu_to_be32((u32)offsetof(struct fadump_mem_struct, cpu_state_data));
155 155
156 /* 156 /*
157 * Fields for disk dump option. 157 * Fields for disk dump option.
@@ -167,27 +167,27 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm,
167 167
168 /* Kernel dump sections */ 168 /* Kernel dump sections */
169 /* cpu state data section. */ 169 /* cpu state data section. */
170 fdm->cpu_state_data.request_flag = FADUMP_REQUEST_FLAG; 170 fdm->cpu_state_data.request_flag = cpu_to_be32(FADUMP_REQUEST_FLAG);
171 fdm->cpu_state_data.source_data_type = FADUMP_CPU_STATE_DATA; 171 fdm->cpu_state_data.source_data_type = cpu_to_be16(FADUMP_CPU_STATE_DATA);
172 fdm->cpu_state_data.source_address = 0; 172 fdm->cpu_state_data.source_address = 0;
173 fdm->cpu_state_data.source_len = fw_dump.cpu_state_data_size; 173 fdm->cpu_state_data.source_len = cpu_to_be64(fw_dump.cpu_state_data_size);
174 fdm->cpu_state_data.destination_address = addr; 174 fdm->cpu_state_data.destination_address = cpu_to_be64(addr);
175 addr += fw_dump.cpu_state_data_size; 175 addr += fw_dump.cpu_state_data_size;
176 176
177 /* hpte region section */ 177 /* hpte region section */
178 fdm->hpte_region.request_flag = FADUMP_REQUEST_FLAG; 178 fdm->hpte_region.request_flag = cpu_to_be32(FADUMP_REQUEST_FLAG);
179 fdm->hpte_region.source_data_type = FADUMP_HPTE_REGION; 179 fdm->hpte_region.source_data_type = cpu_to_be16(FADUMP_HPTE_REGION);
180 fdm->hpte_region.source_address = 0; 180 fdm->hpte_region.source_address = 0;
181 fdm->hpte_region.source_len = fw_dump.hpte_region_size; 181 fdm->hpte_region.source_len = cpu_to_be64(fw_dump.hpte_region_size);
182 fdm->hpte_region.destination_address = addr; 182 fdm->hpte_region.destination_address = cpu_to_be64(addr);
183 addr += fw_dump.hpte_region_size; 183 addr += fw_dump.hpte_region_size;
184 184
185 /* RMA region section */ 185 /* RMA region section */
186 fdm->rmr_region.request_flag = FADUMP_REQUEST_FLAG; 186 fdm->rmr_region.request_flag = cpu_to_be32(FADUMP_REQUEST_FLAG);
187 fdm->rmr_region.source_data_type = FADUMP_REAL_MODE_REGION; 187 fdm->rmr_region.source_data_type = cpu_to_be16(FADUMP_REAL_MODE_REGION);
188 fdm->rmr_region.source_address = RMA_START; 188 fdm->rmr_region.source_address = cpu_to_be64(RMA_START);
189 fdm->rmr_region.source_len = fw_dump.boot_memory_size; 189 fdm->rmr_region.source_len = cpu_to_be64(fw_dump.boot_memory_size);
190 fdm->rmr_region.destination_address = addr; 190 fdm->rmr_region.destination_address = cpu_to_be64(addr);
191 addr += fw_dump.boot_memory_size; 191 addr += fw_dump.boot_memory_size;
192 192
193 return addr; 193 return addr;
@@ -272,7 +272,7 @@ int __init fadump_reserve_mem(void)
272 * first kernel. 272 * first kernel.
273 */ 273 */
274 if (fdm_active) 274 if (fdm_active)
275 fw_dump.boot_memory_size = fdm_active->rmr_region.source_len; 275 fw_dump.boot_memory_size = be64_to_cpu(fdm_active->rmr_region.source_len);
276 else 276 else
277 fw_dump.boot_memory_size = fadump_calculate_reserve_size(); 277 fw_dump.boot_memory_size = fadump_calculate_reserve_size();
278 278
@@ -314,8 +314,8 @@ int __init fadump_reserve_mem(void)
314 (unsigned long)(base >> 20)); 314 (unsigned long)(base >> 20));
315 315
316 fw_dump.fadumphdr_addr = 316 fw_dump.fadumphdr_addr =
317 fdm_active->rmr_region.destination_address + 317 be64_to_cpu(fdm_active->rmr_region.destination_address) +
318 fdm_active->rmr_region.source_len; 318 be64_to_cpu(fdm_active->rmr_region.source_len);
319 pr_debug("fadumphdr_addr = %p\n", 319 pr_debug("fadumphdr_addr = %p\n",
320 (void *) fw_dump.fadumphdr_addr); 320 (void *) fw_dump.fadumphdr_addr);
321 } else { 321 } else {
@@ -472,9 +472,9 @@ fadump_read_registers(struct fadump_reg_entry *reg_entry, struct pt_regs *regs)
472{ 472{
473 memset(regs, 0, sizeof(struct pt_regs)); 473 memset(regs, 0, sizeof(struct pt_regs));
474 474
475 while (reg_entry->reg_id != REG_ID("CPUEND")) { 475 while (be64_to_cpu(reg_entry->reg_id) != REG_ID("CPUEND")) {
476 fadump_set_regval(regs, reg_entry->reg_id, 476 fadump_set_regval(regs, be64_to_cpu(reg_entry->reg_id),
477 reg_entry->reg_value); 477 be64_to_cpu(reg_entry->reg_value));
478 reg_entry++; 478 reg_entry++;
479 } 479 }
480 reg_entry++; 480 reg_entry++;
@@ -603,20 +603,20 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
603 if (!fdm->cpu_state_data.bytes_dumped) 603 if (!fdm->cpu_state_data.bytes_dumped)
604 return -EINVAL; 604 return -EINVAL;
605 605
606 addr = fdm->cpu_state_data.destination_address; 606 addr = be64_to_cpu(fdm->cpu_state_data.destination_address);
607 vaddr = __va(addr); 607 vaddr = __va(addr);
608 608
609 reg_header = vaddr; 609 reg_header = vaddr;
610 if (reg_header->magic_number != REGSAVE_AREA_MAGIC) { 610 if (be64_to_cpu(reg_header->magic_number) != REGSAVE_AREA_MAGIC) {
611 printk(KERN_ERR "Unable to read register save area.\n"); 611 printk(KERN_ERR "Unable to read register save area.\n");
612 return -ENOENT; 612 return -ENOENT;
613 } 613 }
614 pr_debug("--------CPU State Data------------\n"); 614 pr_debug("--------CPU State Data------------\n");
615 pr_debug("Magic Number: %llx\n", reg_header->magic_number); 615 pr_debug("Magic Number: %llx\n", be64_to_cpu(reg_header->magic_number));
616 pr_debug("NumCpuOffset: %x\n", reg_header->num_cpu_offset); 616 pr_debug("NumCpuOffset: %x\n", be32_to_cpu(reg_header->num_cpu_offset));
617 617
618 vaddr += reg_header->num_cpu_offset; 618 vaddr += be32_to_cpu(reg_header->num_cpu_offset);
619 num_cpus = *((u32 *)(vaddr)); 619 num_cpus = be32_to_cpu(*((__be32 *)(vaddr)));
620 pr_debug("NumCpus : %u\n", num_cpus); 620 pr_debug("NumCpus : %u\n", num_cpus);
621 vaddr += sizeof(u32); 621 vaddr += sizeof(u32);
622 reg_entry = (struct fadump_reg_entry *)vaddr; 622 reg_entry = (struct fadump_reg_entry *)vaddr;
@@ -639,13 +639,13 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
639 fdh = __va(fw_dump.fadumphdr_addr); 639 fdh = __va(fw_dump.fadumphdr_addr);
640 640
641 for (i = 0; i < num_cpus; i++) { 641 for (i = 0; i < num_cpus; i++) {
642 if (reg_entry->reg_id != REG_ID("CPUSTRT")) { 642 if (be64_to_cpu(reg_entry->reg_id) != REG_ID("CPUSTRT")) {
643 printk(KERN_ERR "Unable to read CPU state data\n"); 643 printk(KERN_ERR "Unable to read CPU state data\n");
644 rc = -ENOENT; 644 rc = -ENOENT;
645 goto error_out; 645 goto error_out;
646 } 646 }
647 /* Lower 4 bytes of reg_value contains logical cpu id */ 647 /* Lower 4 bytes of reg_value contains logical cpu id */
648 cpu = reg_entry->reg_value & FADUMP_CPU_ID_MASK; 648 cpu = be64_to_cpu(reg_entry->reg_value) & FADUMP_CPU_ID_MASK;
649 if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) { 649 if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) {
650 SKIP_TO_NEXT_CPU(reg_entry); 650 SKIP_TO_NEXT_CPU(reg_entry);
651 continue; 651 continue;
@@ -692,7 +692,7 @@ static int __init process_fadump(const struct fadump_mem_struct *fdm_active)
692 return -EINVAL; 692 return -EINVAL;
693 693
694 /* Check if the dump data is valid. */ 694 /* Check if the dump data is valid. */
695 if ((fdm_active->header.dump_status_flag == FADUMP_ERROR_FLAG) || 695 if ((be16_to_cpu(fdm_active->header.dump_status_flag) == FADUMP_ERROR_FLAG) ||
696 (fdm_active->cpu_state_data.error_flags != 0) || 696 (fdm_active->cpu_state_data.error_flags != 0) ||
697 (fdm_active->rmr_region.error_flags != 0)) { 697 (fdm_active->rmr_region.error_flags != 0)) {
698 printk(KERN_ERR "Dump taken by platform is not valid\n"); 698 printk(KERN_ERR "Dump taken by platform is not valid\n");
@@ -828,7 +828,7 @@ static void fadump_setup_crash_memory_ranges(void)
828static inline unsigned long fadump_relocate(unsigned long paddr) 828static inline unsigned long fadump_relocate(unsigned long paddr)
829{ 829{
830 if (paddr > RMA_START && paddr < fw_dump.boot_memory_size) 830 if (paddr > RMA_START && paddr < fw_dump.boot_memory_size)
831 return fdm.rmr_region.destination_address + paddr; 831 return be64_to_cpu(fdm.rmr_region.destination_address) + paddr;
832 else 832 else
833 return paddr; 833 return paddr;
834} 834}
@@ -902,7 +902,7 @@ static int fadump_create_elfcore_headers(char *bufp)
902 * to the specified destination_address. Hence set 902 * to the specified destination_address. Hence set
903 * the correct offset. 903 * the correct offset.
904 */ 904 */
905 phdr->p_offset = fdm.rmr_region.destination_address; 905 phdr->p_offset = be64_to_cpu(fdm.rmr_region.destination_address);
906 } 906 }
907 907
908 phdr->p_paddr = mbase; 908 phdr->p_paddr = mbase;
@@ -951,7 +951,7 @@ static void register_fadump(void)
951 951
952 fadump_setup_crash_memory_ranges(); 952 fadump_setup_crash_memory_ranges();
953 953
954 addr = fdm.rmr_region.destination_address + fdm.rmr_region.source_len; 954 addr = be64_to_cpu(fdm.rmr_region.destination_address) + be64_to_cpu(fdm.rmr_region.source_len);
955 /* Initialize fadump crash info header. */ 955 /* Initialize fadump crash info header. */
956 addr = init_fadump_header(addr); 956 addr = init_fadump_header(addr);
957 vaddr = __va(addr); 957 vaddr = __va(addr);
@@ -1023,7 +1023,7 @@ void fadump_cleanup(void)
1023 /* Invalidate the registration only if dump is active. */ 1023 /* Invalidate the registration only if dump is active. */
1024 if (fw_dump.dump_active) { 1024 if (fw_dump.dump_active) {
1025 init_fadump_mem_struct(&fdm, 1025 init_fadump_mem_struct(&fdm,
1026 fdm_active->cpu_state_data.destination_address); 1026 be64_to_cpu(fdm_active->cpu_state_data.destination_address));
1027 fadump_invalidate_dump(&fdm); 1027 fadump_invalidate_dump(&fdm);
1028 } 1028 }
1029} 1029}
@@ -1063,7 +1063,7 @@ static void fadump_invalidate_release_mem(void)
1063 return; 1063 return;
1064 } 1064 }
1065 1065
1066 destination_address = fdm_active->cpu_state_data.destination_address; 1066 destination_address = be64_to_cpu(fdm_active->cpu_state_data.destination_address);
1067 fadump_cleanup(); 1067 fadump_cleanup();
1068 mutex_unlock(&fadump_mutex); 1068 mutex_unlock(&fadump_mutex);
1069 1069
@@ -1183,31 +1183,31 @@ static int fadump_region_show(struct seq_file *m, void *private)
1183 seq_printf(m, 1183 seq_printf(m,
1184 "CPU : [%#016llx-%#016llx] %#llx bytes, " 1184 "CPU : [%#016llx-%#016llx] %#llx bytes, "
1185 "Dumped: %#llx\n", 1185 "Dumped: %#llx\n",
1186 fdm_ptr->cpu_state_data.destination_address, 1186 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address),
1187 fdm_ptr->cpu_state_data.destination_address + 1187 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address) +
1188 fdm_ptr->cpu_state_data.source_len - 1, 1188 be64_to_cpu(fdm_ptr->cpu_state_data.source_len) - 1,
1189 fdm_ptr->cpu_state_data.source_len, 1189 be64_to_cpu(fdm_ptr->cpu_state_data.source_len),
1190 fdm_ptr->cpu_state_data.bytes_dumped); 1190 be64_to_cpu(fdm_ptr->cpu_state_data.bytes_dumped));
1191 seq_printf(m, 1191 seq_printf(m,
1192 "HPTE: [%#016llx-%#016llx] %#llx bytes, " 1192 "HPTE: [%#016llx-%#016llx] %#llx bytes, "
1193 "Dumped: %#llx\n", 1193 "Dumped: %#llx\n",
1194 fdm_ptr->hpte_region.destination_address, 1194 be64_to_cpu(fdm_ptr->hpte_region.destination_address),
1195 fdm_ptr->hpte_region.destination_address + 1195 be64_to_cpu(fdm_ptr->hpte_region.destination_address) +
1196 fdm_ptr->hpte_region.source_len - 1, 1196 be64_to_cpu(fdm_ptr->hpte_region.source_len) - 1,
1197 fdm_ptr->hpte_region.source_len, 1197 be64_to_cpu(fdm_ptr->hpte_region.source_len),
1198 fdm_ptr->hpte_region.bytes_dumped); 1198 be64_to_cpu(fdm_ptr->hpte_region.bytes_dumped));
1199 seq_printf(m, 1199 seq_printf(m,
1200 "DUMP: [%#016llx-%#016llx] %#llx bytes, " 1200 "DUMP: [%#016llx-%#016llx] %#llx bytes, "
1201 "Dumped: %#llx\n", 1201 "Dumped: %#llx\n",
1202 fdm_ptr->rmr_region.destination_address, 1202 be64_to_cpu(fdm_ptr->rmr_region.destination_address),
1203 fdm_ptr->rmr_region.destination_address + 1203 be64_to_cpu(fdm_ptr->rmr_region.destination_address) +
1204 fdm_ptr->rmr_region.source_len - 1, 1204 be64_to_cpu(fdm_ptr->rmr_region.source_len) - 1,
1205 fdm_ptr->rmr_region.source_len, 1205 be64_to_cpu(fdm_ptr->rmr_region.source_len),
1206 fdm_ptr->rmr_region.bytes_dumped); 1206 be64_to_cpu(fdm_ptr->rmr_region.bytes_dumped));
1207 1207
1208 if (!fdm_active || 1208 if (!fdm_active ||
1209 (fw_dump.reserve_dump_area_start == 1209 (fw_dump.reserve_dump_area_start ==
1210 fdm_ptr->cpu_state_data.destination_address)) 1210 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address)))
1211 goto out; 1211 goto out;
1212 1212
1213 /* Dump is active. Show reserved memory region. */ 1213 /* Dump is active. Show reserved memory region. */
@@ -1215,10 +1215,10 @@ static int fadump_region_show(struct seq_file *m, void *private)
1215 " : [%#016llx-%#016llx] %#llx bytes, " 1215 " : [%#016llx-%#016llx] %#llx bytes, "
1216 "Dumped: %#llx\n", 1216 "Dumped: %#llx\n",
1217 (unsigned long long)fw_dump.reserve_dump_area_start, 1217 (unsigned long long)fw_dump.reserve_dump_area_start,
1218 fdm_ptr->cpu_state_data.destination_address - 1, 1218 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address) - 1,
1219 fdm_ptr->cpu_state_data.destination_address - 1219 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address) -
1220 fw_dump.reserve_dump_area_start, 1220 fw_dump.reserve_dump_area_start,
1221 fdm_ptr->cpu_state_data.destination_address - 1221 be64_to_cpu(fdm_ptr->cpu_state_data.destination_address) -
1222 fw_dump.reserve_dump_area_start); 1222 fw_dump.reserve_dump_area_start);
1223out: 1223out:
1224 if (fdm_active) 1224 if (fdm_active)
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index 0f9939e693df..5a236f082c78 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -99,8 +99,6 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
99 u64 vsid; 99 u64 vsid;
100 int psize, ssize; 100 int psize, ssize;
101 101
102 slb->esid = (ea & ESID_MASK) | SLB_ESID_V;
103
104 switch (REGION_ID(ea)) { 102 switch (REGION_ID(ea)) {
105 case USER_REGION_ID: 103 case USER_REGION_ID:
106 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); 104 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea);
@@ -133,6 +131,7 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
133 vsid |= mmu_psize_defs[psize].sllp | 131 vsid |= mmu_psize_defs[psize].sllp |
134 ((ssize == MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0); 132 ((ssize == MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0);
135 133
134 slb->esid = (ea & (ssize == MMU_SEGSIZE_1T ? ESID_MASK_1T : ESID_MASK)) | SLB_ESID_V;
136 slb->vsid = vsid; 135 slb->vsid = vsid;
137 136
138 return 0; 137 return 0;
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index cad68ff8eca5..415a51b028b9 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -103,7 +103,7 @@ unsigned long __max_low_memory = MAX_LOW_MEM;
103/* 103/*
104 * Check for command-line options that affect what MMU_init will do. 104 * Check for command-line options that affect what MMU_init will do.
105 */ 105 */
106void MMU_setup(void) 106void __init MMU_setup(void)
107{ 107{
108 /* Check for nobats option (used in mapin_ram). */ 108 /* Check for nobats option (used in mapin_ram). */
109 if (strstr(boot_command_line, "nobats")) { 109 if (strstr(boot_command_line, "nobats")) {
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index e5236c24dc07..b9d1dfdbe5bb 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1509,11 +1509,14 @@ static int update_cpu_topology(void *data)
1509 cpu = smp_processor_id(); 1509 cpu = smp_processor_id();
1510 1510
1511 for (update = data; update; update = update->next) { 1511 for (update = data; update; update = update->next) {
1512 int new_nid = update->new_nid;
1512 if (cpu != update->cpu) 1513 if (cpu != update->cpu)
1513 continue; 1514 continue;
1514 1515
1515 unmap_cpu_from_node(update->cpu); 1516 unmap_cpu_from_node(cpu);
1516 map_cpu_to_node(update->cpu, update->new_nid); 1517 map_cpu_to_node(cpu, new_nid);
1518 set_cpu_numa_node(cpu, new_nid);
1519 set_cpu_numa_mem(cpu, local_memory_node(new_nid));
1517 vdso_getcpu_init(); 1520 vdso_getcpu_init();
1518 } 1521 }
1519 1522
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index 8d7bda94d196..ded0ea1afde4 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -682,6 +682,7 @@ void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
682 slice_convert(mm, mask, psize); 682 slice_convert(mm, mask, psize);
683} 683}
684 684
685#ifdef CONFIG_HUGETLB_PAGE
685/* 686/*
686 * is_hugepage_only_range() is used by generic code to verify whether 687 * is_hugepage_only_range() is used by generic code to verify whether
687 * a normal mmap mapping (non hugetlbfs) is valid on a given area. 688 * a normal mmap mapping (non hugetlbfs) is valid on a given area.
@@ -726,4 +727,4 @@ int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
726#endif 727#endif
727 return !slice_check_fit(mask, available); 728 return !slice_check_fit(mask, available);
728} 729}
729 730#endif
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 6c8710dd90c9..dba34088da28 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -417,11 +417,6 @@ static int h_24x7_event_add(struct perf_event *event, int flags)
417 return 0; 417 return 0;
418} 418}
419 419
420static int h_24x7_event_idx(struct perf_event *event)
421{
422 return 0;
423}
424
425static struct pmu h_24x7_pmu = { 420static struct pmu h_24x7_pmu = {
426 .task_ctx_nr = perf_invalid_context, 421 .task_ctx_nr = perf_invalid_context,
427 422
@@ -433,7 +428,6 @@ static struct pmu h_24x7_pmu = {
433 .start = h_24x7_event_start, 428 .start = h_24x7_event_start,
434 .stop = h_24x7_event_stop, 429 .stop = h_24x7_event_stop,
435 .read = h_24x7_event_update, 430 .read = h_24x7_event_update,
436 .event_idx = h_24x7_event_idx,
437}; 431};
438 432
439static int hv_24x7_init(void) 433static int hv_24x7_init(void)
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 15fc76c93022..a051fe946c63 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -246,11 +246,6 @@ static int h_gpci_event_init(struct perf_event *event)
246 return 0; 246 return 0;
247} 247}
248 248
249static int h_gpci_event_idx(struct perf_event *event)
250{
251 return 0;
252}
253
254static struct pmu h_gpci_pmu = { 249static struct pmu h_gpci_pmu = {
255 .task_ctx_nr = perf_invalid_context, 250 .task_ctx_nr = perf_invalid_context,
256 251
@@ -262,7 +257,6 @@ static struct pmu h_gpci_pmu = {
262 .start = h_gpci_event_start, 257 .start = h_gpci_event_start,
263 .stop = h_gpci_event_stop, 258 .stop = h_gpci_event_stop,
264 .read = h_gpci_event_update, 259 .read = h_gpci_event_update,
265 .event_idx = h_gpci_event_idx,
266}; 260};
267 261
268static int hv_gpci_init(void) 262static int hv_gpci_init(void)
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c
index dd2c285ad170..e4169d68cb32 100644
--- a/arch/powerpc/platforms/powernv/opal-lpc.c
+++ b/arch/powerpc/platforms/powernv/opal-lpc.c
@@ -191,7 +191,6 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
191{ 191{
192 struct lpc_debugfs_entry *lpc = filp->private_data; 192 struct lpc_debugfs_entry *lpc = filp->private_data;
193 u32 data, pos, len, todo; 193 u32 data, pos, len, todo;
194 __be32 bedata;
195 int rc; 194 int rc;
196 195
197 if (!access_ok(VERIFY_WRITE, ubuf, count)) 196 if (!access_ok(VERIFY_WRITE, ubuf, count))
@@ -214,18 +213,57 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
214 len = 2; 213 len = 2;
215 } 214 }
216 rc = opal_lpc_read(opal_lpc_chip_id, lpc->lpc_type, pos, 215 rc = opal_lpc_read(opal_lpc_chip_id, lpc->lpc_type, pos,
217 &bedata, len); 216 &data, len);
218 if (rc) 217 if (rc)
219 return -ENXIO; 218 return -ENXIO;
220 data = be32_to_cpu(bedata); 219
220 /*
221 * Now there is some trickery with the data returned by OPAL
222 * as it's the desired data right justified in a 32-bit BE
223 * word.
224 *
225 * This is a very bad interface and I'm to blame for it :-(
226 *
227 * So we can't just apply a 32-bit swap to what comes from OPAL,
228 * because user space expects the *bytes* to be in their proper
229 * respective positions (ie, LPC position).
230 *
231 * So what we really want to do here is to shift data right
232 * appropriately on a LE kernel.
233 *
234 * IE. If the LPC transaction has bytes B0, B1, B2 and B3 in that
235 * order, we have in memory written to by OPAL at the "data"
236 * pointer:
237 *
238 * Bytes: OPAL "data" LE "data"
239 * 32-bit: B0 B1 B2 B3 B0B1B2B3 B3B2B1B0
240 * 16-bit: B0 B1 0000B0B1 B1B00000
241 * 8-bit: B0 000000B0 B0000000
242 *
243 * So a BE kernel will have the leftmost of the above in the MSB
244 * and rightmost in the LSB and can just then "cast" the u32 "data"
245 * down to the appropriate quantity and write it.
246 *
247 * However, an LE kernel can't. It doesn't need to swap because a
248 * load from data followed by a store to user are going to preserve
249 * the byte ordering which is the wire byte order which is what the
250 * user wants, but in order to "crop" to the right size, we need to
251 * shift right first.
252 */
221 switch(len) { 253 switch(len) {
222 case 4: 254 case 4:
223 rc = __put_user((u32)data, (u32 __user *)ubuf); 255 rc = __put_user((u32)data, (u32 __user *)ubuf);
224 break; 256 break;
225 case 2: 257 case 2:
258#ifdef __LITTLE_ENDIAN__
259 data >>= 16;
260#endif
226 rc = __put_user((u16)data, (u16 __user *)ubuf); 261 rc = __put_user((u16)data, (u16 __user *)ubuf);
227 break; 262 break;
228 default: 263 default:
264#ifdef __LITTLE_ENDIAN__
265 data >>= 24;
266#endif
229 rc = __put_user((u8)data, (u8 __user *)ubuf); 267 rc = __put_user((u8)data, (u8 __user *)ubuf);
230 break; 268 break;
231 } 269 }
@@ -265,12 +303,31 @@ static ssize_t lpc_debug_write(struct file *filp, const char __user *ubuf,
265 else if (todo > 1 && (pos & 1) == 0) 303 else if (todo > 1 && (pos & 1) == 0)
266 len = 2; 304 len = 2;
267 } 305 }
306
307 /*
308 * Similarly to the read case, we have some trickery here but
309 * it's different to handle. We need to pass the value to OPAL in
310 * a register whose layout depends on the access size. We want
311 * to reproduce the memory layout of the user, however we aren't
312 * doing a load from user and a store to another memory location
313 * which would achieve that. Here we pass the value to OPAL via
314 * a register which is expected to contain the "BE" interpretation
315 * of the byte sequence. IE: for a 32-bit access, byte 0 should be
316 * in the MSB. So here we *do* need to byteswap on LE.
317 *
318 * User bytes: LE "data" OPAL "data"
319 * 32-bit: B0 B1 B2 B3 B3B2B1B0 B0B1B2B3
320 * 16-bit: B0 B1 0000B1B0 0000B0B1
321 * 8-bit: B0 000000B0 000000B0
322 */
268 switch(len) { 323 switch(len) {
269 case 4: 324 case 4:
270 rc = __get_user(data, (u32 __user *)ubuf); 325 rc = __get_user(data, (u32 __user *)ubuf);
326 data = cpu_to_be32(data);
271 break; 327 break;
272 case 2: 328 case 2:
273 rc = __get_user(data, (u16 __user *)ubuf); 329 rc = __get_user(data, (u16 __user *)ubuf);
330 data = cpu_to_be16(data);
274 break; 331 break;
275 default: 332 default:
276 rc = __get_user(data, (u8 __user *)ubuf); 333 rc = __get_user(data, (u8 __user *)ubuf);
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index e9e2450c1fdd..feb549aa3eea 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -58,7 +58,7 @@ END_FTR_SECTION(0, 1); \
58 */ 58 */
59 59
60#define OPAL_CALL(name, token) \ 60#define OPAL_CALL(name, token) \
61 _GLOBAL(name); \ 61 _GLOBAL_TOC(name); \
62 mflr r0; \ 62 mflr r0; \
63 std r0,16(r1); \ 63 std r0,16(r1); \
64 li r0,token; \ 64 li r0,token; \
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 6ad83bd11fe2..c22bb1b4beb8 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -382,7 +382,7 @@ static int dlpar_online_cpu(struct device_node *dn)
382 BUG_ON(get_cpu_current_state(cpu) 382 BUG_ON(get_cpu_current_state(cpu)
383 != CPU_STATE_OFFLINE); 383 != CPU_STATE_OFFLINE);
384 cpu_maps_update_done(); 384 cpu_maps_update_done();
385 rc = cpu_up(cpu); 385 rc = device_online(get_cpu_device(cpu));
386 if (rc) 386 if (rc)
387 goto out; 387 goto out;
388 cpu_maps_update_begin(); 388 cpu_maps_update_begin();
@@ -467,7 +467,7 @@ static int dlpar_offline_cpu(struct device_node *dn)
467 if (get_cpu_current_state(cpu) == CPU_STATE_ONLINE) { 467 if (get_cpu_current_state(cpu) == CPU_STATE_ONLINE) {
468 set_preferred_offline_state(cpu, CPU_STATE_OFFLINE); 468 set_preferred_offline_state(cpu, CPU_STATE_OFFLINE);
469 cpu_maps_update_done(); 469 cpu_maps_update_done();
470 rc = cpu_down(cpu); 470 rc = device_offline(get_cpu_device(cpu));
471 if (rc) 471 if (rc)
472 goto out; 472 goto out;
473 cpu_maps_update_begin(); 473 cpu_maps_update_begin();
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 8c509d5397c6..f6880d2a40fb 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -43,6 +43,7 @@
43#include <asm/trace.h> 43#include <asm/trace.h>
44#include <asm/firmware.h> 44#include <asm/firmware.h>
45#include <asm/plpar_wrappers.h> 45#include <asm/plpar_wrappers.h>
46#include <asm/fadump.h>
46 47
47#include "pseries.h" 48#include "pseries.h"
48 49
@@ -247,8 +248,17 @@ static void pSeries_lpar_hptab_clear(void)
247 } 248 }
248 249
249#ifdef __LITTLE_ENDIAN__ 250#ifdef __LITTLE_ENDIAN__
250 /* Reset exceptions to big endian */ 251 /*
251 if (firmware_has_feature(FW_FEATURE_SET_MODE)) { 252 * Reset exceptions to big endian.
253 *
254 * FIXME this is a hack for kexec, we need to reset the exception
255 * endian before starting the new kernel and this is a convenient place
256 * to do it.
257 *
258 * This is also called on boot when a fadump happens. In that case we
259 * must not change the exception endian mode.
260 */
261 if (firmware_has_feature(FW_FEATURE_SET_MODE) && !is_fadump_active()) {
252 long rc; 262 long rc;
253 263
254 rc = pseries_big_endian_exceptions(); 264 rc = pseries_big_endian_exceptions();
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig
index 9d94fdd9f525..9432d0f202ef 100644
--- a/arch/s390/configs/default_defconfig
+++ b/arch/s390/configs/default_defconfig
@@ -35,7 +35,6 @@ CONFIG_MODULE_UNLOAD=y
35CONFIG_MODULE_FORCE_UNLOAD=y 35CONFIG_MODULE_FORCE_UNLOAD=y
36CONFIG_MODVERSIONS=y 36CONFIG_MODVERSIONS=y
37CONFIG_MODULE_SRCVERSION_ALL=y 37CONFIG_MODULE_SRCVERSION_ALL=y
38CONFIG_BLK_DEV_INTEGRITY=y
39CONFIG_BLK_DEV_THROTTLING=y 38CONFIG_BLK_DEV_THROTTLING=y
40CONFIG_PARTITION_ADVANCED=y 39CONFIG_PARTITION_ADVANCED=y
41CONFIG_IBM_PARTITION=y 40CONFIG_IBM_PARTITION=y
@@ -245,6 +244,7 @@ CONFIG_NF_TABLES_IPV4=m
245CONFIG_NFT_CHAIN_ROUTE_IPV4=m 244CONFIG_NFT_CHAIN_ROUTE_IPV4=m
246CONFIG_NFT_CHAIN_NAT_IPV4=m 245CONFIG_NFT_CHAIN_NAT_IPV4=m
247CONFIG_NF_TABLES_ARP=m 246CONFIG_NF_TABLES_ARP=m
247CONFIG_NF_NAT_IPV4=m
248CONFIG_IP_NF_IPTABLES=m 248CONFIG_IP_NF_IPTABLES=m
249CONFIG_IP_NF_MATCH_AH=m 249CONFIG_IP_NF_MATCH_AH=m
250CONFIG_IP_NF_MATCH_ECN=m 250CONFIG_IP_NF_MATCH_ECN=m
@@ -252,11 +252,6 @@ CONFIG_IP_NF_MATCH_RPFILTER=m
252CONFIG_IP_NF_MATCH_TTL=m 252CONFIG_IP_NF_MATCH_TTL=m
253CONFIG_IP_NF_FILTER=m 253CONFIG_IP_NF_FILTER=m
254CONFIG_IP_NF_TARGET_REJECT=m 254CONFIG_IP_NF_TARGET_REJECT=m
255CONFIG_IP_NF_TARGET_ULOG=m
256CONFIG_NF_NAT_IPV4=m
257CONFIG_IP_NF_TARGET_MASQUERADE=m
258CONFIG_IP_NF_TARGET_NETMAP=m
259CONFIG_IP_NF_TARGET_REDIRECT=m
260CONFIG_IP_NF_MANGLE=m 255CONFIG_IP_NF_MANGLE=m
261CONFIG_IP_NF_TARGET_CLUSTERIP=m 256CONFIG_IP_NF_TARGET_CLUSTERIP=m
262CONFIG_IP_NF_TARGET_ECN=m 257CONFIG_IP_NF_TARGET_ECN=m
@@ -270,6 +265,7 @@ CONFIG_NF_CONNTRACK_IPV6=m
270CONFIG_NF_TABLES_IPV6=m 265CONFIG_NF_TABLES_IPV6=m
271CONFIG_NFT_CHAIN_ROUTE_IPV6=m 266CONFIG_NFT_CHAIN_ROUTE_IPV6=m
272CONFIG_NFT_CHAIN_NAT_IPV6=m 267CONFIG_NFT_CHAIN_NAT_IPV6=m
268CONFIG_NF_NAT_IPV6=m
273CONFIG_IP6_NF_IPTABLES=m 269CONFIG_IP6_NF_IPTABLES=m
274CONFIG_IP6_NF_MATCH_AH=m 270CONFIG_IP6_NF_MATCH_AH=m
275CONFIG_IP6_NF_MATCH_EUI64=m 271CONFIG_IP6_NF_MATCH_EUI64=m
@@ -286,9 +282,6 @@ CONFIG_IP6_NF_TARGET_REJECT=m
286CONFIG_IP6_NF_MANGLE=m 282CONFIG_IP6_NF_MANGLE=m
287CONFIG_IP6_NF_RAW=m 283CONFIG_IP6_NF_RAW=m
288CONFIG_IP6_NF_SECURITY=m 284CONFIG_IP6_NF_SECURITY=m
289CONFIG_NF_NAT_IPV6=m
290CONFIG_IP6_NF_TARGET_MASQUERADE=m
291CONFIG_IP6_NF_TARGET_NPT=m
292CONFIG_NF_TABLES_BRIDGE=m 285CONFIG_NF_TABLES_BRIDGE=m
293CONFIG_NET_SCTPPROBE=m 286CONFIG_NET_SCTPPROBE=m
294CONFIG_RDS=m 287CONFIG_RDS=m
@@ -374,14 +367,13 @@ CONFIG_BLK_DEV_SR=m
374CONFIG_CHR_DEV_SG=y 367CONFIG_CHR_DEV_SG=y
375CONFIG_CHR_DEV_SCH=m 368CONFIG_CHR_DEV_SCH=m
376CONFIG_SCSI_ENCLOSURE=m 369CONFIG_SCSI_ENCLOSURE=m
377CONFIG_SCSI_MULTI_LUN=y
378CONFIG_SCSI_CONSTANTS=y 370CONFIG_SCSI_CONSTANTS=y
379CONFIG_SCSI_LOGGING=y 371CONFIG_SCSI_LOGGING=y
380CONFIG_SCSI_SPI_ATTRS=m 372CONFIG_SCSI_SPI_ATTRS=m
373CONFIG_SCSI_FC_ATTRS=y
381CONFIG_SCSI_SAS_LIBSAS=m 374CONFIG_SCSI_SAS_LIBSAS=m
382CONFIG_SCSI_SRP_ATTRS=m 375CONFIG_SCSI_SRP_ATTRS=m
383CONFIG_ISCSI_TCP=m 376CONFIG_ISCSI_TCP=m
384CONFIG_LIBFCOE=m
385CONFIG_SCSI_DEBUG=m 377CONFIG_SCSI_DEBUG=m
386CONFIG_ZFCP=y 378CONFIG_ZFCP=y
387CONFIG_SCSI_VIRTIO=m 379CONFIG_SCSI_VIRTIO=m
@@ -427,7 +419,6 @@ CONFIG_VIRTIO_NET=m
427CONFIG_NLMON=m 419CONFIG_NLMON=m
428CONFIG_VHOST_NET=m 420CONFIG_VHOST_NET=m
429# CONFIG_NET_VENDOR_ARC is not set 421# CONFIG_NET_VENDOR_ARC is not set
430# CONFIG_NET_CADENCE is not set
431# CONFIG_NET_VENDOR_CHELSIO is not set 422# CONFIG_NET_VENDOR_CHELSIO is not set
432# CONFIG_NET_VENDOR_INTEL is not set 423# CONFIG_NET_VENDOR_INTEL is not set
433# CONFIG_NET_VENDOR_MARVELL is not set 424# CONFIG_NET_VENDOR_MARVELL is not set
@@ -481,14 +472,14 @@ CONFIG_JFS_FS=m
481CONFIG_JFS_POSIX_ACL=y 472CONFIG_JFS_POSIX_ACL=y
482CONFIG_JFS_SECURITY=y 473CONFIG_JFS_SECURITY=y
483CONFIG_JFS_STATISTICS=y 474CONFIG_JFS_STATISTICS=y
484CONFIG_XFS_FS=m 475CONFIG_XFS_FS=y
485CONFIG_XFS_QUOTA=y 476CONFIG_XFS_QUOTA=y
486CONFIG_XFS_POSIX_ACL=y 477CONFIG_XFS_POSIX_ACL=y
487CONFIG_XFS_RT=y 478CONFIG_XFS_RT=y
488CONFIG_XFS_DEBUG=y 479CONFIG_XFS_DEBUG=y
489CONFIG_GFS2_FS=m 480CONFIG_GFS2_FS=m
490CONFIG_OCFS2_FS=m 481CONFIG_OCFS2_FS=m
491CONFIG_BTRFS_FS=m 482CONFIG_BTRFS_FS=y
492CONFIG_BTRFS_FS_POSIX_ACL=y 483CONFIG_BTRFS_FS_POSIX_ACL=y
493CONFIG_NILFS2_FS=m 484CONFIG_NILFS2_FS=m
494CONFIG_FANOTIFY=y 485CONFIG_FANOTIFY=y
@@ -574,7 +565,6 @@ CONFIG_DEBUG_SHIRQ=y
574CONFIG_DETECT_HUNG_TASK=y 565CONFIG_DETECT_HUNG_TASK=y
575CONFIG_TIMER_STATS=y 566CONFIG_TIMER_STATS=y
576CONFIG_DEBUG_RT_MUTEXES=y 567CONFIG_DEBUG_RT_MUTEXES=y
577CONFIG_RT_MUTEX_TESTER=y
578CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y 568CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y
579CONFIG_PROVE_LOCKING=y 569CONFIG_PROVE_LOCKING=y
580CONFIG_LOCK_STAT=y 570CONFIG_LOCK_STAT=y
@@ -600,8 +590,13 @@ CONFIG_FAULT_INJECTION_DEBUG_FS=y
600CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y 590CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
601CONFIG_LATENCYTOP=y 591CONFIG_LATENCYTOP=y
602CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y 592CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
593CONFIG_IRQSOFF_TRACER=y
594CONFIG_PREEMPT_TRACER=y
595CONFIG_SCHED_TRACER=y
596CONFIG_FTRACE_SYSCALLS=y
597CONFIG_STACK_TRACER=y
603CONFIG_BLK_DEV_IO_TRACE=y 598CONFIG_BLK_DEV_IO_TRACE=y
604# CONFIG_KPROBE_EVENT is not set 599CONFIG_UPROBE_EVENT=y
605CONFIG_LKDTM=m 600CONFIG_LKDTM=m
606CONFIG_TEST_LIST_SORT=y 601CONFIG_TEST_LIST_SORT=y
607CONFIG_KPROBES_SANITY_TEST=y 602CONFIG_KPROBES_SANITY_TEST=y
@@ -609,7 +604,10 @@ CONFIG_RBTREE_TEST=y
609CONFIG_INTERVAL_TREE_TEST=m 604CONFIG_INTERVAL_TREE_TEST=m
610CONFIG_PERCPU_TEST=m 605CONFIG_PERCPU_TEST=m
611CONFIG_ATOMIC64_SELFTEST=y 606CONFIG_ATOMIC64_SELFTEST=y
607CONFIG_TEST_STRING_HELPERS=y
608CONFIG_TEST_KSTRTOX=y
612CONFIG_DMA_API_DEBUG=y 609CONFIG_DMA_API_DEBUG=y
610CONFIG_TEST_BPF=m
613# CONFIG_STRICT_DEVMEM is not set 611# CONFIG_STRICT_DEVMEM is not set
614CONFIG_S390_PTDUMP=y 612CONFIG_S390_PTDUMP=y
615CONFIG_ENCRYPTED_KEYS=m 613CONFIG_ENCRYPTED_KEYS=m
@@ -673,12 +671,6 @@ CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=m
673CONFIG_X509_CERTIFICATE_PARSER=m 671CONFIG_X509_CERTIFICATE_PARSER=m
674CONFIG_CRC7=m 672CONFIG_CRC7=m
675CONFIG_CRC8=m 673CONFIG_CRC8=m
676CONFIG_XZ_DEC_X86=y
677CONFIG_XZ_DEC_POWERPC=y
678CONFIG_XZ_DEC_IA64=y
679CONFIG_XZ_DEC_ARM=y
680CONFIG_XZ_DEC_ARMTHUMB=y
681CONFIG_XZ_DEC_SPARC=y
682CONFIG_CORDIC=m 674CONFIG_CORDIC=m
683CONFIG_CMM=m 675CONFIG_CMM=m
684CONFIG_APPLDATA_BASE=y 676CONFIG_APPLDATA_BASE=y
diff --git a/arch/s390/configs/gcov_defconfig b/arch/s390/configs/gcov_defconfig
index 90f514baa37d..219dca6ea926 100644
--- a/arch/s390/configs/gcov_defconfig
+++ b/arch/s390/configs/gcov_defconfig
@@ -35,7 +35,6 @@ CONFIG_MODULE_UNLOAD=y
35CONFIG_MODULE_FORCE_UNLOAD=y 35CONFIG_MODULE_FORCE_UNLOAD=y
36CONFIG_MODVERSIONS=y 36CONFIG_MODVERSIONS=y
37CONFIG_MODULE_SRCVERSION_ALL=y 37CONFIG_MODULE_SRCVERSION_ALL=y
38CONFIG_BLK_DEV_INTEGRITY=y
39CONFIG_BLK_DEV_THROTTLING=y 38CONFIG_BLK_DEV_THROTTLING=y
40CONFIG_PARTITION_ADVANCED=y 39CONFIG_PARTITION_ADVANCED=y
41CONFIG_IBM_PARTITION=y 40CONFIG_IBM_PARTITION=y
@@ -243,6 +242,7 @@ CONFIG_NF_TABLES_IPV4=m
243CONFIG_NFT_CHAIN_ROUTE_IPV4=m 242CONFIG_NFT_CHAIN_ROUTE_IPV4=m
244CONFIG_NFT_CHAIN_NAT_IPV4=m 243CONFIG_NFT_CHAIN_NAT_IPV4=m
245CONFIG_NF_TABLES_ARP=m 244CONFIG_NF_TABLES_ARP=m
245CONFIG_NF_NAT_IPV4=m
246CONFIG_IP_NF_IPTABLES=m 246CONFIG_IP_NF_IPTABLES=m
247CONFIG_IP_NF_MATCH_AH=m 247CONFIG_IP_NF_MATCH_AH=m
248CONFIG_IP_NF_MATCH_ECN=m 248CONFIG_IP_NF_MATCH_ECN=m
@@ -250,11 +250,6 @@ CONFIG_IP_NF_MATCH_RPFILTER=m
250CONFIG_IP_NF_MATCH_TTL=m 250CONFIG_IP_NF_MATCH_TTL=m
251CONFIG_IP_NF_FILTER=m 251CONFIG_IP_NF_FILTER=m
252CONFIG_IP_NF_TARGET_REJECT=m 252CONFIG_IP_NF_TARGET_REJECT=m
253CONFIG_IP_NF_TARGET_ULOG=m
254CONFIG_NF_NAT_IPV4=m
255CONFIG_IP_NF_TARGET_MASQUERADE=m
256CONFIG_IP_NF_TARGET_NETMAP=m
257CONFIG_IP_NF_TARGET_REDIRECT=m
258CONFIG_IP_NF_MANGLE=m 253CONFIG_IP_NF_MANGLE=m
259CONFIG_IP_NF_TARGET_CLUSTERIP=m 254CONFIG_IP_NF_TARGET_CLUSTERIP=m
260CONFIG_IP_NF_TARGET_ECN=m 255CONFIG_IP_NF_TARGET_ECN=m
@@ -268,6 +263,7 @@ CONFIG_NF_CONNTRACK_IPV6=m
268CONFIG_NF_TABLES_IPV6=m 263CONFIG_NF_TABLES_IPV6=m
269CONFIG_NFT_CHAIN_ROUTE_IPV6=m 264CONFIG_NFT_CHAIN_ROUTE_IPV6=m
270CONFIG_NFT_CHAIN_NAT_IPV6=m 265CONFIG_NFT_CHAIN_NAT_IPV6=m
266CONFIG_NF_NAT_IPV6=m
271CONFIG_IP6_NF_IPTABLES=m 267CONFIG_IP6_NF_IPTABLES=m
272CONFIG_IP6_NF_MATCH_AH=m 268CONFIG_IP6_NF_MATCH_AH=m
273CONFIG_IP6_NF_MATCH_EUI64=m 269CONFIG_IP6_NF_MATCH_EUI64=m
@@ -284,9 +280,6 @@ CONFIG_IP6_NF_TARGET_REJECT=m
284CONFIG_IP6_NF_MANGLE=m 280CONFIG_IP6_NF_MANGLE=m
285CONFIG_IP6_NF_RAW=m 281CONFIG_IP6_NF_RAW=m
286CONFIG_IP6_NF_SECURITY=m 282CONFIG_IP6_NF_SECURITY=m
287CONFIG_NF_NAT_IPV6=m
288CONFIG_IP6_NF_TARGET_MASQUERADE=m
289CONFIG_IP6_NF_TARGET_NPT=m
290CONFIG_NF_TABLES_BRIDGE=m 283CONFIG_NF_TABLES_BRIDGE=m
291CONFIG_NET_SCTPPROBE=m 284CONFIG_NET_SCTPPROBE=m
292CONFIG_RDS=m 285CONFIG_RDS=m
@@ -371,14 +364,13 @@ CONFIG_BLK_DEV_SR=m
371CONFIG_CHR_DEV_SG=y 364CONFIG_CHR_DEV_SG=y
372CONFIG_CHR_DEV_SCH=m 365CONFIG_CHR_DEV_SCH=m
373CONFIG_SCSI_ENCLOSURE=m 366CONFIG_SCSI_ENCLOSURE=m
374CONFIG_SCSI_MULTI_LUN=y
375CONFIG_SCSI_CONSTANTS=y 367CONFIG_SCSI_CONSTANTS=y
376CONFIG_SCSI_LOGGING=y 368CONFIG_SCSI_LOGGING=y
377CONFIG_SCSI_SPI_ATTRS=m 369CONFIG_SCSI_SPI_ATTRS=m
370CONFIG_SCSI_FC_ATTRS=y
378CONFIG_SCSI_SAS_LIBSAS=m 371CONFIG_SCSI_SAS_LIBSAS=m
379CONFIG_SCSI_SRP_ATTRS=m 372CONFIG_SCSI_SRP_ATTRS=m
380CONFIG_ISCSI_TCP=m 373CONFIG_ISCSI_TCP=m
381CONFIG_LIBFCOE=m
382CONFIG_SCSI_DEBUG=m 374CONFIG_SCSI_DEBUG=m
383CONFIG_ZFCP=y 375CONFIG_ZFCP=y
384CONFIG_SCSI_VIRTIO=m 376CONFIG_SCSI_VIRTIO=m
@@ -424,7 +416,6 @@ CONFIG_VIRTIO_NET=m
424CONFIG_NLMON=m 416CONFIG_NLMON=m
425CONFIG_VHOST_NET=m 417CONFIG_VHOST_NET=m
426# CONFIG_NET_VENDOR_ARC is not set 418# CONFIG_NET_VENDOR_ARC is not set
427# CONFIG_NET_CADENCE is not set
428# CONFIG_NET_VENDOR_CHELSIO is not set 419# CONFIG_NET_VENDOR_CHELSIO is not set
429# CONFIG_NET_VENDOR_INTEL is not set 420# CONFIG_NET_VENDOR_INTEL is not set
430# CONFIG_NET_VENDOR_MARVELL is not set 421# CONFIG_NET_VENDOR_MARVELL is not set
@@ -478,13 +469,13 @@ CONFIG_JFS_FS=m
478CONFIG_JFS_POSIX_ACL=y 469CONFIG_JFS_POSIX_ACL=y
479CONFIG_JFS_SECURITY=y 470CONFIG_JFS_SECURITY=y
480CONFIG_JFS_STATISTICS=y 471CONFIG_JFS_STATISTICS=y
481CONFIG_XFS_FS=m 472CONFIG_XFS_FS=y
482CONFIG_XFS_QUOTA=y 473CONFIG_XFS_QUOTA=y
483CONFIG_XFS_POSIX_ACL=y 474CONFIG_XFS_POSIX_ACL=y
484CONFIG_XFS_RT=y 475CONFIG_XFS_RT=y
485CONFIG_GFS2_FS=m 476CONFIG_GFS2_FS=m
486CONFIG_OCFS2_FS=m 477CONFIG_OCFS2_FS=m
487CONFIG_BTRFS_FS=m 478CONFIG_BTRFS_FS=y
488CONFIG_BTRFS_FS_POSIX_ACL=y 479CONFIG_BTRFS_FS_POSIX_ACL=y
489CONFIG_NILFS2_FS=m 480CONFIG_NILFS2_FS=m
490CONFIG_FANOTIFY=y 481CONFIG_FANOTIFY=y
@@ -626,12 +617,6 @@ CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=m
626CONFIG_X509_CERTIFICATE_PARSER=m 617CONFIG_X509_CERTIFICATE_PARSER=m
627CONFIG_CRC7=m 618CONFIG_CRC7=m
628CONFIG_CRC8=m 619CONFIG_CRC8=m
629CONFIG_XZ_DEC_X86=y
630CONFIG_XZ_DEC_POWERPC=y
631CONFIG_XZ_DEC_IA64=y
632CONFIG_XZ_DEC_ARM=y
633CONFIG_XZ_DEC_ARMTHUMB=y
634CONFIG_XZ_DEC_SPARC=y
635CONFIG_CORDIC=m 620CONFIG_CORDIC=m
636CONFIG_CMM=m 621CONFIG_CMM=m
637CONFIG_APPLDATA_BASE=y 622CONFIG_APPLDATA_BASE=y
diff --git a/arch/s390/configs/performance_defconfig b/arch/s390/configs/performance_defconfig
index 13559d32af69..822c2f2e0c25 100644
--- a/arch/s390/configs/performance_defconfig
+++ b/arch/s390/configs/performance_defconfig
@@ -33,7 +33,6 @@ CONFIG_MODULE_UNLOAD=y
33CONFIG_MODULE_FORCE_UNLOAD=y 33CONFIG_MODULE_FORCE_UNLOAD=y
34CONFIG_MODVERSIONS=y 34CONFIG_MODVERSIONS=y
35CONFIG_MODULE_SRCVERSION_ALL=y 35CONFIG_MODULE_SRCVERSION_ALL=y
36CONFIG_BLK_DEV_INTEGRITY=y
37CONFIG_BLK_DEV_THROTTLING=y 36CONFIG_BLK_DEV_THROTTLING=y
38CONFIG_PARTITION_ADVANCED=y 37CONFIG_PARTITION_ADVANCED=y
39CONFIG_IBM_PARTITION=y 38CONFIG_IBM_PARTITION=y
@@ -241,6 +240,7 @@ CONFIG_NF_TABLES_IPV4=m
241CONFIG_NFT_CHAIN_ROUTE_IPV4=m 240CONFIG_NFT_CHAIN_ROUTE_IPV4=m
242CONFIG_NFT_CHAIN_NAT_IPV4=m 241CONFIG_NFT_CHAIN_NAT_IPV4=m
243CONFIG_NF_TABLES_ARP=m 242CONFIG_NF_TABLES_ARP=m
243CONFIG_NF_NAT_IPV4=m
244CONFIG_IP_NF_IPTABLES=m 244CONFIG_IP_NF_IPTABLES=m
245CONFIG_IP_NF_MATCH_AH=m 245CONFIG_IP_NF_MATCH_AH=m
246CONFIG_IP_NF_MATCH_ECN=m 246CONFIG_IP_NF_MATCH_ECN=m
@@ -248,11 +248,6 @@ CONFIG_IP_NF_MATCH_RPFILTER=m
248CONFIG_IP_NF_MATCH_TTL=m 248CONFIG_IP_NF_MATCH_TTL=m
249CONFIG_IP_NF_FILTER=m 249CONFIG_IP_NF_FILTER=m
250CONFIG_IP_NF_TARGET_REJECT=m 250CONFIG_IP_NF_TARGET_REJECT=m
251CONFIG_IP_NF_TARGET_ULOG=m
252CONFIG_NF_NAT_IPV4=m
253CONFIG_IP_NF_TARGET_MASQUERADE=m
254CONFIG_IP_NF_TARGET_NETMAP=m
255CONFIG_IP_NF_TARGET_REDIRECT=m
256CONFIG_IP_NF_MANGLE=m 251CONFIG_IP_NF_MANGLE=m
257CONFIG_IP_NF_TARGET_CLUSTERIP=m 252CONFIG_IP_NF_TARGET_CLUSTERIP=m
258CONFIG_IP_NF_TARGET_ECN=m 253CONFIG_IP_NF_TARGET_ECN=m
@@ -266,6 +261,7 @@ CONFIG_NF_CONNTRACK_IPV6=m
266CONFIG_NF_TABLES_IPV6=m 261CONFIG_NF_TABLES_IPV6=m
267CONFIG_NFT_CHAIN_ROUTE_IPV6=m 262CONFIG_NFT_CHAIN_ROUTE_IPV6=m
268CONFIG_NFT_CHAIN_NAT_IPV6=m 263CONFIG_NFT_CHAIN_NAT_IPV6=m
264CONFIG_NF_NAT_IPV6=m
269CONFIG_IP6_NF_IPTABLES=m 265CONFIG_IP6_NF_IPTABLES=m
270CONFIG_IP6_NF_MATCH_AH=m 266CONFIG_IP6_NF_MATCH_AH=m
271CONFIG_IP6_NF_MATCH_EUI64=m 267CONFIG_IP6_NF_MATCH_EUI64=m
@@ -282,9 +278,6 @@ CONFIG_IP6_NF_TARGET_REJECT=m
282CONFIG_IP6_NF_MANGLE=m 278CONFIG_IP6_NF_MANGLE=m
283CONFIG_IP6_NF_RAW=m 279CONFIG_IP6_NF_RAW=m
284CONFIG_IP6_NF_SECURITY=m 280CONFIG_IP6_NF_SECURITY=m
285CONFIG_NF_NAT_IPV6=m
286CONFIG_IP6_NF_TARGET_MASQUERADE=m
287CONFIG_IP6_NF_TARGET_NPT=m
288CONFIG_NF_TABLES_BRIDGE=m 281CONFIG_NF_TABLES_BRIDGE=m
289CONFIG_NET_SCTPPROBE=m 282CONFIG_NET_SCTPPROBE=m
290CONFIG_RDS=m 283CONFIG_RDS=m
@@ -369,14 +362,13 @@ CONFIG_BLK_DEV_SR=m
369CONFIG_CHR_DEV_SG=y 362CONFIG_CHR_DEV_SG=y
370CONFIG_CHR_DEV_SCH=m 363CONFIG_CHR_DEV_SCH=m
371CONFIG_SCSI_ENCLOSURE=m 364CONFIG_SCSI_ENCLOSURE=m
372CONFIG_SCSI_MULTI_LUN=y
373CONFIG_SCSI_CONSTANTS=y 365CONFIG_SCSI_CONSTANTS=y
374CONFIG_SCSI_LOGGING=y 366CONFIG_SCSI_LOGGING=y
375CONFIG_SCSI_SPI_ATTRS=m 367CONFIG_SCSI_SPI_ATTRS=m
368CONFIG_SCSI_FC_ATTRS=y
376CONFIG_SCSI_SAS_LIBSAS=m 369CONFIG_SCSI_SAS_LIBSAS=m
377CONFIG_SCSI_SRP_ATTRS=m 370CONFIG_SCSI_SRP_ATTRS=m
378CONFIG_ISCSI_TCP=m 371CONFIG_ISCSI_TCP=m
379CONFIG_LIBFCOE=m
380CONFIG_SCSI_DEBUG=m 372CONFIG_SCSI_DEBUG=m
381CONFIG_ZFCP=y 373CONFIG_ZFCP=y
382CONFIG_SCSI_VIRTIO=m 374CONFIG_SCSI_VIRTIO=m
@@ -422,7 +414,6 @@ CONFIG_VIRTIO_NET=m
422CONFIG_NLMON=m 414CONFIG_NLMON=m
423CONFIG_VHOST_NET=m 415CONFIG_VHOST_NET=m
424# CONFIG_NET_VENDOR_ARC is not set 416# CONFIG_NET_VENDOR_ARC is not set
425# CONFIG_NET_CADENCE is not set
426# CONFIG_NET_VENDOR_CHELSIO is not set 417# CONFIG_NET_VENDOR_CHELSIO is not set
427# CONFIG_NET_VENDOR_INTEL is not set 418# CONFIG_NET_VENDOR_INTEL is not set
428# CONFIG_NET_VENDOR_MARVELL is not set 419# CONFIG_NET_VENDOR_MARVELL is not set
@@ -476,13 +467,13 @@ CONFIG_JFS_FS=m
476CONFIG_JFS_POSIX_ACL=y 467CONFIG_JFS_POSIX_ACL=y
477CONFIG_JFS_SECURITY=y 468CONFIG_JFS_SECURITY=y
478CONFIG_JFS_STATISTICS=y 469CONFIG_JFS_STATISTICS=y
479CONFIG_XFS_FS=m 470CONFIG_XFS_FS=y
480CONFIG_XFS_QUOTA=y 471CONFIG_XFS_QUOTA=y
481CONFIG_XFS_POSIX_ACL=y 472CONFIG_XFS_POSIX_ACL=y
482CONFIG_XFS_RT=y 473CONFIG_XFS_RT=y
483CONFIG_GFS2_FS=m 474CONFIG_GFS2_FS=m
484CONFIG_OCFS2_FS=m 475CONFIG_OCFS2_FS=m
485CONFIG_BTRFS_FS=m 476CONFIG_BTRFS_FS=y
486CONFIG_BTRFS_FS_POSIX_ACL=y 477CONFIG_BTRFS_FS_POSIX_ACL=y
487CONFIG_NILFS2_FS=m 478CONFIG_NILFS2_FS=m
488CONFIG_FANOTIFY=y 479CONFIG_FANOTIFY=y
@@ -550,8 +541,11 @@ CONFIG_TIMER_STATS=y
550CONFIG_RCU_TORTURE_TEST=m 541CONFIG_RCU_TORTURE_TEST=m
551CONFIG_RCU_CPU_STALL_TIMEOUT=60 542CONFIG_RCU_CPU_STALL_TIMEOUT=60
552CONFIG_LATENCYTOP=y 543CONFIG_LATENCYTOP=y
544CONFIG_SCHED_TRACER=y
545CONFIG_FTRACE_SYSCALLS=y
546CONFIG_STACK_TRACER=y
553CONFIG_BLK_DEV_IO_TRACE=y 547CONFIG_BLK_DEV_IO_TRACE=y
554# CONFIG_KPROBE_EVENT is not set 548CONFIG_UPROBE_EVENT=y
555CONFIG_LKDTM=m 549CONFIG_LKDTM=m
556CONFIG_PERCPU_TEST=m 550CONFIG_PERCPU_TEST=m
557CONFIG_ATOMIC64_SELFTEST=y 551CONFIG_ATOMIC64_SELFTEST=y
@@ -618,12 +612,6 @@ CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=m
618CONFIG_X509_CERTIFICATE_PARSER=m 612CONFIG_X509_CERTIFICATE_PARSER=m
619CONFIG_CRC7=m 613CONFIG_CRC7=m
620CONFIG_CRC8=m 614CONFIG_CRC8=m
621CONFIG_XZ_DEC_X86=y
622CONFIG_XZ_DEC_POWERPC=y
623CONFIG_XZ_DEC_IA64=y
624CONFIG_XZ_DEC_ARM=y
625CONFIG_XZ_DEC_ARMTHUMB=y
626CONFIG_XZ_DEC_SPARC=y
627CONFIG_CORDIC=m 615CONFIG_CORDIC=m
628CONFIG_CMM=m 616CONFIG_CMM=m
629CONFIG_APPLDATA_BASE=y 617CONFIG_APPLDATA_BASE=y
diff --git a/arch/s390/configs/zfcpdump_defconfig b/arch/s390/configs/zfcpdump_defconfig
index e376789f2d8d..9d63051ebec4 100644
--- a/arch/s390/configs/zfcpdump_defconfig
+++ b/arch/s390/configs/zfcpdump_defconfig
@@ -22,8 +22,8 @@ CONFIG_HZ_100=y
22CONFIG_CRASH_DUMP=y 22CONFIG_CRASH_DUMP=y
23# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 23# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
24# CONFIG_SECCOMP is not set 24# CONFIG_SECCOMP is not set
25# CONFIG_IUCV is not set
26CONFIG_NET=y 25CONFIG_NET=y
26# CONFIG_IUCV is not set
27CONFIG_ATM=y 27CONFIG_ATM=y
28CONFIG_ATM_LANE=y 28CONFIG_ATM_LANE=y
29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
@@ -36,9 +36,9 @@ CONFIG_ENCLOSURE_SERVICES=y
36CONFIG_SCSI=y 36CONFIG_SCSI=y
37CONFIG_BLK_DEV_SD=y 37CONFIG_BLK_DEV_SD=y
38CONFIG_SCSI_ENCLOSURE=y 38CONFIG_SCSI_ENCLOSURE=y
39CONFIG_SCSI_MULTI_LUN=y
40CONFIG_SCSI_CONSTANTS=y 39CONFIG_SCSI_CONSTANTS=y
41CONFIG_SCSI_LOGGING=y 40CONFIG_SCSI_LOGGING=y
41CONFIG_SCSI_FC_ATTRS=y
42CONFIG_SCSI_SRP_ATTRS=y 42CONFIG_SCSI_SRP_ATTRS=y
43CONFIG_ZFCP=y 43CONFIG_ZFCP=y
44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
@@ -75,12 +75,6 @@ CONFIG_DEBUG_KERNEL=y
75CONFIG_RCU_CPU_STALL_TIMEOUT=60 75CONFIG_RCU_CPU_STALL_TIMEOUT=60
76# CONFIG_FTRACE is not set 76# CONFIG_FTRACE is not set
77# CONFIG_STRICT_DEVMEM is not set 77# CONFIG_STRICT_DEVMEM is not set
78CONFIG_XZ_DEC_X86=y
79CONFIG_XZ_DEC_POWERPC=y
80CONFIG_XZ_DEC_IA64=y
81CONFIG_XZ_DEC_ARM=y
82CONFIG_XZ_DEC_ARMTHUMB=y
83CONFIG_XZ_DEC_SPARC=y
84# CONFIG_PFAULT is not set 78# CONFIG_PFAULT is not set
85# CONFIG_S390_HYPFS_FS is not set 79# CONFIG_S390_HYPFS_FS is not set
86# CONFIG_VIRTUALIZATION is not set 80# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index fab35a8efa4f..785c5f24d6f9 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -92,10 +92,10 @@ CONFIG_CHR_DEV_ST=y
92CONFIG_BLK_DEV_SR=y 92CONFIG_BLK_DEV_SR=y
93CONFIG_BLK_DEV_SR_VENDOR=y 93CONFIG_BLK_DEV_SR_VENDOR=y
94CONFIG_CHR_DEV_SG=y 94CONFIG_CHR_DEV_SG=y
95CONFIG_SCSI_MULTI_LUN=y
96CONFIG_SCSI_CONSTANTS=y 95CONFIG_SCSI_CONSTANTS=y
97CONFIG_SCSI_LOGGING=y 96CONFIG_SCSI_LOGGING=y
98CONFIG_SCSI_SCAN_ASYNC=y 97CONFIG_SCSI_SCAN_ASYNC=y
98CONFIG_SCSI_FC_ATTRS=y
99CONFIG_ZFCP=y 99CONFIG_ZFCP=y
100CONFIG_SCSI_VIRTIO=y 100CONFIG_SCSI_VIRTIO=y
101CONFIG_NETDEVICES=y 101CONFIG_NETDEVICES=y
@@ -164,14 +164,13 @@ CONFIG_CRYPTO_CMAC=m
164CONFIG_CRYPTO_XCBC=m 164CONFIG_CRYPTO_XCBC=m
165CONFIG_CRYPTO_VMAC=m 165CONFIG_CRYPTO_VMAC=m
166CONFIG_CRYPTO_CRC32=m 166CONFIG_CRYPTO_CRC32=m
167CONFIG_CRYPTO_CRCT10DIF=m
168CONFIG_CRYPTO_MD4=m 167CONFIG_CRYPTO_MD4=m
169CONFIG_CRYPTO_MICHAEL_MIC=m 168CONFIG_CRYPTO_MICHAEL_MIC=m
170CONFIG_CRYPTO_RMD128=m 169CONFIG_CRYPTO_RMD128=m
171CONFIG_CRYPTO_RMD160=m 170CONFIG_CRYPTO_RMD160=m
172CONFIG_CRYPTO_RMD256=m 171CONFIG_CRYPTO_RMD256=m
173CONFIG_CRYPTO_RMD320=m 172CONFIG_CRYPTO_RMD320=m
174CONFIG_CRYPTO_SHA256=m 173CONFIG_CRYPTO_SHA256=y
175CONFIG_CRYPTO_SHA512=m 174CONFIG_CRYPTO_SHA512=m
176CONFIG_CRYPTO_TGR192=m 175CONFIG_CRYPTO_TGR192=m
177CONFIG_CRYPTO_WP512=m 176CONFIG_CRYPTO_WP512=m
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 51d14fe5eb9a..ca1cabb3a96c 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -121,6 +121,8 @@ unsigned long __kprobes prepare_ftrace_return(unsigned long parent,
121{ 121{
122 struct ftrace_graph_ent trace; 122 struct ftrace_graph_ent trace;
123 123
124 if (unlikely(ftrace_graph_is_dead()))
125 goto out;
124 if (unlikely(atomic_read(&current->tracing_graph_pause))) 126 if (unlikely(atomic_read(&current->tracing_graph_pause)))
125 goto out; 127 goto out;
126 ip = (ip & PSW_ADDR_INSN) - MCOUNT_INSN_SIZE; 128 ip = (ip & PSW_ADDR_INSN) - MCOUNT_INSN_SIZE;
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 08e761318c17..b878f12a9597 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -1411,11 +1411,6 @@ static void cpumsf_pmu_del(struct perf_event *event, int flags)
1411 perf_pmu_enable(event->pmu); 1411 perf_pmu_enable(event->pmu);
1412} 1412}
1413 1413
1414static int cpumsf_pmu_event_idx(struct perf_event *event)
1415{
1416 return event->hw.idx;
1417}
1418
1419CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC, PERF_EVENT_CPUM_SF); 1414CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC, PERF_EVENT_CPUM_SF);
1420CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG); 1415CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG);
1421 1416
@@ -1458,7 +1453,6 @@ static struct pmu cpumf_sampling = {
1458 .stop = cpumsf_pmu_stop, 1453 .stop = cpumsf_pmu_stop,
1459 .read = cpumsf_pmu_read, 1454 .read = cpumsf_pmu_read,
1460 1455
1461 .event_idx = cpumsf_pmu_event_idx,
1462 .attr_groups = cpumsf_pmu_attr_groups, 1456 .attr_groups = cpumsf_pmu_attr_groups,
1463}; 1457};
1464 1458
diff --git a/arch/s390/kernel/vdso32/clock_gettime.S b/arch/s390/kernel/vdso32/clock_gettime.S
index 48c2206a3956..5eec9afbb5b5 100644
--- a/arch/s390/kernel/vdso32/clock_gettime.S
+++ b/arch/s390/kernel/vdso32/clock_gettime.S
@@ -19,6 +19,7 @@
19 .type __kernel_clock_gettime,@function 19 .type __kernel_clock_gettime,@function
20__kernel_clock_gettime: 20__kernel_clock_gettime:
21 .cfi_startproc 21 .cfi_startproc
22 ahi %r15,-16
22 basr %r5,0 23 basr %r5,0
230: al %r5,21f-0b(%r5) /* get &_vdso_data */ 240: al %r5,21f-0b(%r5) /* get &_vdso_data */
24 chi %r2,__CLOCK_REALTIME_COARSE 25 chi %r2,__CLOCK_REALTIME_COARSE
@@ -34,8 +35,8 @@ __kernel_clock_gettime:
341: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */ 351: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
35 tml %r4,0x0001 /* pending update ? loop */ 36 tml %r4,0x0001 /* pending update ? loop */
36 jnz 1b 37 jnz 1b
37 stcke 24(%r15) /* Store TOD clock */ 38 stcke 0(%r15) /* Store TOD clock */
38 lm %r0,%r1,25(%r15) 39 lm %r0,%r1,1(%r15)
39 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 40 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
40 sl %r1,__VDSO_XTIME_STAMP+4(%r5) 41 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
41 brc 3,2f 42 brc 3,2f
@@ -70,6 +71,7 @@ __kernel_clock_gettime:
708: st %r2,0(%r3) /* store tp->tv_sec */ 718: st %r2,0(%r3) /* store tp->tv_sec */
71 st %r1,4(%r3) /* store tp->tv_nsec */ 72 st %r1,4(%r3) /* store tp->tv_nsec */
72 lhi %r2,0 73 lhi %r2,0
74 ahi %r15,16
73 br %r14 75 br %r14
74 76
75 /* CLOCK_MONOTONIC_COARSE */ 77 /* CLOCK_MONOTONIC_COARSE */
@@ -96,8 +98,8 @@ __kernel_clock_gettime:
9611: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */ 9811: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
97 tml %r4,0x0001 /* pending update ? loop */ 99 tml %r4,0x0001 /* pending update ? loop */
98 jnz 11b 100 jnz 11b
99 stcke 24(%r15) /* Store TOD clock */ 101 stcke 0(%r15) /* Store TOD clock */
100 lm %r0,%r1,25(%r15) 102 lm %r0,%r1,1(%r15)
101 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 103 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
102 sl %r1,__VDSO_XTIME_STAMP+4(%r5) 104 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
103 brc 3,12f 105 brc 3,12f
@@ -132,11 +134,13 @@ __kernel_clock_gettime:
13217: st %r2,0(%r3) /* store tp->tv_sec */ 13417: st %r2,0(%r3) /* store tp->tv_sec */
133 st %r1,4(%r3) /* store tp->tv_nsec */ 135 st %r1,4(%r3) /* store tp->tv_nsec */
134 lhi %r2,0 136 lhi %r2,0
137 ahi %r15,16
135 br %r14 138 br %r14
136 139
137 /* Fallback to system call */ 140 /* Fallback to system call */
13819: lhi %r1,__NR_clock_gettime 14119: lhi %r1,__NR_clock_gettime
139 svc 0 142 svc 0
143 ahi %r15,16
140 br %r14 144 br %r14
141 145
14220: .long 1000000000 14620: .long 1000000000
diff --git a/arch/s390/kernel/vdso32/gettimeofday.S b/arch/s390/kernel/vdso32/gettimeofday.S
index 60def5f562db..719de6186b20 100644
--- a/arch/s390/kernel/vdso32/gettimeofday.S
+++ b/arch/s390/kernel/vdso32/gettimeofday.S
@@ -19,6 +19,7 @@
19 .type __kernel_gettimeofday,@function 19 .type __kernel_gettimeofday,@function
20__kernel_gettimeofday: 20__kernel_gettimeofday:
21 .cfi_startproc 21 .cfi_startproc
22 ahi %r15,-16
22 basr %r5,0 23 basr %r5,0
230: al %r5,13f-0b(%r5) /* get &_vdso_data */ 240: al %r5,13f-0b(%r5) /* get &_vdso_data */
241: ltr %r3,%r3 /* check if tz is NULL */ 251: ltr %r3,%r3 /* check if tz is NULL */
@@ -29,30 +30,30 @@ __kernel_gettimeofday:
29 l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */ 30 l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
30 tml %r4,0x0001 /* pending update ? loop */ 31 tml %r4,0x0001 /* pending update ? loop */
31 jnz 1b 32 jnz 1b
32 stcke 24(%r15) /* Store TOD clock */ 33 stcke 0(%r15) /* Store TOD clock */
33 lm %r0,%r1,25(%r15) 34 lm %r0,%r1,1(%r15)
34 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 35 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
35 sl %r1,__VDSO_XTIME_STAMP+4(%r5) 36 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
36 brc 3,3f 37 brc 3,3f
37 ahi %r0,-1 38 ahi %r0,-1
383: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */ 393: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
39 st %r0,24(%r15) 40 st %r0,0(%r15)
40 l %r0,__VDSO_TK_MULT(%r5) 41 l %r0,__VDSO_TK_MULT(%r5)
41 ltr %r1,%r1 42 ltr %r1,%r1
42 mr %r0,%r0 43 mr %r0,%r0
43 jnm 4f 44 jnm 4f
44 a %r0,__VDSO_TK_MULT(%r5) 45 a %r0,__VDSO_TK_MULT(%r5)
454: al %r0,24(%r15) 464: al %r0,0(%r15)
46 al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */ 47 al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */
47 al %r1,__VDSO_XTIME_NSEC+4(%r5) 48 al %r1,__VDSO_XTIME_NSEC+4(%r5)
48 brc 12,5f 49 brc 12,5f
49 ahi %r0,1 50 ahi %r0,1
505: mvc 24(4,%r15),__VDSO_XTIME_SEC+4(%r5) 515: mvc 0(4,%r15),__VDSO_XTIME_SEC+4(%r5)
51 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */ 52 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
52 jne 1b 53 jne 1b
53 l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 54 l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
54 srdl %r0,0(%r4) /* >> tk->shift */ 55 srdl %r0,0(%r4) /* >> tk->shift */
55 l %r4,24(%r15) /* get tv_sec from stack */ 56 l %r4,0(%r15) /* get tv_sec from stack */
56 basr %r5,0 57 basr %r5,0
576: ltr %r0,%r0 586: ltr %r0,%r0
58 jnz 7f 59 jnz 7f
@@ -71,6 +72,7 @@ __kernel_gettimeofday:
719: srl %r0,6 729: srl %r0,6
72 st %r0,4(%r2) /* store tv->tv_usec */ 73 st %r0,4(%r2) /* store tv->tv_usec */
7310: slr %r2,%r2 7410: slr %r2,%r2
75 ahi %r15,16
74 br %r14 76 br %r14
7511: .long 1000000000 7711: .long 1000000000
7612: .long 274877907 7812: .long 274877907
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
index 9d9761f8e110..7699e735ae28 100644
--- a/arch/s390/kernel/vdso64/clock_gettime.S
+++ b/arch/s390/kernel/vdso64/clock_gettime.S
@@ -19,6 +19,7 @@
19 .type __kernel_clock_gettime,@function 19 .type __kernel_clock_gettime,@function
20__kernel_clock_gettime: 20__kernel_clock_gettime:
21 .cfi_startproc 21 .cfi_startproc
22 aghi %r15,-16
22 larl %r5,_vdso_data 23 larl %r5,_vdso_data
23 cghi %r2,__CLOCK_REALTIME_COARSE 24 cghi %r2,__CLOCK_REALTIME_COARSE
24 je 4f 25 je 4f
@@ -37,10 +38,10 @@ __kernel_clock_gettime:
370: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */ 380: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
38 tmll %r4,0x0001 /* pending update ? loop */ 39 tmll %r4,0x0001 /* pending update ? loop */
39 jnz 0b 40 jnz 0b
40 stcke 48(%r15) /* Store TOD clock */ 41 stcke 0(%r15) /* Store TOD clock */
41 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 42 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
42 lg %r0,__VDSO_WTOM_SEC(%r5) 43 lg %r0,__VDSO_WTOM_SEC(%r5)
43 lg %r1,49(%r15) 44 lg %r1,1(%r15)
44 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 45 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
45 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */ 46 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
46 alg %r1,__VDSO_WTOM_NSEC(%r5) 47 alg %r1,__VDSO_WTOM_NSEC(%r5)
@@ -56,6 +57,7 @@ __kernel_clock_gettime:
562: stg %r0,0(%r3) /* store tp->tv_sec */ 572: stg %r0,0(%r3) /* store tp->tv_sec */
57 stg %r1,8(%r3) /* store tp->tv_nsec */ 58 stg %r1,8(%r3) /* store tp->tv_nsec */
58 lghi %r2,0 59 lghi %r2,0
60 aghi %r15,16
59 br %r14 61 br %r14
60 62
61 /* CLOCK_MONOTONIC_COARSE */ 63 /* CLOCK_MONOTONIC_COARSE */
@@ -82,9 +84,9 @@ __kernel_clock_gettime:
825: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */ 845: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
83 tmll %r4,0x0001 /* pending update ? loop */ 85 tmll %r4,0x0001 /* pending update ? loop */
84 jnz 5b 86 jnz 5b
85 stcke 48(%r15) /* Store TOD clock */ 87 stcke 0(%r15) /* Store TOD clock */
86 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 88 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
87 lg %r1,49(%r15) 89 lg %r1,1(%r15)
88 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 90 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
89 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */ 91 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
90 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */ 92 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
@@ -101,6 +103,7 @@ __kernel_clock_gettime:
1017: stg %r0,0(%r3) /* store tp->tv_sec */ 1037: stg %r0,0(%r3) /* store tp->tv_sec */
102 stg %r1,8(%r3) /* store tp->tv_nsec */ 104 stg %r1,8(%r3) /* store tp->tv_nsec */
103 lghi %r2,0 105 lghi %r2,0
106 aghi %r15,16
104 br %r14 107 br %r14
105 108
106 /* CLOCK_THREAD_CPUTIME_ID for this thread */ 109 /* CLOCK_THREAD_CPUTIME_ID for this thread */
@@ -134,11 +137,13 @@ __kernel_clock_gettime:
134 slgr %r4,%r0 /* r4 = tv_nsec */ 137 slgr %r4,%r0 /* r4 = tv_nsec */
135 stg %r4,8(%r3) 138 stg %r4,8(%r3)
136 lghi %r2,0 139 lghi %r2,0
140 aghi %r15,16
137 br %r14 141 br %r14
138 142
139 /* Fallback to system call */ 143 /* Fallback to system call */
14012: lghi %r1,__NR_clock_gettime 14412: lghi %r1,__NR_clock_gettime
141 svc 0 145 svc 0
146 aghi %r15,16
142 br %r14 147 br %r14
143 148
14413: .quad 1000000000 14913: .quad 1000000000
diff --git a/arch/s390/kernel/vdso64/gettimeofday.S b/arch/s390/kernel/vdso64/gettimeofday.S
index 7a344995a97f..6ce46707663c 100644
--- a/arch/s390/kernel/vdso64/gettimeofday.S
+++ b/arch/s390/kernel/vdso64/gettimeofday.S
@@ -19,6 +19,7 @@
19 .type __kernel_gettimeofday,@function 19 .type __kernel_gettimeofday,@function
20__kernel_gettimeofday: 20__kernel_gettimeofday:
21 .cfi_startproc 21 .cfi_startproc
22 aghi %r15,-16
22 larl %r5,_vdso_data 23 larl %r5,_vdso_data
230: ltgr %r3,%r3 /* check if tz is NULL */ 240: ltgr %r3,%r3 /* check if tz is NULL */
24 je 1f 25 je 1f
@@ -28,8 +29,8 @@ __kernel_gettimeofday:
28 lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */ 29 lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
29 tmll %r4,0x0001 /* pending update ? loop */ 30 tmll %r4,0x0001 /* pending update ? loop */
30 jnz 0b 31 jnz 0b
31 stcke 48(%r15) /* Store TOD clock */ 32 stcke 0(%r15) /* Store TOD clock */
32 lg %r1,49(%r15) 33 lg %r1,1(%r15)
33 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 34 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
34 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */ 35 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
35 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */ 36 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
@@ -50,6 +51,7 @@ __kernel_gettimeofday:
50 srlg %r0,%r0,6 51 srlg %r0,%r0,6
51 stg %r0,8(%r2) /* store tv->tv_usec */ 52 stg %r0,8(%r2) /* store tv->tv_usec */
524: lghi %r2,0 534: lghi %r2,0
54 aghi %r15,16
53 br %r14 55 br %r14
545: .quad 1000000000 565: .quad 1000000000
55 .long 274877907 57 .long 274877907
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 416f2a323ba5..7f0089d9a4aa 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -66,7 +66,11 @@ static int do_account_vtime(struct task_struct *tsk, int hardirq_offset)
66 clock = S390_lowcore.last_update_clock; 66 clock = S390_lowcore.last_update_clock;
67 asm volatile( 67 asm volatile(
68 " stpt %0\n" /* Store current cpu timer value */ 68 " stpt %0\n" /* Store current cpu timer value */
69#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
70 " stckf %1" /* Store current tod clock value */
71#else
69 " stck %1" /* Store current tod clock value */ 72 " stck %1" /* Store current tod clock value */
73#endif
70 : "=m" (S390_lowcore.last_update_timer), 74 : "=m" (S390_lowcore.last_update_timer),
71 "=m" (S390_lowcore.last_update_clock)); 75 "=m" (S390_lowcore.last_update_clock));
72 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer; 76 S390_lowcore.system_timer += timer - S390_lowcore.last_update_timer;
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
index 9139d14b9c53..538c10db3537 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -118,7 +118,7 @@ static struct plat_sci_port scif0_platform_data = {
118}; 118};
119 119
120static struct resource scif0_resources[] = { 120static struct resource scif0_resources[] = {
121 DEFINE_RES_MEM(0xfffffe80, 0x100), 121 DEFINE_RES_MEM(0xfffffe80, 0x10),
122 DEFINE_RES_IRQ(evt2irq(0x4e0)), 122 DEFINE_RES_IRQ(evt2irq(0x4e0)),
123}; 123};
124 124
@@ -143,7 +143,7 @@ static struct plat_sci_port scif1_platform_data = {
143}; 143};
144 144
145static struct resource scif1_resources[] = { 145static struct resource scif1_resources[] = {
146 DEFINE_RES_MEM(0xa4000150, 0x100), 146 DEFINE_RES_MEM(0xa4000150, 0x10),
147 DEFINE_RES_IRQ(evt2irq(0x900)), 147 DEFINE_RES_IRQ(evt2irq(0x900)),
148}; 148};
149 149
@@ -169,7 +169,7 @@ static struct plat_sci_port scif2_platform_data = {
169}; 169};
170 170
171static struct resource scif2_resources[] = { 171static struct resource scif2_resources[] = {
172 DEFINE_RES_MEM(0xa4000140, 0x100), 172 DEFINE_RES_MEM(0xa4000140, 0x10),
173 DEFINE_RES_IRQ(evt2irq(0x880)), 173 DEFINE_RES_IRQ(evt2irq(0x880)),
174}; 174};
175 175
diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h
index c842a89b1190..46d83842eddc 100644
--- a/arch/sparc/include/uapi/asm/unistd.h
+++ b/arch/sparc/include/uapi/asm/unistd.h
@@ -414,8 +414,9 @@
414#define __NR_seccomp 346 414#define __NR_seccomp 346
415#define __NR_getrandom 347 415#define __NR_getrandom 347
416#define __NR_memfd_create 348 416#define __NR_memfd_create 348
417#define __NR_bpf 349
417 418
418#define NR_syscalls 349 419#define NR_syscalls 350
419 420
420/* Bitmask values returned from kern_features system call. */ 421/* Bitmask values returned from kern_features system call. */
421#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001 422#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S
index 6a873c344bc0..ad0cdf497b78 100644
--- a/arch/sparc/kernel/systbls_32.S
+++ b/arch/sparc/kernel/systbls_32.S
@@ -86,4 +86,4 @@ sys_call_table:
86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
88/*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 88/*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
89/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 89/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
index d9151b6490d8..580cde9370c9 100644
--- a/arch/sparc/kernel/systbls_64.S
+++ b/arch/sparc/kernel/systbls_64.S
@@ -87,7 +87,7 @@ sys_call_table32:
87/*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime 87/*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime
88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev 88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev
89/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 89/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
90 .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 90 .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
91 91
92#endif /* CONFIG_COMPAT */ 92#endif /* CONFIG_COMPAT */
93 93
@@ -166,4 +166,4 @@ sys_call_table:
166/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 166/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
167 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 167 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
168/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 168/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
169 .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 169 .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f2327e88e07c..ded8a6774ac9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -142,6 +142,10 @@ config INSTRUCTION_DECODER
142 def_bool y 142 def_bool y
143 depends on KPROBES || PERF_EVENTS || UPROBES 143 depends on KPROBES || PERF_EVENTS || UPROBES
144 144
145config PERF_EVENTS_INTEL_UNCORE
146 def_bool y
147 depends on PERF_EVENTS && SUP_SUP_INTEL && PCI
148
145config OUTPUT_FORMAT 149config OUTPUT_FORMAT
146 string 150 string
147 default "elf32-i386" if X86_32 151 default "elf32-i386" if X86_32
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 8ffba18395c8..ffe71228fc10 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -157,7 +157,7 @@ ENTRY(ia32_sysenter_target)
157 * ourselves. To save a few cycles, we can check whether 157 * ourselves. To save a few cycles, we can check whether
158 * NT was set instead of doing an unconditional popfq. 158 * NT was set instead of doing an unconditional popfq.
159 */ 159 */
160 testl $X86_EFLAGS_NT,EFLAGS(%rsp) /* saved EFLAGS match cpu */ 160 testl $X86_EFLAGS_NT,EFLAGS-ARGOFFSET(%rsp)
161 jnz sysenter_fix_flags 161 jnz sysenter_fix_flags
162sysenter_flags_fixed: 162sysenter_flags_fixed:
163 163
diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
index 7024c12f7bfe..400873450e33 100644
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -105,6 +105,7 @@ static __always_inline bool should_resched(void)
105# ifdef CONFIG_CONTEXT_TRACKING 105# ifdef CONFIG_CONTEXT_TRACKING
106 extern asmlinkage void ___preempt_schedule_context(void); 106 extern asmlinkage void ___preempt_schedule_context(void);
107# define __preempt_schedule_context() asm ("call ___preempt_schedule_context") 107# define __preempt_schedule_context() asm ("call ___preempt_schedule_context")
108 extern asmlinkage void preempt_schedule_context(void);
108# endif 109# endif
109#endif 110#endif
110 111
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index b436fc735aa4..a142e77693e1 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -397,7 +397,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
397 397
398 /* Don't set up the ACPI SCI because it's already set up */ 398 /* Don't set up the ACPI SCI because it's already set up */
399 if (acpi_gbl_FADT.sci_interrupt == gsi) 399 if (acpi_gbl_FADT.sci_interrupt == gsi)
400 return gsi; 400 return mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC);
401 401
402 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1; 402 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
403 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1; 403 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
@@ -604,14 +604,18 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
604 604
605int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) 605int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
606{ 606{
607 int irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK); 607 int irq;
608 608
609 if (irq >= 0) { 609 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
610 *irqp = gsi;
611 } else {
612 irq = mp_map_gsi_to_irq(gsi,
613 IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
614 if (irq < 0)
615 return -1;
610 *irqp = irq; 616 *irqp = irq;
611 return 0;
612 } 617 }
613 618 return 0;
614 return -1;
615} 619}
616EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); 620EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
617 621
diff --git a/arch/x86/kernel/apb_timer.c b/arch/x86/kernel/apb_timer.c
index 5972b108f15a..b708738d016e 100644
--- a/arch/x86/kernel/apb_timer.c
+++ b/arch/x86/kernel/apb_timer.c
@@ -185,8 +185,6 @@ static void apbt_setup_irq(struct apbt_dev *adev)
185 185
186 irq_modify_status(adev->irq, 0, IRQ_MOVE_PCNTXT); 186 irq_modify_status(adev->irq, 0, IRQ_MOVE_PCNTXT);
187 irq_set_affinity(adev->irq, cpumask_of(adev->cpu)); 187 irq_set_affinity(adev->irq, cpumask_of(adev->cpu));
188 /* APB timer irqs are set up as mp_irqs, timer is edge type */
189 __irq_set_handler(adev->irq, handle_edge_irq, 0, "edge");
190} 188}
191 189
192/* Should be called with per cpu */ 190/* Should be called with per cpu */
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 00853b254ab0..ba6cc041edb1 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1297,7 +1297,7 @@ void setup_local_APIC(void)
1297 unsigned int value, queued; 1297 unsigned int value, queued;
1298 int i, j, acked = 0; 1298 int i, j, acked = 0;
1299 unsigned long long tsc = 0, ntsc; 1299 unsigned long long tsc = 0, ntsc;
1300 long long max_loops = cpu_khz; 1300 long long max_loops = cpu_khz ? cpu_khz : 1000000;
1301 1301
1302 if (cpu_has_tsc) 1302 if (cpu_has_tsc)
1303 rdtscll(tsc); 1303 rdtscll(tsc);
@@ -1383,7 +1383,7 @@ void setup_local_APIC(void)
1383 break; 1383 break;
1384 } 1384 }
1385 if (queued) { 1385 if (queued) {
1386 if (cpu_has_tsc) { 1386 if (cpu_has_tsc && cpu_khz) {
1387 rdtscll(ntsc); 1387 rdtscll(ntsc);
1388 max_loops = (cpu_khz << 10) - (ntsc - tsc); 1388 max_loops = (cpu_khz << 10) - (ntsc - tsc);
1389 } else 1389 } else
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 01d5453b5502..e27b49d7c922 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -39,9 +39,12 @@ obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd_iommu.o
39endif 39endif
40obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o 40obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o
41obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o 41obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
42obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore.o perf_event_intel_uncore_snb.o
43obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore_snbep.o perf_event_intel_uncore_nhmex.o
44obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o 42obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o
43
44obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE) += perf_event_intel_uncore.o \
45 perf_event_intel_uncore_snb.o \
46 perf_event_intel_uncore_snbep.o \
47 perf_event_intel_uncore_nhmex.o
45endif 48endif
46 49
47 50
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1ef456273172..9cc6b6f25f42 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -213,12 +213,13 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
213{ 213{
214#ifdef CONFIG_X86_F00F_BUG 214#ifdef CONFIG_X86_F00F_BUG
215 /* 215 /*
216 * All current models of Pentium and Pentium with MMX technology CPUs 216 * All models of Pentium and Pentium with MMX technology CPUs
217 * have the F0 0F bug, which lets nonprivileged users lock up the 217 * have the F0 0F bug, which lets nonprivileged users lock up the
218 * system. Announce that the fault handler will be checking for it. 218 * system. Announce that the fault handler will be checking for it.
219 * The Quark is also family 5, but does not have the same bug.
219 */ 220 */
220 clear_cpu_bug(c, X86_BUG_F00F); 221 clear_cpu_bug(c, X86_BUG_F00F);
221 if (!paravirt_enabled() && c->x86 == 5) { 222 if (!paravirt_enabled() && c->x86 == 5 && c->x86_model < 9) {
222 static int f00f_workaround_enabled; 223 static int f00f_workaround_enabled;
223 224
224 set_cpu_bug(c, X86_BUG_F00F); 225 set_cpu_bug(c, X86_BUG_F00F);
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 1b8299dd3d91..143e5f5dc855 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,8 +243,9 @@ static bool check_hw_exists(void)
243 243
244msr_fail: 244msr_fail:
245 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n"); 245 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
246 printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR 246 printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
247 "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new); 247 boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
248 reg, val_new);
248 249
249 return false; 250 return false;
250} 251}
@@ -444,12 +445,6 @@ int x86_pmu_hw_config(struct perf_event *event)
444 if (event->attr.type == PERF_TYPE_RAW) 445 if (event->attr.type == PERF_TYPE_RAW)
445 event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK; 446 event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK;
446 447
447 if (event->attr.sample_period && x86_pmu.limit_period) {
448 if (x86_pmu.limit_period(event, event->attr.sample_period) >
449 event->attr.sample_period)
450 return -EINVAL;
451 }
452
453 return x86_setup_perfctr(event); 448 return x86_setup_perfctr(event);
454} 449}
455 450
@@ -987,9 +982,6 @@ int x86_perf_event_set_period(struct perf_event *event)
987 if (left > x86_pmu.max_period) 982 if (left > x86_pmu.max_period)
988 left = x86_pmu.max_period; 983 left = x86_pmu.max_period;
989 984
990 if (x86_pmu.limit_period)
991 left = x86_pmu.limit_period(event, left);
992
993 per_cpu(pmc_prev_left[idx], smp_processor_id()) = left; 985 per_cpu(pmc_prev_left[idx], smp_processor_id()) = left;
994 986
995 /* 987 /*
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index d98a34d435d7..fc5eb390b368 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -445,7 +445,6 @@ struct x86_pmu {
445 struct x86_pmu_quirk *quirks; 445 struct x86_pmu_quirk *quirks;
446 int perfctr_second_write; 446 int perfctr_second_write;
447 bool late_ack; 447 bool late_ack;
448 unsigned (*limit_period)(struct perf_event *event, unsigned l);
449 448
450 /* 449 /*
451 * sysfs attrs 450 * sysfs attrs
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index a73947c53b65..944bf019b74f 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -220,15 +220,6 @@ static struct event_constraint intel_hsw_event_constraints[] = {
220 EVENT_CONSTRAINT_END 220 EVENT_CONSTRAINT_END
221}; 221};
222 222
223static struct event_constraint intel_bdw_event_constraints[] = {
224 FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
225 FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
226 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */
227 INTEL_UEVENT_CONSTRAINT(0x148, 0x4), /* L1D_PEND_MISS.PENDING */
228 INTEL_EVENT_CONSTRAINT(0xa3, 0x4), /* CYCLE_ACTIVITY.* */
229 EVENT_CONSTRAINT_END
230};
231
232static u64 intel_pmu_event_map(int hw_event) 223static u64 intel_pmu_event_map(int hw_event)
233{ 224{
234 return intel_perfmon_event_map[hw_event]; 225 return intel_perfmon_event_map[hw_event];
@@ -424,126 +415,6 @@ static __initconst const u64 snb_hw_cache_event_ids
424 415
425}; 416};
426 417
427static __initconst const u64 hsw_hw_cache_event_ids
428 [PERF_COUNT_HW_CACHE_MAX]
429 [PERF_COUNT_HW_CACHE_OP_MAX]
430 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
431{
432 [ C(L1D ) ] = {
433 [ C(OP_READ) ] = {
434 [ C(RESULT_ACCESS) ] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */
435 [ C(RESULT_MISS) ] = 0x151, /* L1D.REPLACEMENT */
436 },
437 [ C(OP_WRITE) ] = {
438 [ C(RESULT_ACCESS) ] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */
439 [ C(RESULT_MISS) ] = 0x0,
440 },
441 [ C(OP_PREFETCH) ] = {
442 [ C(RESULT_ACCESS) ] = 0x0,
443 [ C(RESULT_MISS) ] = 0x0,
444 },
445 },
446 [ C(L1I ) ] = {
447 [ C(OP_READ) ] = {
448 [ C(RESULT_ACCESS) ] = 0x0,
449 [ C(RESULT_MISS) ] = 0x280, /* ICACHE.MISSES */
450 },
451 [ C(OP_WRITE) ] = {
452 [ C(RESULT_ACCESS) ] = -1,
453 [ C(RESULT_MISS) ] = -1,
454 },
455 [ C(OP_PREFETCH) ] = {
456 [ C(RESULT_ACCESS) ] = 0x0,
457 [ C(RESULT_MISS) ] = 0x0,
458 },
459 },
460 [ C(LL ) ] = {
461 [ C(OP_READ) ] = {
462 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD */
463 [ C(RESULT_ACCESS) ] = 0x1b7,
464 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD|SUPPLIER_NONE|
465 L3_MISS|ANY_SNOOP */
466 [ C(RESULT_MISS) ] = 0x1b7,
467 },
468 [ C(OP_WRITE) ] = {
469 [ C(RESULT_ACCESS) ] = 0x1b7, /* OFFCORE_RESPONSE:ALL_RFO */
470 /* OFFCORE_RESPONSE:ALL_RFO|SUPPLIER_NONE|L3_MISS|ANY_SNOOP */
471 [ C(RESULT_MISS) ] = 0x1b7,
472 },
473 [ C(OP_PREFETCH) ] = {
474 [ C(RESULT_ACCESS) ] = 0x0,
475 [ C(RESULT_MISS) ] = 0x0,
476 },
477 },
478 [ C(DTLB) ] = {
479 [ C(OP_READ) ] = {
480 [ C(RESULT_ACCESS) ] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */
481 [ C(RESULT_MISS) ] = 0x108, /* DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK */
482 },
483 [ C(OP_WRITE) ] = {
484 [ C(RESULT_ACCESS) ] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */
485 [ C(RESULT_MISS) ] = 0x149, /* DTLB_STORE_MISSES.MISS_CAUSES_A_WALK */
486 },
487 [ C(OP_PREFETCH) ] = {
488 [ C(RESULT_ACCESS) ] = 0x0,
489 [ C(RESULT_MISS) ] = 0x0,
490 },
491 },
492 [ C(ITLB) ] = {
493 [ C(OP_READ) ] = {
494 [ C(RESULT_ACCESS) ] = 0x6085, /* ITLB_MISSES.STLB_HIT */
495 [ C(RESULT_MISS) ] = 0x185, /* ITLB_MISSES.MISS_CAUSES_A_WALK */
496 },
497 [ C(OP_WRITE) ] = {
498 [ C(RESULT_ACCESS) ] = -1,
499 [ C(RESULT_MISS) ] = -1,
500 },
501 [ C(OP_PREFETCH) ] = {
502 [ C(RESULT_ACCESS) ] = -1,
503 [ C(RESULT_MISS) ] = -1,
504 },
505 },
506 [ C(BPU ) ] = {
507 [ C(OP_READ) ] = {
508 [ C(RESULT_ACCESS) ] = 0xc4, /* BR_INST_RETIRED.ALL_BRANCHES */
509 [ C(RESULT_MISS) ] = 0xc5, /* BR_MISP_RETIRED.ALL_BRANCHES */
510 },
511 [ C(OP_WRITE) ] = {
512 [ C(RESULT_ACCESS) ] = -1,
513 [ C(RESULT_MISS) ] = -1,
514 },
515 [ C(OP_PREFETCH) ] = {
516 [ C(RESULT_ACCESS) ] = -1,
517 [ C(RESULT_MISS) ] = -1,
518 },
519 },
520};
521
522static __initconst const u64 hsw_hw_cache_extra_regs
523 [PERF_COUNT_HW_CACHE_MAX]
524 [PERF_COUNT_HW_CACHE_OP_MAX]
525 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
526{
527 [ C(LL ) ] = {
528 [ C(OP_READ) ] = {
529 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD */
530 [ C(RESULT_ACCESS) ] = 0x2d5,
531 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD|SUPPLIER_NONE|
532 L3_MISS|ANY_SNOOP */
533 [ C(RESULT_MISS) ] = 0x3fbc0202d5ull,
534 },
535 [ C(OP_WRITE) ] = {
536 [ C(RESULT_ACCESS) ] = 0x122, /* OFFCORE_RESPONSE:ALL_RFO */
537 /* OFFCORE_RESPONSE:ALL_RFO|SUPPLIER_NONE|L3_MISS|ANY_SNOOP */
538 [ C(RESULT_MISS) ] = 0x3fbc020122ull,
539 },
540 [ C(OP_PREFETCH) ] = {
541 [ C(RESULT_ACCESS) ] = 0x0,
542 [ C(RESULT_MISS) ] = 0x0,
543 },
544 },
545};
546
547static __initconst const u64 westmere_hw_cache_event_ids 418static __initconst const u64 westmere_hw_cache_event_ids
548 [PERF_COUNT_HW_CACHE_MAX] 419 [PERF_COUNT_HW_CACHE_MAX]
549 [PERF_COUNT_HW_CACHE_OP_MAX] 420 [PERF_COUNT_HW_CACHE_OP_MAX]
@@ -2034,24 +1905,6 @@ hsw_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
2034 return c; 1905 return c;
2035} 1906}
2036 1907
2037/*
2038 * Broadwell:
2039 * The INST_RETIRED.ALL period always needs to have lowest
2040 * 6bits cleared (BDM57). It shall not use a period smaller
2041 * than 100 (BDM11). We combine the two to enforce
2042 * a min-period of 128.
2043 */
2044static unsigned bdw_limit_period(struct perf_event *event, unsigned left)
2045{
2046 if ((event->hw.config & INTEL_ARCH_EVENT_MASK) ==
2047 X86_CONFIG(.event=0xc0, .umask=0x01)) {
2048 if (left < 128)
2049 left = 128;
2050 left &= ~0x3fu;
2051 }
2052 return left;
2053}
2054
2055PMU_FORMAT_ATTR(event, "config:0-7" ); 1908PMU_FORMAT_ATTR(event, "config:0-7" );
2056PMU_FORMAT_ATTR(umask, "config:8-15" ); 1909PMU_FORMAT_ATTR(umask, "config:8-15" );
2057PMU_FORMAT_ATTR(edge, "config:18" ); 1910PMU_FORMAT_ATTR(edge, "config:18" );
@@ -2692,8 +2545,8 @@ __init int intel_pmu_init(void)
2692 case 69: /* 22nm Haswell ULT */ 2545 case 69: /* 22nm Haswell ULT */
2693 case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */ 2546 case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */
2694 x86_pmu.late_ack = true; 2547 x86_pmu.late_ack = true;
2695 memcpy(hw_cache_event_ids, hsw_hw_cache_event_ids, sizeof(hw_cache_event_ids)); 2548 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, sizeof(hw_cache_event_ids));
2696 memcpy(hw_cache_extra_regs, hsw_hw_cache_extra_regs, sizeof(hw_cache_extra_regs)); 2549 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
2697 2550
2698 intel_pmu_lbr_init_snb(); 2551 intel_pmu_lbr_init_snb();
2699 2552
@@ -2712,28 +2565,6 @@ __init int intel_pmu_init(void)
2712 pr_cont("Haswell events, "); 2565 pr_cont("Haswell events, ");
2713 break; 2566 break;
2714 2567
2715 case 61: /* 14nm Broadwell Core-M */
2716 x86_pmu.late_ack = true;
2717 memcpy(hw_cache_event_ids, hsw_hw_cache_event_ids, sizeof(hw_cache_event_ids));
2718 memcpy(hw_cache_extra_regs, hsw_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
2719
2720 intel_pmu_lbr_init_snb();
2721
2722 x86_pmu.event_constraints = intel_bdw_event_constraints;
2723 x86_pmu.pebs_constraints = intel_hsw_pebs_event_constraints;
2724 x86_pmu.extra_regs = intel_snbep_extra_regs;
2725 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
2726 /* all extra regs are per-cpu when HT is on */
2727 x86_pmu.er_flags |= ERF_HAS_RSP_1;
2728 x86_pmu.er_flags |= ERF_NO_HT_SHARING;
2729
2730 x86_pmu.hw_config = hsw_hw_config;
2731 x86_pmu.get_event_constraints = hsw_get_event_constraints;
2732 x86_pmu.cpu_events = hsw_events_attrs;
2733 x86_pmu.limit_period = bdw_limit_period;
2734 pr_cont("Broadwell events, ");
2735 break;
2736
2737 default: 2568 default:
2738 switch (x86_pmu.version) { 2569 switch (x86_pmu.version) {
2739 case 1: 2570 case 1:
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index b553ed89e5f5..344b63f18d14 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -447,15 +447,14 @@ sysenter_exit:
447sysenter_audit: 447sysenter_audit:
448 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp) 448 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
449 jnz syscall_trace_entry 449 jnz syscall_trace_entry
450 addl $4,%esp 450 /* movl PT_EAX(%esp), %eax already set, syscall number: 1st arg to audit */
451 CFI_ADJUST_CFA_OFFSET -4 451 movl PT_EBX(%esp), %edx /* ebx/a0: 2nd arg to audit */
452 movl %esi,4(%esp) /* 5th arg: 4th syscall arg */ 452 /* movl PT_ECX(%esp), %ecx already set, a1: 3nd arg to audit */
453 movl %edx,(%esp) /* 4th arg: 3rd syscall arg */ 453 pushl_cfi PT_ESI(%esp) /* a3: 5th arg */
454 /* %ecx already in %ecx 3rd arg: 2nd syscall arg */ 454 pushl_cfi PT_EDX+4(%esp) /* a2: 4th arg */
455 movl %ebx,%edx /* 2nd arg: 1st syscall arg */
456 /* %eax already in %eax 1st arg: syscall number */
457 call __audit_syscall_entry 455 call __audit_syscall_entry
458 pushl_cfi %ebx 456 popl_cfi %ecx /* get that remapped edx off the stack */
457 popl_cfi %ecx /* get that remapped esi off the stack */
459 movl PT_EAX(%esp),%eax /* reload syscall number */ 458 movl PT_EAX(%esp),%eax /* reload syscall number */
460 jmp sysenter_do_call 459 jmp sysenter_do_call
461 460
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
index 8af817105e29..e7cc5370cd2f 100644
--- a/arch/x86/kernel/i8259.c
+++ b/arch/x86/kernel/i8259.c
@@ -111,8 +111,7 @@ static void make_8259A_irq(unsigned int irq)
111{ 111{
112 disable_irq_nosync(irq); 112 disable_irq_nosync(irq);
113 io_apic_irqs &= ~(1<<irq); 113 io_apic_irqs &= ~(1<<irq);
114 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq, 114 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
115 i8259A_chip.name);
116 enable_irq(irq); 115 enable_irq(irq);
117} 116}
118 117
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 44f1ed42fdf2..4de73ee78361 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -70,7 +70,6 @@ int vector_used_by_percpu_irq(unsigned int vector)
70void __init init_ISA_irqs(void) 70void __init init_ISA_irqs(void)
71{ 71{
72 struct irq_chip *chip = legacy_pic->chip; 72 struct irq_chip *chip = legacy_pic->chip;
73 const char *name = chip->name;
74 int i; 73 int i;
75 74
76#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 75#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
@@ -79,7 +78,7 @@ void __init init_ISA_irqs(void)
79 legacy_pic->init(0); 78 legacy_pic->init(0);
80 79
81 for (i = 0; i < nr_legacy_irqs(); i++) 80 for (i = 0; i < nr_legacy_irqs(); i++)
82 irq_set_chip_and_handler_name(i, chip, handle_level_irq, name); 81 irq_set_chip_and_handler(i, chip, handle_level_irq);
83} 82}
84 83
85void __init init_IRQ(void) 84void __init init_IRQ(void)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 235cfd39e0d7..ab08aa2276fb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1128,7 +1128,6 @@ void __init setup_arch(char **cmdline_p)
1128 setup_real_mode(); 1128 setup_real_mode();
1129 1129
1130 memblock_set_current_limit(get_max_mapped()); 1130 memblock_set_current_limit(get_max_mapped());
1131 dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
1132 1131
1133 /* 1132 /*
1134 * NOTE: On x86-32, only from this point on, fixmaps are ready for use. 1133 * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
@@ -1159,6 +1158,7 @@ void __init setup_arch(char **cmdline_p)
1159 early_acpi_boot_init(); 1158 early_acpi_boot_init();
1160 1159
1161 initmem_init(); 1160 initmem_init();
1161 dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
1162 1162
1163 /* 1163 /*
1164 * Reserve memory for crash kernel after SRAT is parsed so that it 1164 * Reserve memory for crash kernel after SRAT is parsed so that it
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 2d5200e56357..4d2128ac70bd 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -102,8 +102,6 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
102DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); 102DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
103EXPORT_PER_CPU_SYMBOL(cpu_info); 103EXPORT_PER_CPU_SYMBOL(cpu_info);
104 104
105static DEFINE_PER_CPU(struct completion, die_complete);
106
107atomic_t init_deasserted; 105atomic_t init_deasserted;
108 106
109/* 107/*
@@ -1318,6 +1316,8 @@ void cpu_disable_common(void)
1318 fixup_irqs(); 1316 fixup_irqs();
1319} 1317}
1320 1318
1319static DEFINE_PER_CPU(struct completion, die_complete);
1320
1321int native_cpu_disable(void) 1321int native_cpu_disable(void)
1322{ 1322{
1323 int ret; 1323 int ret;
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index b6025f9e36c6..b7e50bba3bbb 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1166,14 +1166,17 @@ void __init tsc_init(void)
1166 1166
1167 x86_init.timers.tsc_pre_init(); 1167 x86_init.timers.tsc_pre_init();
1168 1168
1169 if (!cpu_has_tsc) 1169 if (!cpu_has_tsc) {
1170 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1170 return; 1171 return;
1172 }
1171 1173
1172 tsc_khz = x86_platform.calibrate_tsc(); 1174 tsc_khz = x86_platform.calibrate_tsc();
1173 cpu_khz = tsc_khz; 1175 cpu_khz = tsc_khz;
1174 1176
1175 if (!tsc_khz) { 1177 if (!tsc_khz) {
1176 mark_tsc_unstable("could not calculate TSC khz"); 1178 mark_tsc_unstable("could not calculate TSC khz");
1179 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1177 return; 1180 return;
1178 } 1181 }
1179 1182
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 749f9fa38254..5edf088ca51e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -574,12 +574,14 @@ static inline int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst,
574 case 4: 574 case 4:
575 ctxt->_eip = (u32)dst; 575 ctxt->_eip = (u32)dst;
576 break; 576 break;
577#ifdef CONFIG_X86_64
577 case 8: 578 case 8:
578 if ((cs_l && is_noncanonical_address(dst)) || 579 if ((cs_l && is_noncanonical_address(dst)) ||
579 (!cs_l && (dst & ~(u32)-1))) 580 (!cs_l && (dst >> 32) != 0))
580 return emulate_gp(ctxt, 0); 581 return emulate_gp(ctxt, 0);
581 ctxt->_eip = dst; 582 ctxt->_eip = dst;
582 break; 583 break;
584#endif
583 default: 585 default:
584 WARN(1, "unsupported eip assignment size\n"); 586 WARN(1, "unsupported eip assignment size\n");
585 } 587 }
@@ -641,7 +643,8 @@ static bool insn_aligned(struct x86_emulate_ctxt *ctxt, unsigned size)
641 643
642static int __linearize(struct x86_emulate_ctxt *ctxt, 644static int __linearize(struct x86_emulate_ctxt *ctxt,
643 struct segmented_address addr, 645 struct segmented_address addr,
644 unsigned size, bool write, bool fetch, 646 unsigned *max_size, unsigned size,
647 bool write, bool fetch,
645 ulong *linear) 648 ulong *linear)
646{ 649{
647 struct desc_struct desc; 650 struct desc_struct desc;
@@ -652,10 +655,15 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
652 unsigned cpl; 655 unsigned cpl;
653 656
654 la = seg_base(ctxt, addr.seg) + addr.ea; 657 la = seg_base(ctxt, addr.seg) + addr.ea;
658 *max_size = 0;
655 switch (ctxt->mode) { 659 switch (ctxt->mode) {
656 case X86EMUL_MODE_PROT64: 660 case X86EMUL_MODE_PROT64:
657 if (((signed long)la << 16) >> 16 != la) 661 if (((signed long)la << 16) >> 16 != la)
658 return emulate_gp(ctxt, 0); 662 return emulate_gp(ctxt, 0);
663
664 *max_size = min_t(u64, ~0u, (1ull << 48) - la);
665 if (size > *max_size)
666 goto bad;
659 break; 667 break;
660 default: 668 default:
661 usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL, 669 usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL,
@@ -673,20 +681,25 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
673 if ((ctxt->mode == X86EMUL_MODE_REAL) && !fetch && 681 if ((ctxt->mode == X86EMUL_MODE_REAL) && !fetch &&
674 (ctxt->d & NoBigReal)) { 682 (ctxt->d & NoBigReal)) {
675 /* la is between zero and 0xffff */ 683 /* la is between zero and 0xffff */
676 if (la > 0xffff || (u32)(la + size - 1) > 0xffff) 684 if (la > 0xffff)
677 goto bad; 685 goto bad;
686 *max_size = 0x10000 - la;
678 } else if ((desc.type & 8) || !(desc.type & 4)) { 687 } else if ((desc.type & 8) || !(desc.type & 4)) {
679 /* expand-up segment */ 688 /* expand-up segment */
680 if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim) 689 if (addr.ea > lim)
681 goto bad; 690 goto bad;
691 *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea);
682 } else { 692 } else {
683 /* expand-down segment */ 693 /* expand-down segment */
684 if (addr.ea <= lim || (u32)(addr.ea + size - 1) <= lim) 694 if (addr.ea <= lim)
685 goto bad; 695 goto bad;
686 lim = desc.d ? 0xffffffff : 0xffff; 696 lim = desc.d ? 0xffffffff : 0xffff;
687 if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim) 697 if (addr.ea > lim)
688 goto bad; 698 goto bad;
699 *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea);
689 } 700 }
701 if (size > *max_size)
702 goto bad;
690 cpl = ctxt->ops->cpl(ctxt); 703 cpl = ctxt->ops->cpl(ctxt);
691 if (!(desc.type & 8)) { 704 if (!(desc.type & 8)) {
692 /* data segment */ 705 /* data segment */
@@ -711,9 +724,9 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
711 return X86EMUL_CONTINUE; 724 return X86EMUL_CONTINUE;
712bad: 725bad:
713 if (addr.seg == VCPU_SREG_SS) 726 if (addr.seg == VCPU_SREG_SS)
714 return emulate_ss(ctxt, sel); 727 return emulate_ss(ctxt, 0);
715 else 728 else
716 return emulate_gp(ctxt, sel); 729 return emulate_gp(ctxt, 0);
717} 730}
718 731
719static int linearize(struct x86_emulate_ctxt *ctxt, 732static int linearize(struct x86_emulate_ctxt *ctxt,
@@ -721,7 +734,8 @@ static int linearize(struct x86_emulate_ctxt *ctxt,
721 unsigned size, bool write, 734 unsigned size, bool write,
722 ulong *linear) 735 ulong *linear)
723{ 736{
724 return __linearize(ctxt, addr, size, write, false, linear); 737 unsigned max_size;
738 return __linearize(ctxt, addr, &max_size, size, write, false, linear);
725} 739}
726 740
727 741
@@ -746,17 +760,27 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
746static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size) 760static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
747{ 761{
748 int rc; 762 int rc;
749 unsigned size; 763 unsigned size, max_size;
750 unsigned long linear; 764 unsigned long linear;
751 int cur_size = ctxt->fetch.end - ctxt->fetch.data; 765 int cur_size = ctxt->fetch.end - ctxt->fetch.data;
752 struct segmented_address addr = { .seg = VCPU_SREG_CS, 766 struct segmented_address addr = { .seg = VCPU_SREG_CS,
753 .ea = ctxt->eip + cur_size }; 767 .ea = ctxt->eip + cur_size };
754 768
755 size = 15UL ^ cur_size; 769 /*
756 rc = __linearize(ctxt, addr, size, false, true, &linear); 770 * We do not know exactly how many bytes will be needed, and
771 * __linearize is expensive, so fetch as much as possible. We
772 * just have to avoid going beyond the 15 byte limit, the end
773 * of the segment, or the end of the page.
774 *
775 * __linearize is called with size 0 so that it does not do any
776 * boundary check itself. Instead, we use max_size to check
777 * against op_size.
778 */
779 rc = __linearize(ctxt, addr, &max_size, 0, false, true, &linear);
757 if (unlikely(rc != X86EMUL_CONTINUE)) 780 if (unlikely(rc != X86EMUL_CONTINUE))
758 return rc; 781 return rc;
759 782
783 size = min_t(unsigned, 15UL ^ cur_size, max_size);
760 size = min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear)); 784 size = min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear));
761 785
762 /* 786 /*
@@ -766,7 +790,8 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
766 * still, we must have hit the 15-byte boundary. 790 * still, we must have hit the 15-byte boundary.
767 */ 791 */
768 if (unlikely(size < op_size)) 792 if (unlikely(size < op_size))
769 return X86EMUL_UNHANDLEABLE; 793 return emulate_gp(ctxt, 0);
794
770 rc = ctxt->ops->fetch(ctxt, linear, ctxt->fetch.end, 795 rc = ctxt->ops->fetch(ctxt, linear, ctxt->fetch.end,
771 size, &ctxt->exception); 796 size, &ctxt->exception);
772 if (unlikely(rc != X86EMUL_CONTINUE)) 797 if (unlikely(rc != X86EMUL_CONTINUE))
@@ -2012,7 +2037,7 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
2012 2037
2013 rc = assign_eip_far(ctxt, ctxt->src.val, new_desc.l); 2038 rc = assign_eip_far(ctxt, ctxt->src.val, new_desc.l);
2014 if (rc != X86EMUL_CONTINUE) { 2039 if (rc != X86EMUL_CONTINUE) {
2015 WARN_ON(!ctxt->mode != X86EMUL_MODE_PROT64); 2040 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
2016 /* assigning eip failed; restore the old cs */ 2041 /* assigning eip failed; restore the old cs */
2017 ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS); 2042 ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS);
2018 return rc; 2043 return rc;
@@ -2109,7 +2134,7 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
2109 return rc; 2134 return rc;
2110 rc = assign_eip_far(ctxt, eip, new_desc.l); 2135 rc = assign_eip_far(ctxt, eip, new_desc.l);
2111 if (rc != X86EMUL_CONTINUE) { 2136 if (rc != X86EMUL_CONTINUE) {
2112 WARN_ON(!ctxt->mode != X86EMUL_MODE_PROT64); 2137 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
2113 ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS); 2138 ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS);
2114 } 2139 }
2115 return rc; 2140 return rc;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a8b76c4c95e2..3e556c68351b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4579,7 +4579,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu)
4579 vmcs_write32(TPR_THRESHOLD, 0); 4579 vmcs_write32(TPR_THRESHOLD, 0);
4580 } 4580 }
4581 4581
4582 kvm_vcpu_reload_apic_access_page(vcpu); 4582 kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
4583 4583
4584 if (vmx_vm_has_apicv(vcpu->kvm)) 4584 if (vmx_vm_has_apicv(vcpu->kvm))
4585 memset(&vmx->pi_desc, 0, sizeof(struct pi_desc)); 4585 memset(&vmx->pi_desc, 0, sizeof(struct pi_desc));
@@ -6426,6 +6426,8 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
6426 const unsigned long *fields = shadow_read_write_fields; 6426 const unsigned long *fields = shadow_read_write_fields;
6427 const int num_fields = max_shadow_read_write_fields; 6427 const int num_fields = max_shadow_read_write_fields;
6428 6428
6429 preempt_disable();
6430
6429 vmcs_load(shadow_vmcs); 6431 vmcs_load(shadow_vmcs);
6430 6432
6431 for (i = 0; i < num_fields; i++) { 6433 for (i = 0; i < num_fields; i++) {
@@ -6449,6 +6451,8 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
6449 6451
6450 vmcs_clear(shadow_vmcs); 6452 vmcs_clear(shadow_vmcs);
6451 vmcs_load(vmx->loaded_vmcs->vmcs); 6453 vmcs_load(vmx->loaded_vmcs->vmcs);
6454
6455 preempt_enable();
6452} 6456}
6453 6457
6454static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) 6458static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index ae242a7c11c7..36de293caf25 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -409,7 +409,7 @@ phys_addr_t slow_virt_to_phys(void *__virt_addr)
409 psize = page_level_size(level); 409 psize = page_level_size(level);
410 pmask = page_level_mask(level); 410 pmask = page_level_mask(level);
411 offset = virt_addr & ~pmask; 411 offset = virt_addr & ~pmask;
412 phys_addr = pte_pfn(*pte) << PAGE_SHIFT; 412 phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT;
413 return (phys_addr | offset); 413 return (phys_addr | offset);
414} 414}
415EXPORT_SYMBOL_GPL(slow_virt_to_phys); 415EXPORT_SYMBOL_GPL(slow_virt_to_phys);
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index 3c53a90fdb18..c14ad34776c4 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -106,6 +106,7 @@ int __init sfi_parse_mtmr(struct sfi_table_header *table)
106 mp_irq.dstapic = MP_APIC_ALL; 106 mp_irq.dstapic = MP_APIC_ALL;
107 mp_irq.dstirq = pentry->irq; 107 mp_irq.dstirq = pentry->irq;
108 mp_save_irq(&mp_irq); 108 mp_save_irq(&mp_irq);
109 mp_map_gsi_to_irq(pentry->irq, IOAPIC_MAP_ALLOC);
109 } 110 }
110 111
111 return 0; 112 return 0;
@@ -176,6 +177,7 @@ int __init sfi_parse_mrtc(struct sfi_table_header *table)
176 mp_irq.dstapic = MP_APIC_ALL; 177 mp_irq.dstapic = MP_APIC_ALL;
177 mp_irq.dstirq = pentry->irq; 178 mp_irq.dstirq = pentry->irq;
178 mp_save_irq(&mp_irq); 179 mp_save_irq(&mp_irq);
180 mp_map_gsi_to_irq(pentry->irq, IOAPIC_MAP_ALLOC);
179 } 181 }
180 return 0; 182 return 0;
181} 183}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ba99351c0f58..b3ac40aef46b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -99,16 +99,17 @@ void 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 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE,
101 &q->queue_flags); 101 &q->queue_flags);
102 bool merge_not_need = bio->bi_vcnt < queue_max_segments(q);
102 103
103 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) && 104 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) &&
104 bio->bi_vcnt < queue_max_segments(q)) 105 merge_not_need)
105 bio->bi_phys_segments = bio->bi_vcnt; 106 bio->bi_phys_segments = bio->bi_vcnt;
106 else { 107 else {
107 struct bio *nxt = bio->bi_next; 108 struct bio *nxt = bio->bi_next;
108 109
109 bio->bi_next = NULL; 110 bio->bi_next = NULL;
110 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, 111 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio,
111 no_sg_merge); 112 no_sg_merge && merge_not_need);
112 bio->bi_next = nxt; 113 bio->bi_next = nxt;
113 } 114 }
114 115
diff --git a/block/elevator.c b/block/elevator.c
index 24c28b659bb3..afa3b037a17c 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -229,7 +229,9 @@ int elevator_init(struct request_queue *q, char *name)
229 } 229 }
230 230
231 err = e->ops.elevator_init_fn(q, e); 231 err = e->ops.elevator_init_fn(q, e);
232 return 0; 232 if (err)
233 elevator_put(e);
234 return err;
233} 235}
234EXPORT_SYMBOL(elevator_init); 236EXPORT_SYMBOL(elevator_init);
235 237
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index abb2e65b24cc..1e053d911240 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -508,7 +508,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
508 508
509 if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) { 509 if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) {
510 err = DRIVER_ERROR << 24; 510 err = DRIVER_ERROR << 24;
511 goto out; 511 goto error;
512 } 512 }
513 513
514 memset(sense, 0, sizeof(sense)); 514 memset(sense, 0, sizeof(sense));
@@ -517,7 +517,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
517 517
518 blk_execute_rq(q, disk, rq, 0); 518 blk_execute_rq(q, disk, rq, 0);
519 519
520out:
521 err = rq->errors & 0xff; /* only 8 bit SCSI status */ 520 err = rq->errors & 0xff; /* only 8 bit SCSI status */
522 if (err) { 521 if (err) {
523 if (rq->sense_len && rq->sense) { 522 if (rq->sense_len && rq->sense) {
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 3d304ff7f095..5f9b74b9b71f 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -126,6 +126,7 @@ static int EC_FLAGS_MSI; /* Out-of-spec MSI controller */
126static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */ 126static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */
127static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ 127static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */
128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ 128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
129static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
129 130
130/* -------------------------------------------------------------------------- 131/* --------------------------------------------------------------------------
131 * Transaction Management 132 * Transaction Management
@@ -236,13 +237,8 @@ static bool advance_transaction(struct acpi_ec *ec)
236 } 237 }
237 return wakeup; 238 return wakeup;
238 } else { 239 } else {
239 /* 240 if (EC_FLAGS_QUERY_HANDSHAKE &&
240 * There is firmware refusing to respond QR_EC when SCI_EVT 241 !(status & ACPI_EC_FLAG_SCI) &&
241 * is not set, for which case, we complete the QR_EC
242 * without issuing it to the firmware.
243 * https://bugzilla.kernel.org/show_bug.cgi?id=86211
244 */
245 if (!(status & ACPI_EC_FLAG_SCI) &&
246 (t->command == ACPI_EC_COMMAND_QUERY)) { 242 (t->command == ACPI_EC_COMMAND_QUERY)) {
247 t->flags |= ACPI_EC_COMMAND_POLL; 243 t->flags |= ACPI_EC_COMMAND_POLL;
248 t->rdata[t->ri++] = 0x00; 244 t->rdata[t->ri++] = 0x00;
@@ -334,13 +330,13 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
334 pr_debug("***** Command(%s) started *****\n", 330 pr_debug("***** Command(%s) started *****\n",
335 acpi_ec_cmd_string(t->command)); 331 acpi_ec_cmd_string(t->command));
336 start_transaction(ec); 332 start_transaction(ec);
337 spin_unlock_irqrestore(&ec->lock, tmp);
338 ret = ec_poll(ec);
339 spin_lock_irqsave(&ec->lock, tmp);
340 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 333 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
341 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 334 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
342 pr_debug("***** Event stopped *****\n"); 335 pr_debug("***** Event stopped *****\n");
343 } 336 }
337 spin_unlock_irqrestore(&ec->lock, tmp);
338 ret = ec_poll(ec);
339 spin_lock_irqsave(&ec->lock, tmp);
344 pr_debug("***** Command(%s) stopped *****\n", 340 pr_debug("***** Command(%s) stopped *****\n",
345 acpi_ec_cmd_string(t->command)); 341 acpi_ec_cmd_string(t->command));
346 ec->curr = NULL; 342 ec->curr = NULL;
@@ -1012,6 +1008,18 @@ static int ec_enlarge_storm_threshold(const struct dmi_system_id *id)
1012} 1008}
1013 1009
1014/* 1010/*
1011 * Acer EC firmware refuses to respond QR_EC when SCI_EVT is not set, for
1012 * which case, we complete the QR_EC without issuing it to the firmware.
1013 * https://bugzilla.kernel.org/show_bug.cgi?id=86211
1014 */
1015static int ec_flag_query_handshake(const struct dmi_system_id *id)
1016{
1017 pr_debug("Detected the EC firmware requiring QR_EC issued when SCI_EVT set\n");
1018 EC_FLAGS_QUERY_HANDSHAKE = 1;
1019 return 0;
1020}
1021
1022/*
1015 * On some hardware it is necessary to clear events accumulated by the EC during 1023 * On some hardware it is necessary to clear events accumulated by the EC during
1016 * sleep. These ECs stop reporting GPEs until they are manually polled, if too 1024 * sleep. These ECs stop reporting GPEs until they are manually polled, if too
1017 * many events are accumulated. (e.g. Samsung Series 5/9 notebooks) 1025 * many events are accumulated. (e.g. Samsung Series 5/9 notebooks)
@@ -1085,6 +1093,9 @@ static struct dmi_system_id ec_dmi_table[] __initdata = {
1085 { 1093 {
1086 ec_clear_on_resume, "Samsung hardware", { 1094 ec_clear_on_resume, "Samsung hardware", {
1087 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, 1095 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
1096 {
1097 ec_flag_query_handshake, "Acer hardware", {
1098 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), }, NULL},
1088 {}, 1099 {},
1089}; 1100};
1090 1101
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d670158a26c5..0476e90b2091 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -142,6 +142,53 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
142} 142}
143 143
144/* 144/*
145 * acpi_companion_match() - Can we match via ACPI companion device
146 * @dev: Device in question
147 *
148 * Check if the given device has an ACPI companion and if that companion has
149 * a valid list of PNP IDs, and if the device is the first (primary) physical
150 * device associated with it.
151 *
152 * If multiple physical devices are attached to a single ACPI companion, we need
153 * to be careful. The usage scenario for this kind of relationship is that all
154 * of the physical devices in question use resources provided by the ACPI
155 * companion. A typical case is an MFD device where all the sub-devices share
156 * the parent's ACPI companion. In such cases we can only allow the primary
157 * (first) physical device to be matched with the help of the companion's PNP
158 * IDs.
159 *
160 * Additional physical devices sharing the ACPI companion can still use
161 * resources available from it but they will be matched normally using functions
162 * provided by their bus types (and analogously for their modalias).
163 */
164static bool acpi_companion_match(const struct device *dev)
165{
166 struct acpi_device *adev;
167 bool ret;
168
169 adev = ACPI_COMPANION(dev);
170 if (!adev)
171 return false;
172
173 if (list_empty(&adev->pnp.ids))
174 return false;
175
176 mutex_lock(&adev->physical_node_lock);
177 if (list_empty(&adev->physical_node_list)) {
178 ret = false;
179 } else {
180 const struct acpi_device_physical_node *node;
181
182 node = list_first_entry(&adev->physical_node_list,
183 struct acpi_device_physical_node, node);
184 ret = node->dev == dev;
185 }
186 mutex_unlock(&adev->physical_node_lock);
187
188 return ret;
189}
190
191/*
145 * Creates uevent modalias field for ACPI enumerated devices. 192 * Creates uevent modalias field for ACPI enumerated devices.
146 * Because the other buses does not support ACPI HIDs & CIDs. 193 * Because the other buses does not support ACPI HIDs & CIDs.
147 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: 194 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
@@ -149,20 +196,14 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
149 */ 196 */
150int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) 197int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
151{ 198{
152 struct acpi_device *acpi_dev;
153 int len; 199 int len;
154 200
155 acpi_dev = ACPI_COMPANION(dev); 201 if (!acpi_companion_match(dev))
156 if (!acpi_dev)
157 return -ENODEV;
158
159 /* Fall back to bus specific way of modalias exporting */
160 if (list_empty(&acpi_dev->pnp.ids))
161 return -ENODEV; 202 return -ENODEV;
162 203
163 if (add_uevent_var(env, "MODALIAS=")) 204 if (add_uevent_var(env, "MODALIAS="))
164 return -ENOMEM; 205 return -ENOMEM;
165 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], 206 len = create_modalias(ACPI_COMPANION(dev), &env->buf[env->buflen - 1],
166 sizeof(env->buf) - env->buflen); 207 sizeof(env->buf) - env->buflen);
167 if (len <= 0) 208 if (len <= 0)
168 return len; 209 return len;
@@ -179,18 +220,12 @@ EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
179 */ 220 */
180int acpi_device_modalias(struct device *dev, char *buf, int size) 221int acpi_device_modalias(struct device *dev, char *buf, int size)
181{ 222{
182 struct acpi_device *acpi_dev;
183 int len; 223 int len;
184 224
185 acpi_dev = ACPI_COMPANION(dev); 225 if (!acpi_companion_match(dev))
186 if (!acpi_dev)
187 return -ENODEV; 226 return -ENODEV;
188 227
189 /* Fall back to bus specific way of modalias exporting */ 228 len = create_modalias(ACPI_COMPANION(dev), buf, size -1);
190 if (list_empty(&acpi_dev->pnp.ids))
191 return -ENODEV;
192
193 len = create_modalias(acpi_dev, buf, size -1);
194 if (len <= 0) 229 if (len <= 0)
195 return len; 230 return len;
196 buf[len++] = '\n'; 231 buf[len++] = '\n';
@@ -853,6 +888,9 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
853 if (!ids || !handle || acpi_bus_get_device(handle, &adev)) 888 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
854 return NULL; 889 return NULL;
855 890
891 if (!acpi_companion_match(dev))
892 return NULL;
893
856 return __acpi_match_device(adev, ids); 894 return __acpi_match_device(adev, ids);
857} 895}
858EXPORT_SYMBOL_GPL(acpi_match_device); 896EXPORT_SYMBOL_GPL(acpi_match_device);
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 61a33f4ba608..df04227d00cf 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -171,20 +171,23 @@ config WANT_DEV_COREDUMP
171 Drivers should "select" this option if they desire to use the 171 Drivers should "select" this option if they desire to use the
172 device coredump mechanism. 172 device coredump mechanism.
173 173
174config DISABLE_DEV_COREDUMP 174config ALLOW_DEV_COREDUMP
175 bool "Disable device coredump" if EXPERT 175 bool "Allow device coredump" if EXPERT
176 default y
176 help 177 help
177 Disable the device coredump mechanism despite drivers wanting to 178 This option controls if the device coredump mechanism is available or
178 use it; this allows for more sensitive systems or systems that 179 not; if disabled, the mechanism will be omitted even if drivers that
179 don't want to ever access the information to not have the code, 180 can use it are enabled.
180 nor keep any data. 181 Say 'N' for more sensitive systems or systems that don't want
182 to ever access the information to not have the code, nor keep any
183 data.
181 184
182 If unsure, say N. 185 If unsure, say Y.
183 186
184config DEV_COREDUMP 187config DEV_COREDUMP
185 bool 188 bool
186 default y if WANT_DEV_COREDUMP 189 default y if WANT_DEV_COREDUMP
187 depends on !DISABLE_DEV_COREDUMP 190 depends on ALLOW_DEV_COREDUMP
188 191
189config DEBUG_DRIVER 192config DEBUG_DRIVER
190 bool "Driver Core verbose debug messages" 193 bool "Driver Core verbose debug messages"
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 14d162952c3b..842d04707de6 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -724,12 +724,12 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
724 return &dir->kobj; 724 return &dir->kobj;
725} 725}
726 726
727static DEFINE_MUTEX(gdp_mutex);
727 728
728static struct kobject *get_device_parent(struct device *dev, 729static struct kobject *get_device_parent(struct device *dev,
729 struct device *parent) 730 struct device *parent)
730{ 731{
731 if (dev->class) { 732 if (dev->class) {
732 static DEFINE_MUTEX(gdp_mutex);
733 struct kobject *kobj = NULL; 733 struct kobject *kobj = NULL;
734 struct kobject *parent_kobj; 734 struct kobject *parent_kobj;
735 struct kobject *k; 735 struct kobject *k;
@@ -793,7 +793,9 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
793 glue_dir->kset != &dev->class->p->glue_dirs) 793 glue_dir->kset != &dev->class->p->glue_dirs)
794 return; 794 return;
795 795
796 mutex_lock(&gdp_mutex);
796 kobject_put(glue_dir); 797 kobject_put(glue_dir);
798 mutex_unlock(&gdp_mutex);
797} 799}
798 800
799static void cleanup_device_parent(struct device *dev) 801static void cleanup_device_parent(struct device *dev)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 473ff4892401..950fff9ce453 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -223,9 +223,10 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
223#undef pr_fmt 223#undef pr_fmt
224#define pr_fmt(fmt) fmt 224#define pr_fmt(fmt) fmt
225 225
226static void rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev) 226static int rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
227{ 227{
228 dev_set_cma_area(dev, rmem->priv); 228 dev_set_cma_area(dev, rmem->priv);
229 return 0;
229} 230}
230 231
231static void rmem_cma_device_release(struct reserved_mem *rmem, 232static void rmem_cma_device_release(struct reserved_mem *rmem,
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 44973196d3fd..9717d5f20139 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1266,6 +1266,8 @@ int dpm_suspend_late(pm_message_t state)
1266 } 1266 }
1267 mutex_unlock(&dpm_list_mtx); 1267 mutex_unlock(&dpm_list_mtx);
1268 async_synchronize_full(); 1268 async_synchronize_full();
1269 if (!error)
1270 error = async_error;
1269 if (error) { 1271 if (error) {
1270 suspend_stats.failed_suspend_late++; 1272 suspend_stats.failed_suspend_late++;
1271 dpm_save_failed_step(SUSPEND_SUSPEND_LATE); 1273 dpm_save_failed_step(SUSPEND_SUSPEND_LATE);
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 1e5ac0a79696..cd9161a8b3a1 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -275,7 +275,7 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend,
275static const struct pci_device_id bcma_pci_bridge_tbl[] = { 275static const struct pci_device_id bcma_pci_bridge_tbl[] = {
276 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, 276 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
277 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) }, 277 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) },
278 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, 278 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, /* 0xa8d8 */
279 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, 279 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
280 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, 280 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
281 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, 281 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
@@ -285,7 +285,8 @@ static const struct pci_device_id bcma_pci_bridge_tbl[] = {
285 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) }, 285 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
286 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) }, 286 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
287 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, 287 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
288 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xA8DB */ 288 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xa8db, BCM43217 (sic!) */
289 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) }, /* 0xa8dc */
289 { 0, }, 290 { 0, },
290}; 291};
291MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl); 292MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index d1656c2f70af..1000955ce09d 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -132,7 +132,7 @@ static bool bcma_is_core_needed_early(u16 core_id)
132 return false; 132 return false;
133} 133}
134 134
135#ifdef CONFIG_OF 135#if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS)
136static struct device_node *bcma_of_find_child_device(struct platform_device *parent, 136static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
137 struct bcma_device *core) 137 struct bcma_device *core)
138{ 138{
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 2671a3f02f0c..8001e812018b 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -450,14 +450,10 @@ static int init_driver_queues(struct nullb *nullb)
450 450
451 ret = setup_commands(nq); 451 ret = setup_commands(nq);
452 if (ret) 452 if (ret)
453 goto err_queue; 453 return ret;
454 nullb->nr_queues++; 454 nullb->nr_queues++;
455 } 455 }
456
457 return 0; 456 return 0;
458err_queue:
459 cleanup_queues(nullb);
460 return ret;
461} 457}
462 458
463static int null_add_dev(void) 459static int null_add_dev(void)
@@ -507,7 +503,9 @@ static int null_add_dev(void)
507 goto out_cleanup_queues; 503 goto out_cleanup_queues;
508 } 504 }
509 blk_queue_make_request(nullb->q, null_queue_bio); 505 blk_queue_make_request(nullb->q, null_queue_bio);
510 init_driver_queues(nullb); 506 rv = init_driver_queues(nullb);
507 if (rv)
508 goto out_cleanup_blk_queue;
511 } else { 509 } else {
512 nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); 510 nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node);
513 if (!nullb->q) { 511 if (!nullb->q) {
@@ -516,7 +514,9 @@ static int null_add_dev(void)
516 } 514 }
517 blk_queue_prep_rq(nullb->q, null_rq_prep_fn); 515 blk_queue_prep_rq(nullb->q, null_rq_prep_fn);
518 blk_queue_softirq_done(nullb->q, null_softirq_done_fn); 516 blk_queue_softirq_done(nullb->q, null_softirq_done_fn);
519 init_driver_queues(nullb); 517 rv = init_driver_queues(nullb);
518 if (rv)
519 goto out_cleanup_blk_queue;
520 } 520 }
521 521
522 nullb->q->queuedata = nullb; 522 nullb->q->queuedata = nullb;
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0a54c588e433..27b71a0b72d0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -342,7 +342,6 @@ struct rbd_device {
342 342
343 struct list_head rq_queue; /* incoming rq queue */ 343 struct list_head rq_queue; /* incoming rq queue */
344 spinlock_t lock; /* queue, flags, open_count */ 344 spinlock_t lock; /* queue, flags, open_count */
345 struct workqueue_struct *rq_wq;
346 struct work_struct rq_work; 345 struct work_struct rq_work;
347 346
348 struct rbd_image_header header; 347 struct rbd_image_header header;
@@ -402,6 +401,8 @@ static struct kmem_cache *rbd_segment_name_cache;
402static int rbd_major; 401static int rbd_major;
403static DEFINE_IDA(rbd_dev_id_ida); 402static DEFINE_IDA(rbd_dev_id_ida);
404 403
404static struct workqueue_struct *rbd_wq;
405
405/* 406/*
406 * Default to false for now, as single-major requires >= 0.75 version of 407 * Default to false for now, as single-major requires >= 0.75 version of
407 * userspace rbd utility. 408 * userspace rbd utility.
@@ -3452,7 +3453,7 @@ static void rbd_request_fn(struct request_queue *q)
3452 } 3453 }
3453 3454
3454 if (queued) 3455 if (queued)
3455 queue_work(rbd_dev->rq_wq, &rbd_dev->rq_work); 3456 queue_work(rbd_wq, &rbd_dev->rq_work);
3456} 3457}
3457 3458
3458/* 3459/*
@@ -3532,7 +3533,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
3532 page_count = (u32) calc_pages_for(offset, length); 3533 page_count = (u32) calc_pages_for(offset, length);
3533 pages = ceph_alloc_page_vector(page_count, GFP_KERNEL); 3534 pages = ceph_alloc_page_vector(page_count, GFP_KERNEL);
3534 if (IS_ERR(pages)) 3535 if (IS_ERR(pages))
3535 ret = PTR_ERR(pages); 3536 return PTR_ERR(pages);
3536 3537
3537 ret = -ENOMEM; 3538 ret = -ENOMEM;
3538 obj_request = rbd_obj_request_create(object_name, offset, length, 3539 obj_request = rbd_obj_request_create(object_name, offset, length,
@@ -5242,16 +5243,9 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5242 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 5243 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
5243 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only); 5244 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only);
5244 5245
5245 rbd_dev->rq_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0,
5246 rbd_dev->disk->disk_name);
5247 if (!rbd_dev->rq_wq) {
5248 ret = -ENOMEM;
5249 goto err_out_mapping;
5250 }
5251
5252 ret = rbd_bus_add_dev(rbd_dev); 5246 ret = rbd_bus_add_dev(rbd_dev);
5253 if (ret) 5247 if (ret)
5254 goto err_out_workqueue; 5248 goto err_out_mapping;
5255 5249
5256 /* Everything's ready. Announce the disk to the world. */ 5250 /* Everything's ready. Announce the disk to the world. */
5257 5251
@@ -5263,9 +5257,6 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5263 5257
5264 return ret; 5258 return ret;
5265 5259
5266err_out_workqueue:
5267 destroy_workqueue(rbd_dev->rq_wq);
5268 rbd_dev->rq_wq = NULL;
5269err_out_mapping: 5260err_out_mapping:
5270 rbd_dev_mapping_clear(rbd_dev); 5261 rbd_dev_mapping_clear(rbd_dev);
5271err_out_disk: 5262err_out_disk:
@@ -5512,7 +5503,6 @@ static void rbd_dev_device_release(struct device *dev)
5512{ 5503{
5513 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); 5504 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
5514 5505
5515 destroy_workqueue(rbd_dev->rq_wq);
5516 rbd_free_disk(rbd_dev); 5506 rbd_free_disk(rbd_dev);
5517 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 5507 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
5518 rbd_dev_mapping_clear(rbd_dev); 5508 rbd_dev_mapping_clear(rbd_dev);
@@ -5716,11 +5706,21 @@ static int __init rbd_init(void)
5716 if (rc) 5706 if (rc)
5717 return rc; 5707 return rc;
5718 5708
5709 /*
5710 * The number of active work items is limited by the number of
5711 * rbd devices, so leave @max_active at default.
5712 */
5713 rbd_wq = alloc_workqueue(RBD_DRV_NAME, WQ_MEM_RECLAIM, 0);
5714 if (!rbd_wq) {
5715 rc = -ENOMEM;
5716 goto err_out_slab;
5717 }
5718
5719 if (single_major) { 5719 if (single_major) {
5720 rbd_major = register_blkdev(0, RBD_DRV_NAME); 5720 rbd_major = register_blkdev(0, RBD_DRV_NAME);
5721 if (rbd_major < 0) { 5721 if (rbd_major < 0) {
5722 rc = rbd_major; 5722 rc = rbd_major;
5723 goto err_out_slab; 5723 goto err_out_wq;
5724 } 5724 }
5725 } 5725 }
5726 5726
@@ -5738,6 +5738,8 @@ static int __init rbd_init(void)
5738err_out_blkdev: 5738err_out_blkdev:
5739 if (single_major) 5739 if (single_major)
5740 unregister_blkdev(rbd_major, RBD_DRV_NAME); 5740 unregister_blkdev(rbd_major, RBD_DRV_NAME);
5741err_out_wq:
5742 destroy_workqueue(rbd_wq);
5741err_out_slab: 5743err_out_slab:
5742 rbd_slab_exit(); 5744 rbd_slab_exit();
5743 return rc; 5745 return rc;
@@ -5749,6 +5751,7 @@ static void __exit rbd_exit(void)
5749 rbd_sysfs_cleanup(); 5751 rbd_sysfs_cleanup();
5750 if (single_major) 5752 if (single_major)
5751 unregister_blkdev(rbd_major, RBD_DRV_NAME); 5753 unregister_blkdev(rbd_major, RBD_DRV_NAME);
5754 destroy_workqueue(rbd_wq);
5752 rbd_slab_exit(); 5755 rbd_slab_exit();
5753} 5756}
5754 5757
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 756b8ec00f16..0ebadf93b6c5 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -69,8 +69,6 @@ struct vdc_port {
69 u8 vdisk_mtype; 69 u8 vdisk_mtype;
70 70
71 char disk_name[32]; 71 char disk_name[32];
72
73 struct vio_disk_vtoc label;
74}; 72};
75 73
76static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio) 74static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
@@ -710,13 +708,6 @@ static int probe_disk(struct vdc_port *port)
710 if (comp.err) 708 if (comp.err)
711 return comp.err; 709 return comp.err;
712 710
713 err = generic_request(port, VD_OP_GET_VTOC,
714 &port->label, sizeof(port->label));
715 if (err < 0) {
716 printk(KERN_ERR PFX "VD_OP_GET_VTOC returns error %d\n", err);
717 return err;
718 }
719
720 if (vdc_version_supported(port, 1, 1)) { 711 if (vdc_version_supported(port, 1, 1)) {
721 /* vdisk_size should be set during the handshake, if it wasn't 712 /* vdisk_size should be set during the handshake, if it wasn't
722 * then the underlying disk is reserved by another system 713 * then the underlying disk is reserved by another system
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 0e63e8aa8279..2ad0b5bce44b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -99,11 +99,12 @@ static ssize_t mem_used_total_show(struct device *dev,
99{ 99{
100 u64 val = 0; 100 u64 val = 0;
101 struct zram *zram = dev_to_zram(dev); 101 struct zram *zram = dev_to_zram(dev);
102 struct zram_meta *meta = zram->meta;
103 102
104 down_read(&zram->init_lock); 103 down_read(&zram->init_lock);
105 if (init_done(zram)) 104 if (init_done(zram)) {
105 struct zram_meta *meta = zram->meta;
106 val = zs_get_total_pages(meta->mem_pool); 106 val = zs_get_total_pages(meta->mem_pool);
107 }
107 up_read(&zram->init_lock); 108 up_read(&zram->init_lock);
108 109
109 return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT); 110 return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT);
@@ -173,16 +174,17 @@ static ssize_t mem_used_max_store(struct device *dev,
173 int err; 174 int err;
174 unsigned long val; 175 unsigned long val;
175 struct zram *zram = dev_to_zram(dev); 176 struct zram *zram = dev_to_zram(dev);
176 struct zram_meta *meta = zram->meta;
177 177
178 err = kstrtoul(buf, 10, &val); 178 err = kstrtoul(buf, 10, &val);
179 if (err || val != 0) 179 if (err || val != 0)
180 return -EINVAL; 180 return -EINVAL;
181 181
182 down_read(&zram->init_lock); 182 down_read(&zram->init_lock);
183 if (init_done(zram)) 183 if (init_done(zram)) {
184 struct zram_meta *meta = zram->meta;
184 atomic_long_set(&zram->stats.max_used_pages, 185 atomic_long_set(&zram->stats.max_used_pages,
185 zs_get_total_pages(meta->mem_pool)); 186 zs_get_total_pages(meta->mem_pool));
187 }
186 up_read(&zram->init_lock); 188 up_read(&zram->init_lock);
187 189
188 return len; 190 return len;
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 0102dc788608..a24891b97547 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -285,7 +285,7 @@ static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
285 285
286static const struct file_operations raw_fops = { 286static const struct file_operations raw_fops = {
287 .read = new_sync_read, 287 .read = new_sync_read,
288 .read_iter = generic_file_read_iter, 288 .read_iter = blkdev_read_iter,
289 .write = new_sync_write, 289 .write = new_sync_write,
290 .write_iter = blkdev_write_iter, 290 .write_iter = blkdev_write_iter,
291 .fsync = blkdev_fsync, 291 .fsync = blkdev_fsync,
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 2133f9d59d06..43005d4d3348 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -660,11 +660,11 @@ static bool __init
660arch_timer_probed(int type, const struct of_device_id *matches) 660arch_timer_probed(int type, const struct of_device_id *matches)
661{ 661{
662 struct device_node *dn; 662 struct device_node *dn;
663 bool probed = false; 663 bool probed = true;
664 664
665 dn = of_find_matching_node(NULL, matches); 665 dn = of_find_matching_node(NULL, matches);
666 if (dn && of_device_is_available(dn) && (arch_timers_present & type)) 666 if (dn && of_device_is_available(dn) && !(arch_timers_present & type))
667 probed = true; 667 probed = false;
668 of_node_put(dn); 668 of_node_put(dn);
669 669
670 return probed; 670 return probed;
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 92c162af5045..23aaf40cf37f 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -187,6 +187,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
187 struct device *cpu_dev; 187 struct device *cpu_dev;
188 struct regulator *cpu_reg; 188 struct regulator *cpu_reg;
189 struct clk *cpu_clk; 189 struct clk *cpu_clk;
190 unsigned long min_uV = ~0, max_uV = 0;
190 unsigned int transition_latency; 191 unsigned int transition_latency;
191 int ret; 192 int ret;
192 193
@@ -206,16 +207,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
206 /* OPPs might be populated at runtime, don't check for error here */ 207 /* OPPs might be populated at runtime, don't check for error here */
207 of_init_opp_table(cpu_dev); 208 of_init_opp_table(cpu_dev);
208 209
209 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
210 if (ret) {
211 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
212 goto out_put_node;
213 }
214
215 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 210 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
216 if (!priv) { 211 if (!priv) {
217 ret = -ENOMEM; 212 ret = -ENOMEM;
218 goto out_free_table; 213 goto out_put_node;
219 } 214 }
220 215
221 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); 216 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
@@ -224,30 +219,51 @@ static int cpufreq_init(struct cpufreq_policy *policy)
224 transition_latency = CPUFREQ_ETERNAL; 219 transition_latency = CPUFREQ_ETERNAL;
225 220
226 if (!IS_ERR(cpu_reg)) { 221 if (!IS_ERR(cpu_reg)) {
227 struct dev_pm_opp *opp; 222 unsigned long opp_freq = 0;
228 unsigned long min_uV, max_uV;
229 int i;
230 223
231 /* 224 /*
232 * OPP is maintained in order of increasing frequency, and 225 * Disable any OPPs where the connected regulator isn't able to
233 * freq_table initialised from OPP is therefore sorted in the 226 * provide the specified voltage and record minimum and maximum
234 * same order. 227 * voltage levels.
235 */ 228 */
236 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) 229 while (1) {
237 ; 230 struct dev_pm_opp *opp;
238 rcu_read_lock(); 231 unsigned long opp_uV, tol_uV;
239 opp = dev_pm_opp_find_freq_exact(cpu_dev, 232
240 freq_table[0].frequency * 1000, true); 233 rcu_read_lock();
241 min_uV = dev_pm_opp_get_voltage(opp); 234 opp = dev_pm_opp_find_freq_ceil(cpu_dev, &opp_freq);
242 opp = dev_pm_opp_find_freq_exact(cpu_dev, 235 if (IS_ERR(opp)) {
243 freq_table[i-1].frequency * 1000, true); 236 rcu_read_unlock();
244 max_uV = dev_pm_opp_get_voltage(opp); 237 break;
245 rcu_read_unlock(); 238 }
239 opp_uV = dev_pm_opp_get_voltage(opp);
240 rcu_read_unlock();
241
242 tol_uV = opp_uV * priv->voltage_tolerance / 100;
243 if (regulator_is_supported_voltage(cpu_reg, opp_uV,
244 opp_uV + tol_uV)) {
245 if (opp_uV < min_uV)
246 min_uV = opp_uV;
247 if (opp_uV > max_uV)
248 max_uV = opp_uV;
249 } else {
250 dev_pm_opp_disable(cpu_dev, opp_freq);
251 }
252
253 opp_freq++;
254 }
255
246 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV); 256 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
247 if (ret > 0) 257 if (ret > 0)
248 transition_latency += ret * 1000; 258 transition_latency += ret * 1000;
249 } 259 }
250 260
261 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
262 if (ret) {
263 pr_err("failed to init cpufreq table: %d\n", ret);
264 goto out_free_priv;
265 }
266
251 /* 267 /*
252 * For now, just loading the cooling device; 268 * For now, just loading the cooling device;
253 * thermal DT code takes care of matching them. 269 * thermal DT code takes care of matching them.
@@ -277,7 +293,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
277 policy->cpuinfo.transition_latency = transition_latency; 293 policy->cpuinfo.transition_latency = transition_latency;
278 294
279 pd = cpufreq_get_driver_data(); 295 pd = cpufreq_get_driver_data();
280 if (pd && !pd->independent_clocks) 296 if (!pd || !pd->independent_clocks)
281 cpumask_setall(policy->cpus); 297 cpumask_setall(policy->cpus);
282 298
283 of_node_put(np); 299 of_node_put(np);
@@ -286,9 +302,9 @@ static int cpufreq_init(struct cpufreq_policy *policy)
286 302
287out_cooling_unregister: 303out_cooling_unregister:
288 cpufreq_cooling_unregister(priv->cdev); 304 cpufreq_cooling_unregister(priv->cdev);
289 kfree(priv);
290out_free_table:
291 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 305 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
306out_free_priv:
307 kfree(priv);
292out_put_node: 308out_put_node:
293 of_node_put(np); 309 of_node_put(np);
294out_put_reg_clk: 310out_put_reg_clk:
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 123f578d6dd3..4cfaaa5a49be 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -1107,52 +1107,14 @@ bool edma_filter_fn(struct dma_chan *chan, void *param)
1107} 1107}
1108EXPORT_SYMBOL(edma_filter_fn); 1108EXPORT_SYMBOL(edma_filter_fn);
1109 1109
1110static struct platform_device *pdev0, *pdev1;
1111
1112static const struct platform_device_info edma_dev_info0 = {
1113 .name = "edma-dma-engine",
1114 .id = 0,
1115 .dma_mask = DMA_BIT_MASK(32),
1116};
1117
1118static const struct platform_device_info edma_dev_info1 = {
1119 .name = "edma-dma-engine",
1120 .id = 1,
1121 .dma_mask = DMA_BIT_MASK(32),
1122};
1123
1124static int edma_init(void) 1110static int edma_init(void)
1125{ 1111{
1126 int ret = platform_driver_register(&edma_driver); 1112 return platform_driver_register(&edma_driver);
1127
1128 if (ret == 0) {
1129 pdev0 = platform_device_register_full(&edma_dev_info0);
1130 if (IS_ERR(pdev0)) {
1131 platform_driver_unregister(&edma_driver);
1132 ret = PTR_ERR(pdev0);
1133 goto out;
1134 }
1135 }
1136
1137 if (!of_have_populated_dt() && EDMA_CTLRS == 2) {
1138 pdev1 = platform_device_register_full(&edma_dev_info1);
1139 if (IS_ERR(pdev1)) {
1140 platform_driver_unregister(&edma_driver);
1141 platform_device_unregister(pdev0);
1142 ret = PTR_ERR(pdev1);
1143 }
1144 }
1145
1146out:
1147 return ret;
1148} 1113}
1149subsys_initcall(edma_init); 1114subsys_initcall(edma_init);
1150 1115
1151static void __exit edma_exit(void) 1116static void __exit edma_exit(void)
1152{ 1117{
1153 platform_device_unregister(pdev0);
1154 if (pdev1)
1155 platform_device_unregister(pdev1);
1156 platform_driver_unregister(&edma_driver); 1118 platform_driver_unregister(&edma_driver);
1157} 1119}
1158module_exit(edma_exit); 1120module_exit(edma_exit);
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 9a0cc09e6653..e4a1490b42c2 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -260,7 +260,7 @@ static void armada_drm_vblank_off(struct armada_crtc *dcrtc)
260 * Tell the DRM core that vblank IRQs aren't going to happen for 260 * Tell the DRM core that vblank IRQs aren't going to happen for
261 * a while. This cleans up any pending vblank events for us. 261 * a while. This cleans up any pending vblank events for us.
262 */ 262 */
263 drm_vblank_off(dev, dcrtc->num); 263 drm_crtc_vblank_off(&dcrtc->crtc);
264 264
265 /* Handle any pending flip event. */ 265 /* Handle any pending flip event. */
266 spin_lock_irq(&dev->event_lock); 266 spin_lock_irq(&dev->event_lock);
@@ -289,6 +289,8 @@ static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
289 armada_drm_crtc_update(dcrtc); 289 armada_drm_crtc_update(dcrtc);
290 if (dpms_blanked(dpms)) 290 if (dpms_blanked(dpms))
291 armada_drm_vblank_off(dcrtc); 291 armada_drm_vblank_off(dcrtc);
292 else
293 drm_crtc_vblank_on(&dcrtc->crtc);
292 } 294 }
293} 295}
294 296
@@ -526,7 +528,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
526 /* Wait for pending flips to complete */ 528 /* Wait for pending flips to complete */
527 wait_event(dcrtc->frame_wait, !dcrtc->frame_work); 529 wait_event(dcrtc->frame_wait, !dcrtc->frame_work);
528 530
529 drm_vblank_pre_modeset(crtc->dev, dcrtc->num); 531 drm_crtc_vblank_off(crtc);
530 532
531 crtc->mode = *adj; 533 crtc->mode = *adj;
532 534
@@ -617,7 +619,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
617 619
618 armada_drm_crtc_update(dcrtc); 620 armada_drm_crtc_update(dcrtc);
619 621
620 drm_vblank_post_modeset(crtc->dev, dcrtc->num); 622 drm_crtc_vblank_on(crtc);
621 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms)); 623 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms));
622 624
623 return 0; 625 return 0;
@@ -945,18 +947,15 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
945 armada_reg_queue_end(work->regs, i); 947 armada_reg_queue_end(work->regs, i);
946 948
947 /* 949 /*
948 * Hold the old framebuffer for the work - DRM appears to drop our 950 * Ensure that we hold a reference on the new framebuffer.
949 * reference to the old framebuffer in drm_mode_page_flip_ioctl(). 951 * This has to match the behaviour in mode_set.
950 */ 952 */
951 drm_framebuffer_reference(work->old_fb); 953 drm_framebuffer_reference(fb);
952 954
953 ret = armada_drm_crtc_queue_frame_work(dcrtc, work); 955 ret = armada_drm_crtc_queue_frame_work(dcrtc, work);
954 if (ret) { 956 if (ret) {
955 /* 957 /* Undo our reference above */
956 * Undo our reference above; DRM does not drop the reference 958 drm_framebuffer_unreference(fb);
957 * to this object on error, so that's okay.
958 */
959 drm_framebuffer_unreference(work->old_fb);
960 kfree(work); 959 kfree(work);
961 return ret; 960 return ret;
962 } 961 }
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index f672e6ad8afa..908e5316eac4 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -190,6 +190,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
190 if (ret) 190 if (ret)
191 goto err_comp; 191 goto err_comp;
192 192
193 dev->irq_enabled = true;
193 dev->vblank_disable_allowed = 1; 194 dev->vblank_disable_allowed = 1;
194 195
195 ret = armada_fbdev_init(dev); 196 ret = armada_fbdev_init(dev);
@@ -331,7 +332,7 @@ static struct drm_driver armada_drm_driver = {
331 .desc = "Armada SoC DRM", 332 .desc = "Armada SoC DRM",
332 .date = "20120730", 333 .date = "20120730",
333 .driver_features = DRIVER_GEM | DRIVER_MODESET | 334 .driver_features = DRIVER_GEM | DRIVER_MODESET |
334 DRIVER_PRIME, 335 DRIVER_HAVE_IRQ | DRIVER_PRIME,
335 .ioctls = armada_ioctls, 336 .ioctls = armada_ioctls,
336 .fops = &armada_drm_fops, 337 .fops = &armada_drm_fops,
337}; 338};
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index cd50ece31601..6adb1e5cfb08 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -1355,13 +1355,8 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
1355 void *data) 1355 void *data)
1356{ 1356{
1357 struct exynos_drm_display *display = dev_get_drvdata(dev); 1357 struct exynos_drm_display *display = dev_get_drvdata(dev);
1358 struct exynos_dp_device *dp = display->ctx;
1359 struct drm_encoder *encoder = dp->encoder;
1360 1358
1361 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); 1359 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
1362
1363 exynos_dp_connector_destroy(&dp->connector);
1364 encoder->funcs->destroy(encoder);
1365} 1360}
1366 1361
1367static const struct component_ops exynos_dp_ops = { 1362static const struct component_ops exynos_dp_ops = {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 8e38e9f8e542..45026e693225 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -71,13 +71,16 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
71 !atomic_read(&exynos_crtc->pending_flip), 71 !atomic_read(&exynos_crtc->pending_flip),
72 HZ/20)) 72 HZ/20))
73 atomic_set(&exynos_crtc->pending_flip, 0); 73 atomic_set(&exynos_crtc->pending_flip, 0);
74 drm_vblank_off(crtc->dev, exynos_crtc->pipe); 74 drm_crtc_vblank_off(crtc);
75 } 75 }
76 76
77 if (manager->ops->dpms) 77 if (manager->ops->dpms)
78 manager->ops->dpms(manager, mode); 78 manager->ops->dpms(manager, mode);
79 79
80 exynos_crtc->dpms = mode; 80 exynos_crtc->dpms = mode;
81
82 if (mode == DRM_MODE_DPMS_ON)
83 drm_crtc_vblank_on(crtc);
81} 84}
82 85
83static void exynos_drm_crtc_prepare(struct drm_crtc *crtc) 86static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 96c87db388fb..3dc678ed9949 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -338,14 +338,10 @@ err_del_component:
338 338
339int exynos_dpi_remove(struct device *dev) 339int exynos_dpi_remove(struct device *dev)
340{ 340{
341 struct drm_encoder *encoder = exynos_dpi_display.encoder;
342 struct exynos_dpi *ctx = exynos_dpi_display.ctx; 341 struct exynos_dpi *ctx = exynos_dpi_display.ctx;
343 342
344 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF); 343 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF);
345 344
346 exynos_dpi_connector_destroy(&ctx->connector);
347 encoder->funcs->destroy(encoder);
348
349 if (ctx->panel) 345 if (ctx->panel)
350 drm_panel_detach(ctx->panel); 346 drm_panel_detach(ctx->panel);
351 347
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 443a2069858a..c57466edf45b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -87,16 +87,12 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
87 87
88 plane = exynos_plane_init(dev, possible_crtcs, 88 plane = exynos_plane_init(dev, possible_crtcs,
89 DRM_PLANE_TYPE_OVERLAY); 89 DRM_PLANE_TYPE_OVERLAY);
90 if (IS_ERR(plane)) 90 if (!IS_ERR(plane))
91 goto err_mode_config_cleanup; 91 continue;
92 }
93
94 /* init kms poll for handling hpd */
95 drm_kms_helper_poll_init(dev);
96 92
97 ret = drm_vblank_init(dev, MAX_CRTC); 93 ret = PTR_ERR(plane);
98 if (ret)
99 goto err_mode_config_cleanup; 94 goto err_mode_config_cleanup;
95 }
100 96
101 /* setup possible_clones. */ 97 /* setup possible_clones. */
102 exynos_drm_encoder_setup(dev); 98 exynos_drm_encoder_setup(dev);
@@ -106,15 +102,16 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
106 /* Try to bind all sub drivers. */ 102 /* Try to bind all sub drivers. */
107 ret = component_bind_all(dev->dev, dev); 103 ret = component_bind_all(dev->dev, dev);
108 if (ret) 104 if (ret)
109 goto err_cleanup_vblank; 105 goto err_mode_config_cleanup;
110 106
111 /* Probe non kms sub drivers and virtual display driver. */ 107 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret) 108 if (ret)
114 goto err_unbind_all; 109 goto err_unbind_all;
115 110
116 /* force connectors detection */ 111 /* Probe non kms sub drivers and virtual display driver. */
117 drm_helper_hpd_irq_event(dev); 112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret)
114 goto err_cleanup_vblank;
118 115
119 /* 116 /*
120 * enable drm irq mode. 117 * enable drm irq mode.
@@ -133,12 +130,18 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
133 */ 130 */
134 dev->vblank_disable_allowed = true; 131 dev->vblank_disable_allowed = true;
135 132
133 /* init kms poll for handling hpd */
134 drm_kms_helper_poll_init(dev);
135
136 /* force connectors detection */
137 drm_helper_hpd_irq_event(dev);
138
136 return 0; 139 return 0;
137 140
138err_unbind_all:
139 component_unbind_all(dev->dev, dev);
140err_cleanup_vblank: 141err_cleanup_vblank:
141 drm_vblank_cleanup(dev); 142 drm_vblank_cleanup(dev);
143err_unbind_all:
144 component_unbind_all(dev->dev, dev);
142err_mode_config_cleanup: 145err_mode_config_cleanup:
143 drm_mode_config_cleanup(dev); 146 drm_mode_config_cleanup(dev);
144 drm_release_iommu_mapping(dev); 147 drm_release_iommu_mapping(dev);
@@ -155,8 +158,8 @@ static int exynos_drm_unload(struct drm_device *dev)
155 exynos_drm_fbdev_fini(dev); 158 exynos_drm_fbdev_fini(dev);
156 drm_kms_helper_poll_fini(dev); 159 drm_kms_helper_poll_fini(dev);
157 160
158 component_unbind_all(dev->dev, dev);
159 drm_vblank_cleanup(dev); 161 drm_vblank_cleanup(dev);
162 component_unbind_all(dev->dev, dev);
160 drm_mode_config_cleanup(dev); 163 drm_mode_config_cleanup(dev);
161 drm_release_iommu_mapping(dev); 164 drm_release_iommu_mapping(dev);
162 165
@@ -191,8 +194,12 @@ static int exynos_drm_resume(struct drm_device *dev)
191 194
192 drm_modeset_lock_all(dev); 195 drm_modeset_lock_all(dev);
193 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 196 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
194 if (connector->funcs->dpms) 197 if (connector->funcs->dpms) {
195 connector->funcs->dpms(connector, connector->dpms); 198 int dpms = connector->dpms;
199
200 connector->dpms = DRM_MODE_DPMS_OFF;
201 connector->funcs->dpms(connector, dpms);
202 }
196 } 203 }
197 drm_modeset_unlock_all(dev); 204 drm_modeset_unlock_all(dev);
198 205
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 24741d8758e8..acf7e9e39dcd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1660,13 +1660,9 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master,
1660 void *data) 1660 void *data)
1661{ 1661{
1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx; 1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx;
1663 struct drm_encoder *encoder = dsi->encoder;
1664 1663
1665 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF); 1664 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF);
1666 1665
1667 exynos_dsi_connector_destroy(&dsi->connector);
1668 encoder->funcs->destroy(encoder);
1669
1670 mipi_dsi_host_unregister(&dsi->dsi_host); 1666 mipi_dsi_host_unregister(&dsi->dsi_host);
1671} 1667}
1672 1668
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index d565207040a2..50faf913e574 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -630,7 +630,6 @@ static int vidi_remove(struct platform_device *pdev)
630{ 630{
631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev); 631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev);
632 struct vidi_context *ctx = mgr->ctx; 632 struct vidi_context *ctx = mgr->ctx;
633 struct drm_encoder *encoder = ctx->encoder;
634 633
635 if (ctx->raw_edid != (struct edid *)fake_edid_info) { 634 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
636 kfree(ctx->raw_edid); 635 kfree(ctx->raw_edid);
@@ -639,9 +638,6 @@ static int vidi_remove(struct platform_device *pdev)
639 return -EINVAL; 638 return -EINVAL;
640 } 639 }
641 640
642 encoder->funcs->destroy(encoder);
643 drm_connector_cleanup(&ctx->connector);
644
645 return 0; 641 return 0;
646} 642}
647 643
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 7910fb37d9bb..563a19e62eb2 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2312,12 +2312,6 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
2312 2312
2313static void hdmi_unbind(struct device *dev, struct device *master, void *data) 2313static void hdmi_unbind(struct device *dev, struct device *master, void *data)
2314{ 2314{
2315 struct exynos_drm_display *display = get_hdmi_display(dev);
2316 struct drm_encoder *encoder = display->encoder;
2317 struct hdmi_context *hdata = display->ctx;
2318
2319 hdmi_connector_destroy(&hdata->connector);
2320 encoder->funcs->destroy(encoder);
2321} 2315}
2322 2316
2323static const struct component_ops hdmi_component_ops = { 2317static const struct component_ops hdmi_component_ops = {
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c9e220963a78..f0a1a56406eb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4585,7 +4585,7 @@ static void vlv_update_cdclk(struct drm_device *dev)
4585 * BSpec erroneously claims we should aim for 4MHz, but 4585 * BSpec erroneously claims we should aim for 4MHz, but
4586 * in fact 1MHz is the correct frequency. 4586 * in fact 1MHz is the correct frequency.
4587 */ 4587 */
4588 I915_WRITE(GMBUSFREQ_VLV, dev_priv->vlv_cdclk_freq); 4588 I915_WRITE(GMBUSFREQ_VLV, DIV_ROUND_UP(dev_priv->vlv_cdclk_freq, 1000));
4589} 4589}
4590 4590
4591/* Adjust CDclk dividers to allow high res or save power if possible */ 4591/* Adjust CDclk dividers to allow high res or save power if possible */
@@ -12885,6 +12885,9 @@ static struct intel_quirk intel_quirks[] = {
12885 /* Acer C720 Chromebook (Core i3 4005U) */ 12885 /* Acer C720 Chromebook (Core i3 4005U) */
12886 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, 12886 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present },
12887 12887
12888 /* Apple Macbook 2,1 (Core 2 T7400) */
12889 { 0x27a2, 0x8086, 0x7270, quirk_backlight_present },
12890
12888 /* Toshiba CB35 Chromebook (Celeron 2955U) */ 12891 /* Toshiba CB35 Chromebook (Celeron 2955U) */
12889 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, 12892 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },
12890 12893
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f6a3fdd5589e..5ad45bfff3fe 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2806,6 +2806,13 @@ intel_dp_dpcd_read_wake(struct drm_dp_aux *aux, unsigned int offset,
2806 ssize_t ret; 2806 ssize_t ret;
2807 int i; 2807 int i;
2808 2808
2809 /*
2810 * Sometime we just get the same incorrect byte repeated
2811 * over the entire buffer. Doing just one throw away read
2812 * initially seems to "solve" it.
2813 */
2814 drm_dp_dpcd_read(aux, DP_DPCD_REV, buffer, 1);
2815
2809 for (i = 0; i < 3; i++) { 2816 for (i = 0; i < 3; i++) {
2810 ret = drm_dp_dpcd_read(aux, offset, buffer, size); 2817 ret = drm_dp_dpcd_read(aux, offset, buffer, size);
2811 if (ret == size) 2818 if (ret == size)
@@ -3724,9 +3731,10 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
3724 } 3731 }
3725 } 3732 }
3726 3733
3727 /* Training Pattern 3 support */ 3734 /* Training Pattern 3 support, both source and sink */
3728 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 && 3735 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 &&
3729 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED) { 3736 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED &&
3737 (IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8)) {
3730 intel_dp->use_tps3 = true; 3738 intel_dp->use_tps3 = true;
3731 DRM_DEBUG_KMS("Displayport TPS3 supported\n"); 3739 DRM_DEBUG_KMS("Displayport TPS3 supported\n");
3732 } else 3740 } else
@@ -4491,6 +4499,18 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
4491 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP) 4499 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP)
4492 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT; 4500 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT;
4493 4501
4502 if (long_hpd && intel_dig_port->base.type == INTEL_OUTPUT_EDP) {
4503 /*
4504 * vdd off can generate a long pulse on eDP which
4505 * would require vdd on to handle it, and thus we
4506 * would end up in an endless cycle of
4507 * "vdd off -> long hpd -> vdd on -> detect -> vdd off -> ..."
4508 */
4509 DRM_DEBUG_KMS("ignoring long hpd on eDP port %c\n",
4510 port_name(intel_dig_port->port));
4511 return false;
4512 }
4513
4494 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n", 4514 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n",
4495 port_name(intel_dig_port->port), 4515 port_name(intel_dig_port->port),
4496 long_hpd ? "long" : "short"); 4516 long_hpd ? "long" : "short");
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a31f1ca40c6a..f37d39d2bbbc 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3005,7 +3005,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3005 u32 vgt_cache_invalidation; 3005 u32 vgt_cache_invalidation;
3006 u32 hdp_host_path_cntl, tmp; 3006 u32 hdp_host_path_cntl, tmp;
3007 u32 disabled_rb_mask; 3007 u32 disabled_rb_mask;
3008 int i, j, num_shader_engines, ps_thread_count; 3008 int i, j, ps_thread_count;
3009 3009
3010 switch (rdev->family) { 3010 switch (rdev->family) {
3011 case CHIP_CYPRESS: 3011 case CHIP_CYPRESS:
@@ -3303,8 +3303,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3303 rdev->config.evergreen.tile_config |= 3303 rdev->config.evergreen.tile_config |=
3304 ((gb_addr_config & 0x30000000) >> 28) << 12; 3304 ((gb_addr_config & 0x30000000) >> 28) << 12;
3305 3305
3306 num_shader_engines = (gb_addr_config & NUM_SHADER_ENGINES(3) >> 12) + 1;
3307
3308 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) { 3306 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) {
3309 u32 efuse_straps_4; 3307 u32 efuse_straps_4;
3310 u32 efuse_straps_3; 3308 u32 efuse_straps_3;
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 1dd976f447fa..9b42001295ba 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2725,7 +2725,11 @@ int kv_dpm_init(struct radeon_device *rdev)
2725 2725
2726 pi->sram_end = SMC_RAM_END; 2726 pi->sram_end = SMC_RAM_END;
2727 2727
2728 pi->enable_nb_dpm = true; 2728 /* Enabling nb dpm on an asrock system prevents dpm from working */
2729 if (rdev->pdev->subsystem_vendor == 0x1849)
2730 pi->enable_nb_dpm = false;
2731 else
2732 pi->enable_nb_dpm = true;
2729 2733
2730 pi->caps_power_containment = true; 2734 pi->caps_power_containment = true;
2731 pi->caps_cac = true; 2735 pi->caps_cac = true;
@@ -2740,10 +2744,19 @@ int kv_dpm_init(struct radeon_device *rdev)
2740 pi->caps_sclk_ds = true; 2744 pi->caps_sclk_ds = true;
2741 pi->enable_auto_thermal_throttling = true; 2745 pi->enable_auto_thermal_throttling = true;
2742 pi->disable_nb_ps3_in_battery = false; 2746 pi->disable_nb_ps3_in_battery = false;
2743 if (radeon_bapm == 0) 2747 if (radeon_bapm == -1) {
2748 /* There are stability issues reported on with
2749 * bapm enabled on an asrock system.
2750 */
2751 if (rdev->pdev->subsystem_vendor == 0x1849)
2752 pi->bapm_enable = false;
2753 else
2754 pi->bapm_enable = true;
2755 } else if (radeon_bapm == 0) {
2744 pi->bapm_enable = false; 2756 pi->bapm_enable = false;
2745 else 2757 } else {
2746 pi->bapm_enable = true; 2758 pi->bapm_enable = true;
2759 }
2747 pi->voltage_drop_t = 0; 2760 pi->voltage_drop_t = 0;
2748 pi->caps_sclk_throttle_low_notification = false; 2761 pi->caps_sclk_throttle_low_notification = false;
2749 pi->caps_fps = false; /* true? */ 2762 pi->caps_fps = false; /* true? */
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 6a03624fadaa..63ccb8fa799c 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -658,12 +658,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
658 r = igp_read_bios_from_vram(rdev); 658 r = igp_read_bios_from_vram(rdev);
659 if (r == false) 659 if (r == false)
660 r = radeon_read_bios(rdev); 660 r = radeon_read_bios(rdev);
661 if (r == false) { 661 if (r == false)
662 r = radeon_read_disabled_bios(rdev); 662 r = radeon_read_disabled_bios(rdev);
663 } 663 if (r == false)
664 if (r == false) {
665 r = radeon_read_platform_bios(rdev); 664 r = radeon_read_platform_bios(rdev);
666 }
667 if (r == false || rdev->bios == NULL) { 665 if (r == false || rdev->bios == NULL) {
668 DRM_ERROR("Unable to locate a BIOS ROM\n"); 666 DRM_ERROR("Unable to locate a BIOS ROM\n");
669 rdev->bios = NULL; 667 rdev->bios = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 1c893447d7cd..a3e7aed7e680 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -450,7 +450,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
450 kfree(parser->track); 450 kfree(parser->track);
451 kfree(parser->relocs); 451 kfree(parser->relocs);
452 kfree(parser->relocs_ptr); 452 kfree(parser->relocs_ptr);
453 kfree(parser->vm_bos); 453 drm_free_large(parser->vm_bos);
454 for (i = 0; i < parser->nchunks; i++) 454 for (i = 0; i < parser->nchunks; i++)
455 drm_free_large(parser->chunks[i].kdata); 455 drm_free_large(parser->chunks[i].kdata);
456 kfree(parser->chunks); 456 kfree(parser->chunks);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 3d17af34afa7..2456f69efd23 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -314,7 +314,7 @@ unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring
314 } 314 }
315 315
316 /* and then save the content of the ring */ 316 /* and then save the content of the ring */
317 *data = kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); 317 *data = drm_malloc_ab(size, sizeof(uint32_t));
318 if (!*data) { 318 if (!*data) {
319 mutex_unlock(&rdev->ring_lock); 319 mutex_unlock(&rdev->ring_lock);
320 return 0; 320 return 0;
@@ -356,7 +356,7 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
356 } 356 }
357 357
358 radeon_ring_unlock_commit(rdev, ring, false); 358 radeon_ring_unlock_commit(rdev, ring, false);
359 kfree(data); 359 drm_free_large(data);
360 return 0; 360 return 0;
361} 361}
362 362
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 4532cc76a0a6..dfde266529e2 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -132,8 +132,8 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev,
132 struct radeon_cs_reloc *list; 132 struct radeon_cs_reloc *list;
133 unsigned i, idx; 133 unsigned i, idx;
134 134
135 list = kmalloc_array(vm->max_pde_used + 2, 135 list = drm_malloc_ab(vm->max_pde_used + 2,
136 sizeof(struct radeon_cs_reloc), GFP_KERNEL); 136 sizeof(struct radeon_cs_reloc));
137 if (!list) 137 if (!list)
138 return NULL; 138 return NULL;
139 139
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index a53c2e79d9cb..676e6c2ba90a 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -6256,7 +6256,7 @@ static void si_parse_pplib_clock_info(struct radeon_device *rdev,
6256 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) && 6256 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
6257 index == 0) { 6257 index == 0) {
6258 /* XXX disable for A0 tahiti */ 6258 /* XXX disable for A0 tahiti */
6259 si_pi->ulv.supported = true; 6259 si_pi->ulv.supported = false;
6260 si_pi->ulv.pl = *pl; 6260 si_pi->ulv.pl = *pl;
6261 si_pi->ulv.one_pcie_lane_in_ulv = false; 6261 si_pi->ulv.one_pcie_lane_in_ulv = false;
6262 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT; 6262 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
index bfeb4b1f2acf..21e9b7f8dad0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
@@ -246,7 +246,8 @@ int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man,
246 struct drm_hash_item *hash; 246 struct drm_hash_item *hash;
247 int ret; 247 int ret;
248 248
249 ret = drm_ht_find_item(&man->resources, user_key, &hash); 249 ret = drm_ht_find_item(&man->resources, user_key | (res_type << 24),
250 &hash);
250 if (likely(ret != 0)) 251 if (likely(ret != 0))
251 return -EINVAL; 252 return -EINVAL;
252 253
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 7197af157313..25f3c250fd98 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -688,7 +688,11 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
688 goto out_err0; 688 goto out_err0;
689 } 689 }
690 690
691 if (unlikely(dev_priv->prim_bb_mem < dev_priv->vram_size)) 691 /*
692 * Limit back buffer size to VRAM size. Remove this once
693 * screen targets are implemented.
694 */
695 if (dev_priv->prim_bb_mem > dev_priv->vram_size)
692 dev_priv->prim_bb_mem = dev_priv->vram_size; 696 dev_priv->prim_bb_mem = dev_priv->vram_size;
693 697
694 mutex_unlock(&dev_priv->hw_mutex); 698 mutex_unlock(&dev_priv->hw_mutex);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d2bc2b03d4c6..941a7bc0b791 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -187,7 +187,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
187 * can do this since the caller in the drm core doesn't check anything 187 * can do this since the caller in the drm core doesn't check anything
188 * which is protected by any looks. 188 * which is protected by any looks.
189 */ 189 */
190 drm_modeset_unlock(&crtc->mutex); 190 drm_modeset_unlock_crtc(crtc);
191 drm_modeset_lock_all(dev_priv->dev); 191 drm_modeset_lock_all(dev_priv->dev);
192 192
193 /* A lot of the code assumes this */ 193 /* A lot of the code assumes this */
@@ -252,7 +252,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
252 ret = 0; 252 ret = 0;
253out: 253out:
254 drm_modeset_unlock_all(dev_priv->dev); 254 drm_modeset_unlock_all(dev_priv->dev);
255 drm_modeset_lock(&crtc->mutex, NULL); 255 drm_modeset_lock_crtc(crtc);
256 256
257 return ret; 257 return ret;
258} 258}
@@ -273,7 +273,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
273 * can do this since the caller in the drm core doesn't check anything 273 * can do this since the caller in the drm core doesn't check anything
274 * which is protected by any looks. 274 * which is protected by any looks.
275 */ 275 */
276 drm_modeset_unlock(&crtc->mutex); 276 drm_modeset_unlock_crtc(crtc);
277 drm_modeset_lock_all(dev_priv->dev); 277 drm_modeset_lock_all(dev_priv->dev);
278 278
279 vmw_cursor_update_position(dev_priv, shown, 279 vmw_cursor_update_position(dev_priv, shown,
@@ -281,7 +281,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
281 du->cursor_y + du->hotspot_y); 281 du->cursor_y + du->hotspot_y);
282 282
283 drm_modeset_unlock_all(dev_priv->dev); 283 drm_modeset_unlock_all(dev_priv->dev);
284 drm_modeset_lock(&crtc->mutex, NULL); 284 drm_modeset_lock_crtc(crtc);
285 285
286 return 0; 286 return 0;
287} 287}
@@ -1950,6 +1950,14 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) 1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
1951 }; 1951 };
1952 int i; 1952 int i;
1953 u32 assumed_bpp = 2;
1954
1955 /*
1956 * If using screen objects, then assume 32-bpp because that's what the
1957 * SVGA device is assuming
1958 */
1959 if (dev_priv->sou_priv)
1960 assumed_bpp = 4;
1953 1961
1954 /* Add preferred mode */ 1962 /* Add preferred mode */
1955 { 1963 {
@@ -1960,8 +1968,9 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1960 mode->vdisplay = du->pref_height; 1968 mode->vdisplay = du->pref_height;
1961 vmw_guess_mode_timing(mode); 1969 vmw_guess_mode_timing(mode);
1962 1970
1963 if (vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * 2, 1971 if (vmw_kms_validate_mode_vram(dev_priv,
1964 mode->vdisplay)) { 1972 mode->hdisplay * assumed_bpp,
1973 mode->vdisplay)) {
1965 drm_mode_probed_add(connector, mode); 1974 drm_mode_probed_add(connector, mode);
1966 } else { 1975 } else {
1967 drm_mode_destroy(dev, mode); 1976 drm_mode_destroy(dev, mode);
@@ -1983,7 +1992,8 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1983 bmode->vdisplay > max_height) 1992 bmode->vdisplay > max_height)
1984 continue; 1993 continue;
1985 1994
1986 if (!vmw_kms_validate_mode_vram(dev_priv, bmode->hdisplay * 2, 1995 if (!vmw_kms_validate_mode_vram(dev_priv,
1996 bmode->hdisplay * assumed_bpp,
1987 bmode->vdisplay)) 1997 bmode->vdisplay))
1988 continue; 1998 continue;
1989 1999
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 84c3cb15ccdd..8bf61d295ffd 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -946,6 +946,12 @@ static const char *keys[KEY_MAX + 1] = {
946 [KEY_BRIGHTNESS_MIN] = "BrightnessMin", 946 [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
947 [KEY_BRIGHTNESS_MAX] = "BrightnessMax", 947 [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
948 [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto", 948 [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
949 [KEY_KBDINPUTASSIST_PREV] = "KbdInputAssistPrev",
950 [KEY_KBDINPUTASSIST_NEXT] = "KbdInputAssistNext",
951 [KEY_KBDINPUTASSIST_PREVGROUP] = "KbdInputAssistPrevGroup",
952 [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup",
953 [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept",
954 [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel",
949}; 955};
950 956
951static const char *relatives[REL_MAX + 1] = { 957static const char *relatives[REL_MAX + 1] = {
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index cd9c9e96cf0e..e23ab8b30626 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -298,6 +298,8 @@
298 298
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
302#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f
301 303
302#define USB_VENDOR_ID_ELECOM 0x056e 304#define USB_VENDOR_ID_ELECOM 0x056e
303#define USB_DEVICE_ID_ELECOM_BM084 0x0061 305#define USB_DEVICE_ID_ELECOM_BM084 0x0061
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 2df7fddbd119..725f22ca47fc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -695,7 +695,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
695 break; 695 break;
696 696
697 case 0x5b: /* TransducerSerialNumber */ 697 case 0x5b: /* TransducerSerialNumber */
698 set_bit(MSC_SERIAL, input->mscbit); 698 usage->type = EV_MSC;
699 usage->code = MSC_SERIAL;
700 bit = input->mscbit;
701 max = MSC_MAX;
699 break; 702 break;
700 703
701 default: goto unknown; 704 default: goto unknown;
@@ -862,6 +865,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
862 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; 865 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break;
863 case 0x28c: map_key_clear(KEY_SEND); break; 866 case 0x28c: map_key_clear(KEY_SEND); break;
864 867
868 case 0x2c7: map_key_clear(KEY_KBDINPUTASSIST_PREV); break;
869 case 0x2c8: map_key_clear(KEY_KBDINPUTASSIST_NEXT); break;
870 case 0x2c9: map_key_clear(KEY_KBDINPUTASSIST_PREVGROUP); break;
871 case 0x2ca: map_key_clear(KEY_KBDINPUTASSIST_NEXTGROUP); break;
872 case 0x2cb: map_key_clear(KEY_KBDINPUTASSIST_ACCEPT); break;
873 case 0x2cc: map_key_clear(KEY_KBDINPUTASSIST_CANCEL); break;
874
865 default: goto ignore; 875 default: goto ignore;
866 } 876 }
867 break; 877 break;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index f3cb5b0a4345..5014bb567b29 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -71,6 +71,8 @@ static const struct hid_blacklist {
71 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, 71 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
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 },
75 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL },
74 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 76 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
75 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 77 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
76 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 78 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 65ef9664d5da..899bede81b31 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -12,11 +12,6 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301 USA.
20 * ------------------------------------------------------------------------- */ 15 * ------------------------------------------------------------------------- */
21 16
22/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki 17/* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index 8b10f88b13d9..580dbf05c148 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -12,11 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301 USA.
20 */ 15 */
21 16
22#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 34370090b753..270d84bfc2c6 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -14,11 +14,6 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA.
21 *
22 * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and 17 * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
23 * Frodo Looijaard <frodol@dds.nl>, and also from Martin Bailey 18 * Frodo Looijaard <frodol@dds.nl>, and also from Martin Bailey
24 * <mbailey@littlefeet-inc.com> 19 * <mbailey@littlefeet-inc.com>
diff --git a/drivers/i2c/algos/i2c-algo-pcf.h b/drivers/i2c/algos/i2c-algo-pcf.h
index 1ec703ee788d..262ee801975b 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.h
+++ b/drivers/i2c/algos/i2c-algo-pcf.h
@@ -12,12 +12,7 @@
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details. */
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 MA 02110-1301 USA. */
21/* -------------------------------------------------------------------- */ 16/* -------------------------------------------------------------------- */
22 17
23/* With some changes from Frodo Looijaard <frodol@dds.nl> */ 18/* With some changes from Frodo Looijaard <frodol@dds.nl> */
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 451e305f7971..4f2d78868281 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/ 17*/
22 18
23/* 19/*
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 2fa21ce9682b..45c5c4883022 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -12,10 +12,6 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 15*/
20 16
21/* 17/*
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 41fc6837fb8b..65e324054970 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21/* 17/*
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index a16f72891358..6c7113d990f8 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -15,10 +15,6 @@
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 18*/
23 19
24/* 20/*
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 917d54588d95..e05a672db3e5 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -434,7 +434,7 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
434 } 434 }
435 } 435 }
436 436
437 ret = wait_for_completion_io_timeout(&dev->cmd_complete, 437 ret = wait_for_completion_timeout(&dev->cmd_complete,
438 dev->adapter.timeout); 438 dev->adapter.timeout);
439 if (ret == 0) { 439 if (ret == 0) {
440 dev_err(dev->dev, "controller timed out\n"); 440 dev_err(dev->dev, "controller timed out\n");
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 8762458ca7da..6f8c0756e350 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -21,10 +21,6 @@
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */ 24 */
29 25
30#include <linux/delay.h> 26#include <linux/delay.h>
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index f3b89a4698b6..5bdbc71698d0 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -23,10 +23,6 @@
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details. 25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 26 */
31 27
32#include <linux/kernel.h> 28#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 4d9614719128..d15b7c9b9219 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -17,10 +17,6 @@
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * ---------------------------------------------------------------------------- 20 * ----------------------------------------------------------------------------
25 * 21 *
26 */ 22 */
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 3c20e4bd6dd1..edca99dbba23 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ---------------------------------------------------------------------------- 21 * ----------------------------------------------------------------------------
26 * 22 *
27 */ 23 */
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index d66b6cbc9edc..5a410ef17abd 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ---------------------------------------------------------------------------- 21 * ----------------------------------------------------------------------------
26 * 22 *
27 */ 23 */
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index d31d313ab4f7..acb40f95db78 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -19,10 +19,6 @@
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details. 21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * ---------------------------------------------------------------------------- 22 * ----------------------------------------------------------------------------
27 * 23 *
28 */ 24 */
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index a7431150acf7..373dd4d47765 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -18,10 +18,6 @@
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details. 20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ---------------------------------------------------------------------------- 21 * ----------------------------------------------------------------------------
26 * 22 *
27 */ 23 */
diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index a44ea13d1434..76e699f9ed97 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -9,10 +9,6 @@
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details. 11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16 */ 12 */
17 13
18#include <linux/module.h> 14#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 485497066ed7..92e8c0ce1625 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -12,11 +12,7 @@
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details. */
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20/* ------------------------------------------------------------------------- */ 16/* ------------------------------------------------------------------------- */
21 17
22/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even 18/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index 14d2b76de25f..b7864cf42a72 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -15,10 +15,6 @@
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 18*/
23 19
24#include <linux/kernel.h> 20#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 7cfc183b3d63..6ab4f1cb21f3 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -15,10 +15,6 @@
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/ 18*/
23 19
24/* 20/*
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index c48e46af670a..e9fb7cf78612 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -11,11 +11,6 @@
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 *
19 * Author: 14 * Author:
20 * Darius Augulis, Teltonika Inc. 15 * Darius Augulis, Teltonika Inc.
21 * 16 *
diff --git a/drivers/i2c/busses/i2c-iop3xx.h b/drivers/i2c/busses/i2c-iop3xx.h
index 097e270955d0..2d6929c2bd92 100644
--- a/drivers/i2c/busses/i2c-iop3xx.h
+++ b/drivers/i2c/busses/i2c-iop3xx.h
@@ -11,11 +11,7 @@
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details. */
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19/* ------------------------------------------------------------------------- */ 15/* ------------------------------------------------------------------------- */
20 16
21 17
diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
index cf99dbf21fd1..113293d275f6 100644
--- a/drivers/i2c/busses/i2c-isch.c
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -14,10 +14,6 @@
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/ 17*/
22 18
23/* 19/*
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 3f6ecbfb9a56..f2b0ff011631 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -14,10 +14,6 @@
14 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution 17 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL. 18 * in the file called LICENSE.GPL.
23 * 19 *
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
index b170bdffb5de..88eda09e73c0 100644
--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21/* 17/*
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index ee3a76c7ae97..70b3c9158509 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -17,10 +17,6 @@
17 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details. 19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/ 20*/
25 21
26/* 22/*
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0dffb0e62c3b..26942c159de1 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -22,10 +22,6 @@
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details. 24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 25 */
30 26
31#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index 62f55fe624cb..d1f625f923c7 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -18,10 +18,6 @@
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details. 20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ------------------------------------------------------------------------ */ 21 * ------------------------------------------------------------------------ */
26 22
27#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index a27aae2d6757..a1fac5aa9bae 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -18,10 +18,6 @@
18 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details. 20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * ------------------------------------------------------------------------ */ 21 * ------------------------------------------------------------------------ */
26 22
27#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h
index e572f3aac0f7..4e1294536805 100644
--- a/drivers/i2c/busses/i2c-parport.h
+++ b/drivers/i2c/busses/i2c-parport.h
@@ -12,10 +12,6 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * ------------------------------------------------------------------------ */ 15 * ------------------------------------------------------------------------ */
20 16
21#define PORT_DATA 0 17#define PORT_DATA 0
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index 7a9dce43e115..df1dbc92a024 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -11,10 +11,6 @@
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 14 */
19 15
20#include <linux/module.h> 16#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c
index 323f061a3163..e0eb4ca0102e 100644
--- a/drivers/i2c/busses/i2c-pca-isa.c
+++ b/drivers/i2c/busses/i2c-pca-isa.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 15 */
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index a6f54ba27e2a..67cbec6796a0 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -11,10 +11,6 @@
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/ 14*/
19 15
20/* 16/*
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index 8564768fee32..177834e2d841 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -18,10 +18,6 @@
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 21 */
26 22
27#include <linux/kernel.h> 23#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 01e967763c2a..60a53c169ed2 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -14,10 +14,6 @@
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/ 17*/
22 18
23#include <linux/module.h> 19#include <linux/module.h>
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index e3b0337faeb7..65244774bfa3 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21*/ 17*/
22 18
23#include <linux/kernel.h> 19#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 8b5e79cb4468..4855188747c9 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -14,10 +14,6 @@
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 17 */
22 18
23#include <linux/kernel.h> 19#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 0fe505d7abe9..2b6219d86b0f 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */ 15 */
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c
index 964e5c6f84ab..15ac8395dcd3 100644
--- a/drivers/i2c/busses/i2c-simtec.c
+++ b/drivers/i2c/busses/i2c-simtec.c
@@ -12,10 +12,6 @@
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/ 15*/
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index ac9bc33acef4..7d58a40faf2d 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -11,10 +11,6 @@
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/ 14*/
19 15
20/* Note: we assume there can only be one SIS5595 with one SMBus interface */ 16/* Note: we assume there can only be one SIS5595 with one SMBus interface */
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index c6366733008d..1e6805b5cef2 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -10,10 +10,6 @@
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/ 13*/
18 14
19/* 15/*
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 8dc2fc5f74ff..44b904426073 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -10,10 +10,6 @@
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/ 13*/
18 14
19/* 15/*
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index 10855a0b7e7f..4c7fc2d47014 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -13,10 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 16 */
21 17
22#include <linux/delay.h> 18#include <linux/delay.h>
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index f4a1ed757612..59b1d233ca7b 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -12,10 +12,6 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/ 15*/
20 16
21#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 6841200b6e50..0ee2646f3b00 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -13,10 +13,6 @@
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 16*/
21 17
22/* 18/*
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index ade9223912d3..cc65ea0b818f 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -12,10 +12,6 @@
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * 15 *
20 * This code was implemented by Mocean Laboratories AB when porting linux 16 * This code was implemented by Mocean Laboratories AB when porting linux
21 * to the automotive development board Russellville. The copyright holder 17 * to the automotive development board Russellville. The copyright holder
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index ff3f5747e43b..5153354b1a6b 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -17,10 +17,6 @@
17 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details. 19 General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/ 20*/
25 21
26#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c
index f24cc64e2e8c..90e322959303 100644
--- a/drivers/i2c/i2c-boardinfo.c
+++ b/drivers/i2c/i2c-boardinfo.c
@@ -10,11 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA.
18 */ 13 */
19 14
20#include <linux/kernel.h> 15#include <linux/kernel.h>
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 2f90ac6a7f79..f43b4e11647a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -10,12 +10,7 @@
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details. */
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 MA 02110-1301 USA. */
19/* ------------------------------------------------------------------------- */ 14/* ------------------------------------------------------------------------- */
20 15
21/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>. 16/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>.
@@ -670,6 +665,9 @@ static int i2c_device_remove(struct device *dev)
670 status = driver->remove(client); 665 status = driver->remove(client);
671 } 666 }
672 667
668 if (dev->of_node)
669 irq_dispose_mapping(client->irq);
670
673 dev_pm_domain_detach(&client->dev, true); 671 dev_pm_domain_detach(&client->dev, true);
674 return status; 672 return status;
675} 673}
diff --git a/drivers/i2c/i2c-core.h b/drivers/i2c/i2c-core.h
index 18a8fd21d2c2..17700bfddcf5 100644
--- a/drivers/i2c/i2c-core.h
+++ b/drivers/i2c/i2c-core.h
@@ -10,11 +10,6 @@
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA.
18 */ 13 */
19 14
20#include <linux/rwsem.h> 15#include <linux/rwsem.h>
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 80b47e8ce030..71c7a3975b62 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -14,11 +14,6 @@
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 MA 02110-1301 USA.
22*/ 17*/
23 18
24/* Note that this is a complete rewrite of Simon Vogl's i2c-dev module. 19/* Note that this is a complete rewrite of Simon Vogl's i2c-dev module.
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index fc99f0d6b4a5..9ebf9cb4ad7a 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -13,11 +13,6 @@
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA.
21 */ 16 */
22 17
23#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
index d241aa295d96..af2a94e1140b 100644
--- a/drivers/i2c/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -13,10 +13,6 @@
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 16*/
21 17
22#define DEBUG 1 18#define DEBUG 1
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 98909a9e284e..a23e58c4ed99 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -894,7 +894,7 @@ static const struct attribute_group kxcjk1013_attrs_group = {
894 894
895static const struct iio_event_spec kxcjk1013_event = { 895static const struct iio_event_spec kxcjk1013_event = {
896 .type = IIO_EV_TYPE_THRESH, 896 .type = IIO_EV_TYPE_THRESH,
897 .dir = IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING, 897 .dir = IIO_EV_DIR_EITHER,
898 .mask_separate = BIT(IIO_EV_INFO_VALUE) | 898 .mask_separate = BIT(IIO_EV_INFO_VALUE) |
899 BIT(IIO_EV_INFO_ENABLE) | 899 BIT(IIO_EV_INFO_ENABLE) |
900 BIT(IIO_EV_INFO_PERIOD) 900 BIT(IIO_EV_INFO_PERIOD)
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index 1665c8e4b62b..e18bc6782256 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -71,7 +71,7 @@ int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
71 goto st_sensors_free_memory; 71 goto st_sensors_free_memory;
72 } 72 }
73 73
74 for (i = 0; i < n * num_data_channels; i++) { 74 for (i = 0; i < n * byte_for_channel; i++) {
75 if (i < n) 75 if (i < n)
76 buf[i] = rx_array[i]; 76 buf[i] = rx_array[i];
77 else 77 else
diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
index a15006efa137..0763b8632573 100644
--- a/drivers/iio/light/tsl4531.c
+++ b/drivers/iio/light/tsl4531.c
@@ -230,9 +230,12 @@ static int tsl4531_resume(struct device *dev)
230 return i2c_smbus_write_byte_data(to_i2c_client(dev), TSL4531_CONTROL, 230 return i2c_smbus_write_byte_data(to_i2c_client(dev), TSL4531_CONTROL,
231 TSL4531_MODE_NORMAL); 231 TSL4531_MODE_NORMAL);
232} 232}
233#endif
234 233
235static SIMPLE_DEV_PM_OPS(tsl4531_pm_ops, tsl4531_suspend, tsl4531_resume); 234static SIMPLE_DEV_PM_OPS(tsl4531_pm_ops, tsl4531_suspend, tsl4531_resume);
235#define TSL4531_PM_OPS (&tsl4531_pm_ops)
236#else
237#define TSL4531_PM_OPS NULL
238#endif
236 239
237static const struct i2c_device_id tsl4531_id[] = { 240static const struct i2c_device_id tsl4531_id[] = {
238 { "tsl4531", 0 }, 241 { "tsl4531", 0 },
@@ -243,7 +246,7 @@ MODULE_DEVICE_TABLE(i2c, tsl4531_id);
243static struct i2c_driver tsl4531_driver = { 246static struct i2c_driver tsl4531_driver = {
244 .driver = { 247 .driver = {
245 .name = TSL4531_DRV_NAME, 248 .name = TSL4531_DRV_NAME,
246 .pm = &tsl4531_pm_ops, 249 .pm = TSL4531_PM_OPS,
247 .owner = THIS_MODULE, 250 .owner = THIS_MODULE,
248 }, 251 },
249 .probe = tsl4531_probe, 252 .probe = tsl4531_probe,
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index 5e780ef206f3..8349cc0fdf66 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -330,7 +330,7 @@ static int as3935_probe(struct spi_device *spi)
330 return -EINVAL; 330 return -EINVAL;
331 } 331 }
332 332
333 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(st)); 333 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
334 if (!indio_dev) 334 if (!indio_dev)
335 return -ENOMEM; 335 return -ENOMEM;
336 336
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index bda5994ceb68..8b72cf392b34 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1173,18 +1173,24 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
1173 err = __mlx4_ib_create_flow(qp, flow_attr, domain, type[i], 1173 err = __mlx4_ib_create_flow(qp, flow_attr, domain, type[i],
1174 &mflow->reg_id[i]); 1174 &mflow->reg_id[i]);
1175 if (err) 1175 if (err)
1176 goto err_free; 1176 goto err_create_flow;
1177 i++; 1177 i++;
1178 } 1178 }
1179 1179
1180 if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) { 1180 if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) {
1181 err = mlx4_ib_tunnel_steer_add(qp, flow_attr, &mflow->reg_id[i]); 1181 err = mlx4_ib_tunnel_steer_add(qp, flow_attr, &mflow->reg_id[i]);
1182 if (err) 1182 if (err)
1183 goto err_free; 1183 goto err_create_flow;
1184 i++;
1184 } 1185 }
1185 1186
1186 return &mflow->ibflow; 1187 return &mflow->ibflow;
1187 1188
1189err_create_flow:
1190 while (i) {
1191 (void)__mlx4_ib_destroy_flow(to_mdev(qp->device)->dev, mflow->reg_id[i]);
1192 i--;
1193 }
1188err_free: 1194err_free:
1189 kfree(mflow); 1195 kfree(mflow);
1190 return ERR_PTR(err); 1196 return ERR_PTR(err);
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index 62abe2c16670..f8502bb29176 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -70,7 +70,7 @@ static int opencores_kbd_probe(struct platform_device *pdev)
70 70
71 opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res); 71 opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res);
72 if (IS_ERR(opencores_kbd->addr)) 72 if (IS_ERR(opencores_kbd->addr))
73 error = PTR_ERR(opencores_kbd->addr); 73 return PTR_ERR(opencores_kbd->addr);
74 74
75 input->name = pdev->name; 75 input->name = pdev->name;
76 input->phys = "opencores-kbd/input0"; 76 input->phys = "opencores-kbd/input0";
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index c6727dda68f2..ef5e67fb567e 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -86,7 +86,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = {
86 .max_cols = 8, 86 .max_cols = 8,
87 .max_rows = 12, 87 .max_rows = 12,
88 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/ 88 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/
89 .row_gpios = 0x1fef00, /* GPIO 8-14, 16-20 */ 89 .row_gpios = 0x1f7f00, /* GPIO 8-14, 16-20 */
90 }, 90 },
91 [STMPE2403] = { 91 [STMPE2403] = {
92 .auto_increment = true, 92 .auto_increment = true,
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 719410feb84b..afed8e2b2f94 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1381,7 +1381,7 @@ static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev,
1381 pcu->ofn_reg_addr = value; 1381 pcu->ofn_reg_addr = value;
1382 mutex_unlock(&pcu->cmd_mutex); 1382 mutex_unlock(&pcu->cmd_mutex);
1383 1383
1384 return error ?: count; 1384 return count;
1385} 1385}
1386 1386
1387static DEVICE_ATTR(reg_addr, S_IRUGO | S_IWUSR, 1387static DEVICE_ATTR(reg_addr, S_IRUGO | S_IWUSR,
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 7b1fde93799e..ef6a9d650d69 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -194,7 +194,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
194 struct ff_effect *effect) 194 struct ff_effect *effect)
195{ 195{
196 struct max77693_haptic *haptic = input_get_drvdata(dev); 196 struct max77693_haptic *haptic = input_get_drvdata(dev);
197 uint64_t period_mag_multi; 197 u64 period_mag_multi;
198 198
199 haptic->magnitude = effect->u.rumble.strong_magnitude; 199 haptic->magnitude = effect->u.rumble.strong_magnitude;
200 if (!haptic->magnitude) 200 if (!haptic->magnitude)
@@ -205,8 +205,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
205 * The formula to convert magnitude to pwm_duty as follows: 205 * The formula to convert magnitude to pwm_duty as follows:
206 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) 206 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF)
207 */ 207 */
208 period_mag_multi = (int64_t)(haptic->pwm_dev->period * 208 period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
209 haptic->magnitude);
210 haptic->pwm_duty = (unsigned int)(period_mag_multi >> 209 haptic->pwm_duty = (unsigned int)(period_mag_multi >>
211 MAX_MAGNITUDE_SHIFT); 210 MAX_MAGNITUDE_SHIFT);
212 211
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 735604753568..e097f1ab427f 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -55,7 +55,7 @@ static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
55 struct gpio_desc *desc; 55 struct gpio_desc *desc;
56 int gpio; 56 int gpio;
57 57
58 desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index); 58 desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index, GPIOD_ASIS);
59 if (IS_ERR(desc)) 59 if (IS_ERR(desc))
60 return PTR_ERR(desc); 60 return PTR_ERR(desc);
61 61
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 26994f6a2b2a..95a3a6e2faf6 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1536,16 +1536,9 @@ static int psmouse_reconnect(struct serio *serio)
1536{ 1536{
1537 struct psmouse *psmouse = serio_get_drvdata(serio); 1537 struct psmouse *psmouse = serio_get_drvdata(serio);
1538 struct psmouse *parent = NULL; 1538 struct psmouse *parent = NULL;
1539 struct serio_driver *drv = serio->drv;
1540 unsigned char type; 1539 unsigned char type;
1541 int rc = -1; 1540 int rc = -1;
1542 1541
1543 if (!drv || !psmouse) {
1544 psmouse_dbg(psmouse,
1545 "reconnect request, but serio is disconnected, ignoring...\n");
1546 return -1;
1547 }
1548
1549 mutex_lock(&psmouse_mutex); 1542 mutex_lock(&psmouse_mutex);
1550 1543
1551 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1544 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index 38298232124f..abd494411e69 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -128,7 +128,7 @@ static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
128 if (num >= mouse->count) { 128 if (num >= mouse->count) {
129 mouse->count = 0; 129 mouse->count = 0;
130 } else { 130 } else {
131 memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num); 131 memmove(mouse->buf, mouse->buf + num, BUFLEN - num);
132 mouse->count -= num; 132 mouse->count -= num;
133 } 133 }
134} 134}
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c
index cce69d6b9587..58781c8a8aec 100644
--- a/drivers/input/serio/altera_ps2.c
+++ b/drivers/input/serio/altera_ps2.c
@@ -37,7 +37,7 @@ static irqreturn_t altera_ps2_rxint(int irq, void *dev_id)
37{ 37{
38 struct ps2if *ps2if = dev_id; 38 struct ps2if *ps2if = dev_id;
39 unsigned int status; 39 unsigned int status;
40 int handled = IRQ_NONE; 40 irqreturn_t handled = IRQ_NONE;
41 41
42 while ((status = readl(ps2if->base)) & 0xffff0000) { 42 while ((status = readl(ps2if->base)) & 0xffff0000) {
43 serio_interrupt(ps2if->io, status & 0xff, 0); 43 serio_interrupt(ps2if->io, status & 0xff, 0);
@@ -74,7 +74,7 @@ static void altera_ps2_close(struct serio *io)
74{ 74{
75 struct ps2if *ps2if = io->port_data; 75 struct ps2if *ps2if = io->port_data;
76 76
77 writel(0, ps2if->base); /* disable rx irq */ 77 writel(0, ps2if->base + 4); /* disable rx irq */
78} 78}
79 79
80/* 80/*
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index a0bcbb64d06d..faeeb1372462 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -207,17 +207,282 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
207}; 207};
208 208
209/* 209/*
210 * Some laptops do implement active multiplexing mode correctly; 210 * Some Fujitsu notebooks are having trouble with touchpads if
211 * unfortunately they are in minority. 211 * active multiplexing mode is activated. Luckily they don't have
212 * external PS/2 ports so we can safely disable it.
213 * ... apparently some Toshibas don't like MUX mode either and
214 * die horrible death on reboot.
212 */ 215 */
213static const struct dmi_system_id __initconst i8042_dmi_mux_table[] = { 216static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
217 {
218 /* Fujitsu Lifebook P7010/P7010D */
219 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
221 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
222 },
223 },
224 {
225 /* Fujitsu Lifebook P7010 */
226 .matches = {
227 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
228 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
229 },
230 },
231 {
232 /* Fujitsu Lifebook P5020D */
233 .matches = {
234 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
235 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
236 },
237 },
238 {
239 /* Fujitsu Lifebook S2000 */
240 .matches = {
241 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
242 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
243 },
244 },
245 {
246 /* Fujitsu Lifebook S6230 */
247 .matches = {
248 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
249 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
250 },
251 },
252 {
253 /* Fujitsu T70H */
254 .matches = {
255 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
256 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
257 },
258 },
259 {
260 /* Fujitsu-Siemens Lifebook T3010 */
261 .matches = {
262 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
263 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
264 },
265 },
266 {
267 /* Fujitsu-Siemens Lifebook E4010 */
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
271 },
272 },
273 {
274 /* Fujitsu-Siemens Amilo Pro 2010 */
275 .matches = {
276 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
277 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
278 },
279 },
280 {
281 /* Fujitsu-Siemens Amilo Pro 2030 */
282 .matches = {
283 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
284 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
285 },
286 },
287 {
288 /*
289 * No data is coming from the touchscreen unless KBC
290 * is in legacy mode.
291 */
292 /* Panasonic CF-29 */
293 .matches = {
294 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
295 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
296 },
297 },
298 {
299 /*
300 * HP Pavilion DV4017EA -
301 * errors on MUX ports are reported without raising AUXDATA
302 * causing "spurious NAK" messages.
303 */
304 .matches = {
305 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
306 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
307 },
308 },
309 {
310 /*
311 * HP Pavilion ZT1000 -
312 * like DV4017EA does not raise AUXERR for errors on MUX ports.
313 */
314 .matches = {
315 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
316 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
317 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
318 },
319 },
320 {
321 /*
322 * HP Pavilion DV4270ca -
323 * like DV4017EA does not raise AUXERR for errors on MUX ports.
324 */
325 .matches = {
326 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
327 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
328 },
329 },
330 {
331 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
333 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
334 },
335 },
336 {
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
340 },
341 },
342 {
343 .matches = {
344 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
345 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
346 },
347 },
348 {
349 .matches = {
350 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
351 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
352 },
353 },
354 {
355 /* Sharp Actius MM20 */
356 .matches = {
357 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
358 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
359 },
360 },
361 {
362 /* Sony Vaio FS-115b */
363 .matches = {
364 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
365 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
366 },
367 },
368 {
369 /*
370 * Sony Vaio FZ-240E -
371 * reset and GET ID commands issued via KBD port are
372 * sometimes being delivered to AUX3.
373 */
374 .matches = {
375 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
376 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ240E"),
377 },
378 },
214 { 379 {
215 /* 380 /*
216 * Panasonic CF-18 needs to be in MUX mode since the 381 * Most (all?) VAIOs do not have external PS/2 ports nor
217 * touchscreen is on serio3 and it also has touchpad. 382 * they implement active multiplexing properly, and
383 * MUX discovery usually messes up keyboard/touchpad.
218 */ 384 */
219 .matches = { 385 .matches = {
220 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), 386 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
387 DMI_MATCH(DMI_BOARD_NAME, "VAIO"),
388 },
389 },
390 {
391 /* Amoi M636/A737 */
392 .matches = {
393 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
394 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
395 },
396 },
397 {
398 /* Lenovo 3000 n100 */
399 .matches = {
400 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
401 DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
402 },
403 },
404 {
405 .matches = {
406 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
407 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
408 },
409 },
410 {
411 /* Acer Aspire 5710 */
412 .matches = {
413 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
414 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5710"),
415 },
416 },
417 {
418 /* Gericom Bellagio */
419 .matches = {
420 DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
421 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
422 },
423 },
424 {
425 /* IBM 2656 */
426 .matches = {
427 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
428 DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
429 },
430 },
431 {
432 /* Dell XPS M1530 */
433 .matches = {
434 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
435 DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
436 },
437 },
438 {
439 /* Compal HEL80I */
440 .matches = {
441 DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
442 DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
443 },
444 },
445 {
446 /* Dell Vostro 1510 */
447 .matches = {
448 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
449 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro1510"),
450 },
451 },
452 {
453 /* Acer Aspire 5536 */
454 .matches = {
455 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
456 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5536"),
457 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
458 },
459 },
460 {
461 /* Dell Vostro V13 */
462 .matches = {
463 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
464 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
465 },
466 },
467 {
468 /* Newer HP Pavilion dv4 models */
469 .matches = {
470 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
471 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
472 },
473 },
474 {
475 /* Asus X450LCP */
476 .matches = {
477 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
478 DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"),
479 },
480 },
481 {
482 /* Avatar AVIU-145A6 */
483 .matches = {
484 DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
485 DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
221 }, 486 },
222 }, 487 },
223 { } 488 { }
@@ -364,6 +629,22 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
364 }, 629 },
365 }, 630 },
366 { 631 {
632 /* Fujitsu A544 laptop */
633 /* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
634 .matches = {
635 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
636 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
637 },
638 },
639 {
640 /* Fujitsu AH544 laptop */
641 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
642 .matches = {
643 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
644 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
645 },
646 },
647 {
367 /* Fujitsu U574 laptop */ 648 /* Fujitsu U574 laptop */
368 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */ 649 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
369 .matches = { 650 .matches = {
@@ -740,8 +1021,8 @@ static int __init i8042_platform_init(void)
740 if (dmi_check_system(i8042_dmi_noloop_table)) 1021 if (dmi_check_system(i8042_dmi_noloop_table))
741 i8042_noloop = true; 1022 i8042_noloop = true;
742 1023
743 if (dmi_check_system(i8042_dmi_mux_table)) 1024 if (dmi_check_system(i8042_dmi_nomux_table))
744 i8042_nomux = false; 1025 i8042_nomux = true;
745 1026
746 if (dmi_check_system(i8042_dmi_notimeout_table)) 1027 if (dmi_check_system(i8042_dmi_notimeout_table))
747 i8042_notimeout = true; 1028 i8042_notimeout = true;
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 9a97c2b10926..f5a98af3b325 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -39,7 +39,7 @@ static bool i8042_noaux;
39module_param_named(noaux, i8042_noaux, bool, 0); 39module_param_named(noaux, i8042_noaux, bool, 0);
40MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); 40MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port.");
41 41
42static bool i8042_nomux = true; 42static bool i8042_nomux;
43module_param_named(nomux, i8042_nomux, bool, 0); 43module_param_named(nomux, i8042_nomux, bool, 0);
44MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present."); 44MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present.");
45 45
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index d0ef91fc87d1..b1ae77995968 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -70,11 +70,11 @@
70 * Documentation/input/input-programming.txt for more details. 70 * Documentation/input/input-programming.txt for more details.
71 */ 71 */
72 72
73static int abs_x[3] = {350, 3900, 5}; 73static int abs_x[3] = {150, 4000, 5};
74module_param_array(abs_x, int, NULL, 0); 74module_param_array(abs_x, int, NULL, 0);
75MODULE_PARM_DESC(abs_x, "Touchscreen absolute X min, max, fuzz"); 75MODULE_PARM_DESC(abs_x, "Touchscreen absolute X min, max, fuzz");
76 76
77static int abs_y[3] = {320, 3750, 40}; 77static int abs_y[3] = {200, 4000, 40};
78module_param_array(abs_y, int, NULL, 0); 78module_param_array(abs_y, int, NULL, 0);
79MODULE_PARM_DESC(abs_y, "Touchscreen absolute Y min, max, fuzz"); 79MODULE_PARM_DESC(abs_y, "Touchscreen absolute Y min, max, fuzz");
80 80
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 3e238cd049e6..6a2e168c3ab0 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -43,6 +43,7 @@
43#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34) 43#define ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS (0x34)
44#define ARMADA_370_XP_INT_SOURCE_CTL(irq) (0x100 + irq*4) 44#define ARMADA_370_XP_INT_SOURCE_CTL(irq) (0x100 + irq*4)
45#define ARMADA_370_XP_INT_SOURCE_CPU_MASK 0xF 45#define ARMADA_370_XP_INT_SOURCE_CPU_MASK 0xF
46#define ARMADA_370_XP_INT_IRQ_FIQ_MASK(cpuid) ((BIT(0) | BIT(8)) << cpuid)
46 47
47#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44) 48#define ARMADA_370_XP_CPU_INTACK_OFFS (0x44)
48#define ARMADA_375_PPI_CAUSE (0x10) 49#define ARMADA_375_PPI_CAUSE (0x10)
@@ -406,19 +407,29 @@ static void armada_370_xp_mpic_handle_cascade_irq(unsigned int irq,
406 struct irq_desc *desc) 407 struct irq_desc *desc)
407{ 408{
408 struct irq_chip *chip = irq_get_chip(irq); 409 struct irq_chip *chip = irq_get_chip(irq);
409 unsigned long irqmap, irqn; 410 unsigned long irqmap, irqn, irqsrc, cpuid;
410 unsigned int cascade_irq; 411 unsigned int cascade_irq;
411 412
412 chained_irq_enter(chip, desc); 413 chained_irq_enter(chip, desc);
413 414
414 irqmap = readl_relaxed(per_cpu_int_base + ARMADA_375_PPI_CAUSE); 415 irqmap = readl_relaxed(per_cpu_int_base + ARMADA_375_PPI_CAUSE);
415 416 cpuid = cpu_logical_map(smp_processor_id());
416 if (irqmap & BIT(0)) {
417 armada_370_xp_handle_msi_irq(NULL, true);
418 irqmap &= ~BIT(0);
419 }
420 417
421 for_each_set_bit(irqn, &irqmap, BITS_PER_LONG) { 418 for_each_set_bit(irqn, &irqmap, BITS_PER_LONG) {
419 irqsrc = readl_relaxed(main_int_base +
420 ARMADA_370_XP_INT_SOURCE_CTL(irqn));
421
422 /* Check if the interrupt is not masked on current CPU.
423 * Test IRQ (0-1) and FIQ (8-9) mask bits.
424 */
425 if (!(irqsrc & ARMADA_370_XP_INT_IRQ_FIQ_MASK(cpuid)))
426 continue;
427
428 if (irqn == 1) {
429 armada_370_xp_handle_msi_irq(NULL, true);
430 continue;
431 }
432
422 cascade_irq = irq_find_mapping(armada_370_xp_mpic_domain, irqn); 433 cascade_irq = irq_find_mapping(armada_370_xp_mpic_domain, irqn);
423 generic_handle_irq(cascade_irq); 434 generic_handle_irq(cascade_irq);
424 } 435 }
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index b8579ee68bd6..2cf30576bf39 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -962,6 +962,11 @@ static int dvb_frontend_clear_cache(struct dvb_frontend *fe)
962 case SYS_ATSC: 962 case SYS_ATSC:
963 c->modulation = VSB_8; 963 c->modulation = VSB_8;
964 break; 964 break;
965 case SYS_ISDBS:
966 c->symbol_rate = 28860000;
967 c->rolloff = ROLLOFF_35;
968 c->bandwidth_hz = c->symbol_rate / 100 * 135;
969 break;
965 default: 970 default:
966 c->modulation = QAM_AUTO; 971 c->modulation = QAM_AUTO;
967 break; 972 break;
@@ -2072,6 +2077,7 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
2072 break; 2077 break;
2073 case SYS_DVBS: 2078 case SYS_DVBS:
2074 case SYS_TURBO: 2079 case SYS_TURBO:
2080 case SYS_ISDBS:
2075 rolloff = 135; 2081 rolloff = 135;
2076 break; 2082 break;
2077 case SYS_DVBS2: 2083 case SYS_DVBS2:
diff --git a/drivers/media/dvb-frontends/ds3000.c b/drivers/media/dvb-frontends/ds3000.c
index 335daeff91b9..9d0d0347758f 100644
--- a/drivers/media/dvb-frontends/ds3000.c
+++ b/drivers/media/dvb-frontends/ds3000.c
@@ -864,6 +864,13 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
864 memcpy(&state->frontend.ops, &ds3000_ops, 864 memcpy(&state->frontend.ops, &ds3000_ops,
865 sizeof(struct dvb_frontend_ops)); 865 sizeof(struct dvb_frontend_ops));
866 state->frontend.demodulator_priv = state; 866 state->frontend.demodulator_priv = state;
867
868 /*
869 * Some devices like T480 starts with voltage on. Be sure
870 * to turn voltage off during init, as this can otherwise
871 * interfere with Unicable SCR systems.
872 */
873 ds3000_set_voltage(&state->frontend, SEC_VOLTAGE_OFF);
867 return &state->frontend; 874 return &state->frontend;
868 875
869error3: 876error3:
diff --git a/drivers/media/dvb-frontends/sp2.c b/drivers/media/dvb-frontends/sp2.c
index 320cbe951790..cc1ef966f99f 100644
--- a/drivers/media/dvb-frontends/sp2.c
+++ b/drivers/media/dvb-frontends/sp2.c
@@ -269,7 +269,7 @@ int sp2_ci_poll_slot_status(struct dvb_ca_en50221 *en50221,
269 return s->status; 269 return s->status;
270} 270}
271 271
272int sp2_init(struct sp2 *s) 272static int sp2_init(struct sp2 *s)
273{ 273{
274 int ret = 0; 274 int ret = 0;
275 u8 buf; 275 u8 buf;
@@ -351,7 +351,7 @@ err:
351 return ret; 351 return ret;
352} 352}
353 353
354int sp2_exit(struct i2c_client *client) 354static int sp2_exit(struct i2c_client *client)
355{ 355{
356 struct sp2 *s; 356 struct sp2 *s;
357 357
diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c
index d9905fb52f84..b35d65c9cc05 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -216,32 +216,30 @@ static int tc90522s_get_frontend(struct dvb_frontend *fe)
216 c->delivery_system = SYS_ISDBS; 216 c->delivery_system = SYS_ISDBS;
217 217
218 layers = 0; 218 layers = 0;
219 ret = reg_read(state, 0xe8, val, 3); 219 ret = reg_read(state, 0xe6, val, 5);
220 if (ret == 0) { 220 if (ret == 0) {
221 int slots;
222 u8 v; 221 u8 v;
223 222
223 c->stream_id = val[0] << 8 | val[1];
224
224 /* high/single layer */ 225 /* high/single layer */
225 v = (val[0] & 0x70) >> 4; 226 v = (val[2] & 0x70) >> 4;
226 c->modulation = (v == 7) ? PSK_8 : QPSK; 227 c->modulation = (v == 7) ? PSK_8 : QPSK;
227 c->fec_inner = fec_conv_sat[v]; 228 c->fec_inner = fec_conv_sat[v];
228 c->layer[0].fec = c->fec_inner; 229 c->layer[0].fec = c->fec_inner;
229 c->layer[0].modulation = c->modulation; 230 c->layer[0].modulation = c->modulation;
230 c->layer[0].segment_count = val[1] & 0x3f; /* slots */ 231 c->layer[0].segment_count = val[3] & 0x3f; /* slots */
231 232
232 /* low layer */ 233 /* low layer */
233 v = (val[0] & 0x07); 234 v = (val[2] & 0x07);
234 c->layer[1].fec = fec_conv_sat[v]; 235 c->layer[1].fec = fec_conv_sat[v];
235 if (v == 0) /* no low layer */ 236 if (v == 0) /* no low layer */
236 c->layer[1].segment_count = 0; 237 c->layer[1].segment_count = 0;
237 else 238 else
238 c->layer[1].segment_count = val[2] & 0x3f; /* slots */ 239 c->layer[1].segment_count = val[4] & 0x3f; /* slots */
239 /* actually, BPSK if v==1, but not defined in fe_modulation_t */ 240 /* actually, BPSK if v==1, but not defined in fe_modulation_t */
240 c->layer[1].modulation = QPSK; 241 c->layer[1].modulation = QPSK;
241 layers = (v > 0) ? 2 : 1; 242 layers = (v > 0) ? 2 : 1;
242
243 slots = c->layer[0].segment_count + c->layer[1].segment_count;
244 c->symbol_rate = 28860000 * slots / 48;
245 } 243 }
246 244
247 /* statistics */ 245 /* statistics */
@@ -363,7 +361,7 @@ static int tc90522t_get_frontend(struct dvb_frontend *fe)
363 u8 v; 361 u8 v;
364 362
365 c->isdbt_partial_reception = val[0] & 0x01; 363 c->isdbt_partial_reception = val[0] & 0x01;
366 c->isdbt_sb_mode = (val[0] & 0xc0) == 0x01; 364 c->isdbt_sb_mode = (val[0] & 0xc0) == 0x40;
367 365
368 /* layer A */ 366 /* layer A */
369 v = (val[2] & 0x78) >> 3; 367 v = (val[2] & 0x78) >> 3;
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
index 2c61a62ab48b..686c3c2ad05b 100644
--- a/drivers/media/platform/vivid/vivid-core.c
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -100,11 +100,9 @@ MODULE_PARM_DESC(ccs_out_mode, " output crop/compose/scale mode:\n"
100 "\t\t bit 0=crop, 1=compose, 2=scale,\n" 100 "\t\t bit 0=crop, 1=compose, 2=scale,\n"
101 "\t\t -1=user-controlled (default)"); 101 "\t\t -1=user-controlled (default)");
102 102
103static unsigned multiplanar[VIVID_MAX_DEVS]; 103static unsigned multiplanar[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 1 };
104module_param_array(multiplanar, uint, NULL, 0444); 104module_param_array(multiplanar, uint, NULL, 0444);
105MODULE_PARM_DESC(multiplanar, " 0 (default) is alternating single and multiplanar devices,\n" 105MODULE_PARM_DESC(multiplanar, " 1 (default) creates a single planar device, 2 creates a multiplanar device.");
106 "\t\t 1 is single planar devices,\n"
107 "\t\t 2 is multiplanar devices");
108 106
109/* Default: video + vbi-cap (raw and sliced) + radio rx + radio tx + sdr + vbi-out + vid-out */ 107/* Default: video + vbi-cap (raw and sliced) + radio rx + radio tx + sdr + vbi-out + vid-out */
110static unsigned node_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x1d3d }; 108static unsigned node_types[VIVID_MAX_DEVS] = { [0 ... (VIVID_MAX_DEVS - 1)] = 0x1d3d };
@@ -669,10 +667,7 @@ static int __init vivid_create_instance(int inst)
669 /* start detecting feature set */ 667 /* start detecting feature set */
670 668
671 /* do we use single- or multi-planar? */ 669 /* do we use single- or multi-planar? */
672 if (multiplanar[inst] == 0) 670 dev->multiplanar = multiplanar[inst] > 1;
673 dev->multiplanar = inst & 1;
674 else
675 dev->multiplanar = multiplanar[inst] > 1;
676 v4l2_info(&dev->v4l2_dev, "using %splanar format API\n", 671 v4l2_info(&dev->v4l2_dev, "using %splanar format API\n",
677 dev->multiplanar ? "multi" : "single "); 672 dev->multiplanar ? "multi" : "single ");
678 673
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index b8837dd39bb2..65f80b8b9f7a 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1678,7 +1678,8 @@ static void imon_incoming_packet(struct imon_context *ictx,
1678 if (press_type == 0) 1678 if (press_type == 0)
1679 rc_keyup(ictx->rdev); 1679 rc_keyup(ictx->rdev);
1680 else { 1680 else {
1681 if (ictx->rc_type == RC_BIT_RC6_MCE) 1681 if (ictx->rc_type == RC_BIT_RC6_MCE ||
1682 ictx->rc_type == RC_BIT_OTHER)
1682 rc_keydown(ictx->rdev, 1683 rc_keydown(ictx->rdev,
1683 ictx->rc_type == RC_BIT_RC6_MCE ? RC_TYPE_RC6_MCE : RC_TYPE_OTHER, 1684 ictx->rc_type == RC_BIT_RC6_MCE ? RC_TYPE_RC6_MCE : RC_TYPE_OTHER,
1684 ictx->rc_scancode, ictx->rc_toggle); 1685 ictx->rc_scancode, ictx->rc_toggle);
diff --git a/drivers/media/rc/ir-hix5hd2.c b/drivers/media/rc/ir-hix5hd2.c
index 08bbd4f508cd..b0df62961c14 100644
--- a/drivers/media/rc/ir-hix5hd2.c
+++ b/drivers/media/rc/ir-hix5hd2.c
@@ -297,7 +297,7 @@ static int hix5hd2_ir_remove(struct platform_device *pdev)
297 return 0; 297 return 0;
298} 298}
299 299
300#ifdef CONFIG_PM 300#ifdef CONFIG_PM_SLEEP
301static int hix5hd2_ir_suspend(struct device *dev) 301static int hix5hd2_ir_suspend(struct device *dev)
302{ 302{
303 struct hix5hd2_ir_priv *priv = dev_get_drvdata(dev); 303 struct hix5hd2_ir_priv *priv = dev_get_drvdata(dev);
diff --git a/drivers/media/rc/ir-rc5-decoder.c b/drivers/media/rc/ir-rc5-decoder.c
index 2ef763928ca4..84fa6e9b59a1 100644
--- a/drivers/media/rc/ir-rc5-decoder.c
+++ b/drivers/media/rc/ir-rc5-decoder.c
@@ -53,7 +53,7 @@ static int ir_rc5_decode(struct rc_dev *dev, struct ir_raw_event ev)
53 u32 scancode; 53 u32 scancode;
54 enum rc_type protocol; 54 enum rc_type protocol;
55 55
56 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X))) 56 if (!(dev->enabled_protocols & (RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ)))
57 return 0; 57 return 0;
58 58
59 if (!is_timing_event(ev)) { 59 if (!is_timing_event(ev)) {
diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c
index e8fff2add265..b732ac6a26d8 100644
--- a/drivers/media/rc/rc-ir-raw.c
+++ b/drivers/media/rc/rc-ir-raw.c
@@ -262,7 +262,6 @@ int ir_raw_event_register(struct rc_dev *dev)
262 return -ENOMEM; 262 return -ENOMEM;
263 263
264 dev->raw->dev = dev; 264 dev->raw->dev = dev;
265 dev->enabled_protocols = ~0;
266 dev->change_protocol = change_protocol; 265 dev->change_protocol = change_protocol;
267 rc = kfifo_alloc(&dev->raw->kfifo, 266 rc = kfifo_alloc(&dev->raw->kfifo,
268 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE, 267 sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 66eabc5dd000..97dd6921edbe 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1424,6 +1424,8 @@ int rc_register_device(struct rc_dev *dev)
1424 1424
1425 if (dev->change_protocol) { 1425 if (dev->change_protocol) {
1426 u64 rc_type = (1ll << rc_map->rc_type); 1426 u64 rc_type = (1ll << rc_map->rc_type);
1427 if (dev->driver_type == RC_DRIVER_IR_RAW)
1428 rc_type |= RC_BIT_LIRC;
1427 rc = dev->change_protocol(dev, &rc_type); 1429 rc = dev->change_protocol(dev, &rc_type);
1428 if (rc < 0) 1430 if (rc < 0)
1429 goto out_raw; 1431 goto out_raw;
diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 69506ebd4d07..c99e896604ee 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -21,60 +21,64 @@
21 21
22#include "cxl.h" 22#include "cxl.h"
23 23
24static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, 24static bool sste_matches(struct cxl_sste *sste, struct copro_slb *slb)
25 bool sec_hash,
26 struct cxl_sste *secondary_group,
27 unsigned int *lru)
28{ 25{
29 unsigned int i, entry; 26 return ((sste->vsid_data == cpu_to_be64(slb->vsid)) &&
30 struct cxl_sste *sste, *group = primary_group; 27 (sste->esid_data == cpu_to_be64(slb->esid)));
31 28}
32 for (i = 0; i < 2; i++) { 29
33 for (entry = 0; entry < 8; entry++) { 30/*
34 sste = group + entry; 31 * This finds a free SSTE for the given SLB, or returns NULL if it's already in
35 if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V)) 32 * the segment table.
36 return sste; 33 */
37 } 34static struct cxl_sste* find_free_sste(struct cxl_context *ctx,
38 if (!sec_hash) 35 struct copro_slb *slb)
39 break; 36{
40 group = secondary_group; 37 struct cxl_sste *primary, *sste, *ret = NULL;
38 unsigned int mask = (ctx->sst_size >> 7) - 1; /* SSTP0[SegTableSize] */
39 unsigned int entry;
40 unsigned int hash;
41
42 if (slb->vsid & SLB_VSID_B_1T)
43 hash = (slb->esid >> SID_SHIFT_1T) & mask;
44 else /* 256M */
45 hash = (slb->esid >> SID_SHIFT) & mask;
46
47 primary = ctx->sstp + (hash << 3);
48
49 for (entry = 0, sste = primary; entry < 8; entry++, sste++) {
50 if (!ret && !(be64_to_cpu(sste->esid_data) & SLB_ESID_V))
51 ret = sste;
52 if (sste_matches(sste, slb))
53 return NULL;
41 } 54 }
55 if (ret)
56 return ret;
57
42 /* Nothing free, select an entry to cast out */ 58 /* Nothing free, select an entry to cast out */
43 if (sec_hash && (*lru & 0x8)) 59 ret = primary + ctx->sst_lru;
44 sste = secondary_group + (*lru & 0x7); 60 ctx->sst_lru = (ctx->sst_lru + 1) & 0x7;
45 else
46 sste = primary_group + (*lru & 0x7);
47 *lru = (*lru + 1) & 0xf;
48 61
49 return sste; 62 return ret;
50} 63}
51 64
52static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb) 65static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb)
53{ 66{
54 /* mask is the group index, we search primary and secondary here. */ 67 /* mask is the group index, we search primary and secondary here. */
55 unsigned int mask = (ctx->sst_size >> 7)-1; /* SSTP0[SegTableSize] */
56 bool sec_hash = 1;
57 struct cxl_sste *sste; 68 struct cxl_sste *sste;
58 unsigned int hash;
59 unsigned long flags; 69 unsigned long flags;
60 70
61
62 sec_hash = !!(cxl_p1n_read(ctx->afu, CXL_PSL_SR_An) & CXL_PSL_SR_An_SC);
63
64 if (slb->vsid & SLB_VSID_B_1T)
65 hash = (slb->esid >> SID_SHIFT_1T) & mask;
66 else /* 256M */
67 hash = (slb->esid >> SID_SHIFT) & mask;
68
69 spin_lock_irqsave(&ctx->sste_lock, flags); 71 spin_lock_irqsave(&ctx->sste_lock, flags);
70 sste = find_free_sste(ctx->sstp + (hash << 3), sec_hash, 72 sste = find_free_sste(ctx, slb);
71 ctx->sstp + ((~hash & mask) << 3), &ctx->sst_lru); 73 if (!sste)
74 goto out_unlock;
72 75
73 pr_devel("CXL Populating SST[%li]: %#llx %#llx\n", 76 pr_devel("CXL Populating SST[%li]: %#llx %#llx\n",
74 sste - ctx->sstp, slb->vsid, slb->esid); 77 sste - ctx->sstp, slb->vsid, slb->esid);
75 78
76 sste->vsid_data = cpu_to_be64(slb->vsid); 79 sste->vsid_data = cpu_to_be64(slb->vsid);
77 sste->esid_data = cpu_to_be64(slb->esid); 80 sste->esid_data = cpu_to_be64(slb->esid);
81out_unlock:
78 spin_unlock_irqrestore(&ctx->sste_lock, flags); 82 spin_unlock_irqrestore(&ctx->sste_lock, flags);
79} 83}
80 84
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 623286a77114..d47532e8f4f1 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -417,7 +417,7 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
417 ctx->elem->haurp = 0; /* disable */ 417 ctx->elem->haurp = 0; /* disable */
418 ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1)); 418 ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1));
419 419
420 sr = CXL_PSL_SR_An_SC; 420 sr = 0;
421 if (ctx->master) 421 if (ctx->master)
422 sr |= CXL_PSL_SR_An_MP; 422 sr |= CXL_PSL_SR_An_MP;
423 if (mfspr(SPRN_LPCR) & LPCR_TC) 423 if (mfspr(SPRN_LPCR) & LPCR_TC)
@@ -508,7 +508,7 @@ static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr)
508 u64 sr; 508 u64 sr;
509 int rc; 509 int rc;
510 510
511 sr = CXL_PSL_SR_An_SC; 511 sr = 0;
512 set_endian(sr); 512 set_endian(sr);
513 if (ctx->master) 513 if (ctx->master)
514 sr |= CXL_PSL_SR_An_MP; 514 sr |= CXL_PSL_SR_An_MP;
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 03c53b72a2d6..270d58a4c43d 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -311,7 +311,8 @@ int mmc_of_parse(struct mmc_host *host)
311 struct device_node *np; 311 struct device_node *np;
312 u32 bus_width; 312 u32 bus_width;
313 int len, ret; 313 int len, ret;
314 bool cap_invert, gpio_invert; 314 bool cd_cap_invert, cd_gpio_invert = false;
315 bool ro_cap_invert, ro_gpio_invert = false;
315 316
316 if (!host->parent || !host->parent->of_node) 317 if (!host->parent || !host->parent->of_node)
317 return 0; 318 return 0;
@@ -359,16 +360,13 @@ int mmc_of_parse(struct mmc_host *host)
359 if (of_find_property(np, "non-removable", &len)) { 360 if (of_find_property(np, "non-removable", &len)) {
360 host->caps |= MMC_CAP_NONREMOVABLE; 361 host->caps |= MMC_CAP_NONREMOVABLE;
361 } else { 362 } else {
362 if (of_property_read_bool(np, "cd-inverted")) 363 cd_cap_invert = of_property_read_bool(np, "cd-inverted");
363 cap_invert = true;
364 else
365 cap_invert = false;
366 364
367 if (of_find_property(np, "broken-cd", &len)) 365 if (of_find_property(np, "broken-cd", &len))
368 host->caps |= MMC_CAP_NEEDS_POLL; 366 host->caps |= MMC_CAP_NEEDS_POLL;
369 367
370 ret = mmc_gpiod_request_cd(host, "cd", 0, true, 368 ret = mmc_gpiod_request_cd(host, "cd", 0, true,
371 0, &gpio_invert); 369 0, &cd_gpio_invert);
372 if (ret) { 370 if (ret) {
373 if (ret == -EPROBE_DEFER) 371 if (ret == -EPROBE_DEFER)
374 return ret; 372 return ret;
@@ -391,17 +389,14 @@ int mmc_of_parse(struct mmc_host *host)
391 * both inverted, the end result is that the CD line is 389 * both inverted, the end result is that the CD line is
392 * not inverted. 390 * not inverted.
393 */ 391 */
394 if (cap_invert ^ gpio_invert) 392 if (cd_cap_invert ^ cd_gpio_invert)
395 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 393 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
396 } 394 }
397 395
398 /* Parse Write Protection */ 396 /* Parse Write Protection */
399 if (of_property_read_bool(np, "wp-inverted")) 397 ro_cap_invert = of_property_read_bool(np, "wp-inverted");
400 cap_invert = true;
401 else
402 cap_invert = false;
403 398
404 ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &gpio_invert); 399 ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert);
405 if (ret) { 400 if (ret) {
406 if (ret == -EPROBE_DEFER) 401 if (ret == -EPROBE_DEFER)
407 goto out; 402 goto out;
@@ -414,7 +409,7 @@ int mmc_of_parse(struct mmc_host *host)
414 dev_info(host->parent, "Got WP GPIO\n"); 409 dev_info(host->parent, "Got WP GPIO\n");
415 410
416 /* See the comment on CD inversion above */ 411 /* See the comment on CD inversion above */
417 if (cap_invert ^ gpio_invert) 412 if (ro_cap_invert ^ ro_gpio_invert)
418 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 413 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
419 414
420 if (of_find_property(np, "cap-sd-highspeed", &len)) 415 if (of_find_property(np, "cap-sd-highspeed", &len))
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index a7543ba3e190..3096f3ded3ad 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2590,6 +2590,8 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2590 2590
2591 /* Go to known state. Chip may have been power cycled */ 2591 /* Go to known state. Chip may have been power cycled */
2592 if (chip->state == FL_PM_SUSPENDED) { 2592 if (chip->state == FL_PM_SUSPENDED) {
2593 /* Refresh LH28F640BF Partition Config. Register */
2594 fixup_LH28F640BF(mtd);
2593 map_write(map, CMD(0xFF), cfi->chips[i].start); 2595 map_write(map, CMD(0xFF), cfi->chips[i].start);
2594 chip->oldstate = chip->state = FL_READY; 2596 chip->oldstate = chip->state = FL_READY;
2595 wake_up(&chip->wq); 2597 wake_up(&chip->wq);
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index dcda6287228d..ed827cf894e4 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -193,10 +193,10 @@ static int m25p_probe(struct spi_device *spi)
193{ 193{
194 struct mtd_part_parser_data ppdata; 194 struct mtd_part_parser_data ppdata;
195 struct flash_platform_data *data; 195 struct flash_platform_data *data;
196 const struct spi_device_id *id = NULL;
197 struct m25p *flash; 196 struct m25p *flash;
198 struct spi_nor *nor; 197 struct spi_nor *nor;
199 enum read_mode mode = SPI_NOR_NORMAL; 198 enum read_mode mode = SPI_NOR_NORMAL;
199 char *flash_name = NULL;
200 int ret; 200 int ret;
201 201
202 data = dev_get_platdata(&spi->dev); 202 data = dev_get_platdata(&spi->dev);
@@ -236,13 +236,11 @@ static int m25p_probe(struct spi_device *spi)
236 * If that's the case, respect "type" and ignore a "name". 236 * If that's the case, respect "type" and ignore a "name".
237 */ 237 */
238 if (data && data->type) 238 if (data && data->type)
239 id = spi_nor_match_id(data->type); 239 flash_name = data->type;
240 else
241 flash_name = spi->modalias;
240 242
241 /* If we didn't get name from platform, simply use "modalias". */ 243 ret = spi_nor_scan(nor, flash_name, mode);
242 if (!id)
243 id = spi_get_device_id(spi);
244
245 ret = spi_nor_scan(nor, id, mode);
246 if (ret) 244 if (ret)
247 return ret; 245 return ret;
248 246
@@ -263,12 +261,62 @@ static int m25p_remove(struct spi_device *spi)
263} 261}
264 262
265 263
264/*
265 * XXX This needs to be kept in sync with spi_nor_ids. We can't share
266 * it with spi-nor, because if this is built as a module then modpost
267 * won't be able to read it and add appropriate aliases.
268 */
269static const struct spi_device_id m25p_ids[] = {
270 {"at25fs010"}, {"at25fs040"}, {"at25df041a"}, {"at25df321a"},
271 {"at25df641"}, {"at26f004"}, {"at26df081a"}, {"at26df161a"},
272 {"at26df321"}, {"at45db081d"},
273 {"en25f32"}, {"en25p32"}, {"en25q32b"}, {"en25p64"},
274 {"en25q64"}, {"en25qh128"}, {"en25qh256"},
275 {"f25l32pa"},
276 {"mr25h256"}, {"mr25h10"},
277 {"gd25q32"}, {"gd25q64"},
278 {"160s33b"}, {"320s33b"}, {"640s33b"},
279 {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"},
280 {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"},
281 {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
282 {"mx66l1g55g"},
283 {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"},
284 {"n25q512a"}, {"n25q512ax3"}, {"n25q00"},
285 {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},
286 {"s25sl032p"}, {"s25sl064p"}, {"s25fl256s0"}, {"s25fl256s1"},
287 {"s25fl512s"}, {"s70fl01gs"}, {"s25sl12800"}, {"s25sl12801"},
288 {"s25fl129p0"}, {"s25fl129p1"}, {"s25sl004a"}, {"s25sl008a"},
289 {"s25sl016a"}, {"s25sl032a"}, {"s25sl064a"}, {"s25fl008k"},
290 {"s25fl016k"}, {"s25fl064k"},
291 {"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
292 {"sst25vf064c"},{"sst25wf512"}, {"sst25wf010"}, {"sst25wf020"},
293 {"sst25wf040"},
294 {"m25p05"}, {"m25p10"}, {"m25p20"}, {"m25p40"},
295 {"m25p80"}, {"m25p16"}, {"m25p32"}, {"m25p64"},
296 {"m25p128"}, {"n25q032"},
297 {"m25p05-nonjedec"}, {"m25p10-nonjedec"}, {"m25p20-nonjedec"},
298 {"m25p40-nonjedec"}, {"m25p80-nonjedec"}, {"m25p16-nonjedec"},
299 {"m25p32-nonjedec"}, {"m25p64-nonjedec"}, {"m25p128-nonjedec"},
300 {"m45pe10"}, {"m45pe80"}, {"m45pe16"},
301 {"m25pe20"}, {"m25pe80"}, {"m25pe16"},
302 {"m25px16"}, {"m25px32"}, {"m25px32-s0"}, {"m25px32-s1"},
303 {"m25px64"},
304 {"w25x10"}, {"w25x20"}, {"w25x40"}, {"w25x80"},
305 {"w25x16"}, {"w25x32"}, {"w25q32"}, {"w25q32dw"},
306 {"w25x64"}, {"w25q64"}, {"w25q128"}, {"w25q80"},
307 {"w25q80bl"}, {"w25q128"}, {"w25q256"}, {"cat25c11"},
308 {"cat25c03"}, {"cat25c09"}, {"cat25c17"}, {"cat25128"},
309 { },
310};
311MODULE_DEVICE_TABLE(spi, m25p_ids);
312
313
266static struct spi_driver m25p80_driver = { 314static struct spi_driver m25p80_driver = {
267 .driver = { 315 .driver = {
268 .name = "m25p80", 316 .name = "m25p80",
269 .owner = THIS_MODULE, 317 .owner = THIS_MODULE,
270 }, 318 },
271 .id_table = spi_nor_ids, 319 .id_table = m25p_ids,
272 .probe = m25p_probe, 320 .probe = m25p_probe,
273 .remove = m25p_remove, 321 .remove = m25p_remove,
274 322
diff --git a/drivers/mtd/nand/omap_elm.c b/drivers/mtd/nand/omap_elm.c
index b4f61c7fc161..058531044ceb 100644
--- a/drivers/mtd/nand/omap_elm.c
+++ b/drivers/mtd/nand/omap_elm.c
@@ -115,7 +115,7 @@ int elm_config(struct device *dev, enum bch_ecc bch_type,
115 115
116 if (!info) { 116 if (!info) {
117 dev_err(dev, "Unable to configure elm - device not probed?\n"); 117 dev_err(dev, "Unable to configure elm - device not probed?\n");
118 return -ENODEV; 118 return -EPROBE_DEFER;
119 } 119 }
120 /* ELM cannot detect ECC errors for chunks > 1KB */ 120 /* ELM cannot detect ECC errors for chunks > 1KB */
121 if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) { 121 if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) {
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 8d659a2888d5..d5269a26c839 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
881 881
882 /* iterate the subnodes. */ 882 /* iterate the subnodes. */
883 for_each_available_child_of_node(dev->of_node, np) { 883 for_each_available_child_of_node(dev->of_node, np) {
884 const struct spi_device_id *id;
885 char modalias[40]; 884 char modalias[40];
886 885
887 /* skip the holes */ 886 /* skip the holes */
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
909 if (of_modalias_node(np, modalias, sizeof(modalias)) < 0) 908 if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
910 goto map_failed; 909 goto map_failed;
911 910
912 id = spi_nor_match_id(modalias);
913 if (!id)
914 goto map_failed;
915
916 ret = of_property_read_u32(np, "spi-max-frequency", 911 ret = of_property_read_u32(np, "spi-max-frequency",
917 &q->clk_rate); 912 &q->clk_rate);
918 if (ret < 0) 913 if (ret < 0)
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
921 /* set the chip address for READID */ 916 /* set the chip address for READID */
922 fsl_qspi_set_base_addr(q, nor); 917 fsl_qspi_set_base_addr(q, nor);
923 918
924 ret = spi_nor_scan(nor, id, SPI_NOR_QUAD); 919 ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
925 if (ret) 920 if (ret)
926 goto map_failed; 921 goto map_failed;
927 922
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index ae16aa2f6885..c51ee52386a7 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,6 +28,8 @@
28 28
29#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16) 29#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
30 30
31static const struct spi_device_id *spi_nor_match_id(const char *name);
32
31/* 33/*
32 * Read the status register, returning its value in the location 34 * Read the status register, returning its value in the location
33 * Return the status register value. 35 * Return the status register value.
@@ -473,7 +475,7 @@ struct flash_info {
473 * more nor chips. This current list focusses on newer chips, which 475 * more nor chips. This current list focusses on newer chips, which
474 * have been converging on command sets which including JEDEC ID. 476 * have been converging on command sets which including JEDEC ID.
475 */ 477 */
476const struct spi_device_id spi_nor_ids[] = { 478static const struct spi_device_id spi_nor_ids[] = {
477 /* Atmel -- some are (confusingly) marketed as "DataFlash" */ 479 /* Atmel -- some are (confusingly) marketed as "DataFlash" */
478 { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, 480 { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) },
479 { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, 481 { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) },
@@ -637,7 +639,6 @@ const struct spi_device_id spi_nor_ids[] = {
637 { "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, 639 { "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
638 { }, 640 { },
639}; 641};
640EXPORT_SYMBOL_GPL(spi_nor_ids);
641 642
642static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor) 643static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
643{ 644{
@@ -911,9 +912,9 @@ static int spi_nor_check(struct spi_nor *nor)
911 return 0; 912 return 0;
912} 913}
913 914
914int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, 915int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
915 enum read_mode mode)
916{ 916{
917 const struct spi_device_id *id = NULL;
917 struct flash_info *info; 918 struct flash_info *info;
918 struct device *dev = nor->dev; 919 struct device *dev = nor->dev;
919 struct mtd_info *mtd = nor->mtd; 920 struct mtd_info *mtd = nor->mtd;
@@ -925,6 +926,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
925 if (ret) 926 if (ret)
926 return ret; 927 return ret;
927 928
929 id = spi_nor_match_id(name);
930 if (!id)
931 return -ENOENT;
932
928 info = (void *)id->driver_data; 933 info = (void *)id->driver_data;
929 934
930 if (info->jedec_id) { 935 if (info->jedec_id) {
@@ -1113,7 +1118,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
1113} 1118}
1114EXPORT_SYMBOL_GPL(spi_nor_scan); 1119EXPORT_SYMBOL_GPL(spi_nor_scan);
1115 1120
1116const struct spi_device_id *spi_nor_match_id(char *name) 1121static const struct spi_device_id *spi_nor_match_id(const char *name)
1117{ 1122{
1118 const struct spi_device_id *id = spi_nor_ids; 1123 const struct spi_device_id *id = spi_nor_ids;
1119 1124
@@ -1124,7 +1129,6 @@ const struct spi_device_id *spi_nor_match_id(char *name)
1124 } 1129 }
1125 return NULL; 1130 return NULL;
1126} 1131}
1127EXPORT_SYMBOL_GPL(spi_nor_match_id);
1128 1132
1129MODULE_LICENSE("GPL"); 1133MODULE_LICENSE("GPL");
1130MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>"); 1134MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4706386b7d34..f9009be3f307 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -135,6 +135,7 @@ config MACVLAN
135config MACVTAP 135config MACVTAP
136 tristate "MAC-VLAN based tap driver" 136 tristate "MAC-VLAN based tap driver"
137 depends on MACVLAN 137 depends on MACVLAN
138 depends on INET
138 help 139 help
139 This adds a specialized tap character device driver that is based 140 This adds a specialized tap character device driver that is based
140 on the MAC-VLAN network interface, called macvtap. A macvtap device 141 on the MAC-VLAN network interface, called macvtap. A macvtap device
@@ -200,6 +201,7 @@ config RIONET_RX_SIZE
200 201
201config TUN 202config TUN
202 tristate "Universal TUN/TAP device driver support" 203 tristate "Universal TUN/TAP device driver support"
204 depends on INET
203 select CRC32 205 select CRC32
204 ---help--- 206 ---help---
205 TUN/TAP provides packet reception and transmission for user space 207 TUN/TAP provides packet reception and transmission for user space
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 1020a7af67cf..78d8e876f3aa 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -395,7 +395,7 @@ static int mv88e6171_get_sset_count(struct dsa_switch *ds)
395} 395}
396 396
397struct dsa_switch_driver mv88e6171_switch_driver = { 397struct dsa_switch_driver mv88e6171_switch_driver = {
398 .tag_protocol = DSA_TAG_PROTO_DSA, 398 .tag_protocol = DSA_TAG_PROTO_EDSA,
399 .priv_size = sizeof(struct mv88e6xxx_priv_state), 399 .priv_size = sizeof(struct mv88e6xxx_priv_state),
400 .probe = mv88e6171_probe, 400 .probe = mv88e6171_probe,
401 .setup = mv88e6171_setup, 401 .setup = mv88e6171_setup,
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 29554992215a..2349ea970255 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1465,7 +1465,7 @@ static int xgbe_set_features(struct net_device *netdev,
1465{ 1465{
1466 struct xgbe_prv_data *pdata = netdev_priv(netdev); 1466 struct xgbe_prv_data *pdata = netdev_priv(netdev);
1467 struct xgbe_hw_if *hw_if = &pdata->hw_if; 1467 struct xgbe_hw_if *hw_if = &pdata->hw_if;
1468 unsigned int rxcsum, rxvlan, rxvlan_filter; 1468 netdev_features_t rxcsum, rxvlan, rxvlan_filter;
1469 1469
1470 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM; 1470 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM;
1471 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX; 1471 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX;
@@ -1598,7 +1598,8 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1598 struct skb_shared_hwtstamps *hwtstamps; 1598 struct skb_shared_hwtstamps *hwtstamps;
1599 unsigned int incomplete, error, context_next, context; 1599 unsigned int incomplete, error, context_next, context;
1600 unsigned int len, put_len, max_len; 1600 unsigned int len, put_len, max_len;
1601 int received = 0; 1601 unsigned int received = 0;
1602 int packet_count = 0;
1602 1603
1603 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget); 1604 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget);
1604 1605
@@ -1608,7 +1609,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1608 1609
1609 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); 1610 rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
1610 packet = &ring->packet_data; 1611 packet = &ring->packet_data;
1611 while (received < budget) { 1612 while (packet_count < budget) {
1612 DBGPR(" cur = %d\n", ring->cur); 1613 DBGPR(" cur = %d\n", ring->cur);
1613 1614
1614 /* First time in loop see if we need to restore state */ 1615 /* First time in loop see if we need to restore state */
@@ -1662,7 +1663,7 @@ read_again:
1662 if (packet->errors) 1663 if (packet->errors)
1663 DBGPR("Error in received packet\n"); 1664 DBGPR("Error in received packet\n");
1664 dev_kfree_skb(skb); 1665 dev_kfree_skb(skb);
1665 continue; 1666 goto next_packet;
1666 } 1667 }
1667 1668
1668 if (!context) { 1669 if (!context) {
@@ -1677,7 +1678,7 @@ read_again:
1677 } 1678 }
1678 1679
1679 dev_kfree_skb(skb); 1680 dev_kfree_skb(skb);
1680 continue; 1681 goto next_packet;
1681 } 1682 }
1682 memcpy(skb_tail_pointer(skb), rdata->skb->data, 1683 memcpy(skb_tail_pointer(skb), rdata->skb->data,
1683 put_len); 1684 put_len);
@@ -1694,7 +1695,7 @@ read_again:
1694 1695
1695 /* Stray Context Descriptor? */ 1696 /* Stray Context Descriptor? */
1696 if (!skb) 1697 if (!skb)
1697 continue; 1698 goto next_packet;
1698 1699
1699 /* Be sure we don't exceed the configured MTU */ 1700 /* Be sure we don't exceed the configured MTU */
1700 max_len = netdev->mtu + ETH_HLEN; 1701 max_len = netdev->mtu + ETH_HLEN;
@@ -1705,7 +1706,7 @@ read_again:
1705 if (skb->len > max_len) { 1706 if (skb->len > max_len) {
1706 DBGPR("packet length exceeds configured MTU\n"); 1707 DBGPR("packet length exceeds configured MTU\n");
1707 dev_kfree_skb(skb); 1708 dev_kfree_skb(skb);
1708 continue; 1709 goto next_packet;
1709 } 1710 }
1710 1711
1711#ifdef XGMAC_ENABLE_RX_PKT_DUMP 1712#ifdef XGMAC_ENABLE_RX_PKT_DUMP
@@ -1739,6 +1740,9 @@ read_again:
1739 1740
1740 netdev->last_rx = jiffies; 1741 netdev->last_rx = jiffies;
1741 napi_gro_receive(&pdata->napi, skb); 1742 napi_gro_receive(&pdata->napi, skb);
1743
1744next_packet:
1745 packet_count++;
1742 } 1746 }
1743 1747
1744 /* Check if we need to save state before leaving */ 1748 /* Check if we need to save state before leaving */
@@ -1752,9 +1756,9 @@ read_again:
1752 rdata->state.error = error; 1756 rdata->state.error = error;
1753 } 1757 }
1754 1758
1755 DBGPR("<--xgbe_rx_poll: received = %d\n", received); 1759 DBGPR("<--xgbe_rx_poll: packet_count = %d\n", packet_count);
1756 1760
1757 return received; 1761 return packet_count;
1758} 1762}
1759 1763
1760static int xgbe_poll(struct napi_struct *napi, int budget) 1764static int xgbe_poll(struct napi_struct *napi, int budget)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index e6d24c210198..c22f32622fa9 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -124,20 +124,18 @@ static int xgene_enet_ecc_init(struct xgene_enet_pdata *p)
124{ 124{
125 struct net_device *ndev = p->ndev; 125 struct net_device *ndev = p->ndev;
126 u32 data; 126 u32 data;
127 int i; 127 int i = 0;
128 128
129 xgene_enet_wr_diag_csr(p, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0); 129 xgene_enet_wr_diag_csr(p, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0);
130 for (i = 0; i < 10 && data != ~0U ; i++) { 130 do {
131 usleep_range(100, 110); 131 usleep_range(100, 110);
132 data = xgene_enet_rd_diag_csr(p, ENET_BLOCK_MEM_RDY_ADDR); 132 data = xgene_enet_rd_diag_csr(p, ENET_BLOCK_MEM_RDY_ADDR);
133 } 133 if (data == ~0U)
134 return 0;
135 } while (++i < 10);
134 136
135 if (data != ~0U) { 137 netdev_err(ndev, "Failed to release memory from shutdown\n");
136 netdev_err(ndev, "Failed to release memory from shutdown\n"); 138 return -ENODEV;
137 return -ENODEV;
138 }
139
140 return 0;
141} 139}
142 140
143static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *p) 141static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *p)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 9ae36979bdee..3a6778a667f4 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1397,6 +1397,9 @@ static void bcm_sysport_netif_start(struct net_device *dev)
1397 /* Enable NAPI */ 1397 /* Enable NAPI */
1398 napi_enable(&priv->napi); 1398 napi_enable(&priv->napi);
1399 1399
1400 /* Enable RX interrupt and TX ring full interrupt */
1401 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1402
1400 phy_start(priv->phydev); 1403 phy_start(priv->phydev);
1401 1404
1402 /* Enable TX interrupts for the 32 TXQs */ 1405 /* Enable TX interrupts for the 32 TXQs */
@@ -1499,9 +1502,6 @@ static int bcm_sysport_open(struct net_device *dev)
1499 if (ret) 1502 if (ret)
1500 goto out_free_rx_ring; 1503 goto out_free_rx_ring;
1501 1504
1502 /* Enable RX interrupt and TX ring full interrupt */
1503 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1504
1505 /* Turn on TDMA */ 1505 /* Turn on TDMA */
1506 ret = tdma_enable_set(priv, 1); 1506 ret = tdma_enable_set(priv, 1);
1507 if (ret) 1507 if (ret)
@@ -1858,6 +1858,8 @@ static int bcm_sysport_resume(struct device *d)
1858 if (!netif_running(dev)) 1858 if (!netif_running(dev))
1859 return 0; 1859 return 0;
1860 1860
1861 umac_reset(priv);
1862
1861 /* We may have been suspended and never received a WOL event that 1863 /* We may have been suspended and never received a WOL event that
1862 * would turn off MPD detection, take care of that now 1864 * would turn off MPD detection, take care of that now
1863 */ 1865 */
@@ -1885,9 +1887,6 @@ static int bcm_sysport_resume(struct device *d)
1885 1887
1886 netif_device_attach(dev); 1888 netif_device_attach(dev);
1887 1889
1888 /* Enable RX interrupt and TX ring full interrupt */
1889 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1890
1891 /* RX pipe enable */ 1890 /* RX pipe enable */
1892 topctrl_writel(priv, 0, RX_FLUSH_CNTL); 1891 topctrl_writel(priv, 0, RX_FLUSH_CNTL);
1893 1892
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 23f23c97c2ad..f05fab65d78a 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -382,10 +382,8 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
382 if (l5_cid >= MAX_CM_SK_TBL_SZ) 382 if (l5_cid >= MAX_CM_SK_TBL_SZ)
383 break; 383 break;
384 384
385 rcu_read_lock();
386 if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) { 385 if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) {
387 rc = -ENODEV; 386 rc = -ENODEV;
388 rcu_read_unlock();
389 break; 387 break;
390 } 388 }
391 csk = &cp->csk_tbl[l5_cid]; 389 csk = &cp->csk_tbl[l5_cid];
@@ -414,7 +412,6 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
414 } 412 }
415 } 413 }
416 csk_put(csk); 414 csk_put(csk);
417 rcu_read_unlock();
418 rc = 0; 415 rc = 0;
419 } 416 }
420 } 417 }
@@ -615,7 +612,7 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
615 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); 612 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL);
616 613
617 mutex_lock(&cnic_lock); 614 mutex_lock(&cnic_lock);
618 if (rcu_dereference(cp->ulp_ops[ulp_type])) { 615 if (rcu_access_pointer(cp->ulp_ops[ulp_type])) {
619 RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL); 616 RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL);
620 cnic_put(dev); 617 cnic_put(dev);
621 } else { 618 } else {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 8edf0f5bd679..6fe300e316c3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -60,6 +60,42 @@ void cxgb4_dcb_version_init(struct net_device *dev)
60 dcb->dcb_version = FW_PORT_DCB_VER_AUTO; 60 dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
61} 61}
62 62
63static void cxgb4_dcb_cleanup_apps(struct net_device *dev)
64{
65 struct port_info *pi = netdev2pinfo(dev);
66 struct adapter *adap = pi->adapter;
67 struct port_dcb_info *dcb = &pi->dcb;
68 struct dcb_app app;
69 int i, err;
70
71 /* zero priority implies remove */
72 app.priority = 0;
73
74 for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) {
75 /* Check if app list is exhausted */
76 if (!dcb->app_priority[i].protocolid)
77 break;
78
79 app.protocol = dcb->app_priority[i].protocolid;
80
81 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
82 app.selector = dcb->app_priority[i].sel_field + 1;
83 err = dcb_ieee_setapp(dev, &app);
84 } else {
85 app.selector = !!(dcb->app_priority[i].sel_field);
86 err = dcb_setapp(dev, &app);
87 }
88
89 if (err) {
90 dev_err(adap->pdev_dev,
91 "Failed DCB Clear %s Application Priority: sel=%d, prot=%d, , err=%d\n",
92 dcb_ver_array[dcb->dcb_version], app.selector,
93 app.protocol, -err);
94 break;
95 }
96 }
97}
98
63/* Finite State machine for Data Center Bridging. 99/* Finite State machine for Data Center Bridging.
64 */ 100 */
65void cxgb4_dcb_state_fsm(struct net_device *dev, 101void cxgb4_dcb_state_fsm(struct net_device *dev,
@@ -80,7 +116,6 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
80 /* we're going to use Host DCB */ 116 /* we're going to use Host DCB */
81 dcb->state = CXGB4_DCB_STATE_HOST; 117 dcb->state = CXGB4_DCB_STATE_HOST;
82 dcb->supported = CXGB4_DCBX_HOST_SUPPORT; 118 dcb->supported = CXGB4_DCBX_HOST_SUPPORT;
83 dcb->enabled = 1;
84 break; 119 break;
85 } 120 }
86 121
@@ -145,6 +180,7 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
145 * state. We need to reset back to a ground state 180 * state. We need to reset back to a ground state
146 * of incomplete. 181 * of incomplete.
147 */ 182 */
183 cxgb4_dcb_cleanup_apps(dev);
148 cxgb4_dcb_state_init(dev); 184 cxgb4_dcb_state_init(dev);
149 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; 185 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
150 dcb->supported = CXGB4_DCBX_FW_SUPPORT; 186 dcb->supported = CXGB4_DCBX_FW_SUPPORT;
@@ -349,6 +385,12 @@ static u8 cxgb4_setstate(struct net_device *dev, u8 enabled)
349{ 385{
350 struct port_info *pi = netdev2pinfo(dev); 386 struct port_info *pi = netdev2pinfo(dev);
351 387
388 /* If DCBx is host-managed, dcb is enabled by outside lldp agents */
389 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) {
390 pi->dcb.enabled = enabled;
391 return 0;
392 }
393
352 /* Firmware doesn't provide any mechanism to control the DCB state. 394 /* Firmware doesn't provide any mechanism to control the DCB state.
353 */ 395 */
354 if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED)) 396 if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED))
@@ -833,11 +875,16 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
833 875
834/* Return whether IEEE Data Center Bridging has been negotiated. 876/* Return whether IEEE Data Center Bridging has been negotiated.
835 */ 877 */
836static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev) 878static inline int
879cxgb4_ieee_negotiation_complete(struct net_device *dev,
880 enum cxgb4_dcb_fw_msgs dcb_subtype)
837{ 881{
838 struct port_info *pi = netdev2pinfo(dev); 882 struct port_info *pi = netdev2pinfo(dev);
839 struct port_dcb_info *dcb = &pi->dcb; 883 struct port_dcb_info *dcb = &pi->dcb;
840 884
885 if (dcb_subtype && !(dcb->msgs & dcb_subtype))
886 return 0;
887
841 return (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED && 888 return (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED &&
842 (dcb->supported & DCB_CAP_DCBX_VER_IEEE)); 889 (dcb->supported & DCB_CAP_DCBX_VER_IEEE));
843} 890}
@@ -850,7 +897,7 @@ static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
850{ 897{
851 int prio; 898 int prio;
852 899
853 if (!cxgb4_ieee_negotiation_complete(dev)) 900 if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID))
854 return -EINVAL; 901 return -EINVAL;
855 if (!(app->selector && app->protocol)) 902 if (!(app->selector && app->protocol))
856 return -EINVAL; 903 return -EINVAL;
@@ -872,7 +919,7 @@ static int cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app)
872{ 919{
873 int ret; 920 int ret;
874 921
875 if (!cxgb4_ieee_negotiation_complete(dev)) 922 if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID))
876 return -EINVAL; 923 return -EINVAL;
877 if (!(app->selector && app->protocol)) 924 if (!(app->selector && app->protocol))
878 return -EINVAL; 925 return -EINVAL;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 3f60070f2519..8520d5529df8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -694,7 +694,11 @@ int cxgb4_dcb_enabled(const struct net_device *dev)
694#ifdef CONFIG_CHELSIO_T4_DCB 694#ifdef CONFIG_CHELSIO_T4_DCB
695 struct port_info *pi = netdev_priv(dev); 695 struct port_info *pi = netdev_priv(dev);
696 696
697 return pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED; 697 if (!pi->dcb.enabled)
698 return 0;
699
700 return ((pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED) ||
701 (pi->dcb.state == CXGB4_DCB_STATE_HOST));
698#else 702#else
699 return 0; 703 return 0;
700#endif 704#endif
@@ -6610,6 +6614,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6610 6614
6611 spin_lock_init(&adapter->stats_lock); 6615 spin_lock_init(&adapter->stats_lock);
6612 spin_lock_init(&adapter->tid_release_lock); 6616 spin_lock_init(&adapter->tid_release_lock);
6617 spin_lock_init(&adapter->win0_lock);
6613 6618
6614 INIT_WORK(&adapter->tid_release_task, process_tid_release_list); 6619 INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
6615 INIT_WORK(&adapter->db_full_task, process_db_full); 6620 INIT_WORK(&adapter->db_full_task, process_db_full);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index bfa398d91826..0b42bddaf284 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2929,14 +2929,14 @@ static const struct pci_device_id cxgb4vf_pci_tbl[] = {
2929 CH_DEVICE(0x480d), /* T480-cr */ 2929 CH_DEVICE(0x480d), /* T480-cr */
2930 CH_DEVICE(0x480e), /* T440-lp-cr */ 2930 CH_DEVICE(0x480e), /* T440-lp-cr */
2931 CH_DEVICE(0x4880), 2931 CH_DEVICE(0x4880),
2932 CH_DEVICE(0x4880), 2932 CH_DEVICE(0x4881),
2933 CH_DEVICE(0x4880), 2933 CH_DEVICE(0x4882),
2934 CH_DEVICE(0x4880), 2934 CH_DEVICE(0x4883),
2935 CH_DEVICE(0x4880), 2935 CH_DEVICE(0x4884),
2936 CH_DEVICE(0x4880), 2936 CH_DEVICE(0x4885),
2937 CH_DEVICE(0x4880), 2937 CH_DEVICE(0x4886),
2938 CH_DEVICE(0x4880), 2938 CH_DEVICE(0x4887),
2939 CH_DEVICE(0x4880), 2939 CH_DEVICE(0x4888),
2940 CH_DEVICE(0x5801), /* T520-cr */ 2940 CH_DEVICE(0x5801), /* T520-cr */
2941 CH_DEVICE(0x5802), /* T522-cr */ 2941 CH_DEVICE(0x5802), /* T522-cr */
2942 CH_DEVICE(0x5803), /* T540-cr */ 2942 CH_DEVICE(0x5803), /* T540-cr */
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
index 69dfd3c9e529..0be6850be8a2 100644
--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
+++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
@@ -86,7 +86,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
86 int i; 86 int i;
87 87
88 enic_rfs_timer_stop(enic); 88 enic_rfs_timer_stop(enic);
89 spin_lock(&enic->rfs_h.lock); 89 spin_lock_bh(&enic->rfs_h.lock);
90 enic->rfs_h.free = 0; 90 enic->rfs_h.free = 0;
91 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { 91 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
92 struct hlist_head *hhead; 92 struct hlist_head *hhead;
@@ -100,7 +100,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
100 kfree(n); 100 kfree(n);
101 } 101 }
102 } 102 }
103 spin_unlock(&enic->rfs_h.lock); 103 spin_unlock_bh(&enic->rfs_h.lock);
104} 104}
105 105
106struct enic_rfs_fltr_node *htbl_fltr_search(struct enic *enic, u16 fltr_id) 106struct enic_rfs_fltr_node *htbl_fltr_search(struct enic *enic, u16 fltr_id)
@@ -128,7 +128,7 @@ void enic_flow_may_expire(unsigned long data)
128 bool res; 128 bool res;
129 int j; 129 int j;
130 130
131 spin_lock(&enic->rfs_h.lock); 131 spin_lock_bh(&enic->rfs_h.lock);
132 for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) { 132 for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) {
133 struct hlist_head *hhead; 133 struct hlist_head *hhead;
134 struct hlist_node *tmp; 134 struct hlist_node *tmp;
@@ -148,7 +148,7 @@ void enic_flow_may_expire(unsigned long data)
148 } 148 }
149 } 149 }
150 } 150 }
151 spin_unlock(&enic->rfs_h.lock); 151 spin_unlock_bh(&enic->rfs_h.lock);
152 mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); 152 mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4);
153} 153}
154 154
@@ -183,7 +183,7 @@ int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
183 return -EPROTONOSUPPORT; 183 return -EPROTONOSUPPORT;
184 184
185 tbl_idx = skb_get_hash_raw(skb) & ENIC_RFS_FLW_MASK; 185 tbl_idx = skb_get_hash_raw(skb) & ENIC_RFS_FLW_MASK;
186 spin_lock(&enic->rfs_h.lock); 186 spin_lock_bh(&enic->rfs_h.lock);
187 n = htbl_key_search(&enic->rfs_h.ht_head[tbl_idx], &keys); 187 n = htbl_key_search(&enic->rfs_h.ht_head[tbl_idx], &keys);
188 188
189 if (n) { /* entry already present */ 189 if (n) { /* entry already present */
@@ -277,7 +277,7 @@ int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
277 } 277 }
278 278
279ret_unlock: 279ret_unlock:
280 spin_unlock(&enic->rfs_h.lock); 280 spin_unlock_bh(&enic->rfs_h.lock);
281 return res; 281 return res;
282} 282}
283 283
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 929bfe70080a..180e53fa628f 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1674,13 +1674,13 @@ static int enic_stop(struct net_device *netdev)
1674 1674
1675 enic_dev_disable(enic); 1675 enic_dev_disable(enic);
1676 1676
1677 local_bh_disable();
1678 for (i = 0; i < enic->rq_count; i++) { 1677 for (i = 0; i < enic->rq_count; i++) {
1679 napi_disable(&enic->napi[i]); 1678 napi_disable(&enic->napi[i]);
1679 local_bh_disable();
1680 while (!enic_poll_lock_napi(&enic->rq[i])) 1680 while (!enic_poll_lock_napi(&enic->rq[i]))
1681 mdelay(1); 1681 mdelay(1);
1682 local_bh_enable();
1682 } 1683 }
1683 local_bh_enable();
1684 1684
1685 netif_carrier_off(netdev); 1685 netif_carrier_off(netdev);
1686 netif_tx_disable(netdev); 1686 netif_tx_disable(netdev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 81b96cf87574..50a851db2852 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1581,7 +1581,8 @@ fec_enet_interrupt(int irq, void *dev_id)
1581 complete(&fep->mdio_done); 1581 complete(&fep->mdio_done);
1582 } 1582 }
1583 1583
1584 fec_ptp_check_pps_event(fep); 1584 if (fep->ptp_clock)
1585 fec_ptp_check_pps_event(fep);
1585 1586
1586 return ret; 1587 return ret;
1587} 1588}
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
index 3d4e08be1709..b34214e2df5f 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
@@ -341,6 +341,9 @@ static void restart(struct net_device *dev)
341 FC(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */ 341 FC(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */
342 } 342 }
343 343
344 /* Restore multicast and promiscuous settings */
345 set_multicast_list(dev);
346
344 /* 347 /*
345 * Enable interrupts we wish to service. 348 * Enable interrupts we wish to service.
346 */ 349 */
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
index f30411f0701f..7a184e8816a4 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
@@ -355,6 +355,9 @@ static void restart(struct net_device *dev)
355 if (fep->phydev->duplex) 355 if (fep->phydev->duplex)
356 S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE); 356 S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE);
357 357
358 /* Restore multicast and promiscuous settings */
359 set_multicast_list(dev);
360
358 S32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); 361 S32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT);
359} 362}
360 363
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 5f6aded512f5..24f3986cfae2 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1075,7 +1075,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1075 NETIF_F_HW_CSUM | 1075 NETIF_F_HW_CSUM |
1076 NETIF_F_SG); 1076 NETIF_F_SG);
1077 1077
1078 netdev->priv_flags |= IFF_UNICAST_FLT; 1078 /* Do not set IFF_UNICAST_FLT for VMWare's 82545EM */
1079 if (hw->device_id != E1000_DEV_ID_82545EM_COPPER ||
1080 hw->subsystem_vendor_id != PCI_VENDOR_ID_VMWARE)
1081 netdev->priv_flags |= IFF_UNICAST_FLT;
1079 1082
1080 adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw); 1083 adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
1081 1084
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ed5f1c15fb0f..c3a7f4a4b775 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -6151,7 +6151,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
6151 I40E_GL_MDET_TX_PF_NUM_SHIFT; 6151 I40E_GL_MDET_TX_PF_NUM_SHIFT;
6152 u8 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> 6152 u8 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >>
6153 I40E_GL_MDET_TX_VF_NUM_SHIFT; 6153 I40E_GL_MDET_TX_VF_NUM_SHIFT;
6154 u8 event = (reg & I40E_GL_MDET_TX_EVENT_SHIFT) >> 6154 u8 event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
6155 I40E_GL_MDET_TX_EVENT_SHIFT; 6155 I40E_GL_MDET_TX_EVENT_SHIFT;
6156 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >> 6156 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
6157 I40E_GL_MDET_TX_QUEUE_SHIFT; 6157 I40E_GL_MDET_TX_QUEUE_SHIFT;
@@ -6165,7 +6165,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
6165 if (reg & I40E_GL_MDET_RX_VALID_MASK) { 6165 if (reg & I40E_GL_MDET_RX_VALID_MASK) {
6166 u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> 6166 u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
6167 I40E_GL_MDET_RX_FUNCTION_SHIFT; 6167 I40E_GL_MDET_RX_FUNCTION_SHIFT;
6168 u8 event = (reg & I40E_GL_MDET_RX_EVENT_SHIFT) >> 6168 u8 event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
6169 I40E_GL_MDET_RX_EVENT_SHIFT; 6169 I40E_GL_MDET_RX_EVENT_SHIFT;
6170 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >> 6170 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
6171 I40E_GL_MDET_RX_QUEUE_SHIFT; 6171 I40E_GL_MDET_RX_QUEUE_SHIFT;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a21b14495ebd..a2d72a87cbde 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6537,6 +6537,9 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer,
6537 if (unlikely(page_to_nid(page) != numa_node_id())) 6537 if (unlikely(page_to_nid(page) != numa_node_id()))
6538 return false; 6538 return false;
6539 6539
6540 if (unlikely(page->pfmemalloc))
6541 return false;
6542
6540#if (PAGE_SIZE < 8192) 6543#if (PAGE_SIZE < 8192)
6541 /* if we are only owner of page we can reuse it */ 6544 /* if we are only owner of page we can reuse it */
6542 if (unlikely(page_count(page) != 1)) 6545 if (unlikely(page_count(page) != 1))
@@ -6603,7 +6606,8 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,
6603 memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long))); 6606 memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));
6604 6607
6605 /* we can reuse buffer as-is, just make sure it is local */ 6608 /* we can reuse buffer as-is, just make sure it is local */
6606 if (likely(page_to_nid(page) == numa_node_id())) 6609 if (likely((page_to_nid(page) == numa_node_id()) &&
6610 !page->pfmemalloc))
6607 return true; 6611 return true;
6608 6612
6609 /* this page cannot be reused so discard it */ 6613 /* this page cannot be reused so discard it */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 3ce4a258f945..0ae038b9af90 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -342,12 +342,16 @@ static int ixgbe_set_settings(struct net_device *netdev,
342 if (old == advertised) 342 if (old == advertised)
343 return err; 343 return err;
344 /* this sets the link speed and restarts auto-neg */ 344 /* this sets the link speed and restarts auto-neg */
345 while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
346 usleep_range(1000, 2000);
347
345 hw->mac.autotry_restart = true; 348 hw->mac.autotry_restart = true;
346 err = hw->mac.ops.setup_link(hw, advertised, true); 349 err = hw->mac.ops.setup_link(hw, advertised, true);
347 if (err) { 350 if (err) {
348 e_info(probe, "setup link failed with code %d\n", err); 351 e_info(probe, "setup link failed with code %d\n", err);
349 hw->mac.ops.setup_link(hw, old, true); 352 hw->mac.ops.setup_link(hw, old, true);
350 } 353 }
354 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
351 } else { 355 } else {
352 /* in this case we currently only support 10Gb/FULL */ 356 /* in this case we currently only support 10Gb/FULL */
353 u32 speed = ethtool_cmd_speed(ecmd); 357 u32 speed = ethtool_cmd_speed(ecmd);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index fec5212d4337..d2df4e3d1032 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -4321,8 +4321,8 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring)
4321 IXGBE_CB(skb)->page_released = false; 4321 IXGBE_CB(skb)->page_released = false;
4322 } 4322 }
4323 dev_kfree_skb(skb); 4323 dev_kfree_skb(skb);
4324 rx_buffer->skb = NULL;
4324 } 4325 }
4325 rx_buffer->skb = NULL;
4326 if (rx_buffer->dma) 4326 if (rx_buffer->dma)
4327 dma_unmap_page(dev, rx_buffer->dma, 4327 dma_unmap_page(dev, rx_buffer->dma,
4328 ixgbe_rx_pg_size(rx_ring), 4328 ixgbe_rx_pg_size(rx_ring),
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 34c137878545..454d9fea640e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -836,8 +836,11 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
836 * whether LSO is used */ 836 * whether LSO is used */
837 tx_desc->ctrl.srcrb_flags = priv->ctrl_flags; 837 tx_desc->ctrl.srcrb_flags = priv->ctrl_flags;
838 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 838 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
839 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | 839 if (!skb->encapsulation)
840 MLX4_WQE_CTRL_TCP_UDP_CSUM); 840 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
841 MLX4_WQE_CTRL_TCP_UDP_CSUM);
842 else
843 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
841 ring->tx_csum++; 844 ring->tx_csum++;
842 } 845 }
843 846
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index a49c9d11d8a5..49290a405903 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1026,6 +1026,7 @@ static void mlx4_free_eq(struct mlx4_dev *dev,
1026 pr_cont("\n"); 1026 pr_cont("\n");
1027 } 1027 }
1028 } 1028 }
1029 synchronize_irq(eq->irq);
1029 1030
1030 mlx4_mtt_cleanup(dev, &eq->mtt); 1031 mlx4_mtt_cleanup(dev, &eq->mtt);
1031 for (i = 0; i < npages; ++i) 1032 for (i = 0; i < npages; ++i)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index ca0f98c95105..872843179f44 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -955,6 +955,10 @@ static void mlx4_err_rule(struct mlx4_dev *dev, char *str,
955 cur->ib.dst_gid_msk); 955 cur->ib.dst_gid_msk);
956 break; 956 break;
957 957
958 case MLX4_NET_TRANS_RULE_ID_VXLAN:
959 len += snprintf(buf + len, BUF_SIZE - len,
960 "VNID = %d ", be32_to_cpu(cur->vxlan.vni));
961 break;
958 case MLX4_NET_TRANS_RULE_ID_IPV6: 962 case MLX4_NET_TRANS_RULE_ID_IPV6:
959 break; 963 break;
960 964
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index ed53291468f3..a278238a2db6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -420,6 +420,7 @@ int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
420 if (err) 420 if (err)
421 mlx5_core_warn(dev, "failed to destroy a previously created eq: eqn %d\n", 421 mlx5_core_warn(dev, "failed to destroy a previously created eq: eqn %d\n",
422 eq->eqn); 422 eq->eqn);
423 synchronize_irq(table->msix_arr[eq->irqn].vector);
423 mlx5_buf_free(dev, &eq->buf); 424 mlx5_buf_free(dev, &eq->buf);
424 425
425 return err; 426 return err;
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index ee84a90e371c..aaf2987512b5 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -343,8 +343,6 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
343 unsigned short dma_flags; 343 unsigned short dma_flags;
344 int i = 0; 344 int i = 0;
345 345
346 EFX_BUG_ON_PARANOID(tx_queue->write_count > tx_queue->insert_count);
347
348 if (skb_shinfo(skb)->gso_size) 346 if (skb_shinfo(skb)->gso_size)
349 return efx_enqueue_skb_tso(tx_queue, skb); 347 return efx_enqueue_skb_tso(tx_queue, skb);
350 348
@@ -1258,8 +1256,6 @@ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
1258 /* Find the packet protocol and sanity-check it */ 1256 /* Find the packet protocol and sanity-check it */
1259 state.protocol = efx_tso_check_protocol(skb); 1257 state.protocol = efx_tso_check_protocol(skb);
1260 1258
1261 EFX_BUG_ON_PARANOID(tx_queue->write_count > tx_queue->insert_count);
1262
1263 rc = tso_start(&state, efx, skb); 1259 rc = tso_start(&state, efx, skb);
1264 if (rc) 1260 if (rc)
1265 goto mem_err; 1261 goto mem_err;
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 5e94d00b96b3..2c62208077fe 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
81#include <linux/workqueue.h> 81#include <linux/workqueue.h>
82#include <linux/of.h> 82#include <linux/of.h>
83#include <linux/of_device.h> 83#include <linux/of_device.h>
84#include <linux/of_gpio.h>
84 85
85#include <linux/netdevice.h> 86#include <linux/netdevice.h>
86#include <linux/etherdevice.h> 87#include <linux/etherdevice.h>
@@ -2188,6 +2189,41 @@ static const struct of_device_id smc91x_match[] = {
2188 {}, 2189 {},
2189}; 2190};
2190MODULE_DEVICE_TABLE(of, smc91x_match); 2191MODULE_DEVICE_TABLE(of, smc91x_match);
2192
2193/**
2194 * of_try_set_control_gpio - configure a gpio if it exists
2195 */
2196static int try_toggle_control_gpio(struct device *dev,
2197 struct gpio_desc **desc,
2198 const char *name, int index,
2199 int value, unsigned int nsdelay)
2200{
2201 struct gpio_desc *gpio = *desc;
2202 int res;
2203
2204 gpio = devm_gpiod_get_index(dev, name, index);
2205 if (IS_ERR(gpio)) {
2206 if (PTR_ERR(gpio) == -ENOENT) {
2207 *desc = NULL;
2208 return 0;
2209 }
2210
2211 return PTR_ERR(gpio);
2212 }
2213 res = gpiod_direction_output(gpio, !value);
2214 if (res) {
2215 dev_err(dev, "unable to toggle gpio %s: %i\n", name, res);
2216 devm_gpiod_put(dev, gpio);
2217 gpio = NULL;
2218 return res;
2219 }
2220 if (nsdelay)
2221 usleep_range(nsdelay, 2 * nsdelay);
2222 gpiod_set_value_cansleep(gpio, value);
2223 *desc = gpio;
2224
2225 return 0;
2226}
2191#endif 2227#endif
2192 2228
2193/* 2229/*
@@ -2237,6 +2273,28 @@ static int smc_drv_probe(struct platform_device *pdev)
2237 struct device_node *np = pdev->dev.of_node; 2273 struct device_node *np = pdev->dev.of_node;
2238 u32 val; 2274 u32 val;
2239 2275
2276 /* Optional pwrdwn GPIO configured? */
2277 ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio,
2278 "power", 0, 0, 100);
2279 if (ret)
2280 return ret;
2281
2282 /*
2283 * Optional reset GPIO configured? Minimum 100 ns reset needed
2284 * according to LAN91C96 datasheet page 14.
2285 */
2286 ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio,
2287 "reset", 0, 0, 100);
2288 if (ret)
2289 return ret;
2290
2291 /*
2292 * Need to wait for optional EEPROM to load, max 750 us according
2293 * to LAN91C96 datasheet page 55.
2294 */
2295 if (lp->reset_gpio)
2296 usleep_range(750, 1000);
2297
2240 /* Combination of IO widths supported, default to 16-bit */ 2298 /* Combination of IO widths supported, default to 16-bit */
2241 if (!of_property_read_u32(np, "reg-io-width", &val)) { 2299 if (!of_property_read_u32(np, "reg-io-width", &val)) {
2242 if (val & 1) 2300 if (val & 1)
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index 47dce918eb0f..2a38dacbbd27 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -298,6 +298,9 @@ struct smc_local {
298 struct sk_buff *pending_tx_skb; 298 struct sk_buff *pending_tx_skb;
299 struct tasklet_struct tx_task; 299 struct tasklet_struct tx_task;
300 300
301 struct gpio_desc *power_gpio;
302 struct gpio_desc *reset_gpio;
303
301 /* version/revision of the SMC91x chip */ 304 /* version/revision of the SMC91x chip */
302 int version; 305 int version;
303 306
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 655a23bbc451..e17a970eaf2b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -33,6 +33,7 @@ static struct stmmac_dma_cfg dma_cfg;
33static void stmmac_default_data(void) 33static void stmmac_default_data(void)
34{ 34{
35 memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data)); 35 memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data));
36
36 plat_dat.bus_id = 1; 37 plat_dat.bus_id = 1;
37 plat_dat.phy_addr = 0; 38 plat_dat.phy_addr = 0;
38 plat_dat.interface = PHY_INTERFACE_MODE_GMII; 39 plat_dat.interface = PHY_INTERFACE_MODE_GMII;
@@ -47,6 +48,12 @@ static void stmmac_default_data(void)
47 dma_cfg.pbl = 32; 48 dma_cfg.pbl = 32;
48 dma_cfg.burst_len = DMA_AXI_BLEN_256; 49 dma_cfg.burst_len = DMA_AXI_BLEN_256;
49 plat_dat.dma_cfg = &dma_cfg; 50 plat_dat.dma_cfg = &dma_cfg;
51
52 /* Set default value for multicast hash bins */
53 plat_dat.multicast_filter_bins = HASH_TABLE_SIZE;
54
55 /* Set default value for unicast filter entries */
56 plat_dat.unicast_filter_entries = 1;
50} 57}
51 58
52/** 59/**
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 952e1e4764b7..d8794488f80a 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -591,8 +591,8 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
591 if (enable) { 591 if (enable) {
592 unsigned long timeout = jiffies + HZ; 592 unsigned long timeout = jiffies + HZ;
593 593
594 /* Disable Learn for all ports */ 594 /* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */
595 for (i = 0; i < priv->data.slaves; i++) { 595 for (i = 0; i <= priv->data.slaves; i++) {
596 cpsw_ale_control_set(ale, i, 596 cpsw_ale_control_set(ale, i,
597 ALE_PORT_NOLEARN, 1); 597 ALE_PORT_NOLEARN, 1);
598 cpsw_ale_control_set(ale, i, 598 cpsw_ale_control_set(ale, i,
@@ -616,11 +616,11 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
616 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1); 616 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1);
617 dev_dbg(&ndev->dev, "promiscuity enabled\n"); 617 dev_dbg(&ndev->dev, "promiscuity enabled\n");
618 } else { 618 } else {
619 /* Flood All Unicast Packets to Host port */ 619 /* Don't Flood All Unicast Packets to Host port */
620 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); 620 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
621 621
622 /* Enable Learn for all ports */ 622 /* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */
623 for (i = 0; i < priv->data.slaves; i++) { 623 for (i = 0; i <= priv->data.slaves; i++) {
624 cpsw_ale_control_set(ale, i, 624 cpsw_ale_control_set(ale, i,
625 ALE_PORT_NOLEARN, 0); 625 ALE_PORT_NOLEARN, 0);
626 cpsw_ale_control_set(ale, i, 626 cpsw_ale_control_set(ale, i,
@@ -638,12 +638,16 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
638 if (ndev->flags & IFF_PROMISC) { 638 if (ndev->flags & IFF_PROMISC) {
639 /* Enable promiscuous mode */ 639 /* Enable promiscuous mode */
640 cpsw_set_promiscious(ndev, true); 640 cpsw_set_promiscious(ndev, true);
641 cpsw_ale_set_allmulti(priv->ale, IFF_ALLMULTI);
641 return; 642 return;
642 } else { 643 } else {
643 /* Disable promiscuous mode */ 644 /* Disable promiscuous mode */
644 cpsw_set_promiscious(ndev, false); 645 cpsw_set_promiscious(ndev, false);
645 } 646 }
646 647
648 /* Restore allmulti on vlans if necessary */
649 cpsw_ale_set_allmulti(priv->ale, priv->ndev->flags & IFF_ALLMULTI);
650
647 /* Clear all mcast from ALE */ 651 /* Clear all mcast from ALE */
648 cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port); 652 cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port);
649 653
@@ -1149,6 +1153,7 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
1149 const int port = priv->host_port; 1153 const int port = priv->host_port;
1150 u32 reg; 1154 u32 reg;
1151 int i; 1155 int i;
1156 int unreg_mcast_mask;
1152 1157
1153 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : 1158 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
1154 CPSW2_PORT_VLAN; 1159 CPSW2_PORT_VLAN;
@@ -1158,9 +1163,14 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
1158 for (i = 0; i < priv->data.slaves; i++) 1163 for (i = 0; i < priv->data.slaves; i++)
1159 slave_write(priv->slaves + i, vlan, reg); 1164 slave_write(priv->slaves + i, vlan, reg);
1160 1165
1166 if (priv->ndev->flags & IFF_ALLMULTI)
1167 unreg_mcast_mask = ALE_ALL_PORTS;
1168 else
1169 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
1170
1161 cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port, 1171 cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
1162 ALE_ALL_PORTS << port, ALE_ALL_PORTS << port, 1172 ALE_ALL_PORTS << port, ALE_ALL_PORTS << port,
1163 (ALE_PORT_1 | ALE_PORT_2) << port); 1173 unreg_mcast_mask << port);
1164} 1174}
1165 1175
1166static void cpsw_init_host_port(struct cpsw_priv *priv) 1176static void cpsw_init_host_port(struct cpsw_priv *priv)
@@ -1620,11 +1630,17 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
1620 unsigned short vid) 1630 unsigned short vid)
1621{ 1631{
1622 int ret; 1632 int ret;
1633 int unreg_mcast_mask;
1634
1635 if (priv->ndev->flags & IFF_ALLMULTI)
1636 unreg_mcast_mask = ALE_ALL_PORTS;
1637 else
1638 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
1623 1639
1624 ret = cpsw_ale_add_vlan(priv->ale, vid, 1640 ret = cpsw_ale_add_vlan(priv->ale, vid,
1625 ALE_ALL_PORTS << priv->host_port, 1641 ALE_ALL_PORTS << priv->host_port,
1626 0, ALE_ALL_PORTS << priv->host_port, 1642 0, ALE_ALL_PORTS << priv->host_port,
1627 (ALE_PORT_1 | ALE_PORT_2) << priv->host_port); 1643 unreg_mcast_mask << priv->host_port);
1628 if (ret != 0) 1644 if (ret != 0)
1629 return ret; 1645 return ret;
1630 1646
@@ -2006,7 +2022,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2006 parp = of_get_property(slave_node, "phy_id", &lenp); 2022 parp = of_get_property(slave_node, "phy_id", &lenp);
2007 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 2023 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
2008 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); 2024 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
2009 return -EINVAL; 2025 goto no_phy_slave;
2010 } 2026 }
2011 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 2027 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
2012 phyid = be32_to_cpup(parp+1); 2028 phyid = be32_to_cpup(parp+1);
@@ -2019,6 +2035,14 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2019 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 2035 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
2020 PHY_ID_FMT, mdio->name, phyid); 2036 PHY_ID_FMT, mdio->name, phyid);
2021 2037
2038 slave_data->phy_if = of_get_phy_mode(slave_node);
2039 if (slave_data->phy_if < 0) {
2040 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
2041 i);
2042 return slave_data->phy_if;
2043 }
2044
2045no_phy_slave:
2022 mac_addr = of_get_mac_address(slave_node); 2046 mac_addr = of_get_mac_address(slave_node);
2023 if (mac_addr) { 2047 if (mac_addr) {
2024 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); 2048 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
@@ -2030,14 +2054,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2030 return ret; 2054 return ret;
2031 } 2055 }
2032 } 2056 }
2033
2034 slave_data->phy_if = of_get_phy_mode(slave_node);
2035 if (slave_data->phy_if < 0) {
2036 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
2037 i);
2038 return slave_data->phy_if;
2039 }
2040
2041 if (data->dual_emac) { 2057 if (data->dual_emac) {
2042 if (of_property_read_u32(slave_node, "dual_emac_res_vlan", 2058 if (of_property_read_u32(slave_node, "dual_emac_res_vlan",
2043 &prop)) { 2059 &prop)) {
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 0579b2243bb6..3ae83879a75f 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -443,6 +443,35 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
443 return 0; 443 return 0;
444} 444}
445 445
446void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti)
447{
448 u32 ale_entry[ALE_ENTRY_WORDS];
449 int type, idx;
450 int unreg_mcast = 0;
451
452 /* Only bother doing the work if the setting is actually changing */
453 if (ale->allmulti == allmulti)
454 return;
455
456 /* Remember the new setting to check against next time */
457 ale->allmulti = allmulti;
458
459 for (idx = 0; idx < ale->params.ale_entries; idx++) {
460 cpsw_ale_read(ale, idx, ale_entry);
461 type = cpsw_ale_get_entry_type(ale_entry);
462 if (type != ALE_TYPE_VLAN)
463 continue;
464
465 unreg_mcast = cpsw_ale_get_vlan_unreg_mcast(ale_entry);
466 if (allmulti)
467 unreg_mcast |= 1;
468 else
469 unreg_mcast &= ~1;
470 cpsw_ale_set_vlan_unreg_mcast(ale_entry, unreg_mcast);
471 cpsw_ale_write(ale, idx, ale_entry);
472 }
473}
474
446struct ale_control_info { 475struct ale_control_info {
447 const char *name; 476 const char *name;
448 int offset, port_offset; 477 int offset, port_offset;
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index 31cf43cab42e..c0d4127aa549 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -27,6 +27,7 @@ struct cpsw_ale {
27 struct cpsw_ale_params params; 27 struct cpsw_ale_params params;
28 struct timer_list timer; 28 struct timer_list timer;
29 unsigned long ageout; 29 unsigned long ageout;
30 int allmulti;
30}; 31};
31 32
32enum cpsw_ale_control { 33enum cpsw_ale_control {
@@ -103,6 +104,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
103int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag, 104int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
104 int reg_mcast, int unreg_mcast); 105 int reg_mcast, int unreg_mcast);
105int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port); 106int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
107void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti);
106 108
107int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); 109int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
108int cpsw_ale_control_set(struct cpsw_ale *ale, int port, 110int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9e17d1a91e71..78ec33f5100b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -550,6 +550,7 @@ do_lso:
550do_send: 550do_send:
551 /* Start filling in the page buffers with the rndis hdr */ 551 /* Start filling in the page buffers with the rndis hdr */
552 rndis_msg->msg_len += rndis_msg_size; 552 rndis_msg->msg_len += rndis_msg_size;
553 packet->total_data_buflen = rndis_msg->msg_len;
553 packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size, 554 packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
554 skb, &packet->page_buf[0]); 555 skb, &packet->page_buf[0]);
555 556
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 29b3bb410781..bfb0b6ec8c56 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -272,7 +272,7 @@ static void macvlan_process_broadcast(struct work_struct *w)
272 struct sk_buff *skb; 272 struct sk_buff *skb;
273 struct sk_buff_head list; 273 struct sk_buff_head list;
274 274
275 skb_queue_head_init(&list); 275 __skb_queue_head_init(&list);
276 276
277 spin_lock_bh(&port->bc_queue.lock); 277 spin_lock_bh(&port->bc_queue.lock);
278 skb_queue_splice_tail_init(&port->bc_queue, &list); 278 skb_queue_splice_tail_init(&port->bc_queue, &list);
@@ -1082,9 +1082,15 @@ static void macvlan_port_destroy(struct net_device *dev)
1082{ 1082{
1083 struct macvlan_port *port = macvlan_port_get_rtnl(dev); 1083 struct macvlan_port *port = macvlan_port_get_rtnl(dev);
1084 1084
1085 cancel_work_sync(&port->bc_work);
1086 dev->priv_flags &= ~IFF_MACVLAN_PORT; 1085 dev->priv_flags &= ~IFF_MACVLAN_PORT;
1087 netdev_rx_handler_unregister(dev); 1086 netdev_rx_handler_unregister(dev);
1087
1088 /* After this point, no packet can schedule bc_work anymore,
1089 * but we need to cancel it and purge left skbs if any.
1090 */
1091 cancel_work_sync(&port->bc_work);
1092 __skb_queue_purge(&port->bc_queue);
1093
1088 kfree_rcu(port, rcu); 1094 kfree_rcu(port, rcu);
1089} 1095}
1090 1096
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 65e2892342bd..6f226de655a4 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -16,6 +16,7 @@
16#include <linux/idr.h> 16#include <linux/idr.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18 18
19#include <net/ipv6.h>
19#include <net/net_namespace.h> 20#include <net/net_namespace.h>
20#include <net/rtnetlink.h> 21#include <net/rtnetlink.h>
21#include <net/sock.h> 22#include <net/sock.h>
@@ -65,7 +66,7 @@ static struct cdev macvtap_cdev;
65static const struct proto_ops macvtap_socket_ops; 66static const struct proto_ops macvtap_socket_ops;
66 67
67#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \ 68#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
68 NETIF_F_TSO6 | NETIF_F_UFO) 69 NETIF_F_TSO6)
69#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO) 70#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
70#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG) 71#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
71 72
@@ -569,7 +570,11 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
569 gso_type = SKB_GSO_TCPV6; 570 gso_type = SKB_GSO_TCPV6;
570 break; 571 break;
571 case VIRTIO_NET_HDR_GSO_UDP: 572 case VIRTIO_NET_HDR_GSO_UDP:
573 pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
574 current->comm);
572 gso_type = SKB_GSO_UDP; 575 gso_type = SKB_GSO_UDP;
576 if (skb->protocol == htons(ETH_P_IPV6))
577 ipv6_proxy_select_ident(skb);
573 break; 578 break;
574 default: 579 default:
575 return -EINVAL; 580 return -EINVAL;
@@ -614,8 +619,6 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
614 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 619 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
615 else if (sinfo->gso_type & SKB_GSO_TCPV6) 620 else if (sinfo->gso_type & SKB_GSO_TCPV6)
616 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 621 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
617 else if (sinfo->gso_type & SKB_GSO_UDP)
618 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
619 else 622 else
620 BUG(); 623 BUG();
621 if (sinfo->gso_type & SKB_GSO_TCP_ECN) 624 if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -950,9 +953,6 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
950 if (arg & TUN_F_TSO6) 953 if (arg & TUN_F_TSO6)
951 feature_mask |= NETIF_F_TSO6; 954 feature_mask |= NETIF_F_TSO6;
952 } 955 }
953
954 if (arg & TUN_F_UFO)
955 feature_mask |= NETIF_F_UFO;
956 } 956 }
957 957
958 /* tun/tap driver inverts the usage for TSO offloads, where 958 /* tun/tap driver inverts the usage for TSO offloads, where
@@ -963,7 +963,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
963 * When user space turns off TSO, we turn off GSO/LRO so that 963 * When user space turns off TSO, we turn off GSO/LRO so that
964 * user-space will not receive TSO frames. 964 * user-space will not receive TSO frames.
965 */ 965 */
966 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) 966 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
967 features |= RX_OFFLOADS; 967 features |= RX_OFFLOADS;
968 else 968 else
969 features &= ~RX_OFFLOADS; 969 features &= ~RX_OFFLOADS;
@@ -1064,7 +1064,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
1064 case TUNSETOFFLOAD: 1064 case TUNSETOFFLOAD:
1065 /* let the user check for future flags */ 1065 /* let the user check for future flags */
1066 if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 | 1066 if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
1067 TUN_F_TSO_ECN | TUN_F_UFO)) 1067 TUN_F_TSO_ECN))
1068 return -EINVAL; 1068 return -EINVAL;
1069 1069
1070 rtnl_lock(); 1070 rtnl_lock();
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45c89c0..225c033b08f3 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,10 +50,15 @@
50#define MII_M1011_PHY_SCR 0x10 50#define MII_M1011_PHY_SCR 0x10
51#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060 51#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
52 52
53#define MII_M1145_PHY_EXT_SR 0x1b
53#define MII_M1145_PHY_EXT_CR 0x14 54#define MII_M1145_PHY_EXT_CR 0x14
54#define MII_M1145_RGMII_RX_DELAY 0x0080 55#define MII_M1145_RGMII_RX_DELAY 0x0080
55#define MII_M1145_RGMII_TX_DELAY 0x0002 56#define MII_M1145_RGMII_TX_DELAY 0x0002
56 57
58#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
59#define MII_M1145_HWCFG_MODE_MASK 0xf
60#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
61
57#define MII_M1111_PHY_LED_CONTROL 0x18 62#define MII_M1111_PHY_LED_CONTROL 0x18
58#define MII_M1111_PHY_LED_DIRECT 0x4100 63#define MII_M1111_PHY_LED_DIRECT 0x4100
59#define MII_M1111_PHY_LED_COMBINE 0x411c 64#define MII_M1111_PHY_LED_COMBINE 0x411c
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
676 } 681 }
677 } 682 }
678 683
684 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
685 int temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
686 if (temp < 0)
687 return temp;
688
689 temp &= ~MII_M1145_HWCFG_MODE_MASK;
690 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
691 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
692
693 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
694 if (err < 0)
695 return err;
696 }
697
679 err = marvell_of_reg_init(phydev); 698 err = marvell_of_reg_init(phydev);
680 if (err < 0) 699 if (err < 0)
681 return err; 700 return err;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 186ce541c657..7302398f0b1f 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -65,6 +65,7 @@
65#include <linux/nsproxy.h> 65#include <linux/nsproxy.h>
66#include <linux/virtio_net.h> 66#include <linux/virtio_net.h>
67#include <linux/rcupdate.h> 67#include <linux/rcupdate.h>
68#include <net/ipv6.h>
68#include <net/net_namespace.h> 69#include <net/net_namespace.h>
69#include <net/netns/generic.h> 70#include <net/netns/generic.h>
70#include <net/rtnetlink.h> 71#include <net/rtnetlink.h>
@@ -174,7 +175,7 @@ struct tun_struct {
174 struct net_device *dev; 175 struct net_device *dev;
175 netdev_features_t set_features; 176 netdev_features_t set_features;
176#define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \ 177#define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
177 NETIF_F_TSO6|NETIF_F_UFO) 178 NETIF_F_TSO6)
178 179
179 int vnet_hdr_sz; 180 int vnet_hdr_sz;
180 int sndbuf; 181 int sndbuf;
@@ -1139,6 +1140,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1139 break; 1140 break;
1140 } 1141 }
1141 1142
1143 skb_reset_network_header(skb);
1144
1142 if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) { 1145 if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
1143 pr_debug("GSO!\n"); 1146 pr_debug("GSO!\n");
1144 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { 1147 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
@@ -1149,8 +1152,20 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1149 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; 1152 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
1150 break; 1153 break;
1151 case VIRTIO_NET_HDR_GSO_UDP: 1154 case VIRTIO_NET_HDR_GSO_UDP:
1155 {
1156 static bool warned;
1157
1158 if (!warned) {
1159 warned = true;
1160 netdev_warn(tun->dev,
1161 "%s: using disabled UFO feature; please fix this program\n",
1162 current->comm);
1163 }
1152 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 1164 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
1165 if (skb->protocol == htons(ETH_P_IPV6))
1166 ipv6_proxy_select_ident(skb);
1153 break; 1167 break;
1168 }
1154 default: 1169 default:
1155 tun->dev->stats.rx_frame_errors++; 1170 tun->dev->stats.rx_frame_errors++;
1156 kfree_skb(skb); 1171 kfree_skb(skb);
@@ -1179,7 +1194,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1179 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; 1194 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
1180 } 1195 }
1181 1196
1182 skb_reset_network_header(skb);
1183 skb_probe_transport_header(skb, 0); 1197 skb_probe_transport_header(skb, 0);
1184 1198
1185 rxhash = skb_get_hash(skb); 1199 rxhash = skb_get_hash(skb);
@@ -1251,8 +1265,6 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1251 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 1265 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
1252 else if (sinfo->gso_type & SKB_GSO_TCPV6) 1266 else if (sinfo->gso_type & SKB_GSO_TCPV6)
1253 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 1267 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
1254 else if (sinfo->gso_type & SKB_GSO_UDP)
1255 gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
1256 else { 1268 else {
1257 pr_err("unexpected GSO type: " 1269 pr_err("unexpected GSO type: "
1258 "0x%x, gso_size %d, hdr_len %d\n", 1270 "0x%x, gso_size %d, hdr_len %d\n",
@@ -1762,11 +1774,6 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
1762 features |= NETIF_F_TSO6; 1774 features |= NETIF_F_TSO6;
1763 arg &= ~(TUN_F_TSO4|TUN_F_TSO6); 1775 arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
1764 } 1776 }
1765
1766 if (arg & TUN_F_UFO) {
1767 features |= NETIF_F_UFO;
1768 arg &= ~TUN_F_UFO;
1769 }
1770 } 1777 }
1771 1778
1772 /* This gives the user a way to test for new features in future by 1779 /* This gives the user a way to test for new features in future by
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index be4275721039..e6338c16081a 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -937,6 +937,7 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
937{ 937{
938 struct usbnet *dev = netdev_priv(net); 938 struct usbnet *dev = netdev_priv(net);
939 struct sockaddr *addr = p; 939 struct sockaddr *addr = p;
940 int ret;
940 941
941 if (netif_running(net)) 942 if (netif_running(net))
942 return -EBUSY; 943 return -EBUSY;
@@ -946,8 +947,12 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
946 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); 947 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
947 948
948 /* Set the MAC address */ 949 /* Set the MAC address */
949 return ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 950 ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
950 ETH_ALEN, net->dev_addr); 951 ETH_ALEN, net->dev_addr);
952 if (ret < 0)
953 return ret;
954
955 return 0;
951} 956}
952 957
953static const struct net_device_ops ax88179_netdev_ops = { 958static const struct net_device_ops ax88179_netdev_ops = {
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 2a32d9167d3b..d3920b54a92c 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -67,6 +67,35 @@ static const u8 mbm_guid[16] = {
67 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, 67 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
68}; 68};
69 69
70static void usbnet_cdc_update_filter(struct usbnet *dev)
71{
72 struct cdc_state *info = (void *) &dev->data;
73 struct usb_interface *intf = info->control;
74
75 u16 cdc_filter =
76 USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED |
77 USB_CDC_PACKET_TYPE_BROADCAST;
78
79 if (dev->net->flags & IFF_PROMISC)
80 cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
81
82 /* FIXME cdc-ether has some multicast code too, though it complains
83 * in routine cases. info->ether describes the multicast support.
84 * Implement that here, manipulating the cdc filter as needed.
85 */
86
87 usb_control_msg(dev->udev,
88 usb_sndctrlpipe(dev->udev, 0),
89 USB_CDC_SET_ETHERNET_PACKET_FILTER,
90 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
91 cdc_filter,
92 intf->cur_altsetting->desc.bInterfaceNumber,
93 NULL,
94 0,
95 USB_CTRL_SET_TIMEOUT
96 );
97}
98
70/* probes control interface, claims data interface, collects the bulk 99/* probes control interface, claims data interface, collects the bulk
71 * endpoints, activates data interface (if needed), maybe sets MTU. 100 * endpoints, activates data interface (if needed), maybe sets MTU.
72 * all pure cdc, except for certain firmware workarounds, and knowing 101 * all pure cdc, except for certain firmware workarounds, and knowing
@@ -347,16 +376,8 @@ next_desc:
347 * don't do reset all the way. So the packet filter should 376 * don't do reset all the way. So the packet filter should
348 * be set to a sane initial value. 377 * be set to a sane initial value.
349 */ 378 */
350 usb_control_msg(dev->udev, 379 usbnet_cdc_update_filter(dev);
351 usb_sndctrlpipe(dev->udev, 0), 380
352 USB_CDC_SET_ETHERNET_PACKET_FILTER,
353 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
354 USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED | USB_CDC_PACKET_TYPE_BROADCAST,
355 intf->cur_altsetting->desc.bInterfaceNumber,
356 NULL,
357 0,
358 USB_CTRL_SET_TIMEOUT
359 );
360 return 0; 381 return 0;
361 382
362bad_desc: 383bad_desc:
@@ -468,10 +489,6 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
468 return status; 489 return status;
469 } 490 }
470 491
471 /* FIXME cdc-ether has some multicast code too, though it complains
472 * in routine cases. info->ether describes the multicast support.
473 * Implement that here, manipulating the cdc filter as needed.
474 */
475 return 0; 492 return 0;
476} 493}
477EXPORT_SYMBOL_GPL(usbnet_cdc_bind); 494EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
@@ -482,6 +499,7 @@ static const struct driver_info cdc_info = {
482 .bind = usbnet_cdc_bind, 499 .bind = usbnet_cdc_bind,
483 .unbind = usbnet_cdc_unbind, 500 .unbind = usbnet_cdc_unbind,
484 .status = usbnet_cdc_status, 501 .status = usbnet_cdc_status,
502 .set_rx_mode = usbnet_cdc_update_filter,
485 .manage_power = usbnet_manage_power, 503 .manage_power = usbnet_manage_power,
486}; 504};
487 505
@@ -491,6 +509,7 @@ static const struct driver_info wwan_info = {
491 .bind = usbnet_cdc_bind, 509 .bind = usbnet_cdc_bind,
492 .unbind = usbnet_cdc_unbind, 510 .unbind = usbnet_cdc_unbind,
493 .status = usbnet_cdc_status, 511 .status = usbnet_cdc_status,
512 .set_rx_mode = usbnet_cdc_update_filter,
494 .manage_power = usbnet_manage_power, 513 .manage_power = usbnet_manage_power,
495}; 514};
496 515
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e3d84c322e4e..c6554c7a8147 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1162,6 +1162,9 @@ static void intr_callback(struct urb *urb)
1162 case -ESHUTDOWN: 1162 case -ESHUTDOWN:
1163 netif_device_detach(tp->netdev); 1163 netif_device_detach(tp->netdev);
1164 case -ENOENT: 1164 case -ENOENT:
1165 case -EPROTO:
1166 netif_info(tp, intr, tp->netdev,
1167 "Stop submitting intr, status %d\n", status);
1165 return; 1168 return;
1166 case -EOVERFLOW: 1169 case -EOVERFLOW:
1167 netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n"); 1170 netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n");
@@ -2891,6 +2894,9 @@ static int rtl8152_open(struct net_device *netdev)
2891 if (res) 2894 if (res)
2892 goto out; 2895 goto out;
2893 2896
2897 /* set speed to 0 to avoid autoresume try to submit rx */
2898 tp->speed = 0;
2899
2894 res = usb_autopm_get_interface(tp->intf); 2900 res = usb_autopm_get_interface(tp->intf);
2895 if (res < 0) { 2901 if (res < 0) {
2896 free_all_mem(tp); 2902 free_all_mem(tp);
@@ -2904,6 +2910,8 @@ static int rtl8152_open(struct net_device *netdev)
2904 clear_bit(WORK_ENABLE, &tp->flags); 2910 clear_bit(WORK_ENABLE, &tp->flags);
2905 usb_kill_urb(tp->intr_urb); 2911 usb_kill_urb(tp->intr_urb);
2906 cancel_delayed_work_sync(&tp->schedule); 2912 cancel_delayed_work_sync(&tp->schedule);
2913
2914 /* disable the tx/rx, if the workqueue has enabled them. */
2907 if (tp->speed & LINK_STATUS) 2915 if (tp->speed & LINK_STATUS)
2908 tp->rtl_ops.disable(tp); 2916 tp->rtl_ops.disable(tp);
2909 } 2917 }
@@ -2955,10 +2963,7 @@ static int rtl8152_close(struct net_device *netdev)
2955 * be disable when autoresume occurs, because the 2963 * be disable when autoresume occurs, because the
2956 * netif_running() would be false. 2964 * netif_running() would be false.
2957 */ 2965 */
2958 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 2966 rtl_runtime_suspend_enable(tp, false);
2959 rtl_runtime_suspend_enable(tp, false);
2960 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
2961 }
2962 2967
2963 tasklet_disable(&tp->tl); 2968 tasklet_disable(&tp->tl);
2964 tp->rtl_ops.down(tp); 2969 tp->rtl_ops.down(tp);
@@ -3205,7 +3210,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3205 netif_device_detach(netdev); 3210 netif_device_detach(netdev);
3206 } 3211 }
3207 3212
3208 if (netif_running(netdev)) { 3213 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3209 clear_bit(WORK_ENABLE, &tp->flags); 3214 clear_bit(WORK_ENABLE, &tp->flags);
3210 usb_kill_urb(tp->intr_urb); 3215 usb_kill_urb(tp->intr_urb);
3211 tasklet_disable(&tp->tl); 3216 tasklet_disable(&tp->tl);
@@ -3253,6 +3258,8 @@ static int rtl8152_resume(struct usb_interface *intf)
3253 set_bit(WORK_ENABLE, &tp->flags); 3258 set_bit(WORK_ENABLE, &tp->flags);
3254 } 3259 }
3255 usb_submit_urb(tp->intr_urb, GFP_KERNEL); 3260 usb_submit_urb(tp->intr_urb, GFP_KERNEL);
3261 } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3262 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3256 } 3263 }
3257 3264
3258 mutex_unlock(&tp->control); 3265 mutex_unlock(&tp->control);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 20615bbd693b..3a6770a65d78 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1052,6 +1052,21 @@ static void __handle_link_change(struct usbnet *dev)
1052 clear_bit(EVENT_LINK_CHANGE, &dev->flags); 1052 clear_bit(EVENT_LINK_CHANGE, &dev->flags);
1053} 1053}
1054 1054
1055static void usbnet_set_rx_mode(struct net_device *net)
1056{
1057 struct usbnet *dev = netdev_priv(net);
1058
1059 usbnet_defer_kevent(dev, EVENT_SET_RX_MODE);
1060}
1061
1062static void __handle_set_rx_mode(struct usbnet *dev)
1063{
1064 if (dev->driver_info->set_rx_mode)
1065 (dev->driver_info->set_rx_mode)(dev);
1066
1067 clear_bit(EVENT_SET_RX_MODE, &dev->flags);
1068}
1069
1055/* work that cannot be done in interrupt context uses keventd. 1070/* work that cannot be done in interrupt context uses keventd.
1056 * 1071 *
1057 * NOTE: with 2.5 we could do more of this using completion callbacks, 1072 * NOTE: with 2.5 we could do more of this using completion callbacks,
@@ -1157,6 +1172,10 @@ skip_reset:
1157 if (test_bit (EVENT_LINK_CHANGE, &dev->flags)) 1172 if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
1158 __handle_link_change(dev); 1173 __handle_link_change(dev);
1159 1174
1175 if (test_bit (EVENT_SET_RX_MODE, &dev->flags))
1176 __handle_set_rx_mode(dev);
1177
1178
1160 if (dev->flags) 1179 if (dev->flags)
1161 netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags); 1180 netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
1162} 1181}
@@ -1525,6 +1544,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
1525 .ndo_stop = usbnet_stop, 1544 .ndo_stop = usbnet_stop,
1526 .ndo_start_xmit = usbnet_start_xmit, 1545 .ndo_start_xmit = usbnet_start_xmit,
1527 .ndo_tx_timeout = usbnet_tx_timeout, 1546 .ndo_tx_timeout = usbnet_tx_timeout,
1547 .ndo_set_rx_mode = usbnet_set_rx_mode,
1528 .ndo_change_mtu = usbnet_change_mtu, 1548 .ndo_change_mtu = usbnet_change_mtu,
1529 .ndo_set_mac_address = eth_mac_addr, 1549 .ndo_set_mac_address = eth_mac_addr,
1530 .ndo_validate_addr = eth_validate_addr, 1550 .ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d75256bd1a6a..ec2a8b41ed41 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -491,8 +491,17 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
491 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; 491 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
492 break; 492 break;
493 case VIRTIO_NET_HDR_GSO_UDP: 493 case VIRTIO_NET_HDR_GSO_UDP:
494 {
495 static bool warned;
496
497 if (!warned) {
498 warned = true;
499 netdev_warn(dev,
500 "host using disabled UFO feature; please fix it\n");
501 }
494 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 502 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
495 break; 503 break;
504 }
496 case VIRTIO_NET_HDR_GSO_TCPV6: 505 case VIRTIO_NET_HDR_GSO_TCPV6:
497 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; 506 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
498 break; 507 break;
@@ -881,8 +890,6 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
881 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 890 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
882 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) 891 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
883 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 892 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
884 else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
885 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
886 else 893 else
887 BUG(); 894 BUG();
888 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN) 895 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1705,7 +1712,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1705 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; 1712 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1706 1713
1707 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { 1714 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
1708 dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO 1715 dev->hw_features |= NETIF_F_TSO
1709 | NETIF_F_TSO_ECN | NETIF_F_TSO6; 1716 | NETIF_F_TSO_ECN | NETIF_F_TSO6;
1710 } 1717 }
1711 /* Individual feature bits: what can host handle? */ 1718 /* Individual feature bits: what can host handle? */
@@ -1715,11 +1722,9 @@ static int virtnet_probe(struct virtio_device *vdev)
1715 dev->hw_features |= NETIF_F_TSO6; 1722 dev->hw_features |= NETIF_F_TSO6;
1716 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN)) 1723 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
1717 dev->hw_features |= NETIF_F_TSO_ECN; 1724 dev->hw_features |= NETIF_F_TSO_ECN;
1718 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
1719 dev->hw_features |= NETIF_F_UFO;
1720 1725
1721 if (gso) 1726 if (gso)
1722 dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO); 1727 dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
1723 /* (!csum && gso) case will be fixed by register_netdev() */ 1728 /* (!csum && gso) case will be fixed by register_netdev() */
1724 } 1729 }
1725 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM)) 1730 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1757,8 +1762,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1757 /* If we can receive ANY GSO packets, we must allocate large ones. */ 1762 /* If we can receive ANY GSO packets, we must allocate large ones. */
1758 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || 1763 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
1759 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) || 1764 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
1760 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) || 1765 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
1761 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
1762 vi->big_packets = true; 1766 vi->big_packets = true;
1763 1767
1764 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) 1768 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1952,9 +1956,9 @@ static struct virtio_device_id id_table[] = {
1952static unsigned int features[] = { 1956static unsigned int features[] = {
1953 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, 1957 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
1954 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, 1958 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
1955 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, 1959 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
1956 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, 1960 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
1957 VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, 1961 VIRTIO_NET_F_GUEST_ECN,
1958 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, 1962 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
1959 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, 1963 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
1960 VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, 1964 VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index e5ba6faf3281..86907e5ba6ca 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -80,6 +80,7 @@ struct reg_dmn_pair_mapping {
80 80
81struct ath_regulatory { 81struct ath_regulatory {
82 char alpha2[2]; 82 char alpha2[2];
83 enum nl80211_dfs_regions region;
83 u16 country_code; 84 u16 country_code;
84 u16 max_power_level; 85 u16 max_power_level;
85 u16 current_rd; 86 u16 current_rd;
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index c6dd7f1fed65..33b0c7aef2ea 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -368,11 +368,11 @@ void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
368{ 368{
369 struct ath_regulatory *reg = ath9k_hw_regulatory(ah); 369 struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
370 370
371 if (reg->power_limit != new_txpow) { 371 if (reg->power_limit != new_txpow)
372 ath9k_hw_set_txpowerlimit(ah, new_txpow, false); 372 ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
373 /* read back in case value is clamped */ 373
374 *txpower = reg->max_power_level; 374 /* read back in case value is clamped */
375 } 375 *txpower = reg->max_power_level;
376} 376}
377EXPORT_SYMBOL(ath9k_cmn_update_txpow); 377EXPORT_SYMBOL(ath9k_cmn_update_txpow);
378 378
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 46f20a309b5f..5c45e787814e 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -455,7 +455,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
455 "%2d %2x %1x %2x %2x\n", 455 "%2d %2x %1x %2x %2x\n",
456 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 456 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
457 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 457 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
458 val[2] & (0x7 << (i * 3)) >> (i * 3), 458 (val[2] & (0x7 << (i * 3))) >> (i * 3),
459 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 459 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
460 } 460 }
461 461
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 156a944134dc..3bd030494986 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -734,6 +734,32 @@ static const struct ieee80211_iface_combination if_comb[] = {
734#endif 734#endif
735}; 735};
736 736
737#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
738static void ath9k_set_mcc_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
739{
740 struct ath_hw *ah = sc->sc_ah;
741 struct ath_common *common = ath9k_hw_common(ah);
742
743 if (!ath9k_is_chanctx_enabled())
744 return;
745
746 hw->flags |= IEEE80211_HW_QUEUE_CONTROL;
747 hw->queues = ATH9K_NUM_TX_QUEUES;
748 hw->offchannel_tx_hw_queue = hw->queues - 1;
749 hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
750 hw->wiphy->iface_combinations = if_comb_multi;
751 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
752 hw->wiphy->max_scan_ssids = 255;
753 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
754 hw->wiphy->max_remain_on_channel_duration = 10000;
755 hw->chanctx_data_size = sizeof(void *);
756 hw->extra_beacon_tailroom =
757 sizeof(struct ieee80211_p2p_noa_attr) + 9;
758
759 ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
760}
761#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
762
737static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) 763static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
738{ 764{
739 struct ath_hw *ah = sc->sc_ah; 765 struct ath_hw *ah = sc->sc_ah;
@@ -746,7 +772,6 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
746 IEEE80211_HW_SPECTRUM_MGMT | 772 IEEE80211_HW_SPECTRUM_MGMT |
747 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 773 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
748 IEEE80211_HW_SUPPORTS_RC_TABLE | 774 IEEE80211_HW_SUPPORTS_RC_TABLE |
749 IEEE80211_HW_QUEUE_CONTROL |
750 IEEE80211_HW_SUPPORTS_HT_CCK_RATES; 775 IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
751 776
752 if (ath9k_ps_enable) 777 if (ath9k_ps_enable)
@@ -781,24 +806,6 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
781 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); 806 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
782 } 807 }
783 808
784#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
785
786 if (ath9k_is_chanctx_enabled()) {
787 hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
788 hw->wiphy->iface_combinations = if_comb_multi;
789 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
790 hw->wiphy->max_scan_ssids = 255;
791 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
792 hw->wiphy->max_remain_on_channel_duration = 10000;
793 hw->chanctx_data_size = sizeof(void *);
794 hw->extra_beacon_tailroom =
795 sizeof(struct ieee80211_p2p_noa_attr) + 9;
796
797 ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
798 }
799
800#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
801
802 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 809 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
803 810
804 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 811 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
@@ -808,12 +815,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
808 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; 815 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
809 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 816 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
810 817
811 /* allow 4 queues per channel context + 818 hw->queues = 4;
812 * 1 cab queue + 1 offchannel tx queue
813 */
814 hw->queues = ATH9K_NUM_TX_QUEUES;
815 /* last queue for offchannel */
816 hw->offchannel_tx_hw_queue = hw->queues - 1;
817 hw->max_rates = 4; 819 hw->max_rates = 4;
818 hw->max_listen_interval = 10; 820 hw->max_listen_interval = 10;
819 hw->max_rate_tries = 10; 821 hw->max_rate_tries = 10;
@@ -837,6 +839,9 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
837 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 839 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
838 &common->sbands[IEEE80211_BAND_5GHZ]; 840 &common->sbands[IEEE80211_BAND_5GHZ];
839 841
842#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
843 ath9k_set_mcc_capab(sc, hw);
844#endif
840 ath9k_init_wow(hw); 845 ath9k_init_wow(hw);
841 ath9k_cmn_reload_chainmask(ah); 846 ath9k_cmn_reload_chainmask(ah);
842 847
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 6f6a974f7fdb..30c66dfcd7a0 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1162,6 +1162,9 @@ static void ath9k_assign_hw_queues(struct ieee80211_hw *hw,
1162{ 1162{
1163 int i; 1163 int i;
1164 1164
1165 if (!ath9k_is_chanctx_enabled())
1166 return;
1167
1165 for (i = 0; i < IEEE80211_NUM_ACS; i++) 1168 for (i = 0; i < IEEE80211_NUM_ACS; i++)
1166 vif->hw_queue[i] = i; 1169 vif->hw_queue[i] = i;
1167 1170
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 493a183d0aaf..d6e54a3c88f6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -169,7 +169,10 @@ static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
169 169
170 if (txq->stopped && 170 if (txq->stopped &&
171 txq->pending_frames < sc->tx.txq_max_pending[q]) { 171 txq->pending_frames < sc->tx.txq_max_pending[q]) {
172 ieee80211_wake_queue(sc->hw, info->hw_queue); 172 if (ath9k_is_chanctx_enabled())
173 ieee80211_wake_queue(sc->hw, info->hw_queue);
174 else
175 ieee80211_wake_queue(sc->hw, q);
173 txq->stopped = false; 176 txq->stopped = false;
174 } 177 }
175} 178}
@@ -2247,7 +2250,10 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
2247 fi->txq = q; 2250 fi->txq = q;
2248 if (++txq->pending_frames > sc->tx.txq_max_pending[q] && 2251 if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
2249 !txq->stopped) { 2252 !txq->stopped) {
2250 ieee80211_stop_queue(sc->hw, info->hw_queue); 2253 if (ath9k_is_chanctx_enabled())
2254 ieee80211_stop_queue(sc->hw, info->hw_queue);
2255 else
2256 ieee80211_stop_queue(sc->hw, q);
2251 txq->stopped = true; 2257 txq->stopped = true;
2252 } 2258 }
2253 } 2259 }
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 415393dfb6fc..06ea6cc9e30a 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -515,6 +515,7 @@ void ath_reg_notifier_apply(struct wiphy *wiphy,
515 if (!request) 515 if (!request)
516 return; 516 return;
517 517
518 reg->region = request->dfs_region;
518 switch (request->initiator) { 519 switch (request->initiator) {
519 case NL80211_REGDOM_SET_BY_CORE: 520 case NL80211_REGDOM_SET_BY_CORE:
520 /* 521 /*
@@ -779,6 +780,19 @@ u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
779 return SD_NO_CTL; 780 return SD_NO_CTL;
780 } 781 }
781 782
783 if (ath_regd_get_eepromRD(reg) == CTRY_DEFAULT) {
784 switch (reg->region) {
785 case NL80211_DFS_FCC:
786 return CTL_FCC;
787 case NL80211_DFS_ETSI:
788 return CTL_ETSI;
789 case NL80211_DFS_JP:
790 return CTL_MKK;
791 default:
792 break;
793 }
794 }
795
782 switch (band) { 796 switch (band) {
783 case IEEE80211_BAND_2GHZ: 797 case IEEE80211_BAND_2GHZ:
784 return reg->regpair->reg_2ghz_ctl; 798 return reg->regpair->reg_2ghz_ctl;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625fd06b..d20d4e6f391a 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -670,7 +670,6 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
670 struct brcmf_sdio_dev *sdiodev) 670 struct brcmf_sdio_dev *sdiodev)
671{ 671{
672 int i; 672 int i;
673 uint fw_len, nv_len;
674 char end; 673 char end;
675 674
676 for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) { 675 for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) {
@@ -684,25 +683,25 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
684 return -ENODEV; 683 return -ENODEV;
685 } 684 }
686 685
687 fw_len = sizeof(sdiodev->fw_name) - 1;
688 nv_len = sizeof(sdiodev->nvram_name) - 1;
689 /* check if firmware path is provided by module parameter */ 686 /* check if firmware path is provided by module parameter */
690 if (brcmf_firmware_path[0] != '\0') { 687 if (brcmf_firmware_path[0] != '\0') {
691 strncpy(sdiodev->fw_name, brcmf_firmware_path, fw_len); 688 strlcpy(sdiodev->fw_name, brcmf_firmware_path,
692 strncpy(sdiodev->nvram_name, brcmf_firmware_path, nv_len); 689 sizeof(sdiodev->fw_name));
693 fw_len -= strlen(sdiodev->fw_name); 690 strlcpy(sdiodev->nvram_name, brcmf_firmware_path,
694 nv_len -= strlen(sdiodev->nvram_name); 691 sizeof(sdiodev->nvram_name));
695 692
696 end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1]; 693 end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1];
697 if (end != '/') { 694 if (end != '/') {
698 strncat(sdiodev->fw_name, "/", fw_len); 695 strlcat(sdiodev->fw_name, "/",
699 strncat(sdiodev->nvram_name, "/", nv_len); 696 sizeof(sdiodev->fw_name));
700 fw_len--; 697 strlcat(sdiodev->nvram_name, "/",
701 nv_len--; 698 sizeof(sdiodev->nvram_name));
702 } 699 }
703 } 700 }
704 strncat(sdiodev->fw_name, brcmf_fwname_data[i].bin, fw_len); 701 strlcat(sdiodev->fw_name, brcmf_fwname_data[i].bin,
705 strncat(sdiodev->nvram_name, brcmf_fwname_data[i].nv, nv_len); 702 sizeof(sdiodev->fw_name));
703 strlcat(sdiodev->nvram_name, brcmf_fwname_data[i].nv,
704 sizeof(sdiodev->nvram_name));
706 705
707 return 0; 706 return 0;
708} 707}
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index 2364a3c09b9e..cae692ff1013 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -1095,6 +1095,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1095 u32 queues, bool drop) 1095 u32 queues, bool drop)
1096{ 1096{
1097 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 1097 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
1098 u32 scd_queues;
1098 1099
1099 mutex_lock(&priv->mutex); 1100 mutex_lock(&priv->mutex);
1100 IWL_DEBUG_MAC80211(priv, "enter\n"); 1101 IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -1108,18 +1109,19 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1108 goto done; 1109 goto done;
1109 } 1110 }
1110 1111
1111 /* 1112 scd_queues = BIT(priv->cfg->base_params->num_of_queues) - 1;
1112 * mac80211 will not push any more frames for transmit 1113 scd_queues &= ~(BIT(IWL_IPAN_CMD_QUEUE_NUM) |
1113 * until the flush is completed 1114 BIT(IWL_DEFAULT_CMD_QUEUE_NUM));
1114 */ 1115
1115 if (drop) { 1116 if (vif)
1116 IWL_DEBUG_MAC80211(priv, "send flush command\n"); 1117 scd_queues &= ~BIT(vif->hw_queue[IEEE80211_AC_VO]);
1117 if (iwlagn_txfifo_flush(priv, 0)) { 1118
1118 IWL_ERR(priv, "flush request fail\n"); 1119 IWL_DEBUG_TX_QUEUES(priv, "Flushing SCD queues: 0x%x\n", scd_queues);
1119 goto done; 1120 if (iwlagn_txfifo_flush(priv, scd_queues)) {
1120 } 1121 IWL_ERR(priv, "flush request fail\n");
1122 goto done;
1121 } 1123 }
1122 IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); 1124 IWL_DEBUG_TX_QUEUES(priv, "wait transmit/flush all frames\n");
1123 iwl_trans_wait_tx_queue_empty(priv->trans, 0xffffffff); 1125 iwl_trans_wait_tx_queue_empty(priv->trans, 0xffffffff);
1124done: 1126done:
1125 mutex_unlock(&priv->mutex); 1127 mutex_unlock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-8000.c b/drivers/net/wireless/iwlwifi/iwl-8000.c
index e4351487ca72..d2b7234b1c73 100644
--- a/drivers/net/wireless/iwlwifi/iwl-8000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-8000.c
@@ -82,7 +82,8 @@
82#define IWL8000_TX_POWER_VERSION 0xffff /* meaningless */ 82#define IWL8000_TX_POWER_VERSION 0xffff /* meaningless */
83 83
84#define IWL8000_FW_PRE "iwlwifi-8000" 84#define IWL8000_FW_PRE "iwlwifi-8000"
85#define IWL8000_MODULE_FIRMWARE(api) IWL8000_FW_PRE __stringify(api) ".ucode" 85#define IWL8000_MODULE_FIRMWARE(api) \
86 IWL8000_FW_PRE "-" __stringify(api) ".ucode"
86 87
87#define NVM_HW_SECTION_NUM_FAMILY_8000 10 88#define NVM_HW_SECTION_NUM_FAMILY_8000 10
88#define DEFAULT_NVM_FILE_FAMILY_8000 "iwl_nvm_8000.bin" 89#define DEFAULT_NVM_FILE_FAMILY_8000 "iwl_nvm_8000.bin"
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 9eb85249e89c..d8fc548c0d6c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -563,6 +563,7 @@ enum iwl_trans_state {
563 * Set during transport allocation. 563 * Set during transport allocation.
564 * @hw_id_str: a string with info about HW ID. Set during transport allocation. 564 * @hw_id_str: a string with info about HW ID. Set during transport allocation.
565 * @pm_support: set to true in start_hw if link pm is supported 565 * @pm_support: set to true in start_hw if link pm is supported
566 * @ltr_enabled: set to true if the LTR is enabled
566 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only. 567 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only.
567 * The user should use iwl_trans_{alloc,free}_tx_cmd. 568 * The user should use iwl_trans_{alloc,free}_tx_cmd.
568 * @dev_cmd_headroom: room needed for the transport's private use before the 569 * @dev_cmd_headroom: room needed for the transport's private use before the
@@ -589,6 +590,7 @@ struct iwl_trans {
589 u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size; 590 u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size;
590 591
591 bool pm_support; 592 bool pm_support;
593 bool ltr_enabled;
592 594
593 /* The following fields are internal only */ 595 /* The following fields are internal only */
594 struct kmem_cache *dev_cmd_pool; 596 struct kmem_cache *dev_cmd_pool;
diff --git a/drivers/net/wireless/iwlwifi/mvm/coex.c b/drivers/net/wireless/iwlwifi/mvm/coex.c
index 8df2021f9856..da2ffb785194 100644
--- a/drivers/net/wireless/iwlwifi/mvm/coex.c
+++ b/drivers/net/wireless/iwlwifi/mvm/coex.c
@@ -303,8 +303,8 @@ static const __le64 iwl_ci_mask[][3] = {
303}; 303};
304 304
305static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = { 305static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = {
306 cpu_to_le32(0x28412201), 306 cpu_to_le32(0x2e402280),
307 cpu_to_le32(0x11118451), 307 cpu_to_le32(0x7711a751),
308}; 308};
309 309
310struct corunning_block_luts { 310struct corunning_block_luts {
diff --git a/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c b/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
index 585c0ab4a3ec..8a1d2f33d5b7 100644
--- a/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
+++ b/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
@@ -291,8 +291,8 @@ static const __le64 iwl_ci_mask[][3] = {
291}; 291};
292 292
293static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = { 293static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = {
294 cpu_to_le32(0x28412201), 294 cpu_to_le32(0x2e402280),
295 cpu_to_le32(0x11118451), 295 cpu_to_le32(0x7711a751),
296}; 296};
297 297
298struct corunning_block_luts { 298struct corunning_block_luts {
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
index 27dd86395b39..2fd8ad4633e0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
@@ -68,13 +68,46 @@
68 68
69/* Power Management Commands, Responses, Notifications */ 69/* Power Management Commands, Responses, Notifications */
70 70
71/**
72 * enum iwl_ltr_config_flags - masks for LTR config command flags
73 * @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
74 * @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
75 * memory access
76 * @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
77 * reg change
78 * @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
79 * D0 to D3
80 * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
81 * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
82 * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
83 */
84enum iwl_ltr_config_flags {
85 LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
86 LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS = BIT(1),
87 LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH = BIT(2),
88 LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 = BIT(3),
89 LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
90 LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
91 LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
92};
93
94/**
95 * struct iwl_ltr_config_cmd - configures the LTR
96 * @flags: See %enum iwl_ltr_config_flags
97 */
98struct iwl_ltr_config_cmd {
99 __le32 flags;
100 __le32 static_long;
101 __le32 static_short;
102} __packed;
103
71/* Radio LP RX Energy Threshold measured in dBm */ 104/* Radio LP RX Energy Threshold measured in dBm */
72#define POWER_LPRX_RSSI_THRESHOLD 75 105#define POWER_LPRX_RSSI_THRESHOLD 75
73#define POWER_LPRX_RSSI_THRESHOLD_MAX 94 106#define POWER_LPRX_RSSI_THRESHOLD_MAX 94
74#define POWER_LPRX_RSSI_THRESHOLD_MIN 30 107#define POWER_LPRX_RSSI_THRESHOLD_MIN 30
75 108
76/** 109/**
77 * enum iwl_scan_flags - masks for power table command flags 110 * enum iwl_power_flags - masks for power table command flags
78 * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off 111 * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
79 * receiver and transmitter. '0' - does not allow. 112 * receiver and transmitter. '0' - does not allow.
80 * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management, 113 * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index 667a92274c87..c62575d86bcd 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -157,6 +157,7 @@ enum {
157 /* Power - legacy power table command */ 157 /* Power - legacy power table command */
158 POWER_TABLE_CMD = 0x77, 158 POWER_TABLE_CMD = 0x77,
159 PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78, 159 PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78,
160 LTR_CONFIG = 0xee,
160 161
161 /* Thermal Throttling*/ 162 /* Thermal Throttling*/
162 REPLY_THERMAL_MNG_BACKOFF = 0x7e, 163 REPLY_THERMAL_MNG_BACKOFF = 0x7e,
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index 23fd711a67e4..e0d9f19650b0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -480,6 +480,15 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
480 /* Initialize tx backoffs to the minimal possible */ 480 /* Initialize tx backoffs to the minimal possible */
481 iwl_mvm_tt_tx_backoff(mvm, 0); 481 iwl_mvm_tt_tx_backoff(mvm, 0);
482 482
483 if (mvm->trans->ltr_enabled) {
484 struct iwl_ltr_config_cmd cmd = {
485 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
486 };
487
488 WARN_ON(iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
489 sizeof(cmd), &cmd));
490 }
491
483 ret = iwl_mvm_power_update_device(mvm); 492 ret = iwl_mvm_power_update_device(mvm);
484 if (ret) 493 if (ret)
485 goto error; 494 goto error;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index c7a73c68bdab..585fe5b7100f 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -526,7 +526,8 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
526 } 526 }
527 527
528 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && 528 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
529 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) 529 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) &&
530 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status))
530 goto drop; 531 goto drop;
531 532
532 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */ 533 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */
@@ -1734,6 +1735,13 @@ iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm,
1734 if (changes & BSS_CHANGED_BEACON && 1735 if (changes & BSS_CHANGED_BEACON &&
1735 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) 1736 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
1736 IWL_WARN(mvm, "Failed updating beacon data\n"); 1737 IWL_WARN(mvm, "Failed updating beacon data\n");
1738
1739 if (changes & BSS_CHANGED_TXPOWER) {
1740 IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n",
1741 bss_conf->txpower);
1742 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
1743 }
1744
1737} 1745}
1738 1746
1739static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, 1747static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
@@ -2367,14 +2375,19 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
2367 /* Set the node address */ 2375 /* Set the node address */
2368 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); 2376 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN);
2369 2377
2378 lockdep_assert_held(&mvm->mutex);
2379
2380 spin_lock_bh(&mvm->time_event_lock);
2381
2382 if (WARN_ON(te_data->id == HOT_SPOT_CMD)) {
2383 spin_unlock_bh(&mvm->time_event_lock);
2384 return -EIO;
2385 }
2386
2370 te_data->vif = vif; 2387 te_data->vif = vif;
2371 te_data->duration = duration; 2388 te_data->duration = duration;
2372 te_data->id = HOT_SPOT_CMD; 2389 te_data->id = HOT_SPOT_CMD;
2373 2390
2374 lockdep_assert_held(&mvm->mutex);
2375
2376 spin_lock_bh(&mvm->time_event_lock);
2377 list_add_tail(&te_data->list, &mvm->time_event_list);
2378 spin_unlock_bh(&mvm->time_event_lock); 2391 spin_unlock_bh(&mvm->time_event_lock);
2379 2392
2380 /* 2393 /*
@@ -2430,22 +2443,23 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
2430 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, 2443 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
2431 duration, type); 2444 duration, type);
2432 2445
2446 mutex_lock(&mvm->mutex);
2447
2433 switch (vif->type) { 2448 switch (vif->type) {
2434 case NL80211_IFTYPE_STATION: 2449 case NL80211_IFTYPE_STATION:
2435 /* Use aux roc framework (HS20) */ 2450 /* Use aux roc framework (HS20) */
2436 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, 2451 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel,
2437 vif, duration); 2452 vif, duration);
2438 return ret; 2453 goto out_unlock;
2439 case NL80211_IFTYPE_P2P_DEVICE: 2454 case NL80211_IFTYPE_P2P_DEVICE:
2440 /* handle below */ 2455 /* handle below */
2441 break; 2456 break;
2442 default: 2457 default:
2443 IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type); 2458 IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type);
2444 return -EINVAL; 2459 ret = -EINVAL;
2460 goto out_unlock;
2445 } 2461 }
2446 2462
2447 mutex_lock(&mvm->mutex);
2448
2449 for (i = 0; i < NUM_PHY_CTX; i++) { 2463 for (i = 0; i < NUM_PHY_CTX; i++) {
2450 phy_ctxt = &mvm->phy_ctxts[i]; 2464 phy_ctxt = &mvm->phy_ctxts[i];
2451 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) 2465 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 15aa298ee79c..48cb25a93591 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -336,6 +336,7 @@ static const char *const iwl_mvm_cmd_strings[REPLY_MAX] = {
336 CMD(DTS_MEASUREMENT_NOTIFICATION), 336 CMD(DTS_MEASUREMENT_NOTIFICATION),
337 CMD(REPLY_THERMAL_MNG_BACKOFF), 337 CMD(REPLY_THERMAL_MNG_BACKOFF),
338 CMD(MAC_PM_POWER_TABLE), 338 CMD(MAC_PM_POWER_TABLE),
339 CMD(LTR_CONFIG),
339 CMD(BT_COEX_CI), 340 CMD(BT_COEX_CI),
340 CMD(BT_COEX_UPDATE_SW_BOOST), 341 CMD(BT_COEX_UPDATE_SW_BOOST),
341 CMD(BT_COEX_UPDATE_CORUN_LUT), 342 CMD(BT_COEX_UPDATE_CORUN_LUT),
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index cb85e63c20aa..b280d5d87127 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -459,7 +459,8 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm,
459 basic_ssid ? 1 : 0); 459 basic_ssid ? 1 : 0);
460 460
461 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL | 461 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL |
462 TX_CMD_FLG_BT_DIS); 462 3 << TX_CMD_FLG_BT_PRIO_POS);
463
463 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id; 464 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id;
464 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE); 465 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
465 cmd->tx_cmd.rate_n_flags = 466 cmd->tx_cmd.rate_n_flags =
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index b7f9e61d14e2..6dfad230be5e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -305,8 +305,8 @@ static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
305 te_data->running = false; 305 te_data->running = false;
306 te_data->vif = NULL; 306 te_data->vif = NULL;
307 te_data->uid = 0; 307 te_data->uid = 0;
308 te_data->id = TE_MAX;
308 } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) { 309 } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) {
309 set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
310 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); 310 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status);
311 te_data->running = true; 311 te_data->running = true;
312 ieee80211_ready_on_channel(mvm->hw); /* Start TE */ 312 ieee80211_ready_on_channel(mvm->hw); /* Start TE */
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 1cb793a498ac..c6a517c771df 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -175,14 +175,10 @@ static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
175 175
176 /* 176 /*
177 * for data packets, rate info comes from the table inside the fw. This 177 * for data packets, rate info comes from the table inside the fw. This
178 * table is controlled by LINK_QUALITY commands. Exclude ctrl port 178 * table is controlled by LINK_QUALITY commands
179 * frames like EAPOLs which should be treated as mgmt frames. This
180 * avoids them being sent initially in high rates which increases the
181 * chances for completion of the 4-Way handshake.
182 */ 179 */
183 180
184 if (ieee80211_is_data(fc) && sta && 181 if (ieee80211_is_data(fc) && sta) {
185 !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) {
186 tx_cmd->initial_rate_index = 0; 182 tx_cmd->initial_rate_index = 0;
187 tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE); 183 tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE);
188 return; 184 return;
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 1393bac0025c..3781b029e54a 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -174,6 +174,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
174{ 174{
175 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 175 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
176 u16 lctl; 176 u16 lctl;
177 u16 cap;
177 178
178 /* 179 /*
179 * HW bug W/A for instability in PCIe bus L0S->L1 transition. 180 * HW bug W/A for instability in PCIe bus L0S->L1 transition.
@@ -184,16 +185,17 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
184 * power savings, even without L1. 185 * power savings, even without L1.
185 */ 186 */
186 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); 187 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl);
187 if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { 188 if (lctl & PCI_EXP_LNKCTL_ASPM_L1)
188 /* L1-ASPM enabled; disable(!) L0S */
189 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 189 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
190 dev_info(trans->dev, "L1 Enabled; Disabling L0S\n"); 190 else
191 } else {
192 /* L1-ASPM disabled; enable(!) L0S */
193 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 191 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
194 dev_info(trans->dev, "L1 Disabled; Enabling L0S\n");
195 }
196 trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); 192 trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);
193
194 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_DEVCTL2, &cap);
195 trans->ltr_enabled = cap & PCI_EXP_DEVCTL2_LTR_EN;
196 dev_info(trans->dev, "L1 %sabled - LTR %sabled\n",
197 (lctl & PCI_EXP_LNKCTL_ASPM_L1) ? "En" : "Dis",
198 trans->ltr_enabled ? "En" : "Dis");
197} 199}
198 200
199/* 201/*
@@ -428,7 +430,7 @@ static int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
428 ret = iwl_poll_bit(trans, CSR_RESET, 430 ret = iwl_poll_bit(trans, CSR_RESET,
429 CSR_RESET_REG_FLAG_MASTER_DISABLED, 431 CSR_RESET_REG_FLAG_MASTER_DISABLED,
430 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 432 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
431 if (ret) 433 if (ret < 0)
432 IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n"); 434 IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n");
433 435
434 IWL_DEBUG_INFO(trans, "stop master\n"); 436 IWL_DEBUG_INFO(trans, "stop master\n");
@@ -544,7 +546,7 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
544 msleep(25); 546 msleep(25);
545 } 547 }
546 548
547 IWL_DEBUG_INFO(trans, "got NIC after %d iterations\n", iter); 549 IWL_ERR(trans, "Couldn't prepare the card\n");
548 550
549 return ret; 551 return ret;
550} 552}
@@ -1043,7 +1045,7 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
1043 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1045 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
1044 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1046 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
1045 25000); 1047 25000);
1046 if (ret) { 1048 if (ret < 0) {
1047 IWL_ERR(trans, "Failed to resume the device (mac ready)\n"); 1049 IWL_ERR(trans, "Failed to resume the device (mac ready)\n");
1048 return ret; 1050 return ret;
1049 } 1051 }
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c
index 40057079ffb9..5ef5a0eeba50 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c
@@ -196,6 +196,7 @@ mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv,
196 mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win); 196 mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win);
197 197
198 del_timer_sync(&tbl->timer_context.timer); 198 del_timer_sync(&tbl->timer_context.timer);
199 tbl->timer_context.timer_is_set = false;
199 200
200 spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); 201 spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags);
201 list_del(&tbl->list); 202 list_del(&tbl->list);
@@ -297,6 +298,7 @@ mwifiex_flush_data(unsigned long context)
297 (struct reorder_tmr_cnxt *) context; 298 (struct reorder_tmr_cnxt *) context;
298 int start_win, seq_num; 299 int start_win, seq_num;
299 300
301 ctx->timer_is_set = false;
300 seq_num = mwifiex_11n_find_last_seq_num(ctx); 302 seq_num = mwifiex_11n_find_last_seq_num(ctx);
301 303
302 if (seq_num < 0) 304 if (seq_num < 0)
@@ -385,6 +387,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
385 387
386 new_node->timer_context.ptr = new_node; 388 new_node->timer_context.ptr = new_node;
387 new_node->timer_context.priv = priv; 389 new_node->timer_context.priv = priv;
390 new_node->timer_context.timer_is_set = false;
388 391
389 init_timer(&new_node->timer_context.timer); 392 init_timer(&new_node->timer_context.timer);
390 new_node->timer_context.timer.function = mwifiex_flush_data; 393 new_node->timer_context.timer.function = mwifiex_flush_data;
@@ -399,6 +402,22 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
399 spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); 402 spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);
400} 403}
401 404
405static void
406mwifiex_11n_rxreorder_timer_restart(struct mwifiex_rx_reorder_tbl *tbl)
407{
408 u32 min_flush_time;
409
410 if (tbl->win_size >= MWIFIEX_BA_WIN_SIZE_32)
411 min_flush_time = MIN_FLUSH_TIMER_15_MS;
412 else
413 min_flush_time = MIN_FLUSH_TIMER_MS;
414
415 mod_timer(&tbl->timer_context.timer,
416 jiffies + msecs_to_jiffies(min_flush_time * tbl->win_size));
417
418 tbl->timer_context.timer_is_set = true;
419}
420
402/* 421/*
403 * This function prepares command for adding a BA request. 422 * This function prepares command for adding a BA request.
404 * 423 *
@@ -523,31 +542,31 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
523 u8 *ta, u8 pkt_type, void *payload) 542 u8 *ta, u8 pkt_type, void *payload)
524{ 543{
525 struct mwifiex_rx_reorder_tbl *tbl; 544 struct mwifiex_rx_reorder_tbl *tbl;
526 int start_win, end_win, win_size; 545 int prev_start_win, start_win, end_win, win_size;
527 u16 pkt_index; 546 u16 pkt_index;
528 bool init_window_shift = false; 547 bool init_window_shift = false;
548 int ret = 0;
529 549
530 tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); 550 tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta);
531 if (!tbl) { 551 if (!tbl) {
532 if (pkt_type != PKT_TYPE_BAR) 552 if (pkt_type != PKT_TYPE_BAR)
533 mwifiex_11n_dispatch_pkt(priv, payload); 553 mwifiex_11n_dispatch_pkt(priv, payload);
534 return 0; 554 return ret;
535 } 555 }
536 556
537 if ((pkt_type == PKT_TYPE_AMSDU) && !tbl->amsdu) { 557 if ((pkt_type == PKT_TYPE_AMSDU) && !tbl->amsdu) {
538 mwifiex_11n_dispatch_pkt(priv, payload); 558 mwifiex_11n_dispatch_pkt(priv, payload);
539 return 0; 559 return ret;
540 } 560 }
541 561
542 start_win = tbl->start_win; 562 start_win = tbl->start_win;
563 prev_start_win = start_win;
543 win_size = tbl->win_size; 564 win_size = tbl->win_size;
544 end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); 565 end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1);
545 if (tbl->flags & RXREOR_INIT_WINDOW_SHIFT) { 566 if (tbl->flags & RXREOR_INIT_WINDOW_SHIFT) {
546 init_window_shift = true; 567 init_window_shift = true;
547 tbl->flags &= ~RXREOR_INIT_WINDOW_SHIFT; 568 tbl->flags &= ~RXREOR_INIT_WINDOW_SHIFT;
548 } 569 }
549 mod_timer(&tbl->timer_context.timer,
550 jiffies + msecs_to_jiffies(MIN_FLUSH_TIMER_MS * win_size));
551 570
552 if (tbl->flags & RXREOR_FORCE_NO_DROP) { 571 if (tbl->flags & RXREOR_FORCE_NO_DROP) {
553 dev_dbg(priv->adapter->dev, 572 dev_dbg(priv->adapter->dev,
@@ -568,11 +587,14 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
568 if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) { 587 if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) {
569 if (seq_num >= ((start_win + TWOPOW11) & 588 if (seq_num >= ((start_win + TWOPOW11) &
570 (MAX_TID_VALUE - 1)) && 589 (MAX_TID_VALUE - 1)) &&
571 seq_num < start_win) 590 seq_num < start_win) {
572 return -1; 591 ret = -1;
592 goto done;
593 }
573 } else if ((seq_num < start_win) || 594 } else if ((seq_num < start_win) ||
574 (seq_num > (start_win + TWOPOW11))) { 595 (seq_num >= (start_win + TWOPOW11))) {
575 return -1; 596 ret = -1;
597 goto done;
576 } 598 }
577 } 599 }
578 600
@@ -601,8 +623,10 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
601 else 623 else
602 pkt_index = (seq_num+MAX_TID_VALUE) - start_win; 624 pkt_index = (seq_num+MAX_TID_VALUE) - start_win;
603 625
604 if (tbl->rx_reorder_ptr[pkt_index]) 626 if (tbl->rx_reorder_ptr[pkt_index]) {
605 return -1; 627 ret = -1;
628 goto done;
629 }
606 630
607 tbl->rx_reorder_ptr[pkt_index] = payload; 631 tbl->rx_reorder_ptr[pkt_index] = payload;
608 } 632 }
@@ -613,7 +637,11 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
613 */ 637 */
614 mwifiex_11n_scan_and_dispatch(priv, tbl); 638 mwifiex_11n_scan_and_dispatch(priv, tbl);
615 639
616 return 0; 640done:
641 if (!tbl->timer_context.timer_is_set ||
642 prev_start_win != tbl->start_win)
643 mwifiex_11n_rxreorder_timer_restart(tbl);
644 return ret;
617} 645}
618 646
619/* 647/*
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.h b/drivers/net/wireless/mwifiex/11n_rxreorder.h
index 3a87bb0e3a62..63ecea89b4ab 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.h
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.h
@@ -21,6 +21,8 @@
21#define _MWIFIEX_11N_RXREORDER_H_ 21#define _MWIFIEX_11N_RXREORDER_H_
22 22
23#define MIN_FLUSH_TIMER_MS 50 23#define MIN_FLUSH_TIMER_MS 50
24#define MIN_FLUSH_TIMER_15_MS 15
25#define MWIFIEX_BA_WIN_SIZE_32 32
24 26
25#define PKT_TYPE_BAR 0xE7 27#define PKT_TYPE_BAR 0xE7
26#define MAX_TID_VALUE (2 << 11) 28#define MAX_TID_VALUE (2 << 11)
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index e2635747d966..f55658d15c60 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -592,6 +592,7 @@ struct reorder_tmr_cnxt {
592 struct timer_list timer; 592 struct timer_list timer;
593 struct mwifiex_rx_reorder_tbl *ptr; 593 struct mwifiex_rx_reorder_tbl *ptr;
594 struct mwifiex_private *priv; 594 struct mwifiex_private *priv;
595 u8 timer_is_set;
595}; 596};
596 597
597struct mwifiex_rx_reorder_tbl { 598struct mwifiex_rx_reorder_tbl {
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 573897b8e878..8444313eabe2 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1111,6 +1111,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1111 /* Ovislink */ 1111 /* Ovislink */
1112 { USB_DEVICE(0x1b75, 0x3071) }, 1112 { USB_DEVICE(0x1b75, 0x3071) },
1113 { USB_DEVICE(0x1b75, 0x3072) }, 1113 { USB_DEVICE(0x1b75, 0x3072) },
1114 { USB_DEVICE(0x1b75, 0xa200) },
1114 /* Para */ 1115 /* Para */
1115 { USB_DEVICE(0x20b8, 0x8888) }, 1116 { USB_DEVICE(0x20b8, 0x8888) },
1116 /* Pegatron */ 1117 /* Pegatron */
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 58ba71830886..40b6d1d006d7 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -467,7 +467,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
467 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw); 467 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw);
468 /* <2> work queue */ 468 /* <2> work queue */
469 rtlpriv->works.hw = hw; 469 rtlpriv->works.hw = hw;
470 rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0); 470 rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
471 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq, 471 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
472 (void *)rtl_watchdog_wq_callback); 472 (void *)rtl_watchdog_wq_callback);
473 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq, 473 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index f6179bc06086..07dae0d44abc 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -1828,3 +1828,9 @@ const struct ieee80211_ops rtl_ops = {
1828 .flush = rtl_op_flush, 1828 .flush = rtl_op_flush,
1829}; 1829};
1830EXPORT_SYMBOL_GPL(rtl_ops); 1830EXPORT_SYMBOL_GPL(rtl_ops);
1831
1832bool rtl_btc_status_false(void)
1833{
1834 return false;
1835}
1836EXPORT_SYMBOL_GPL(rtl_btc_status_false);
diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
index 59cd3b9dca25..624e1dc16d31 100644
--- a/drivers/net/wireless/rtlwifi/core.h
+++ b/drivers/net/wireless/rtlwifi/core.h
@@ -42,5 +42,6 @@ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
42 u32 mask, u32 data); 42 u32 mask, u32 data);
43void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data); 43void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
44bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); 44bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
45bool rtl_btc_status_false(void);
45 46
46#endif 47#endif
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 667aba81246c..25daa8715219 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1796,7 +1796,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1796 rtl_pci_reset_trx_ring(hw); 1796 rtl_pci_reset_trx_ring(hw);
1797 1797
1798 rtlpci->driver_is_goingto_unload = false; 1798 rtlpci->driver_is_goingto_unload = false;
1799 if (rtlpriv->cfg->ops->get_btc_status()) { 1799 if (rtlpriv->cfg->ops->get_btc_status &&
1800 rtlpriv->cfg->ops->get_btc_status()) {
1800 rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv); 1801 rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv);
1801 rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv); 1802 rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv);
1802 } 1803 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
index a00861b26ece..29983bc96a89 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
@@ -656,7 +656,8 @@ static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = {
656 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 656 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
657}; 657};
658 658
659void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) 659void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
660 bool (*cmd_send_packet)(struct ieee80211_hw *, struct sk_buff *))
660{ 661{
661 struct rtl_priv *rtlpriv = rtl_priv(hw); 662 struct rtl_priv *rtlpriv = rtl_priv(hw);
662 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 663 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -722,7 +723,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
722 memcpy((u8 *)skb_put(skb, totalpacketlen), 723 memcpy((u8 *)skb_put(skb, totalpacketlen),
723 &reserved_page_packet, totalpacketlen); 724 &reserved_page_packet, totalpacketlen);
724 725
725 rtstatus = rtl_cmd_send_packet(hw, skb); 726 if (cmd_send_packet)
727 rtstatus = cmd_send_packet(hw, skb);
728 else
729 rtstatus = rtl_cmd_send_packet(hw, skb);
726 730
727 if (rtstatus) 731 if (rtstatus)
728 b_dlok = true; 732 b_dlok = true;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
index a815bd6273da..b64ae45dc674 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
@@ -109,7 +109,9 @@ void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
109 u32 cmd_len, u8 *p_cmdbuffer); 109 u32 cmd_len, u8 *p_cmdbuffer);
110void rtl92c_firmware_selfreset(struct ieee80211_hw *hw); 110void rtl92c_firmware_selfreset(struct ieee80211_hw *hw);
111void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); 111void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
112void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); 112void rtl92c_set_fw_rsvdpagepkt
113 (struct ieee80211_hw *hw,
114 bool (*cmd_send_packet)(struct ieee80211_hw *, struct sk_buff *));
113void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); 115void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
114void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len); 116void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len);
115void rtl92c_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); 117void rtl92c_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 831df101d7b7..9b660df6fd71 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -114,6 +114,8 @@
114 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4) 114 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4)
115#define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \ 115#define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \
116 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12) 116 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12)
117#define GET_RX_STATUS_DESC_BUFF_ADDR(__pdesc) \
118 SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
117 119
118#define CHIP_VER_B BIT(4) 120#define CHIP_VER_B BIT(4)
119#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3) 121#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index 8ec0f031f48a..55357d69397a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -459,7 +459,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
459 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, 459 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
460 tmp_reg422 & (~BIT(6))); 460 tmp_reg422 & (~BIT(6)));
461 461
462 rtl92c_set_fw_rsvdpagepkt(hw, 0); 462 rtl92c_set_fw_rsvdpagepkt(hw, NULL);
463 463
464 _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0); 464 _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0);
465 _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4)); 465 _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4));
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index d86b5b566444..46ea07605eb4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -244,6 +244,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
244 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate, 244 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate,
245 .phy_set_bw_mode_callback = rtl92ce_phy_set_bw_mode_callback, 245 .phy_set_bw_mode_callback = rtl92ce_phy_set_bw_mode_callback,
246 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower, 246 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower,
247 .get_btc_status = rtl_btc_status_false,
247}; 248};
248 249
249static struct rtl_mod_params rtl92ce_mod_params = { 250static struct rtl_mod_params rtl92ce_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 2fb9c7acb76a..dc3d20b17a26 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -728,6 +728,9 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
728 case HW_DESC_RXPKT_LEN: 728 case HW_DESC_RXPKT_LEN:
729 ret = GET_RX_DESC_PKT_LEN(pdesc); 729 ret = GET_RX_DESC_PKT_LEN(pdesc);
730 break; 730 break;
731 case HW_DESC_RXBUFF_ADDR:
732 ret = GET_RX_STATUS_DESC_BUFF_ADDR(pdesc);
733 break;
731 default: 734 default:
732 RT_ASSERT(false, "ERR rxdesc :%d not process\n", 735 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
733 desc_name); 736 desc_name);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 04aa0b5f5b3d..873363acbacf 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -1592,6 +1592,20 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1592 } 1592 }
1593} 1593}
1594 1594
1595bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1596{
1597 /* Currently nothing happens here.
1598 * Traffic stops after some seconds in WPA2 802.11n mode.
1599 * Maybe because rtl8192cu chip should be set from here?
1600 * If I understand correctly, the realtek vendor driver sends some urbs
1601 * if its "here".
1602 *
1603 * This is maybe necessary:
1604 * rtlpriv->cfg->ops->fill_tx_cmddesc(hw, buffer, 1, 1, skb);
1605 */
1606 return true;
1607}
1608
1595void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) 1609void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1596{ 1610{
1597 struct rtl_priv *rtlpriv = rtl_priv(hw); 1611 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -1939,7 +1953,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1939 recover = true; 1953 recover = true;
1940 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, 1954 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
1941 tmp_reg422 & (~BIT(6))); 1955 tmp_reg422 & (~BIT(6)));
1942 rtl92c_set_fw_rsvdpagepkt(hw, 0); 1956 rtl92c_set_fw_rsvdpagepkt(hw,
1957 &usb_cmd_send_packet);
1943 _rtl92cu_set_bcn_ctrl_reg(hw, BIT(3), 0); 1958 _rtl92cu_set_bcn_ctrl_reg(hw, BIT(3), 0);
1944 _rtl92cu_set_bcn_ctrl_reg(hw, 0, BIT(4)); 1959 _rtl92cu_set_bcn_ctrl_reg(hw, 0, BIT(4));
1945 if (recover) 1960 if (recover)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
index 0f7812e0c8aa..c1e33b0228c0 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
@@ -104,7 +104,6 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid);
104void rtl92cu_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); 104void rtl92cu_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid);
105int rtl92c_download_fw(struct ieee80211_hw *hw); 105int rtl92c_download_fw(struct ieee80211_hw *hw);
106void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); 106void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
107void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished);
108void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); 107void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
109void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, 108void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw,
110 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer); 109 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 7c5fbaf5fee0..e06bafee37f9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -101,6 +101,12 @@ static void rtl92cu_deinit_sw_vars(struct ieee80211_hw *hw)
101 } 101 }
102} 102}
103 103
104/* get bt coexist status */
105static bool rtl92cu_get_btc_status(void)
106{
107 return false;
108}
109
104static struct rtl_hal_ops rtl8192cu_hal_ops = { 110static struct rtl_hal_ops rtl8192cu_hal_ops = {
105 .init_sw_vars = rtl92cu_init_sw_vars, 111 .init_sw_vars = rtl92cu_init_sw_vars,
106 .deinit_sw_vars = rtl92cu_deinit_sw_vars, 112 .deinit_sw_vars = rtl92cu_deinit_sw_vars,
@@ -148,6 +154,7 @@ static struct rtl_hal_ops rtl8192cu_hal_ops = {
148 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback, 154 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback,
149 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower, 155 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower,
150 .fill_h2c_cmd = rtl92c_fill_h2c_cmd, 156 .fill_h2c_cmd = rtl92c_fill_h2c_cmd,
157 .get_btc_status = rtl92cu_get_btc_status,
151}; 158};
152 159
153static struct rtl_mod_params rtl92cu_mod_params = { 160static struct rtl_mod_params rtl92cu_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index edab5a5351b5..a0aba088259a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -251,6 +251,7 @@ static struct rtl_hal_ops rtl8192de_hal_ops = {
251 .get_rfreg = rtl92d_phy_query_rf_reg, 251 .get_rfreg = rtl92d_phy_query_rf_reg,
252 .set_rfreg = rtl92d_phy_set_rf_reg, 252 .set_rfreg = rtl92d_phy_set_rf_reg,
253 .linked_set_reg = rtl92d_linked_set_reg, 253 .linked_set_reg = rtl92d_linked_set_reg,
254 .get_btc_status = rtl_btc_status_false,
254}; 255};
255 256
256static struct rtl_mod_params rtl92de_mod_params = { 257static struct rtl_mod_params rtl92de_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
index dfdc9b20e4ad..1a87edca2c3f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
@@ -362,7 +362,7 @@ void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
362 } 362 }
363 break; 363 break;
364 default: 364 default:
365 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 365 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
366 "switch case not process %x\n", variable); 366 "switch case not process %x\n", variable);
367 break; 367 break;
368 } 368 }
@@ -591,7 +591,7 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
591 acm_ctrl &= (~ACMHW_BEQEN); 591 acm_ctrl &= (~ACMHW_BEQEN);
592 break; 592 break;
593 default: 593 default:
594 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 594 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
595 "switch case not process\n"); 595 "switch case not process\n");
596 break; 596 break;
597 } 597 }
@@ -710,7 +710,7 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
710 } 710 }
711 break; 711 break;
712 default: 712 default:
713 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 713 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
714 "switch case not process %x\n", variable); 714 "switch case not process %x\n", variable);
715 break; 715 break;
716 } 716 }
@@ -2424,7 +2424,7 @@ void rtl92ee_set_key(struct ieee80211_hw *hw, u32 key_index,
2424 enc_algo = CAM_AES; 2424 enc_algo = CAM_AES;
2425 break; 2425 break;
2426 default: 2426 default:
2427 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2427 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
2428 "switch case not process\n"); 2428 "switch case not process\n");
2429 enc_algo = CAM_TKIP; 2429 enc_algo = CAM_TKIP;
2430 break; 2430 break;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
index 83c98674bfd3..6e7a70b43949 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
@@ -446,6 +446,8 @@
446/* DWORD 6 */ 446/* DWORD 6 */
447#define SET_RX_STATUS__DESC_BUFF_ADDR(__pdesc, __val) \ 447#define SET_RX_STATUS__DESC_BUFF_ADDR(__pdesc, __val) \
448 SET_BITS_OFFSET_LE(__pdesc + 24, 0, 32, __val) 448 SET_BITS_OFFSET_LE(__pdesc + 24, 0, 32, __val)
449#define GET_RX_STATUS_DESC_BUFF_ADDR(__pdesc) \
450 SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
449 451
450#define SE_RX_HAL_IS_CCK_RATE(_pdesc)\ 452#define SE_RX_HAL_IS_CCK_RATE(_pdesc)\
451 (GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M || \ 453 (GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M || \
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index 1bff2a0f7600..aadba29c167a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -87,11 +87,8 @@ static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
87static void rtl92se_fw_cb(const struct firmware *firmware, void *context) 87static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
88{ 88{
89 struct ieee80211_hw *hw = context; 89 struct ieee80211_hw *hw = context;
90 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
91 struct rtl_priv *rtlpriv = rtl_priv(hw); 90 struct rtl_priv *rtlpriv = rtl_priv(hw);
92 struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
93 struct rt_firmware *pfirmware = NULL; 91 struct rt_firmware *pfirmware = NULL;
94 int err;
95 92
96 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
97 "Firmware callback routine entered!\n"); 94 "Firmware callback routine entered!\n");
@@ -112,20 +109,6 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
112 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size); 109 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
113 pfirmware->sz_fw_tmpbufferlen = firmware->size; 110 pfirmware->sz_fw_tmpbufferlen = firmware->size;
114 release_firmware(firmware); 111 release_firmware(firmware);
115
116 err = ieee80211_register_hw(hw);
117 if (err) {
118 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
119 "Can't register mac80211 hw\n");
120 return;
121 } else {
122 rtlpriv->mac80211.mac80211_registered = 1;
123 }
124 rtlpci->irq_alloc = 1;
125 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
126
127 /*init rfkill */
128 rtl_init_rfkill(hw);
129} 112}
130 113
131static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) 114static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
@@ -226,8 +209,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
226 if (!rtlpriv->rtlhal.pfirmware) 209 if (!rtlpriv->rtlhal.pfirmware)
227 return 1; 210 return 1;
228 211
229 rtlpriv->max_fw_size = RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE; 212 rtlpriv->max_fw_size = RTL8190_MAX_FIRMWARE_CODE_SIZE*2 +
230 213 sizeof(struct fw_hdr);
231 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" 214 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
232 "Loading firmware %s\n", rtlpriv->cfg->fw_name); 215 "Loading firmware %s\n", rtlpriv->cfg->fw_name);
233 /* request fw */ 216 /* request fw */
@@ -294,6 +277,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
294 .set_bbreg = rtl92s_phy_set_bb_reg, 277 .set_bbreg = rtl92s_phy_set_bb_reg,
295 .get_rfreg = rtl92s_phy_query_rf_reg, 278 .get_rfreg = rtl92s_phy_query_rf_reg,
296 .set_rfreg = rtl92s_phy_set_rf_reg, 279 .set_rfreg = rtl92s_phy_set_rf_reg,
280 .get_btc_status = rtl_btc_status_false,
297}; 281};
298 282
299static struct rtl_mod_params rtl92se_mod_params = { 283static struct rtl_mod_params rtl92se_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index b358ebce8942..672fd3b02835 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -640,6 +640,9 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name)
640 case HW_DESC_RXPKT_LEN: 640 case HW_DESC_RXPKT_LEN:
641 ret = GET_RX_STATUS_DESC_PKT_LEN(desc); 641 ret = GET_RX_STATUS_DESC_PKT_LEN(desc);
642 break; 642 break;
643 case HW_DESC_RXBUFF_ADDR:
644 ret = GET_RX_STATUS_DESC_BUFF_ADDR(desc);
645 break;
643 default: 646 default:
644 RT_ASSERT(false, "ERR rxdesc :%d not process\n", 647 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
645 desc_name); 648 desc_name);
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
index 9786313dc62f..1e9570fa874f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
@@ -1889,15 +1889,18 @@ static void _rtl8821ae_store_tx_power_by_rate(struct ieee80211_hw *hw,
1889 struct rtl_phy *rtlphy = &rtlpriv->phy; 1889 struct rtl_phy *rtlphy = &rtlpriv->phy;
1890 u8 rate_section = _rtl8821ae_get_rate_section_index(regaddr); 1890 u8 rate_section = _rtl8821ae_get_rate_section_index(regaddr);
1891 1891
1892 if (band != BAND_ON_2_4G && band != BAND_ON_5G) 1892 if (band != BAND_ON_2_4G && band != BAND_ON_5G) {
1893 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid Band %d\n", band); 1893 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid Band %d\n", band);
1894 1894 band = BAND_ON_2_4G;
1895 if (rfpath >= MAX_RF_PATH) 1895 }
1896 if (rfpath >= MAX_RF_PATH) {
1896 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid RfPath %d\n", rfpath); 1897 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid RfPath %d\n", rfpath);
1897 1898 rfpath = MAX_RF_PATH - 1;
1898 if (txnum >= MAX_RF_PATH) 1899 }
1900 if (txnum >= MAX_RF_PATH) {
1899 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid TxNum %d\n", txnum); 1901 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid TxNum %d\n", txnum);
1900 1902 txnum = MAX_RF_PATH - 1;
1903 }
1901 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] = data; 1904 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] = data;
1902 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1905 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1903 "TxPwrByRateOffset[Band %d][RfPath %d][TxNum %d][RateSection %d] = 0x%x\n", 1906 "TxPwrByRateOffset[Band %d][RfPath %d][TxNum %d][RateSection %d] = 0x%x\n",
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 10cf69c4bc42..46ee956d0235 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -1117,7 +1117,18 @@ int rtl_usb_probe(struct usb_interface *intf,
1117 } 1117 }
1118 rtlpriv->cfg->ops->init_sw_leds(hw); 1118 rtlpriv->cfg->ops->init_sw_leds(hw);
1119 1119
1120 err = ieee80211_register_hw(hw);
1121 if (err) {
1122 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1123 "Can't register mac80211 hw.\n");
1124 err = -ENODEV;
1125 goto error_out;
1126 }
1127 rtlpriv->mac80211.mac80211_registered = 1;
1128
1129 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
1120 return 0; 1130 return 0;
1131
1121error_out: 1132error_out:
1122 rtl_deinit_core(hw); 1133 rtl_deinit_core(hw);
1123 _rtl_usb_io_handler_release(hw); 1134 _rtl_usb_io_handler_release(hw);
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index d4eb8d2e9cb7..083ecc93fe5e 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -176,10 +176,11 @@ struct xenvif_queue { /* Per-queue data for xenvif */
176 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */ 176 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */
177 struct xen_netif_rx_back_ring rx; 177 struct xen_netif_rx_back_ring rx;
178 struct sk_buff_head rx_queue; 178 struct sk_buff_head rx_queue;
179 RING_IDX rx_last_skb_slots;
180 unsigned long status;
181 179
182 struct timer_list rx_stalled; 180 unsigned int rx_queue_max;
181 unsigned int rx_queue_len;
182 unsigned long last_rx_time;
183 bool stalled;
183 184
184 struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS]; 185 struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS];
185 186
@@ -199,18 +200,14 @@ struct xenvif_queue { /* Per-queue data for xenvif */
199 struct xenvif_stats stats; 200 struct xenvif_stats stats;
200}; 201};
201 202
203/* Maximum number of Rx slots a to-guest packet may use, including the
204 * slot needed for GSO meta-data.
205 */
206#define XEN_NETBK_RX_SLOTS_MAX (MAX_SKB_FRAGS + 1)
207
202enum state_bit_shift { 208enum state_bit_shift {
203 /* This bit marks that the vif is connected */ 209 /* This bit marks that the vif is connected */
204 VIF_STATUS_CONNECTED, 210 VIF_STATUS_CONNECTED,
205 /* This bit signals the RX thread that queuing was stopped (in
206 * start_xmit), and either the timer fired or an RX interrupt came
207 */
208 QUEUE_STATUS_RX_PURGE_EVENT,
209 /* This bit tells the interrupt handler that this queue was the reason
210 * for the carrier off, so it should kick the thread. Only queues which
211 * brought it down can turn on the carrier.
212 */
213 QUEUE_STATUS_RX_STALLED
214}; 211};
215 212
216struct xenvif { 213struct xenvif {
@@ -228,9 +225,6 @@ struct xenvif {
228 u8 ip_csum:1; 225 u8 ip_csum:1;
229 u8 ipv6_csum:1; 226 u8 ipv6_csum:1;
230 227
231 /* Internal feature information. */
232 u8 can_queue:1; /* can queue packets for receiver? */
233
234 /* Is this interface disabled? True when backend discovers 228 /* Is this interface disabled? True when backend discovers
235 * frontend is rogue. 229 * frontend is rogue.
236 */ 230 */
@@ -240,6 +234,9 @@ struct xenvif {
240 /* Queues */ 234 /* Queues */
241 struct xenvif_queue *queues; 235 struct xenvif_queue *queues;
242 unsigned int num_queues; /* active queues, resource allocated */ 236 unsigned int num_queues; /* active queues, resource allocated */
237 unsigned int stalled_queues;
238
239 spinlock_t lock;
243 240
244#ifdef CONFIG_DEBUG_FS 241#ifdef CONFIG_DEBUG_FS
245 struct dentry *xenvif_dbg_root; 242 struct dentry *xenvif_dbg_root;
@@ -249,6 +246,14 @@ struct xenvif {
249 struct net_device *dev; 246 struct net_device *dev;
250}; 247};
251 248
249struct xenvif_rx_cb {
250 unsigned long expires;
251 int meta_slots_used;
252 bool full_coalesce;
253};
254
255#define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb)
256
252static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif) 257static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)
253{ 258{
254 return to_xenbus_device(vif->dev->dev.parent); 259 return to_xenbus_device(vif->dev->dev.parent);
@@ -272,8 +277,6 @@ void xenvif_xenbus_fini(void);
272 277
273int xenvif_schedulable(struct xenvif *vif); 278int xenvif_schedulable(struct xenvif *vif);
274 279
275int xenvif_must_stop_queue(struct xenvif_queue *queue);
276
277int xenvif_queue_stopped(struct xenvif_queue *queue); 280int xenvif_queue_stopped(struct xenvif_queue *queue);
278void xenvif_wake_queue(struct xenvif_queue *queue); 281void xenvif_wake_queue(struct xenvif_queue *queue);
279 282
@@ -296,6 +299,8 @@ void xenvif_kick_thread(struct xenvif_queue *queue);
296 299
297int xenvif_dealloc_kthread(void *data); 300int xenvif_dealloc_kthread(void *data);
298 301
302void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb);
303
299/* Determine whether the needed number of slots (req) are available, 304/* Determine whether the needed number of slots (req) are available,
300 * and set req_event if not. 305 * and set req_event if not.
301 */ 306 */
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index f379689dde30..895fe84011e7 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -43,6 +43,9 @@
43#define XENVIF_QUEUE_LENGTH 32 43#define XENVIF_QUEUE_LENGTH 32
44#define XENVIF_NAPI_WEIGHT 64 44#define XENVIF_NAPI_WEIGHT 64
45 45
46/* Number of bytes allowed on the internal guest Rx queue. */
47#define XENVIF_RX_QUEUE_BYTES (XEN_NETIF_RX_RING_SIZE/2 * PAGE_SIZE)
48
46/* This function is used to set SKBTX_DEV_ZEROCOPY as well as 49/* This function is used to set SKBTX_DEV_ZEROCOPY as well as
47 * increasing the inflight counter. We need to increase the inflight 50 * increasing the inflight counter. We need to increase the inflight
48 * counter because core driver calls into xenvif_zerocopy_callback 51 * counter because core driver calls into xenvif_zerocopy_callback
@@ -60,20 +63,11 @@ void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue)
60 atomic_dec(&queue->inflight_packets); 63 atomic_dec(&queue->inflight_packets);
61} 64}
62 65
63static inline void xenvif_stop_queue(struct xenvif_queue *queue)
64{
65 struct net_device *dev = queue->vif->dev;
66
67 if (!queue->vif->can_queue)
68 return;
69
70 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id));
71}
72
73int xenvif_schedulable(struct xenvif *vif) 66int xenvif_schedulable(struct xenvif *vif)
74{ 67{
75 return netif_running(vif->dev) && 68 return netif_running(vif->dev) &&
76 test_bit(VIF_STATUS_CONNECTED, &vif->status); 69 test_bit(VIF_STATUS_CONNECTED, &vif->status) &&
70 !vif->disabled;
77} 71}
78 72
79static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) 73static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id)
@@ -114,16 +108,7 @@ int xenvif_poll(struct napi_struct *napi, int budget)
114static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id) 108static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id)
115{ 109{
116 struct xenvif_queue *queue = dev_id; 110 struct xenvif_queue *queue = dev_id;
117 struct netdev_queue *net_queue =
118 netdev_get_tx_queue(queue->vif->dev, queue->id);
119 111
120 /* QUEUE_STATUS_RX_PURGE_EVENT is only set if either QDisc was off OR
121 * the carrier went down and this queue was previously blocked
122 */
123 if (unlikely(netif_tx_queue_stopped(net_queue) ||
124 (!netif_carrier_ok(queue->vif->dev) &&
125 test_bit(QUEUE_STATUS_RX_STALLED, &queue->status))))
126 set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status);
127 xenvif_kick_thread(queue); 112 xenvif_kick_thread(queue);
128 113
129 return IRQ_HANDLED; 114 return IRQ_HANDLED;
@@ -151,24 +136,13 @@ void xenvif_wake_queue(struct xenvif_queue *queue)
151 netif_tx_wake_queue(netdev_get_tx_queue(dev, id)); 136 netif_tx_wake_queue(netdev_get_tx_queue(dev, id));
152} 137}
153 138
154/* Callback to wake the queue's thread and turn the carrier off on timeout */
155static void xenvif_rx_stalled(unsigned long data)
156{
157 struct xenvif_queue *queue = (struct xenvif_queue *)data;
158
159 if (xenvif_queue_stopped(queue)) {
160 set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status);
161 xenvif_kick_thread(queue);
162 }
163}
164
165static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) 139static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
166{ 140{
167 struct xenvif *vif = netdev_priv(dev); 141 struct xenvif *vif = netdev_priv(dev);
168 struct xenvif_queue *queue = NULL; 142 struct xenvif_queue *queue = NULL;
169 unsigned int num_queues = vif->num_queues; 143 unsigned int num_queues = vif->num_queues;
170 u16 index; 144 u16 index;
171 int min_slots_needed; 145 struct xenvif_rx_cb *cb;
172 146
173 BUG_ON(skb->dev != dev); 147 BUG_ON(skb->dev != dev);
174 148
@@ -191,30 +165,10 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
191 !xenvif_schedulable(vif)) 165 !xenvif_schedulable(vif))
192 goto drop; 166 goto drop;
193 167
194 /* At best we'll need one slot for the header and one for each 168 cb = XENVIF_RX_CB(skb);
195 * frag. 169 cb->expires = jiffies + rx_drain_timeout_jiffies;
196 */
197 min_slots_needed = 1 + skb_shinfo(skb)->nr_frags;
198
199 /* If the skb is GSO then we'll also need an extra slot for the
200 * metadata.
201 */
202 if (skb_is_gso(skb))
203 min_slots_needed++;
204 170
205 /* If the skb can't possibly fit in the remaining slots 171 xenvif_rx_queue_tail(queue, skb);
206 * then turn off the queue to give the ring a chance to
207 * drain.
208 */
209 if (!xenvif_rx_ring_slots_available(queue, min_slots_needed)) {
210 queue->rx_stalled.function = xenvif_rx_stalled;
211 queue->rx_stalled.data = (unsigned long)queue;
212 xenvif_stop_queue(queue);
213 mod_timer(&queue->rx_stalled,
214 jiffies + rx_drain_timeout_jiffies);
215 }
216
217 skb_queue_tail(&queue->rx_queue, skb);
218 xenvif_kick_thread(queue); 172 xenvif_kick_thread(queue);
219 173
220 return NETDEV_TX_OK; 174 return NETDEV_TX_OK;
@@ -465,6 +419,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
465 vif->queues = NULL; 419 vif->queues = NULL;
466 vif->num_queues = 0; 420 vif->num_queues = 0;
467 421
422 spin_lock_init(&vif->lock);
423
468 dev->netdev_ops = &xenvif_netdev_ops; 424 dev->netdev_ops = &xenvif_netdev_ops;
469 dev->hw_features = NETIF_F_SG | 425 dev->hw_features = NETIF_F_SG |
470 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 426 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
@@ -508,6 +464,8 @@ int xenvif_init_queue(struct xenvif_queue *queue)
508 init_timer(&queue->credit_timeout); 464 init_timer(&queue->credit_timeout);
509 queue->credit_window_start = get_jiffies_64(); 465 queue->credit_window_start = get_jiffies_64();
510 466
467 queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES;
468
511 skb_queue_head_init(&queue->rx_queue); 469 skb_queue_head_init(&queue->rx_queue);
512 skb_queue_head_init(&queue->tx_queue); 470 skb_queue_head_init(&queue->tx_queue);
513 471
@@ -539,8 +497,6 @@ int xenvif_init_queue(struct xenvif_queue *queue)
539 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; 497 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE;
540 } 498 }
541 499
542 init_timer(&queue->rx_stalled);
543
544 return 0; 500 return 0;
545} 501}
546 502
@@ -551,7 +507,6 @@ void xenvif_carrier_on(struct xenvif *vif)
551 dev_set_mtu(vif->dev, ETH_DATA_LEN); 507 dev_set_mtu(vif->dev, ETH_DATA_LEN);
552 netdev_update_features(vif->dev); 508 netdev_update_features(vif->dev);
553 set_bit(VIF_STATUS_CONNECTED, &vif->status); 509 set_bit(VIF_STATUS_CONNECTED, &vif->status);
554 netif_carrier_on(vif->dev);
555 if (netif_running(vif->dev)) 510 if (netif_running(vif->dev))
556 xenvif_up(vif); 511 xenvif_up(vif);
557 rtnl_unlock(); 512 rtnl_unlock();
@@ -611,6 +566,8 @@ int xenvif_connect(struct xenvif_queue *queue, unsigned long tx_ring_ref,
611 disable_irq(queue->rx_irq); 566 disable_irq(queue->rx_irq);
612 } 567 }
613 568
569 queue->stalled = true;
570
614 task = kthread_create(xenvif_kthread_guest_rx, 571 task = kthread_create(xenvif_kthread_guest_rx,
615 (void *)queue, "%s-guest-rx", queue->name); 572 (void *)queue, "%s-guest-rx", queue->name);
616 if (IS_ERR(task)) { 573 if (IS_ERR(task)) {
@@ -674,7 +631,6 @@ void xenvif_disconnect(struct xenvif *vif)
674 netif_napi_del(&queue->napi); 631 netif_napi_del(&queue->napi);
675 632
676 if (queue->task) { 633 if (queue->task) {
677 del_timer_sync(&queue->rx_stalled);
678 kthread_stop(queue->task); 634 kthread_stop(queue->task);
679 queue->task = NULL; 635 queue->task = NULL;
680 } 636 }
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 08f65996534c..6563f0713fc0 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -55,13 +55,20 @@
55bool separate_tx_rx_irq = 1; 55bool separate_tx_rx_irq = 1;
56module_param(separate_tx_rx_irq, bool, 0644); 56module_param(separate_tx_rx_irq, bool, 0644);
57 57
58/* When guest ring is filled up, qdisc queues the packets for us, but we have 58/* The time that packets can stay on the guest Rx internal queue
59 * to timeout them, otherwise other guests' packets can get stuck there 59 * before they are dropped.
60 */ 60 */
61unsigned int rx_drain_timeout_msecs = 10000; 61unsigned int rx_drain_timeout_msecs = 10000;
62module_param(rx_drain_timeout_msecs, uint, 0444); 62module_param(rx_drain_timeout_msecs, uint, 0444);
63unsigned int rx_drain_timeout_jiffies; 63unsigned int rx_drain_timeout_jiffies;
64 64
65/* The length of time before the frontend is considered unresponsive
66 * because it isn't providing Rx slots.
67 */
68static unsigned int rx_stall_timeout_msecs = 60000;
69module_param(rx_stall_timeout_msecs, uint, 0444);
70static unsigned int rx_stall_timeout_jiffies;
71
65unsigned int xenvif_max_queues; 72unsigned int xenvif_max_queues;
66module_param_named(max_queues, xenvif_max_queues, uint, 0644); 73module_param_named(max_queues, xenvif_max_queues, uint, 0644);
67MODULE_PARM_DESC(max_queues, 74MODULE_PARM_DESC(max_queues,
@@ -83,7 +90,6 @@ static void make_tx_response(struct xenvif_queue *queue,
83 s8 st); 90 s8 st);
84 91
85static inline int tx_work_todo(struct xenvif_queue *queue); 92static inline int tx_work_todo(struct xenvif_queue *queue);
86static inline int rx_work_todo(struct xenvif_queue *queue);
87 93
88static struct xen_netif_rx_response *make_rx_response(struct xenvif_queue *queue, 94static struct xen_netif_rx_response *make_rx_response(struct xenvif_queue *queue,
89 u16 id, 95 u16 id,
@@ -163,6 +169,69 @@ bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue, int needed)
163 return false; 169 return false;
164} 170}
165 171
172void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb)
173{
174 unsigned long flags;
175
176 spin_lock_irqsave(&queue->rx_queue.lock, flags);
177
178 __skb_queue_tail(&queue->rx_queue, skb);
179
180 queue->rx_queue_len += skb->len;
181 if (queue->rx_queue_len > queue->rx_queue_max)
182 netif_tx_stop_queue(netdev_get_tx_queue(queue->vif->dev, queue->id));
183
184 spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
185}
186
187static struct sk_buff *xenvif_rx_dequeue(struct xenvif_queue *queue)
188{
189 struct sk_buff *skb;
190
191 spin_lock_irq(&queue->rx_queue.lock);
192
193 skb = __skb_dequeue(&queue->rx_queue);
194 if (skb)
195 queue->rx_queue_len -= skb->len;
196
197 spin_unlock_irq(&queue->rx_queue.lock);
198
199 return skb;
200}
201
202static void xenvif_rx_queue_maybe_wake(struct xenvif_queue *queue)
203{
204 spin_lock_irq(&queue->rx_queue.lock);
205
206 if (queue->rx_queue_len < queue->rx_queue_max)
207 netif_tx_wake_queue(netdev_get_tx_queue(queue->vif->dev, queue->id));
208
209 spin_unlock_irq(&queue->rx_queue.lock);
210}
211
212
213static void xenvif_rx_queue_purge(struct xenvif_queue *queue)
214{
215 struct sk_buff *skb;
216 while ((skb = xenvif_rx_dequeue(queue)) != NULL)
217 kfree_skb(skb);
218}
219
220static void xenvif_rx_queue_drop_expired(struct xenvif_queue *queue)
221{
222 struct sk_buff *skb;
223
224 for(;;) {
225 skb = skb_peek(&queue->rx_queue);
226 if (!skb)
227 break;
228 if (time_before(jiffies, XENVIF_RX_CB(skb)->expires))
229 break;
230 xenvif_rx_dequeue(queue);
231 kfree_skb(skb);
232 }
233}
234
166/* 235/*
167 * Returns true if we should start a new receive buffer instead of 236 * Returns true if we should start a new receive buffer instead of
168 * adding 'size' bytes to a buffer which currently contains 'offset' 237 * adding 'size' bytes to a buffer which currently contains 'offset'
@@ -237,13 +306,6 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif_queue *queue,
237 return meta; 306 return meta;
238} 307}
239 308
240struct xenvif_rx_cb {
241 int meta_slots_used;
242 bool full_coalesce;
243};
244
245#define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb)
246
247/* 309/*
248 * Set up the grant operations for this fragment. If it's a flipping 310 * Set up the grant operations for this fragment. If it's a flipping
249 * interface, we also set up the unmap request from here. 311 * interface, we also set up the unmap request from here.
@@ -587,12 +649,15 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
587 649
588 skb_queue_head_init(&rxq); 650 skb_queue_head_init(&rxq);
589 651
590 while ((skb = skb_dequeue(&queue->rx_queue)) != NULL) { 652 while (xenvif_rx_ring_slots_available(queue, XEN_NETBK_RX_SLOTS_MAX)
653 && (skb = xenvif_rx_dequeue(queue)) != NULL) {
591 RING_IDX max_slots_needed; 654 RING_IDX max_slots_needed;
592 RING_IDX old_req_cons; 655 RING_IDX old_req_cons;
593 RING_IDX ring_slots_used; 656 RING_IDX ring_slots_used;
594 int i; 657 int i;
595 658
659 queue->last_rx_time = jiffies;
660
596 /* We need a cheap worse case estimate for the number of 661 /* We need a cheap worse case estimate for the number of
597 * slots we'll use. 662 * slots we'll use.
598 */ 663 */
@@ -634,15 +699,6 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
634 skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)) 699 skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6))
635 max_slots_needed++; 700 max_slots_needed++;
636 701
637 /* If the skb may not fit then bail out now */
638 if (!xenvif_rx_ring_slots_available(queue, max_slots_needed)) {
639 skb_queue_head(&queue->rx_queue, skb);
640 need_to_notify = true;
641 queue->rx_last_skb_slots = max_slots_needed;
642 break;
643 } else
644 queue->rx_last_skb_slots = 0;
645
646 old_req_cons = queue->rx.req_cons; 702 old_req_cons = queue->rx.req_cons;
647 XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo, queue); 703 XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo, queue);
648 ring_slots_used = queue->rx.req_cons - old_req_cons; 704 ring_slots_used = queue->rx.req_cons - old_req_cons;
@@ -1869,12 +1925,6 @@ void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx)
1869 } 1925 }
1870} 1926}
1871 1927
1872static inline int rx_work_todo(struct xenvif_queue *queue)
1873{
1874 return (!skb_queue_empty(&queue->rx_queue) &&
1875 xenvif_rx_ring_slots_available(queue, queue->rx_last_skb_slots));
1876}
1877
1878static inline int tx_work_todo(struct xenvif_queue *queue) 1928static inline int tx_work_todo(struct xenvif_queue *queue)
1879{ 1929{
1880 if (likely(RING_HAS_UNCONSUMED_REQUESTS(&queue->tx))) 1930 if (likely(RING_HAS_UNCONSUMED_REQUESTS(&queue->tx)))
@@ -1931,92 +1981,121 @@ err:
1931 return err; 1981 return err;
1932} 1982}
1933 1983
1934static void xenvif_start_queue(struct xenvif_queue *queue) 1984static void xenvif_queue_carrier_off(struct xenvif_queue *queue)
1935{ 1985{
1936 if (xenvif_schedulable(queue->vif)) 1986 struct xenvif *vif = queue->vif;
1937 xenvif_wake_queue(queue); 1987
1988 queue->stalled = true;
1989
1990 /* At least one queue has stalled? Disable the carrier. */
1991 spin_lock(&vif->lock);
1992 if (vif->stalled_queues++ == 0) {
1993 netdev_info(vif->dev, "Guest Rx stalled");
1994 netif_carrier_off(vif->dev);
1995 }
1996 spin_unlock(&vif->lock);
1938} 1997}
1939 1998
1940/* Only called from the queue's thread, it handles the situation when the guest 1999static void xenvif_queue_carrier_on(struct xenvif_queue *queue)
1941 * doesn't post enough requests on the receiving ring.
1942 * First xenvif_start_xmit disables QDisc and start a timer, and then either the
1943 * timer fires, or the guest send an interrupt after posting new request. If it
1944 * is the timer, the carrier is turned off here.
1945 * */
1946static void xenvif_rx_purge_event(struct xenvif_queue *queue)
1947{ 2000{
1948 /* Either the last unsuccesful skb or at least 1 slot should fit */ 2001 struct xenvif *vif = queue->vif;
1949 int needed = queue->rx_last_skb_slots ?
1950 queue->rx_last_skb_slots : 1;
1951 2002
1952 /* It is assumed that if the guest post new slots after this, the RX 2003 queue->last_rx_time = jiffies; /* Reset Rx stall detection. */
1953 * interrupt will set the QUEUE_STATUS_RX_PURGE_EVENT bit and wake up 2004 queue->stalled = false;
1954 * the thread again
1955 */
1956 set_bit(QUEUE_STATUS_RX_STALLED, &queue->status);
1957 if (!xenvif_rx_ring_slots_available(queue, needed)) {
1958 rtnl_lock();
1959 if (netif_carrier_ok(queue->vif->dev)) {
1960 /* Timer fired and there are still no slots. Turn off
1961 * everything except the interrupts
1962 */
1963 netif_carrier_off(queue->vif->dev);
1964 skb_queue_purge(&queue->rx_queue);
1965 queue->rx_last_skb_slots = 0;
1966 if (net_ratelimit())
1967 netdev_err(queue->vif->dev, "Carrier off due to lack of guest response on queue %d\n", queue->id);
1968 } else {
1969 /* Probably an another queue already turned the carrier
1970 * off, make sure nothing is stucked in the internal
1971 * queue of this queue
1972 */
1973 skb_queue_purge(&queue->rx_queue);
1974 queue->rx_last_skb_slots = 0;
1975 }
1976 rtnl_unlock();
1977 } else if (!netif_carrier_ok(queue->vif->dev)) {
1978 unsigned int num_queues = queue->vif->num_queues;
1979 unsigned int i;
1980 /* The carrier was down, but an interrupt kicked
1981 * the thread again after new requests were
1982 * posted
1983 */
1984 clear_bit(QUEUE_STATUS_RX_STALLED,
1985 &queue->status);
1986 rtnl_lock();
1987 netif_carrier_on(queue->vif->dev);
1988 netif_tx_wake_all_queues(queue->vif->dev);
1989 rtnl_unlock();
1990 2005
1991 for (i = 0; i < num_queues; i++) { 2006 /* All queues are ready? Enable the carrier. */
1992 struct xenvif_queue *temp = &queue->vif->queues[i]; 2007 spin_lock(&vif->lock);
2008 if (--vif->stalled_queues == 0) {
2009 netdev_info(vif->dev, "Guest Rx ready");
2010 netif_carrier_on(vif->dev);
2011 }
2012 spin_unlock(&vif->lock);
2013}
1993 2014
1994 xenvif_napi_schedule_or_enable_events(temp); 2015static bool xenvif_rx_queue_stalled(struct xenvif_queue *queue)
1995 } 2016{
1996 if (net_ratelimit()) 2017 RING_IDX prod, cons;
1997 netdev_err(queue->vif->dev, "Carrier on again\n"); 2018
1998 } else { 2019 prod = queue->rx.sring->req_prod;
1999 /* Queuing were stopped, but the guest posted 2020 cons = queue->rx.req_cons;
2000 * new requests and sent an interrupt 2021
2001 */ 2022 return !queue->stalled
2002 clear_bit(QUEUE_STATUS_RX_STALLED, 2023 && prod - cons < XEN_NETBK_RX_SLOTS_MAX
2003 &queue->status); 2024 && time_after(jiffies,
2004 del_timer_sync(&queue->rx_stalled); 2025 queue->last_rx_time + rx_stall_timeout_jiffies);
2005 xenvif_start_queue(queue); 2026}
2027
2028static bool xenvif_rx_queue_ready(struct xenvif_queue *queue)
2029{
2030 RING_IDX prod, cons;
2031
2032 prod = queue->rx.sring->req_prod;
2033 cons = queue->rx.req_cons;
2034
2035 return queue->stalled
2036 && prod - cons >= XEN_NETBK_RX_SLOTS_MAX;
2037}
2038
2039static bool xenvif_have_rx_work(struct xenvif_queue *queue)
2040{
2041 return (!skb_queue_empty(&queue->rx_queue)
2042 && xenvif_rx_ring_slots_available(queue, XEN_NETBK_RX_SLOTS_MAX))
2043 || xenvif_rx_queue_stalled(queue)
2044 || xenvif_rx_queue_ready(queue)
2045 || kthread_should_stop()
2046 || queue->vif->disabled;
2047}
2048
2049static long xenvif_rx_queue_timeout(struct xenvif_queue *queue)
2050{
2051 struct sk_buff *skb;
2052 long timeout;
2053
2054 skb = skb_peek(&queue->rx_queue);
2055 if (!skb)
2056 return MAX_SCHEDULE_TIMEOUT;
2057
2058 timeout = XENVIF_RX_CB(skb)->expires - jiffies;
2059 return timeout < 0 ? 0 : timeout;
2060}
2061
2062/* Wait until the guest Rx thread has work.
2063 *
2064 * The timeout needs to be adjusted based on the current head of the
2065 * queue (and not just the head at the beginning). In particular, if
2066 * the queue is initially empty an infinite timeout is used and this
2067 * needs to be reduced when a skb is queued.
2068 *
2069 * This cannot be done with wait_event_timeout() because it only
2070 * calculates the timeout once.
2071 */
2072static void xenvif_wait_for_rx_work(struct xenvif_queue *queue)
2073{
2074 DEFINE_WAIT(wait);
2075
2076 if (xenvif_have_rx_work(queue))
2077 return;
2078
2079 for (;;) {
2080 long ret;
2081
2082 prepare_to_wait(&queue->wq, &wait, TASK_INTERRUPTIBLE);
2083 if (xenvif_have_rx_work(queue))
2084 break;
2085 ret = schedule_timeout(xenvif_rx_queue_timeout(queue));
2086 if (!ret)
2087 break;
2006 } 2088 }
2089 finish_wait(&queue->wq, &wait);
2007} 2090}
2008 2091
2009int xenvif_kthread_guest_rx(void *data) 2092int xenvif_kthread_guest_rx(void *data)
2010{ 2093{
2011 struct xenvif_queue *queue = data; 2094 struct xenvif_queue *queue = data;
2012 struct sk_buff *skb; 2095 struct xenvif *vif = queue->vif;
2013 2096
2014 while (!kthread_should_stop()) { 2097 for (;;) {
2015 wait_event_interruptible(queue->wq, 2098 xenvif_wait_for_rx_work(queue);
2016 rx_work_todo(queue) ||
2017 queue->vif->disabled ||
2018 test_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status) ||
2019 kthread_should_stop());
2020 2099
2021 if (kthread_should_stop()) 2100 if (kthread_should_stop())
2022 break; 2101 break;
@@ -2028,35 +2107,38 @@ int xenvif_kthread_guest_rx(void *data)
2028 * context so we defer it here, if this thread is 2107 * context so we defer it here, if this thread is
2029 * associated with queue 0. 2108 * associated with queue 0.
2030 */ 2109 */
2031 if (unlikely(queue->vif->disabled && queue->id == 0)) { 2110 if (unlikely(vif->disabled && queue->id == 0)) {
2032 xenvif_carrier_off(queue->vif); 2111 xenvif_carrier_off(vif);
2033 } else if (unlikely(queue->vif->disabled)) { 2112 xenvif_rx_queue_purge(queue);
2034 /* kthread_stop() would be called upon this thread soon, 2113 continue;
2035 * be a bit proactive
2036 */
2037 skb_queue_purge(&queue->rx_queue);
2038 queue->rx_last_skb_slots = 0;
2039 } else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT,
2040 &queue->status))) {
2041 xenvif_rx_purge_event(queue);
2042 } else if (!netif_carrier_ok(queue->vif->dev)) {
2043 /* Another queue stalled and turned the carrier off, so
2044 * purge the internal queue of queues which were not
2045 * blocked
2046 */
2047 skb_queue_purge(&queue->rx_queue);
2048 queue->rx_last_skb_slots = 0;
2049 } 2114 }
2050 2115
2051 if (!skb_queue_empty(&queue->rx_queue)) 2116 if (!skb_queue_empty(&queue->rx_queue))
2052 xenvif_rx_action(queue); 2117 xenvif_rx_action(queue);
2053 2118
2119 /* If the guest hasn't provided any Rx slots for a
2120 * while it's probably not responsive, drop the
2121 * carrier so packets are dropped earlier.
2122 */
2123 if (xenvif_rx_queue_stalled(queue))
2124 xenvif_queue_carrier_off(queue);
2125 else if (xenvif_rx_queue_ready(queue))
2126 xenvif_queue_carrier_on(queue);
2127
2128 /* Queued packets may have foreign pages from other
2129 * domains. These cannot be queued indefinitely as
2130 * this would starve guests of grant refs and transmit
2131 * slots.
2132 */
2133 xenvif_rx_queue_drop_expired(queue);
2134
2135 xenvif_rx_queue_maybe_wake(queue);
2136
2054 cond_resched(); 2137 cond_resched();
2055 } 2138 }
2056 2139
2057 /* Bin any remaining skbs */ 2140 /* Bin any remaining skbs */
2058 while ((skb = skb_dequeue(&queue->rx_queue)) != NULL) 2141 xenvif_rx_queue_purge(queue);
2059 dev_kfree_skb(skb);
2060 2142
2061 return 0; 2143 return 0;
2062} 2144}
@@ -2113,6 +2195,7 @@ static int __init netback_init(void)
2113 goto failed_init; 2195 goto failed_init;
2114 2196
2115 rx_drain_timeout_jiffies = msecs_to_jiffies(rx_drain_timeout_msecs); 2197 rx_drain_timeout_jiffies = msecs_to_jiffies(rx_drain_timeout_msecs);
2198 rx_stall_timeout_jiffies = msecs_to_jiffies(rx_stall_timeout_msecs);
2116 2199
2117#ifdef CONFIG_DEBUG_FS 2200#ifdef CONFIG_DEBUG_FS
2118 xen_netback_dbg_root = debugfs_create_dir("xen-netback", NULL); 2201 xen_netback_dbg_root = debugfs_create_dir("xen-netback", NULL);
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 8079c31ac5e6..4e56a27f9689 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -52,6 +52,7 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
52 struct xenvif_queue *queue = m->private; 52 struct xenvif_queue *queue = m->private;
53 struct xen_netif_tx_back_ring *tx_ring = &queue->tx; 53 struct xen_netif_tx_back_ring *tx_ring = &queue->tx;
54 struct xen_netif_rx_back_ring *rx_ring = &queue->rx; 54 struct xen_netif_rx_back_ring *rx_ring = &queue->rx;
55 struct netdev_queue *dev_queue;
55 56
56 if (tx_ring->sring) { 57 if (tx_ring->sring) {
57 struct xen_netif_tx_sring *sring = tx_ring->sring; 58 struct xen_netif_tx_sring *sring = tx_ring->sring;
@@ -112,6 +113,13 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
112 queue->credit_timeout.expires, 113 queue->credit_timeout.expires,
113 jiffies); 114 jiffies);
114 115
116 dev_queue = netdev_get_tx_queue(queue->vif->dev, queue->id);
117
118 seq_printf(m, "\nRx internal queue: len %u max %u pkts %u %s\n",
119 queue->rx_queue_len, queue->rx_queue_max,
120 skb_queue_len(&queue->rx_queue),
121 netif_tx_queue_stopped(dev_queue) ? "stopped" : "running");
122
115 return 0; 123 return 0;
116} 124}
117 125
@@ -703,6 +711,7 @@ static void connect(struct backend_info *be)
703 be->vif->queues = vzalloc(requested_num_queues * 711 be->vif->queues = vzalloc(requested_num_queues *
704 sizeof(struct xenvif_queue)); 712 sizeof(struct xenvif_queue));
705 be->vif->num_queues = requested_num_queues; 713 be->vif->num_queues = requested_num_queues;
714 be->vif->stalled_queues = requested_num_queues;
706 715
707 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) { 716 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) {
708 queue = &be->vif->queues[queue_index]; 717 queue = &be->vif->queues[queue_index];
@@ -873,15 +882,10 @@ static int read_xenbus_vif_flags(struct backend_info *be)
873 if (!rx_copy) 882 if (!rx_copy)
874 return -EOPNOTSUPP; 883 return -EOPNOTSUPP;
875 884
876 if (vif->dev->tx_queue_len != 0) { 885 if (xenbus_scanf(XBT_NIL, dev->otherend,
877 if (xenbus_scanf(XBT_NIL, dev->otherend, 886 "feature-rx-notify", "%d", &val) < 0 || val == 0) {
878 "feature-rx-notify", "%d", &val) < 0) 887 xenbus_dev_fatal(dev, -EINVAL, "feature-rx-notify is mandatory");
879 val = 0; 888 return -EINVAL;
880 if (val)
881 vif->can_queue = 1;
882 else
883 /* Must be non-zero for pfifo_fast to work. */
884 vif->dev->tx_queue_len = 1;
885 } 889 }
886 890
887 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", 891 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 2305dc0382bc..3823edf2d012 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1280,52 +1280,6 @@ int of_property_read_string(struct device_node *np, const char *propname,
1280EXPORT_SYMBOL_GPL(of_property_read_string); 1280EXPORT_SYMBOL_GPL(of_property_read_string);
1281 1281
1282/** 1282/**
1283 * of_property_read_string_index - Find and read a string from a multiple
1284 * strings property.
1285 * @np: device node from which the property value is to be read.
1286 * @propname: name of the property to be searched.
1287 * @index: index of the string in the list of strings
1288 * @out_string: pointer to null terminated return string, modified only if
1289 * return value is 0.
1290 *
1291 * Search for a property in a device tree node and retrieve a null
1292 * terminated string value (pointer to data, not a copy) in the list of strings
1293 * contained in that property.
1294 * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
1295 * property does not have a value, and -EILSEQ if the string is not
1296 * null-terminated within the length of the property data.
1297 *
1298 * The out_string pointer is modified only if a valid string can be decoded.
1299 */
1300int of_property_read_string_index(struct device_node *np, const char *propname,
1301 int index, const char **output)
1302{
1303 struct property *prop = of_find_property(np, propname, NULL);
1304 int i = 0;
1305 size_t l = 0, total = 0;
1306 const char *p;
1307
1308 if (!prop)
1309 return -EINVAL;
1310 if (!prop->value)
1311 return -ENODATA;
1312 if (strnlen(prop->value, prop->length) >= prop->length)
1313 return -EILSEQ;
1314
1315 p = prop->value;
1316
1317 for (i = 0; total < prop->length; total += l, p += l) {
1318 l = strlen(p) + 1;
1319 if (i++ == index) {
1320 *output = p;
1321 return 0;
1322 }
1323 }
1324 return -ENODATA;
1325}
1326EXPORT_SYMBOL_GPL(of_property_read_string_index);
1327
1328/**
1329 * of_property_match_string() - Find string in a list and return index 1283 * of_property_match_string() - Find string in a list and return index
1330 * @np: pointer to node containing string list property 1284 * @np: pointer to node containing string list property
1331 * @propname: string list property name 1285 * @propname: string list property name
@@ -1351,7 +1305,7 @@ int of_property_match_string(struct device_node *np, const char *propname,
1351 end = p + prop->length; 1305 end = p + prop->length;
1352 1306
1353 for (i = 0; p < end; i++, p += l) { 1307 for (i = 0; p < end; i++, p += l) {
1354 l = strlen(p) + 1; 1308 l = strnlen(p, end - p) + 1;
1355 if (p + l > end) 1309 if (p + l > end)
1356 return -EILSEQ; 1310 return -EILSEQ;
1357 pr_debug("comparing %s with %s\n", string, p); 1311 pr_debug("comparing %s with %s\n", string, p);
@@ -1363,39 +1317,41 @@ int of_property_match_string(struct device_node *np, const char *propname,
1363EXPORT_SYMBOL_GPL(of_property_match_string); 1317EXPORT_SYMBOL_GPL(of_property_match_string);
1364 1318
1365/** 1319/**
1366 * of_property_count_strings - Find and return the number of strings from a 1320 * of_property_read_string_util() - Utility helper for parsing string properties
1367 * multiple strings property.
1368 * @np: device node from which the property value is to be read. 1321 * @np: device node from which the property value is to be read.
1369 * @propname: name of the property to be searched. 1322 * @propname: name of the property to be searched.
1323 * @out_strs: output array of string pointers.
1324 * @sz: number of array elements to read.
1325 * @skip: Number of strings to skip over at beginning of list.
1370 * 1326 *
1371 * Search for a property in a device tree node and retrieve the number of null 1327 * Don't call this function directly. It is a utility helper for the
1372 * terminated string contain in it. Returns the number of strings on 1328 * of_property_read_string*() family of functions.
1373 * success, -EINVAL if the property does not exist, -ENODATA if property
1374 * does not have a value, and -EILSEQ if the string is not null-terminated
1375 * within the length of the property data.
1376 */ 1329 */
1377int of_property_count_strings(struct device_node *np, const char *propname) 1330int of_property_read_string_helper(struct device_node *np, const char *propname,
1331 const char **out_strs, size_t sz, int skip)
1378{ 1332{
1379 struct property *prop = of_find_property(np, propname, NULL); 1333 struct property *prop = of_find_property(np, propname, NULL);
1380 int i = 0; 1334 int l = 0, i = 0;
1381 size_t l = 0, total = 0; 1335 const char *p, *end;
1382 const char *p;
1383 1336
1384 if (!prop) 1337 if (!prop)
1385 return -EINVAL; 1338 return -EINVAL;
1386 if (!prop->value) 1339 if (!prop->value)
1387 return -ENODATA; 1340 return -ENODATA;
1388 if (strnlen(prop->value, prop->length) >= prop->length)
1389 return -EILSEQ;
1390
1391 p = prop->value; 1341 p = prop->value;
1342 end = p + prop->length;
1392 1343
1393 for (i = 0; total < prop->length; total += l, p += l, i++) 1344 for (i = 0; p < end && (!out_strs || i < skip + sz); i++, p += l) {
1394 l = strlen(p) + 1; 1345 l = strnlen(p, end - p) + 1;
1395 1346 if (p + l > end)
1396 return i; 1347 return -EILSEQ;
1348 if (out_strs && i >= skip)
1349 *out_strs++ = p;
1350 }
1351 i -= skip;
1352 return i <= 0 ? -ENODATA : i;
1397} 1353}
1398EXPORT_SYMBOL_GPL(of_property_count_strings); 1354EXPORT_SYMBOL_GPL(of_property_read_string_helper);
1399 1355
1400void of_print_phandle_args(const char *msg, const struct of_phandle_args *args) 1356void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)
1401{ 1357{
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 59fb12e84e6b..dc566b38645f 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -243,23 +243,27 @@ static inline struct reserved_mem *__find_rmem(struct device_node *node)
243 * This function assign memory region pointed by "memory-region" device tree 243 * This function assign memory region pointed by "memory-region" device tree
244 * property to the given device. 244 * property to the given device.
245 */ 245 */
246void of_reserved_mem_device_init(struct device *dev) 246int of_reserved_mem_device_init(struct device *dev)
247{ 247{
248 struct reserved_mem *rmem; 248 struct reserved_mem *rmem;
249 struct device_node *np; 249 struct device_node *np;
250 int ret;
250 251
251 np = of_parse_phandle(dev->of_node, "memory-region", 0); 252 np = of_parse_phandle(dev->of_node, "memory-region", 0);
252 if (!np) 253 if (!np)
253 return; 254 return -ENODEV;
254 255
255 rmem = __find_rmem(np); 256 rmem = __find_rmem(np);
256 of_node_put(np); 257 of_node_put(np);
257 258
258 if (!rmem || !rmem->ops || !rmem->ops->device_init) 259 if (!rmem || !rmem->ops || !rmem->ops->device_init)
259 return; 260 return -EINVAL;
261
262 ret = rmem->ops->device_init(rmem, dev);
263 if (ret == 0)
264 dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
260 265
261 rmem->ops->device_init(rmem, dev); 266 return ret;
262 dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
263} 267}
264 268
265/** 269/**
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index 78001270a598..11b873c54a77 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -339,8 +339,9 @@ static void __init of_selftest_parse_phandle_with_args(void)
339 selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); 339 selftest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc);
340} 340}
341 341
342static void __init of_selftest_property_match_string(void) 342static void __init of_selftest_property_string(void)
343{ 343{
344 const char *strings[4];
344 struct device_node *np; 345 struct device_node *np;
345 int rc; 346 int rc;
346 347
@@ -357,13 +358,66 @@ static void __init of_selftest_property_match_string(void)
357 rc = of_property_match_string(np, "phandle-list-names", "third"); 358 rc = of_property_match_string(np, "phandle-list-names", "third");
358 selftest(rc == 2, "third expected:0 got:%i\n", rc); 359 selftest(rc == 2, "third expected:0 got:%i\n", rc);
359 rc = of_property_match_string(np, "phandle-list-names", "fourth"); 360 rc = of_property_match_string(np, "phandle-list-names", "fourth");
360 selftest(rc == -ENODATA, "unmatched string; rc=%i", rc); 361 selftest(rc == -ENODATA, "unmatched string; rc=%i\n", rc);
361 rc = of_property_match_string(np, "missing-property", "blah"); 362 rc = of_property_match_string(np, "missing-property", "blah");
362 selftest(rc == -EINVAL, "missing property; rc=%i", rc); 363 selftest(rc == -EINVAL, "missing property; rc=%i\n", rc);
363 rc = of_property_match_string(np, "empty-property", "blah"); 364 rc = of_property_match_string(np, "empty-property", "blah");
364 selftest(rc == -ENODATA, "empty property; rc=%i", rc); 365 selftest(rc == -ENODATA, "empty property; rc=%i\n", rc);
365 rc = of_property_match_string(np, "unterminated-string", "blah"); 366 rc = of_property_match_string(np, "unterminated-string", "blah");
366 selftest(rc == -EILSEQ, "unterminated string; rc=%i", rc); 367 selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
368
369 /* of_property_count_strings() tests */
370 rc = of_property_count_strings(np, "string-property");
371 selftest(rc == 1, "Incorrect string count; rc=%i\n", rc);
372 rc = of_property_count_strings(np, "phandle-list-names");
373 selftest(rc == 3, "Incorrect string count; rc=%i\n", rc);
374 rc = of_property_count_strings(np, "unterminated-string");
375 selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
376 rc = of_property_count_strings(np, "unterminated-string-list");
377 selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
378
379 /* of_property_read_string_index() tests */
380 rc = of_property_read_string_index(np, "string-property", 0, strings);
381 selftest(rc == 0 && !strcmp(strings[0], "foobar"), "of_property_read_string_index() failure; rc=%i\n", rc);
382 strings[0] = NULL;
383 rc = of_property_read_string_index(np, "string-property", 1, strings);
384 selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
385 rc = of_property_read_string_index(np, "phandle-list-names", 0, strings);
386 selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
387 rc = of_property_read_string_index(np, "phandle-list-names", 1, strings);
388 selftest(rc == 0 && !strcmp(strings[0], "second"), "of_property_read_string_index() failure; rc=%i\n", rc);
389 rc = of_property_read_string_index(np, "phandle-list-names", 2, strings);
390 selftest(rc == 0 && !strcmp(strings[0], "third"), "of_property_read_string_index() failure; rc=%i\n", rc);
391 strings[0] = NULL;
392 rc = of_property_read_string_index(np, "phandle-list-names", 3, strings);
393 selftest(rc == -ENODATA && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
394 strings[0] = NULL;
395 rc = of_property_read_string_index(np, "unterminated-string", 0, strings);
396 selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
397 rc = of_property_read_string_index(np, "unterminated-string-list", 0, strings);
398 selftest(rc == 0 && !strcmp(strings[0], "first"), "of_property_read_string_index() failure; rc=%i\n", rc);
399 strings[0] = NULL;
400 rc = of_property_read_string_index(np, "unterminated-string-list", 2, strings); /* should fail */
401 selftest(rc == -EILSEQ && strings[0] == NULL, "of_property_read_string_index() failure; rc=%i\n", rc);
402 strings[1] = NULL;
403
404 /* of_property_read_string_array() tests */
405 rc = of_property_read_string_array(np, "string-property", strings, 4);
406 selftest(rc == 1, "Incorrect string count; rc=%i\n", rc);
407 rc = of_property_read_string_array(np, "phandle-list-names", strings, 4);
408 selftest(rc == 3, "Incorrect string count; rc=%i\n", rc);
409 rc = of_property_read_string_array(np, "unterminated-string", strings, 4);
410 selftest(rc == -EILSEQ, "unterminated string; rc=%i\n", rc);
411 /* -- An incorrectly formed string should cause a failure */
412 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 4);
413 selftest(rc == -EILSEQ, "unterminated string array; rc=%i\n", rc);
414 /* -- parsing the correctly formed strings should still work: */
415 strings[2] = NULL;
416 rc = of_property_read_string_array(np, "unterminated-string-list", strings, 2);
417 selftest(rc == 2 && strings[2] == NULL, "of_property_read_string_array() failure; rc=%i\n", rc);
418 strings[1] = NULL;
419 rc = of_property_read_string_array(np, "phandle-list-names", strings, 1);
420 selftest(rc == 1 && strings[1] == NULL, "Overwrote end of string array; rc=%i, str='%s'\n", rc, strings[1]);
367} 421}
368 422
369#define propcmp(p1, p2) (((p1)->length == (p2)->length) && \ 423#define propcmp(p1, p2) (((p1)->length == (p2)->length) && \
@@ -881,7 +935,7 @@ static int __init of_selftest(void)
881 of_selftest_find_node_by_name(); 935 of_selftest_find_node_by_name();
882 of_selftest_dynamic(); 936 of_selftest_dynamic();
883 of_selftest_parse_phandle_with_args(); 937 of_selftest_parse_phandle_with_args();
884 of_selftest_property_match_string(); 938 of_selftest_property_string();
885 of_selftest_property_copy(); 939 of_selftest_property_copy();
886 of_selftest_changeset(); 940 of_selftest_changeset();
887 of_selftest_parse_interrupts(); 941 of_selftest_parse_interrupts();
diff --git a/drivers/of/testcase-data/tests-phandle.dtsi b/drivers/of/testcase-data/tests-phandle.dtsi
index ce0fe083d406..5b1527e8a7fb 100644
--- a/drivers/of/testcase-data/tests-phandle.dtsi
+++ b/drivers/of/testcase-data/tests-phandle.dtsi
@@ -39,7 +39,9 @@
39 phandle-list-bad-args = <&provider2 1 0>, 39 phandle-list-bad-args = <&provider2 1 0>,
40 <&provider3 0>; 40 <&provider3 0>;
41 empty-property; 41 empty-property;
42 string-property = "foobar";
42 unterminated-string = [40 41 42 43]; 43 unterminated-string = [40 41 42 43];
44 unterminated-string-list = "first", "second", [40 41 42 43];
43 }; 45 };
44 }; 46 };
45 }; 47 };
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 233fe8a88264..69202d1eb8fb 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -275,15 +275,22 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
275 goto err_pcie; 275 goto err_pcie;
276 } 276 }
277 277
278 /* allow the clocks to stabilize */
279 usleep_range(200, 500);
280
281 /* power up core phy and enable ref clock */ 278 /* power up core phy and enable ref clock */
282 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, 279 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
283 IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); 280 IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
281 /*
282 * the async reset input need ref clock to sync internally,
283 * when the ref clock comes after reset, internal synced
284 * reset time is too short, cannot meet the requirement.
285 * add one ~10us delay here.
286 */
287 udelay(10);
284 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, 288 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
285 IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); 289 IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
286 290
291 /* allow the clocks to stabilize */
292 usleep_range(200, 500);
293
287 /* Some boards don't have PCIe reset GPIO. */ 294 /* Some boards don't have PCIe reset GPIO. */
288 if (gpio_is_valid(imx6_pcie->reset_gpio)) { 295 if (gpio_is_valid(imx6_pcie->reset_gpio)) {
289 gpio_set_value(imx6_pcie->reset_gpio, 0); 296 gpio_set_value(imx6_pcie->reset_gpio, 0);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 3a5e7e28b874..07aa722bb12c 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -262,13 +262,6 @@ static int pciehp_probe(struct pcie_device *dev)
262 goto err_out_none; 262 goto err_out_none;
263 } 263 }
264 264
265 if (!dev->port->subordinate) {
266 /* Can happen if we run out of bus numbers during probe */
267 dev_err(&dev->device,
268 "Hotplug bridge without secondary bus, ignoring\n");
269 goto err_out_none;
270 }
271
272 ctrl = pcie_init(dev); 265 ctrl = pcie_init(dev);
273 if (!ctrl) { 266 if (!ctrl) {
274 dev_err(&dev->device, "Controller initialization failed\n"); 267 dev_err(&dev->device, "Controller initialization failed\n");
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 92b6d9ab00e4..2c6643fdc0cf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -185,7 +185,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
185} 185}
186static DEVICE_ATTR_RO(modalias); 186static DEVICE_ATTR_RO(modalias);
187 187
188static ssize_t enabled_store(struct device *dev, struct device_attribute *attr, 188static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
189 const char *buf, size_t count) 189 const char *buf, size_t count)
190{ 190{
191 struct pci_dev *pdev = to_pci_dev(dev); 191 struct pci_dev *pdev = to_pci_dev(dev);
@@ -210,7 +210,7 @@ static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
210 return result < 0 ? result : count; 210 return result < 0 ? result : count;
211} 211}
212 212
213static ssize_t enabled_show(struct device *dev, struct device_attribute *attr, 213static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
214 char *buf) 214 char *buf)
215{ 215{
216 struct pci_dev *pdev; 216 struct pci_dev *pdev;
@@ -218,7 +218,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
218 pdev = to_pci_dev(dev); 218 pdev = to_pci_dev(dev);
219 return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt)); 219 return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt));
220} 220}
221static DEVICE_ATTR_RW(enabled); 221static DEVICE_ATTR_RW(enable);
222 222
223#ifdef CONFIG_NUMA 223#ifdef CONFIG_NUMA
224static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, 224static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
@@ -563,7 +563,7 @@ static struct attribute *pci_dev_attrs[] = {
563#endif 563#endif
564 &dev_attr_dma_mask_bits.attr, 564 &dev_attr_dma_mask_bits.attr,
565 &dev_attr_consistent_dma_mask_bits.attr, 565 &dev_attr_consistent_dma_mask_bits.attr,
566 &dev_attr_enabled.attr, 566 &dev_attr_enable.attr,
567 &dev_attr_broken_parity_status.attr, 567 &dev_attr_broken_parity_status.attr,
568 &dev_attr_msi_bus.attr, 568 &dev_attr_msi_bus.attr,
569#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 569#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 8c842980834a..f091576b6449 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -258,14 +258,16 @@ static int omap_usb2_probe(struct platform_device *pdev)
258 otg->phy = &phy->phy; 258 otg->phy = &phy->phy;
259 259
260 platform_set_drvdata(pdev, phy); 260 platform_set_drvdata(pdev, phy);
261 pm_runtime_enable(phy->dev);
261 262
262 generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL); 263 generic_phy = devm_phy_create(phy->dev, NULL, &ops, NULL);
263 if (IS_ERR(generic_phy)) 264 if (IS_ERR(generic_phy)) {
265 pm_runtime_disable(phy->dev);
264 return PTR_ERR(generic_phy); 266 return PTR_ERR(generic_phy);
267 }
265 268
266 phy_set_drvdata(generic_phy, phy); 269 phy_set_drvdata(generic_phy, phy);
267 270
268 pm_runtime_enable(phy->dev);
269 phy_provider = devm_of_phy_provider_register(phy->dev, 271 phy_provider = devm_of_phy_provider_register(phy->dev,
270 of_phy_simple_xlate); 272 of_phy_simple_xlate);
271 if (IS_ERR(phy_provider)) { 273 if (IS_ERR(phy_provider)) {
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e12e5b07f6d7..9dc38140194b 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -227,10 +227,14 @@ static int byt_irq_type(struct irq_data *d, unsigned type)
227 spin_lock_irqsave(&vg->lock, flags); 227 spin_lock_irqsave(&vg->lock, flags);
228 value = readl(reg); 228 value = readl(reg);
229 229
230 WARN(value & BYT_DIRECT_IRQ_EN,
231 "Bad pad config for io mode, force direct_irq_en bit clearing");
232
230 /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits 233 /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
231 * are used to indicate high and low level triggering 234 * are used to indicate high and low level triggering
232 */ 235 */
233 value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL); 236 value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG |
237 BYT_TRIG_LVL);
234 238
235 switch (type) { 239 switch (type) {
236 case IRQ_TYPE_LEVEL_HIGH: 240 case IRQ_TYPE_LEVEL_HIGH:
@@ -318,7 +322,7 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
318 "Potential Error: Setting GPIO with direct_irq_en to output"); 322 "Potential Error: Setting GPIO with direct_irq_en to output");
319 323
320 reg_val = readl(reg) | BYT_DIR_MASK; 324 reg_val = readl(reg) | BYT_DIR_MASK;
321 reg_val &= ~BYT_OUTPUT_EN; 325 reg_val &= ~(BYT_OUTPUT_EN | BYT_INPUT_EN);
322 326
323 if (value) 327 if (value)
324 writel(reg_val | BYT_LEVEL, reg); 328 writel(reg_val | BYT_LEVEL, reg);
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 96a0b75c52c9..26c4fd1394da 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -579,6 +579,17 @@ static const struct dmi_system_id video_vendor_dmi_table[] __initconst = {
579 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"), 579 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5741"),
580 }, 580 },
581 }, 581 },
582 {
583 /*
584 * Note no video_set_backlight_video_vendor, we must use the
585 * acer interface, as there is no native backlight interface.
586 */
587 .ident = "Acer KAV80",
588 .matches = {
589 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
590 DMI_MATCH(DMI_PRODUCT_NAME, "KAV80"),
591 },
592 },
582 {} 593 {}
583}; 594};
584 595
diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 3a4951f46065..c1a6cd66af42 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -182,6 +182,15 @@ static const struct dmi_system_id asus_quirks[] = {
182 }, 182 },
183 { 183 {
184 .callback = dmi_matched, 184 .callback = dmi_matched,
185 .ident = "ASUSTeK COMPUTER INC. X550VB",
186 .matches = {
187 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
188 DMI_MATCH(DMI_PRODUCT_NAME, "X550VB"),
189 },
190 .driver_data = &quirk_asus_wapf4,
191 },
192 {
193 .callback = dmi_matched,
185 .ident = "ASUSTeK COMPUTER INC. X55A", 194 .ident = "ASUSTeK COMPUTER INC. X55A",
186 .matches = { 195 .matches = {
187 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 196 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 02152de135b5..ed494f37c40f 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -837,6 +837,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
837 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Yoga 2"), 837 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Yoga 2"),
838 }, 838 },
839 }, 839 },
840 {
841 .ident = "Lenovo Yoga 3 Pro 1370",
842 .matches = {
843 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
844 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 3 Pro-1370"),
845 },
846 },
840 {} 847 {}
841}; 848};
842 849
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index 5a5966512277..ff765d8e1a09 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -1561,6 +1561,16 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
1561 }, 1561 },
1562 { 1562 {
1563 .callback = samsung_dmi_matched, 1563 .callback = samsung_dmi_matched,
1564 .ident = "NC210",
1565 .matches = {
1566 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
1567 DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
1568 DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
1569 },
1570 .driver_data = &samsung_broken_acpi_video,
1571 },
1572 {
1573 .callback = samsung_dmi_matched,
1564 .ident = "730U3E/740U3E", 1574 .ident = "730U3E/740U3E",
1565 .matches = { 1575 .matches = {
1566 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."), 1576 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index ef3a1904e92f..ab6151f05420 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -240,6 +240,12 @@ static const struct dmi_system_id toshiba_alt_keymap_dmi[] = {
240 DMI_MATCH(DMI_PRODUCT_NAME, "Qosmio X75-A"), 240 DMI_MATCH(DMI_PRODUCT_NAME, "Qosmio X75-A"),
241 }, 241 },
242 }, 242 },
243 {
244 .matches = {
245 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
246 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA A50-A"),
247 },
248 },
243 {} 249 {}
244}; 250};
245 251
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 86db310d5304..d2a8c64cae42 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -163,7 +163,7 @@ static int of_get_max1586_platform_data(struct device *dev,
163 struct max1586_platform_data *pdata) 163 struct max1586_platform_data *pdata)
164{ 164{
165 struct max1586_subdev_data *sub; 165 struct max1586_subdev_data *sub;
166 struct of_regulator_match rmatch[ARRAY_SIZE(max1586_reg)]; 166 struct of_regulator_match rmatch[ARRAY_SIZE(max1586_reg)] = { };
167 struct device_node *np = dev->of_node; 167 struct device_node *np = dev->of_node;
168 int i, matched; 168 int i, matched;
169 169
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index ef1af2debbd2..f69320e1738f 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -395,7 +395,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
395 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 395 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
396 struct device_node *pmic_np, *regulators_np; 396 struct device_node *pmic_np, *regulators_np;
397 struct max77686_regulator_data *rdata; 397 struct max77686_regulator_data *rdata;
398 struct of_regulator_match rmatch; 398 struct of_regulator_match rmatch = { };
399 unsigned int i; 399 unsigned int i;
400 400
401 pmic_np = iodev->dev->of_node; 401 pmic_np = iodev->dev->of_node;
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c
index c67ff05fc1dd..d158f71fa128 100644
--- a/drivers/regulator/max77693.c
+++ b/drivers/regulator/max77693.c
@@ -227,7 +227,7 @@ static int max77693_pmic_probe(struct platform_device *pdev)
227 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 227 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
228 struct max77693_regulator_data *rdata = NULL; 228 struct max77693_regulator_data *rdata = NULL;
229 int num_rdata, i; 229 int num_rdata, i;
230 struct regulator_config config; 230 struct regulator_config config = { };
231 231
232 num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); 232 num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata);
233 if (!rdata || num_rdata <= 0) { 233 if (!rdata || num_rdata <= 0) {
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index d89792b084e9..45fa240fe243 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -454,7 +454,7 @@ static int max77802_pmic_dt_parse_pdata(struct platform_device *pdev,
454 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 454 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
455 struct device_node *pmic_np, *regulators_np; 455 struct device_node *pmic_np, *regulators_np;
456 struct max77686_regulator_data *rdata; 456 struct max77686_regulator_data *rdata;
457 struct of_regulator_match rmatch; 457 struct of_regulator_match rmatch = { };
458 unsigned int i; 458 unsigned int i;
459 459
460 pmic_np = iodev->dev->of_node; 460 pmic_np = iodev->dev->of_node;
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index 2fc411188794..7eee2ca18541 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -335,7 +335,7 @@ static int max8660_pdata_from_dt(struct device *dev,
335 int matched, i; 335 int matched, i;
336 struct device_node *np; 336 struct device_node *np;
337 struct max8660_subdev_data *sub; 337 struct max8660_subdev_data *sub;
338 struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)]; 338 struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)] = { };
339 339
340 np = of_get_child_by_name(dev->of_node, "regulators"); 340 np = of_get_child_by_name(dev->of_node, "regulators");
341 if (!np) { 341 if (!np) {
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 7a51814abdc5..5a1d4afa4776 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -211,7 +211,8 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
211 search = dev->of_node; 211 search = dev->of_node;
212 212
213 if (!search) { 213 if (!search) {
214 dev_err(dev, "Failed to find regulator container node\n"); 214 dev_dbg(dev, "Failed to find regulator container node '%s'\n",
215 desc->regulators_node);
215 return NULL; 216 return NULL;
216 } 217 }
217 218
diff --git a/drivers/regulator/s2mpa01.c b/drivers/regulator/s2mpa01.c
index 4acefa6b462e..7633b9bfbe6e 100644
--- a/drivers/regulator/s2mpa01.c
+++ b/drivers/regulator/s2mpa01.c
@@ -341,7 +341,7 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev)
341{ 341{
342 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); 342 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
343 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev); 343 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
344 struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX]; 344 struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX] = { };
345 struct device_node *reg_np = NULL; 345 struct device_node *reg_np = NULL;
346 struct regulator_config config = { }; 346 struct regulator_config config = { };
347 struct s2mpa01_info *s2mpa01; 347 struct s2mpa01_info *s2mpa01;
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 94ae1798d48a..6dd12ddbabc6 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1320,7 +1320,7 @@ config RTC_DRV_LPC32XX
1320 1320
1321config RTC_DRV_PM8XXX 1321config RTC_DRV_PM8XXX
1322 tristate "Qualcomm PMIC8XXX RTC" 1322 tristate "Qualcomm PMIC8XXX RTC"
1323 depends on MFD_PM8XXX 1323 depends on MFD_PM8XXX || MFD_SPMI_PMIC
1324 help 1324 help
1325 If you say yes here you get support for the 1325 If you say yes here you get support for the
1326 Qualcomm PMIC8XXX RTC. 1326 Qualcomm PMIC8XXX RTC.
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 314129e66d6e..92679df6d6e2 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -160,7 +160,7 @@ static int trickle_charger_of_init(struct device *dev, struct device_node *node)
160 dev_err(dev, "bq32k: diode and resistor mismatch\n"); 160 dev_err(dev, "bq32k: diode and resistor mismatch\n");
161 return -EINVAL; 161 return -EINVAL;
162 } 162 }
163 reg = 0x25; 163 reg = 0x45;
164 break; 164 break;
165 165
166 default: 166 default:
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 197699f358c7..5adcf111fc14 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -27,21 +27,36 @@
27 27
28/* RTC_CTRL register bit fields */ 28/* RTC_CTRL register bit fields */
29#define PM8xxx_RTC_ENABLE BIT(7) 29#define PM8xxx_RTC_ENABLE BIT(7)
30#define PM8xxx_RTC_ALARM_ENABLE BIT(1)
31#define PM8xxx_RTC_ALARM_CLEAR BIT(0) 30#define PM8xxx_RTC_ALARM_CLEAR BIT(0)
32 31
33#define NUM_8_BIT_RTC_REGS 0x4 32#define NUM_8_BIT_RTC_REGS 0x4
34 33
35/** 34/**
35 * struct pm8xxx_rtc_regs - describe RTC registers per PMIC versions
36 * @ctrl: base address of control register
37 * @write: base address of write register
38 * @read: base address of read register
39 * @alarm_ctrl: base address of alarm control register
40 * @alarm_ctrl2: base address of alarm control2 register
41 * @alarm_rw: base address of alarm read-write register
42 * @alarm_en: alarm enable mask
43 */
44struct pm8xxx_rtc_regs {
45 unsigned int ctrl;
46 unsigned int write;
47 unsigned int read;
48 unsigned int alarm_ctrl;
49 unsigned int alarm_ctrl2;
50 unsigned int alarm_rw;
51 unsigned int alarm_en;
52};
53
54/**
36 * struct pm8xxx_rtc - rtc driver internal structure 55 * struct pm8xxx_rtc - rtc driver internal structure
37 * @rtc: rtc device for this driver. 56 * @rtc: rtc device for this driver.
38 * @regmap: regmap used to access RTC registers 57 * @regmap: regmap used to access RTC registers
39 * @allow_set_time: indicates whether writing to the RTC is allowed 58 * @allow_set_time: indicates whether writing to the RTC is allowed
40 * @rtc_alarm_irq: rtc alarm irq number. 59 * @rtc_alarm_irq: rtc alarm irq number.
41 * @rtc_base: address of rtc control register.
42 * @rtc_read_base: base address of read registers.
43 * @rtc_write_base: base address of write registers.
44 * @alarm_rw_base: base address of alarm registers.
45 * @ctrl_reg: rtc control register. 60 * @ctrl_reg: rtc control register.
46 * @rtc_dev: device structure. 61 * @rtc_dev: device structure.
47 * @ctrl_reg_lock: spinlock protecting access to ctrl_reg. 62 * @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
@@ -51,11 +66,7 @@ struct pm8xxx_rtc {
51 struct regmap *regmap; 66 struct regmap *regmap;
52 bool allow_set_time; 67 bool allow_set_time;
53 int rtc_alarm_irq; 68 int rtc_alarm_irq;
54 int rtc_base; 69 const struct pm8xxx_rtc_regs *regs;
55 int rtc_read_base;
56 int rtc_write_base;
57 int alarm_rw_base;
58 u8 ctrl_reg;
59 struct device *rtc_dev; 70 struct device *rtc_dev;
60 spinlock_t ctrl_reg_lock; 71 spinlock_t ctrl_reg_lock;
61}; 72};
@@ -71,8 +82,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
71{ 82{
72 int rc, i; 83 int rc, i;
73 unsigned long secs, irq_flags; 84 unsigned long secs, irq_flags;
74 u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, ctrl_reg; 85 u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
86 unsigned int ctrl_reg;
75 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 87 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
88 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
76 89
77 if (!rtc_dd->allow_set_time) 90 if (!rtc_dd->allow_set_time)
78 return -EACCES; 91 return -EACCES;
@@ -87,30 +100,30 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
87 dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs); 100 dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
88 101
89 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 102 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
90 ctrl_reg = rtc_dd->ctrl_reg;
91 103
92 if (ctrl_reg & PM8xxx_RTC_ALARM_ENABLE) { 104 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg);
105 if (rc)
106 goto rtc_rw_fail;
107
108 if (ctrl_reg & regs->alarm_en) {
93 alarm_enabled = 1; 109 alarm_enabled = 1;
94 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 110 ctrl_reg &= ~regs->alarm_en;
95 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 111 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
96 if (rc) { 112 if (rc) {
97 dev_err(dev, "Write to RTC control register failed\n"); 113 dev_err(dev, "Write to RTC control register failed\n");
98 goto rtc_rw_fail; 114 goto rtc_rw_fail;
99 } 115 }
100 rtc_dd->ctrl_reg = ctrl_reg;
101 } else {
102 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
103 } 116 }
104 117
105 /* Write 0 to Byte[0] */ 118 /* Write 0 to Byte[0] */
106 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_write_base, 0); 119 rc = regmap_write(rtc_dd->regmap, regs->write, 0);
107 if (rc) { 120 if (rc) {
108 dev_err(dev, "Write to RTC write data register failed\n"); 121 dev_err(dev, "Write to RTC write data register failed\n");
109 goto rtc_rw_fail; 122 goto rtc_rw_fail;
110 } 123 }
111 124
112 /* Write Byte[1], Byte[2], Byte[3] */ 125 /* Write Byte[1], Byte[2], Byte[3] */
113 rc = regmap_bulk_write(rtc_dd->regmap, rtc_dd->rtc_write_base + 1, 126 rc = regmap_bulk_write(rtc_dd->regmap, regs->write + 1,
114 &value[1], sizeof(value) - 1); 127 &value[1], sizeof(value) - 1);
115 if (rc) { 128 if (rc) {
116 dev_err(dev, "Write to RTC write data register failed\n"); 129 dev_err(dev, "Write to RTC write data register failed\n");
@@ -118,25 +131,23 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
118 } 131 }
119 132
120 /* Write Byte[0] */ 133 /* Write Byte[0] */
121 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_write_base, value[0]); 134 rc = regmap_write(rtc_dd->regmap, regs->write, value[0]);
122 if (rc) { 135 if (rc) {
123 dev_err(dev, "Write to RTC write data register failed\n"); 136 dev_err(dev, "Write to RTC write data register failed\n");
124 goto rtc_rw_fail; 137 goto rtc_rw_fail;
125 } 138 }
126 139
127 if (alarm_enabled) { 140 if (alarm_enabled) {
128 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 141 ctrl_reg |= regs->alarm_en;
129 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 142 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
130 if (rc) { 143 if (rc) {
131 dev_err(dev, "Write to RTC control register failed\n"); 144 dev_err(dev, "Write to RTC control register failed\n");
132 goto rtc_rw_fail; 145 goto rtc_rw_fail;
133 } 146 }
134 rtc_dd->ctrl_reg = ctrl_reg;
135 } 147 }
136 148
137rtc_rw_fail: 149rtc_rw_fail:
138 if (alarm_enabled) 150 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
139 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
140 151
141 return rc; 152 return rc;
142} 153}
@@ -148,9 +159,9 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
148 unsigned long secs; 159 unsigned long secs;
149 unsigned int reg; 160 unsigned int reg;
150 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 161 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
162 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
151 163
152 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->rtc_read_base, 164 rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value));
153 value, sizeof(value));
154 if (rc) { 165 if (rc) {
155 dev_err(dev, "RTC read data register failed\n"); 166 dev_err(dev, "RTC read data register failed\n");
156 return rc; 167 return rc;
@@ -160,14 +171,14 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
160 * Read the LSB again and check if there has been a carry over. 171 * Read the LSB again and check if there has been a carry over.
161 * If there is, redo the read operation. 172 * If there is, redo the read operation.
162 */ 173 */
163 rc = regmap_read(rtc_dd->regmap, rtc_dd->rtc_read_base, &reg); 174 rc = regmap_read(rtc_dd->regmap, regs->read, &reg);
164 if (rc < 0) { 175 if (rc < 0) {
165 dev_err(dev, "RTC read data register failed\n"); 176 dev_err(dev, "RTC read data register failed\n");
166 return rc; 177 return rc;
167 } 178 }
168 179
169 if (unlikely(reg < value[0])) { 180 if (unlikely(reg < value[0])) {
170 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->rtc_read_base, 181 rc = regmap_bulk_read(rtc_dd->regmap, regs->read,
171 value, sizeof(value)); 182 value, sizeof(value));
172 if (rc) { 183 if (rc) {
173 dev_err(dev, "RTC read data register failed\n"); 184 dev_err(dev, "RTC read data register failed\n");
@@ -195,9 +206,11 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
195static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) 206static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
196{ 207{
197 int rc, i; 208 int rc, i;
198 u8 value[NUM_8_BIT_RTC_REGS], ctrl_reg; 209 u8 value[NUM_8_BIT_RTC_REGS];
210 unsigned int ctrl_reg;
199 unsigned long secs, irq_flags; 211 unsigned long secs, irq_flags;
200 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 212 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
213 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
201 214
202 rtc_tm_to_time(&alarm->time, &secs); 215 rtc_tm_to_time(&alarm->time, &secs);
203 216
@@ -208,28 +221,28 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
208 221
209 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 222 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
210 223
211 rc = regmap_bulk_write(rtc_dd->regmap, rtc_dd->alarm_rw_base, value, 224 rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value,
212 sizeof(value)); 225 sizeof(value));
213 if (rc) { 226 if (rc) {
214 dev_err(dev, "Write to RTC ALARM register failed\n"); 227 dev_err(dev, "Write to RTC ALARM register failed\n");
215 goto rtc_rw_fail; 228 goto rtc_rw_fail;
216 } 229 }
217 230
218 ctrl_reg = rtc_dd->ctrl_reg; 231 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
232 if (rc)
233 goto rtc_rw_fail;
219 234
220 if (alarm->enabled) 235 if (alarm->enabled)
221 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 236 ctrl_reg |= regs->alarm_en;
222 else 237 else
223 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 238 ctrl_reg &= ~regs->alarm_en;
224 239
225 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 240 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
226 if (rc) { 241 if (rc) {
227 dev_err(dev, "Write to RTC control register failed\n"); 242 dev_err(dev, "Write to RTC alarm control register failed\n");
228 goto rtc_rw_fail; 243 goto rtc_rw_fail;
229 } 244 }
230 245
231 rtc_dd->ctrl_reg = ctrl_reg;
232
233 dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n", 246 dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n",
234 alarm->time.tm_hour, alarm->time.tm_min, 247 alarm->time.tm_hour, alarm->time.tm_min,
235 alarm->time.tm_sec, alarm->time.tm_mday, 248 alarm->time.tm_sec, alarm->time.tm_mday,
@@ -245,8 +258,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
245 u8 value[NUM_8_BIT_RTC_REGS]; 258 u8 value[NUM_8_BIT_RTC_REGS];
246 unsigned long secs; 259 unsigned long secs;
247 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 260 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
261 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
248 262
249 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->alarm_rw_base, value, 263 rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value,
250 sizeof(value)); 264 sizeof(value));
251 if (rc) { 265 if (rc) {
252 dev_err(dev, "RTC alarm time read failed\n"); 266 dev_err(dev, "RTC alarm time read failed\n");
@@ -276,25 +290,26 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
276 int rc; 290 int rc;
277 unsigned long irq_flags; 291 unsigned long irq_flags;
278 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 292 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
279 u8 ctrl_reg; 293 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
294 unsigned int ctrl_reg;
280 295
281 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 296 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
282 297
283 ctrl_reg = rtc_dd->ctrl_reg; 298 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
299 if (rc)
300 goto rtc_rw_fail;
284 301
285 if (enable) 302 if (enable)
286 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 303 ctrl_reg |= regs->alarm_en;
287 else 304 else
288 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 305 ctrl_reg &= ~regs->alarm_en;
289 306
290 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 307 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
291 if (rc) { 308 if (rc) {
292 dev_err(dev, "Write to RTC control register failed\n"); 309 dev_err(dev, "Write to RTC control register failed\n");
293 goto rtc_rw_fail; 310 goto rtc_rw_fail;
294 } 311 }
295 312
296 rtc_dd->ctrl_reg = ctrl_reg;
297
298rtc_rw_fail: 313rtc_rw_fail:
299 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 314 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
300 return rc; 315 return rc;
@@ -311,6 +326,7 @@ static const struct rtc_class_ops pm8xxx_rtc_ops = {
311static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) 326static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id)
312{ 327{
313 struct pm8xxx_rtc *rtc_dd = dev_id; 328 struct pm8xxx_rtc *rtc_dd = dev_id;
329 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
314 unsigned int ctrl_reg; 330 unsigned int ctrl_reg;
315 int rc; 331 int rc;
316 unsigned long irq_flags; 332 unsigned long irq_flags;
@@ -320,48 +336,100 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id)
320 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 336 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
321 337
322 /* Clear the alarm enable bit */ 338 /* Clear the alarm enable bit */
323 ctrl_reg = rtc_dd->ctrl_reg; 339 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
324 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 340 if (rc) {
341 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
342 goto rtc_alarm_handled;
343 }
344
345 ctrl_reg &= ~regs->alarm_en;
325 346
326 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 347 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
327 if (rc) { 348 if (rc) {
328 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 349 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
329 dev_err(rtc_dd->rtc_dev, 350 dev_err(rtc_dd->rtc_dev,
330 "Write to RTC control register failed\n"); 351 "Write to alarm control register failed\n");
331 goto rtc_alarm_handled; 352 goto rtc_alarm_handled;
332 } 353 }
333 354
334 rtc_dd->ctrl_reg = ctrl_reg;
335 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 355 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
336 356
337 /* Clear RTC alarm register */ 357 /* Clear RTC alarm register */
338 rc = regmap_read(rtc_dd->regmap, 358 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl2, &ctrl_reg);
339 rtc_dd->rtc_base + PM8XXX_ALARM_CTRL_OFFSET,
340 &ctrl_reg);
341 if (rc) { 359 if (rc) {
342 dev_err(rtc_dd->rtc_dev, 360 dev_err(rtc_dd->rtc_dev,
343 "RTC Alarm control register read failed\n"); 361 "RTC Alarm control2 register read failed\n");
344 goto rtc_alarm_handled; 362 goto rtc_alarm_handled;
345 } 363 }
346 364
347 ctrl_reg &= ~PM8xxx_RTC_ALARM_CLEAR; 365 ctrl_reg |= PM8xxx_RTC_ALARM_CLEAR;
348 rc = regmap_write(rtc_dd->regmap, 366 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl2, ctrl_reg);
349 rtc_dd->rtc_base + PM8XXX_ALARM_CTRL_OFFSET,
350 ctrl_reg);
351 if (rc) 367 if (rc)
352 dev_err(rtc_dd->rtc_dev, 368 dev_err(rtc_dd->rtc_dev,
353 "Write to RTC Alarm control register failed\n"); 369 "Write to RTC Alarm control2 register failed\n");
354 370
355rtc_alarm_handled: 371rtc_alarm_handled:
356 return IRQ_HANDLED; 372 return IRQ_HANDLED;
357} 373}
358 374
375static int pm8xxx_rtc_enable(struct pm8xxx_rtc *rtc_dd)
376{
377 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
378 unsigned int ctrl_reg;
379 int rc;
380
381 /* Check if the RTC is on, else turn it on */
382 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg);
383 if (rc)
384 return rc;
385
386 if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) {
387 ctrl_reg |= PM8xxx_RTC_ENABLE;
388 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
389 if (rc)
390 return rc;
391 }
392
393 return 0;
394}
395
396static const struct pm8xxx_rtc_regs pm8921_regs = {
397 .ctrl = 0x11d,
398 .write = 0x11f,
399 .read = 0x123,
400 .alarm_rw = 0x127,
401 .alarm_ctrl = 0x11d,
402 .alarm_ctrl2 = 0x11e,
403 .alarm_en = BIT(1),
404};
405
406static const struct pm8xxx_rtc_regs pm8058_regs = {
407 .ctrl = 0x1e8,
408 .write = 0x1ea,
409 .read = 0x1ee,
410 .alarm_rw = 0x1f2,
411 .alarm_ctrl = 0x1e8,
412 .alarm_ctrl2 = 0x1e9,
413 .alarm_en = BIT(1),
414};
415
416static const struct pm8xxx_rtc_regs pm8941_regs = {
417 .ctrl = 0x6046,
418 .write = 0x6040,
419 .read = 0x6048,
420 .alarm_rw = 0x6140,
421 .alarm_ctrl = 0x6146,
422 .alarm_ctrl2 = 0x6148,
423 .alarm_en = BIT(7),
424};
425
359/* 426/*
360 * Hardcoded RTC bases until IORESOURCE_REG mapping is figured out 427 * Hardcoded RTC bases until IORESOURCE_REG mapping is figured out
361 */ 428 */
362static const struct of_device_id pm8xxx_id_table[] = { 429static const struct of_device_id pm8xxx_id_table[] = {
363 { .compatible = "qcom,pm8921-rtc", .data = (void *) 0x11D }, 430 { .compatible = "qcom,pm8921-rtc", .data = &pm8921_regs },
364 { .compatible = "qcom,pm8058-rtc", .data = (void *) 0x1E8 }, 431 { .compatible = "qcom,pm8058-rtc", .data = &pm8058_regs },
432 { .compatible = "qcom,pm8941-rtc", .data = &pm8941_regs },
365 { }, 433 { },
366}; 434};
367MODULE_DEVICE_TABLE(of, pm8xxx_id_table); 435MODULE_DEVICE_TABLE(of, pm8xxx_id_table);
@@ -369,7 +437,6 @@ MODULE_DEVICE_TABLE(of, pm8xxx_id_table);
369static int pm8xxx_rtc_probe(struct platform_device *pdev) 437static int pm8xxx_rtc_probe(struct platform_device *pdev)
370{ 438{
371 int rc; 439 int rc;
372 unsigned int ctrl_reg;
373 struct pm8xxx_rtc *rtc_dd; 440 struct pm8xxx_rtc *rtc_dd;
374 const struct of_device_id *match; 441 const struct of_device_id *match;
375 442
@@ -399,33 +466,12 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
399 rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, 466 rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node,
400 "allow-set-time"); 467 "allow-set-time");
401 468
402 rtc_dd->rtc_base = (long) match->data; 469 rtc_dd->regs = match->data;
403
404 /* Setup RTC register addresses */
405 rtc_dd->rtc_write_base = rtc_dd->rtc_base + PM8XXX_RTC_WRITE_OFFSET;
406 rtc_dd->rtc_read_base = rtc_dd->rtc_base + PM8XXX_RTC_READ_OFFSET;
407 rtc_dd->alarm_rw_base = rtc_dd->rtc_base + PM8XXX_ALARM_RW_OFFSET;
408
409 rtc_dd->rtc_dev = &pdev->dev; 470 rtc_dd->rtc_dev = &pdev->dev;
410 471
411 /* Check if the RTC is on, else turn it on */ 472 rc = pm8xxx_rtc_enable(rtc_dd);
412 rc = regmap_read(rtc_dd->regmap, rtc_dd->rtc_base, &ctrl_reg); 473 if (rc)
413 if (rc) {
414 dev_err(&pdev->dev, "RTC control register read failed!\n");
415 return rc; 474 return rc;
416 }
417
418 if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) {
419 ctrl_reg |= PM8xxx_RTC_ENABLE;
420 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg);
421 if (rc) {
422 dev_err(&pdev->dev,
423 "Write to RTC control register failed\n");
424 return rc;
425 }
426 }
427
428 rtc_dd->ctrl_reg = ctrl_reg;
429 475
430 platform_set_drvdata(pdev, rtc_dd); 476 platform_set_drvdata(pdev, rtc_dd);
431 477
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a6b1252c9941..806072238c00 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -535,13 +535,15 @@ static int s3c_rtc_probe(struct platform_device *pdev)
535 } 535 }
536 clk_prepare_enable(info->rtc_clk); 536 clk_prepare_enable(info->rtc_clk);
537 537
538 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); 538 if (info->data->needs_src_clk) {
539 if (IS_ERR(info->rtc_src_clk)) { 539 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
540 dev_err(&pdev->dev, "failed to find rtc source clock\n"); 540 if (IS_ERR(info->rtc_src_clk)) {
541 return PTR_ERR(info->rtc_src_clk); 541 dev_err(&pdev->dev,
542 "failed to find rtc source clock\n");
543 return PTR_ERR(info->rtc_src_clk);
544 }
545 clk_prepare_enable(info->rtc_src_clk);
542 } 546 }
543 clk_prepare_enable(info->rtc_src_clk);
544
545 547
546 /* check to see if everything is setup correctly */ 548 /* check to see if everything is setup correctly */
547 if (info->data->enable) 549 if (info->data->enable)
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 54fa6e0bc1bb..674d498b46ab 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -399,6 +399,35 @@ EXPORT_SYMBOL_GPL(cxgbi_hbas_add);
399 * If the source port is outside our allocation range, the caller is 399 * If the source port is outside our allocation range, the caller is
400 * responsible for keeping track of their port usage. 400 * responsible for keeping track of their port usage.
401 */ 401 */
402
403static struct cxgbi_sock *find_sock_on_port(struct cxgbi_device *cdev,
404 unsigned char port_id)
405{
406 struct cxgbi_ports_map *pmap = &cdev->pmap;
407 unsigned int i;
408 unsigned int used;
409
410 if (!pmap->max_connect || !pmap->used)
411 return NULL;
412
413 spin_lock_bh(&pmap->lock);
414 used = pmap->used;
415 for (i = 0; used && i < pmap->max_connect; i++) {
416 struct cxgbi_sock *csk = pmap->port_csk[i];
417
418 if (csk) {
419 if (csk->port_id == port_id) {
420 spin_unlock_bh(&pmap->lock);
421 return csk;
422 }
423 used--;
424 }
425 }
426 spin_unlock_bh(&pmap->lock);
427
428 return NULL;
429}
430
402static int sock_get_port(struct cxgbi_sock *csk) 431static int sock_get_port(struct cxgbi_sock *csk)
403{ 432{
404 struct cxgbi_device *cdev = csk->cdev; 433 struct cxgbi_device *cdev = csk->cdev;
@@ -749,6 +778,7 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr)
749 csk->daddr6.sin6_addr = daddr6->sin6_addr; 778 csk->daddr6.sin6_addr = daddr6->sin6_addr;
750 csk->daddr6.sin6_port = daddr6->sin6_port; 779 csk->daddr6.sin6_port = daddr6->sin6_port;
751 csk->daddr6.sin6_family = daddr6->sin6_family; 780 csk->daddr6.sin6_family = daddr6->sin6_family;
781 csk->saddr6.sin6_family = daddr6->sin6_family;
752 csk->saddr6.sin6_addr = pref_saddr; 782 csk->saddr6.sin6_addr = pref_saddr;
753 783
754 neigh_release(n); 784 neigh_release(n);
@@ -2647,12 +2677,14 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param,
2647 break; 2677 break;
2648 case ISCSI_HOST_PARAM_IPADDRESS: 2678 case ISCSI_HOST_PARAM_IPADDRESS:
2649 { 2679 {
2650 __be32 addr; 2680 struct cxgbi_sock *csk = find_sock_on_port(chba->cdev,
2651 2681 chba->port_id);
2652 addr = cxgbi_get_iscsi_ipv4(chba); 2682 if (csk) {
2653 len = sprintf(buf, "%pI4", &addr); 2683 len = sprintf(buf, "%pIS",
2684 (struct sockaddr *)&csk->saddr);
2685 }
2654 log_debug(1 << CXGBI_DBG_ISCSI, 2686 log_debug(1 << CXGBI_DBG_ISCSI,
2655 "hba %s, ipv4 %pI4.\n", chba->ndev->name, &addr); 2687 "hba %s, addr %s.\n", chba->ndev->name, buf);
2656 break; 2688 break;
2657 } 2689 }
2658 default: 2690 default:
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 1d98fad6a0ab..2c7cb1c0c453 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -700,11 +700,6 @@ static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
700 chba->ndev->name); 700 chba->ndev->name);
701} 701}
702 702
703static inline __be32 cxgbi_get_iscsi_ipv4(struct cxgbi_hba *chba)
704{
705 return chba->ipv4addr;
706}
707
708struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int); 703struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
709void cxgbi_device_unregister(struct cxgbi_device *); 704void cxgbi_device_unregister(struct cxgbi_device *);
710void cxgbi_device_unregister_all(unsigned int flag); 705void cxgbi_device_unregister_all(unsigned int flag);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9eff8a375132..50a6e1ac8d9c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1893,6 +1893,11 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req,
1893 blk_mq_start_request(req); 1893 blk_mq_start_request(req);
1894 } 1894 }
1895 1895
1896 if (blk_queue_tagged(q))
1897 req->cmd_flags |= REQ_QUEUED;
1898 else
1899 req->cmd_flags &= ~REQ_QUEUED;
1900
1896 scsi_init_cmd_errh(cmd); 1901 scsi_init_cmd_errh(cmd);
1897 cmd->scsi_done = scsi_mq_done; 1902 cmd->scsi_done = scsi_mq_done;
1898 1903
diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index cea8ea3491d2..1a07bf540fec 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -26,6 +26,7 @@ static const struct of_device_id realview_soc_of_match[] = {
26 { .compatible = "arm,realview-pb11mp-soc", }, 26 { .compatible = "arm,realview-pb11mp-soc", },
27 { .compatible = "arm,realview-pba8-soc", }, 27 { .compatible = "arm,realview-pba8-soc", },
28 { .compatible = "arm,realview-pbx-soc", }, 28 { .compatible = "arm,realview-pbx-soc", },
29 { }
29}; 30};
30 31
31static u32 realview_coreid; 32static u32 realview_coreid;
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 448216025ce8..831ceb4a91f6 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -46,7 +46,7 @@
46 46
47#define SPI_TCR 0x08 47#define SPI_TCR 0x08
48 48
49#define SPI_CTAR(x) (0x0c + (x * 4)) 49#define SPI_CTAR(x) (0x0c + (((x) & 0x3) * 4))
50#define SPI_CTAR_FMSZ(x) (((x) & 0x0000000f) << 27) 50#define SPI_CTAR_FMSZ(x) (((x) & 0x0000000f) << 27)
51#define SPI_CTAR_CPOL(x) ((x) << 26) 51#define SPI_CTAR_CPOL(x) ((x) << 26)
52#define SPI_CTAR_CPHA(x) ((x) << 25) 52#define SPI_CTAR_CPHA(x) ((x) << 25)
@@ -70,7 +70,7 @@
70 70
71#define SPI_PUSHR 0x34 71#define SPI_PUSHR 0x34
72#define SPI_PUSHR_CONT (1 << 31) 72#define SPI_PUSHR_CONT (1 << 31)
73#define SPI_PUSHR_CTAS(x) (((x) & 0x00000007) << 28) 73#define SPI_PUSHR_CTAS(x) (((x) & 0x00000003) << 28)
74#define SPI_PUSHR_EOQ (1 << 27) 74#define SPI_PUSHR_EOQ (1 << 27)
75#define SPI_PUSHR_CTCNT (1 << 26) 75#define SPI_PUSHR_CTCNT (1 << 26)
76#define SPI_PUSHR_PCS(x) (((1 << x) & 0x0000003f) << 16) 76#define SPI_PUSHR_PCS(x) (((1 << x) & 0x0000003f) << 16)
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index d8a105f76837..9e9e0f971e6c 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1274,7 +1274,9 @@ static int pxa2xx_spi_suspend(struct device *dev)
1274 if (status != 0) 1274 if (status != 0)
1275 return status; 1275 return status;
1276 write_SSCR0(0, drv_data->ioaddr); 1276 write_SSCR0(0, drv_data->ioaddr);
1277 clk_disable_unprepare(ssp->clk); 1277
1278 if (!pm_runtime_suspended(dev))
1279 clk_disable_unprepare(ssp->clk);
1278 1280
1279 return 0; 1281 return 0;
1280} 1282}
@@ -1288,7 +1290,8 @@ static int pxa2xx_spi_resume(struct device *dev)
1288 pxa2xx_spi_dma_resume(drv_data); 1290 pxa2xx_spi_dma_resume(drv_data);
1289 1291
1290 /* Enable the SSP clock */ 1292 /* Enable the SSP clock */
1291 clk_prepare_enable(ssp->clk); 1293 if (!pm_runtime_suspended(dev))
1294 clk_prepare_enable(ssp->clk);
1292 1295
1293 /* Restore LPSS private register bits */ 1296 /* Restore LPSS private register bits */
1294 lpss_ssp_setup(drv_data); 1297 lpss_ssp_setup(drv_data);
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index 28b93d39a94e..a673ffa34aa3 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -420,7 +420,7 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
420 struct logger_log *log = file_get_log(iocb->ki_filp); 420 struct logger_log *log = file_get_log(iocb->ki_filp);
421 struct logger_entry header; 421 struct logger_entry header;
422 struct timespec now; 422 struct timespec now;
423 size_t len, count; 423 size_t len, count, w_off;
424 424
425 count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD); 425 count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD);
426 426
@@ -452,11 +452,14 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
452 memcpy(log->buffer + log->w_off, &header, len); 452 memcpy(log->buffer + log->w_off, &header, len);
453 memcpy(log->buffer, (char *)&header + len, sizeof(header) - len); 453 memcpy(log->buffer, (char *)&header + len, sizeof(header) - len);
454 454
455 len = min(count, log->size - log->w_off); 455 /* Work with a copy until we are ready to commit the whole entry */
456 w_off = logger_offset(log, log->w_off + sizeof(struct logger_entry));
456 457
457 if (copy_from_iter(log->buffer + log->w_off, len, from) != len) { 458 len = min(count, log->size - w_off);
459
460 if (copy_from_iter(log->buffer + w_off, len, from) != len) {
458 /* 461 /*
459 * Note that by not updating w_off, this abandons the 462 * Note that by not updating log->w_off, this abandons the
460 * portion of the new entry that *was* successfully 463 * portion of the new entry that *was* successfully
461 * copied, just above. This is intentional to avoid 464 * copied, just above. This is intentional to avoid
462 * message corruption from missing fragments. 465 * message corruption from missing fragments.
@@ -470,7 +473,7 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
470 return -EFAULT; 473 return -EFAULT;
471 } 474 }
472 475
473 log->w_off = logger_offset(log, log->w_off + count); 476 log->w_off = logger_offset(log, w_off + count);
474 mutex_unlock(&log->mutex); 477 mutex_unlock(&log->mutex);
475 478
476 /* wake up any blocked readers */ 479 /* wake up any blocked readers */
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index a8bc2b567789..152f4c12ea43 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -426,6 +426,7 @@ config COMEDI_AIO_IIRO_16
426 426
427config COMEDI_II_PCI20KC 427config COMEDI_II_PCI20KC
428 tristate "Intelligent Instruments PCI-20001C carrier support" 428 tristate "Intelligent Instruments PCI-20001C carrier support"
429 depends on HAS_IOMEM
429 ---help--- 430 ---help---
430 Enable support for Intelligent Instruments PCI-20001C carrier 431 Enable support for Intelligent Instruments PCI-20001C carrier
431 PCI-20001, PCI-20006 and PCI-20341 432 PCI-20001, PCI-20006 and PCI-20341
@@ -667,7 +668,6 @@ config COMEDI_ADDI_APCI_2200
667config COMEDI_ADDI_APCI_3120 668config COMEDI_ADDI_APCI_3120
668 tristate "ADDI-DATA APCI_3120/3001 support" 669 tristate "ADDI-DATA APCI_3120/3001 support"
669 depends on HAS_DMA 670 depends on HAS_DMA
670 depends on VIRT_TO_BUS
671 ---help--- 671 ---help---
672 Enable support for ADDI-DATA APCI_3120/3001 cards 672 Enable support for ADDI-DATA APCI_3120/3001 cards
673 673
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 495969f46e76..9c32f0276009 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1462,10 +1462,7 @@ static int __comedi_get_user_chanlist(struct comedi_device *dev,
1462 unsigned int *chanlist; 1462 unsigned int *chanlist;
1463 int ret; 1463 int ret;
1464 1464
1465 /* user_chanlist could be NULL for do_cmdtest ioctls */ 1465 cmd->chanlist = NULL;
1466 if (!user_chanlist)
1467 return 0;
1468
1469 chanlist = memdup_user(user_chanlist, 1466 chanlist = memdup_user(user_chanlist,
1470 cmd->chanlist_len * sizeof(unsigned int)); 1467 cmd->chanlist_len * sizeof(unsigned int));
1471 if (IS_ERR(chanlist)) 1468 if (IS_ERR(chanlist))
@@ -1609,13 +1606,18 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
1609 1606
1610 s = &dev->subdevices[cmd.subdev]; 1607 s = &dev->subdevices[cmd.subdev];
1611 1608
1612 /* load channel/gain list */ 1609 /* user_chanlist can be NULL for COMEDI_CMDTEST ioctl */
1613 ret = __comedi_get_user_chanlist(dev, s, user_chanlist, &cmd); 1610 if (user_chanlist) {
1614 if (ret) 1611 /* load channel/gain list */
1615 return ret; 1612 ret = __comedi_get_user_chanlist(dev, s, user_chanlist, &cmd);
1613 if (ret)
1614 return ret;
1615 }
1616 1616
1617 ret = s->do_cmdtest(dev, s, &cmd); 1617 ret = s->do_cmdtest(dev, s, &cmd);
1618 1618
1619 kfree(cmd.chanlist); /* free kernel copy of user chanlist */
1620
1619 /* restore chanlist pointer before copying back */ 1621 /* restore chanlist pointer before copying back */
1620 cmd.chanlist = (unsigned int __force *)user_chanlist; 1622 cmd.chanlist = (unsigned int __force *)user_chanlist;
1621 1623
@@ -1642,7 +1644,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
1642 1644
1643*/ 1645*/
1644 1646
1645static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, 1647static int do_lock_ioctl(struct comedi_device *dev, unsigned long arg,
1646 void *file) 1648 void *file)
1647{ 1649{
1648 int ret = 0; 1650 int ret = 0;
@@ -1679,7 +1681,7 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
1679 This function isn't protected by the semaphore, since 1681 This function isn't protected by the semaphore, since
1680 we already own the lock. 1682 we already own the lock.
1681*/ 1683*/
1682static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, 1684static int do_unlock_ioctl(struct comedi_device *dev, unsigned long arg,
1683 void *file) 1685 void *file)
1684{ 1686{
1685 struct comedi_subdevice *s; 1687 struct comedi_subdevice *s;
@@ -1714,7 +1716,7 @@ static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
1714 nothing 1716 nothing
1715 1717
1716*/ 1718*/
1717static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, 1719static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
1718 void *file) 1720 void *file)
1719{ 1721{
1720 struct comedi_subdevice *s; 1722 struct comedi_subdevice *s;
@@ -1751,7 +1753,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
1751 nothing 1753 nothing
1752 1754
1753*/ 1755*/
1754static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, 1756static int do_poll_ioctl(struct comedi_device *dev, unsigned long arg,
1755 void *file) 1757 void *file)
1756{ 1758{
1757 struct comedi_subdevice *s; 1759 struct comedi_subdevice *s;
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 32a19264a170..2a29b9baec0d 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -1559,14 +1559,16 @@ static int mxs_lradc_probe(struct platform_device *pdev)
1559 /* Grab all IRQ sources */ 1559 /* Grab all IRQ sources */
1560 for (i = 0; i < of_cfg->irq_count; i++) { 1560 for (i = 0; i < of_cfg->irq_count; i++) {
1561 lradc->irq[i] = platform_get_irq(pdev, i); 1561 lradc->irq[i] = platform_get_irq(pdev, i);
1562 if (lradc->irq[i] < 0) 1562 if (lradc->irq[i] < 0) {
1563 return lradc->irq[i]; 1563 ret = lradc->irq[i];
1564 goto err_clk;
1565 }
1564 1566
1565 ret = devm_request_irq(dev, lradc->irq[i], 1567 ret = devm_request_irq(dev, lradc->irq[i],
1566 mxs_lradc_handle_irq, 0, 1568 mxs_lradc_handle_irq, 0,
1567 of_cfg->irq_name[i], iio); 1569 of_cfg->irq_name[i], iio);
1568 if (ret) 1570 if (ret)
1569 return ret; 1571 goto err_clk;
1570 } 1572 }
1571 1573
1572 lradc->vref_mv = of_cfg->vref_mv; 1574 lradc->vref_mv = of_cfg->vref_mv;
@@ -1588,7 +1590,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
1588 &mxs_lradc_trigger_handler, 1590 &mxs_lradc_trigger_handler,
1589 &mxs_lradc_buffer_ops); 1591 &mxs_lradc_buffer_ops);
1590 if (ret) 1592 if (ret)
1591 return ret; 1593 goto err_clk;
1592 1594
1593 ret = mxs_lradc_trigger_init(iio); 1595 ret = mxs_lradc_trigger_init(iio);
1594 if (ret) 1596 if (ret)
@@ -1643,6 +1645,8 @@ err_dev:
1643 mxs_lradc_trigger_remove(iio); 1645 mxs_lradc_trigger_remove(iio);
1644err_trig: 1646err_trig:
1645 iio_triggered_buffer_cleanup(iio); 1647 iio_triggered_buffer_cleanup(iio);
1648err_clk:
1649 clk_disable_unprepare(lradc->clk);
1646 return ret; 1650 return ret;
1647} 1651}
1648 1652
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index d0c89d0457de..b6bd609c3655 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -115,6 +115,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
115 .channel = 0, 115 .channel = 0,
116 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), 116 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
117 .address = AD5933_REG_TEMP_DATA, 117 .address = AD5933_REG_TEMP_DATA,
118 .scan_index = -1,
118 .scan_type = { 119 .scan_type = {
119 .sign = 's', 120 .sign = 's',
120 .realbits = 14, 121 .realbits = 14,
@@ -124,9 +125,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
124 .type = IIO_VOLTAGE, 125 .type = IIO_VOLTAGE,
125 .indexed = 1, 126 .indexed = 1,
126 .channel = 0, 127 .channel = 0,
127 .extend_name = "real_raw", 128 .extend_name = "real",
128 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
129 BIT(IIO_CHAN_INFO_SCALE),
130 .address = AD5933_REG_REAL_DATA, 129 .address = AD5933_REG_REAL_DATA,
131 .scan_index = 0, 130 .scan_index = 0,
132 .scan_type = { 131 .scan_type = {
@@ -138,9 +137,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
138 .type = IIO_VOLTAGE, 137 .type = IIO_VOLTAGE,
139 .indexed = 1, 138 .indexed = 1,
140 .channel = 0, 139 .channel = 0,
141 .extend_name = "imag_raw", 140 .extend_name = "imag",
142 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
143 BIT(IIO_CHAN_INFO_SCALE),
144 .address = AD5933_REG_IMAG_DATA, 141 .address = AD5933_REG_IMAG_DATA,
145 .scan_index = 1, 142 .scan_index = 1,
146 .scan_type = { 143 .scan_type = {
@@ -749,14 +746,14 @@ static int ad5933_probe(struct i2c_client *client,
749 indio_dev->name = id->name; 746 indio_dev->name = id->name;
750 indio_dev->modes = INDIO_DIRECT_MODE; 747 indio_dev->modes = INDIO_DIRECT_MODE;
751 indio_dev->channels = ad5933_channels; 748 indio_dev->channels = ad5933_channels;
752 indio_dev->num_channels = 1; /* only register temp0_input */ 749 indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
753 750
754 ret = ad5933_register_ring_funcs_and_init(indio_dev); 751 ret = ad5933_register_ring_funcs_and_init(indio_dev);
755 if (ret) 752 if (ret)
756 goto error_disable_reg; 753 goto error_disable_reg;
757 754
758 /* skip temp0_input, register in0_(real|imag)_raw */ 755 ret = iio_buffer_register(indio_dev, ad5933_channels,
759 ret = iio_buffer_register(indio_dev, &ad5933_channels[1], 2); 756 ARRAY_SIZE(ad5933_channels));
760 if (ret) 757 if (ret)
761 goto error_unreg_ring; 758 goto error_unreg_ring;
762 759
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
index 07318203a836..e8c98cf57070 100644
--- a/drivers/staging/iio/meter/ade7758.h
+++ b/drivers/staging/iio/meter/ade7758.h
@@ -119,7 +119,6 @@ struct ade7758_state {
119 u8 *tx; 119 u8 *tx;
120 u8 *rx; 120 u8 *rx;
121 struct mutex buf_lock; 121 struct mutex buf_lock;
122 const struct iio_chan_spec *ade7758_ring_channels;
123 struct spi_transfer ring_xfer[4]; 122 struct spi_transfer ring_xfer[4];
124 struct spi_message ring_msg; 123 struct spi_message ring_msg;
125 /* 124 /*
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
index abc60067cd72..fb373b89dcc2 100644
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ b/drivers/staging/iio/meter/ade7758_core.c
@@ -634,9 +634,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
634 .type = IIO_VOLTAGE, 634 .type = IIO_VOLTAGE,
635 .indexed = 1, 635 .indexed = 1,
636 .channel = 0, 636 .channel = 0,
637 .extend_name = "raw",
638 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
639 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
640 .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE), 637 .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
641 .scan_index = 0, 638 .scan_index = 0,
642 .scan_type = { 639 .scan_type = {
@@ -648,9 +645,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
648 .type = IIO_CURRENT, 645 .type = IIO_CURRENT,
649 .indexed = 1, 646 .indexed = 1,
650 .channel = 0, 647 .channel = 0,
651 .extend_name = "raw",
652 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
653 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
654 .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT), 648 .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
655 .scan_index = 1, 649 .scan_index = 1,
656 .scan_type = { 650 .scan_type = {
@@ -662,9 +656,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
662 .type = IIO_POWER, 656 .type = IIO_POWER,
663 .indexed = 1, 657 .indexed = 1,
664 .channel = 0, 658 .channel = 0,
665 .extend_name = "apparent_raw", 659 .extend_name = "apparent",
666 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
667 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
668 .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR), 660 .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
669 .scan_index = 2, 661 .scan_index = 2,
670 .scan_type = { 662 .scan_type = {
@@ -676,9 +668,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
676 .type = IIO_POWER, 668 .type = IIO_POWER,
677 .indexed = 1, 669 .indexed = 1,
678 .channel = 0, 670 .channel = 0,
679 .extend_name = "active_raw", 671 .extend_name = "active",
680 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
681 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
682 .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR), 672 .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
683 .scan_index = 3, 673 .scan_index = 3,
684 .scan_type = { 674 .scan_type = {
@@ -690,9 +680,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
690 .type = IIO_POWER, 680 .type = IIO_POWER,
691 .indexed = 1, 681 .indexed = 1,
692 .channel = 0, 682 .channel = 0,
693 .extend_name = "reactive_raw", 683 .extend_name = "reactive",
694 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
695 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
696 .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR), 684 .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
697 .scan_index = 4, 685 .scan_index = 4,
698 .scan_type = { 686 .scan_type = {
@@ -704,9 +692,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
704 .type = IIO_VOLTAGE, 692 .type = IIO_VOLTAGE,
705 .indexed = 1, 693 .indexed = 1,
706 .channel = 1, 694 .channel = 1,
707 .extend_name = "raw",
708 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
709 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
710 .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE), 695 .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
711 .scan_index = 5, 696 .scan_index = 5,
712 .scan_type = { 697 .scan_type = {
@@ -718,9 +703,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
718 .type = IIO_CURRENT, 703 .type = IIO_CURRENT,
719 .indexed = 1, 704 .indexed = 1,
720 .channel = 1, 705 .channel = 1,
721 .extend_name = "raw",
722 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
723 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
724 .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT), 706 .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
725 .scan_index = 6, 707 .scan_index = 6,
726 .scan_type = { 708 .scan_type = {
@@ -732,9 +714,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
732 .type = IIO_POWER, 714 .type = IIO_POWER,
733 .indexed = 1, 715 .indexed = 1,
734 .channel = 1, 716 .channel = 1,
735 .extend_name = "apparent_raw", 717 .extend_name = "apparent",
736 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
737 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
738 .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR), 718 .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
739 .scan_index = 7, 719 .scan_index = 7,
740 .scan_type = { 720 .scan_type = {
@@ -746,9 +726,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
746 .type = IIO_POWER, 726 .type = IIO_POWER,
747 .indexed = 1, 727 .indexed = 1,
748 .channel = 1, 728 .channel = 1,
749 .extend_name = "active_raw", 729 .extend_name = "active",
750 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
751 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
752 .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR), 730 .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
753 .scan_index = 8, 731 .scan_index = 8,
754 .scan_type = { 732 .scan_type = {
@@ -760,9 +738,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
760 .type = IIO_POWER, 738 .type = IIO_POWER,
761 .indexed = 1, 739 .indexed = 1,
762 .channel = 1, 740 .channel = 1,
763 .extend_name = "reactive_raw", 741 .extend_name = "reactive",
764 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
765 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
766 .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR), 742 .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
767 .scan_index = 9, 743 .scan_index = 9,
768 .scan_type = { 744 .scan_type = {
@@ -774,9 +750,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
774 .type = IIO_VOLTAGE, 750 .type = IIO_VOLTAGE,
775 .indexed = 1, 751 .indexed = 1,
776 .channel = 2, 752 .channel = 2,
777 .extend_name = "raw",
778 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
779 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
780 .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE), 753 .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
781 .scan_index = 10, 754 .scan_index = 10,
782 .scan_type = { 755 .scan_type = {
@@ -788,9 +761,6 @@ static const struct iio_chan_spec ade7758_channels[] = {
788 .type = IIO_CURRENT, 761 .type = IIO_CURRENT,
789 .indexed = 1, 762 .indexed = 1,
790 .channel = 2, 763 .channel = 2,
791 .extend_name = "raw",
792 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
793 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
794 .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT), 764 .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
795 .scan_index = 11, 765 .scan_index = 11,
796 .scan_type = { 766 .scan_type = {
@@ -802,9 +772,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
802 .type = IIO_POWER, 772 .type = IIO_POWER,
803 .indexed = 1, 773 .indexed = 1,
804 .channel = 2, 774 .channel = 2,
805 .extend_name = "apparent_raw", 775 .extend_name = "apparent",
806 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
807 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
808 .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR), 776 .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
809 .scan_index = 12, 777 .scan_index = 12,
810 .scan_type = { 778 .scan_type = {
@@ -816,9 +784,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
816 .type = IIO_POWER, 784 .type = IIO_POWER,
817 .indexed = 1, 785 .indexed = 1,
818 .channel = 2, 786 .channel = 2,
819 .extend_name = "active_raw", 787 .extend_name = "active",
820 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
821 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
822 .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR), 788 .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
823 .scan_index = 13, 789 .scan_index = 13,
824 .scan_type = { 790 .scan_type = {
@@ -830,9 +796,7 @@ static const struct iio_chan_spec ade7758_channels[] = {
830 .type = IIO_POWER, 796 .type = IIO_POWER,
831 .indexed = 1, 797 .indexed = 1,
832 .channel = 2, 798 .channel = 2,
833 .extend_name = "reactive_raw", 799 .extend_name = "reactive",
834 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
835 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
836 .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR), 800 .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
837 .scan_index = 14, 801 .scan_index = 14,
838 .scan_type = { 802 .scan_type = {
@@ -873,13 +837,14 @@ static int ade7758_probe(struct spi_device *spi)
873 goto error_free_rx; 837 goto error_free_rx;
874 } 838 }
875 st->us = spi; 839 st->us = spi;
876 st->ade7758_ring_channels = &ade7758_channels[0];
877 mutex_init(&st->buf_lock); 840 mutex_init(&st->buf_lock);
878 841
879 indio_dev->name = spi->dev.driver->name; 842 indio_dev->name = spi->dev.driver->name;
880 indio_dev->dev.parent = &spi->dev; 843 indio_dev->dev.parent = &spi->dev;
881 indio_dev->info = &ade7758_info; 844 indio_dev->info = &ade7758_info;
882 indio_dev->modes = INDIO_DIRECT_MODE; 845 indio_dev->modes = INDIO_DIRECT_MODE;
846 indio_dev->channels = ade7758_channels;
847 indio_dev->num_channels = ARRAY_SIZE(ade7758_channels);
883 848
884 ret = ade7758_configure_ring(indio_dev); 849 ret = ade7758_configure_ring(indio_dev);
885 if (ret) 850 if (ret)
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
index c0accf8cce93..6e9006490742 100644
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ b/drivers/staging/iio/meter/ade7758_ring.c
@@ -85,17 +85,16 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
85 **/ 85 **/
86static int ade7758_ring_preenable(struct iio_dev *indio_dev) 86static int ade7758_ring_preenable(struct iio_dev *indio_dev)
87{ 87{
88 struct ade7758_state *st = iio_priv(indio_dev);
89 unsigned channel; 88 unsigned channel;
90 89
91 if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) 90 if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
92 return -EINVAL; 91 return -EINVAL;
93 92
94 channel = find_first_bit(indio_dev->active_scan_mask, 93 channel = find_first_bit(indio_dev->active_scan_mask,
95 indio_dev->masklength); 94 indio_dev->masklength);
96 95
97 ade7758_write_waveform_type(&indio_dev->dev, 96 ade7758_write_waveform_type(&indio_dev->dev,
98 st->ade7758_ring_channels[channel].address); 97 indio_dev->channels[channel].address);
99 98
100 return 0; 99 return 0;
101} 100}
diff --git a/drivers/staging/rtl8723au/include/rtw_eeprom.h b/drivers/staging/rtl8723au/include/rtw_eeprom.h
index e5121a2a64b4..a86f36e49dd1 100644
--- a/drivers/staging/rtl8723au/include/rtw_eeprom.h
+++ b/drivers/staging/rtl8723au/include/rtw_eeprom.h
@@ -107,12 +107,12 @@ enum rt_customer_id
107}; 107};
108 108
109struct eeprom_priv { 109struct eeprom_priv {
110 u8 mac_addr[6]; /* PermanentAddress */
110 u8 bautoload_fail_flag; 111 u8 bautoload_fail_flag;
111 u8 bloadfile_fail_flag; 112 u8 bloadfile_fail_flag;
112 u8 bloadmac_fail_flag; 113 u8 bloadmac_fail_flag;
113 /* u8 bempty; */ 114 /* u8 bempty; */
114 /* u8 sys_config; */ 115 /* u8 sys_config; */
115 u8 mac_addr[6]; /* PermanentAddress */
116 /* u8 config0; */ 116 /* u8 config0; */
117 u16 channel_plan; 117 u16 channel_plan;
118 /* u8 country_string[3]; */ 118 /* u8 country_string[3]; */
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index f8eb625b8400..62143ba31001 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -387,15 +387,18 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
387 int (*get_trend)(void *, long *)) 387 int (*get_trend)(void *, long *))
388{ 388{
389 struct device_node *np, *child, *sensor_np; 389 struct device_node *np, *child, *sensor_np;
390 struct thermal_zone_device *tzd = ERR_PTR(-ENODEV);
390 391
391 np = of_find_node_by_name(NULL, "thermal-zones"); 392 np = of_find_node_by_name(NULL, "thermal-zones");
392 if (!np) 393 if (!np)
393 return ERR_PTR(-ENODEV); 394 return ERR_PTR(-ENODEV);
394 395
395 if (!dev || !dev->of_node) 396 if (!dev || !dev->of_node) {
397 of_node_put(np);
396 return ERR_PTR(-EINVAL); 398 return ERR_PTR(-EINVAL);
399 }
397 400
398 sensor_np = dev->of_node; 401 sensor_np = of_node_get(dev->of_node);
399 402
400 for_each_child_of_node(np, child) { 403 for_each_child_of_node(np, child) {
401 struct of_phandle_args sensor_specs; 404 struct of_phandle_args sensor_specs;
@@ -422,16 +425,21 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id,
422 } 425 }
423 426
424 if (sensor_specs.np == sensor_np && id == sensor_id) { 427 if (sensor_specs.np == sensor_np && id == sensor_id) {
425 of_node_put(np); 428 tzd = thermal_zone_of_add_sensor(child, sensor_np,
426 return thermal_zone_of_add_sensor(child, sensor_np, 429 data,
427 data, 430 get_temp,
428 get_temp, 431 get_trend);
429 get_trend); 432 of_node_put(sensor_specs.np);
433 of_node_put(child);
434 goto exit;
430 } 435 }
436 of_node_put(sensor_specs.np);
431 } 437 }
438exit:
439 of_node_put(sensor_np);
432 of_node_put(np); 440 of_node_put(np);
433 441
434 return ERR_PTR(-ENODEV); 442 return tzd;
435} 443}
436EXPORT_SYMBOL_GPL(thermal_zone_of_sensor_register); 444EXPORT_SYMBOL_GPL(thermal_zone_of_sensor_register);
437 445
@@ -623,6 +631,7 @@ static int thermal_of_populate_trip(struct device_node *np,
623 631
624 /* Required for cooling map matching */ 632 /* Required for cooling map matching */
625 trip->np = np; 633 trip->np = np;
634 of_node_get(np);
626 635
627 return 0; 636 return 0;
628} 637}
@@ -730,9 +739,14 @@ finish:
730 return tz; 739 return tz;
731 740
732free_tbps: 741free_tbps:
742 for (i = 0; i < tz->num_tbps; i++)
743 of_node_put(tz->tbps[i].cooling_device);
733 kfree(tz->tbps); 744 kfree(tz->tbps);
734free_trips: 745free_trips:
746 for (i = 0; i < tz->ntrips; i++)
747 of_node_put(tz->trips[i].np);
735 kfree(tz->trips); 748 kfree(tz->trips);
749 of_node_put(gchild);
736free_tz: 750free_tz:
737 kfree(tz); 751 kfree(tz);
738 of_node_put(child); 752 of_node_put(child);
@@ -742,7 +756,13 @@ free_tz:
742 756
743static inline void of_thermal_free_zone(struct __thermal_zone *tz) 757static inline void of_thermal_free_zone(struct __thermal_zone *tz)
744{ 758{
759 int i;
760
761 for (i = 0; i < tz->num_tbps; i++)
762 of_node_put(tz->tbps[i].cooling_device);
745 kfree(tz->tbps); 763 kfree(tz->tbps);
764 for (i = 0; i < tz->ntrips; i++)
765 of_node_put(tz->trips[i].np);
746 kfree(tz->trips); 766 kfree(tz->trips);
747 kfree(tz); 767 kfree(tz);
748} 768}
@@ -814,10 +834,13 @@ int __init of_parse_thermal_zones(void)
814 /* attempting to build remaining zones still */ 834 /* attempting to build remaining zones still */
815 } 835 }
816 } 836 }
837 of_node_put(np);
817 838
818 return 0; 839 return 0;
819 840
820exit_free: 841exit_free:
842 of_node_put(child);
843 of_node_put(np);
821 of_thermal_free_zone(tz); 844 of_thermal_free_zone(tz);
822 845
823 /* no memory available, so free what we have built */ 846 /* no memory available, so free what we have built */
@@ -859,4 +882,5 @@ void of_thermal_destroy_zones(void)
859 kfree(zone->ops); 882 kfree(zone->ops);
860 of_thermal_free_zone(zone->devdata); 883 of_thermal_free_zone(zone->devdata);
861 } 884 }
885 of_node_put(np);
862} 886}
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h
index 3eb2ed9ea3a4..158f5aa8dc5d 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ b/drivers/thermal/samsung/exynos_thermal_common.h
@@ -27,7 +27,7 @@
27#define SENSOR_NAME_LEN 16 27#define SENSOR_NAME_LEN 16
28#define MAX_TRIP_COUNT 8 28#define MAX_TRIP_COUNT 8
29#define MAX_COOLING_DEVICE 4 29#define MAX_COOLING_DEVICE 4
30#define MAX_THRESHOLD_LEVS 5 30#define MAX_TRIMINFO_CTRL_REG 2
31 31
32#define ACTIVE_INTERVAL 500 32#define ACTIVE_INTERVAL 500
33#define IDLE_INTERVAL 10000 33#define IDLE_INTERVAL 10000
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index acbff14da3a4..49c09243fd38 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -77,16 +77,6 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
77 struct exynos_tmu_platform_data *pdata = data->pdata; 77 struct exynos_tmu_platform_data *pdata = data->pdata;
78 int temp_code; 78 int temp_code;
79 79
80 if (pdata->cal_mode == HW_MODE)
81 return temp;
82
83 if (data->soc == SOC_ARCH_EXYNOS4210)
84 /* temp should range between 25 and 125 */
85 if (temp < 25 || temp > 125) {
86 temp_code = -EINVAL;
87 goto out;
88 }
89
90 switch (pdata->cal_type) { 80 switch (pdata->cal_type) {
91 case TYPE_TWO_POINT_TRIMMING: 81 case TYPE_TWO_POINT_TRIMMING:
92 temp_code = (temp - pdata->first_point_trim) * 82 temp_code = (temp - pdata->first_point_trim) *
@@ -101,7 +91,7 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
101 temp_code = temp + pdata->default_temp_offset; 91 temp_code = temp + pdata->default_temp_offset;
102 break; 92 break;
103 } 93 }
104out: 94
105 return temp_code; 95 return temp_code;
106} 96}
107 97
@@ -114,16 +104,6 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
114 struct exynos_tmu_platform_data *pdata = data->pdata; 104 struct exynos_tmu_platform_data *pdata = data->pdata;
115 int temp; 105 int temp;
116 106
117 if (pdata->cal_mode == HW_MODE)
118 return temp_code;
119
120 if (data->soc == SOC_ARCH_EXYNOS4210)
121 /* temp_code should range between 75 and 175 */
122 if (temp_code < 75 || temp_code > 175) {
123 temp = -ENODATA;
124 goto out;
125 }
126
127 switch (pdata->cal_type) { 107 switch (pdata->cal_type) {
128 case TYPE_TWO_POINT_TRIMMING: 108 case TYPE_TWO_POINT_TRIMMING:
129 temp = (temp_code - data->temp_error1) * 109 temp = (temp_code - data->temp_error1) *
@@ -138,18 +118,35 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code)
138 temp = temp_code - pdata->default_temp_offset; 118 temp = temp_code - pdata->default_temp_offset;
139 break; 119 break;
140 } 120 }
141out: 121
142 return temp; 122 return temp;
143} 123}
144 124
125static void exynos_tmu_clear_irqs(struct exynos_tmu_data *data)
126{
127 const struct exynos_tmu_registers *reg = data->pdata->registers;
128 unsigned int val_irq;
129
130 val_irq = readl(data->base + reg->tmu_intstat);
131 /*
132 * Clear the interrupts. Please note that the documentation for
133 * Exynos3250, Exynos4412, Exynos5250 and Exynos5260 incorrectly
134 * states that INTCLEAR register has a different placing of bits
135 * responsible for FALL IRQs than INTSTAT register. Exynos5420
136 * and Exynos5440 documentation is correct (Exynos4210 doesn't
137 * support FALL IRQs at all).
138 */
139 writel(val_irq, data->base + reg->tmu_intclear);
140}
141
145static int exynos_tmu_initialize(struct platform_device *pdev) 142static int exynos_tmu_initialize(struct platform_device *pdev)
146{ 143{
147 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 144 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
148 struct exynos_tmu_platform_data *pdata = data->pdata; 145 struct exynos_tmu_platform_data *pdata = data->pdata;
149 const struct exynos_tmu_registers *reg = pdata->registers; 146 const struct exynos_tmu_registers *reg = pdata->registers;
150 unsigned int status, trim_info = 0, con; 147 unsigned int status, trim_info = 0, con, ctrl;
151 unsigned int rising_threshold = 0, falling_threshold = 0; 148 unsigned int rising_threshold = 0, falling_threshold = 0;
152 int ret = 0, threshold_code, i, trigger_levs = 0; 149 int ret = 0, threshold_code, i;
153 150
154 mutex_lock(&data->lock); 151 mutex_lock(&data->lock);
155 clk_enable(data->clk); 152 clk_enable(data->clk);
@@ -164,11 +161,17 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
164 } 161 }
165 } 162 }
166 163
167 if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) 164 if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) {
168 __raw_writel(1, data->base + reg->triminfo_ctrl); 165 for (i = 0; i < reg->triminfo_ctrl_count; i++) {
169 166 if (pdata->triminfo_reload[i]) {
170 if (pdata->cal_mode == HW_MODE) 167 ctrl = readl(data->base +
171 goto skip_calib_data; 168 reg->triminfo_ctrl[i]);
169 ctrl |= pdata->triminfo_reload[i];
170 writel(ctrl, data->base +
171 reg->triminfo_ctrl[i]);
172 }
173 }
174 }
172 175
173 /* Save trimming info in order to perform calibration */ 176 /* Save trimming info in order to perform calibration */
174 if (data->soc == SOC_ARCH_EXYNOS5440) { 177 if (data->soc == SOC_ARCH_EXYNOS5440) {
@@ -197,7 +200,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
197 trim_info = readl(data->base + reg->triminfo_data); 200 trim_info = readl(data->base + reg->triminfo_data);
198 } 201 }
199 data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK; 202 data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
200 data->temp_error2 = ((trim_info >> reg->triminfo_85_shift) & 203 data->temp_error2 = ((trim_info >> EXYNOS_TRIMINFO_85_SHIFT) &
201 EXYNOS_TMU_TEMP_MASK); 204 EXYNOS_TMU_TEMP_MASK);
202 205
203 if (!data->temp_error1 || 206 if (!data->temp_error1 ||
@@ -207,67 +210,33 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
207 210
208 if (!data->temp_error2) 211 if (!data->temp_error2)
209 data->temp_error2 = 212 data->temp_error2 =
210 (pdata->efuse_value >> reg->triminfo_85_shift) & 213 (pdata->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
211 EXYNOS_TMU_TEMP_MASK; 214 EXYNOS_TMU_TEMP_MASK;
212 215
213skip_calib_data:
214 if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
215 dev_err(&pdev->dev, "Invalid max trigger level\n");
216 ret = -EINVAL;
217 goto out;
218 }
219
220 for (i = 0; i < pdata->max_trigger_level; i++) {
221 if (!pdata->trigger_levels[i])
222 continue;
223
224 if ((pdata->trigger_type[i] == HW_TRIP) &&
225 (!pdata->trigger_levels[pdata->max_trigger_level - 1])) {
226 dev_err(&pdev->dev, "Invalid hw trigger level\n");
227 ret = -EINVAL;
228 goto out;
229 }
230
231 /* Count trigger levels except the HW trip*/
232 if (!(pdata->trigger_type[i] == HW_TRIP))
233 trigger_levs++;
234 }
235
236 rising_threshold = readl(data->base + reg->threshold_th0); 216 rising_threshold = readl(data->base + reg->threshold_th0);
237 217
238 if (data->soc == SOC_ARCH_EXYNOS4210) { 218 if (data->soc == SOC_ARCH_EXYNOS4210) {
239 /* Write temperature code for threshold */ 219 /* Write temperature code for threshold */
240 threshold_code = temp_to_code(data, pdata->threshold); 220 threshold_code = temp_to_code(data, pdata->threshold);
241 if (threshold_code < 0) {
242 ret = threshold_code;
243 goto out;
244 }
245 writeb(threshold_code, 221 writeb(threshold_code,
246 data->base + reg->threshold_temp); 222 data->base + reg->threshold_temp);
247 for (i = 0; i < trigger_levs; i++) 223 for (i = 0; i < pdata->non_hw_trigger_levels; i++)
248 writeb(pdata->trigger_levels[i], data->base + 224 writeb(pdata->trigger_levels[i], data->base +
249 reg->threshold_th0 + i * sizeof(reg->threshold_th0)); 225 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
250 226
251 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear); 227 exynos_tmu_clear_irqs(data);
252 } else { 228 } else {
253 /* Write temperature code for rising and falling threshold */ 229 /* Write temperature code for rising and falling threshold */
254 for (i = 0; 230 for (i = 0; i < pdata->non_hw_trigger_levels; i++) {
255 i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
256 threshold_code = temp_to_code(data, 231 threshold_code = temp_to_code(data,
257 pdata->trigger_levels[i]); 232 pdata->trigger_levels[i]);
258 if (threshold_code < 0) {
259 ret = threshold_code;
260 goto out;
261 }
262 rising_threshold &= ~(0xff << 8 * i); 233 rising_threshold &= ~(0xff << 8 * i);
263 rising_threshold |= threshold_code << 8 * i; 234 rising_threshold |= threshold_code << 8 * i;
264 if (pdata->threshold_falling) { 235 if (pdata->threshold_falling) {
265 threshold_code = temp_to_code(data, 236 threshold_code = temp_to_code(data,
266 pdata->trigger_levels[i] - 237 pdata->trigger_levels[i] -
267 pdata->threshold_falling); 238 pdata->threshold_falling);
268 if (threshold_code > 0) 239 falling_threshold |= threshold_code << 8 * i;
269 falling_threshold |=
270 threshold_code << 8 * i;
271 } 240 }
272 } 241 }
273 242
@@ -276,9 +245,7 @@ skip_calib_data:
276 writel(falling_threshold, 245 writel(falling_threshold,
277 data->base + reg->threshold_th1); 246 data->base + reg->threshold_th1);
278 247
279 writel((reg->intclr_rise_mask << reg->intclr_rise_shift) | 248 exynos_tmu_clear_irqs(data);
280 (reg->intclr_fall_mask << reg->intclr_fall_shift),
281 data->base + reg->tmu_intclear);
282 249
283 /* if last threshold limit is also present */ 250 /* if last threshold limit is also present */
284 i = pdata->max_trigger_level - 1; 251 i = pdata->max_trigger_level - 1;
@@ -286,10 +253,6 @@ skip_calib_data:
286 (pdata->trigger_type[i] == HW_TRIP)) { 253 (pdata->trigger_type[i] == HW_TRIP)) {
287 threshold_code = temp_to_code(data, 254 threshold_code = temp_to_code(data,
288 pdata->trigger_levels[i]); 255 pdata->trigger_levels[i]);
289 if (threshold_code < 0) {
290 ret = threshold_code;
291 goto out;
292 }
293 if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) { 256 if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
294 /* 1-4 level to be assigned in th0 reg */ 257 /* 1-4 level to be assigned in th0 reg */
295 rising_threshold &= ~(0xff << 8 * i); 258 rising_threshold &= ~(0xff << 8 * i);
@@ -325,7 +288,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
325 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 288 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
326 struct exynos_tmu_platform_data *pdata = data->pdata; 289 struct exynos_tmu_platform_data *pdata = data->pdata;
327 const struct exynos_tmu_registers *reg = pdata->registers; 290 const struct exynos_tmu_registers *reg = pdata->registers;
328 unsigned int con, interrupt_en, cal_val; 291 unsigned int con, interrupt_en;
329 292
330 mutex_lock(&data->lock); 293 mutex_lock(&data->lock);
331 clk_enable(data->clk); 294 clk_enable(data->clk);
@@ -335,15 +298,11 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
335 if (pdata->test_mux) 298 if (pdata->test_mux)
336 con |= (pdata->test_mux << reg->test_mux_addr_shift); 299 con |= (pdata->test_mux << reg->test_mux_addr_shift);
337 300
338 if (pdata->reference_voltage) { 301 con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << EXYNOS_TMU_REF_VOLTAGE_SHIFT);
339 con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift); 302 con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
340 con |= pdata->reference_voltage << reg->buf_vref_sel_shift;
341 }
342 303
343 if (pdata->gain) { 304 con &= ~(EXYNOS_TMU_BUF_SLOPE_SEL_MASK << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
344 con &= ~(reg->buf_slope_sel_mask << reg->buf_slope_sel_shift); 305 con |= (pdata->gain << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
345 con |= (pdata->gain << reg->buf_slope_sel_shift);
346 }
347 306
348 if (pdata->noise_cancel_mode) { 307 if (pdata->noise_cancel_mode) {
349 con &= ~(reg->therm_trip_mode_mask << 308 con &= ~(reg->therm_trip_mode_mask <<
@@ -351,29 +310,8 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
351 con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift); 310 con |= (pdata->noise_cancel_mode << reg->therm_trip_mode_shift);
352 } 311 }
353 312
354 if (pdata->cal_mode == HW_MODE) {
355 con &= ~(reg->calib_mode_mask << reg->calib_mode_shift);
356 cal_val = 0;
357 switch (pdata->cal_type) {
358 case TYPE_TWO_POINT_TRIMMING:
359 cal_val = 3;
360 break;
361 case TYPE_ONE_POINT_TRIMMING_85:
362 cal_val = 2;
363 break;
364 case TYPE_ONE_POINT_TRIMMING_25:
365 cal_val = 1;
366 break;
367 case TYPE_NONE:
368 break;
369 default:
370 dev_err(&pdev->dev, "Invalid calibration type, using none\n");
371 }
372 con |= cal_val << reg->calib_mode_shift;
373 }
374
375 if (on) { 313 if (on) {
376 con |= (1 << reg->core_en_shift); 314 con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
377 interrupt_en = 315 interrupt_en =
378 pdata->trigger_enable[3] << reg->inten_rise3_shift | 316 pdata->trigger_enable[3] << reg->inten_rise3_shift |
379 pdata->trigger_enable[2] << reg->inten_rise2_shift | 317 pdata->trigger_enable[2] << reg->inten_rise2_shift |
@@ -383,7 +321,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
383 interrupt_en |= 321 interrupt_en |=
384 interrupt_en << reg->inten_fall0_shift; 322 interrupt_en << reg->inten_fall0_shift;
385 } else { 323 } else {
386 con &= ~(1 << reg->core_en_shift); 324 con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
387 interrupt_en = 0; /* Disable all interrupts */ 325 interrupt_en = 0; /* Disable all interrupts */
388 } 326 }
389 writel(interrupt_en, data->base + reg->tmu_inten); 327 writel(interrupt_en, data->base + reg->tmu_inten);
@@ -404,8 +342,16 @@ static int exynos_tmu_read(struct exynos_tmu_data *data)
404 clk_enable(data->clk); 342 clk_enable(data->clk);
405 343
406 temp_code = readb(data->base + reg->tmu_cur_temp); 344 temp_code = readb(data->base + reg->tmu_cur_temp);
407 temp = code_to_temp(data, temp_code);
408 345
346 if (data->soc == SOC_ARCH_EXYNOS4210)
347 /* temp_code should range between 75 and 175 */
348 if (temp_code < 75 || temp_code > 175) {
349 temp = -ENODATA;
350 goto out;
351 }
352
353 temp = code_to_temp(data, temp_code);
354out:
409 clk_disable(data->clk); 355 clk_disable(data->clk);
410 mutex_unlock(&data->lock); 356 mutex_unlock(&data->lock);
411 357
@@ -465,7 +411,7 @@ static void exynos_tmu_work(struct work_struct *work)
465 struct exynos_tmu_data, irq_work); 411 struct exynos_tmu_data, irq_work);
466 struct exynos_tmu_platform_data *pdata = data->pdata; 412 struct exynos_tmu_platform_data *pdata = data->pdata;
467 const struct exynos_tmu_registers *reg = pdata->registers; 413 const struct exynos_tmu_registers *reg = pdata->registers;
468 unsigned int val_irq, val_type; 414 unsigned int val_type;
469 415
470 if (!IS_ERR(data->clk_sec)) 416 if (!IS_ERR(data->clk_sec))
471 clk_enable(data->clk_sec); 417 clk_enable(data->clk_sec);
@@ -483,9 +429,7 @@ static void exynos_tmu_work(struct work_struct *work)
483 clk_enable(data->clk); 429 clk_enable(data->clk);
484 430
485 /* TODO: take action based on particular interrupt */ 431 /* TODO: take action based on particular interrupt */
486 val_irq = readl(data->base + reg->tmu_intstat); 432 exynos_tmu_clear_irqs(data);
487 /* clear the interrupts */
488 writel(val_irq, data->base + reg->tmu_intclear);
489 433
490 clk_disable(data->clk); 434 clk_disable(data->clk);
491 mutex_unlock(&data->lock); 435 mutex_unlock(&data->lock);
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 1b4a6444ea61..c58c7663a3fe 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -34,11 +34,6 @@ enum calibration_type {
34 TYPE_NONE, 34 TYPE_NONE,
35}; 35};
36 36
37enum calibration_mode {
38 SW_MODE,
39 HW_MODE,
40};
41
42enum soc_type { 37enum soc_type {
43 SOC_ARCH_EXYNOS3250 = 1, 38 SOC_ARCH_EXYNOS3250 = 1,
44 SOC_ARCH_EXYNOS4210, 39 SOC_ARCH_EXYNOS4210,
@@ -82,46 +77,19 @@ enum soc_type {
82 * bitfields. The register validity, offsets and bitfield values may vary 77 * bitfields. The register validity, offsets and bitfield values may vary
83 * slightly across different exynos SOC's. 78 * slightly across different exynos SOC's.
84 * @triminfo_data: register containing 2 pont trimming data 79 * @triminfo_data: register containing 2 pont trimming data
85 * @triminfo_25_shift: shift bit of the 25 C trim value in triminfo_data reg.
86 * @triminfo_85_shift: shift bit of the 85 C trim value in triminfo_data reg.
87 * @triminfo_ctrl: trim info controller register. 80 * @triminfo_ctrl: trim info controller register.
88 * @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl 81 * @triminfo_ctrl_count: the number of trim info controller register.
89 reg.
90 * @tmu_ctrl: TMU main controller register. 82 * @tmu_ctrl: TMU main controller register.
91 * @test_mux_addr_shift: shift bits of test mux address. 83 * @test_mux_addr_shift: shift bits of test mux address.
92 * @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
93 * @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
94 * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register. 84 * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
95 * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register. 85 * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
96 * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register. 86 * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
97 * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
98 register.
99 * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
100 * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl
101 register.
102 * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl
103 register.
104 * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
105 tmu_ctrl register.
106 * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
107 * @tmu_status: register drescribing the TMU status. 87 * @tmu_status: register drescribing the TMU status.
108 * @tmu_cur_temp: register containing the current temperature of the TMU. 88 * @tmu_cur_temp: register containing the current temperature of the TMU.
109 * @tmu_cur_temp_shift: shift bits of current temp value in tmu_cur_temp
110 register.
111 * @threshold_temp: register containing the base threshold level. 89 * @threshold_temp: register containing the base threshold level.
112 * @threshold_th0: Register containing first set of rising levels. 90 * @threshold_th0: Register containing first set of rising levels.
113 * @threshold_th0_l0_shift: shift bits of level0 threshold temperature.
114 * @threshold_th0_l1_shift: shift bits of level1 threshold temperature.
115 * @threshold_th0_l2_shift: shift bits of level2 threshold temperature.
116 * @threshold_th0_l3_shift: shift bits of level3 threshold temperature.
117 * @threshold_th1: Register containing second set of rising levels. 91 * @threshold_th1: Register containing second set of rising levels.
118 * @threshold_th1_l0_shift: shift bits of level0 threshold temperature.
119 * @threshold_th1_l1_shift: shift bits of level1 threshold temperature.
120 * @threshold_th1_l2_shift: shift bits of level2 threshold temperature.
121 * @threshold_th1_l3_shift: shift bits of level3 threshold temperature.
122 * @threshold_th2: Register containing third set of rising levels. 92 * @threshold_th2: Register containing third set of rising levels.
123 * @threshold_th2_l0_shift: shift bits of level0 threshold temperature.
124 * @threshold_th3: Register containing fourth set of rising levels.
125 * @threshold_th3_l0_shift: shift bits of level0 threshold temperature. 93 * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
126 * @tmu_inten: register containing the different threshold interrupt 94 * @tmu_inten: register containing the different threshold interrupt
127 enable bits. 95 enable bits.
@@ -130,68 +98,35 @@ enum soc_type {
130 * @inten_rise2_shift: shift bits of rising 2 interrupt bits. 98 * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
131 * @inten_rise3_shift: shift bits of rising 3 interrupt bits. 99 * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
132 * @inten_fall0_shift: shift bits of falling 0 interrupt bits. 100 * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
133 * @inten_fall1_shift: shift bits of falling 1 interrupt bits.
134 * @inten_fall2_shift: shift bits of falling 2 interrupt bits.
135 * @inten_fall3_shift: shift bits of falling 3 interrupt bits.
136 * @tmu_intstat: Register containing the interrupt status values. 101 * @tmu_intstat: Register containing the interrupt status values.
137 * @tmu_intclear: Register for clearing the raised interrupt status. 102 * @tmu_intclear: Register for clearing the raised interrupt status.
138 * @intclr_fall_shift: shift bits for interrupt clear fall 0
139 * @intclr_rise_shift: shift bits of all rising interrupt bits.
140 * @intclr_rise_mask: mask bits of all rising interrupt bits.
141 * @intclr_fall_mask: mask bits of all rising interrupt bits.
142 * @emul_con: TMU emulation controller register. 103 * @emul_con: TMU emulation controller register.
143 * @emul_temp_shift: shift bits of emulation temperature. 104 * @emul_temp_shift: shift bits of emulation temperature.
144 * @emul_time_shift: shift bits of emulation time. 105 * @emul_time_shift: shift bits of emulation time.
145 * @emul_time_mask: mask bits of emulation time.
146 * @tmu_irqstatus: register to find which TMU generated interrupts. 106 * @tmu_irqstatus: register to find which TMU generated interrupts.
147 * @tmu_pmin: register to get/set the Pmin value. 107 * @tmu_pmin: register to get/set the Pmin value.
148 */ 108 */
149struct exynos_tmu_registers { 109struct exynos_tmu_registers {
150 u32 triminfo_data; 110 u32 triminfo_data;
151 u32 triminfo_25_shift;
152 u32 triminfo_85_shift;
153 111
154 u32 triminfo_ctrl; 112 u32 triminfo_ctrl[MAX_TRIMINFO_CTRL_REG];
155 u32 triminfo_ctrl1; 113 u32 triminfo_ctrl_count;
156 u32 triminfo_reload_shift;
157 114
158 u32 tmu_ctrl; 115 u32 tmu_ctrl;
159 u32 test_mux_addr_shift; 116 u32 test_mux_addr_shift;
160 u32 buf_vref_sel_shift;
161 u32 buf_vref_sel_mask;
162 u32 therm_trip_mode_shift; 117 u32 therm_trip_mode_shift;
163 u32 therm_trip_mode_mask; 118 u32 therm_trip_mode_mask;
164 u32 therm_trip_en_shift; 119 u32 therm_trip_en_shift;
165 u32 buf_slope_sel_shift;
166 u32 buf_slope_sel_mask;
167 u32 calib_mode_shift;
168 u32 calib_mode_mask;
169 u32 therm_trip_tq_en_shift;
170 u32 core_en_shift;
171 120
172 u32 tmu_status; 121 u32 tmu_status;
173 122
174 u32 tmu_cur_temp; 123 u32 tmu_cur_temp;
175 u32 tmu_cur_temp_shift;
176 124
177 u32 threshold_temp; 125 u32 threshold_temp;
178 126
179 u32 threshold_th0; 127 u32 threshold_th0;
180 u32 threshold_th0_l0_shift;
181 u32 threshold_th0_l1_shift;
182 u32 threshold_th0_l2_shift;
183 u32 threshold_th0_l3_shift;
184
185 u32 threshold_th1; 128 u32 threshold_th1;
186 u32 threshold_th1_l0_shift;
187 u32 threshold_th1_l1_shift;
188 u32 threshold_th1_l2_shift;
189 u32 threshold_th1_l3_shift;
190
191 u32 threshold_th2; 129 u32 threshold_th2;
192 u32 threshold_th2_l0_shift;
193
194 u32 threshold_th3;
195 u32 threshold_th3_l0_shift; 130 u32 threshold_th3_l0_shift;
196 131
197 u32 tmu_inten; 132 u32 tmu_inten;
@@ -200,22 +135,14 @@ struct exynos_tmu_registers {
200 u32 inten_rise2_shift; 135 u32 inten_rise2_shift;
201 u32 inten_rise3_shift; 136 u32 inten_rise3_shift;
202 u32 inten_fall0_shift; 137 u32 inten_fall0_shift;
203 u32 inten_fall1_shift;
204 u32 inten_fall2_shift;
205 u32 inten_fall3_shift;
206 138
207 u32 tmu_intstat; 139 u32 tmu_intstat;
208 140
209 u32 tmu_intclear; 141 u32 tmu_intclear;
210 u32 intclr_fall_shift;
211 u32 intclr_rise_shift;
212 u32 intclr_fall_mask;
213 u32 intclr_rise_mask;
214 142
215 u32 emul_con; 143 u32 emul_con;
216 u32 emul_temp_shift; 144 u32 emul_temp_shift;
217 u32 emul_time_shift; 145 u32 emul_time_shift;
218 u32 emul_time_mask;
219 146
220 u32 tmu_irqstatus; 147 u32 tmu_irqstatus;
221 u32 tmu_pmin; 148 u32 tmu_pmin;
@@ -250,11 +177,12 @@ struct exynos_tmu_registers {
250 * 1 = enable trigger_level[] interrupt, 177 * 1 = enable trigger_level[] interrupt,
251 * 0 = disable trigger_level[] interrupt 178 * 0 = disable trigger_level[] interrupt
252 * @max_trigger_level: max trigger level supported by the TMU 179 * @max_trigger_level: max trigger level supported by the TMU
180 * @non_hw_trigger_levels: number of defined non-hardware trigger levels
253 * @gain: gain of amplifier in the positive-TC generator block 181 * @gain: gain of amplifier in the positive-TC generator block
254 * 0 <= gain <= 15 182 * 0 < gain <= 15
255 * @reference_voltage: reference voltage of amplifier 183 * @reference_voltage: reference voltage of amplifier
256 * in the positive-TC generator block 184 * in the positive-TC generator block
257 * 0 <= reference_voltage <= 31 185 * 0 < reference_voltage <= 31
258 * @noise_cancel_mode: noise cancellation mode 186 * @noise_cancel_mode: noise cancellation mode
259 * 000, 100, 101, 110 and 111 can be different modes 187 * 000, 100, 101, 110 and 111 can be different modes
260 * @type: determines the type of SOC 188 * @type: determines the type of SOC
@@ -265,8 +193,8 @@ struct exynos_tmu_registers {
265 * @second_point_trim: temp value of the second point trimming 193 * @second_point_trim: temp value of the second point trimming
266 * @default_temp_offset: default temperature offset in case of no trimming 194 * @default_temp_offset: default temperature offset in case of no trimming
267 * @test_mux; information if SoC supports test MUX 195 * @test_mux; information if SoC supports test MUX
196 * @triminfo_reload: reload value to read TRIMINFO register
268 * @cal_type: calibration type for temperature 197 * @cal_type: calibration type for temperature
269 * @cal_mode: calibration mode for temperature
270 * @freq_clip_table: Table representing frequency reduction percentage. 198 * @freq_clip_table: Table representing frequency reduction percentage.
271 * @freq_tab_count: Count of the above table as frequency reduction may 199 * @freq_tab_count: Count of the above table as frequency reduction may
272 * applicable to only some of the trigger levels. 200 * applicable to only some of the trigger levels.
@@ -284,6 +212,7 @@ struct exynos_tmu_platform_data {
284 enum trigger_type trigger_type[MAX_TRIP_COUNT]; 212 enum trigger_type trigger_type[MAX_TRIP_COUNT];
285 bool trigger_enable[MAX_TRIP_COUNT]; 213 bool trigger_enable[MAX_TRIP_COUNT];
286 u8 max_trigger_level; 214 u8 max_trigger_level;
215 u8 non_hw_trigger_levels;
287 u8 gain; 216 u8 gain;
288 u8 reference_voltage; 217 u8 reference_voltage;
289 u8 noise_cancel_mode; 218 u8 noise_cancel_mode;
@@ -295,9 +224,9 @@ struct exynos_tmu_platform_data {
295 u8 second_point_trim; 224 u8 second_point_trim;
296 u8 default_temp_offset; 225 u8 default_temp_offset;
297 u8 test_mux; 226 u8 test_mux;
227 u8 triminfo_reload[MAX_TRIMINFO_CTRL_REG];
298 228
299 enum calibration_type cal_type; 229 enum calibration_type cal_type;
300 enum calibration_mode cal_mode;
301 enum soc_type type; 230 enum soc_type type;
302 struct freq_clip_table freq_tab[4]; 231 struct freq_clip_table freq_tab[4];
303 unsigned int freq_tab_count; 232 unsigned int freq_tab_count;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index aa8e0dee2055..2683d2897e90 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -27,14 +27,7 @@
27#if defined(CONFIG_CPU_EXYNOS4210) 27#if defined(CONFIG_CPU_EXYNOS4210)
28static const struct exynos_tmu_registers exynos4210_tmu_registers = { 28static const struct exynos_tmu_registers exynos4210_tmu_registers = {
29 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 29 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
30 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
31 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
32 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 30 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
33 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
34 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
35 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
36 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
37 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
38 .tmu_status = EXYNOS_TMU_REG_STATUS, 31 .tmu_status = EXYNOS_TMU_REG_STATUS,
39 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, 32 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
40 .threshold_temp = EXYNOS4210_TMU_REG_THRESHOLD_TEMP, 33 .threshold_temp = EXYNOS4210_TMU_REG_THRESHOLD_TEMP,
@@ -46,7 +39,6 @@ static const struct exynos_tmu_registers exynos4210_tmu_registers = {
46 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT, 39 .inten_rise3_shift = EXYNOS_TMU_INTEN_RISE3_SHIFT,
47 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 40 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
48 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 41 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
49 .intclr_rise_mask = EXYNOS4210_TMU_TRIG_LEVEL_MASK,
50}; 42};
51 43
52struct exynos_tmu_init_data const exynos4210_default_tmu_data = { 44struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
@@ -64,6 +56,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
64 .trigger_type[1] = THROTTLE_ACTIVE, 56 .trigger_type[1] = THROTTLE_ACTIVE,
65 .trigger_type[2] = SW_TRIP, 57 .trigger_type[2] = SW_TRIP,
66 .max_trigger_level = 4, 58 .max_trigger_level = 4,
59 .non_hw_trigger_levels = 3,
67 .gain = 15, 60 .gain = 15,
68 .reference_voltage = 7, 61 .reference_voltage = 7,
69 .cal_type = TYPE_ONE_POINT_TRIMMING, 62 .cal_type = TYPE_ONE_POINT_TRIMMING,
@@ -93,18 +86,14 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
93#if defined(CONFIG_SOC_EXYNOS3250) 86#if defined(CONFIG_SOC_EXYNOS3250)
94static const struct exynos_tmu_registers exynos3250_tmu_registers = { 87static const struct exynos_tmu_registers exynos3250_tmu_registers = {
95 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 88 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
96 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, 89 .triminfo_ctrl[0] = EXYNOS_TMU_TRIMINFO_CON1,
97 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, 90 .triminfo_ctrl[1] = EXYNOS_TMU_TRIMINFO_CON2,
91 .triminfo_ctrl_count = 2,
98 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 92 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
99 .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT, 93 .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT,
100 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
101 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
102 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 94 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
103 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 95 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
104 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 96 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
105 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
106 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
107 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
108 .tmu_status = EXYNOS_TMU_REG_STATUS, 97 .tmu_status = EXYNOS_TMU_REG_STATUS,
109 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, 98 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
110 .threshold_th0 = EXYNOS_THD_TEMP_RISE, 99 .threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -116,14 +105,9 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
116 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 105 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
117 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 106 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
118 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 107 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
119 .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT,
120 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
121 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
122 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
123 .emul_con = EXYNOS_EMUL_CON, 108 .emul_con = EXYNOS_EMUL_CON,
124 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 109 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
125 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 110 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
126 .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
127}; 111};
128 112
129#define EXYNOS3250_TMU_DATA \ 113#define EXYNOS3250_TMU_DATA \
@@ -141,6 +125,7 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
141 .trigger_type[2] = SW_TRIP, \ 125 .trigger_type[2] = SW_TRIP, \
142 .trigger_type[3] = HW_TRIP, \ 126 .trigger_type[3] = HW_TRIP, \
143 .max_trigger_level = 4, \ 127 .max_trigger_level = 4, \
128 .non_hw_trigger_levels = 3, \
144 .gain = 8, \ 129 .gain = 8, \
145 .reference_voltage = 16, \ 130 .reference_voltage = 16, \
146 .noise_cancel_mode = 4, \ 131 .noise_cancel_mode = 4, \
@@ -160,8 +145,10 @@ static const struct exynos_tmu_registers exynos3250_tmu_registers = {
160 .temp_level = 95, \ 145 .temp_level = 95, \
161 }, \ 146 }, \
162 .freq_tab_count = 2, \ 147 .freq_tab_count = 2, \
148 .triminfo_reload[0] = EXYNOS_TRIMINFO_RELOAD_ENABLE, \
149 .triminfo_reload[1] = EXYNOS_TRIMINFO_RELOAD_ENABLE, \
163 .registers = &exynos3250_tmu_registers, \ 150 .registers = &exynos3250_tmu_registers, \
164 .features = (TMU_SUPPORT_EMULATION | \ 151 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
165 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ 152 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
166 TMU_SUPPORT_EMUL_TIME) 153 TMU_SUPPORT_EMUL_TIME)
167#endif 154#endif
@@ -182,20 +169,13 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
182#if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250) 169#if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
183static const struct exynos_tmu_registers exynos4412_tmu_registers = { 170static const struct exynos_tmu_registers exynos4412_tmu_registers = {
184 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 171 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
185 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT, 172 .triminfo_ctrl[0] = EXYNOS_TMU_TRIMINFO_CON2,
186 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT, 173 .triminfo_ctrl_count = 1,
187 .triminfo_ctrl = EXYNOS_TMU_TRIMINFO_CON,
188 .triminfo_reload_shift = EXYNOS_TRIMINFO_RELOAD_SHIFT,
189 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 174 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
190 .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT, 175 .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT,
191 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
192 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
193 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 176 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
194 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 177 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
195 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 178 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
196 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
197 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
198 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
199 .tmu_status = EXYNOS_TMU_REG_STATUS, 179 .tmu_status = EXYNOS_TMU_REG_STATUS,
200 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, 180 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
201 .threshold_th0 = EXYNOS_THD_TEMP_RISE, 181 .threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -208,14 +188,9 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
208 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 188 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
209 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 189 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
210 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 190 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
211 .intclr_fall_shift = EXYNOS_TMU_CLEAR_FALL_INT_SHIFT,
212 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
213 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
214 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
215 .emul_con = EXYNOS_EMUL_CON, 191 .emul_con = EXYNOS_EMUL_CON,
216 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 192 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
217 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 193 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
218 .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
219}; 194};
220 195
221#define EXYNOS4412_TMU_DATA \ 196#define EXYNOS4412_TMU_DATA \
@@ -233,6 +208,7 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
233 .trigger_type[2] = SW_TRIP, \ 208 .trigger_type[2] = SW_TRIP, \
234 .trigger_type[3] = HW_TRIP, \ 209 .trigger_type[3] = HW_TRIP, \
235 .max_trigger_level = 4, \ 210 .max_trigger_level = 4, \
211 .non_hw_trigger_levels = 3, \
236 .gain = 8, \ 212 .gain = 8, \
237 .reference_voltage = 16, \ 213 .reference_voltage = 16, \
238 .noise_cancel_mode = 4, \ 214 .noise_cancel_mode = 4, \
@@ -252,6 +228,7 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = {
252 .temp_level = 95, \ 228 .temp_level = 95, \
253 }, \ 229 }, \
254 .freq_tab_count = 2, \ 230 .freq_tab_count = 2, \
231 .triminfo_reload[0] = EXYNOS_TRIMINFO_RELOAD_ENABLE, \
255 .registers = &exynos4412_tmu_registers, \ 232 .registers = &exynos4412_tmu_registers, \
256 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ 233 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
257 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ 234 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
@@ -286,18 +263,11 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
286#if defined(CONFIG_SOC_EXYNOS5260) 263#if defined(CONFIG_SOC_EXYNOS5260)
287static const struct exynos_tmu_registers exynos5260_tmu_registers = { 264static const struct exynos_tmu_registers exynos5260_tmu_registers = {
288 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 265 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
289 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
290 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
291 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 266 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
292 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL1, 267 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL1,
293 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
294 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
295 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 268 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
296 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 269 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
297 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 270 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
298 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
299 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
300 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
301 .tmu_status = EXYNOS_TMU_REG_STATUS, 271 .tmu_status = EXYNOS_TMU_REG_STATUS,
302 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, 272 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
303 .threshold_th0 = EXYNOS_THD_TEMP_RISE, 273 .threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -310,14 +280,9 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
310 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 280 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
311 .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, 281 .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT,
312 .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, 282 .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR,
313 .intclr_fall_shift = EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT,
314 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
315 .intclr_rise_mask = EXYNOS5260_TMU_RISE_INT_MASK,
316 .intclr_fall_mask = EXYNOS5260_TMU_FALL_INT_MASK,
317 .emul_con = EXYNOS5260_EMUL_CON, 283 .emul_con = EXYNOS5260_EMUL_CON,
318 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 284 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
319 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 285 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
320 .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
321}; 286};
322 287
323#define __EXYNOS5260_TMU_DATA \ 288#define __EXYNOS5260_TMU_DATA \
@@ -335,6 +300,7 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
335 .trigger_type[2] = SW_TRIP, \ 300 .trigger_type[2] = SW_TRIP, \
336 .trigger_type[3] = HW_TRIP, \ 301 .trigger_type[3] = HW_TRIP, \
337 .max_trigger_level = 4, \ 302 .max_trigger_level = 4, \
303 .non_hw_trigger_levels = 3, \
338 .gain = 8, \ 304 .gain = 8, \
339 .reference_voltage = 16, \ 305 .reference_voltage = 16, \
340 .noise_cancel_mode = 4, \ 306 .noise_cancel_mode = 4, \
@@ -359,9 +325,8 @@ static const struct exynos_tmu_registers exynos5260_tmu_registers = {
359#define EXYNOS5260_TMU_DATA \ 325#define EXYNOS5260_TMU_DATA \
360 __EXYNOS5260_TMU_DATA \ 326 __EXYNOS5260_TMU_DATA \
361 .type = SOC_ARCH_EXYNOS5260, \ 327 .type = SOC_ARCH_EXYNOS5260, \
362 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ 328 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
363 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ 329 TMU_SUPPORT_READY_STATUS | TMU_SUPPORT_EMUL_TIME)
364 TMU_SUPPORT_EMUL_TIME)
365 330
366struct exynos_tmu_init_data const exynos5260_default_tmu_data = { 331struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
367 .tmu_data = { 332 .tmu_data = {
@@ -378,17 +343,10 @@ struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
378#if defined(CONFIG_SOC_EXYNOS5420) 343#if defined(CONFIG_SOC_EXYNOS5420)
379static const struct exynos_tmu_registers exynos5420_tmu_registers = { 344static const struct exynos_tmu_registers exynos5420_tmu_registers = {
380 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO, 345 .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
381 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
382 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
383 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL, 346 .tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
384 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
385 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
386 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 347 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
387 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 348 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
388 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 349 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
389 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
390 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
391 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
392 .tmu_status = EXYNOS_TMU_REG_STATUS, 350 .tmu_status = EXYNOS_TMU_REG_STATUS,
393 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, 351 .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
394 .threshold_th0 = EXYNOS_THD_TEMP_RISE, 352 .threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -402,14 +360,9 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
402 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT, 360 .inten_fall0_shift = EXYNOS_TMU_INTEN_FALL0_SHIFT,
403 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, 361 .tmu_intstat = EXYNOS_TMU_REG_INTSTAT,
404 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, 362 .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR,
405 .intclr_fall_shift = EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT,
406 .intclr_rise_shift = EXYNOS_TMU_RISE_INT_SHIFT,
407 .intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
408 .intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
409 .emul_con = EXYNOS_EMUL_CON, 363 .emul_con = EXYNOS_EMUL_CON,
410 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 364 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
411 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT, 365 .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
412 .emul_time_mask = EXYNOS_EMUL_TIME_MASK,
413}; 366};
414 367
415#define __EXYNOS5420_TMU_DATA \ 368#define __EXYNOS5420_TMU_DATA \
@@ -427,6 +380,7 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
427 .trigger_type[2] = SW_TRIP, \ 380 .trigger_type[2] = SW_TRIP, \
428 .trigger_type[3] = HW_TRIP, \ 381 .trigger_type[3] = HW_TRIP, \
429 .max_trigger_level = 4, \ 382 .max_trigger_level = 4, \
383 .non_hw_trigger_levels = 3, \
430 .gain = 8, \ 384 .gain = 8, \
431 .reference_voltage = 16, \ 385 .reference_voltage = 16, \
432 .noise_cancel_mode = 4, \ 386 .noise_cancel_mode = 4, \
@@ -451,16 +405,15 @@ static const struct exynos_tmu_registers exynos5420_tmu_registers = {
451#define EXYNOS5420_TMU_DATA \ 405#define EXYNOS5420_TMU_DATA \
452 __EXYNOS5420_TMU_DATA \ 406 __EXYNOS5420_TMU_DATA \
453 .type = SOC_ARCH_EXYNOS5250, \ 407 .type = SOC_ARCH_EXYNOS5250, \
454 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ 408 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
455 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ 409 TMU_SUPPORT_READY_STATUS | TMU_SUPPORT_EMUL_TIME)
456 TMU_SUPPORT_EMUL_TIME)
457 410
458#define EXYNOS5420_TMU_DATA_SHARED \ 411#define EXYNOS5420_TMU_DATA_SHARED \
459 __EXYNOS5420_TMU_DATA \ 412 __EXYNOS5420_TMU_DATA \
460 .type = SOC_ARCH_EXYNOS5420_TRIMINFO, \ 413 .type = SOC_ARCH_EXYNOS5420_TRIMINFO, \
461 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ 414 .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
462 TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ 415 TMU_SUPPORT_READY_STATUS | TMU_SUPPORT_EMUL_TIME | \
463 TMU_SUPPORT_EMUL_TIME | TMU_SUPPORT_ADDRESS_MULTIPLE) 416 TMU_SUPPORT_ADDRESS_MULTIPLE)
464 417
465struct exynos_tmu_init_data const exynos5420_default_tmu_data = { 418struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
466 .tmu_data = { 419 .tmu_data = {
@@ -477,19 +430,10 @@ struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
477#if defined(CONFIG_SOC_EXYNOS5440) 430#if defined(CONFIG_SOC_EXYNOS5440)
478static const struct exynos_tmu_registers exynos5440_tmu_registers = { 431static const struct exynos_tmu_registers exynos5440_tmu_registers = {
479 .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM, 432 .triminfo_data = EXYNOS5440_TMU_S0_7_TRIM,
480 .triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
481 .triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
482 .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL, 433 .tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL,
483 .buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
484 .buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
485 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT, 434 .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
486 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK, 435 .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
487 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT, 436 .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
488 .buf_slope_sel_shift = EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT,
489 .buf_slope_sel_mask = EXYNOS_TMU_BUF_SLOPE_SEL_MASK,
490 .calib_mode_shift = EXYNOS_TMU_CALIB_MODE_SHIFT,
491 .calib_mode_mask = EXYNOS_TMU_CALIB_MODE_MASK,
492 .core_en_shift = EXYNOS_TMU_CORE_EN_SHIFT,
493 .tmu_status = EXYNOS5440_TMU_S0_7_STATUS, 437 .tmu_status = EXYNOS5440_TMU_S0_7_STATUS,
494 .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, 438 .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
495 .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0, 439 .threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
@@ -504,10 +448,6 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
504 .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT, 448 .inten_fall0_shift = EXYNOS5440_TMU_INTEN_FALL0_SHIFT,
505 .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, 449 .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ,
506 .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, 450 .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ,
507 .intclr_fall_shift = EXYNOS5440_TMU_CLEAR_FALL_INT_SHIFT,
508 .intclr_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
509 .intclr_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
510 .intclr_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
511 .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS, 451 .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
512 .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, 452 .emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
513 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT, 453 .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
@@ -521,11 +461,11 @@ static const struct exynos_tmu_registers exynos5440_tmu_registers = {
521 .trigger_type[0] = SW_TRIP, \ 461 .trigger_type[0] = SW_TRIP, \
522 .trigger_type[4] = HW_TRIP, \ 462 .trigger_type[4] = HW_TRIP, \
523 .max_trigger_level = 5, \ 463 .max_trigger_level = 5, \
464 .non_hw_trigger_levels = 1, \
524 .gain = 5, \ 465 .gain = 5, \
525 .reference_voltage = 16, \ 466 .reference_voltage = 16, \
526 .noise_cancel_mode = 4, \ 467 .noise_cancel_mode = 4, \
527 .cal_type = TYPE_ONE_POINT_TRIMMING, \ 468 .cal_type = TYPE_ONE_POINT_TRIMMING, \
528 .cal_mode = 0, \
529 .efuse_value = 0x5b2d, \ 469 .efuse_value = 0x5b2d, \
530 .min_efuse_value = 16, \ 470 .min_efuse_value = 16, \
531 .max_efuse_value = 76, \ 471 .max_efuse_value = 76, \
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h
index f0979e598491..65e2ea6a9579 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -39,55 +39,31 @@
39#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 39#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8
40#define EXYNOS_TMU_CORE_EN_SHIFT 0 40#define EXYNOS_TMU_CORE_EN_SHIFT 0
41 41
42/* Exynos3250 specific registers */
43#define EXYNOS_TMU_TRIMINFO_CON1 0x10
44
42/* Exynos4210 specific registers */ 45/* Exynos4210 specific registers */
43#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 46#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44
44#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 47#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50
45#define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54 48
46#define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58 49/* Exynos5250, Exynos4412, Exynos3250 specific registers */
47#define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C 50#define EXYNOS_TMU_TRIMINFO_CON2 0x14
48#define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60
49#define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64
50#define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68
51#define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C
52
53#define EXYNOS4210_TMU_TRIG_LEVEL0_MASK 0x1
54#define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10
55#define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100
56#define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000
57#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x1111
58#define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111
59
60/* Exynos5250 and Exynos4412 specific registers */
61#define EXYNOS_TMU_TRIMINFO_CON 0x14
62#define EXYNOS_THD_TEMP_RISE 0x50 51#define EXYNOS_THD_TEMP_RISE 0x50
63#define EXYNOS_THD_TEMP_FALL 0x54 52#define EXYNOS_THD_TEMP_FALL 0x54
64#define EXYNOS_EMUL_CON 0x80 53#define EXYNOS_EMUL_CON 0x80
65 54
66#define EXYNOS_TRIMINFO_RELOAD_SHIFT 1 55#define EXYNOS_TRIMINFO_RELOAD_ENABLE 1
67#define EXYNOS_TRIMINFO_25_SHIFT 0 56#define EXYNOS_TRIMINFO_25_SHIFT 0
68#define EXYNOS_TRIMINFO_85_SHIFT 8 57#define EXYNOS_TRIMINFO_85_SHIFT 8
69#define EXYNOS_TMU_RISE_INT_MASK 0x111
70#define EXYNOS_TMU_RISE_INT_SHIFT 0
71#define EXYNOS_TMU_FALL_INT_MASK 0x111
72#define EXYNOS_TMU_CLEAR_RISE_INT 0x111
73#define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12)
74#define EXYNOS_TMU_CLEAR_FALL_INT_SHIFT 12
75#define EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT 16
76#define EXYNOS5440_TMU_CLEAR_FALL_INT_SHIFT 4
77#define EXYNOS_TMU_TRIP_MODE_SHIFT 13 58#define EXYNOS_TMU_TRIP_MODE_SHIFT 13
78#define EXYNOS_TMU_TRIP_MODE_MASK 0x7 59#define EXYNOS_TMU_TRIP_MODE_MASK 0x7
79#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 60#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
80#define EXYNOS_TMU_CALIB_MODE_SHIFT 4
81#define EXYNOS_TMU_CALIB_MODE_MASK 0x3
82 61
83#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 62#define EXYNOS_TMU_INTEN_RISE0_SHIFT 0
84#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4 63#define EXYNOS_TMU_INTEN_RISE1_SHIFT 4
85#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8 64#define EXYNOS_TMU_INTEN_RISE2_SHIFT 8
86#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12 65#define EXYNOS_TMU_INTEN_RISE3_SHIFT 12
87#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 66#define EXYNOS_TMU_INTEN_FALL0_SHIFT 16
88#define EXYNOS_TMU_INTEN_FALL1_SHIFT 20
89#define EXYNOS_TMU_INTEN_FALL2_SHIFT 24
90#define EXYNOS_TMU_INTEN_FALL3_SHIFT 28
91 67
92#define EXYNOS_EMUL_TIME 0x57F0 68#define EXYNOS_EMUL_TIME 0x57F0
93#define EXYNOS_EMUL_TIME_MASK 0xffff 69#define EXYNOS_EMUL_TIME_MASK 0xffff
@@ -103,10 +79,6 @@
103#define EXYNOS5260_TMU_REG_INTEN 0xC0 79#define EXYNOS5260_TMU_REG_INTEN 0xC0
104#define EXYNOS5260_TMU_REG_INTSTAT 0xC4 80#define EXYNOS5260_TMU_REG_INTSTAT 0xC4
105#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8 81#define EXYNOS5260_TMU_REG_INTCLEAR 0xC8
106#define EXYNOS5260_TMU_CLEAR_RISE_INT 0x1111
107#define EXYNOS5260_TMU_CLEAR_FALL_INT (0x1111 << 16)
108#define EXYNOS5260_TMU_RISE_INT_MASK 0x1111
109#define EXYNOS5260_TMU_FALL_INT_MASK 0x1111
110#define EXYNOS5260_EMUL_CON 0x100 82#define EXYNOS5260_EMUL_CON 0x100
111 83
112/* Exynos4412 specific */ 84/* Exynos4412 specific */
@@ -122,29 +94,17 @@
122#define EXYNOS5440_TMU_S0_7_TH0 0x110 94#define EXYNOS5440_TMU_S0_7_TH0 0x110
123#define EXYNOS5440_TMU_S0_7_TH1 0x130 95#define EXYNOS5440_TMU_S0_7_TH1 0x130
124#define EXYNOS5440_TMU_S0_7_TH2 0x150 96#define EXYNOS5440_TMU_S0_7_TH2 0x150
125#define EXYNOS5440_TMU_S0_7_EVTEN 0x1F0
126#define EXYNOS5440_TMU_S0_7_IRQEN 0x210 97#define EXYNOS5440_TMU_S0_7_IRQEN 0x210
127#define EXYNOS5440_TMU_S0_7_IRQ 0x230 98#define EXYNOS5440_TMU_S0_7_IRQ 0x230
128/* exynos5440 common registers */ 99/* exynos5440 common registers */
129#define EXYNOS5440_TMU_IRQ_STATUS 0x000 100#define EXYNOS5440_TMU_IRQ_STATUS 0x000
130#define EXYNOS5440_TMU_PMIN 0x004 101#define EXYNOS5440_TMU_PMIN 0x004
131#define EXYNOS5440_TMU_TEMP 0x008
132 102
133#define EXYNOS5440_TMU_RISE_INT_MASK 0xf
134#define EXYNOS5440_TMU_RISE_INT_SHIFT 0
135#define EXYNOS5440_TMU_FALL_INT_MASK 0xf
136#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT 0 103#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT 0
137#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT 1 104#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT 1
138#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT 2 105#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT 2
139#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT 3 106#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT 3
140#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT 4 107#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT 4
141#define EXYNOS5440_TMU_INTEN_FALL1_SHIFT 5
142#define EXYNOS5440_TMU_INTEN_FALL2_SHIFT 6
143#define EXYNOS5440_TMU_INTEN_FALL3_SHIFT 7
144#define EXYNOS5440_TMU_TH_RISE0_SHIFT 0
145#define EXYNOS5440_TMU_TH_RISE1_SHIFT 8
146#define EXYNOS5440_TMU_TH_RISE2_SHIFT 16
147#define EXYNOS5440_TMU_TH_RISE3_SHIFT 24
148#define EXYNOS5440_TMU_TH_RISE4_SHIFT 24 108#define EXYNOS5440_TMU_TH_RISE4_SHIFT 24
149#define EXYNOS5440_EFUSE_SWAP_OFFSET 8 109#define EXYNOS5440_EFUSE_SWAP_OFFSET 8
150 110
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 9bf10aa6069b..43b90709585f 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1575,8 +1575,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
1575 1575
1576 thermal_zone_device_update(tz); 1576 thermal_zone_device_update(tz);
1577 1577
1578 if (!result) 1578 return tz;
1579 return tz;
1580 1579
1581unregister: 1580unregister:
1582 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1581 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 89c4cee253e3..2e900a98c3e3 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2413,12 +2413,17 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
2413 2413
2414 poll_wait(file, &tty->read_wait, wait); 2414 poll_wait(file, &tty->read_wait, wait);
2415 poll_wait(file, &tty->write_wait, wait); 2415 poll_wait(file, &tty->write_wait, wait);
2416 if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2417 mask |= POLLHUP;
2416 if (input_available_p(tty, 1)) 2418 if (input_available_p(tty, 1))
2417 mask |= POLLIN | POLLRDNORM; 2419 mask |= POLLIN | POLLRDNORM;
2420 else if (mask & POLLHUP) {
2421 tty_flush_to_ldisc(tty);
2422 if (input_available_p(tty, 1))
2423 mask |= POLLIN | POLLRDNORM;
2424 }
2418 if (tty->packet && tty->link->ctrl_status) 2425 if (tty->packet && tty->link->ctrl_status)
2419 mask |= POLLPRI | POLLIN | POLLRDNORM; 2426 mask |= POLLPRI | POLLIN | POLLRDNORM;
2420 if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
2421 mask |= POLLHUP;
2422 if (tty_hung_up_p(file)) 2427 if (tty_hung_up_p(file))
2423 mask |= POLLHUP; 2428 mask |= POLLHUP;
2424 if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) { 2429 if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) {
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 8f37d57165ec..de7aae523b37 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -81,7 +81,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
81 /* Set to highest baudrate supported */ 81 /* Set to highest baudrate supported */
82 if (baud >= 1152000) 82 if (baud >= 1152000)
83 baud = 921600; 83 baud = 921600;
84 quot = DIV_ROUND_CLOSEST(port->uartclk, 256 * baud); 84 quot = (port->uartclk / (256 * baud)) + 1;
85 } 85 }
86 86
87 /* 87 /*
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 8bc2563335ae..56982da4a9e9 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -158,7 +158,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
158 if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) 158 if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL))
159 return -EBUSY; 159 return -EBUSY;
160 160
161 info = kmalloc(sizeof(*info), GFP_KERNEL); 161 info = kzalloc(sizeof(*info), GFP_KERNEL);
162 if (info == NULL) 162 if (info == NULL)
163 return -ENOMEM; 163 return -ENOMEM;
164 164
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index df3a8c74358e..eaeb9a02c7fe 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -363,7 +363,7 @@ uart_get_baud_rate(struct uart_port *port, struct ktermios *termios,
363 * The spd_hi, spd_vhi, spd_shi, spd_warp kludge... 363 * The spd_hi, spd_vhi, spd_shi, spd_warp kludge...
364 * Die! Die! Die! 364 * Die! Die! Die!
365 */ 365 */
366 if (baud == 38400) 366 if (try == 0 && baud == 38400)
367 baud = altbaud; 367 baud = altbaud;
368 368
369 /* 369 /*
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 16a2c0237dd6..0508a1d8e4cd 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1709,6 +1709,8 @@ int tty_release(struct inode *inode, struct file *filp)
1709 int pty_master, tty_closing, o_tty_closing, do_sleep; 1709 int pty_master, tty_closing, o_tty_closing, do_sleep;
1710 int idx; 1710 int idx;
1711 char buf[64]; 1711 char buf[64];
1712 long timeout = 0;
1713 int once = 1;
1712 1714
1713 if (tty_paranoia_check(tty, inode, __func__)) 1715 if (tty_paranoia_check(tty, inode, __func__))
1714 return 0; 1716 return 0;
@@ -1789,11 +1791,18 @@ int tty_release(struct inode *inode, struct file *filp)
1789 if (!do_sleep) 1791 if (!do_sleep)
1790 break; 1792 break;
1791 1793
1792 printk(KERN_WARNING "%s: %s: read/write wait queue active!\n", 1794 if (once) {
1793 __func__, tty_name(tty, buf)); 1795 once = 0;
1796 printk(KERN_WARNING "%s: %s: read/write wait queue active!\n",
1797 __func__, tty_name(tty, buf));
1798 }
1794 tty_unlock_pair(tty, o_tty); 1799 tty_unlock_pair(tty, o_tty);
1795 mutex_unlock(&tty_mutex); 1800 mutex_unlock(&tty_mutex);
1796 schedule(); 1801 schedule_timeout_killable(timeout);
1802 if (timeout < 120 * HZ)
1803 timeout = 2 * timeout + 1;
1804 else
1805 timeout = MAX_SCHEDULE_TIMEOUT;
1797 } 1806 }
1798 1807
1799 /* 1808 /*
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index 610b720d3b91..59b25e039968 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -539,6 +539,12 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
539 539
540 /* Save original vc_unipagdir_loc in case we allocate a new one */ 540 /* Save original vc_unipagdir_loc in case we allocate a new one */
541 p = *vc->vc_uni_pagedir_loc; 541 p = *vc->vc_uni_pagedir_loc;
542
543 if (!p) {
544 err = -EINVAL;
545
546 goto out_unlock;
547 }
542 548
543 if (p->refcount > 1) { 549 if (p->refcount > 1) {
544 int j, k; 550 int j, k;
@@ -623,6 +629,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
623 set_inverse_transl(vc, p, i); /* Update inverse translations */ 629 set_inverse_transl(vc, p, i); /* Update inverse translations */
624 set_inverse_trans_unicode(vc, p); 630 set_inverse_trans_unicode(vc, p);
625 631
632out_unlock:
626 console_unlock(); 633 console_unlock();
627 return err; 634 return err;
628} 635}
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3df5005c554d..9bdc6bd73432 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -742,7 +742,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
742 ci_role_destroy(ci); 742 ci_role_destroy(ci);
743 ci_hdrc_enter_lpm(ci, true); 743 ci_hdrc_enter_lpm(ci, true);
744 usb_phy_shutdown(ci->transceiver); 744 usb_phy_shutdown(ci->transceiver);
745 kfree(ci->hw_bank.regmap);
746 745
747 return 0; 746 return 0;
748} 747}
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e934e19f49f5..077d58ac3dcb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -60,6 +60,9 @@ static struct acm *acm_table[ACM_TTY_MINORS];
60 60
61static DEFINE_MUTEX(acm_table_lock); 61static DEFINE_MUTEX(acm_table_lock);
62 62
63static void acm_tty_set_termios(struct tty_struct *tty,
64 struct ktermios *termios_old);
65
63/* 66/*
64 * acm_table accessors 67 * acm_table accessors
65 */ 68 */
@@ -145,8 +148,15 @@ static int acm_ctrl_msg(struct acm *acm, int request, int value,
145/* devices aren't required to support these requests. 148/* devices aren't required to support these requests.
146 * the cdc acm descriptor tells whether they do... 149 * the cdc acm descriptor tells whether they do...
147 */ 150 */
148#define acm_set_control(acm, control) \ 151static inline int acm_set_control(struct acm *acm, int control)
149 acm_ctrl_msg(acm, USB_CDC_REQ_SET_CONTROL_LINE_STATE, control, NULL, 0) 152{
153 if (acm->quirks & QUIRK_CONTROL_LINE_STATE)
154 return -EOPNOTSUPP;
155
156 return acm_ctrl_msg(acm, USB_CDC_REQ_SET_CONTROL_LINE_STATE,
157 control, NULL, 0);
158}
159
150#define acm_set_line(acm, line) \ 160#define acm_set_line(acm, line) \
151 acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0, line, sizeof *(line)) 161 acm_ctrl_msg(acm, USB_CDC_REQ_SET_LINE_CODING, 0, line, sizeof *(line))
152#define acm_send_break(acm, ms) \ 162#define acm_send_break(acm, ms) \
@@ -554,6 +564,8 @@ static int acm_port_activate(struct tty_port *port, struct tty_struct *tty)
554 goto error_submit_urb; 564 goto error_submit_urb;
555 } 565 }
556 566
567 acm_tty_set_termios(tty, NULL);
568
557 /* 569 /*
558 * Unthrottle device in case the TTY was closed while throttled. 570 * Unthrottle device in case the TTY was closed while throttled.
559 */ 571 */
@@ -980,11 +992,12 @@ static void acm_tty_set_termios(struct tty_struct *tty,
980 /* FIXME: Needs to clear unsupported bits in the termios */ 992 /* FIXME: Needs to clear unsupported bits in the termios */
981 acm->clocal = ((termios->c_cflag & CLOCAL) != 0); 993 acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
982 994
983 if (!newline.dwDTERate) { 995 if (C_BAUD(tty) == B0) {
984 newline.dwDTERate = acm->line.dwDTERate; 996 newline.dwDTERate = acm->line.dwDTERate;
985 newctrl &= ~ACM_CTRL_DTR; 997 newctrl &= ~ACM_CTRL_DTR;
986 } else 998 } else if (termios_old && (termios_old->c_cflag & CBAUD) == B0) {
987 newctrl |= ACM_CTRL_DTR; 999 newctrl |= ACM_CTRL_DTR;
1000 }
988 1001
989 if (newctrl != acm->ctrlout) 1002 if (newctrl != acm->ctrlout)
990 acm_set_control(acm, acm->ctrlout = newctrl); 1003 acm_set_control(acm, acm->ctrlout = newctrl);
@@ -1314,6 +1327,7 @@ made_compressed_probe:
1314 tty_port_init(&acm->port); 1327 tty_port_init(&acm->port);
1315 acm->port.ops = &acm_port_ops; 1328 acm->port.ops = &acm_port_ops;
1316 init_usb_anchor(&acm->delayed); 1329 init_usb_anchor(&acm->delayed);
1330 acm->quirks = quirks;
1317 1331
1318 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 1332 buf = usb_alloc_coherent(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
1319 if (!buf) { 1333 if (!buf) {
@@ -1681,6 +1695,9 @@ static const struct usb_device_id acm_ids[] = {
1681 { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */ 1695 { USB_DEVICE(0x0572, 0x1328), /* Shiro / Aztech USB MODEM UM-3100 */
1682 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1696 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1683 }, 1697 },
1698 { USB_DEVICE(0x20df, 0x0001), /* Simtec Electronics Entropy Key */
1699 .driver_info = QUIRK_CONTROL_LINE_STATE, },
1700 { USB_DEVICE(0x2184, 0x001c) }, /* GW Instek AFG-2225 */
1684 { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */ 1701 { USB_DEVICE(0x22b8, 0x6425), /* Motorola MOTOMAGX phones */
1685 }, 1702 },
1686 /* Motorola H24 HSPA module: */ 1703 /* Motorola H24 HSPA module: */
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index fc75651afe1c..d3251ebd09e2 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -121,6 +121,7 @@ struct acm {
121 unsigned int throttle_req:1; /* throttle requested */ 121 unsigned int throttle_req:1; /* throttle requested */
122 u8 bInterval; 122 u8 bInterval;
123 struct usb_anchor delayed; /* writes queued for a device about to be woken */ 123 struct usb_anchor delayed; /* writes queued for a device about to be woken */
124 unsigned long quirks;
124}; 125};
125 126
126#define CDC_DATA_INTERFACE_TYPE 0x0a 127#define CDC_DATA_INTERFACE_TYPE 0x0a
@@ -132,3 +133,4 @@ struct acm {
132#define NOT_A_MODEM BIT(3) 133#define NOT_A_MODEM BIT(3)
133#define NO_DATA_INTERFACE BIT(4) 134#define NO_DATA_INTERFACE BIT(4)
134#define IGNORE_DEVICE BIT(5) 135#define IGNORE_DEVICE BIT(5)
136#define QUIRK_CONTROL_LINE_STATE BIT(6)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index b84fb141e122..a6efb4184f2b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2060,6 +2060,8 @@ int usb_alloc_streams(struct usb_interface *interface,
2060 return -EINVAL; 2060 return -EINVAL;
2061 if (dev->speed != USB_SPEED_SUPER) 2061 if (dev->speed != USB_SPEED_SUPER)
2062 return -EINVAL; 2062 return -EINVAL;
2063 if (dev->state < USB_STATE_CONFIGURED)
2064 return -ENODEV;
2063 2065
2064 for (i = 0; i < num_eps; i++) { 2066 for (i = 0; i < num_eps; i++) {
2065 /* Streams only apply to bulk endpoints. */ 2067 /* Streams only apply to bulk endpoints. */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 11e80ac31324..b649fef2e35d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4468,9 +4468,6 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
4468 if (retval) 4468 if (retval)
4469 goto fail; 4469 goto fail;
4470 4470
4471 if (hcd->usb_phy && !hdev->parent)
4472 usb_phy_notify_connect(hcd->usb_phy, udev->speed);
4473
4474 /* 4471 /*
4475 * Some superspeed devices have finished the link training process 4472 * Some superspeed devices have finished the link training process
4476 * and attached to a superspeed hub port, but the device descriptor 4473 * and attached to a superspeed hub port, but the device descriptor
@@ -4627,8 +4624,7 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4627 4624
4628 /* Disconnect any existing devices under this port */ 4625 /* Disconnect any existing devices under this port */
4629 if (udev) { 4626 if (udev) {
4630 if (hcd->usb_phy && !hdev->parent && 4627 if (hcd->usb_phy && !hdev->parent)
4631 !(portstatus & USB_PORT_STAT_CONNECTION))
4632 usb_phy_notify_disconnect(hcd->usb_phy, udev->speed); 4628 usb_phy_notify_disconnect(hcd->usb_phy, udev->speed);
4633 usb_disconnect(&port_dev->child); 4629 usb_disconnect(&port_dev->child);
4634 } 4630 }
@@ -4783,6 +4779,10 @@ static void hub_port_connect(struct usb_hub *hub, int port1, u16 portstatus,
4783 port_dev->child = NULL; 4779 port_dev->child = NULL;
4784 spin_unlock_irq(&device_state_lock); 4780 spin_unlock_irq(&device_state_lock);
4785 mutex_unlock(&usb_port_peer_mutex); 4781 mutex_unlock(&usb_port_peer_mutex);
4782 } else {
4783 if (hcd->usb_phy && !hdev->parent)
4784 usb_phy_notify_connect(hcd->usb_phy,
4785 udev->speed);
4786 } 4786 }
4787 } 4787 }
4788 4788
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 5ae883dc21f5..39b4081b632d 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -97,6 +97,12 @@ static const struct usb_device_id usb_quirk_list[] = {
97 { USB_DEVICE(0x04f3, 0x0089), .driver_info = 97 { USB_DEVICE(0x04f3, 0x0089), .driver_info =
98 USB_QUIRK_DEVICE_QUALIFIER }, 98 USB_QUIRK_DEVICE_QUALIFIER },
99 99
100 { USB_DEVICE(0x04f3, 0x009b), .driver_info =
101 USB_QUIRK_DEVICE_QUALIFIER },
102
103 { USB_DEVICE(0x04f3, 0x016f), .driver_info =
104 USB_QUIRK_DEVICE_QUALIFIER },
105
100 /* Roland SC-8820 */ 106 /* Roland SC-8820 */
101 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME }, 107 { USB_DEVICE(0x0582, 0x0007), .driver_info = USB_QUIRK_RESET_RESUME },
102 108
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index bf015ab3b44c..55c90c53f2d6 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -619,7 +619,7 @@ struct dwc2_hsotg {
619 unsigned port_suspend_change:1; 619 unsigned port_suspend_change:1;
620 unsigned port_over_current_change:1; 620 unsigned port_over_current_change:1;
621 unsigned port_l1_change:1; 621 unsigned port_l1_change:1;
622 unsigned reserved:26; 622 unsigned reserved:25;
623 } b; 623 } b;
624 } flags; 624 } flags;
625 625
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b5856fadd93..8b5c079c7b7d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2327,7 +2327,7 @@ irq_retry:
2327 2327
2328 u32 usb_status = readl(hsotg->regs + GOTGCTL); 2328 u32 usb_status = readl(hsotg->regs + GOTGCTL);
2329 2329
2330 dev_info(hsotg->dev, "%s: USBRst\n", __func__); 2330 dev_dbg(hsotg->dev, "%s: USBRst\n", __func__);
2331 dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n", 2331 dev_dbg(hsotg->dev, "GNPTXSTS=%08x\n",
2332 readl(hsotg->regs + GNPTXSTS)); 2332 readl(hsotg->regs + GNPTXSTS));
2333 2333
@@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2561 hs_ep->fifo_size = val; 2561 hs_ep->fifo_size = val;
2562 break; 2562 break;
2563 } 2563 }
2564 if (i == 8) 2564 if (i == 8) {
2565 return -ENOMEM; 2565 ret = -ENOMEM;
2566 goto error;
2567 }
2566 } 2568 }
2567 2569
2568 /* for non control endpoints, set PID to D0 */ 2570 /* for non control endpoints, set PID to D0 */
@@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2579 /* enable the endpoint interrupt */ 2581 /* enable the endpoint interrupt */
2580 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); 2582 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1);
2581 2583
2584error:
2582 spin_unlock_irqrestore(&hsotg->lock, flags); 2585 spin_unlock_irqrestore(&hsotg->lock, flags);
2583 return ret; 2586 return ret;
2584} 2587}
@@ -2934,9 +2937,7 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
2934 2937
2935 spin_lock_irqsave(&hsotg->lock, flags); 2938 spin_lock_irqsave(&hsotg->lock, flags);
2936 2939
2937 if (!driver) 2940 hsotg->driver = NULL;
2938 hsotg->driver = NULL;
2939
2940 hsotg->gadget.speed = USB_SPEED_UNKNOWN; 2941 hsotg->gadget.speed = USB_SPEED_UNKNOWN;
2941 2942
2942 spin_unlock_irqrestore(&hsotg->lock, flags); 2943 spin_unlock_irqrestore(&hsotg->lock, flags);
@@ -3567,6 +3568,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3567 s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum); 3568 s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum);
3568 3569
3569 /* disable power and clock */ 3570 /* disable power and clock */
3571 s3c_hsotg_phy_disable(hsotg);
3570 3572
3571 ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), 3573 ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
3572 hsotg->supplies); 3574 hsotg->supplies);
@@ -3575,8 +3577,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3575 goto err_ep_mem; 3577 goto err_ep_mem;
3576 } 3578 }
3577 3579
3578 s3c_hsotg_phy_disable(hsotg);
3579
3580 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget); 3580 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget);
3581 if (ret) 3581 if (ret)
3582 goto err_ep_mem; 3582 goto err_ep_mem;
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 2f537d588225..a0aa9f3da441 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -597,7 +597,7 @@ static int dwc3_omap_prepare(struct device *dev)
597{ 597{
598 struct dwc3_omap *omap = dev_get_drvdata(dev); 598 struct dwc3_omap *omap = dev_get_drvdata(dev);
599 599
600 dwc3_omap_write_irqmisc_set(omap, 0x00); 600 dwc3_omap_disable_irqs(omap);
601 601
602 return 0; 602 return 0;
603} 603}
@@ -605,19 +605,8 @@ static int dwc3_omap_prepare(struct device *dev)
605static void dwc3_omap_complete(struct device *dev) 605static void dwc3_omap_complete(struct device *dev)
606{ 606{
607 struct dwc3_omap *omap = dev_get_drvdata(dev); 607 struct dwc3_omap *omap = dev_get_drvdata(dev);
608 u32 reg;
609 608
610 reg = (USBOTGSS_IRQMISC_OEVT | 609 dwc3_omap_enable_irqs(omap);
611 USBOTGSS_IRQMISC_DRVVBUS_RISE |
612 USBOTGSS_IRQMISC_CHRGVBUS_RISE |
613 USBOTGSS_IRQMISC_DISCHRGVBUS_RISE |
614 USBOTGSS_IRQMISC_IDPULLUP_RISE |
615 USBOTGSS_IRQMISC_DRVVBUS_FALL |
616 USBOTGSS_IRQMISC_CHRGVBUS_FALL |
617 USBOTGSS_IRQMISC_DISCHRGVBUS_FALL |
618 USBOTGSS_IRQMISC_IDPULLUP_FALL);
619
620 dwc3_omap_write_irqmisc_set(omap, reg);
621} 610}
622 611
623static int dwc3_omap_suspend(struct device *dev) 612static int dwc3_omap_suspend(struct device *dev)
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 436fb08c40b8..a36cf66302fb 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -30,6 +30,7 @@
30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd 30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
31#define PCI_DEVICE_ID_INTEL_BYT 0x0f37 31#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
32#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 32#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
33#define PCI_DEVICE_ID_INTEL_BSW 0x22B7
33 34
34struct dwc3_pci { 35struct dwc3_pci {
35 struct device *dev; 36 struct device *dev;
@@ -181,6 +182,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
181 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 182 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
182 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), 183 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
183 }, 184 },
185 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
184 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), }, 186 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
185 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), }, 187 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
186 { } /* Terminating Entry */ 188 { } /* Terminating Entry */
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index b35938777dde..711b23019d54 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -256,7 +256,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
256 256
257 /* stall is always issued on EP0 */ 257 /* stall is always issued on EP0 */
258 dep = dwc->eps[0]; 258 dep = dwc->eps[0];
259 __dwc3_gadget_ep_set_halt(dep, 1); 259 __dwc3_gadget_ep_set_halt(dep, 1, false);
260 dep->flags = DWC3_EP_ENABLED; 260 dep->flags = DWC3_EP_ENABLED;
261 dwc->delayed_status = false; 261 dwc->delayed_status = false;
262 262
@@ -271,7 +271,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
271 dwc3_ep0_out_start(dwc); 271 dwc3_ep0_out_start(dwc);
272} 272}
273 273
274int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) 274int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
275{ 275{
276 struct dwc3_ep *dep = to_dwc3_ep(ep); 276 struct dwc3_ep *dep = to_dwc3_ep(ep);
277 struct dwc3 *dwc = dep->dwc; 277 struct dwc3 *dwc = dep->dwc;
@@ -281,6 +281,20 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
281 return 0; 281 return 0;
282} 282}
283 283
284int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
285{
286 struct dwc3_ep *dep = to_dwc3_ep(ep);
287 struct dwc3 *dwc = dep->dwc;
288 unsigned long flags;
289 int ret;
290
291 spin_lock_irqsave(&dwc->lock, flags);
292 ret = __dwc3_gadget_ep0_set_halt(ep, value);
293 spin_unlock_irqrestore(&dwc->lock, flags);
294
295 return ret;
296}
297
284void dwc3_ep0_out_start(struct dwc3 *dwc) 298void dwc3_ep0_out_start(struct dwc3 *dwc)
285{ 299{
286 int ret; 300 int ret;
@@ -466,7 +480,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
466 return -EINVAL; 480 return -EINVAL;
467 if (set == 0 && (dep->flags & DWC3_EP_WEDGE)) 481 if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
468 break; 482 break;
469 ret = __dwc3_gadget_ep_set_halt(dep, set); 483 ret = __dwc3_gadget_ep_set_halt(dep, set, true);
470 if (ret) 484 if (ret)
471 return -EINVAL; 485 return -EINVAL;
472 break; 486 break;
@@ -775,9 +789,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
775 789
776 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS; 790 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
777 791
778 r = next_request(&ep0->request_list);
779 ur = &r->request;
780
781 trb = dwc->ep0_trb; 792 trb = dwc->ep0_trb;
782 793
783 status = DWC3_TRB_SIZE_TRBSTS(trb->size); 794 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
@@ -790,6 +801,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
790 return; 801 return;
791 } 802 }
792 803
804 r = next_request(&ep0->request_list);
805 if (!r)
806 return;
807
808 ur = &r->request;
809
793 length = trb->size & DWC3_TRB_SIZE_MASK; 810 length = trb->size & DWC3_TRB_SIZE_MASK;
794 811
795 if (dwc->ep0_bounced) { 812 if (dwc->ep0_bounced) {
@@ -811,12 +828,19 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
811 828
812 dwc3_ep0_stall_and_restart(dwc); 829 dwc3_ep0_stall_and_restart(dwc);
813 } else { 830 } else {
814 /* 831 dwc3_gadget_giveback(ep0, r, 0);
815 * handle the case where we have to send a zero packet. This 832
816 * seems to be case when req.length > maxpacket. Could it be? 833 if (IS_ALIGNED(ur->length, ep0->endpoint.maxpacket) &&
817 */ 834 ur->length && ur->zero) {
818 if (r) 835 int ret;
819 dwc3_gadget_giveback(ep0, r, 0); 836
837 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
838
839 ret = dwc3_ep0_start_trans(dwc, epnum,
840 dwc->ctrl_req_addr, 0,
841 DWC3_TRBCTL_CONTROL_DATA);
842 WARN_ON(ret < 0);
843 }
820 } 844 }
821} 845}
822 846
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3818b26bfc05..546ea5431b8c 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -525,12 +525,11 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
525 if (!usb_endpoint_xfer_isoc(desc)) 525 if (!usb_endpoint_xfer_isoc(desc))
526 return 0; 526 return 0;
527 527
528 memset(&trb_link, 0, sizeof(trb_link));
529
530 /* Link TRB for ISOC. The HWO bit is never reset */ 528 /* Link TRB for ISOC. The HWO bit is never reset */
531 trb_st_hw = &dep->trb_pool[0]; 529 trb_st_hw = &dep->trb_pool[0];
532 530
533 trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; 531 trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1];
532 memset(trb_link, 0, sizeof(*trb_link));
534 533
535 trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); 534 trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
536 trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); 535 trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
@@ -581,7 +580,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
581 580
582 /* make sure HW endpoint isn't stalled */ 581 /* make sure HW endpoint isn't stalled */
583 if (dep->flags & DWC3_EP_STALL) 582 if (dep->flags & DWC3_EP_STALL)
584 __dwc3_gadget_ep_set_halt(dep, 0); 583 __dwc3_gadget_ep_set_halt(dep, 0, false);
585 584
586 reg = dwc3_readl(dwc->regs, DWC3_DALEPENA); 585 reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
587 reg &= ~DWC3_DALEPENA_EP(dep->number); 586 reg &= ~DWC3_DALEPENA_EP(dep->number);
@@ -1202,15 +1201,28 @@ out0:
1202 return ret; 1201 return ret;
1203} 1202}
1204 1203
1205int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value) 1204int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
1206{ 1205{
1207 struct dwc3_gadget_ep_cmd_params params; 1206 struct dwc3_gadget_ep_cmd_params params;
1208 struct dwc3 *dwc = dep->dwc; 1207 struct dwc3 *dwc = dep->dwc;
1209 int ret; 1208 int ret;
1210 1209
1210 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1211 dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name);
1212 return -EINVAL;
1213 }
1214
1211 memset(&params, 0x00, sizeof(params)); 1215 memset(&params, 0x00, sizeof(params));
1212 1216
1213 if (value) { 1217 if (value) {
1218 if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) ||
1219 (!list_empty(&dep->req_queued) ||
1220 !list_empty(&dep->request_list)))) {
1221 dev_dbg(dwc->dev, "%s: pending request, cannot halt\n",
1222 dep->name);
1223 return -EAGAIN;
1224 }
1225
1214 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 1226 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
1215 DWC3_DEPCMD_SETSTALL, &params); 1227 DWC3_DEPCMD_SETSTALL, &params);
1216 if (ret) 1228 if (ret)
@@ -1241,15 +1253,7 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)
1241 int ret; 1253 int ret;
1242 1254
1243 spin_lock_irqsave(&dwc->lock, flags); 1255 spin_lock_irqsave(&dwc->lock, flags);
1244 1256 ret = __dwc3_gadget_ep_set_halt(dep, value, false);
1245 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1246 dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name);
1247 ret = -EINVAL;
1248 goto out;
1249 }
1250
1251 ret = __dwc3_gadget_ep_set_halt(dep, value);
1252out:
1253 spin_unlock_irqrestore(&dwc->lock, flags); 1257 spin_unlock_irqrestore(&dwc->lock, flags);
1254 1258
1255 return ret; 1259 return ret;
@@ -1260,15 +1264,18 @@ static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
1260 struct dwc3_ep *dep = to_dwc3_ep(ep); 1264 struct dwc3_ep *dep = to_dwc3_ep(ep);
1261 struct dwc3 *dwc = dep->dwc; 1265 struct dwc3 *dwc = dep->dwc;
1262 unsigned long flags; 1266 unsigned long flags;
1267 int ret;
1263 1268
1264 spin_lock_irqsave(&dwc->lock, flags); 1269 spin_lock_irqsave(&dwc->lock, flags);
1265 dep->flags |= DWC3_EP_WEDGE; 1270 dep->flags |= DWC3_EP_WEDGE;
1266 spin_unlock_irqrestore(&dwc->lock, flags);
1267 1271
1268 if (dep->number == 0 || dep->number == 1) 1272 if (dep->number == 0 || dep->number == 1)
1269 return dwc3_gadget_ep0_set_halt(ep, 1); 1273 ret = __dwc3_gadget_ep0_set_halt(ep, 1);
1270 else 1274 else
1271 return dwc3_gadget_ep_set_halt(ep, 1); 1275 ret = __dwc3_gadget_ep_set_halt(dep, 1, false);
1276 spin_unlock_irqrestore(&dwc->lock, flags);
1277
1278 return ret;
1272} 1279}
1273 1280
1274/* -------------------------------------------------------------------------- */ 1281/* -------------------------------------------------------------------------- */
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 178ad8982206..18ae3eaa8b6f 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -82,10 +82,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
82void dwc3_ep0_interrupt(struct dwc3 *dwc, 82void dwc3_ep0_interrupt(struct dwc3 *dwc,
83 const struct dwc3_event_depevt *event); 83 const struct dwc3_event_depevt *event);
84void dwc3_ep0_out_start(struct dwc3 *dwc); 84void dwc3_ep0_out_start(struct dwc3 *dwc);
85int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
85int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); 86int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
86int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, 87int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
87 gfp_t gfp_flags); 88 gfp_t gfp_flags);
88int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); 89int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);
89 90
90/** 91/**
91 * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW 92 * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
index 78aff1da089a..60b0f41eafc4 100644
--- a/drivers/usb/dwc3/trace.h
+++ b/drivers/usb/dwc3/trace.h
@@ -73,15 +73,23 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl,
73 TP_PROTO(struct usb_ctrlrequest *ctrl), 73 TP_PROTO(struct usb_ctrlrequest *ctrl),
74 TP_ARGS(ctrl), 74 TP_ARGS(ctrl),
75 TP_STRUCT__entry( 75 TP_STRUCT__entry(
76 __field(struct usb_ctrlrequest *, ctrl) 76 __field(__u8, bRequestType)
77 __field(__u8, bRequest)
78 __field(__le16, wValue)
79 __field(__le16, wIndex)
80 __field(__le16, wLength)
77 ), 81 ),
78 TP_fast_assign( 82 TP_fast_assign(
79 __entry->ctrl = ctrl; 83 __entry->bRequestType = ctrl->bRequestType;
84 __entry->bRequest = ctrl->bRequest;
85 __entry->wValue = ctrl->wValue;
86 __entry->wIndex = ctrl->wIndex;
87 __entry->wLength = ctrl->wLength;
80 ), 88 ),
81 TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d", 89 TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
82 __entry->ctrl->bRequestType, __entry->ctrl->bRequest, 90 __entry->bRequestType, __entry->bRequest,
83 le16_to_cpu(__entry->ctrl->wValue), le16_to_cpu(__entry->ctrl->wIndex), 91 le16_to_cpu(__entry->wValue), le16_to_cpu(__entry->wIndex),
84 le16_to_cpu(__entry->ctrl->wLength) 92 le16_to_cpu(__entry->wLength)
85 ) 93 )
86); 94);
87 95
@@ -94,15 +102,22 @@ DECLARE_EVENT_CLASS(dwc3_log_request,
94 TP_PROTO(struct dwc3_request *req), 102 TP_PROTO(struct dwc3_request *req),
95 TP_ARGS(req), 103 TP_ARGS(req),
96 TP_STRUCT__entry( 104 TP_STRUCT__entry(
105 __dynamic_array(char, name, DWC3_MSG_MAX)
97 __field(struct dwc3_request *, req) 106 __field(struct dwc3_request *, req)
107 __field(unsigned, actual)
108 __field(unsigned, length)
109 __field(int, status)
98 ), 110 ),
99 TP_fast_assign( 111 TP_fast_assign(
112 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
100 __entry->req = req; 113 __entry->req = req;
114 __entry->actual = req->request.actual;
115 __entry->length = req->request.length;
116 __entry->status = req->request.status;
101 ), 117 ),
102 TP_printk("%s: req %p length %u/%u ==> %d", 118 TP_printk("%s: req %p length %u/%u ==> %d",
103 __entry->req->dep->name, __entry->req, 119 __get_str(name), __entry->req, __entry->actual, __entry->length,
104 __entry->req->request.actual, __entry->req->request.length, 120 __entry->status
105 __entry->req->request.status
106 ) 121 )
107); 122);
108 123
@@ -158,17 +173,17 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
158 struct dwc3_gadget_ep_cmd_params *params), 173 struct dwc3_gadget_ep_cmd_params *params),
159 TP_ARGS(dep, cmd, params), 174 TP_ARGS(dep, cmd, params),
160 TP_STRUCT__entry( 175 TP_STRUCT__entry(
161 __field(struct dwc3_ep *, dep) 176 __dynamic_array(char, name, DWC3_MSG_MAX)
162 __field(unsigned int, cmd) 177 __field(unsigned int, cmd)
163 __field(struct dwc3_gadget_ep_cmd_params *, params) 178 __field(struct dwc3_gadget_ep_cmd_params *, params)
164 ), 179 ),
165 TP_fast_assign( 180 TP_fast_assign(
166 __entry->dep = dep; 181 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
167 __entry->cmd = cmd; 182 __entry->cmd = cmd;
168 __entry->params = params; 183 __entry->params = params;
169 ), 184 ),
170 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x\n", 185 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x\n",
171 __entry->dep->name, dwc3_gadget_ep_cmd_string(__entry->cmd), 186 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
172 __entry->cmd, __entry->params->param0, 187 __entry->cmd, __entry->params->param0,
173 __entry->params->param1, __entry->params->param2 188 __entry->params->param1, __entry->params->param2
174 ) 189 )
@@ -184,16 +199,24 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
184 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), 199 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
185 TP_ARGS(dep, trb), 200 TP_ARGS(dep, trb),
186 TP_STRUCT__entry( 201 TP_STRUCT__entry(
187 __field(struct dwc3_ep *, dep) 202 __dynamic_array(char, name, DWC3_MSG_MAX)
188 __field(struct dwc3_trb *, trb) 203 __field(struct dwc3_trb *, trb)
204 __field(u32, bpl)
205 __field(u32, bph)
206 __field(u32, size)
207 __field(u32, ctrl)
189 ), 208 ),
190 TP_fast_assign( 209 TP_fast_assign(
191 __entry->dep = dep; 210 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
192 __entry->trb = trb; 211 __entry->trb = trb;
212 __entry->bpl = trb->bpl;
213 __entry->bph = trb->bph;
214 __entry->size = trb->size;
215 __entry->ctrl = trb->ctrl;
193 ), 216 ),
194 TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x\n", 217 TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x\n",
195 __entry->dep->name, __entry->trb, __entry->trb->bph, 218 __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
196 __entry->trb->bpl, __entry->trb->size, __entry->trb->ctrl 219 __entry->size, __entry->ctrl
197 ) 220 )
198); 221);
199 222
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a8c18df171c3..f6a51fddd5b5 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -560,7 +560,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
560 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; 560 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
561 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; 561 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
562 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; 562 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
563 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT); 563 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
564 564
565 /* 565 /*
566 * The Superspeed USB Capability descriptor shall be implemented by all 566 * The Superspeed USB Capability descriptor shall be implemented by all
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 6da4685490ef..aad8165e98ef 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -433,12 +433,12 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
433 dev_vdbg(&cdev->gadget->dev, 433 dev_vdbg(&cdev->gadget->dev,
434 "reset acm control interface %d\n", intf); 434 "reset acm control interface %d\n", intf);
435 usb_ep_disable(acm->notify); 435 usb_ep_disable(acm->notify);
436 } else { 436 }
437 dev_vdbg(&cdev->gadget->dev, 437
438 "init acm ctrl interface %d\n", intf); 438 if (!acm->notify->desc)
439 if (config_ep_by_speed(cdev->gadget, f, acm->notify)) 439 if (config_ep_by_speed(cdev->gadget, f, acm->notify))
440 return -EINVAL; 440 return -EINVAL;
441 } 441
442 usb_ep_enable(acm->notify); 442 usb_ep_enable(acm->notify);
443 acm->notify->driver_data = acm; 443 acm->notify->driver_data = acm;
444 444
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index 4d8b236ea608..c9e90de5bdd9 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -325,7 +325,6 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f)
325 return 0; 325 return 0;
326 326
327fail: 327fail:
328 usb_free_all_descriptors(f);
329 if (eem->port.out_ep) 328 if (eem->port.out_ep)
330 eem->port.out_ep->driver_data = NULL; 329 eem->port.out_ep->driver_data = NULL;
331 if (eem->port.in_ep) 330 if (eem->port.in_ep)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 7c6771d027a2..63314ede7ba6 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -647,15 +647,26 @@ static void ffs_user_copy_worker(struct work_struct *work)
647 if (io_data->read && ret > 0) { 647 if (io_data->read && ret > 0) {
648 int i; 648 int i;
649 size_t pos = 0; 649 size_t pos = 0;
650
651 /*
652 * Since req->length may be bigger than io_data->len (after
653 * being rounded up to maxpacketsize), we may end up with more
654 * data then user space has space for.
655 */
656 ret = min_t(int, ret, io_data->len);
657
650 use_mm(io_data->mm); 658 use_mm(io_data->mm);
651 for (i = 0; i < io_data->nr_segs; i++) { 659 for (i = 0; i < io_data->nr_segs; i++) {
660 size_t len = min_t(size_t, ret - pos,
661 io_data->iovec[i].iov_len);
662 if (!len)
663 break;
652 if (unlikely(copy_to_user(io_data->iovec[i].iov_base, 664 if (unlikely(copy_to_user(io_data->iovec[i].iov_base,
653 &io_data->buf[pos], 665 &io_data->buf[pos], len))) {
654 io_data->iovec[i].iov_len))) {
655 ret = -EFAULT; 666 ret = -EFAULT;
656 break; 667 break;
657 } 668 }
658 pos += io_data->iovec[i].iov_len; 669 pos += len;
659 } 670 }
660 unuse_mm(io_data->mm); 671 unuse_mm(io_data->mm);
661 } 672 }
@@ -687,7 +698,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
687 struct ffs_epfile *epfile = file->private_data; 698 struct ffs_epfile *epfile = file->private_data;
688 struct ffs_ep *ep; 699 struct ffs_ep *ep;
689 char *data = NULL; 700 char *data = NULL;
690 ssize_t ret, data_len; 701 ssize_t ret, data_len = -EINVAL;
691 int halt; 702 int halt;
692 703
693 /* Are we still active? */ 704 /* Are we still active? */
@@ -787,13 +798,30 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
787 /* Fire the request */ 798 /* Fire the request */
788 struct usb_request *req; 799 struct usb_request *req;
789 800
801 /*
802 * Sanity Check: even though data_len can't be used
803 * uninitialized at the time I write this comment, some
804 * compilers complain about this situation.
805 * In order to keep the code clean from warnings, data_len is
806 * being initialized to -EINVAL during its declaration, which
807 * means we can't rely on compiler anymore to warn no future
808 * changes won't result in data_len being used uninitialized.
809 * For such reason, we're adding this redundant sanity check
810 * here.
811 */
812 if (unlikely(data_len == -EINVAL)) {
813 WARN(1, "%s: data_len == -EINVAL\n", __func__);
814 ret = -EINVAL;
815 goto error_lock;
816 }
817
790 if (io_data->aio) { 818 if (io_data->aio) {
791 req = usb_ep_alloc_request(ep->ep, GFP_KERNEL); 819 req = usb_ep_alloc_request(ep->ep, GFP_KERNEL);
792 if (unlikely(!req)) 820 if (unlikely(!req))
793 goto error_lock; 821 goto error_lock;
794 822
795 req->buf = data; 823 req->buf = data;
796 req->length = io_data->len; 824 req->length = data_len;
797 825
798 io_data->buf = data; 826 io_data->buf = data;
799 io_data->ep = ep->ep; 827 io_data->ep = ep->ep;
@@ -815,7 +843,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
815 843
816 req = ep->req; 844 req = ep->req;
817 req->buf = data; 845 req->buf = data;
818 req->length = io_data->len; 846 req->length = data_len;
819 847
820 req->context = &done; 848 req->context = &done;
821 req->complete = ffs_epfile_io_complete; 849 req->complete = ffs_epfile_io_complete;
@@ -2663,8 +2691,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
2663 func->conf = c; 2691 func->conf = c;
2664 func->gadget = c->cdev->gadget; 2692 func->gadget = c->cdev->gadget;
2665 2693
2666 ffs_data_get(func->ffs);
2667
2668 /* 2694 /*
2669 * in drivers/usb/gadget/configfs.c:configfs_composite_bind() 2695 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
2670 * configurations are bound in sequence with list_for_each_entry, 2696 * configurations are bound in sequence with list_for_each_entry,
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index a95290a1289f..59ab62c92b66 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -621,12 +621,14 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
621 dev = MKDEV(major, hidg->minor); 621 dev = MKDEV(major, hidg->minor);
622 status = cdev_add(&hidg->cdev, dev, 1); 622 status = cdev_add(&hidg->cdev, dev, 1);
623 if (status) 623 if (status)
624 goto fail; 624 goto fail_free_descs;
625 625
626 device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor); 626 device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
627 627
628 return 0; 628 return 0;
629 629
630fail_free_descs:
631 usb_free_all_descriptors(f);
630fail: 632fail:
631 ERROR(f->config->cdev, "hidg_bind FAILED\n"); 633 ERROR(f->config->cdev, "hidg_bind FAILED\n");
632 if (hidg->req != NULL) { 634 if (hidg->req != NULL) {
@@ -635,7 +637,6 @@ fail:
635 usb_ep_free_request(hidg->in_ep, hidg->req); 637 usb_ep_free_request(hidg->in_ep, hidg->req);
636 } 638 }
637 639
638 usb_free_all_descriptors(f);
639 return status; 640 return status;
640} 641}
641 642
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
index bf04389137e6..298b46112b1a 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -253,22 +253,13 @@ static void loopback_complete(struct usb_ep *ep, struct usb_request *req)
253 253
254 case 0: /* normal completion? */ 254 case 0: /* normal completion? */
255 if (ep == loop->out_ep) { 255 if (ep == loop->out_ep) {
256 /* loop this OUT packet back IN to the host */
257 req->zero = (req->actual < req->length); 256 req->zero = (req->actual < req->length);
258 req->length = req->actual; 257 req->length = req->actual;
259 status = usb_ep_queue(loop->in_ep, req, GFP_ATOMIC);
260 if (status == 0)
261 return;
262
263 /* "should never get here" */
264 ERROR(cdev, "can't loop %s to %s: %d\n",
265 ep->name, loop->in_ep->name,
266 status);
267 } 258 }
268 259
269 /* queue the buffer for some later OUT packet */ 260 /* queue the buffer for some later OUT packet */
270 req->length = buflen; 261 req->length = buflen;
271 status = usb_ep_queue(loop->out_ep, req, GFP_ATOMIC); 262 status = usb_ep_queue(ep, req, GFP_ATOMIC);
272 if (status == 0) 263 if (status == 0)
273 return; 264 return;
274 265
@@ -308,60 +299,66 @@ static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len)
308 return alloc_ep_req(ep, len, buflen); 299 return alloc_ep_req(ep, len, buflen);
309} 300}
310 301
311static int 302static int enable_endpoint(struct usb_composite_dev *cdev, struct f_loopback *loop,
312enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) 303 struct usb_ep *ep)
313{ 304{
314 int result = 0;
315 struct usb_ep *ep;
316 struct usb_request *req; 305 struct usb_request *req;
317 unsigned i; 306 unsigned i;
307 int result;
318 308
319 /* one endpoint writes data back IN to the host */ 309 /*
320 ep = loop->in_ep; 310 * one endpoint writes data back IN to the host while another endpoint
311 * just reads OUT packets
312 */
321 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep); 313 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep);
322 if (result) 314 if (result)
323 return result; 315 goto fail0;
324 result = usb_ep_enable(ep); 316 result = usb_ep_enable(ep);
325 if (result < 0) 317 if (result < 0)
326 return result;
327 ep->driver_data = loop;
328
329 /* one endpoint just reads OUT packets */
330 ep = loop->out_ep;
331 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep);
332 if (result)
333 goto fail0; 318 goto fail0;
334
335 result = usb_ep_enable(ep);
336 if (result < 0) {
337fail0:
338 ep = loop->in_ep;
339 usb_ep_disable(ep);
340 ep->driver_data = NULL;
341 return result;
342 }
343 ep->driver_data = loop; 319 ep->driver_data = loop;
344 320
345 /* allocate a bunch of read buffers and queue them all at once. 321 /*
322 * allocate a bunch of read buffers and queue them all at once.
346 * we buffer at most 'qlen' transfers; fewer if any need more 323 * we buffer at most 'qlen' transfers; fewer if any need more
347 * than 'buflen' bytes each. 324 * than 'buflen' bytes each.
348 */ 325 */
349 for (i = 0; i < qlen && result == 0; i++) { 326 for (i = 0; i < qlen && result == 0; i++) {
350 req = lb_alloc_ep_req(ep, 0); 327 req = lb_alloc_ep_req(ep, 0);
351 if (req) { 328 if (!req)
352 req->complete = loopback_complete; 329 goto fail1;
353 result = usb_ep_queue(ep, req, GFP_ATOMIC); 330
354 if (result) 331 req->complete = loopback_complete;
355 ERROR(cdev, "%s queue req --> %d\n", 332 result = usb_ep_queue(ep, req, GFP_ATOMIC);
356 ep->name, result); 333 if (result) {
357 } else { 334 ERROR(cdev, "%s queue req --> %d\n",
358 usb_ep_disable(ep); 335 ep->name, result);
359 ep->driver_data = NULL; 336 goto fail1;
360 result = -ENOMEM;
361 goto fail0;
362 } 337 }
363 } 338 }
364 339
340 return 0;
341
342fail1:
343 usb_ep_disable(ep);
344
345fail0:
346 return result;
347}
348
349static int
350enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
351{
352 int result = 0;
353
354 result = enable_endpoint(cdev, loop, loop->in_ep);
355 if (result)
356 return result;
357
358 result = enable_endpoint(cdev, loop, loop->out_ep);
359 if (result)
360 return result;
361
365 DBG(cdev, "%s enabled\n", loop->function.name); 362 DBG(cdev, "%s enabled\n", loop->function.name);
366 return result; 363 return result;
367} 364}
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 146f48cc65d7..16361b0a8b46 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1461,7 +1461,6 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
1461 return 0; 1461 return 0;
1462 1462
1463fail: 1463fail:
1464 usb_free_all_descriptors(f);
1465 if (ncm->notify_req) { 1464 if (ncm->notify_req) {
1466 kfree(ncm->notify_req->buf); 1465 kfree(ncm->notify_req->buf);
1467 usb_ep_free_request(ncm->notify, ncm->notify_req); 1466 usb_ep_free_request(ncm->notify, ncm->notify_req);
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c
index 5f40080c92cc..a1b79c53499c 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -35,6 +35,7 @@ struct f_obex {
35 struct gserial port; 35 struct gserial port;
36 u8 ctrl_id; 36 u8 ctrl_id;
37 u8 data_id; 37 u8 data_id;
38 u8 cur_alt;
38 u8 port_num; 39 u8 port_num;
39 u8 can_activate; 40 u8 can_activate;
40}; 41};
@@ -235,6 +236,8 @@ static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
235 } else 236 } else
236 goto fail; 237 goto fail;
237 238
239 obex->cur_alt = alt;
240
238 return 0; 241 return 0;
239 242
240fail: 243fail:
@@ -245,10 +248,7 @@ static int obex_get_alt(struct usb_function *f, unsigned intf)
245{ 248{
246 struct f_obex *obex = func_to_obex(f); 249 struct f_obex *obex = func_to_obex(f);
247 250
248 if (intf == obex->ctrl_id) 251 return obex->cur_alt;
249 return 0;
250
251 return obex->port.in->driver_data ? 1 : 0;
252} 252}
253 253
254static void obex_disable(struct usb_function *f) 254static void obex_disable(struct usb_function *f)
@@ -397,7 +397,6 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f)
397 return 0; 397 return 0;
398 398
399fail: 399fail:
400 usb_free_all_descriptors(f);
401 /* we might as well release our claims on endpoints */ 400 /* we might as well release our claims on endpoints */
402 if (obex->port.out) 401 if (obex->port.out)
403 obex->port.out->driver_data = NULL; 402 obex->port.out->driver_data = NULL;
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
index b9cfc1571d71..1ec8b7ffdccd 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -570,8 +570,8 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
570err_req: 570err_req:
571 for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) 571 for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
572 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); 572 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
573err:
574 usb_free_all_descriptors(f); 573 usb_free_all_descriptors(f);
574err:
575 if (fp->out_ep) 575 if (fp->out_ep)
576 fp->out_ep->driver_data = NULL; 576 fp->out_ep->driver_data = NULL;
577 if (fp->in_ep) 577 if (fp->in_ep)
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index ddb09dc6d1f2..f13fc6a58565 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -802,8 +802,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
802 802
803 if (rndis->manufacturer && rndis->vendorID && 803 if (rndis->manufacturer && rndis->vendorID &&
804 rndis_set_param_vendor(rndis->config, rndis->vendorID, 804 rndis_set_param_vendor(rndis->config, rndis->vendorID,
805 rndis->manufacturer)) 805 rndis->manufacturer)) {
806 goto fail; 806 status = -EINVAL;
807 goto fail_free_descs;
808 }
807 809
808 /* NOTE: all that is done without knowing or caring about 810 /* NOTE: all that is done without knowing or caring about
809 * the network link ... which is unavailable to this code 811 * the network link ... which is unavailable to this code
@@ -817,10 +819,11 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
817 rndis->notify->name); 819 rndis->notify->name);
818 return 0; 820 return 0;
819 821
822fail_free_descs:
823 usb_free_all_descriptors(f);
820fail: 824fail:
821 kfree(f->os_desc_table); 825 kfree(f->os_desc_table);
822 f->os_desc_n = 0; 826 f->os_desc_n = 0;
823 usb_free_all_descriptors(f);
824 827
825 if (rndis->notify_req) { 828 if (rndis->notify_req) {
826 kfree(rndis->notify_req->buf); 829 kfree(rndis->notify_req->buf);
diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c
index 1ea8baf33333..e3dfa675ff06 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -380,7 +380,6 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
380 return 0; 380 return 0;
381 381
382fail: 382fail:
383 usb_free_all_descriptors(f);
384 /* we might as well release our claims on endpoints */ 383 /* we might as well release our claims on endpoints */
385 if (geth->port.out_ep) 384 if (geth->port.out_ep)
386 geth->port.out_ep->driver_data = NULL; 385 geth->port.out_ep->driver_data = NULL;
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index a5a27a504d67..33e16658e5cf 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -512,6 +512,11 @@ static int snd_uac2_remove(struct platform_device *pdev)
512 return 0; 512 return 0;
513} 513}
514 514
515static void snd_uac2_release(struct device *dev)
516{
517 dev_dbg(dev, "releasing '%s'\n", dev_name(dev));
518}
519
515static int alsa_uac2_init(struct audio_dev *agdev) 520static int alsa_uac2_init(struct audio_dev *agdev)
516{ 521{
517 struct snd_uac2_chip *uac2 = &agdev->uac2; 522 struct snd_uac2_chip *uac2 = &agdev->uac2;
@@ -523,6 +528,7 @@ static int alsa_uac2_init(struct audio_dev *agdev)
523 528
524 uac2->pdev.id = 0; 529 uac2->pdev.id = 0;
525 uac2->pdev.name = uac2_name; 530 uac2->pdev.name = uac2_name;
531 uac2->pdev.dev.release = snd_uac2_release;
526 532
527 /* Register snd_uac2 driver */ 533 /* Register snd_uac2 driver */
528 err = platform_driver_register(&uac2->pdrv); 534 err = platform_driver_register(&uac2->pdrv);
@@ -772,6 +778,7 @@ struct usb_endpoint_descriptor fs_epout_desc = {
772 778
773 .bEndpointAddress = USB_DIR_OUT, 779 .bEndpointAddress = USB_DIR_OUT,
774 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 780 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
781 .wMaxPacketSize = cpu_to_le16(1023),
775 .bInterval = 1, 782 .bInterval = 1,
776}; 783};
777 784
@@ -780,6 +787,7 @@ struct usb_endpoint_descriptor hs_epout_desc = {
780 .bDescriptorType = USB_DT_ENDPOINT, 787 .bDescriptorType = USB_DT_ENDPOINT,
781 788
782 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 789 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
790 .wMaxPacketSize = cpu_to_le16(1024),
783 .bInterval = 4, 791 .bInterval = 4,
784}; 792};
785 793
@@ -847,6 +855,7 @@ struct usb_endpoint_descriptor fs_epin_desc = {
847 855
848 .bEndpointAddress = USB_DIR_IN, 856 .bEndpointAddress = USB_DIR_IN,
849 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 857 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
858 .wMaxPacketSize = cpu_to_le16(1023),
850 .bInterval = 1, 859 .bInterval = 1,
851}; 860};
852 861
@@ -855,6 +864,7 @@ struct usb_endpoint_descriptor hs_epin_desc = {
855 .bDescriptorType = USB_DT_ENDPOINT, 864 .bDescriptorType = USB_DT_ENDPOINT,
856 865
857 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 866 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
867 .wMaxPacketSize = cpu_to_le16(1024),
858 .bInterval = 4, 868 .bInterval = 4,
859}; 869};
860 870
@@ -947,6 +957,9 @@ free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep)
947 struct snd_uac2_chip *uac2 = prm->uac2; 957 struct snd_uac2_chip *uac2 = prm->uac2;
948 int i; 958 int i;
949 959
960 if (!prm->ep_enabled)
961 return;
962
950 prm->ep_enabled = false; 963 prm->ep_enabled = false;
951 964
952 for (i = 0; i < USB_XFERS; i++) { 965 for (i = 0; i < USB_XFERS; i++) {
@@ -1071,7 +1084,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1071 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); 1084 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
1072 if (!prm->rbuf) { 1085 if (!prm->rbuf) {
1073 prm->max_psize = 0; 1086 prm->max_psize = 0;
1074 goto err; 1087 goto err_free_descs;
1075 } 1088 }
1076 1089
1077 prm = &agdev->uac2.p_prm; 1090 prm = &agdev->uac2.p_prm;
@@ -1079,17 +1092,19 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1079 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); 1092 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
1080 if (!prm->rbuf) { 1093 if (!prm->rbuf) {
1081 prm->max_psize = 0; 1094 prm->max_psize = 0;
1082 goto err; 1095 goto err_free_descs;
1083 } 1096 }
1084 1097
1085 ret = alsa_uac2_init(agdev); 1098 ret = alsa_uac2_init(agdev);
1086 if (ret) 1099 if (ret)
1087 goto err; 1100 goto err_free_descs;
1088 return 0; 1101 return 0;
1102
1103err_free_descs:
1104 usb_free_all_descriptors(fn);
1089err: 1105err:
1090 kfree(agdev->uac2.p_prm.rbuf); 1106 kfree(agdev->uac2.p_prm.rbuf);
1091 kfree(agdev->uac2.c_prm.rbuf); 1107 kfree(agdev->uac2.c_prm.rbuf);
1092 usb_free_all_descriptors(fn);
1093 if (agdev->in_ep) 1108 if (agdev->in_ep)
1094 agdev->in_ep->driver_data = NULL; 1109 agdev->in_ep->driver_data = NULL;
1095 if (agdev->out_ep) 1110 if (agdev->out_ep)
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index e126439e4b65..945b3bd2ca98 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -279,27 +279,41 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
279 else if (interface != uvc->streaming_intf) 279 else if (interface != uvc->streaming_intf)
280 return -EINVAL; 280 return -EINVAL;
281 else 281 else
282 return uvc->state == UVC_STATE_STREAMING ? 1 : 0; 282 return uvc->video.ep->driver_data ? 1 : 0;
283} 283}
284 284
285static int 285static int
286uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) 286uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
287{ 287{
288 struct uvc_device *uvc = to_uvc(f); 288 struct uvc_device *uvc = to_uvc(f);
289 struct usb_composite_dev *cdev = f->config->cdev;
289 struct v4l2_event v4l2_event; 290 struct v4l2_event v4l2_event;
290 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; 291 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
291 int ret; 292 int ret;
292 293
293 INFO(f->config->cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); 294 INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt);
294 295
295 if (interface == uvc->control_intf) { 296 if (interface == uvc->control_intf) {
296 if (alt) 297 if (alt)
297 return -EINVAL; 298 return -EINVAL;
298 299
300 if (uvc->control_ep->driver_data) {
301 INFO(cdev, "reset UVC Control\n");
302 usb_ep_disable(uvc->control_ep);
303 uvc->control_ep->driver_data = NULL;
304 }
305
306 if (!uvc->control_ep->desc)
307 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep))
308 return -EINVAL;
309
310 usb_ep_enable(uvc->control_ep);
311 uvc->control_ep->driver_data = uvc;
312
299 if (uvc->state == UVC_STATE_DISCONNECTED) { 313 if (uvc->state == UVC_STATE_DISCONNECTED) {
300 memset(&v4l2_event, 0, sizeof(v4l2_event)); 314 memset(&v4l2_event, 0, sizeof(v4l2_event));
301 v4l2_event.type = UVC_EVENT_CONNECT; 315 v4l2_event.type = UVC_EVENT_CONNECT;
302 uvc_event->speed = f->config->cdev->gadget->speed; 316 uvc_event->speed = cdev->gadget->speed;
303 v4l2_event_queue(uvc->vdev, &v4l2_event); 317 v4l2_event_queue(uvc->vdev, &v4l2_event);
304 318
305 uvc->state = UVC_STATE_CONNECTED; 319 uvc->state = UVC_STATE_CONNECTED;
@@ -321,8 +335,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
321 if (uvc->state != UVC_STATE_STREAMING) 335 if (uvc->state != UVC_STATE_STREAMING)
322 return 0; 336 return 0;
323 337
324 if (uvc->video.ep) 338 if (uvc->video.ep) {
325 usb_ep_disable(uvc->video.ep); 339 usb_ep_disable(uvc->video.ep);
340 uvc->video.ep->driver_data = NULL;
341 }
326 342
327 memset(&v4l2_event, 0, sizeof(v4l2_event)); 343 memset(&v4l2_event, 0, sizeof(v4l2_event));
328 v4l2_event.type = UVC_EVENT_STREAMOFF; 344 v4l2_event.type = UVC_EVENT_STREAMOFF;
@@ -335,14 +351,22 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
335 if (uvc->state != UVC_STATE_CONNECTED) 351 if (uvc->state != UVC_STATE_CONNECTED)
336 return 0; 352 return 0;
337 353
338 if (uvc->video.ep) { 354 if (!uvc->video.ep)
339 ret = config_ep_by_speed(f->config->cdev->gadget, 355 return -EINVAL;
340 &(uvc->func), uvc->video.ep); 356
341 if (ret) 357 if (uvc->video.ep->driver_data) {
342 return ret; 358 INFO(cdev, "reset UVC\n");
343 usb_ep_enable(uvc->video.ep); 359 usb_ep_disable(uvc->video.ep);
360 uvc->video.ep->driver_data = NULL;
344 } 361 }
345 362
363 ret = config_ep_by_speed(f->config->cdev->gadget,
364 &(uvc->func), uvc->video.ep);
365 if (ret)
366 return ret;
367 usb_ep_enable(uvc->video.ep);
368 uvc->video.ep->driver_data = uvc;
369
346 memset(&v4l2_event, 0, sizeof(v4l2_event)); 370 memset(&v4l2_event, 0, sizeof(v4l2_event));
347 v4l2_event.type = UVC_EVENT_STREAMON; 371 v4l2_event.type = UVC_EVENT_STREAMON;
348 v4l2_event_queue(uvc->vdev, &v4l2_event); 372 v4l2_event_queue(uvc->vdev, &v4l2_event);
@@ -366,6 +390,16 @@ uvc_function_disable(struct usb_function *f)
366 v4l2_event_queue(uvc->vdev, &v4l2_event); 390 v4l2_event_queue(uvc->vdev, &v4l2_event);
367 391
368 uvc->state = UVC_STATE_DISCONNECTED; 392 uvc->state = UVC_STATE_DISCONNECTED;
393
394 if (uvc->video.ep->driver_data) {
395 usb_ep_disable(uvc->video.ep);
396 uvc->video.ep->driver_data = NULL;
397 }
398
399 if (uvc->control_ep->driver_data) {
400 usb_ep_disable(uvc->control_ep);
401 uvc->control_ep->driver_data = NULL;
402 }
369} 403}
370 404
371/* -------------------------------------------------------------------------- 405/* --------------------------------------------------------------------------
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index c3e1f27dbbef..9cb86bc1a9a5 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -352,7 +352,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
352 352
353 if (!enable) { 353 if (!enable) {
354 for (i = 0; i < UVC_NUM_REQUESTS; ++i) 354 for (i = 0; i < UVC_NUM_REQUESTS; ++i)
355 usb_ep_dequeue(video->ep, video->req[i]); 355 if (video->req[i])
356 usb_ep_dequeue(video->ep, video->req[i]);
356 357
357 uvc_video_free_requests(video); 358 uvc_video_free_requests(video);
358 uvcg_queue_enable(&video->queue, 0); 359 uvcg_queue_enable(&video->queue, 0);
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 3ea287b0e448..217365d35a25 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -357,6 +357,7 @@ config USB_EG20T
357 357
358config USB_GADGET_XILINX 358config USB_GADGET_XILINX
359 tristate "Xilinx USB Driver" 359 tristate "Xilinx USB Driver"
360 depends on HAS_DMA
360 depends on OF || COMPILE_TEST 361 depends on OF || COMPILE_TEST
361 help 362 help
362 USB peripheral controller driver for Xilinx USB2 device. 363 USB peripheral controller driver for Xilinx USB2 device.
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index f107bb60a5ab..f2054659f25b 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -507,6 +507,11 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
507{ 507{
508 struct usb_udc *udc = container_of(dev, struct usb_udc, dev); 508 struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
509 509
510 if (!udc->driver) {
511 dev_err(dev, "soft-connect without a gadget driver\n");
512 return -EOPNOTSUPP;
513 }
514
510 if (sysfs_streq(buf, "connect")) { 515 if (sysfs_streq(buf, "connect")) {
511 usb_gadget_udc_start(udc->gadget, udc->driver); 516 usb_gadget_udc_start(udc->gadget, udc->driver);
512 usb_gadget_connect(udc->gadget); 517 usb_gadget_connect(udc->gadget);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index a8a30b1d4167..a3ca1375dd52 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -234,7 +234,7 @@ config USB_EHCI_SH
234 234
235config USB_EHCI_EXYNOS 235config USB_EHCI_EXYNOS
236 tristate "EHCI support for Samsung S5P/EXYNOS SoC Series" 236 tristate "EHCI support for Samsung S5P/EXYNOS SoC Series"
237 depends on PLAT_S5P || ARCH_EXYNOS 237 depends on ARCH_S5PV210 || ARCH_EXYNOS
238 help 238 help
239 Enable support for the Samsung Exynos SOC's on-chip EHCI controller. 239 Enable support for the Samsung Exynos SOC's on-chip EHCI controller.
240 240
@@ -550,7 +550,7 @@ config USB_OHCI_SH
550 550
551config USB_OHCI_EXYNOS 551config USB_OHCI_EXYNOS
552 tristate "OHCI support for Samsung S5P/EXYNOS SoC Series" 552 tristate "OHCI support for Samsung S5P/EXYNOS SoC Series"
553 depends on PLAT_S5P || ARCH_EXYNOS 553 depends on ARCH_S5PV210 || ARCH_EXYNOS
554 help 554 help
555 Enable support for the Samsung Exynos SOC's on-chip OHCI controller. 555 Enable support for the Samsung Exynos SOC's on-chip OHCI controller.
556 556
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c
index d0d8fadf7066..1db0626c8bf4 100644
--- a/drivers/usb/host/hwa-hc.c
+++ b/drivers/usb/host/hwa-hc.c
@@ -607,7 +607,7 @@ found:
607 wa->wa_descr = wa_descr = (struct usb_wa_descriptor *) hdr; 607 wa->wa_descr = wa_descr = (struct usb_wa_descriptor *) hdr;
608 if (le16_to_cpu(wa_descr->bcdWAVersion) > 0x0100) 608 if (le16_to_cpu(wa_descr->bcdWAVersion) > 0x0100)
609 dev_warn(dev, "Wire Adapter v%d.%d newer than groked v1.0\n", 609 dev_warn(dev, "Wire Adapter v%d.%d newer than groked v1.0\n",
610 le16_to_cpu(wa_descr->bcdWAVersion) & 0xff00 >> 8, 610 (le16_to_cpu(wa_descr->bcdWAVersion) & 0xff00) >> 8,
611 le16_to_cpu(wa_descr->bcdWAVersion) & 0x00ff); 611 le16_to_cpu(wa_descr->bcdWAVersion) & 0x00ff);
612 result = 0; 612 result = 0;
613error: 613error:
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 280dde93abe5..9a69b1f1b300 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -128,20 +128,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
128 xhci->quirks |= XHCI_AVOID_BEI; 128 xhci->quirks |= XHCI_AVOID_BEI;
129 } 129 }
130 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 130 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
131 (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI ||
132 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI)) {
133 /* Workaround for occasional spurious wakeups from S5 (or
134 * any other sleep) on Haswell machines with LPT and LPT-LP
135 * with the new Intel BIOS
136 */
137 /* Limit the quirk to only known vendors, as this triggers
138 * yet another BIOS bug on some other machines
139 * https://bugzilla.kernel.org/show_bug.cgi?id=66171
140 */
141 if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)
142 xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
143 }
144 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
145 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { 131 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) {
146 xhci->quirks |= XHCI_SPURIOUS_REBOOT; 132 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
147 } 133 }
@@ -162,6 +148,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
162 pdev->device == 0x3432) 148 pdev->device == 0x3432)
163 xhci->quirks |= XHCI_BROKEN_STREAMS; 149 xhci->quirks |= XHCI_BROKEN_STREAMS;
164 150
151 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
152 pdev->device == 0x1042)
153 xhci->quirks |= XHCI_BROKEN_STREAMS;
154
165 if (xhci->quirks & XHCI_RESET_ON_RESUME) 155 if (xhci->quirks & XHCI_RESET_ON_RESUME)
166 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, 156 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
167 "QUIRK: Resetting on resume"); 157 "QUIRK: Resetting on resume");
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index acdfb3e68a90..5a9b977fbc19 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -209,7 +209,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
209 } 209 }
210 } 210 }
211 211
212 if (!list_empty(&controller->early_tx_list)) { 212 if (!list_empty(&controller->early_tx_list) &&
213 !hrtimer_is_queued(&controller->early_tx)) {
213 ret = HRTIMER_RESTART; 214 ret = HRTIMER_RESTART;
214 hrtimer_forward_now(&controller->early_tx, 215 hrtimer_forward_now(&controller->early_tx,
215 ktime_set(0, 20 * NSEC_PER_USEC)); 216 ktime_set(0, 20 * NSEC_PER_USEC));
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 154bcf1b5dfa..48bc09e7b83b 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -868,9 +868,15 @@ static int dsps_suspend(struct device *dev)
868 struct dsps_glue *glue = dev_get_drvdata(dev); 868 struct dsps_glue *glue = dev_get_drvdata(dev);
869 const struct dsps_musb_wrapper *wrp = glue->wrp; 869 const struct dsps_musb_wrapper *wrp = glue->wrp;
870 struct musb *musb = platform_get_drvdata(glue->musb); 870 struct musb *musb = platform_get_drvdata(glue->musb);
871 void __iomem *mbase = musb->ctrl_base; 871 void __iomem *mbase;
872 872
873 del_timer_sync(&glue->timer); 873 del_timer_sync(&glue->timer);
874
875 if (!musb)
876 /* This can happen if the musb device is in -EPROBE_DEFER */
877 return 0;
878
879 mbase = musb->ctrl_base;
874 glue->context.control = dsps_readl(mbase, wrp->control); 880 glue->context.control = dsps_readl(mbase, wrp->control);
875 glue->context.epintr = dsps_readl(mbase, wrp->epintr_set); 881 glue->context.epintr = dsps_readl(mbase, wrp->epintr_set);
876 glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set); 882 glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set);
@@ -887,8 +893,12 @@ static int dsps_resume(struct device *dev)
887 struct dsps_glue *glue = dev_get_drvdata(dev); 893 struct dsps_glue *glue = dev_get_drvdata(dev);
888 const struct dsps_musb_wrapper *wrp = glue->wrp; 894 const struct dsps_musb_wrapper *wrp = glue->wrp;
889 struct musb *musb = platform_get_drvdata(glue->musb); 895 struct musb *musb = platform_get_drvdata(glue->musb);
890 void __iomem *mbase = musb->ctrl_base; 896 void __iomem *mbase;
897
898 if (!musb)
899 return 0;
891 900
901 mbase = musb->ctrl_base;
892 dsps_writel(mbase, wrp->control, glue->context.control); 902 dsps_writel(mbase, wrp->control, glue->context.control);
893 dsps_writel(mbase, wrp->epintr_set, glue->context.epintr); 903 dsps_writel(mbase, wrp->epintr_set, glue->context.epintr);
894 dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr); 904 dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr);
@@ -896,7 +906,9 @@ static int dsps_resume(struct device *dev)
896 dsps_writel(mbase, wrp->mode, glue->context.mode); 906 dsps_writel(mbase, wrp->mode, glue->context.mode);
897 dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode); 907 dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
898 dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode); 908 dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
899 setup_timer(&glue->timer, otg_timer, (unsigned long) musb); 909 if (musb->xceiv->state == OTG_STATE_B_IDLE &&
910 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
911 mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
900 912
901 return 0; 913 return 0;
902} 914}
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eca1747ca8c7..cfd009dc4018 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = {
155 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 155 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
156 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ 156 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
157 { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ 157 { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
158 { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */
158 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ 159 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
159 { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */ 160 { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */
160 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ 161 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index dc72b924c399..0dad8ce5a609 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -140,6 +140,7 @@ static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
140 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report. 140 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
141 */ 141 */
142static const struct usb_device_id id_table_combined[] = { 142static const struct usb_device_id id_table_combined[] = {
143 { USB_DEVICE(FTDI_VID, FTDI_BRICK_PID) },
143 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) }, 144 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) },
144 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) }, 145 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) },
145 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) }, 146 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) },
@@ -661,6 +662,8 @@ static const struct usb_device_id id_table_combined[] = {
661 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, 662 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
662 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, 663 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
663 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, 664 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
665 { USB_DEVICE(XSENS_VID, XSENS_AWINDA_DONGLE_PID) },
666 { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) },
664 { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) }, 667 { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
665 { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) }, 668 { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
666 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) }, 669 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 5937b2d242f2..6786b705ccf6 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -30,6 +30,12 @@
30 30
31/*** third-party PIDs (using FTDI_VID) ***/ 31/*** third-party PIDs (using FTDI_VID) ***/
32 32
33/*
34 * Certain versions of the official Windows FTDI driver reprogrammed
35 * counterfeit FTDI devices to PID 0. Support these devices anyway.
36 */
37#define FTDI_BRICK_PID 0x0000
38
33#define FTDI_LUMEL_PD12_PID 0x6002 39#define FTDI_LUMEL_PD12_PID 0x6002
34 40
35/* 41/*
@@ -143,8 +149,12 @@
143 * Xsens Technologies BV products (http://www.xsens.com). 149 * Xsens Technologies BV products (http://www.xsens.com).
144 */ 150 */
145#define XSENS_VID 0x2639 151#define XSENS_VID 0x2639
146#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */ 152#define XSENS_AWINDA_STATION_PID 0x0101
153#define XSENS_AWINDA_DONGLE_PID 0x0102
147#define XSENS_MTW_PID 0x0200 /* Xsens MTw */ 154#define XSENS_MTW_PID 0x0200 /* Xsens MTw */
155#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
156
157/* Xsens devices using FTDI VID */
148#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */ 158#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */
149#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */ 159#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */
150#define XSENS_CONVERTER_2_PID 0xD38A 160#define XSENS_CONVERTER_2_PID 0xD38A
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 078f9ed419c8..02c420af251e 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -335,7 +335,8 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
335 port->interrupt_out_urb->transfer_buffer_length = length; 335 port->interrupt_out_urb->transfer_buffer_length = length;
336 336
337 priv->cur_pos = priv->cur_pos + length; 337 priv->cur_pos = priv->cur_pos + length;
338 result = usb_submit_urb(port->interrupt_out_urb, GFP_NOIO); 338 result = usb_submit_urb(port->interrupt_out_urb,
339 GFP_ATOMIC);
339 dev_dbg(&port->dev, "%s - Send write URB returns: %i\n", __func__, result); 340 dev_dbg(&port->dev, "%s - Send write URB returns: %i\n", __func__, result);
340 todo = priv->filled - priv->cur_pos; 341 todo = priv->filled - priv->cur_pos;
341 342
@@ -350,7 +351,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
350 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || 351 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
351 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { 352 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
352 result = usb_submit_urb(port->interrupt_in_urb, 353 result = usb_submit_urb(port->interrupt_in_urb,
353 GFP_NOIO); 354 GFP_ATOMIC);
354 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result); 355 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
355 } 356 }
356 } 357 }
@@ -414,8 +415,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
414 int result; 415 int result;
415 int dtr = 0; 416 int dtr = 0;
416 int rts = 0; 417 int rts = 0;
417 unsigned char *transfer_buffer;
418 int transfer_buffer_length = 8;
419 418
420 /* FIXME: locking ? */ 419 /* FIXME: locking ? */
421 priv = usb_get_serial_port_data(port); 420 priv = usb_get_serial_port_data(port);
@@ -425,11 +424,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
425 return -EINVAL; 424 return -EINVAL;
426 } 425 }
427 426
428 /* allocate memory for transfer buffer */
429 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
430 if (!transfer_buffer)
431 return -ENOMEM;
432
433 if (set & TIOCM_RTS) 427 if (set & TIOCM_RTS)
434 rts = 1; 428 rts = 1;
435 if (set & TIOCM_DTR) 429 if (set & TIOCM_DTR)
@@ -469,7 +463,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
469 KOBIL_TIMEOUT); 463 KOBIL_TIMEOUT);
470 } 464 }
471 dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result); 465 dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result);
472 kfree(transfer_buffer);
473 return (result < 0) ? result : 0; 466 return (result < 0) ? result : 0;
474} 467}
475 468
@@ -530,8 +523,6 @@ static int kobil_ioctl(struct tty_struct *tty,
530{ 523{
531 struct usb_serial_port *port = tty->driver_data; 524 struct usb_serial_port *port = tty->driver_data;
532 struct kobil_private *priv = usb_get_serial_port_data(port); 525 struct kobil_private *priv = usb_get_serial_port_data(port);
533 unsigned char *transfer_buffer;
534 int transfer_buffer_length = 8;
535 int result; 526 int result;
536 527
537 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || 528 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
@@ -541,10 +532,6 @@ static int kobil_ioctl(struct tty_struct *tty,
541 532
542 switch (cmd) { 533 switch (cmd) {
543 case TCFLSH: 534 case TCFLSH:
544 transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
545 if (!transfer_buffer)
546 return -ENOBUFS;
547
548 result = usb_control_msg(port->serial->dev, 535 result = usb_control_msg(port->serial->dev,
549 usb_sndctrlpipe(port->serial->dev, 0), 536 usb_sndctrlpipe(port->serial->dev, 0),
550 SUSBCRequest_Misc, 537 SUSBCRequest_Misc,
@@ -559,7 +546,6 @@ static int kobil_ioctl(struct tty_struct *tty,
559 dev_dbg(&port->dev, 546 dev_dbg(&port->dev,
560 "%s - Send reset_all_queues (FLUSH) URB returns: %i\n", 547 "%s - Send reset_all_queues (FLUSH) URB returns: %i\n",
561 __func__, result); 548 __func__, result);
562 kfree(transfer_buffer);
563 return (result < 0) ? -EIO: 0; 549 return (result < 0) ? -EIO: 0;
564 default: 550 default:
565 return -ENOIOCTLCMD; 551 return -ENOIOCTLCMD;
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 4856fb7e637e..4b7bfb394a32 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -215,7 +215,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
215 215
216 /* The connected devices do not have a bulk write endpoint, 216 /* The connected devices do not have a bulk write endpoint,
217 * to transmit data to de barcode device the control endpoint is used */ 217 * to transmit data to de barcode device the control endpoint is used */
218 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); 218 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
219 if (!dr) { 219 if (!dr) {
220 count = -ENOMEM; 220 count = -ENOMEM;
221 goto error_no_dr; 221 goto error_no_dr;
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index d1a3f6044c8a..7a4c21b4f676 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -269,6 +269,7 @@ static void option_instat_callback(struct urb *urb);
269#define TELIT_PRODUCT_DE910_DUAL 0x1010 269#define TELIT_PRODUCT_DE910_DUAL 0x1010
270#define TELIT_PRODUCT_UE910_V2 0x1012 270#define TELIT_PRODUCT_UE910_V2 0x1012
271#define TELIT_PRODUCT_LE920 0x1200 271#define TELIT_PRODUCT_LE920 0x1200
272#define TELIT_PRODUCT_LE910 0x1201
272 273
273/* ZTE PRODUCTS */ 274/* ZTE PRODUCTS */
274#define ZTE_VENDOR_ID 0x19d2 275#define ZTE_VENDOR_ID 0x19d2
@@ -362,6 +363,7 @@ static void option_instat_callback(struct urb *urb);
362 363
363/* Haier products */ 364/* Haier products */
364#define HAIER_VENDOR_ID 0x201e 365#define HAIER_VENDOR_ID 0x201e
366#define HAIER_PRODUCT_CE81B 0x10f8
365#define HAIER_PRODUCT_CE100 0x2009 367#define HAIER_PRODUCT_CE100 0x2009
366 368
367/* Cinterion (formerly Siemens) products */ 369/* Cinterion (formerly Siemens) products */
@@ -589,6 +591,11 @@ static const struct option_blacklist_info zte_1255_blacklist = {
589 .reserved = BIT(3) | BIT(4), 591 .reserved = BIT(3) | BIT(4),
590}; 592};
591 593
594static const struct option_blacklist_info telit_le910_blacklist = {
595 .sendsetup = BIT(0),
596 .reserved = BIT(1) | BIT(2),
597};
598
592static const struct option_blacklist_info telit_le920_blacklist = { 599static const struct option_blacklist_info telit_le920_blacklist = {
593 .sendsetup = BIT(0), 600 .sendsetup = BIT(0),
594 .reserved = BIT(1) | BIT(5), 601 .reserved = BIT(1) | BIT(5),
@@ -1138,6 +1145,8 @@ static const struct usb_device_id option_ids[] = {
1138 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, 1145 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
1139 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, 1146 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
1140 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, 1147 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) },
1148 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
1149 .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
1141 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), 1150 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
1142 .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, 1151 .driver_info = (kernel_ulong_t)&telit_le920_blacklist },
1143 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 1152 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -1621,6 +1630,7 @@ static const struct usb_device_id option_ids[] = {
1621 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, 1630 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
1622 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) }, 1631 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
1623 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 1632 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
1633 { USB_DEVICE_AND_INTERFACE_INFO(HAIER_VENDOR_ID, HAIER_PRODUCT_CE81B, 0xff, 0xff, 0xff) },
1624 /* Pirelli */ 1634 /* Pirelli */
1625 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, 1635 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
1626 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) }, 1636 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index 4bc2fc98636e..73f125e0cb58 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -52,7 +52,7 @@ int usb_stor_euscsi_init(struct us_data *us)
52 us->iobuf[0] = 0x1; 52 us->iobuf[0] = 0x1;
53 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 53 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
54 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR, 54 0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,
55 0x01, 0x0, us->iobuf, 0x1, USB_CTRL_SET_TIMEOUT); 55 0x01, 0x0, us->iobuf, 0x1, 5 * HZ);
56 usb_stor_dbg(us, "-- result is %d\n", result); 56 usb_stor_dbg(us, "-- result is %d\n", result);
57 57
58 return 0; 58 return 0;
@@ -100,7 +100,7 @@ int usb_stor_huawei_e220_init(struct us_data *us)
100 result = usb_stor_control_msg(us, us->send_ctrl_pipe, 100 result = usb_stor_control_msg(us, us->send_ctrl_pipe,
101 USB_REQ_SET_FEATURE, 101 USB_REQ_SET_FEATURE,
102 USB_TYPE_STANDARD | USB_RECIP_DEVICE, 102 USB_TYPE_STANDARD | USB_RECIP_DEVICE,
103 0x01, 0x0, NULL, 0x0, 1000); 103 0x01, 0x0, NULL, 0x0, 1 * HZ);
104 usb_stor_dbg(us, "Huawei mode set result is %d\n", result); 104 usb_stor_dbg(us, "Huawei mode set result is %d\n", result);
105 return 0; 105 return 0;
106} 106}
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 8591d89a38e6..27e4a580d2ed 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -626,6 +626,7 @@ static int config_autodelink_after_power_on(struct us_data *us)
626 return 0; 626 return 0;
627} 627}
628 628
629#ifdef CONFIG_PM
629static int config_autodelink_before_power_down(struct us_data *us) 630static int config_autodelink_before_power_down(struct us_data *us)
630{ 631{
631 struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra); 632 struct rts51x_chip *chip = (struct rts51x_chip *)(us->extra);
@@ -716,6 +717,7 @@ static void fw5895_init(struct us_data *us)
716 } 717 }
717 } 718 }
718} 719}
720#endif
719 721
720#ifdef CONFIG_REALTEK_AUTOPM 722#ifdef CONFIG_REALTEK_AUTOPM
721static void fw5895_set_mmc_wp(struct us_data *us) 723static void fw5895_set_mmc_wp(struct us_data *us)
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 22c7d4360fa2..b1d815eb6d0b 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1118,6 +1118,31 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1118 */ 1118 */
1119 if (result == USB_STOR_XFER_LONG) 1119 if (result == USB_STOR_XFER_LONG)
1120 fake_sense = 1; 1120 fake_sense = 1;
1121
1122 /*
1123 * Sometimes a device will mistakenly skip the data phase
1124 * and go directly to the status phase without sending a
1125 * zero-length packet. If we get a 13-byte response here,
1126 * check whether it really is a CSW.
1127 */
1128 if (result == USB_STOR_XFER_SHORT &&
1129 srb->sc_data_direction == DMA_FROM_DEVICE &&
1130 transfer_length - scsi_get_resid(srb) ==
1131 US_BULK_CS_WRAP_LEN) {
1132 struct scatterlist *sg = NULL;
1133 unsigned int offset = 0;
1134
1135 if (usb_stor_access_xfer_buf((unsigned char *) bcs,
1136 US_BULK_CS_WRAP_LEN, srb, &sg,
1137 &offset, FROM_XFER_BUF) ==
1138 US_BULK_CS_WRAP_LEN &&
1139 bcs->Signature ==
1140 cpu_to_le32(US_BULK_CS_SIGN)) {
1141 usb_stor_dbg(us, "Device skipped data phase\n");
1142 scsi_set_resid(srb, transfer_length);
1143 goto skipped_data_phase;
1144 }
1145 }
1121 } 1146 }
1122 1147
1123 /* See flow chart on pg 15 of the Bulk Only Transport spec for 1148 /* See flow chart on pg 15 of the Bulk Only Transport spec for
@@ -1153,6 +1178,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
1153 if (result != USB_STOR_XFER_GOOD) 1178 if (result != USB_STOR_XFER_GOOD)
1154 return USB_STOR_TRANSPORT_ERROR; 1179 return USB_STOR_TRANSPORT_ERROR;
1155 1180
1181 skipped_data_phase:
1156 /* check bulk status */ 1182 /* check bulk status */
1157 residue = le32_to_cpu(bcs->Residue); 1183 residue = le32_to_cpu(bcs->Residue);
1158 usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n", 1184 usb_stor_dbg(us, "Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index 8511b54a65d9..2fefaf923e4a 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -54,6 +54,20 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x9999,
54 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 54 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
55 US_FL_NO_ATA_1X), 55 US_FL_NO_ATA_1X),
56 56
57/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
58UNUSUAL_DEV(0x0bc2, 0x3320, 0x0000, 0x9999,
59 "Seagate",
60 "Expansion Desk",
61 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
62 US_FL_NO_ATA_1X),
63
64/* Reported-by: Bogdan Mihalcea <bogdan.mihalcea@infim.ro> */
65UNUSUAL_DEV(0x0bc2, 0xa003, 0x0000, 0x9999,
66 "Seagate",
67 "Backup Plus",
68 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
69 US_FL_NO_ATA_1X),
70
57/* https://bbs.archlinux.org/viewtopic.php?id=183190 */ 71/* https://bbs.archlinux.org/viewtopic.php?id=183190 */
58UNUSUAL_DEV(0x0bc2, 0xab20, 0x0000, 0x9999, 72UNUSUAL_DEV(0x0bc2, 0xab20, 0x0000, 0x9999,
59 "Seagate", 73 "Seagate",
@@ -61,6 +75,13 @@ UNUSUAL_DEV(0x0bc2, 0xab20, 0x0000, 0x9999,
61 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 75 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
62 US_FL_NO_ATA_1X), 76 US_FL_NO_ATA_1X),
63 77
78/* https://bbs.archlinux.org/viewtopic.php?id=183190 */
79UNUSUAL_DEV(0x0bc2, 0xab21, 0x0000, 0x9999,
80 "Seagate",
81 "Backup+ BK",
82 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
83 US_FL_NO_ATA_1X),
84
64/* Reported-by: Claudio Bizzarri <claudio.bizzarri@gmail.com> */ 85/* Reported-by: Claudio Bizzarri <claudio.bizzarri@gmail.com> */
65UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x9999, 86UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x9999,
66 "JMicron", 87 "JMicron",
@@ -75,3 +96,10 @@ UNUSUAL_DEV(0x174c, 0x5106, 0x0000, 0x9999,
75 "ASM1051", 96 "ASM1051",
76 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 97 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
77 US_FL_IGNORE_UAS), 98 US_FL_IGNORE_UAS),
99
100/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
101UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
102 "VIA",
103 "VL711",
104 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
105 US_FL_NO_ATA_1X),
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 57b1d44acbfe..eb976ee3a02f 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -448,8 +448,10 @@ static int __init fb_console_setup(char *this_opt)
448 return 1; 448 return 1;
449 449
450 while ((options = strsep(&this_opt, ",")) != NULL) { 450 while ((options = strsep(&this_opt, ",")) != NULL) {
451 if (!strncmp(options, "font:", 5)) 451 if (!strncmp(options, "font:", 5)) {
452 strlcpy(fontname, options + 5, sizeof(fontname)); 452 strlcpy(fontname, options + 5, sizeof(fontname));
453 continue;
454 }
453 455
454 if (!strncmp(options, "scrollback:", 11)) { 456 if (!strncmp(options, "scrollback:", 11)) {
455 options += 11; 457 options += 11;
@@ -457,13 +459,9 @@ static int __init fb_console_setup(char *this_opt)
457 fbcon_softback_size = simple_strtoul(options, &options, 0); 459 fbcon_softback_size = simple_strtoul(options, &options, 0);
458 if (*options == 'k' || *options == 'K') { 460 if (*options == 'k' || *options == 'K') {
459 fbcon_softback_size *= 1024; 461 fbcon_softback_size *= 1024;
460 options++;
461 } 462 }
462 if (*options != ',') 463 }
463 return 1; 464 continue;
464 options++;
465 } else
466 return 1;
467 } 465 }
468 466
469 if (!strncmp(options, "map:", 4)) { 467 if (!strncmp(options, "map:", 4)) {
@@ -478,8 +476,7 @@ static int __init fb_console_setup(char *this_opt)
478 476
479 fbcon_map_override(); 477 fbcon_map_override();
480 } 478 }
481 479 continue;
482 return 1;
483 } 480 }
484 481
485 if (!strncmp(options, "vc:", 3)) { 482 if (!strncmp(options, "vc:", 3)) {
@@ -491,7 +488,8 @@ static int __init fb_console_setup(char *this_opt)
491 if (*options++ == '-') 488 if (*options++ == '-')
492 last_fb_vc = simple_strtoul(options, &options, 10) - 1; 489 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
493 fbcon_is_default = 0; 490 fbcon_is_default = 0;
494 } 491 continue;
492 }
495 493
496 if (!strncmp(options, "rotate:", 7)) { 494 if (!strncmp(options, "rotate:", 7)) {
497 options += 7; 495 options += 7;
@@ -499,6 +497,7 @@ static int __init fb_console_setup(char *this_opt)
499 initial_rotation = simple_strtoul(options, &options, 0); 497 initial_rotation = simple_strtoul(options, &options, 0);
500 if (initial_rotation > 3) 498 if (initial_rotation > 3)
501 initial_rotation = 0; 499 initial_rotation = 0;
500 continue;
502 } 501 }
503 } 502 }
504 return 1; 503 return 1;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 6e6aa704fe84..517f565b65d7 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -56,7 +56,7 @@ static int cursor_size_lastfrom;
56static int cursor_size_lastto; 56static int cursor_size_lastto;
57static u32 vgacon_xres; 57static u32 vgacon_xres;
58static u32 vgacon_yres; 58static u32 vgacon_yres;
59static struct vgastate state; 59static struct vgastate vgastate;
60 60
61#define BLANK 0x0020 61#define BLANK 0x0020
62 62
@@ -400,7 +400,7 @@ static const char *vgacon_startup(void)
400 400
401 vga_video_num_lines = screen_info.orig_video_lines; 401 vga_video_num_lines = screen_info.orig_video_lines;
402 vga_video_num_columns = screen_info.orig_video_cols; 402 vga_video_num_columns = screen_info.orig_video_cols;
403 state.vgabase = NULL; 403 vgastate.vgabase = NULL;
404 404
405 if (screen_info.orig_video_mode == 7) { 405 if (screen_info.orig_video_mode == 7) {
406 /* Monochrome display */ 406 /* Monochrome display */
@@ -851,12 +851,12 @@ static void vga_set_palette(struct vc_data *vc, unsigned char *table)
851{ 851{
852 int i, j; 852 int i, j;
853 853
854 vga_w(state.vgabase, VGA_PEL_MSK, 0xff); 854 vga_w(vgastate.vgabase, VGA_PEL_MSK, 0xff);
855 for (i = j = 0; i < 16; i++) { 855 for (i = j = 0; i < 16; i++) {
856 vga_w(state.vgabase, VGA_PEL_IW, table[i]); 856 vga_w(vgastate.vgabase, VGA_PEL_IW, table[i]);
857 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 857 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
858 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 858 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
859 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 859 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
860 } 860 }
861} 861}
862 862
@@ -1008,7 +1008,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1008 switch (blank) { 1008 switch (blank) {
1009 case 0: /* Unblank */ 1009 case 0: /* Unblank */
1010 if (vga_vesa_blanked) { 1010 if (vga_vesa_blanked) {
1011 vga_vesa_unblank(&state); 1011 vga_vesa_unblank(&vgastate);
1012 vga_vesa_blanked = 0; 1012 vga_vesa_blanked = 0;
1013 } 1013 }
1014 if (vga_palette_blanked) { 1014 if (vga_palette_blanked) {
@@ -1022,7 +1022,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1022 case 1: /* Normal blanking */ 1022 case 1: /* Normal blanking */
1023 case -1: /* Obsolete */ 1023 case -1: /* Obsolete */
1024 if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) { 1024 if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) {
1025 vga_pal_blank(&state); 1025 vga_pal_blank(&vgastate);
1026 vga_palette_blanked = 1; 1026 vga_palette_blanked = 1;
1027 return 0; 1027 return 0;
1028 } 1028 }
@@ -1034,7 +1034,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1034 return 1; 1034 return 1;
1035 default: /* VESA blanking */ 1035 default: /* VESA blanking */
1036 if (vga_video_type == VIDEO_TYPE_VGAC) { 1036 if (vga_video_type == VIDEO_TYPE_VGAC) {
1037 vga_vesa_blank(&state, blank - 1); 1037 vga_vesa_blank(&vgastate, blank - 1);
1038 vga_vesa_blanked = blank; 1038 vga_vesa_blanked = blank;
1039 } 1039 }
1040 return 0; 1040 return 0;
@@ -1280,7 +1280,7 @@ static int vgacon_font_set(struct vc_data *c, struct console_font *font, unsigne
1280 (charcount != 256 && charcount != 512)) 1280 (charcount != 256 && charcount != 512))
1281 return -EINVAL; 1281 return -EINVAL;
1282 1282
1283 rc = vgacon_do_font_op(&state, font->data, 1, charcount == 512); 1283 rc = vgacon_do_font_op(&vgastate, font->data, 1, charcount == 512);
1284 if (rc) 1284 if (rc)
1285 return rc; 1285 return rc;
1286 1286
@@ -1299,7 +1299,7 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font)
1299 font->charcount = vga_512_chars ? 512 : 256; 1299 font->charcount = vga_512_chars ? 512 : 256;
1300 if (!font->data) 1300 if (!font->data)
1301 return 0; 1301 return 0;
1302 return vgacon_do_font_op(&state, font->data, 0, vga_512_chars); 1302 return vgacon_do_font_op(&vgastate, font->data, 0, vga_512_chars);
1303} 1303}
1304 1304
1305#else 1305#else
diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
index 3bf403150a2d..9ec81d46fc57 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -27,7 +27,6 @@
27#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
28#include <video/videomode.h> 28#include <video/videomode.h>
29 29
30#include <mach/cpu.h>
31#include <asm/gpio.h> 30#include <asm/gpio.h>
32 31
33#include <video/atmel_lcdc.h> 32#include <video/atmel_lcdc.h>
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c b/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
index 5ee3b5505f7f..91921665b98b 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
@@ -301,6 +301,8 @@ static const struct of_device_id tvc_of_match[] = {
301 {}, 301 {},
302}; 302};
303 303
304MODULE_DEVICE_TABLE(of, tvc_of_match);
305
304static struct platform_driver tvc_connector_driver = { 306static struct platform_driver tvc_connector_driver = {
305 .probe = tvc_probe, 307 .probe = tvc_probe,
306 .remove = __exit_p(tvc_remove), 308 .remove = __exit_p(tvc_remove),
@@ -308,6 +310,7 @@ static struct platform_driver tvc_connector_driver = {
308 .name = "connector-analog-tv", 310 .name = "connector-analog-tv",
309 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
310 .of_match_table = tvc_of_match, 312 .of_match_table = tvc_of_match,
313 .suppress_bind_attrs = true,
311 }, 314 },
312}; 315};
313 316
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
index 74de2bc50c4f..2dfb6e5ff0cc 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
@@ -391,6 +391,7 @@ static struct platform_driver dvi_connector_driver = {
391 .name = "connector-dvi", 391 .name = "connector-dvi",
392 .owner = THIS_MODULE, 392 .owner = THIS_MODULE,
393 .of_match_table = dvic_of_match, 393 .of_match_table = dvic_of_match,
394 .suppress_bind_attrs = true,
394 }, 395 },
395}; 396};
396 397
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c b/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
index 131c6e260898..7b25967a91eb 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
@@ -437,6 +437,7 @@ static struct platform_driver hdmi_connector_driver = {
437 .name = "connector-hdmi", 437 .name = "connector-hdmi",
438 .owner = THIS_MODULE, 438 .owner = THIS_MODULE,
439 .of_match_table = hdmic_of_match, 439 .of_match_table = hdmic_of_match,
440 .suppress_bind_attrs = true,
440 }, 441 },
441}; 442};
442 443
diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c b/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
index b4e9a42a79e6..47ee7cdee1c5 100644
--- a/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
+++ b/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
@@ -298,6 +298,7 @@ static struct platform_driver tfp410_driver = {
298 .name = "tfp410", 298 .name = "tfp410",
299 .owner = THIS_MODULE, 299 .owner = THIS_MODULE,
300 .of_match_table = tfp410_of_match, 300 .of_match_table = tfp410_of_match,
301 .suppress_bind_attrs = true,
301 }, 302 },
302}; 303};
303 304
diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c b/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
index c891d8f84cb2..c4abd56dd846 100644
--- a/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
+++ b/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
@@ -461,6 +461,7 @@ static struct platform_driver tpd_driver = {
461 .name = "tpd12s015", 461 .name = "tpd12s015",
462 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
463 .of_match_table = tpd_of_match, 463 .of_match_table = tpd_of_match,
464 .suppress_bind_attrs = true,
464 }, 465 },
465}; 466};
466 467
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
index 3636b61dc9b4..a9c3dcf0f6b5 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
@@ -327,6 +327,7 @@ static struct platform_driver panel_dpi_driver = {
327 .name = "panel-dpi", 327 .name = "panel-dpi",
328 .owner = THIS_MODULE, 328 .owner = THIS_MODULE,
329 .of_match_table = panel_dpi_of_match, 329 .of_match_table = panel_dpi_of_match,
330 .suppress_bind_attrs = true,
330 }, 331 },
331}; 332};
332 333
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c b/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
index d6f14e8717e8..899cb1ab523d 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
@@ -1378,6 +1378,7 @@ static struct platform_driver dsicm_driver = {
1378 .name = "panel-dsi-cm", 1378 .name = "panel-dsi-cm",
1379 .owner = THIS_MODULE, 1379 .owner = THIS_MODULE,
1380 .of_match_table = dsicm_of_match, 1380 .of_match_table = dsicm_of_match,
1381 .suppress_bind_attrs = true,
1381 }, 1382 },
1382}; 1383};
1383 1384
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
index cc5b5124e0b4..27d4fcfa1824 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
@@ -394,6 +394,7 @@ static struct spi_driver lb035q02_spi_driver = {
394 .name = "panel_lgphilips_lb035q02", 394 .name = "panel_lgphilips_lb035q02",
395 .owner = THIS_MODULE, 395 .owner = THIS_MODULE,
396 .of_match_table = lb035q02_of_match, 396 .of_match_table = lb035q02_of_match,
397 .suppress_bind_attrs = true,
397 }, 398 },
398}; 399};
399 400
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c b/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
index 3595f111aa35..ccf3f4f3c703 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
@@ -424,6 +424,7 @@ static struct spi_driver nec_8048_driver = {
424 .owner = THIS_MODULE, 424 .owner = THIS_MODULE,
425 .pm = NEC_8048_PM_OPS, 425 .pm = NEC_8048_PM_OPS,
426 .of_match_table = nec_8048_of_match, 426 .of_match_table = nec_8048_of_match,
427 .suppress_bind_attrs = true,
427 }, 428 },
428 .probe = nec_8048_probe, 429 .probe = nec_8048_probe,
429 .remove = nec_8048_remove, 430 .remove = nec_8048_remove,
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
index f1f72ce50a17..234142cc3764 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
@@ -410,6 +410,7 @@ static struct platform_driver sharp_ls_driver = {
410 .name = "panel-sharp-ls037v7dw01", 410 .name = "panel-sharp-ls037v7dw01",
411 .owner = THIS_MODULE, 411 .owner = THIS_MODULE,
412 .of_match_table = sharp_ls_of_match, 412 .of_match_table = sharp_ls_of_match,
413 .suppress_bind_attrs = true,
413 }, 414 },
414}; 415};
415 416
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
index 617f8d2f5127..337ccc5c0f5e 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
@@ -904,6 +904,7 @@ static struct spi_driver acx565akm_driver = {
904 .name = "acx565akm", 904 .name = "acx565akm",
905 .owner = THIS_MODULE, 905 .owner = THIS_MODULE,
906 .of_match_table = acx565akm_of_match, 906 .of_match_table = acx565akm_of_match,
907 .suppress_bind_attrs = true,
907 }, 908 },
908 .probe = acx565akm_probe, 909 .probe = acx565akm_probe,
909 .remove = acx565akm_remove, 910 .remove = acx565akm_remove,
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
index 728808bcceeb..fbba0b8ca871 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
@@ -500,6 +500,7 @@ static struct spi_driver td028ttec1_spi_driver = {
500 .name = "panel-tpo-td028ttec1", 500 .name = "panel-tpo-td028ttec1",
501 .owner = THIS_MODULE, 501 .owner = THIS_MODULE,
502 .of_match_table = td028ttec1_of_match, 502 .of_match_table = td028ttec1_of_match,
503 .suppress_bind_attrs = true,
503 }, 504 },
504}; 505};
505 506
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
index de78ab0caaa8..5aba76bca25a 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
@@ -673,6 +673,7 @@ static struct spi_driver tpo_td043_spi_driver = {
673 .owner = THIS_MODULE, 673 .owner = THIS_MODULE,
674 .pm = &tpo_td043_spi_pm, 674 .pm = &tpo_td043_spi_pm,
675 .of_match_table = tpo_td043_of_match, 675 .of_match_table = tpo_td043_of_match,
676 .suppress_bind_attrs = true,
676 }, 677 },
677 .probe = tpo_td043_probe, 678 .probe = tpo_td043_probe,
678 .remove = tpo_td043_remove, 679 .remove = tpo_td043_remove,
diff --git a/drivers/video/fbdev/omap2/dss/apply.c b/drivers/video/fbdev/omap2/dss/apply.c
index 0a0b084ce65d..663ccc3bf4e5 100644
--- a/drivers/video/fbdev/omap2/dss/apply.c
+++ b/drivers/video/fbdev/omap2/dss/apply.c
@@ -1132,6 +1132,8 @@ static void dss_mgr_disable_compat(struct omap_overlay_manager *mgr)
1132 if (!mp->enabled) 1132 if (!mp->enabled)
1133 goto out; 1133 goto out;
1134 1134
1135 wait_pending_extra_info_updates();
1136
1135 if (!mgr_manual_update(mgr)) 1137 if (!mgr_manual_update(mgr))
1136 dispc_mgr_disable_sync(mgr->id); 1138 dispc_mgr_disable_sync(mgr->id);
1137 1139
diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index be053aa80880..0e9a74bb9fc2 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -3290,8 +3290,11 @@ static void dispc_dump_regs(struct seq_file *s)
3290 DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS); 3290 DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
3291 DUMPREG(i, DISPC_OVL_ROW_INC); 3291 DUMPREG(i, DISPC_OVL_ROW_INC);
3292 DUMPREG(i, DISPC_OVL_PIXEL_INC); 3292 DUMPREG(i, DISPC_OVL_PIXEL_INC);
3293
3293 if (dss_has_feature(FEAT_PRELOAD)) 3294 if (dss_has_feature(FEAT_PRELOAD))
3294 DUMPREG(i, DISPC_OVL_PRELOAD); 3295 DUMPREG(i, DISPC_OVL_PRELOAD);
3296 if (dss_has_feature(FEAT_MFLAG))
3297 DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
3295 3298
3296 if (i == OMAP_DSS_GFX) { 3299 if (i == OMAP_DSS_GFX) {
3297 DUMPREG(i, DISPC_OVL_WINDOW_SKIP); 3300 DUMPREG(i, DISPC_OVL_WINDOW_SKIP);
@@ -3312,10 +3315,6 @@ static void dispc_dump_regs(struct seq_file *s)
3312 } 3315 }
3313 if (dss_has_feature(FEAT_ATTR2)) 3316 if (dss_has_feature(FEAT_ATTR2))
3314 DUMPREG(i, DISPC_OVL_ATTRIBUTES2); 3317 DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
3315 if (dss_has_feature(FEAT_PRELOAD))
3316 DUMPREG(i, DISPC_OVL_PRELOAD);
3317 if (dss_has_feature(FEAT_MFLAG))
3318 DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
3319 } 3318 }
3320 3319
3321#undef DISPC_REG 3320#undef DISPC_REG
@@ -3843,6 +3842,7 @@ static struct platform_driver omap_dispchw_driver = {
3843 .owner = THIS_MODULE, 3842 .owner = THIS_MODULE,
3844 .pm = &dispc_pm_ops, 3843 .pm = &dispc_pm_ops,
3845 .of_match_table = dispc_of_match, 3844 .of_match_table = dispc_of_match,
3845 .suppress_bind_attrs = true,
3846 }, 3846 },
3847}; 3847};
3848 3848
diff --git a/drivers/video/fbdev/omap2/dss/dispc.h b/drivers/video/fbdev/omap2/dss/dispc.h
index 78edb449c763..3043d6e0a5f9 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.h
+++ b/drivers/video/fbdev/omap2/dss/dispc.h
@@ -101,8 +101,7 @@
101 DISPC_FIR_COEF_V2_OFFSET(n, i)) 101 DISPC_FIR_COEF_V2_OFFSET(n, i))
102#define DISPC_OVL_PRELOAD(n) (DISPC_OVL_BASE(n) + \ 102#define DISPC_OVL_PRELOAD(n) (DISPC_OVL_BASE(n) + \
103 DISPC_PRELOAD_OFFSET(n)) 103 DISPC_PRELOAD_OFFSET(n))
104#define DISPC_OVL_MFLAG_THRESHOLD(n) (DISPC_OVL_BASE(n) + \ 104#define DISPC_OVL_MFLAG_THRESHOLD(n) DISPC_MFLAG_THRESHOLD_OFFSET(n)
105 DISPC_MFLAG_THRESHOLD_OFFSET(n))
106 105
107/* DISPC up/downsampling FIR filter coefficient structure */ 106/* DISPC up/downsampling FIR filter coefficient structure */
108struct dispc_coef { 107struct dispc_coef {
diff --git a/drivers/video/fbdev/omap2/dss/dpi.c b/drivers/video/fbdev/omap2/dss/dpi.c
index 9368972d6962..4a3363dae74a 100644
--- a/drivers/video/fbdev/omap2/dss/dpi.c
+++ b/drivers/video/fbdev/omap2/dss/dpi.c
@@ -720,6 +720,7 @@ static struct platform_driver omap_dpi_driver = {
720 .driver = { 720 .driver = {
721 .name = "omapdss_dpi", 721 .name = "omapdss_dpi",
722 .owner = THIS_MODULE, 722 .owner = THIS_MODULE,
723 .suppress_bind_attrs = true,
723 }, 724 },
724}; 725};
725 726
diff --git a/drivers/video/fbdev/omap2/dss/dsi.c b/drivers/video/fbdev/omap2/dss/dsi.c
index b6f6ae1d4664..0793bc67a275 100644
--- a/drivers/video/fbdev/omap2/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/dss/dsi.c
@@ -1603,7 +1603,7 @@ int dsi_pll_set_clock_div(struct platform_device *dsidev,
1603 } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) { 1603 } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) {
1604 f = cinfo->clkin4ddr < 1000000000 ? 0x2 : 0x4; 1604 f = cinfo->clkin4ddr < 1000000000 ? 0x2 : 0x4;
1605 1605
1606 l = FLD_MOD(l, f, 4, 1); /* PLL_SELFREQDCO */ 1606 l = FLD_MOD(l, f, 3, 1); /* PLL_SELFREQDCO */
1607 } 1607 }
1608 1608
1609 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */ 1609 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */
@@ -5754,6 +5754,7 @@ static struct platform_driver omap_dsihw_driver = {
5754 .owner = THIS_MODULE, 5754 .owner = THIS_MODULE,
5755 .pm = &dsi_pm_ops, 5755 .pm = &dsi_pm_ops,
5756 .of_match_table = dsi_of_match, 5756 .of_match_table = dsi_of_match,
5757 .suppress_bind_attrs = true,
5757 }, 5758 },
5758}; 5759};
5759 5760
diff --git a/drivers/video/fbdev/omap2/dss/dss.c b/drivers/video/fbdev/omap2/dss/dss.c
index 6daeb7ed44c6..14bcd6c43f72 100644
--- a/drivers/video/fbdev/omap2/dss/dss.c
+++ b/drivers/video/fbdev/omap2/dss/dss.c
@@ -966,6 +966,7 @@ static struct platform_driver omap_dsshw_driver = {
966 .owner = THIS_MODULE, 966 .owner = THIS_MODULE,
967 .pm = &dss_pm_ops, 967 .pm = &dss_pm_ops,
968 .of_match_table = dss_of_match, 968 .of_match_table = dss_of_match,
969 .suppress_bind_attrs = true,
969 }, 970 },
970}; 971};
971 972
diff --git a/drivers/video/fbdev/omap2/dss/hdmi4.c b/drivers/video/fbdev/omap2/dss/hdmi4.c
index 6a8550cf43e5..9a8713ca090c 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi4.c
@@ -781,6 +781,7 @@ static struct platform_driver omapdss_hdmihw_driver = {
781 .owner = THIS_MODULE, 781 .owner = THIS_MODULE,
782 .pm = &hdmi_pm_ops, 782 .pm = &hdmi_pm_ops,
783 .of_match_table = hdmi_of_match, 783 .of_match_table = hdmi_of_match,
784 .suppress_bind_attrs = true,
784 }, 785 },
785}; 786};
786 787
diff --git a/drivers/video/fbdev/omap2/dss/hdmi5.c b/drivers/video/fbdev/omap2/dss/hdmi5.c
index 32d02ec34d23..169b764bb9d4 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi5.c
@@ -806,6 +806,7 @@ static struct platform_driver omapdss_hdmihw_driver = {
806 .owner = THIS_MODULE, 806 .owner = THIS_MODULE,
807 .pm = &hdmi_pm_ops, 807 .pm = &hdmi_pm_ops,
808 .of_match_table = hdmi_of_match, 808 .of_match_table = hdmi_of_match,
809 .suppress_bind_attrs = true,
809 }, 810 },
810}; 811};
811 812
diff --git a/drivers/video/fbdev/omap2/dss/hdmi_pll.c b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
index 54df12a8d744..6d92bb32fe51 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi_pll.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
@@ -124,16 +124,15 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll)
124 r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */ 124 r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */
125 r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */ 125 r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */
126 126
127 if (fmt->dcofreq) { 127 if (fmt->dcofreq)
128 /* divider programming for frequency beyond 1000Mhz */
129 REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
130 r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */ 128 r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */
131 } else { 129 else
132 r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */ 130 r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */
133 }
134 131
135 hdmi_write_reg(pll->base, PLLCTRL_CFG2, r); 132 hdmi_write_reg(pll->base, PLLCTRL_CFG2, r);
136 133
134 REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
135
137 r = hdmi_read_reg(pll->base, PLLCTRL_CFG4); 136 r = hdmi_read_reg(pll->base, PLLCTRL_CFG4);
138 r = FLD_MOD(r, fmt->regm2, 24, 18); 137 r = FLD_MOD(r, fmt->regm2, 24, 18);
139 r = FLD_MOD(r, fmt->regmf, 17, 0); 138 r = FLD_MOD(r, fmt->regmf, 17, 0);
@@ -144,8 +143,8 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll)
144 143
145 /* wait for bit change */ 144 /* wait for bit change */
146 if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO, 145 if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO,
147 0, 0, 1) != 1) { 146 0, 0, 0) != 0) {
148 DSSERR("PLL GO bit not set\n"); 147 DSSERR("PLL GO bit not clearing\n");
149 return -ETIMEDOUT; 148 return -ETIMEDOUT;
150 } 149 }
151 150
diff --git a/drivers/video/fbdev/omap2/dss/rfbi.c b/drivers/video/fbdev/omap2/dss/rfbi.c
index c8a81a2b879c..878273f58839 100644
--- a/drivers/video/fbdev/omap2/dss/rfbi.c
+++ b/drivers/video/fbdev/omap2/dss/rfbi.c
@@ -1044,6 +1044,7 @@ static struct platform_driver omap_rfbihw_driver = {
1044 .name = "omapdss_rfbi", 1044 .name = "omapdss_rfbi",
1045 .owner = THIS_MODULE, 1045 .owner = THIS_MODULE,
1046 .pm = &rfbi_pm_ops, 1046 .pm = &rfbi_pm_ops,
1047 .suppress_bind_attrs = true,
1047 }, 1048 },
1048}; 1049};
1049 1050
diff --git a/drivers/video/fbdev/omap2/dss/sdi.c b/drivers/video/fbdev/omap2/dss/sdi.c
index 911dcc9173a6..4c9c46d4ea60 100644
--- a/drivers/video/fbdev/omap2/dss/sdi.c
+++ b/drivers/video/fbdev/omap2/dss/sdi.c
@@ -377,6 +377,7 @@ static struct platform_driver omap_sdi_driver = {
377 .driver = { 377 .driver = {
378 .name = "omapdss_sdi", 378 .name = "omapdss_sdi",
379 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .suppress_bind_attrs = true,
380 }, 381 },
381}; 382};
382 383
diff --git a/drivers/video/fbdev/omap2/dss/venc.c b/drivers/video/fbdev/omap2/dss/venc.c
index 21d81113962b..d077d8a75ddc 100644
--- a/drivers/video/fbdev/omap2/dss/venc.c
+++ b/drivers/video/fbdev/omap2/dss/venc.c
@@ -966,6 +966,7 @@ static struct platform_driver omap_venchw_driver = {
966 .owner = THIS_MODULE, 966 .owner = THIS_MODULE,
967 .pm = &venc_pm_ops, 967 .pm = &venc_pm_ops,
968 .of_match_table = venc_of_match, 968 .of_match_table = venc_of_match,
969 .suppress_bind_attrs = true,
969 }, 970 },
970}; 971};
971 972
diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
index 15872433e0c6..ce8a70570756 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
@@ -1833,14 +1833,13 @@ static void omapfb_free_resources(struct omapfb2_device *fbdev)
1833 if (fbdev == NULL) 1833 if (fbdev == NULL)
1834 return; 1834 return;
1835 1835
1836 for (i = 0; i < fbdev->num_fbs; i++) { 1836 for (i = 0; i < fbdev->num_overlays; i++) {
1837 struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]); 1837 struct omap_overlay *ovl = fbdev->overlays[i];
1838 int j;
1839 1838
1840 for (j = 0; j < ofbi->num_overlays; j++) { 1839 ovl->disable(ovl);
1841 struct omap_overlay *ovl = ofbi->overlays[j]; 1840
1842 ovl->disable(ovl); 1841 if (ovl->manager)
1843 } 1842 ovl->unset_manager(ovl);
1844 } 1843 }
1845 1844
1846 for (i = 0; i < fbdev->num_fbs; i++) 1845 for (i = 0; i < fbdev->num_fbs; i++)
@@ -2619,7 +2618,7 @@ err0:
2619 return r; 2618 return r;
2620} 2619}
2621 2620
2622static int __exit omapfb_remove(struct platform_device *pdev) 2621static int omapfb_remove(struct platform_device *pdev)
2623{ 2622{
2624 struct omapfb2_device *fbdev = platform_get_drvdata(pdev); 2623 struct omapfb2_device *fbdev = platform_get_drvdata(pdev);
2625 2624
@@ -2636,7 +2635,7 @@ static int __exit omapfb_remove(struct platform_device *pdev)
2636 2635
2637static struct platform_driver omapfb_driver = { 2636static struct platform_driver omapfb_driver = {
2638 .probe = omapfb_probe, 2637 .probe = omapfb_probe,
2639 .remove = __exit_p(omapfb_remove), 2638 .remove = omapfb_remove,
2640 .driver = { 2639 .driver = {
2641 .name = "omapfb", 2640 .name = "omapfb",
2642 .owner = THIS_MODULE, 2641 .owner = THIS_MODULE,
@@ -2651,6 +2650,7 @@ module_param_named(mirror, def_mirror, bool, 0);
2651 2650
2652module_platform_driver(omapfb_driver); 2651module_platform_driver(omapfb_driver);
2653 2652
2653MODULE_ALIAS("platform:omapfb");
2654MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>"); 2654MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
2655MODULE_DESCRIPTION("OMAP2/3 Framebuffer"); 2655MODULE_DESCRIPTION("OMAP2/3 Framebuffer");
2656MODULE_LICENSE("GPL v2"); 2656MODULE_LICENSE("GPL v2");
diff --git a/fs/block_dev.c b/fs/block_dev.c
index cc9d4114cda0..1d9c9f3754f8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1585,7 +1585,7 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
1585} 1585}
1586EXPORT_SYMBOL_GPL(blkdev_write_iter); 1586EXPORT_SYMBOL_GPL(blkdev_write_iter);
1587 1587
1588static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) 1588ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1589{ 1589{
1590 struct file *file = iocb->ki_filp; 1590 struct file *file = iocb->ki_filp;
1591 struct inode *bd_inode = file->f_mapping->host; 1591 struct inode *bd_inode = file->f_mapping->host;
@@ -1599,6 +1599,7 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1599 iov_iter_truncate(to, size); 1599 iov_iter_truncate(to, size);
1600 return generic_file_read_iter(iocb, to); 1600 return generic_file_read_iter(iocb, to);
1601} 1601}
1602EXPORT_SYMBOL_GPL(blkdev_read_iter);
1602 1603
1603/* 1604/*
1604 * Try to release a page associated with block device when the system 1605 * Try to release a page associated with block device when the system
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d557264ee974..fe69edda11fb 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3276,7 +3276,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
3276 struct btrfs_root *root, unsigned long count); 3276 struct btrfs_root *root, unsigned long count);
3277int btrfs_async_run_delayed_refs(struct btrfs_root *root, 3277int btrfs_async_run_delayed_refs(struct btrfs_root *root,
3278 unsigned long count, int wait); 3278 unsigned long count, int wait);
3279int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 3279int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len);
3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, 3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
3281 struct btrfs_root *root, u64 bytenr, 3281 struct btrfs_root *root, u64 bytenr,
3282 u64 offset, int metadata, u64 *refs, u64 *flags); 3282 u64 offset, int metadata, u64 *refs, u64 *flags);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1ad0f47ac850..1bf9f897065d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3817,19 +3817,19 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3817 struct btrfs_super_block *sb = fs_info->super_copy; 3817 struct btrfs_super_block *sb = fs_info->super_copy;
3818 int ret = 0; 3818 int ret = 0;
3819 3819
3820 if (sb->root_level > BTRFS_MAX_LEVEL) { 3820 if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {
3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d > %d\n", 3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d >= %d\n",
3822 sb->root_level, BTRFS_MAX_LEVEL); 3822 btrfs_super_root_level(sb), BTRFS_MAX_LEVEL);
3823 ret = -EINVAL; 3823 ret = -EINVAL;
3824 } 3824 }
3825 if (sb->chunk_root_level > BTRFS_MAX_LEVEL) { 3825 if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {
3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d > %d\n", 3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d >= %d\n",
3827 sb->chunk_root_level, BTRFS_MAX_LEVEL); 3827 btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);
3828 ret = -EINVAL; 3828 ret = -EINVAL;
3829 } 3829 }
3830 if (sb->log_root_level > BTRFS_MAX_LEVEL) { 3830 if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {
3831 printk(KERN_ERR "BTRFS: log_root level too big: %d > %d\n", 3831 printk(KERN_ERR "BTRFS: log_root level too big: %d >= %d\n",
3832 sb->log_root_level, BTRFS_MAX_LEVEL); 3832 btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);
3833 ret = -EINVAL; 3833 ret = -EINVAL;
3834 } 3834 }
3835 3835
@@ -3837,15 +3837,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize 3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize
3838 * items yet, they'll be verified later. Issue just a warning. 3838 * items yet, they'll be verified later. Issue just a warning.
3839 */ 3839 */
3840 if (!IS_ALIGNED(sb->root, 4096)) 3840 if (!IS_ALIGNED(btrfs_super_root(sb), 4096))
3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3842 sb->root); 3842 sb->root);
3843 if (!IS_ALIGNED(sb->chunk_root, 4096)) 3843 if (!IS_ALIGNED(btrfs_super_chunk_root(sb), 4096))
3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3845 sb->chunk_root); 3845 sb->chunk_root);
3846 if (!IS_ALIGNED(sb->log_root, 4096)) 3846 if (!IS_ALIGNED(btrfs_super_log_root(sb), 4096))
3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3848 sb->log_root); 3848 btrfs_super_log_root(sb));
3849 3849
3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { 3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) {
3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n", 3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n",
@@ -3857,13 +3857,13 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are 3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are
3858 * done later 3858 * done later
3859 */ 3859 */
3860 if (sb->num_devices > (1UL << 31)) 3860 if (btrfs_super_num_devices(sb) > (1UL << 31))
3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", 3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n",
3862 sb->num_devices); 3862 btrfs_super_num_devices(sb));
3863 3863
3864 if (sb->bytenr != BTRFS_SUPER_INFO_OFFSET) { 3864 if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) {
3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n", 3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n",
3866 sb->bytenr, BTRFS_SUPER_INFO_OFFSET); 3866 btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET);
3867 ret = -EINVAL; 3867 ret = -EINVAL;
3868 } 3868 }
3869 3869
@@ -3871,14 +3871,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3871 * The generation is a global counter, we'll trust it more than the others 3871 * The generation is a global counter, we'll trust it more than the others
3872 * but it's still possible that it's the one that's wrong. 3872 * but it's still possible that it's the one that's wrong.
3873 */ 3873 */
3874 if (sb->generation < sb->chunk_root_generation) 3874 if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb))
3875 printk(KERN_WARNING 3875 printk(KERN_WARNING
3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n", 3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n",
3877 sb->generation, sb->chunk_root_generation); 3877 btrfs_super_generation(sb), btrfs_super_chunk_root_generation(sb));
3878 if (sb->generation < sb->cache_generation && sb->cache_generation != (u64)-1) 3878 if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb)
3879 && btrfs_super_cache_generation(sb) != (u64)-1)
3879 printk(KERN_WARNING 3880 printk(KERN_WARNING
3880 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n", 3881 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n",
3881 sb->generation, sb->cache_generation); 3882 btrfs_super_generation(sb), btrfs_super_cache_generation(sb));
3882 3883
3883 return ret; 3884 return ret;
3884} 3885}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d56589571012..47c1ba141082 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -710,8 +710,8 @@ void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
710 rcu_read_unlock(); 710 rcu_read_unlock();
711} 711}
712 712
713/* simple helper to search for an existing extent at a given offset */ 713/* simple helper to search for an existing data extent at a given offset */
714int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len) 714int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len)
715{ 715{
716 int ret; 716 int ret;
717 struct btrfs_key key; 717 struct btrfs_key key;
@@ -726,12 +726,6 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
726 key.type = BTRFS_EXTENT_ITEM_KEY; 726 key.type = BTRFS_EXTENT_ITEM_KEY;
727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path, 727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path,
728 0, 0); 728 0, 0);
729 if (ret > 0) {
730 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
731 if (key.objectid == start &&
732 key.type == BTRFS_METADATA_ITEM_KEY)
733 ret = 0;
734 }
735 btrfs_free_path(path); 729 btrfs_free_path(path);
736 return ret; 730 return ret;
737} 731}
@@ -786,7 +780,6 @@ search_again:
786 else 780 else
787 key.type = BTRFS_EXTENT_ITEM_KEY; 781 key.type = BTRFS_EXTENT_ITEM_KEY;
788 782
789again:
790 ret = btrfs_search_slot(trans, root->fs_info->extent_root, 783 ret = btrfs_search_slot(trans, root->fs_info->extent_root,
791 &key, path, 0, 0); 784 &key, path, 0, 0);
792 if (ret < 0) 785 if (ret < 0)
@@ -802,13 +795,6 @@ again:
802 key.offset == root->nodesize) 795 key.offset == root->nodesize)
803 ret = 0; 796 ret = 0;
804 } 797 }
805 if (ret) {
806 key.objectid = bytenr;
807 key.type = BTRFS_EXTENT_ITEM_KEY;
808 key.offset = root->nodesize;
809 btrfs_release_path(path);
810 goto again;
811 }
812 } 798 }
813 799
814 if (ret == 0) { 800 if (ret == 0) {
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 783a94355efd..84a2d1868271 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -413,7 +413,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
413 ret = 0; 413 ret = 0;
414fail: 414fail:
415 while (ret < 0 && !list_empty(&tmplist)) { 415 while (ret < 0 && !list_empty(&tmplist)) {
416 sums = list_entry(&tmplist, struct btrfs_ordered_sum, list); 416 sums = list_entry(tmplist.next, struct btrfs_ordered_sum, list);
417 list_del(&sums->list); 417 list_del(&sums->list);
418 kfree(sums); 418 kfree(sums);
419 } 419 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a2b97ef10317..54bd91ece35b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2151,6 +2151,7 @@ static void __exit exit_btrfs_fs(void)
2151 extent_map_exit(); 2151 extent_map_exit();
2152 extent_io_exit(); 2152 extent_io_exit();
2153 btrfs_interface_exit(); 2153 btrfs_interface_exit();
2154 btrfs_end_io_wq_exit();
2154 unregister_filesystem(&btrfs_fs_type); 2155 unregister_filesystem(&btrfs_fs_type);
2155 btrfs_exit_sysfs(); 2156 btrfs_exit_sysfs();
2156 btrfs_cleanup_fs_uuids(); 2157 btrfs_cleanup_fs_uuids();
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979e5718..286213cec861 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -672,7 +672,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
672 * is this extent already allocated in the extent 672 * is this extent already allocated in the extent
673 * allocation tree? If so, just add a reference 673 * allocation tree? If so, just add a reference
674 */ 674 */
675 ret = btrfs_lookup_extent(root, ins.objectid, 675 ret = btrfs_lookup_data_extent(root, ins.objectid,
676 ins.offset); 676 ins.offset);
677 if (ret == 0) { 677 if (ret == 0) {
678 ret = btrfs_inc_extent_ref(trans, root, 678 ret = btrfs_inc_extent_ref(trans, root,
diff --git a/fs/buffer.c b/fs/buffer.c
index 6c48f20eddd4..20805db2c987 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -128,21 +128,15 @@ __clear_page_buffers(struct page *page)
128 page_cache_release(page); 128 page_cache_release(page);
129} 129}
130 130
131 131static void buffer_io_error(struct buffer_head *bh, char *msg)
132static int quiet_error(struct buffer_head *bh)
133{
134 if (!test_bit(BH_Quiet, &bh->b_state) && printk_ratelimit())
135 return 0;
136 return 1;
137}
138
139
140static void buffer_io_error(struct buffer_head *bh)
141{ 132{
142 char b[BDEVNAME_SIZE]; 133 char b[BDEVNAME_SIZE];
143 printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n", 134
135 if (!test_bit(BH_Quiet, &bh->b_state))
136 printk_ratelimited(KERN_ERR
137 "Buffer I/O error on dev %s, logical block %llu%s\n",
144 bdevname(bh->b_bdev, b), 138 bdevname(bh->b_bdev, b),
145 (unsigned long long)bh->b_blocknr); 139 (unsigned long long)bh->b_blocknr, msg);
146} 140}
147 141
148/* 142/*
@@ -177,17 +171,10 @@ EXPORT_SYMBOL(end_buffer_read_sync);
177 171
178void end_buffer_write_sync(struct buffer_head *bh, int uptodate) 172void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
179{ 173{
180 char b[BDEVNAME_SIZE];
181
182 if (uptodate) { 174 if (uptodate) {
183 set_buffer_uptodate(bh); 175 set_buffer_uptodate(bh);
184 } else { 176 } else {
185 if (!quiet_error(bh)) { 177 buffer_io_error(bh, ", lost sync page write");
186 buffer_io_error(bh);
187 printk(KERN_WARNING "lost page write due to "
188 "I/O error on %s\n",
189 bdevname(bh->b_bdev, b));
190 }
191 set_buffer_write_io_error(bh); 178 set_buffer_write_io_error(bh);
192 clear_buffer_uptodate(bh); 179 clear_buffer_uptodate(bh);
193 } 180 }
@@ -304,8 +291,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
304 set_buffer_uptodate(bh); 291 set_buffer_uptodate(bh);
305 } else { 292 } else {
306 clear_buffer_uptodate(bh); 293 clear_buffer_uptodate(bh);
307 if (!quiet_error(bh)) 294 buffer_io_error(bh, ", async page read");
308 buffer_io_error(bh);
309 SetPageError(page); 295 SetPageError(page);
310 } 296 }
311 297
@@ -353,7 +339,6 @@ still_busy:
353 */ 339 */
354void end_buffer_async_write(struct buffer_head *bh, int uptodate) 340void end_buffer_async_write(struct buffer_head *bh, int uptodate)
355{ 341{
356 char b[BDEVNAME_SIZE];
357 unsigned long flags; 342 unsigned long flags;
358 struct buffer_head *first; 343 struct buffer_head *first;
359 struct buffer_head *tmp; 344 struct buffer_head *tmp;
@@ -365,12 +350,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
365 if (uptodate) { 350 if (uptodate) {
366 set_buffer_uptodate(bh); 351 set_buffer_uptodate(bh);
367 } else { 352 } else {
368 if (!quiet_error(bh)) { 353 buffer_io_error(bh, ", lost async page write");
369 buffer_io_error(bh);
370 printk(KERN_WARNING "lost page write due to "
371 "I/O error on %s\n",
372 bdevname(bh->b_bdev, b));
373 }
374 set_bit(AS_EIO, &page->mapping->flags); 354 set_bit(AS_EIO, &page->mapping->flags);
375 set_buffer_write_io_error(bh); 355 set_buffer_write_io_error(bh);
376 clear_buffer_uptodate(bh); 356 clear_buffer_uptodate(bh);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7015db0bafd1..eb742d0e67ff 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1354,13 +1354,6 @@ set_qf_format:
1354 "not specified."); 1354 "not specified.");
1355 return 0; 1355 return 0;
1356 } 1356 }
1357 } else {
1358 if (sbi->s_jquota_fmt) {
1359 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1360 "specified with no journaling "
1361 "enabled.");
1362 return 0;
1363 }
1364 } 1357 }
1365#endif 1358#endif
1366 return 1; 1359 return 1;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 37043d0b2be8..0b16fb4c06d3 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3603,11 +3603,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
3603 } 3603 }
3604 } 3604 }
3605 3605
3606 allocated = ext4_split_extent(handle, inode, ppath, 3606 err = ext4_split_extent(handle, inode, ppath, &split_map, split_flag,
3607 &split_map, split_flag, flags); 3607 flags);
3608 if (allocated < 0) 3608 if (err > 0)
3609 err = allocated; 3609 err = 0;
3610
3611out: 3610out:
3612 /* If we have gotten a failure, don't zero out status tree */ 3611 /* If we have gotten a failure, don't zero out status tree */
3613 if (!err) 3612 if (!err)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index aca7b24a4432..8131be8c0af3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -137,10 +137,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos); 137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
138 } 138 }
139 139
140 iocb->private = &overwrite;
140 if (o_direct) { 141 if (o_direct) {
141 blk_start_plug(&plug); 142 blk_start_plug(&plug);
142 143
143 iocb->private = &overwrite;
144 144
145 /* check whether we do a DIO overwrite or not */ 145 /* check whether we do a DIO overwrite or not */
146 if (ext4_should_dioread_nolock(inode) && !aio_mutex && 146 if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 8012a5daf401..ac644c31ca67 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -887,6 +887,10 @@ got:
887 struct buffer_head *block_bitmap_bh; 887 struct buffer_head *block_bitmap_bh;
888 888
889 block_bitmap_bh = ext4_read_block_bitmap(sb, group); 889 block_bitmap_bh = ext4_read_block_bitmap(sb, group);
890 if (!block_bitmap_bh) {
891 err = -EIO;
892 goto out;
893 }
890 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access"); 894 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
891 err = ext4_journal_get_write_access(handle, block_bitmap_bh); 895 err = ext4_journal_get_write_access(handle, block_bitmap_bh);
892 if (err) { 896 if (err) {
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e9777f93cf05..3356ab5395f4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4959,7 +4959,12 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
4959 if (val) 4959 if (val)
4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4961 else { 4961 else {
4962 jbd2_journal_flush(journal); 4962 err = jbd2_journal_flush(journal);
4963 if (err < 0) {
4964 jbd2_journal_unlock_updates(journal);
4965 ext4_inode_resume_unlocked_dio(inode);
4966 return err;
4967 }
4963 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4968 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4964 } 4969 }
4965 ext4_set_aops(inode); 4970 ext4_set_aops(inode);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 123798c5ac31..426211882f72 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1816,31 +1816,39 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; 1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; 1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
1818 ext4fs_dirhash(name, namelen, &hinfo); 1818 ext4fs_dirhash(name, namelen, &hinfo);
1819 memset(frames, 0, sizeof(frames));
1819 frame = frames; 1820 frame = frames;
1820 frame->entries = entries; 1821 frame->entries = entries;
1821 frame->at = entries; 1822 frame->at = entries;
1822 frame->bh = bh; 1823 frame->bh = bh;
1823 bh = bh2; 1824 bh = bh2;
1824 1825
1825 ext4_handle_dirty_dx_node(handle, dir, frame->bh); 1826 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
1826 ext4_handle_dirty_dirent_node(handle, dir, bh); 1827 if (retval)
1828 goto out_frames;
1829 retval = ext4_handle_dirty_dirent_node(handle, dir, bh);
1830 if (retval)
1831 goto out_frames;
1827 1832
1828 de = do_split(handle,dir, &bh, frame, &hinfo); 1833 de = do_split(handle,dir, &bh, frame, &hinfo);
1829 if (IS_ERR(de)) { 1834 if (IS_ERR(de)) {
1830 /* 1835 retval = PTR_ERR(de);
1831 * Even if the block split failed, we have to properly write 1836 goto out_frames;
1832 * out all the changes we did so far. Otherwise we can end up
1833 * with corrupted filesystem.
1834 */
1835 ext4_mark_inode_dirty(handle, dir);
1836 dx_release(frames);
1837 return PTR_ERR(de);
1838 } 1837 }
1839 dx_release(frames); 1838 dx_release(frames);
1840 1839
1841 retval = add_dirent_to_buf(handle, dentry, inode, de, bh); 1840 retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1842 brelse(bh); 1841 brelse(bh);
1843 return retval; 1842 return retval;
1843out_frames:
1844 /*
1845 * Even if the block split failed, we have to properly write
1846 * out all the changes we did so far. Otherwise we can end up
1847 * with corrupted filesystem.
1848 */
1849 ext4_mark_inode_dirty(handle, dir);
1850 dx_release(frames);
1851 return retval;
1844} 1852}
1845 1853
1846/* 1854/*
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index f298c60f907d..ca4588388fc3 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1081,7 +1081,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
1081 break; 1081 break;
1082 1082
1083 if (meta_bg == 0) 1083 if (meta_bg == 0)
1084 backup_block = group * bpg + blk_off; 1084 backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
1085 else 1085 else
1086 backup_block = (ext4_group_first_block_no(sb, group) + 1086 backup_block = (ext4_group_first_block_no(sb, group) +
1087 ext4_bg_has_super(sb, group)); 1087 ext4_bg_has_super(sb, group));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1eda6ab0ef9d..2c9e6864abd9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3526,6 +3526,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3526#ifdef CONFIG_EXT4_FS_POSIX_ACL 3526#ifdef CONFIG_EXT4_FS_POSIX_ACL
3527 set_opt(sb, POSIX_ACL); 3527 set_opt(sb, POSIX_ACL);
3528#endif 3528#endif
3529 /* don't forget to enable journal_csum when metadata_csum is enabled. */
3530 if (ext4_has_metadata_csum(sb))
3531 set_opt(sb, JOURNAL_CHECKSUM);
3532
3529 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) 3533 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
3530 set_opt(sb, JOURNAL_DATA); 3534 set_opt(sb, JOURNAL_DATA);
3531 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) 3535 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
@@ -3943,7 +3947,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3943 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) && 3947 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
3944 !(sb->s_flags & MS_RDONLY)) 3948 !(sb->s_flags & MS_RDONLY))
3945 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 3949 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
3946 goto failed_mount3; 3950 goto failed_mount3a;
3947 3951
3948 /* 3952 /*
3949 * The first inode we look at is the journal inode. Don't try 3953 * The first inode we look at is the journal inode. Don't try
@@ -3952,7 +3956,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3952 if (!test_opt(sb, NOLOAD) && 3956 if (!test_opt(sb, NOLOAD) &&
3953 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { 3957 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
3954 if (ext4_load_journal(sb, es, journal_devnum)) 3958 if (ext4_load_journal(sb, es, journal_devnum))
3955 goto failed_mount3; 3959 goto failed_mount3a;
3956 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && 3960 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
3957 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 3961 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
3958 ext4_msg(sb, KERN_ERR, "required journal recovery " 3962 ext4_msg(sb, KERN_ERR, "required journal recovery "
@@ -4240,6 +4244,7 @@ failed_mount_wq:
4240 jbd2_journal_destroy(sbi->s_journal); 4244 jbd2_journal_destroy(sbi->s_journal);
4241 sbi->s_journal = NULL; 4245 sbi->s_journal = NULL;
4242 } 4246 }
4247failed_mount3a:
4243 ext4_es_unregister_shrinker(sbi); 4248 ext4_es_unregister_shrinker(sbi);
4244failed_mount3: 4249failed_mount3:
4245 del_timer_sync(&sbi->s_err_report); 4250 del_timer_sync(&sbi->s_err_report);
@@ -4841,6 +4846,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4841 goto restore_opts; 4846 goto restore_opts;
4842 } 4847 }
4843 4848
4849 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^
4850 test_opt(sb, JOURNAL_CHECKSUM)) {
4851 ext4_msg(sb, KERN_ERR, "changing journal_checksum "
4852 "during remount not supported");
4853 err = -EINVAL;
4854 goto restore_opts;
4855 }
4856
4844 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4857 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
4845 if (test_opt2(sb, EXPLICIT_DELALLOC)) { 4858 if (test_opt2(sb, EXPLICIT_DELALLOC)) {
4846 ext4_msg(sb, KERN_ERR, "can't mount with " 4859 ext4_msg(sb, KERN_ERR, "can't mount with "
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 881b3bd0143f..fe839b915116 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -29,13 +29,9 @@
29#define BEQUIET 29#define BEQUIET
30 30
31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); 31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr);
32static int isofs_hash(const struct dentry *parent, struct qstr *qstr);
33static int isofs_dentry_cmpi(const struct dentry *parent, 32static int isofs_dentry_cmpi(const struct dentry *parent,
34 const struct dentry *dentry, 33 const struct dentry *dentry,
35 unsigned int len, const char *str, const struct qstr *name); 34 unsigned int len, const char *str, const struct qstr *name);
36static int isofs_dentry_cmp(const struct dentry *parent,
37 const struct dentry *dentry,
38 unsigned int len, const char *str, const struct qstr *name);
39 35
40#ifdef CONFIG_JOLIET 36#ifdef CONFIG_JOLIET
41static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr); 37static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr);
@@ -135,10 +131,6 @@ static const struct super_operations isofs_sops = {
135 131
136static const struct dentry_operations isofs_dentry_ops[] = { 132static const struct dentry_operations isofs_dentry_ops[] = {
137 { 133 {
138 .d_hash = isofs_hash,
139 .d_compare = isofs_dentry_cmp,
140 },
141 {
142 .d_hash = isofs_hashi, 134 .d_hash = isofs_hashi,
143 .d_compare = isofs_dentry_cmpi, 135 .d_compare = isofs_dentry_cmpi,
144 }, 136 },
@@ -258,25 +250,12 @@ static int isofs_dentry_cmp_common(
258} 250}
259 251
260static int 252static int
261isofs_hash(const struct dentry *dentry, struct qstr *qstr)
262{
263 return isofs_hash_common(qstr, 0);
264}
265
266static int
267isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 253isofs_hashi(const struct dentry *dentry, struct qstr *qstr)
268{ 254{
269 return isofs_hashi_common(qstr, 0); 255 return isofs_hashi_common(qstr, 0);
270} 256}
271 257
272static int 258static int
273isofs_dentry_cmp(const struct dentry *parent, const struct dentry *dentry,
274 unsigned int len, const char *str, const struct qstr *name)
275{
276 return isofs_dentry_cmp_common(len, str, name, 0, 0);
277}
278
279static int
280isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry, 259isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry,
281 unsigned int len, const char *str, const struct qstr *name) 260 unsigned int len, const char *str, const struct qstr *name)
282{ 261{
@@ -930,7 +909,8 @@ root_found:
930 if (opt.check == 'r') 909 if (opt.check == 'r')
931 table++; 910 table++;
932 911
933 s->s_d_op = &isofs_dentry_ops[table]; 912 if (table)
913 s->s_d_op = &isofs_dentry_ops[table - 1];
934 914
935 /* get the root dentry */ 915 /* get the root dentry */
936 s->s_root = d_make_root(inode); 916 s->s_root = d_make_root(inode);
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 95295640d9c8..7b543e6b6526 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -18,25 +18,10 @@ static int
18isofs_cmp(struct dentry *dentry, const char *compare, int dlen) 18isofs_cmp(struct dentry *dentry, const char *compare, int dlen)
19{ 19{
20 struct qstr qstr; 20 struct qstr qstr;
21
22 if (!compare)
23 return 1;
24
25 /* check special "." and ".." files */
26 if (dlen == 1) {
27 /* "." */
28 if (compare[0] == 0) {
29 if (!dentry->d_name.len)
30 return 0;
31 compare = ".";
32 } else if (compare[0] == 1) {
33 compare = "..";
34 dlen = 2;
35 }
36 }
37
38 qstr.name = compare; 21 qstr.name = compare;
39 qstr.len = dlen; 22 qstr.len = dlen;
23 if (likely(!dentry->d_op))
24 return dentry->d_name.len != dlen || memcmp(dentry->d_name.name, compare, dlen);
40 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr); 25 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr);
41} 26}
42 27
@@ -146,7 +131,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
146 (!(de->flags[-sbi->s_high_sierra] & 1))) && 131 (!(de->flags[-sbi->s_high_sierra] & 1))) &&
147 (sbi->s_showassoc || 132 (sbi->s_showassoc ||
148 (!(de->flags[-sbi->s_high_sierra] & 4)))) { 133 (!(de->flags[-sbi->s_high_sierra] & 4)))) {
149 match = (isofs_cmp(dentry, dpnt, dlen) == 0); 134 if (dpnt && (dlen > 1 || dpnt[0] > 1))
135 match = (isofs_cmp(dentry, dpnt, dlen) == 0);
150 } 136 }
151 if (match) { 137 if (match) {
152 isofs_normalize_block_and_offset(de, 138 isofs_normalize_block_and_offset(de,
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index 8898bbd2b61e..dcead636c33b 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -93,6 +93,7 @@
93#include <linux/bio.h> 93#include <linux/bio.h>
94#endif 94#endif
95#include <linux/log2.h> 95#include <linux/log2.h>
96#include <linux/hash.h>
96 97
97static struct kmem_cache *revoke_record_cache; 98static struct kmem_cache *revoke_record_cache;
98static struct kmem_cache *revoke_table_cache; 99static struct kmem_cache *revoke_table_cache;
@@ -129,15 +130,11 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int);
129 130
130/* Utility functions to maintain the revoke table */ 131/* Utility functions to maintain the revoke table */
131 132
132/* Borrowed from buffer.c: this is a tried and tested block hash function */
133static inline int hash(journal_t *journal, unsigned int block) 133static inline int hash(journal_t *journal, unsigned int block)
134{ 134{
135 struct jbd_revoke_table_s *table = journal->j_revoke; 135 struct jbd_revoke_table_s *table = journal->j_revoke;
136 int hash_shift = table->hash_shift;
137 136
138 return ((block << (hash_shift - 6)) ^ 137 return hash_32(block, table->hash_shift);
139 (block >> 13) ^
140 (block << (hash_shift - 12))) & (table->hash_size - 1);
141} 138}
142 139
143static int insert_revoke_hash(journal_t *journal, unsigned int blocknr, 140static int insert_revoke_hash(journal_t *journal, unsigned int blocknr,
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index d5e95a175c92..c6cbaef2bda1 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -92,6 +92,7 @@
92#include <linux/init.h> 92#include <linux/init.h>
93#include <linux/bio.h> 93#include <linux/bio.h>
94#include <linux/log2.h> 94#include <linux/log2.h>
95#include <linux/hash.h>
95#endif 96#endif
96 97
97static struct kmem_cache *jbd2_revoke_record_cache; 98static struct kmem_cache *jbd2_revoke_record_cache;
@@ -130,16 +131,9 @@ static void flush_descriptor(journal_t *, struct buffer_head *, int, int);
130 131
131/* Utility functions to maintain the revoke table */ 132/* Utility functions to maintain the revoke table */
132 133
133/* Borrowed from buffer.c: this is a tried and tested block hash function */
134static inline int hash(journal_t *journal, unsigned long long block) 134static inline int hash(journal_t *journal, unsigned long long block)
135{ 135{
136 struct jbd2_revoke_table_s *table = journal->j_revoke; 136 return hash_64(block, journal->j_revoke->hash_shift);
137 int hash_shift = table->hash_shift;
138 int hash = (int)block ^ (int)((block >> 31) >> 1);
139
140 return ((hash << (hash_shift - 6)) ^
141 (hash >> 13) ^
142 (hash << (hash_shift - 12))) & (table->hash_size - 1);
143} 137}
144 138
145static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, 139static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
diff --git a/fs/namei.c b/fs/namei.c
index 42df664e95e5..db5fe86319e6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2497,7 +2497,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
2497 } 2497 }
2498 2498
2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2);
2501 return NULL; 2501 return NULL;
2502} 2502}
2503EXPORT_SYMBOL(lock_rename); 2503EXPORT_SYMBOL(lock_rename);
@@ -3154,7 +3154,8 @@ static int do_tmpfile(int dfd, struct filename *pathname,
3154 if (error) 3154 if (error)
3155 goto out2; 3155 goto out2;
3156 audit_inode(pathname, nd->path.dentry, 0); 3156 audit_inode(pathname, nd->path.dentry, 0);
3157 error = may_open(&nd->path, op->acc_mode, op->open_flag); 3157 /* Don't check for other permissions, the inode was just created */
3158 error = may_open(&nd->path, MAY_OPEN, op->open_flag);
3158 if (error) 3159 if (error)
3159 goto out2; 3160 goto out2;
3160 file->f_path.mnt = nd->path.mnt; 3161 file->f_path.mnt = nd->path.mnt;
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index cdeb3cfd6f32..0beb023f25ac 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1272,7 +1272,8 @@ static bool need_wrongsec_check(struct svc_rqst *rqstp)
1272 */ 1272 */
1273 if (argp->opcnt == resp->opcnt) 1273 if (argp->opcnt == resp->opcnt)
1274 return false; 1274 return false;
1275 1275 if (next->opnum == OP_ILLEGAL)
1276 return false;
1276 nextd = OPDESC(next); 1277 nextd = OPDESC(next);
1277 /* 1278 /*
1278 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC 1279 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC
@@ -1589,7 +1590,8 @@ static inline u32 nfsd4_rename_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op
1589static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp, 1590static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp,
1590 struct nfsd4_op *op) 1591 struct nfsd4_op *op)
1591{ 1592{
1592 return NFS4_MAX_SESSIONID_LEN + 20; 1593 return (op_encode_hdr_size
1594 + XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) * sizeof(__be32);
1593} 1595}
1594 1596
1595static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1597static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
@@ -1893,6 +1895,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
1893 .op_func = (nfsd4op_func)nfsd4_sequence, 1895 .op_func = (nfsd4op_func)nfsd4_sequence,
1894 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, 1896 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
1895 .op_name = "OP_SEQUENCE", 1897 .op_name = "OP_SEQUENCE",
1898 .op_rsize_bop = (nfsd4op_rsize)nfsd4_sequence_rsize,
1896 }, 1899 },
1897 [OP_DESTROY_CLIENTID] = { 1900 [OP_DESTROY_CLIENTID] = {
1898 .op_func = (nfsd4op_func)nfsd4_destroy_clientid, 1901 .op_func = (nfsd4op_func)nfsd4_destroy_clientid,
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index 9ce062218de9..e8497144b323 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -288,20 +288,25 @@ void fsnotify_unmount_inodes(struct list_head *list)
288 spin_unlock(&inode->i_lock); 288 spin_unlock(&inode->i_lock);
289 289
290 /* In case the dropping of a reference would nuke next_i. */ 290 /* In case the dropping of a reference would nuke next_i. */
291 if ((&next_i->i_sb_list != list) && 291 while (&next_i->i_sb_list != list) {
292 atomic_read(&next_i->i_count)) {
293 spin_lock(&next_i->i_lock); 292 spin_lock(&next_i->i_lock);
294 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE))) { 293 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE)) &&
294 atomic_read(&next_i->i_count)) {
295 __iget(next_i); 295 __iget(next_i);
296 need_iput = next_i; 296 need_iput = next_i;
297 spin_unlock(&next_i->i_lock);
298 break;
297 } 299 }
298 spin_unlock(&next_i->i_lock); 300 spin_unlock(&next_i->i_lock);
301 next_i = list_entry(next_i->i_sb_list.next,
302 struct inode, i_sb_list);
299 } 303 }
300 304
301 /* 305 /*
302 * We can safely drop inode_sb_list_lock here because we hold 306 * We can safely drop inode_sb_list_lock here because either
303 * references on both inode and next_i. Also no new inodes 307 * we actually hold references on both inode and next_i or
304 * will be added since the umount has begun. 308 * end of list. Also no new inodes will be added since the
309 * umount has begun.
305 */ 310 */
306 spin_unlock(&inode_sb_list_lock); 311 spin_unlock(&inode_sb_list_lock);
307 312
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 97de0fbd9f78..a96044004064 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -925,7 +925,7 @@ static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec,
925 size_t veclen, size_t total) 925 size_t veclen, size_t total)
926{ 926{
927 int ret; 927 int ret;
928 struct msghdr msg; 928 struct msghdr msg = {.msg_flags = 0,};
929 929
930 if (sock == NULL) { 930 if (sock == NULL) {
931 ret = -EINVAL; 931 ret = -EINVAL;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1030d7..b931e04e3388 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -158,7 +158,7 @@ bail_add:
158 * NOTE: This dentry already has ->d_op set from 158 * NOTE: This dentry already has ->d_op set from
159 * ocfs2_get_parent() and ocfs2_get_dentry() 159 * ocfs2_get_parent() and ocfs2_get_dentry()
160 */ 160 */
161 if (ret) 161 if (!IS_ERR_OR_NULL(ret))
162 dentry = ret; 162 dentry = ret;
163 163
164 status = ocfs2_dentry_attach_lock(dentry, inode, 164 status = ocfs2_dentry_attach_lock(dentry, inode,
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 910553f37aca..2a7ef4f8e2a6 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -21,9 +21,10 @@ struct ovl_cache_entry {
21 unsigned int len; 21 unsigned int len;
22 unsigned int type; 22 unsigned int type;
23 u64 ino; 23 u64 ino;
24 bool is_whiteout;
25 struct list_head l_node; 24 struct list_head l_node;
26 struct rb_node node; 25 struct rb_node node;
26 bool is_whiteout;
27 bool is_cursor;
27 char name[]; 28 char name[];
28}; 29};
29 30
@@ -92,6 +93,7 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
92 p->type = d_type; 93 p->type = d_type;
93 p->ino = ino; 94 p->ino = ino;
94 p->is_whiteout = false; 95 p->is_whiteout = false;
96 p->is_cursor = false;
95 } 97 }
96 98
97 return p; 99 return p;
@@ -166,7 +168,7 @@ static void ovl_cache_put(struct ovl_dir_file *od, struct dentry *dentry)
166{ 168{
167 struct ovl_dir_cache *cache = od->cache; 169 struct ovl_dir_cache *cache = od->cache;
168 170
169 list_del(&od->cursor.l_node); 171 list_del_init(&od->cursor.l_node);
170 WARN_ON(cache->refcount <= 0); 172 WARN_ON(cache->refcount <= 0);
171 cache->refcount--; 173 cache->refcount--;
172 if (!cache->refcount) { 174 if (!cache->refcount) {
@@ -251,7 +253,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
251 253
252 mutex_lock(&dir->d_inode->i_mutex); 254 mutex_lock(&dir->d_inode->i_mutex);
253 list_for_each_entry(p, rdd->list, l_node) { 255 list_for_each_entry(p, rdd->list, l_node) {
254 if (!p->name) 256 if (p->is_cursor)
255 continue; 257 continue;
256 258
257 if (p->type != DT_CHR) 259 if (p->type != DT_CHR)
@@ -307,7 +309,6 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
307 } 309 }
308out: 310out:
309 return err; 311 return err;
310
311} 312}
312 313
313static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) 314static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
@@ -316,7 +317,7 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
316 loff_t off = 0; 317 loff_t off = 0;
317 318
318 list_for_each_entry(p, &od->cache->entries, l_node) { 319 list_for_each_entry(p, &od->cache->entries, l_node) {
319 if (!p->name) 320 if (p->is_cursor)
320 continue; 321 continue;
321 if (off >= pos) 322 if (off >= pos)
322 break; 323 break;
@@ -389,7 +390,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
389 390
390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); 391 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node);
391 /* Skip cursors */ 392 /* Skip cursors */
392 if (p->name) { 393 if (!p->is_cursor) {
393 if (!p->is_whiteout) { 394 if (!p->is_whiteout) {
394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) 395 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
395 break; 396 break;
@@ -454,12 +455,13 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
454 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) { 455 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) {
455 struct inode *inode = file_inode(file); 456 struct inode *inode = file_inode(file);
456 457
457 realfile = od->upperfile; 458 realfile =lockless_dereference(od->upperfile);
458 if (!realfile) { 459 if (!realfile) {
459 struct path upperpath; 460 struct path upperpath;
460 461
461 ovl_path_upper(dentry, &upperpath); 462 ovl_path_upper(dentry, &upperpath);
462 realfile = ovl_path_open(&upperpath, O_RDONLY); 463 realfile = ovl_path_open(&upperpath, O_RDONLY);
464 smp_mb__before_spinlock();
463 mutex_lock(&inode->i_mutex); 465 mutex_lock(&inode->i_mutex);
464 if (!od->upperfile) { 466 if (!od->upperfile) {
465 if (IS_ERR(realfile)) { 467 if (IS_ERR(realfile)) {
@@ -518,6 +520,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
518 od->realfile = realfile; 520 od->realfile = realfile;
519 od->is_real = (type != OVL_PATH_MERGE); 521 od->is_real = (type != OVL_PATH_MERGE);
520 od->is_upper = (type != OVL_PATH_LOWER); 522 od->is_upper = (type != OVL_PATH_LOWER);
523 od->cursor.is_cursor = true;
521 file->private_data = od; 524 file->private_data = od;
522 525
523 return 0; 526 return 0;
@@ -569,7 +572,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
569{ 572{
570 struct ovl_cache_entry *p; 573 struct ovl_cache_entry *p;
571 574
572 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT); 575 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD);
573 list_for_each_entry(p, list, l_node) { 576 list_for_each_entry(p, list, l_node) {
574 struct dentry *dentry; 577 struct dentry *dentry;
575 578
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8b663b2d9562..6b4527216a7f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -634,7 +634,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
634 dqstats_inc(DQST_LOOKUPS); 634 dqstats_inc(DQST_LOOKUPS);
635 err = sb->dq_op->write_dquot(dquot); 635 err = sb->dq_op->write_dquot(dquot);
636 if (!ret && err) 636 if (!ret && err)
637 err = ret; 637 ret = err;
638 dqput(dquot); 638 dqput(dquot);
639 spin_lock(&dq_list_lock); 639 spin_lock(&dq_list_lock);
640 } 640 }
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 92e8f99a5857..281002689d64 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1338,7 +1338,10 @@ xfs_free_file_space(
1338 goto out; 1338 goto out;
1339} 1339}
1340 1340
1341 1341/*
1342 * Preallocate and zero a range of a file. This mechanism has the allocation
1343 * semantics of fallocate and in addition converts data in the range to zeroes.
1344 */
1342int 1345int
1343xfs_zero_file_space( 1346xfs_zero_file_space(
1344 struct xfs_inode *ip, 1347 struct xfs_inode *ip,
@@ -1346,65 +1349,30 @@ xfs_zero_file_space(
1346 xfs_off_t len) 1349 xfs_off_t len)
1347{ 1350{
1348 struct xfs_mount *mp = ip->i_mount; 1351 struct xfs_mount *mp = ip->i_mount;
1349 uint granularity; 1352 uint blksize;
1350 xfs_off_t start_boundary;
1351 xfs_off_t end_boundary;
1352 int error; 1353 int error;
1353 1354
1354 trace_xfs_zero_file_space(ip); 1355 trace_xfs_zero_file_space(ip);
1355 1356
1356 granularity = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1357 blksize = 1 << mp->m_sb.sb_blocklog;
1357 1358
1358 /* 1359 /*
1359 * Round the range of extents we are going to convert inwards. If the 1360 * Punch a hole and prealloc the range. We use hole punch rather than
1360 * offset is aligned, then it doesn't get changed so we zero from the 1361 * unwritten extent conversion for two reasons:
1361 * start of the block offset points to. 1362 *
1363 * 1.) Hole punch handles partial block zeroing for us.
1364 *
1365 * 2.) If prealloc returns ENOSPC, the file range is still zero-valued
1366 * by virtue of the hole punch.
1362 */ 1367 */
1363 start_boundary = round_up(offset, granularity); 1368 error = xfs_free_file_space(ip, offset, len);
1364 end_boundary = round_down(offset + len, granularity); 1369 if (error)
1365 1370 goto out;
1366 ASSERT(start_boundary >= offset);
1367 ASSERT(end_boundary <= offset + len);
1368
1369 if (start_boundary < end_boundary - 1) {
1370 /*
1371 * Writeback the range to ensure any inode size updates due to
1372 * appending writes make it to disk (otherwise we could just
1373 * punch out the delalloc blocks).
1374 */
1375 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1376 start_boundary, end_boundary - 1);
1377 if (error)
1378 goto out;
1379 truncate_pagecache_range(VFS_I(ip), start_boundary,
1380 end_boundary - 1);
1381
1382 /* convert the blocks */
1383 error = xfs_alloc_file_space(ip, start_boundary,
1384 end_boundary - start_boundary - 1,
1385 XFS_BMAPI_PREALLOC | XFS_BMAPI_CONVERT);
1386 if (error)
1387 goto out;
1388
1389 /* We've handled the interior of the range, now for the edges */
1390 if (start_boundary != offset) {
1391 error = xfs_iozero(ip, offset, start_boundary - offset);
1392 if (error)
1393 goto out;
1394 }
1395
1396 if (end_boundary != offset + len)
1397 error = xfs_iozero(ip, end_boundary,
1398 offset + len - end_boundary);
1399
1400 } else {
1401 /*
1402 * It's either a sub-granularity range or the range spanned lies
1403 * partially across two adjacent blocks.
1404 */
1405 error = xfs_iozero(ip, offset, len);
1406 }
1407 1371
1372 error = xfs_alloc_file_space(ip, round_down(offset, blksize),
1373 round_up(offset + len, blksize) -
1374 round_down(offset, blksize),
1375 XFS_BMAPI_PREALLOC);
1408out: 1376out:
1409 return error; 1377 return error;
1410 1378
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index f1deb961a296..894924a5129b 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -236,8 +236,10 @@ xfs_bulkstat_grab_ichunk(
236 XFS_WANT_CORRUPTED_RETURN(stat == 1); 236 XFS_WANT_CORRUPTED_RETURN(stat == 1);
237 237
238 /* Check if the record contains the inode in request */ 238 /* Check if the record contains the inode in request */
239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) 239 if (irec->ir_startino + XFS_INODES_PER_CHUNK <= agino) {
240 return -EINVAL; 240 *icount = 0;
241 return 0;
242 }
241 243
242 idx = agino - irec->ir_startino + 1; 244 idx = agino - irec->ir_startino + 1;
243 if (idx < XFS_INODES_PER_CHUNK && 245 if (idx < XFS_INODES_PER_CHUNK &&
@@ -262,75 +264,76 @@ xfs_bulkstat_grab_ichunk(
262 264
263#define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size) 265#define XFS_BULKSTAT_UBLEFT(ubleft) ((ubleft) >= statstruct_size)
264 266
267struct xfs_bulkstat_agichunk {
268 char __user **ac_ubuffer;/* pointer into user's buffer */
269 int ac_ubleft; /* bytes left in user's buffer */
270 int ac_ubelem; /* spaces used in user's buffer */
271};
272
265/* 273/*
266 * Process inodes in chunk with a pointer to a formatter function 274 * Process inodes in chunk with a pointer to a formatter function
267 * that will iget the inode and fill in the appropriate structure. 275 * that will iget the inode and fill in the appropriate structure.
268 */ 276 */
269int 277static int
270xfs_bulkstat_ag_ichunk( 278xfs_bulkstat_ag_ichunk(
271 struct xfs_mount *mp, 279 struct xfs_mount *mp,
272 xfs_agnumber_t agno, 280 xfs_agnumber_t agno,
273 struct xfs_inobt_rec_incore *irbp, 281 struct xfs_inobt_rec_incore *irbp,
274 bulkstat_one_pf formatter, 282 bulkstat_one_pf formatter,
275 size_t statstruct_size, 283 size_t statstruct_size,
276 struct xfs_bulkstat_agichunk *acp) 284 struct xfs_bulkstat_agichunk *acp,
285 xfs_agino_t *last_agino)
277{ 286{
278 xfs_ino_t lastino = acp->ac_lastino;
279 char __user **ubufp = acp->ac_ubuffer; 287 char __user **ubufp = acp->ac_ubuffer;
280 int ubleft = acp->ac_ubleft; 288 int chunkidx;
281 int ubelem = acp->ac_ubelem;
282 int chunkidx, clustidx;
283 int error = 0; 289 int error = 0;
284 xfs_agino_t agino; 290 xfs_agino_t agino = irbp->ir_startino;
285 291
286 for (agino = irbp->ir_startino, chunkidx = clustidx = 0; 292 for (chunkidx = 0; chunkidx < XFS_INODES_PER_CHUNK;
287 XFS_BULKSTAT_UBLEFT(ubleft) && 293 chunkidx++, agino++) {
288 irbp->ir_freecount < XFS_INODES_PER_CHUNK; 294 int fmterror;
289 chunkidx++, clustidx++, agino++) {
290 int fmterror; /* bulkstat formatter result */
291 int ubused; 295 int ubused;
292 xfs_ino_t ino = XFS_AGINO_TO_INO(mp, agno, agino);
293 296
294 ASSERT(chunkidx < XFS_INODES_PER_CHUNK); 297 /* inode won't fit in buffer, we are done */
298 if (acp->ac_ubleft < statstruct_size)
299 break;
295 300
296 /* Skip if this inode is free */ 301 /* Skip if this inode is free */
297 if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) { 302 if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free)
298 lastino = ino;
299 continue; 303 continue;
300 }
301
302 /*
303 * Count used inodes as free so we can tell when the
304 * chunk is used up.
305 */
306 irbp->ir_freecount++;
307 304
308 /* Get the inode and fill in a single buffer */ 305 /* Get the inode and fill in a single buffer */
309 ubused = statstruct_size; 306 ubused = statstruct_size;
310 error = formatter(mp, ino, *ubufp, ubleft, &ubused, &fmterror); 307 error = formatter(mp, XFS_AGINO_TO_INO(mp, agno, agino),
311 if (fmterror == BULKSTAT_RV_NOTHING) { 308 *ubufp, acp->ac_ubleft, &ubused, &fmterror);
312 if (error && error != -ENOENT && error != -EINVAL) { 309
313 ubleft = 0; 310 if (fmterror == BULKSTAT_RV_GIVEUP ||
314 break; 311 (error && error != -ENOENT && error != -EINVAL)) {
315 } 312 acp->ac_ubleft = 0;
316 lastino = ino;
317 continue;
318 }
319 if (fmterror == BULKSTAT_RV_GIVEUP) {
320 ubleft = 0;
321 ASSERT(error); 313 ASSERT(error);
322 break; 314 break;
323 } 315 }
324 if (*ubufp) 316
325 *ubufp += ubused; 317 /* be careful not to leak error if at end of chunk */
326 ubleft -= ubused; 318 if (fmterror == BULKSTAT_RV_NOTHING || error) {
327 ubelem++; 319 error = 0;
328 lastino = ino; 320 continue;
321 }
322
323 *ubufp += ubused;
324 acp->ac_ubleft -= ubused;
325 acp->ac_ubelem++;
329 } 326 }
330 327
331 acp->ac_lastino = lastino; 328 /*
332 acp->ac_ubleft = ubleft; 329 * Post-update *last_agino. At this point, agino will always point one
333 acp->ac_ubelem = ubelem; 330 * inode past the last inode we processed successfully. Hence we
331 * substract that inode when setting the *last_agino cursor so that we
332 * return the correct cookie to userspace. On the next bulkstat call,
333 * the inode under the lastino cookie will be skipped as we have already
334 * processed it here.
335 */
336 *last_agino = agino - 1;
334 337
335 return error; 338 return error;
336} 339}
@@ -353,45 +356,33 @@ xfs_bulkstat(
353 xfs_agino_t agino; /* inode # in allocation group */ 356 xfs_agino_t agino; /* inode # in allocation group */
354 xfs_agnumber_t agno; /* allocation group number */ 357 xfs_agnumber_t agno; /* allocation group number */
355 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ 358 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */
356 int end_of_ag; /* set if we've seen the ag end */
357 int error; /* error code */
358 int fmterror;/* bulkstat formatter result */
359 int i; /* loop index */
360 int icount; /* count of inodes good in irbuf */
361 size_t irbsize; /* size of irec buffer in bytes */ 359 size_t irbsize; /* size of irec buffer in bytes */
362 xfs_ino_t ino; /* inode number (filesystem) */
363 xfs_inobt_rec_incore_t *irbp; /* current irec buffer pointer */
364 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */ 360 xfs_inobt_rec_incore_t *irbuf; /* start of irec buffer */
365 xfs_inobt_rec_incore_t *irbufend; /* end of good irec buffer entries */
366 xfs_ino_t lastino; /* last inode number returned */
367 int nirbuf; /* size of irbuf */ 361 int nirbuf; /* size of irbuf */
368 int rval; /* return value error code */
369 int tmp; /* result value from btree calls */
370 int ubcount; /* size of user's buffer */ 362 int ubcount; /* size of user's buffer */
371 int ubleft; /* bytes left in user's buffer */ 363 struct xfs_bulkstat_agichunk ac;
372 char __user *ubufp; /* pointer into user's buffer */ 364 int error = 0;
373 int ubelem; /* spaces used in user's buffer */
374 365
375 /* 366 /*
376 * Get the last inode value, see if there's nothing to do. 367 * Get the last inode value, see if there's nothing to do.
377 */ 368 */
378 ino = (xfs_ino_t)*lastinop; 369 agno = XFS_INO_TO_AGNO(mp, *lastinop);
379 lastino = ino; 370 agino = XFS_INO_TO_AGINO(mp, *lastinop);
380 agno = XFS_INO_TO_AGNO(mp, ino);
381 agino = XFS_INO_TO_AGINO(mp, ino);
382 if (agno >= mp->m_sb.sb_agcount || 371 if (agno >= mp->m_sb.sb_agcount ||
383 ino != XFS_AGINO_TO_INO(mp, agno, agino)) { 372 *lastinop != XFS_AGINO_TO_INO(mp, agno, agino)) {
384 *done = 1; 373 *done = 1;
385 *ubcountp = 0; 374 *ubcountp = 0;
386 return 0; 375 return 0;
387 } 376 }
388 377
389 ubcount = *ubcountp; /* statstruct's */ 378 ubcount = *ubcountp; /* statstruct's */
390 ubleft = ubcount * statstruct_size; /* bytes */ 379 ac.ac_ubuffer = &ubuffer;
391 *ubcountp = ubelem = 0; 380 ac.ac_ubleft = ubcount * statstruct_size; /* bytes */;
381 ac.ac_ubelem = 0;
382
383 *ubcountp = 0;
392 *done = 0; 384 *done = 0;
393 fmterror = 0; 385
394 ubufp = ubuffer;
395 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4); 386 irbuf = kmem_zalloc_greedy(&irbsize, PAGE_SIZE, PAGE_SIZE * 4);
396 if (!irbuf) 387 if (!irbuf)
397 return -ENOMEM; 388 return -ENOMEM;
@@ -402,9 +393,13 @@ xfs_bulkstat(
402 * Loop over the allocation groups, starting from the last 393 * Loop over the allocation groups, starting from the last
403 * inode returned; 0 means start of the allocation group. 394 * inode returned; 0 means start of the allocation group.
404 */ 395 */
405 rval = 0; 396 while (agno < mp->m_sb.sb_agcount) {
406 while (XFS_BULKSTAT_UBLEFT(ubleft) && agno < mp->m_sb.sb_agcount) { 397 struct xfs_inobt_rec_incore *irbp = irbuf;
407 cond_resched(); 398 struct xfs_inobt_rec_incore *irbufend = irbuf + nirbuf;
399 bool end_of_ag = false;
400 int icount = 0;
401 int stat;
402
408 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); 403 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp);
409 if (error) 404 if (error)
410 break; 405 break;
@@ -414,10 +409,6 @@ xfs_bulkstat(
414 */ 409 */
415 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno, 410 cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno,
416 XFS_BTNUM_INO); 411 XFS_BTNUM_INO);
417 irbp = irbuf;
418 irbufend = irbuf + nirbuf;
419 end_of_ag = 0;
420 icount = 0;
421 if (agino > 0) { 412 if (agino > 0) {
422 /* 413 /*
423 * In the middle of an allocation group, we need to get 414 * In the middle of an allocation group, we need to get
@@ -427,22 +418,23 @@ xfs_bulkstat(
427 418
428 error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r); 419 error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r);
429 if (error) 420 if (error)
430 break; 421 goto del_cursor;
431 if (icount) { 422 if (icount) {
432 irbp->ir_startino = r.ir_startino; 423 irbp->ir_startino = r.ir_startino;
433 irbp->ir_freecount = r.ir_freecount; 424 irbp->ir_freecount = r.ir_freecount;
434 irbp->ir_free = r.ir_free; 425 irbp->ir_free = r.ir_free;
435 irbp++; 426 irbp++;
436 agino = r.ir_startino + XFS_INODES_PER_CHUNK;
437 } 427 }
438 /* Increment to the next record */ 428 /* Increment to the next record */
439 error = xfs_btree_increment(cur, 0, &tmp); 429 error = xfs_btree_increment(cur, 0, &stat);
440 } else { 430 } else {
441 /* Start of ag. Lookup the first inode chunk */ 431 /* Start of ag. Lookup the first inode chunk */
442 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp); 432 error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &stat);
433 }
434 if (error || stat == 0) {
435 end_of_ag = true;
436 goto del_cursor;
443 } 437 }
444 if (error)
445 break;
446 438
447 /* 439 /*
448 * Loop through inode btree records in this ag, 440 * Loop through inode btree records in this ag,
@@ -451,10 +443,10 @@ xfs_bulkstat(
451 while (irbp < irbufend && icount < ubcount) { 443 while (irbp < irbufend && icount < ubcount) {
452 struct xfs_inobt_rec_incore r; 444 struct xfs_inobt_rec_incore r;
453 445
454 error = xfs_inobt_get_rec(cur, &r, &i); 446 error = xfs_inobt_get_rec(cur, &r, &stat);
455 if (error || i == 0) { 447 if (error || stat == 0) {
456 end_of_ag = 1; 448 end_of_ag = true;
457 break; 449 goto del_cursor;
458 } 450 }
459 451
460 /* 452 /*
@@ -469,77 +461,79 @@ xfs_bulkstat(
469 irbp++; 461 irbp++;
470 icount += XFS_INODES_PER_CHUNK - r.ir_freecount; 462 icount += XFS_INODES_PER_CHUNK - r.ir_freecount;
471 } 463 }
472 /* 464 error = xfs_btree_increment(cur, 0, &stat);
473 * Set agino to after this chunk and bump the cursor. 465 if (error || stat == 0) {
474 */ 466 end_of_ag = true;
475 agino = r.ir_startino + XFS_INODES_PER_CHUNK; 467 goto del_cursor;
476 error = xfs_btree_increment(cur, 0, &tmp); 468 }
477 cond_resched(); 469 cond_resched();
478 } 470 }
471
479 /* 472 /*
480 * Drop the btree buffers and the agi buffer. 473 * Drop the btree buffers and the agi buffer as we can't hold any
481 * We can't hold any of the locks these represent 474 * of the locks these represent when calling iget. If there is a
482 * when calling iget. 475 * pending error, then we are done.
483 */ 476 */
477del_cursor:
484 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 478 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
485 xfs_buf_relse(agbp); 479 xfs_buf_relse(agbp);
480 if (error)
481 break;
486 /* 482 /*
487 * Now format all the good inodes into the user's buffer. 483 * Now format all the good inodes into the user's buffer. The
484 * call to xfs_bulkstat_ag_ichunk() sets up the agino pointer
485 * for the next loop iteration.
488 */ 486 */
489 irbufend = irbp; 487 irbufend = irbp;
490 for (irbp = irbuf; 488 for (irbp = irbuf;
491 irbp < irbufend && XFS_BULKSTAT_UBLEFT(ubleft); irbp++) { 489 irbp < irbufend && ac.ac_ubleft >= statstruct_size;
492 struct xfs_bulkstat_agichunk ac; 490 irbp++) {
493
494 ac.ac_lastino = lastino;
495 ac.ac_ubuffer = &ubuffer;
496 ac.ac_ubleft = ubleft;
497 ac.ac_ubelem = ubelem;
498 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp, 491 error = xfs_bulkstat_ag_ichunk(mp, agno, irbp,
499 formatter, statstruct_size, &ac); 492 formatter, statstruct_size, &ac,
493 &agino);
500 if (error) 494 if (error)
501 rval = error; 495 break;
502
503 lastino = ac.ac_lastino;
504 ubleft = ac.ac_ubleft;
505 ubelem = ac.ac_ubelem;
506 496
507 cond_resched(); 497 cond_resched();
508 } 498 }
499
509 /* 500 /*
510 * Set up for the next loop iteration. 501 * If we've run out of space or had a formatting error, we
502 * are now done
511 */ 503 */
512 if (XFS_BULKSTAT_UBLEFT(ubleft)) { 504 if (ac.ac_ubleft < statstruct_size || error)
513 if (end_of_ag) {
514 agno++;
515 agino = 0;
516 } else
517 agino = XFS_INO_TO_AGINO(mp, lastino);
518 } else
519 break; 505 break;
506
507 if (end_of_ag) {
508 agno++;
509 agino = 0;
510 }
520 } 511 }
521 /* 512 /*
522 * Done, we're either out of filesystem or space to put the data. 513 * Done, we're either out of filesystem or space to put the data.
523 */ 514 */
524 kmem_free(irbuf); 515 kmem_free(irbuf);
525 *ubcountp = ubelem; 516 *ubcountp = ac.ac_ubelem;
517
526 /* 518 /*
527 * Found some inodes, return them now and return the error next time. 519 * We found some inodes, so clear the error status and return them.
520 * The lastino pointer will point directly at the inode that triggered
521 * any error that occurred, so on the next call the error will be
522 * triggered again and propagated to userspace as there will be no
523 * formatted inodes in the buffer.
528 */ 524 */
529 if (ubelem) 525 if (ac.ac_ubelem)
530 rval = 0; 526 error = 0;
531 if (agno >= mp->m_sb.sb_agcount) { 527
532 /* 528 /*
533 * If we ran out of filesystem, mark lastino as off 529 * If we ran out of filesystem, lastino will point off the end of
534 * the end of the filesystem, so the next call 530 * the filesystem so the next call will return immediately.
535 * will return immediately. 531 */
536 */ 532 *lastinop = XFS_AGINO_TO_INO(mp, agno, agino);
537 *lastinop = (xfs_ino_t)XFS_AGINO_TO_INO(mp, agno, 0); 533 if (agno >= mp->m_sb.sb_agcount)
538 *done = 1; 534 *done = 1;
539 } else
540 *lastinop = (xfs_ino_t)lastino;
541 535
542 return rval; 536 return error;
543} 537}
544 538
545int 539int
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
index aaed08022eb9..6ea8b3912fa4 100644
--- a/fs/xfs/xfs_itable.h
+++ b/fs/xfs/xfs_itable.h
@@ -30,22 +30,6 @@ typedef int (*bulkstat_one_pf)(struct xfs_mount *mp,
30 int *ubused, 30 int *ubused,
31 int *stat); 31 int *stat);
32 32
33struct xfs_bulkstat_agichunk {
34 xfs_ino_t ac_lastino; /* last inode returned */
35 char __user **ac_ubuffer;/* pointer into user's buffer */
36 int ac_ubleft; /* bytes left in user's buffer */
37 int ac_ubelem; /* spaces used in user's buffer */
38};
39
40int
41xfs_bulkstat_ag_ichunk(
42 struct xfs_mount *mp,
43 xfs_agnumber_t agno,
44 struct xfs_inobt_rec_incore *irbp,
45 bulkstat_one_pf formatter,
46 size_t statstruct_size,
47 struct xfs_bulkstat_agichunk *acp);
48
49/* 33/*
50 * Values for stat return value. 34 * Values for stat return value.
51 */ 35 */
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index e973540cd15b..2dd405c9be78 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -74,7 +74,6 @@
74 {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 74 {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
75 {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 75 {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
76 {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 76 {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
77 {0x1002, 0x4C6E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \
78 {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 77 {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
79 {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 78 {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
80 {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 79 {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
diff --git a/include/dt-bindings/clock/vf610-clock.h b/include/dt-bindings/clock/vf610-clock.h
index d6b56b21539b..801c0ac50c47 100644
--- a/include/dt-bindings/clock/vf610-clock.h
+++ b/include/dt-bindings/clock/vf610-clock.h
@@ -21,24 +21,24 @@
21#define VF610_CLK_FASK_CLK_SEL 8 21#define VF610_CLK_FASK_CLK_SEL 8
22#define VF610_CLK_AUDIO_EXT 9 22#define VF610_CLK_AUDIO_EXT 9
23#define VF610_CLK_ENET_EXT 10 23#define VF610_CLK_ENET_EXT 10
24#define VF610_CLK_PLL1_MAIN 11 24#define VF610_CLK_PLL1_SYS 11
25#define VF610_CLK_PLL1_PFD1 12 25#define VF610_CLK_PLL1_PFD1 12
26#define VF610_CLK_PLL1_PFD2 13 26#define VF610_CLK_PLL1_PFD2 13
27#define VF610_CLK_PLL1_PFD3 14 27#define VF610_CLK_PLL1_PFD3 14
28#define VF610_CLK_PLL1_PFD4 15 28#define VF610_CLK_PLL1_PFD4 15
29#define VF610_CLK_PLL2_MAIN 16 29#define VF610_CLK_PLL2_BUS 16
30#define VF610_CLK_PLL2_PFD1 17 30#define VF610_CLK_PLL2_PFD1 17
31#define VF610_CLK_PLL2_PFD2 18 31#define VF610_CLK_PLL2_PFD2 18
32#define VF610_CLK_PLL2_PFD3 19 32#define VF610_CLK_PLL2_PFD3 19
33#define VF610_CLK_PLL2_PFD4 20 33#define VF610_CLK_PLL2_PFD4 20
34#define VF610_CLK_PLL3_MAIN 21 34#define VF610_CLK_PLL3_USB_OTG 21
35#define VF610_CLK_PLL3_PFD1 22 35#define VF610_CLK_PLL3_PFD1 22
36#define VF610_CLK_PLL3_PFD2 23 36#define VF610_CLK_PLL3_PFD2 23
37#define VF610_CLK_PLL3_PFD3 24 37#define VF610_CLK_PLL3_PFD3 24
38#define VF610_CLK_PLL3_PFD4 25 38#define VF610_CLK_PLL3_PFD4 25
39#define VF610_CLK_PLL4_MAIN 26 39#define VF610_CLK_PLL4_AUDIO 26
40#define VF610_CLK_PLL5_MAIN 27 40#define VF610_CLK_PLL5_ENET 27
41#define VF610_CLK_PLL6_MAIN 28 41#define VF610_CLK_PLL6_VIDEO 28
42#define VF610_CLK_PLL3_MAIN_DIV 29 42#define VF610_CLK_PLL3_MAIN_DIV 29
43#define VF610_CLK_PLL4_MAIN_DIV 30 43#define VF610_CLK_PLL4_MAIN_DIV 30
44#define VF610_CLK_PLL6_MAIN_DIV 31 44#define VF610_CLK_PLL6_MAIN_DIV 31
@@ -166,9 +166,32 @@
166#define VF610_CLK_DMAMUX3 153 166#define VF610_CLK_DMAMUX3 153
167#define VF610_CLK_FLEXCAN0_EN 154 167#define VF610_CLK_FLEXCAN0_EN 154
168#define VF610_CLK_FLEXCAN1_EN 155 168#define VF610_CLK_FLEXCAN1_EN 155
169#define VF610_CLK_PLL7_MAIN 156 169#define VF610_CLK_PLL7_USB_HOST 156
170#define VF610_CLK_USBPHY0 157 170#define VF610_CLK_USBPHY0 157
171#define VF610_CLK_USBPHY1 158 171#define VF610_CLK_USBPHY1 158
172#define VF610_CLK_END 159 172#define VF610_CLK_LVDS1_IN 159
173#define VF610_CLK_ANACLK1 160
174#define VF610_CLK_PLL1_BYPASS_SRC 161
175#define VF610_CLK_PLL2_BYPASS_SRC 162
176#define VF610_CLK_PLL3_BYPASS_SRC 163
177#define VF610_CLK_PLL4_BYPASS_SRC 164
178#define VF610_CLK_PLL5_BYPASS_SRC 165
179#define VF610_CLK_PLL6_BYPASS_SRC 166
180#define VF610_CLK_PLL7_BYPASS_SRC 167
181#define VF610_CLK_PLL1 168
182#define VF610_CLK_PLL2 169
183#define VF610_CLK_PLL3 170
184#define VF610_CLK_PLL4 171
185#define VF610_CLK_PLL5 172
186#define VF610_CLK_PLL6 173
187#define VF610_CLK_PLL7 174
188#define VF610_PLL1_BYPASS 175
189#define VF610_PLL2_BYPASS 176
190#define VF610_PLL3_BYPASS 177
191#define VF610_PLL4_BYPASS 178
192#define VF610_PLL5_BYPASS 179
193#define VF610_PLL6_BYPASS 180
194#define VF610_PLL7_BYPASS 181
195#define VF610_CLK_END 182
173 196
174#endif /* __DT_BINDINGS_CLOCK_VF610_H */ 197#endif /* __DT_BINDINGS_CLOCK_VF610_H */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0207a78a8d82..aac0f9ea952a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1136,8 +1136,7 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk)
1136/* 1136/*
1137 * tag stuff 1137 * tag stuff
1138 */ 1138 */
1139#define blk_rq_tagged(rq) \ 1139#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
1140 ((rq)->mq_ctx || ((rq)->cmd_flags & REQ_QUEUED))
1141extern int blk_queue_start_tag(struct request_queue *, struct request *); 1140extern int blk_queue_start_tag(struct request_queue *, struct request *);
1142extern struct request *blk_queue_find_tag(struct request_queue *, int); 1141extern struct request *blk_queue_find_tag(struct request_queue *, int);
1143extern void blk_queue_end_tag(struct request_queue *, struct request *); 1142extern void blk_queue_end_tag(struct request_queue *, struct request *);
@@ -1583,13 +1582,13 @@ static inline bool blk_integrity_merge_rq(struct request_queue *rq,
1583 struct request *r1, 1582 struct request *r1,
1584 struct request *r2) 1583 struct request *r2)
1585{ 1584{
1586 return 0; 1585 return true;
1587} 1586}
1588static inline bool blk_integrity_merge_bio(struct request_queue *rq, 1587static inline bool blk_integrity_merge_bio(struct request_queue *rq,
1589 struct request *r, 1588 struct request *r,
1590 struct bio *b) 1589 struct bio *b)
1591{ 1590{
1592 return 0; 1591 return true;
1593} 1592}
1594static inline bool blk_integrity_is_initialized(struct gendisk *g) 1593static inline bool blk_integrity_is_initialized(struct gendisk *g)
1595{ 1594{
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 0430ed05d3b9..a93438beb33c 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -18,12 +18,12 @@ struct cma;
18extern phys_addr_t cma_get_base(struct cma *cma); 18extern phys_addr_t cma_get_base(struct cma *cma);
19extern unsigned long cma_get_size(struct cma *cma); 19extern unsigned long cma_get_size(struct cma *cma);
20 20
21extern int __init cma_declare_contiguous(phys_addr_t size, 21extern int __init cma_declare_contiguous(phys_addr_t base,
22 phys_addr_t base, phys_addr_t limit, 22 phys_addr_t size, phys_addr_t limit,
23 phys_addr_t alignment, unsigned int order_per_bit, 23 phys_addr_t alignment, unsigned int order_per_bit,
24 bool fixed, struct cma **res_cma); 24 bool fixed, struct cma **res_cma);
25extern int cma_init_reserved_mem(phys_addr_t size, 25extern int cma_init_reserved_mem(phys_addr_t base,
26 phys_addr_t base, int order_per_bit, 26 phys_addr_t size, int order_per_bit,
27 struct cma **res_cma); 27 struct cma **res_cma);
28extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align); 28extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align);
29extern bool cma_release(struct cma *cma, struct page *pages, int count); 29extern bool cma_release(struct cma *cma, struct page *pages, int count);
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 2507fd2a1eb4..d1a558239b1a 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -71,7 +71,6 @@
71 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 71 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
72 * 72 *
73 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. 73 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
74 * Fixed in GCC 4.8.2 and later versions.
75 * 74 *
76 * (asm goto is automatically volatile - the naming reflects this.) 75 * (asm goto is automatically volatile - the naming reflects this.)
77 */ 76 */
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
index cdd1cc202d51..c8c565952548 100644
--- a/include/linux/compiler-gcc5.h
+++ b/include/linux/compiler-gcc5.h
@@ -53,7 +53,6 @@
53 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 53 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
54 * 54 *
55 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. 55 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
56 * Fixed in GCC 4.8.2 and later versions.
57 * 56 *
58 * (asm goto is automatically volatile - the naming reflects this.) 57 * (asm goto is automatically volatile - the naming reflects this.)
59 */ 58 */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4e41a4a331bb..9ab779e8a63c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -639,11 +639,13 @@ static inline int inode_unhashed(struct inode *inode)
639 * 2: child/target 639 * 2: child/target
640 * 3: xattr 640 * 3: xattr
641 * 4: second non-directory 641 * 4: second non-directory
642 * The last is for certain operations (such as rename) which lock two 642 * 5: second parent (when locking independent directories in rename)
643 *
644 * I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two
643 * non-directories at once. 645 * non-directories at once.
644 * 646 *
645 * The locking order between these classes is 647 * The locking order between these classes is
646 * parent -> child -> normal -> xattr -> second non-directory 648 * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory
647 */ 649 */
648enum inode_i_mutex_lock_class 650enum inode_i_mutex_lock_class
649{ 651{
@@ -651,7 +653,8 @@ enum inode_i_mutex_lock_class
651 I_MUTEX_PARENT, 653 I_MUTEX_PARENT,
652 I_MUTEX_CHILD, 654 I_MUTEX_CHILD,
653 I_MUTEX_XATTR, 655 I_MUTEX_XATTR,
654 I_MUTEX_NONDIR2 656 I_MUTEX_NONDIR2,
657 I_MUTEX_PARENT2,
655}; 658};
656 659
657void lock_two_nondirectories(struct inode *, struct inode*); 660void lock_two_nondirectories(struct inode *, struct inode*);
@@ -2466,6 +2469,7 @@ extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
2466extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2469extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
2467 2470
2468/* fs/block_dev.c */ 2471/* fs/block_dev.c */
2472extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
2469extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2473extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from);
2470extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2474extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
2471 int datasync); 2475 int datasync);
diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
index 6b394f0b5148..eeb307985715 100644
--- a/include/linux/khugepaged.h
+++ b/include/linux/khugepaged.h
@@ -6,7 +6,8 @@
6#ifdef CONFIG_TRANSPARENT_HUGEPAGE 6#ifdef CONFIG_TRANSPARENT_HUGEPAGE
7extern int __khugepaged_enter(struct mm_struct *mm); 7extern int __khugepaged_enter(struct mm_struct *mm);
8extern void __khugepaged_exit(struct mm_struct *mm); 8extern void __khugepaged_exit(struct mm_struct *mm);
9extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma); 9extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
10 unsigned long vm_flags);
10 11
11#define khugepaged_enabled() \ 12#define khugepaged_enabled() \
12 (transparent_hugepage_flags & \ 13 (transparent_hugepage_flags & \
@@ -35,13 +36,13 @@ static inline void khugepaged_exit(struct mm_struct *mm)
35 __khugepaged_exit(mm); 36 __khugepaged_exit(mm);
36} 37}
37 38
38static inline int khugepaged_enter(struct vm_area_struct *vma) 39static inline int khugepaged_enter(struct vm_area_struct *vma,
40 unsigned long vm_flags)
39{ 41{
40 if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags)) 42 if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
41 if ((khugepaged_always() || 43 if ((khugepaged_always() ||
42 (khugepaged_req_madv() && 44 (khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
43 vma->vm_flags & VM_HUGEPAGE)) && 45 !(vm_flags & VM_NOHUGEPAGE))
44 !(vma->vm_flags & VM_NOHUGEPAGE))
45 if (__khugepaged_enter(vma->vm_mm)) 46 if (__khugepaged_enter(vma->vm_mm))
46 return -ENOMEM; 47 return -ENOMEM;
47 return 0; 48 return 0;
@@ -54,11 +55,13 @@ static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
54static inline void khugepaged_exit(struct mm_struct *mm) 55static inline void khugepaged_exit(struct mm_struct *mm)
55{ 56{
56} 57}
57static inline int khugepaged_enter(struct vm_area_struct *vma) 58static inline int khugepaged_enter(struct vm_area_struct *vma,
59 unsigned long vm_flags)
58{ 60{
59 return 0; 61 return 0;
60} 62}
61static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma) 63static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
64 unsigned long vm_flags)
62{ 65{
63 return 0; 66 return 0;
64} 67}
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 19df5d857411..6b75640ef5ab 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -139,48 +139,23 @@ static inline bool mem_cgroup_disabled(void)
139 return false; 139 return false;
140} 140}
141 141
142void __mem_cgroup_begin_update_page_stat(struct page *page, bool *locked, 142struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page, bool *locked,
143 unsigned long *flags); 143 unsigned long *flags);
144 144void mem_cgroup_end_page_stat(struct mem_cgroup *memcg, bool locked,
145extern atomic_t memcg_moving; 145 unsigned long flags);
146 146void mem_cgroup_update_page_stat(struct mem_cgroup *memcg,
147static inline void mem_cgroup_begin_update_page_stat(struct page *page, 147 enum mem_cgroup_stat_index idx, int val);
148 bool *locked, unsigned long *flags) 148
149{ 149static inline void mem_cgroup_inc_page_stat(struct mem_cgroup *memcg,
150 if (mem_cgroup_disabled())
151 return;
152 rcu_read_lock();
153 *locked = false;
154 if (atomic_read(&memcg_moving))
155 __mem_cgroup_begin_update_page_stat(page, locked, flags);
156}
157
158void __mem_cgroup_end_update_page_stat(struct page *page,
159 unsigned long *flags);
160static inline void mem_cgroup_end_update_page_stat(struct page *page,
161 bool *locked, unsigned long *flags)
162{
163 if (mem_cgroup_disabled())
164 return;
165 if (*locked)
166 __mem_cgroup_end_update_page_stat(page, flags);
167 rcu_read_unlock();
168}
169
170void mem_cgroup_update_page_stat(struct page *page,
171 enum mem_cgroup_stat_index idx,
172 int val);
173
174static inline void mem_cgroup_inc_page_stat(struct page *page,
175 enum mem_cgroup_stat_index idx) 150 enum mem_cgroup_stat_index idx)
176{ 151{
177 mem_cgroup_update_page_stat(page, idx, 1); 152 mem_cgroup_update_page_stat(memcg, idx, 1);
178} 153}
179 154
180static inline void mem_cgroup_dec_page_stat(struct page *page, 155static inline void mem_cgroup_dec_page_stat(struct mem_cgroup *memcg,
181 enum mem_cgroup_stat_index idx) 156 enum mem_cgroup_stat_index idx)
182{ 157{
183 mem_cgroup_update_page_stat(page, idx, -1); 158 mem_cgroup_update_page_stat(memcg, idx, -1);
184} 159}
185 160
186unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, 161unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
@@ -315,13 +290,14 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
315{ 290{
316} 291}
317 292
318static inline void mem_cgroup_begin_update_page_stat(struct page *page, 293static inline struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page,
319 bool *locked, unsigned long *flags) 294 bool *locked, unsigned long *flags)
320{ 295{
296 return NULL;
321} 297}
322 298
323static inline void mem_cgroup_end_update_page_stat(struct page *page, 299static inline void mem_cgroup_end_page_stat(struct mem_cgroup *memcg,
324 bool *locked, unsigned long *flags) 300 bool locked, unsigned long flags)
325{ 301{
326} 302}
327 303
@@ -343,12 +319,12 @@ static inline bool mem_cgroup_oom_synchronize(bool wait)
343 return false; 319 return false;
344} 320}
345 321
346static inline void mem_cgroup_inc_page_stat(struct page *page, 322static inline void mem_cgroup_inc_page_stat(struct mem_cgroup *memcg,
347 enum mem_cgroup_stat_index idx) 323 enum mem_cgroup_stat_index idx)
348{ 324{
349} 325}
350 326
351static inline void mem_cgroup_dec_page_stat(struct page *page, 327static inline void mem_cgroup_dec_page_stat(struct mem_cgroup *memcg,
352 enum mem_cgroup_stat_index idx) 328 enum mem_cgroup_stat_index idx)
353{ 329{
354} 330}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 27eb1bfbe704..b46461116cd2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1235,7 +1235,6 @@ int __set_page_dirty_no_writeback(struct page *page);
1235int redirty_page_for_writepage(struct writeback_control *wbc, 1235int redirty_page_for_writepage(struct writeback_control *wbc,
1236 struct page *page); 1236 struct page *page);
1237void account_page_dirtied(struct page *page, struct address_space *mapping); 1237void account_page_dirtied(struct page *page, struct address_space *mapping);
1238void account_page_writeback(struct page *page);
1239int set_page_dirty(struct page *page); 1238int set_page_dirty(struct page *page);
1240int set_page_dirty_lock(struct page *page); 1239int set_page_dirty_lock(struct page *page);
1241int clear_page_dirty_for_io(struct page *page); 1240int clear_page_dirty_for_io(struct page *page);
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9e6294f32ba8..046a0a2e4c4e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -187,32 +187,17 @@ struct spi_nor {
187/** 187/**
188 * spi_nor_scan() - scan the SPI NOR 188 * spi_nor_scan() - scan the SPI NOR
189 * @nor: the spi_nor structure 189 * @nor: the spi_nor structure
190 * @id: the spi_device_id provided by the driver 190 * @name: the chip type name
191 * @mode: the read mode supported by the driver 191 * @mode: the read mode supported by the driver
192 * 192 *
193 * The drivers can use this fuction to scan the SPI NOR. 193 * The drivers can use this fuction to scan the SPI NOR.
194 * In the scanning, it will try to get all the necessary information to 194 * In the scanning, it will try to get all the necessary information to
195 * fill the mtd_info{} and the spi_nor{}. 195 * fill the mtd_info{} and the spi_nor{}.
196 * 196 *
197 * The board may assigns a spi_device_id with @id which be used to compared with 197 * The chip type name can be provided through the @name parameter.
198 * the spi_device_id detected by the scanning.
199 * 198 *
200 * Return: 0 for success, others for failure. 199 * Return: 0 for success, others for failure.
201 */ 200 */
202int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, 201int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
203 enum read_mode mode);
204extern const struct spi_device_id spi_nor_ids[];
205
206/**
207 * spi_nor_match_id() - find the spi_device_id by the name
208 * @name: the name of the spi_device_id
209 *
210 * The drivers use this function to find the spi_device_id
211 * specified by the @name.
212 *
213 * Return: returns the right spi_device_id pointer on success,
214 * and returns NULL on failure.
215 */
216const struct spi_device_id *spi_nor_match_id(char *name);
217 202
218#endif 203#endif
diff --git a/include/linux/of.h b/include/linux/of.h
index 6545e7aec7bb..29f0adc5f3e4 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -267,14 +267,12 @@ extern int of_property_read_u64(const struct device_node *np,
267extern int of_property_read_string(struct device_node *np, 267extern int of_property_read_string(struct device_node *np,
268 const char *propname, 268 const char *propname,
269 const char **out_string); 269 const char **out_string);
270extern int of_property_read_string_index(struct device_node *np,
271 const char *propname,
272 int index, const char **output);
273extern int of_property_match_string(struct device_node *np, 270extern int of_property_match_string(struct device_node *np,
274 const char *propname, 271 const char *propname,
275 const char *string); 272 const char *string);
276extern int of_property_count_strings(struct device_node *np, 273extern int of_property_read_string_helper(struct device_node *np,
277 const char *propname); 274 const char *propname,
275 const char **out_strs, size_t sz, int index);
278extern int of_device_is_compatible(const struct device_node *device, 276extern int of_device_is_compatible(const struct device_node *device,
279 const char *); 277 const char *);
280extern int of_device_is_available(const struct device_node *device); 278extern int of_device_is_available(const struct device_node *device);
@@ -486,15 +484,9 @@ static inline int of_property_read_string(struct device_node *np,
486 return -ENOSYS; 484 return -ENOSYS;
487} 485}
488 486
489static inline int of_property_read_string_index(struct device_node *np, 487static inline int of_property_read_string_helper(struct device_node *np,
490 const char *propname, int index, 488 const char *propname,
491 const char **out_string) 489 const char **out_strs, size_t sz, int index)
492{
493 return -ENOSYS;
494}
495
496static inline int of_property_count_strings(struct device_node *np,
497 const char *propname)
498{ 490{
499 return -ENOSYS; 491 return -ENOSYS;
500} 492}
@@ -668,6 +660,70 @@ static inline int of_property_count_u64_elems(const struct device_node *np,
668} 660}
669 661
670/** 662/**
663 * of_property_read_string_array() - Read an array of strings from a multiple
664 * strings property.
665 * @np: device node from which the property value is to be read.
666 * @propname: name of the property to be searched.
667 * @out_strs: output array of string pointers.
668 * @sz: number of array elements to read.
669 *
670 * Search for a property in a device tree node and retrieve a list of
671 * terminated string values (pointer to data, not a copy) in that property.
672 *
673 * If @out_strs is NULL, the number of strings in the property is returned.
674 */
675static inline int of_property_read_string_array(struct device_node *np,
676 const char *propname, const char **out_strs,
677 size_t sz)
678{
679 return of_property_read_string_helper(np, propname, out_strs, sz, 0);
680}
681
682/**
683 * of_property_count_strings() - Find and return the number of strings from a
684 * multiple strings property.
685 * @np: device node from which the property value is to be read.
686 * @propname: name of the property to be searched.
687 *
688 * Search for a property in a device tree node and retrieve the number of null
689 * terminated string contain in it. Returns the number of strings on
690 * success, -EINVAL if the property does not exist, -ENODATA if property
691 * does not have a value, and -EILSEQ if the string is not null-terminated
692 * within the length of the property data.
693 */
694static inline int of_property_count_strings(struct device_node *np,
695 const char *propname)
696{
697 return of_property_read_string_helper(np, propname, NULL, 0, 0);
698}
699
700/**
701 * of_property_read_string_index() - Find and read a string from a multiple
702 * strings property.
703 * @np: device node from which the property value is to be read.
704 * @propname: name of the property to be searched.
705 * @index: index of the string in the list of strings
706 * @out_string: pointer to null terminated return string, modified only if
707 * return value is 0.
708 *
709 * Search for a property in a device tree node and retrieve a null
710 * terminated string value (pointer to data, not a copy) in the list of strings
711 * contained in that property.
712 * Returns 0 on success, -EINVAL if the property does not exist, -ENODATA if
713 * property does not have a value, and -EILSEQ if the string is not
714 * null-terminated within the length of the property data.
715 *
716 * The out_string pointer is modified only if a valid string can be decoded.
717 */
718static inline int of_property_read_string_index(struct device_node *np,
719 const char *propname,
720 int index, const char **output)
721{
722 int rc = of_property_read_string_helper(np, propname, output, 1, index);
723 return rc < 0 ? rc : 0;
724}
725
726/**
671 * of_property_read_bool - Findfrom a property 727 * of_property_read_bool - Findfrom a property
672 * @np: device node from which the property value is to be read. 728 * @np: device node from which the property value is to be read.
673 * @propname: name of the property to be searched. 729 * @propname: name of the property to be searched.
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 5b5efae09135..ad2f67054372 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -16,7 +16,7 @@ struct reserved_mem {
16}; 16};
17 17
18struct reserved_mem_ops { 18struct reserved_mem_ops {
19 void (*device_init)(struct reserved_mem *rmem, 19 int (*device_init)(struct reserved_mem *rmem,
20 struct device *dev); 20 struct device *dev);
21 void (*device_release)(struct reserved_mem *rmem, 21 void (*device_release)(struct reserved_mem *rmem,
22 struct device *dev); 22 struct device *dev);
@@ -28,14 +28,17 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
28 _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) 28 _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)
29 29
30#ifdef CONFIG_OF_RESERVED_MEM 30#ifdef CONFIG_OF_RESERVED_MEM
31void of_reserved_mem_device_init(struct device *dev); 31int of_reserved_mem_device_init(struct device *dev);
32void of_reserved_mem_device_release(struct device *dev); 32void of_reserved_mem_device_release(struct device *dev);
33 33
34void fdt_init_reserved_mem(void); 34void fdt_init_reserved_mem(void);
35void fdt_reserved_mem_save_node(unsigned long node, const char *uname, 35void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
36 phys_addr_t base, phys_addr_t size); 36 phys_addr_t base, phys_addr_t size);
37#else 37#else
38static inline void of_reserved_mem_device_init(struct device *dev) { } 38static inline int of_reserved_mem_device_init(struct device *dev)
39{
40 return -ENOSYS;
41}
39static inline void of_reserved_mem_device_release(struct device *pdev) { } 42static inline void of_reserved_mem_device_release(struct device *pdev) { }
40 43
41static inline void fdt_init_reserved_mem(void) { } 44static inline void fdt_init_reserved_mem(void) { }
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 64dacb7288a6..24c7728ca681 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -41,8 +41,13 @@ static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)
41 41
42 if (pci_is_root_bus(pbus)) 42 if (pci_is_root_bus(pbus))
43 dev = pbus->bridge; 43 dev = pbus->bridge;
44 else 44 else {
45 /* If pbus is a virtual bus, there is no bridge to it */
46 if (!pbus->self)
47 return NULL;
48
45 dev = &pbus->self->dev; 49 dev = &pbus->self->dev;
50 }
46 51
47 return ACPI_HANDLE(dev); 52 return ACPI_HANDLE(dev);
48} 53}
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index a4a819ffb2d1..53ff1a752d7e 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -617,6 +617,21 @@ static inline void rcu_preempt_sleep_check(void)
617#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v) 617#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
618 618
619/** 619/**
620 * lockless_dereference() - safely load a pointer for later dereference
621 * @p: The pointer to load
622 *
623 * Similar to rcu_dereference(), but for situations where the pointed-to
624 * object's lifetime is managed by something other than RCU. That
625 * "something other" might be reference counting or simple immortality.
626 */
627#define lockless_dereference(p) \
628({ \
629 typeof(p) _________p1 = ACCESS_ONCE(p); \
630 smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
631 (_________p1); \
632})
633
634/**
620 * rcu_assign_pointer() - assign to RCU-protected pointer 635 * rcu_assign_pointer() - assign to RCU-protected pointer
621 * @p: pointer to assign to 636 * @p: pointer to assign to
622 * @v: value to assign (publish) 637 * @v: value to assign (publish)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d9343c25b..6c8b6f604e76 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -557,7 +557,9 @@ struct sk_buff {
557 /* fields enclosed in headers_start/headers_end are copied 557 /* fields enclosed in headers_start/headers_end are copied
558 * using a single memcpy() in __copy_skb_header() 558 * using a single memcpy() in __copy_skb_header()
559 */ 559 */
560 /* private: */
560 __u32 headers_start[0]; 561 __u32 headers_start[0];
562 /* public: */
561 563
562/* if you move pkt_type around you also must adapt those constants */ 564/* if you move pkt_type around you also must adapt those constants */
563#ifdef __BIG_ENDIAN_BITFIELD 565#ifdef __BIG_ENDIAN_BITFIELD
@@ -642,7 +644,9 @@ struct sk_buff {
642 __u16 network_header; 644 __u16 network_header;
643 __u16 mac_header; 645 __u16 mac_header;
644 646
647 /* private: */
645 __u32 headers_end[0]; 648 __u32 headers_end[0];
649 /* public: */
646 650
647 /* These elements must be at the end, see alloc_skb() for details. */ 651 /* These elements must be at the end, see alloc_skb() for details. */
648 sk_buff_data_t tail; 652 sk_buff_data_t tail;
@@ -795,15 +799,19 @@ struct sk_buff_fclones {
795 * @skb: buffer 799 * @skb: buffer
796 * 800 *
797 * Returns true is skb is a fast clone, and its clone is not freed. 801 * Returns true is skb is a fast clone, and its clone is not freed.
802 * Some drivers call skb_orphan() in their ndo_start_xmit(),
803 * so we also check that this didnt happen.
798 */ 804 */
799static inline bool skb_fclone_busy(const struct sk_buff *skb) 805static inline bool skb_fclone_busy(const struct sock *sk,
806 const struct sk_buff *skb)
800{ 807{
801 const struct sk_buff_fclones *fclones; 808 const struct sk_buff_fclones *fclones;
802 809
803 fclones = container_of(skb, struct sk_buff_fclones, skb1); 810 fclones = container_of(skb, struct sk_buff_fclones, skb1);
804 811
805 return skb->fclone == SKB_FCLONE_ORIG && 812 return skb->fclone == SKB_FCLONE_ORIG &&
806 fclones->skb2.fclone == SKB_FCLONE_CLONE; 813 fclones->skb2.fclone == SKB_FCLONE_CLONE &&
814 fclones->skb2.sk == sk;
807} 815}
808 816
809static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 817static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 26088feb6608..d9a4905e01d0 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -78,6 +78,7 @@ struct usbnet {
78# define EVENT_NO_RUNTIME_PM 9 78# define EVENT_NO_RUNTIME_PM 9
79# define EVENT_RX_KILL 10 79# define EVENT_RX_KILL 10
80# define EVENT_LINK_CHANGE 11 80# define EVENT_LINK_CHANGE 11
81# define EVENT_SET_RX_MODE 12
81}; 82};
82 83
83static inline struct usb_driver *driver_of(struct usb_interface *intf) 84static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -159,6 +160,9 @@ struct driver_info {
159 /* called by minidriver when receiving indication */ 160 /* called by minidriver when receiving indication */
160 void (*indication)(struct usbnet *dev, void *ind, int indlen); 161 void (*indication)(struct usbnet *dev, void *ind, int indlen);
161 162
163 /* rx mode change (device changes address list filtering) */
164 void (*set_rx_mode)(struct usbnet *dev);
165
162 /* for new devices, use the descriptor-reading code instead */ 166 /* for new devices, use the descriptor-reading code instead */
163 int in; /* rx endpoint */ 167 int in; /* rx endpoint */
164 int out; /* tx endpoint */ 168 int out; /* tx endpoint */
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 97f472012438..4292929392b0 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -671,6 +671,8 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
671 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr)); 671 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
672} 672}
673 673
674void ipv6_proxy_select_ident(struct sk_buff *skb);
675
674int ip6_dst_hoplimit(struct dst_entry *dst); 676int ip6_dst_hoplimit(struct dst_entry *dst);
675 677
676static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6, 678static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6,
diff --git a/include/net/netfilter/ipv4/nf_reject.h b/include/net/netfilter/ipv4/nf_reject.h
index e8427193c777..03e928a55229 100644
--- a/include/net/netfilter/ipv4/nf_reject.h
+++ b/include/net/netfilter/ipv4/nf_reject.h
@@ -1,6 +1,8 @@
1#ifndef _IPV4_NF_REJECT_H 1#ifndef _IPV4_NF_REJECT_H
2#define _IPV4_NF_REJECT_H 2#define _IPV4_NF_REJECT_H
3 3
4#include <linux/skbuff.h>
5#include <net/ip.h>
4#include <net/icmp.h> 6#include <net/icmp.h>
5 7
6static inline void nf_send_unreach(struct sk_buff *skb_in, int code) 8static inline void nf_send_unreach(struct sk_buff *skb_in, int code)
@@ -10,4 +12,12 @@ static inline void nf_send_unreach(struct sk_buff *skb_in, int code)
10 12
11void nf_send_reset(struct sk_buff *oldskb, int hook); 13void nf_send_reset(struct sk_buff *oldskb, int hook);
12 14
15const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
16 struct tcphdr *_oth, int hook);
17struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
18 const struct sk_buff *oldskb,
19 __be16 protocol, int ttl);
20void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
21 const struct tcphdr *oth);
22
13#endif /* _IPV4_NF_REJECT_H */ 23#endif /* _IPV4_NF_REJECT_H */
diff --git a/include/net/netfilter/ipv6/nf_reject.h b/include/net/netfilter/ipv6/nf_reject.h
index 48e18810a9be..23216d48abf9 100644
--- a/include/net/netfilter/ipv6/nf_reject.h
+++ b/include/net/netfilter/ipv6/nf_reject.h
@@ -15,4 +15,14 @@ nf_send_unreach6(struct net *net, struct sk_buff *skb_in, unsigned char code,
15 15
16void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook); 16void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook);
17 17
18const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
19 struct tcphdr *otcph,
20 unsigned int *otcplen, int hook);
21struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
22 const struct sk_buff *oldskb,
23 __be16 protocol, int hoplimit);
24void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
25 const struct sk_buff *oldskb,
26 const struct tcphdr *oth, unsigned int otcplen);
27
18#endif /* _IPV6_NF_REJECT_H */ 28#endif /* _IPV6_NF_REJECT_H */
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 3d7292392fac..845c596bf594 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -530,6 +530,9 @@ enum nft_chain_type {
530 NFT_CHAIN_T_MAX 530 NFT_CHAIN_T_MAX
531}; 531};
532 532
533int nft_chain_validate_dependency(const struct nft_chain *chain,
534 enum nft_chain_type type);
535
533struct nft_stats { 536struct nft_stats {
534 u64 bytes; 537 u64 bytes;
535 u64 pkts; 538 u64 pkts;
diff --git a/include/net/netfilter/nft_masq.h b/include/net/netfilter/nft_masq.h
index c72729f954f4..e2a518b60e19 100644
--- a/include/net/netfilter/nft_masq.h
+++ b/include/net/netfilter/nft_masq.h
@@ -13,4 +13,7 @@ int nft_masq_init(const struct nft_ctx *ctx,
13 13
14int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr); 14int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr);
15 15
16int nft_masq_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
17 const struct nft_data **data);
18
16#endif /* _NFT_MASQ_H_ */ 19#endif /* _NFT_MASQ_H_ */
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index e64583560701..56ed843969ca 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -67,8 +67,9 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
67 if (!sdev->tagged_supported) 67 if (!sdev->tagged_supported)
68 return; 68 return;
69 69
70 if (!shost_use_blk_mq(sdev->host) && 70 if (shost_use_blk_mq(sdev->host))
71 !blk_queue_tagged(sdev->request_queue)) 71 queue_flag_set_unlocked(QUEUE_FLAG_QUEUED, sdev->request_queue);
72 else if (!blk_queue_tagged(sdev->request_queue))
72 blk_queue_init_tags(sdev->request_queue, depth, 73 blk_queue_init_tags(sdev->request_queue, depth,
73 sdev->host->bqt); 74 sdev->host->bqt);
74 75
@@ -81,8 +82,7 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
81 **/ 82 **/
82static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) 83static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
83{ 84{
84 if (!shost_use_blk_mq(sdev->host) && 85 if (blk_queue_tagged(sdev->request_queue))
85 blk_queue_tagged(sdev->request_queue))
86 blk_queue_free_tags(sdev->request_queue); 86 blk_queue_free_tags(sdev->request_queue);
87 scsi_adjust_queue_depth(sdev, 0, depth); 87 scsi_adjust_queue_depth(sdev, 0, depth);
88} 88}
diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index 9b56f37148cf..e335e7d8c6c2 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -660,18 +660,18 @@ TRACE_EVENT(rcu_torture_read,
660/* 660/*
661 * Tracepoint for _rcu_barrier() execution. The string "s" describes 661 * Tracepoint for _rcu_barrier() execution. The string "s" describes
662 * the _rcu_barrier phase: 662 * the _rcu_barrier phase:
663 * "Begin": rcu_barrier_callback() started. 663 * "Begin": _rcu_barrier() started.
664 * "Check": rcu_barrier_callback() checking for piggybacking. 664 * "Check": _rcu_barrier() checking for piggybacking.
665 * "EarlyExit": rcu_barrier_callback() piggybacked, thus early exit. 665 * "EarlyExit": _rcu_barrier() piggybacked, thus early exit.
666 * "Inc1": rcu_barrier_callback() piggyback check counter incremented. 666 * "Inc1": _rcu_barrier() piggyback check counter incremented.
667 * "Offline": rcu_barrier_callback() found offline CPU 667 * "OfflineNoCB": _rcu_barrier() found callback on never-online CPU
668 * "OnlineNoCB": rcu_barrier_callback() found online no-CBs CPU. 668 * "OnlineNoCB": _rcu_barrier() found online no-CBs CPU.
669 * "OnlineQ": rcu_barrier_callback() found online CPU with callbacks. 669 * "OnlineQ": _rcu_barrier() found online CPU with callbacks.
670 * "OnlineNQ": rcu_barrier_callback() found online CPU, no callbacks. 670 * "OnlineNQ": _rcu_barrier() found online CPU, no callbacks.
671 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU. 671 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
672 * "CB": An rcu_barrier_callback() invoked a callback, not the last. 672 * "CB": An rcu_barrier_callback() invoked a callback, not the last.
673 * "LastCB": An rcu_barrier_callback() invoked the last callback. 673 * "LastCB": An rcu_barrier_callback() invoked the last callback.
674 * "Inc2": rcu_barrier_callback() piggyback check counter incremented. 674 * "Inc2": _rcu_barrier() piggyback check counter incremented.
675 * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument 675 * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
676 * is the count of remaining callbacks, and "done" is the piggybacking count. 676 * is the count of remaining callbacks, and "done" is the piggybacking count.
677 */ 677 */
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 1874ebe9ac1e..a1d7e931ab72 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -739,6 +739,13 @@ struct input_keymap_entry {
739#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 739#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
740#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 740#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
741 741
742#define KEY_KBDINPUTASSIST_PREV 0x260
743#define KEY_KBDINPUTASSIST_NEXT 0x261
744#define KEY_KBDINPUTASSIST_PREVGROUP 0x262
745#define KEY_KBDINPUTASSIST_NEXTGROUP 0x263
746#define KEY_KBDINPUTASSIST_ACCEPT 0x264
747#define KEY_KBDINPUTASSIST_CANCEL 0x265
748
742#define BTN_TRIGGER_HAPPY 0x2c0 749#define BTN_TRIGGER_HAPPY 0x2c0
743#define BTN_TRIGGER_HAPPY1 0x2c0 750#define BTN_TRIGGER_HAPPY1 0x2c0
744#define BTN_TRIGGER_HAPPY2 0x2c1 751#define BTN_TRIGGER_HAPPY2 0x2c1
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 9269de254874..9d845404d875 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -364,7 +364,7 @@ struct perf_event_mmap_page {
364 /* 364 /*
365 * Bits needed to read the hw events in user-space. 365 * Bits needed to read the hw events in user-space.
366 * 366 *
367 * u32 seq, time_mult, time_shift, idx, width; 367 * u32 seq, time_mult, time_shift, index, width;
368 * u64 count, enabled, running; 368 * u64 count, enabled, running;
369 * u64 cyc, time_offset; 369 * u64 cyc, time_offset;
370 * s64 pmc = 0; 370 * s64 pmc = 0;
@@ -383,11 +383,11 @@ struct perf_event_mmap_page {
383 * time_shift = pc->time_shift; 383 * time_shift = pc->time_shift;
384 * } 384 * }
385 * 385 *
386 * idx = pc->index; 386 * index = pc->index;
387 * count = pc->offset; 387 * count = pc->offset;
388 * if (pc->cap_usr_rdpmc && idx) { 388 * if (pc->cap_user_rdpmc && index) {
389 * width = pc->pmc_width; 389 * width = pc->pmc_width;
390 * pmc = rdpmc(idx - 1); 390 * pmc = rdpmc(index - 1);
391 * } 391 * }
392 * 392 *
393 * barrier(); 393 * barrier();
@@ -415,7 +415,7 @@ struct perf_event_mmap_page {
415 }; 415 };
416 416
417 /* 417 /*
418 * If cap_usr_rdpmc this field provides the bit-width of the value 418 * If cap_user_rdpmc this field provides the bit-width of the value
419 * read using the rdpmc() or equivalent instruction. This can be used 419 * read using the rdpmc() or equivalent instruction. This can be used
420 * to sign extend the result like: 420 * to sign extend the result like:
421 * 421 *
@@ -439,10 +439,10 @@ struct perf_event_mmap_page {
439 * 439 *
440 * Where time_offset,time_mult,time_shift and cyc are read in the 440 * Where time_offset,time_mult,time_shift and cyc are read in the
441 * seqcount loop described above. This delta can then be added to 441 * seqcount loop described above. This delta can then be added to
442 * enabled and possible running (if idx), improving the scaling: 442 * enabled and possible running (if index), improving the scaling:
443 * 443 *
444 * enabled += delta; 444 * enabled += delta;
445 * if (idx) 445 * if (index)
446 * running += delta; 446 * running += delta;
447 * 447 *
448 * quot = count / running; 448 * quot = count / running;
diff --git a/include/uapi/linux/sched.h b/include/uapi/linux/sched.h
index 34f9d7387d13..b932be9f5c5b 100644
--- a/include/uapi/linux/sched.h
+++ b/include/uapi/linux/sched.h
@@ -13,7 +13,7 @@
13#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ 13#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
14#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */ 14#define CLONE_PARENT 0x00008000 /* set if we want to have the same parent as the cloner */
15#define CLONE_THREAD 0x00010000 /* Same thread group? */ 15#define CLONE_THREAD 0x00010000 /* Same thread group? */
16#define CLONE_NEWNS 0x00020000 /* New namespace group? */ 16#define CLONE_NEWNS 0x00020000 /* New mount namespace group */
17#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */ 17#define CLONE_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
18#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */ 18#define CLONE_SETTLS 0x00080000 /* create a new TLS for the child */
19#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */ 19#define CLONE_PARENT_SETTID 0x00100000 /* set the TID in the parent */
diff --git a/init/Kconfig b/init/Kconfig
index 3ee28ae02cc8..2081a4d3d917 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1341,6 +1341,10 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
1341config HAVE_PCSPKR_PLATFORM 1341config HAVE_PCSPKR_PLATFORM
1342 bool 1342 bool
1343 1343
1344# interpreter that classic socket filters depend on
1345config BPF
1346 bool
1347
1344menuconfig EXPERT 1348menuconfig EXPERT
1345 bool "Configure standard kernel features (expert users)" 1349 bool "Configure standard kernel features (expert users)"
1346 # Unhide debug options, to make the on-by-default options visible 1350 # Unhide debug options, to make the on-by-default options visible
@@ -1521,6 +1525,16 @@ config EVENTFD
1521 1525
1522 If unsure, say Y. 1526 If unsure, say Y.
1523 1527
1528# syscall, maps, verifier
1529config BPF_SYSCALL
1530 bool "Enable bpf() system call" if EXPERT
1531 select ANON_INODES
1532 select BPF
1533 default n
1534 help
1535 Enable the bpf() system call that allows to manipulate eBPF
1536 programs and maps via file descriptors.
1537
1524config SHMEM 1538config SHMEM
1525 bool "Use full shmem filesystem" if EXPERT 1539 bool "Use full shmem filesystem" if EXPERT
1526 default y 1540 default y
diff --git a/kernel/Makefile b/kernel/Makefile
index dc5c77544fd6..17ea6d4a9a24 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -86,7 +86,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/
86obj-$(CONFIG_TRACEPOINTS) += trace/ 86obj-$(CONFIG_TRACEPOINTS) += trace/
87obj-$(CONFIG_IRQ_WORK) += irq_work.o 87obj-$(CONFIG_IRQ_WORK) += irq_work.o
88obj-$(CONFIG_CPU_PM) += cpu_pm.o 88obj-$(CONFIG_CPU_PM) += cpu_pm.o
89obj-$(CONFIG_NET) += bpf/ 89obj-$(CONFIG_BPF) += bpf/
90 90
91obj-$(CONFIG_PERF_EVENTS) += events/ 91obj-$(CONFIG_PERF_EVENTS) += events/
92 92
diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 45427239f375..0daf7f6ae7df 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -1,5 +1,5 @@
1obj-y := core.o syscall.o verifier.o 1obj-y := core.o
2 2obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o
3ifdef CONFIG_TEST_BPF 3ifdef CONFIG_TEST_BPF
4obj-y += test_stub.o 4obj-$(CONFIG_BPF_SYSCALL) += test_stub.o
5endif 5endif
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index f0c30c59b317..d6594e457a25 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -655,3 +655,12 @@ void bpf_prog_free(struct bpf_prog *fp)
655 schedule_work(&aux->work); 655 schedule_work(&aux->work);
656} 656}
657EXPORT_SYMBOL_GPL(bpf_prog_free); 657EXPORT_SYMBOL_GPL(bpf_prog_free);
658
659/* To execute LD_ABS/LD_IND instructions __bpf_prog_run() may call
660 * skb_copy_bits(), so provide a weak definition of it for NET-less config.
661 */
662int __weak skb_copy_bits(const struct sk_buff *skb, int offset, void *to,
663 int len)
664{
665 return -EFAULT;
666}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 801f5f3b9307..9f81818f2941 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1409,7 +1409,8 @@ static bool states_equal(struct verifier_state *old, struct verifier_state *cur)
1409 if (memcmp(&old->regs[i], &cur->regs[i], 1409 if (memcmp(&old->regs[i], &cur->regs[i],
1410 sizeof(old->regs[0])) != 0) { 1410 sizeof(old->regs[0])) != 0) {
1411 if (old->regs[i].type == NOT_INIT || 1411 if (old->regs[i].type == NOT_INIT ||
1412 old->regs[i].type == UNKNOWN_VALUE) 1412 (old->regs[i].type == UNKNOWN_VALUE &&
1413 cur->regs[i].type != NOT_INIT))
1413 continue; 1414 continue;
1414 return false; 1415 return false;
1415 } 1416 }
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 5664985c46a0..937ecdfdf258 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -107,46 +107,6 @@ void context_tracking_user_enter(void)
107} 107}
108NOKPROBE_SYMBOL(context_tracking_user_enter); 108NOKPROBE_SYMBOL(context_tracking_user_enter);
109 109
110#ifdef CONFIG_PREEMPT
111/**
112 * preempt_schedule_context - preempt_schedule called by tracing
113 *
114 * The tracing infrastructure uses preempt_enable_notrace to prevent
115 * recursion and tracing preempt enabling caused by the tracing
116 * infrastructure itself. But as tracing can happen in areas coming
117 * from userspace or just about to enter userspace, a preempt enable
118 * can occur before user_exit() is called. This will cause the scheduler
119 * to be called when the system is still in usermode.
120 *
121 * To prevent this, the preempt_enable_notrace will use this function
122 * instead of preempt_schedule() to exit user context if needed before
123 * calling the scheduler.
124 */
125asmlinkage __visible void __sched notrace preempt_schedule_context(void)
126{
127 enum ctx_state prev_ctx;
128
129 if (likely(!preemptible()))
130 return;
131
132 /*
133 * Need to disable preemption in case user_exit() is traced
134 * and the tracer calls preempt_enable_notrace() causing
135 * an infinite recursion.
136 */
137 preempt_disable_notrace();
138 prev_ctx = exception_enter();
139 preempt_enable_no_resched_notrace();
140
141 preempt_schedule();
142
143 preempt_disable_notrace();
144 exception_exit(prev_ctx);
145 preempt_enable_notrace();
146}
147EXPORT_SYMBOL_GPL(preempt_schedule_context);
148#endif /* CONFIG_PREEMPT */
149
150/** 110/**
151 * context_tracking_user_exit - Inform the context tracking that the CPU is 111 * context_tracking_user_exit - Inform the context tracking that the CPU is
152 * exiting userspace mode and entering the kernel. 112 * exiting userspace mode and entering the kernel.
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 356450f09c1f..90a3d017b90c 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -64,6 +64,8 @@ static struct {
64 * an ongoing cpu hotplug operation. 64 * an ongoing cpu hotplug operation.
65 */ 65 */
66 int refcount; 66 int refcount;
67 /* And allows lockless put_online_cpus(). */
68 atomic_t puts_pending;
67 69
68#ifdef CONFIG_DEBUG_LOCK_ALLOC 70#ifdef CONFIG_DEBUG_LOCK_ALLOC
69 struct lockdep_map dep_map; 71 struct lockdep_map dep_map;
@@ -113,7 +115,11 @@ void put_online_cpus(void)
113{ 115{
114 if (cpu_hotplug.active_writer == current) 116 if (cpu_hotplug.active_writer == current)
115 return; 117 return;
116 mutex_lock(&cpu_hotplug.lock); 118 if (!mutex_trylock(&cpu_hotplug.lock)) {
119 atomic_inc(&cpu_hotplug.puts_pending);
120 cpuhp_lock_release();
121 return;
122 }
117 123
118 if (WARN_ON(!cpu_hotplug.refcount)) 124 if (WARN_ON(!cpu_hotplug.refcount))
119 cpu_hotplug.refcount++; /* try to fix things up */ 125 cpu_hotplug.refcount++; /* try to fix things up */
@@ -155,6 +161,12 @@ void cpu_hotplug_begin(void)
155 cpuhp_lock_acquire(); 161 cpuhp_lock_acquire();
156 for (;;) { 162 for (;;) {
157 mutex_lock(&cpu_hotplug.lock); 163 mutex_lock(&cpu_hotplug.lock);
164 if (atomic_read(&cpu_hotplug.puts_pending)) {
165 int delta;
166
167 delta = atomic_xchg(&cpu_hotplug.puts_pending, 0);
168 cpu_hotplug.refcount -= delta;
169 }
158 if (likely(!cpu_hotplug.refcount)) 170 if (likely(!cpu_hotplug.refcount))
159 break; 171 break;
160 __set_current_state(TASK_UNINTERRUPTIBLE); 172 __set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1425d07018de..2b02c9fda790 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6071,11 +6071,6 @@ static int perf_swevent_init(struct perf_event *event)
6071 return 0; 6071 return 0;
6072} 6072}
6073 6073
6074static int perf_swevent_event_idx(struct perf_event *event)
6075{
6076 return 0;
6077}
6078
6079static struct pmu perf_swevent = { 6074static struct pmu perf_swevent = {
6080 .task_ctx_nr = perf_sw_context, 6075 .task_ctx_nr = perf_sw_context,
6081 6076
@@ -6085,8 +6080,6 @@ static struct pmu perf_swevent = {
6085 .start = perf_swevent_start, 6080 .start = perf_swevent_start,
6086 .stop = perf_swevent_stop, 6081 .stop = perf_swevent_stop,
6087 .read = perf_swevent_read, 6082 .read = perf_swevent_read,
6088
6089 .event_idx = perf_swevent_event_idx,
6090}; 6083};
6091 6084
6092#ifdef CONFIG_EVENT_TRACING 6085#ifdef CONFIG_EVENT_TRACING
@@ -6204,8 +6197,6 @@ static struct pmu perf_tracepoint = {
6204 .start = perf_swevent_start, 6197 .start = perf_swevent_start,
6205 .stop = perf_swevent_stop, 6198 .stop = perf_swevent_stop,
6206 .read = perf_swevent_read, 6199 .read = perf_swevent_read,
6207
6208 .event_idx = perf_swevent_event_idx,
6209}; 6200};
6210 6201
6211static inline void perf_tp_register(void) 6202static inline void perf_tp_register(void)
@@ -6431,8 +6422,6 @@ static struct pmu perf_cpu_clock = {
6431 .start = cpu_clock_event_start, 6422 .start = cpu_clock_event_start,
6432 .stop = cpu_clock_event_stop, 6423 .stop = cpu_clock_event_stop,
6433 .read = cpu_clock_event_read, 6424 .read = cpu_clock_event_read,
6434
6435 .event_idx = perf_swevent_event_idx,
6436}; 6425};
6437 6426
6438/* 6427/*
@@ -6511,8 +6500,6 @@ static struct pmu perf_task_clock = {
6511 .start = task_clock_event_start, 6500 .start = task_clock_event_start,
6512 .stop = task_clock_event_stop, 6501 .stop = task_clock_event_stop,
6513 .read = task_clock_event_read, 6502 .read = task_clock_event_read,
6514
6515 .event_idx = perf_swevent_event_idx,
6516}; 6503};
6517 6504
6518static void perf_pmu_nop_void(struct pmu *pmu) 6505static void perf_pmu_nop_void(struct pmu *pmu)
@@ -6542,7 +6529,7 @@ static void perf_pmu_cancel_txn(struct pmu *pmu)
6542 6529
6543static int perf_event_idx_default(struct perf_event *event) 6530static int perf_event_idx_default(struct perf_event *event)
6544{ 6531{
6545 return event->hw.idx + 1; 6532 return 0;
6546} 6533}
6547 6534
6548/* 6535/*
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 1559fb0b9296..9803a6600d49 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -605,11 +605,6 @@ static void hw_breakpoint_stop(struct perf_event *bp, int flags)
605 bp->hw.state = PERF_HES_STOPPED; 605 bp->hw.state = PERF_HES_STOPPED;
606} 606}
607 607
608static int hw_breakpoint_event_idx(struct perf_event *bp)
609{
610 return 0;
611}
612
613static struct pmu perf_breakpoint = { 608static struct pmu perf_breakpoint = {
614 .task_ctx_nr = perf_sw_context, /* could eventually get its own */ 609 .task_ctx_nr = perf_sw_context, /* could eventually get its own */
615 610
@@ -619,8 +614,6 @@ static struct pmu perf_breakpoint = {
619 .start = hw_breakpoint_start, 614 .start = hw_breakpoint_start,
620 .stop = hw_breakpoint_stop, 615 .stop = hw_breakpoint_stop,
621 .read = hw_breakpoint_pmu_read, 616 .read = hw_breakpoint_pmu_read,
622
623 .event_idx = hw_breakpoint_event_idx,
624}; 617};
625 618
626int __init init_hw_breakpoint(void) 619int __init init_hw_breakpoint(void)
diff --git a/kernel/futex.c b/kernel/futex.c
index f3a3a071283c..63678b573d61 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -143,9 +143,8 @@
143 * 143 *
144 * Where (A) orders the waiters increment and the futex value read through 144 * Where (A) orders the waiters increment and the futex value read through
145 * atomic operations (see hb_waiters_inc) and where (B) orders the write 145 * atomic operations (see hb_waiters_inc) and where (B) orders the write
146 * to futex and the waiters read -- this is done by the barriers in 146 * to futex and the waiters read -- this is done by the barriers for both
147 * get_futex_key_refs(), through either ihold or atomic_inc, depending on the 147 * shared and private futexes in get_futex_key_refs().
148 * futex type.
149 * 148 *
150 * This yields the following case (where X:=waiters, Y:=futex): 149 * This yields the following case (where X:=waiters, Y:=futex):
151 * 150 *
@@ -344,13 +343,20 @@ static void get_futex_key_refs(union futex_key *key)
344 futex_get_mm(key); /* implies MB (B) */ 343 futex_get_mm(key); /* implies MB (B) */
345 break; 344 break;
346 default: 345 default:
346 /*
347 * Private futexes do not hold reference on an inode or
348 * mm, therefore the only purpose of calling get_futex_key_refs
349 * is because we need the barrier for the lockless waiter check.
350 */
347 smp_mb(); /* explicit MB (B) */ 351 smp_mb(); /* explicit MB (B) */
348 } 352 }
349} 353}
350 354
351/* 355/*
352 * Drop a reference to the resource addressed by a key. 356 * Drop a reference to the resource addressed by a key.
353 * The hash bucket spinlock must not be held. 357 * The hash bucket spinlock must not be held. This is
358 * a no-op for private futexes, see comment in the get
359 * counterpart.
354 */ 360 */
355static void drop_futex_key_refs(union futex_key *key) 361static void drop_futex_key_refs(union futex_key *key)
356{ 362{
@@ -641,8 +647,14 @@ static struct futex_pi_state * alloc_pi_state(void)
641 return pi_state; 647 return pi_state;
642} 648}
643 649
650/*
651 * Must be called with the hb lock held.
652 */
644static void free_pi_state(struct futex_pi_state *pi_state) 653static void free_pi_state(struct futex_pi_state *pi_state)
645{ 654{
655 if (!pi_state)
656 return;
657
646 if (!atomic_dec_and_test(&pi_state->refcount)) 658 if (!atomic_dec_and_test(&pi_state->refcount))
647 return; 659 return;
648 660
@@ -1521,15 +1533,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
1521 } 1533 }
1522 1534
1523retry: 1535retry:
1524 if (pi_state != NULL) {
1525 /*
1526 * We will have to lookup the pi_state again, so free this one
1527 * to keep the accounting correct.
1528 */
1529 free_pi_state(pi_state);
1530 pi_state = NULL;
1531 }
1532
1533 ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ); 1536 ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ);
1534 if (unlikely(ret != 0)) 1537 if (unlikely(ret != 0))
1535 goto out; 1538 goto out;
@@ -1619,6 +1622,8 @@ retry_private:
1619 case 0: 1622 case 0:
1620 break; 1623 break;
1621 case -EFAULT: 1624 case -EFAULT:
1625 free_pi_state(pi_state);
1626 pi_state = NULL;
1622 double_unlock_hb(hb1, hb2); 1627 double_unlock_hb(hb1, hb2);
1623 hb_waiters_dec(hb2); 1628 hb_waiters_dec(hb2);
1624 put_futex_key(&key2); 1629 put_futex_key(&key2);
@@ -1634,6 +1639,8 @@ retry_private:
1634 * exit to complete. 1639 * exit to complete.
1635 * - The user space value changed. 1640 * - The user space value changed.
1636 */ 1641 */
1642 free_pi_state(pi_state);
1643 pi_state = NULL;
1637 double_unlock_hb(hb1, hb2); 1644 double_unlock_hb(hb1, hb2);
1638 hb_waiters_dec(hb2); 1645 hb_waiters_dec(hb2);
1639 put_futex_key(&key2); 1646 put_futex_key(&key2);
@@ -1710,6 +1717,7 @@ retry_private:
1710 } 1717 }
1711 1718
1712out_unlock: 1719out_unlock:
1720 free_pi_state(pi_state);
1713 double_unlock_hb(hb1, hb2); 1721 double_unlock_hb(hb1, hb2);
1714 hb_waiters_dec(hb2); 1722 hb_waiters_dec(hb2);
1715 1723
@@ -1727,8 +1735,6 @@ out_put_keys:
1727out_put_key1: 1735out_put_key1:
1728 put_futex_key(&key1); 1736 put_futex_key(&key1);
1729out: 1737out:
1730 if (pi_state != NULL)
1731 free_pi_state(pi_state);
1732 return ret ? ret : task_count; 1738 return ret ? ret : task_count;
1733} 1739}
1734 1740
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index cf66c5c8458e..3b7408759bdf 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -35,7 +35,7 @@ config GCOV_KERNEL
35config GCOV_PROFILE_ALL 35config GCOV_PROFILE_ALL
36 bool "Profile entire Kernel" 36 bool "Profile entire Kernel"
37 depends on GCOV_KERNEL 37 depends on GCOV_KERNEL
38 depends on SUPERH || S390 || X86 || PPC || MICROBLAZE || ARM 38 depends on SUPERH || S390 || X86 || PPC || MICROBLAZE || ARM || ARM64
39 default n 39 default n
40 ---help--- 40 ---help---
41 This options activates profiling for the entire kernel. 41 This options activates profiling for the entire kernel.
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 8637e041a247..80f7a6d00519 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -196,12 +196,34 @@ int __request_module(bool wait, const char *fmt, ...)
196EXPORT_SYMBOL(__request_module); 196EXPORT_SYMBOL(__request_module);
197#endif /* CONFIG_MODULES */ 197#endif /* CONFIG_MODULES */
198 198
199static void call_usermodehelper_freeinfo(struct subprocess_info *info)
200{
201 if (info->cleanup)
202 (*info->cleanup)(info);
203 kfree(info);
204}
205
206static void umh_complete(struct subprocess_info *sub_info)
207{
208 struct completion *comp = xchg(&sub_info->complete, NULL);
209 /*
210 * See call_usermodehelper_exec(). If xchg() returns NULL
211 * we own sub_info, the UMH_KILLABLE caller has gone away
212 * or the caller used UMH_NO_WAIT.
213 */
214 if (comp)
215 complete(comp);
216 else
217 call_usermodehelper_freeinfo(sub_info);
218}
219
199/* 220/*
200 * This is the task which runs the usermode application 221 * This is the task which runs the usermode application
201 */ 222 */
202static int ____call_usermodehelper(void *data) 223static int ____call_usermodehelper(void *data)
203{ 224{
204 struct subprocess_info *sub_info = data; 225 struct subprocess_info *sub_info = data;
226 int wait = sub_info->wait & ~UMH_KILLABLE;
205 struct cred *new; 227 struct cred *new;
206 int retval; 228 int retval;
207 229
@@ -221,7 +243,7 @@ static int ____call_usermodehelper(void *data)
221 retval = -ENOMEM; 243 retval = -ENOMEM;
222 new = prepare_kernel_cred(current); 244 new = prepare_kernel_cred(current);
223 if (!new) 245 if (!new)
224 goto fail; 246 goto out;
225 247
226 spin_lock(&umh_sysctl_lock); 248 spin_lock(&umh_sysctl_lock);
227 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset); 249 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset);
@@ -233,7 +255,7 @@ static int ____call_usermodehelper(void *data)
233 retval = sub_info->init(sub_info, new); 255 retval = sub_info->init(sub_info, new);
234 if (retval) { 256 if (retval) {
235 abort_creds(new); 257 abort_creds(new);
236 goto fail; 258 goto out;
237 } 259 }
238 } 260 }
239 261
@@ -242,12 +264,13 @@ static int ____call_usermodehelper(void *data)
242 retval = do_execve(getname_kernel(sub_info->path), 264 retval = do_execve(getname_kernel(sub_info->path),
243 (const char __user *const __user *)sub_info->argv, 265 (const char __user *const __user *)sub_info->argv,
244 (const char __user *const __user *)sub_info->envp); 266 (const char __user *const __user *)sub_info->envp);
267out:
268 sub_info->retval = retval;
269 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
270 if (wait != UMH_WAIT_PROC)
271 umh_complete(sub_info);
245 if (!retval) 272 if (!retval)
246 return 0; 273 return 0;
247
248 /* Exec failed? */
249fail:
250 sub_info->retval = retval;
251 do_exit(0); 274 do_exit(0);
252} 275}
253 276
@@ -258,26 +281,6 @@ static int call_helper(void *data)
258 return ____call_usermodehelper(data); 281 return ____call_usermodehelper(data);
259} 282}
260 283
261static void call_usermodehelper_freeinfo(struct subprocess_info *info)
262{
263 if (info->cleanup)
264 (*info->cleanup)(info);
265 kfree(info);
266}
267
268static void umh_complete(struct subprocess_info *sub_info)
269{
270 struct completion *comp = xchg(&sub_info->complete, NULL);
271 /*
272 * See call_usermodehelper_exec(). If xchg() returns NULL
273 * we own sub_info, the UMH_KILLABLE caller has gone away.
274 */
275 if (comp)
276 complete(comp);
277 else
278 call_usermodehelper_freeinfo(sub_info);
279}
280
281/* Keventd can't block, but this (a child) can. */ 284/* Keventd can't block, but this (a child) can. */
282static int wait_for_helper(void *data) 285static int wait_for_helper(void *data)
283{ 286{
@@ -336,18 +339,8 @@ static void __call_usermodehelper(struct work_struct *work)
336 kmod_thread_locker = NULL; 339 kmod_thread_locker = NULL;
337 } 340 }
338 341
339 switch (wait) { 342 if (pid < 0) {
340 case UMH_NO_WAIT: 343 sub_info->retval = pid;
341 call_usermodehelper_freeinfo(sub_info);
342 break;
343
344 case UMH_WAIT_PROC:
345 if (pid > 0)
346 break;
347 /* FALLTHROUGH */
348 case UMH_WAIT_EXEC:
349 if (pid < 0)
350 sub_info->retval = pid;
351 umh_complete(sub_info); 344 umh_complete(sub_info);
352 } 345 }
353} 346}
@@ -588,7 +581,12 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
588 goto out; 581 goto out;
589 } 582 }
590 583
591 sub_info->complete = &done; 584 /*
585 * Set the completion pointer only if there is a waiter.
586 * This makes it possible to use umh_complete to free
587 * the data structure in case of UMH_NO_WAIT.
588 */
589 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done;
592 sub_info->wait = wait; 590 sub_info->wait = wait;
593 591
594 queue_work(khelper_wq, &sub_info->work); 592 queue_work(khelper_wq, &sub_info->work);
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a9dfa79b6bab..1f35a3478f3c 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -502,8 +502,14 @@ int hibernation_restore(int platform_mode)
502 error = dpm_suspend_start(PMSG_QUIESCE); 502 error = dpm_suspend_start(PMSG_QUIESCE);
503 if (!error) { 503 if (!error) {
504 error = resume_target_kernel(platform_mode); 504 error = resume_target_kernel(platform_mode);
505 dpm_resume_end(PMSG_RECOVER); 505 /*
506 * The above should either succeed and jump to the new kernel,
507 * or return with an error. Otherwise things are just
508 * undefined, so let's be paranoid.
509 */
510 BUG_ON(!error);
506 } 511 }
512 dpm_resume_end(PMSG_RECOVER);
507 pm_restore_gfp_mask(); 513 pm_restore_gfp_mask();
508 resume_console(); 514 resume_console();
509 pm_restore_console(); 515 pm_restore_console();
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 133e47223095..9815447d22e0 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3299,11 +3299,16 @@ static void _rcu_barrier(struct rcu_state *rsp)
3299 continue; 3299 continue;
3300 rdp = per_cpu_ptr(rsp->rda, cpu); 3300 rdp = per_cpu_ptr(rsp->rda, cpu);
3301 if (rcu_is_nocb_cpu(cpu)) { 3301 if (rcu_is_nocb_cpu(cpu)) {
3302 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu, 3302 if (!rcu_nocb_cpu_needs_barrier(rsp, cpu)) {
3303 rsp->n_barrier_done); 3303 _rcu_barrier_trace(rsp, "OfflineNoCB", cpu,
3304 atomic_inc(&rsp->barrier_cpu_count); 3304 rsp->n_barrier_done);
3305 __call_rcu(&rdp->barrier_head, rcu_barrier_callback, 3305 } else {
3306 rsp, cpu, 0); 3306 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu,
3307 rsp->n_barrier_done);
3308 atomic_inc(&rsp->barrier_cpu_count);
3309 __call_rcu(&rdp->barrier_head,
3310 rcu_barrier_callback, rsp, cpu, 0);
3311 }
3307 } else if (ACCESS_ONCE(rdp->qlen)) { 3312 } else if (ACCESS_ONCE(rdp->qlen)) {
3308 _rcu_barrier_trace(rsp, "OnlineQ", cpu, 3313 _rcu_barrier_trace(rsp, "OnlineQ", cpu,
3309 rsp->n_barrier_done); 3314 rsp->n_barrier_done);
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index d03764652d91..bbdc45d8d74f 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -587,6 +587,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu);
587static void print_cpu_stall_info_end(void); 587static void print_cpu_stall_info_end(void);
588static void zero_cpu_stall_ticks(struct rcu_data *rdp); 588static void zero_cpu_stall_ticks(struct rcu_data *rdp);
589static void increment_cpu_stall_ticks(void); 589static void increment_cpu_stall_ticks(void);
590static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu);
590static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq); 591static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq);
591static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp); 592static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp);
592static void rcu_init_one_nocb(struct rcu_node *rnp); 593static void rcu_init_one_nocb(struct rcu_node *rnp);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 387dd4599344..c1d7f27bd38f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2050,6 +2050,33 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force)
2050} 2050}
2051 2051
2052/* 2052/*
2053 * Does the specified CPU need an RCU callback for the specified flavor
2054 * of rcu_barrier()?
2055 */
2056static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu)
2057{
2058 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
2059 struct rcu_head *rhp;
2060
2061 /* No-CBs CPUs might have callbacks on any of three lists. */
2062 rhp = ACCESS_ONCE(rdp->nocb_head);
2063 if (!rhp)
2064 rhp = ACCESS_ONCE(rdp->nocb_gp_head);
2065 if (!rhp)
2066 rhp = ACCESS_ONCE(rdp->nocb_follower_head);
2067
2068 /* Having no rcuo kthread but CBs after scheduler starts is bad! */
2069 if (!ACCESS_ONCE(rdp->nocb_kthread) && rhp) {
2070 /* RCU callback enqueued before CPU first came online??? */
2071 pr_err("RCU: Never-onlined no-CBs CPU %d has CB %p\n",
2072 cpu, rhp->func);
2073 WARN_ON_ONCE(1);
2074 }
2075
2076 return !!rhp;
2077}
2078
2079/*
2053 * Enqueue the specified string of rcu_head structures onto the specified 2080 * Enqueue the specified string of rcu_head structures onto the specified
2054 * CPU's no-CBs lists. The CPU is specified by rdp, the head of the 2081 * CPU's no-CBs lists. The CPU is specified by rdp, the head of the
2055 * string by rhp, and the tail of the string by rhtp. The non-lazy/lazy 2082 * string by rhp, and the tail of the string by rhtp. The non-lazy/lazy
@@ -2642,6 +2669,12 @@ static bool init_nocb_callback_list(struct rcu_data *rdp)
2642 2669
2643#else /* #ifdef CONFIG_RCU_NOCB_CPU */ 2670#else /* #ifdef CONFIG_RCU_NOCB_CPU */
2644 2671
2672static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu)
2673{
2674 WARN_ON_ONCE(1); /* Should be dead code. */
2675 return false;
2676}
2677
2645static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp) 2678static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
2646{ 2679{
2647} 2680}
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 44999505e1bf..240157c13ddc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2951,6 +2951,47 @@ asmlinkage __visible void __sched notrace preempt_schedule(void)
2951} 2951}
2952NOKPROBE_SYMBOL(preempt_schedule); 2952NOKPROBE_SYMBOL(preempt_schedule);
2953EXPORT_SYMBOL(preempt_schedule); 2953EXPORT_SYMBOL(preempt_schedule);
2954
2955#ifdef CONFIG_CONTEXT_TRACKING
2956/**
2957 * preempt_schedule_context - preempt_schedule called by tracing
2958 *
2959 * The tracing infrastructure uses preempt_enable_notrace to prevent
2960 * recursion and tracing preempt enabling caused by the tracing
2961 * infrastructure itself. But as tracing can happen in areas coming
2962 * from userspace or just about to enter userspace, a preempt enable
2963 * can occur before user_exit() is called. This will cause the scheduler
2964 * to be called when the system is still in usermode.
2965 *
2966 * To prevent this, the preempt_enable_notrace will use this function
2967 * instead of preempt_schedule() to exit user context if needed before
2968 * calling the scheduler.
2969 */
2970asmlinkage __visible void __sched notrace preempt_schedule_context(void)
2971{
2972 enum ctx_state prev_ctx;
2973
2974 if (likely(!preemptible()))
2975 return;
2976
2977 do {
2978 __preempt_count_add(PREEMPT_ACTIVE);
2979 /*
2980 * Needs preempt disabled in case user_exit() is traced
2981 * and the tracer calls preempt_enable_notrace() causing
2982 * an infinite recursion.
2983 */
2984 prev_ctx = exception_enter();
2985 __schedule();
2986 exception_exit(prev_ctx);
2987
2988 __preempt_count_sub(PREEMPT_ACTIVE);
2989 barrier();
2990 } while (need_resched());
2991}
2992EXPORT_SYMBOL_GPL(preempt_schedule_context);
2993#endif /* CONFIG_CONTEXT_TRACKING */
2994
2954#endif /* CONFIG_PREEMPT */ 2995#endif /* CONFIG_PREEMPT */
2955 2996
2956/* 2997/*
@@ -7833,6 +7874,11 @@ static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
7833 sched_offline_group(tg); 7874 sched_offline_group(tg);
7834} 7875}
7835 7876
7877static void cpu_cgroup_fork(struct task_struct *task)
7878{
7879 sched_move_task(task);
7880}
7881
7836static int cpu_cgroup_can_attach(struct cgroup_subsys_state *css, 7882static int cpu_cgroup_can_attach(struct cgroup_subsys_state *css,
7837 struct cgroup_taskset *tset) 7883 struct cgroup_taskset *tset)
7838{ 7884{
@@ -8205,6 +8251,7 @@ struct cgroup_subsys cpu_cgrp_subsys = {
8205 .css_free = cpu_cgroup_css_free, 8251 .css_free = cpu_cgroup_css_free,
8206 .css_online = cpu_cgroup_css_online, 8252 .css_online = cpu_cgroup_css_online,
8207 .css_offline = cpu_cgroup_css_offline, 8253 .css_offline = cpu_cgroup_css_offline,
8254 .fork = cpu_cgroup_fork,
8208 .can_attach = cpu_cgroup_can_attach, 8255 .can_attach = cpu_cgroup_can_attach,
8209 .attach = cpu_cgroup_attach, 8256 .attach = cpu_cgroup_attach,
8210 .exit = cpu_cgroup_exit, 8257 .exit = cpu_cgroup_exit,
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 256e577faf1b..5285332392d5 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -518,12 +518,20 @@ again:
518 } 518 }
519 519
520 /* 520 /*
521 * We need to take care of a possible races here. In fact, the 521 * We need to take care of several possible races here:
522 * task might have changed its scheduling policy to something 522 *
523 * different from SCHED_DEADLINE or changed its reservation 523 * - the task might have changed its scheduling policy
524 * parameters (through sched_setattr()). 524 * to something different than SCHED_DEADLINE
525 * - the task might have changed its reservation parameters
526 * (through sched_setattr())
527 * - the task might have been boosted by someone else and
528 * might be in the boosting/deboosting path
529 *
530 * In all this cases we bail out, as the task is already
531 * in the runqueue or is going to be enqueued back anyway.
525 */ 532 */
526 if (!dl_task(p) || dl_se->dl_new) 533 if (!dl_task(p) || dl_se->dl_new ||
534 dl_se->dl_boosted || !dl_se->dl_throttled)
527 goto unlock; 535 goto unlock;
528 536
529 sched_clock_tick(); 537 sched_clock_tick();
@@ -532,7 +540,7 @@ again:
532 dl_se->dl_yielded = 0; 540 dl_se->dl_yielded = 0;
533 if (task_on_rq_queued(p)) { 541 if (task_on_rq_queued(p)) {
534 enqueue_task_dl(rq, p, ENQUEUE_REPLENISH); 542 enqueue_task_dl(rq, p, ENQUEUE_REPLENISH);
535 if (task_has_dl_policy(rq->curr)) 543 if (dl_task(rq->curr))
536 check_preempt_curr_dl(rq, p, 0); 544 check_preempt_curr_dl(rq, p, 0);
537 else 545 else
538 resched_curr(rq); 546 resched_curr(rq);
@@ -847,8 +855,19 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
847 * smaller than our one... OTW we keep our runtime and 855 * smaller than our one... OTW we keep our runtime and
848 * deadline. 856 * deadline.
849 */ 857 */
850 if (pi_task && p->dl.dl_boosted && dl_prio(pi_task->normal_prio)) 858 if (pi_task && p->dl.dl_boosted && dl_prio(pi_task->normal_prio)) {
851 pi_se = &pi_task->dl; 859 pi_se = &pi_task->dl;
860 } else if (!dl_prio(p->normal_prio)) {
861 /*
862 * Special case in which we have a !SCHED_DEADLINE task
863 * that is going to be deboosted, but exceedes its
864 * runtime while doing so. No point in replenishing
865 * it, as it's going to return back to its original
866 * scheduling class after this.
867 */
868 BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH);
869 return;
870 }
852 871
853 /* 872 /*
854 * If p is throttled, we do nothing. In fact, if it exhausted 873 * If p is throttled, we do nothing. In fact, if it exhausted
@@ -1607,8 +1626,12 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
1607 /* Only reschedule if pushing failed */ 1626 /* Only reschedule if pushing failed */
1608 check_resched = 0; 1627 check_resched = 0;
1609#endif /* CONFIG_SMP */ 1628#endif /* CONFIG_SMP */
1610 if (check_resched && task_has_dl_policy(rq->curr)) 1629 if (check_resched) {
1611 check_preempt_curr_dl(rq, p, 0); 1630 if (dl_task(rq->curr))
1631 check_preempt_curr_dl(rq, p, 0);
1632 else
1633 resched_curr(rq);
1634 }
1612 } 1635 }
1613} 1636}
1614 1637
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0b069bf3e708..34baa60f8a7b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -828,11 +828,12 @@ static unsigned int task_nr_scan_windows(struct task_struct *p)
828 828
829static unsigned int task_scan_min(struct task_struct *p) 829static unsigned int task_scan_min(struct task_struct *p)
830{ 830{
831 unsigned int scan_size = ACCESS_ONCE(sysctl_numa_balancing_scan_size);
831 unsigned int scan, floor; 832 unsigned int scan, floor;
832 unsigned int windows = 1; 833 unsigned int windows = 1;
833 834
834 if (sysctl_numa_balancing_scan_size < MAX_SCAN_WINDOW) 835 if (scan_size < MAX_SCAN_WINDOW)
835 windows = MAX_SCAN_WINDOW / sysctl_numa_balancing_scan_size; 836 windows = MAX_SCAN_WINDOW / scan_size;
836 floor = 1000 / windows; 837 floor = 1000 / windows;
837 838
838 scan = sysctl_numa_balancing_scan_period_min / task_nr_scan_windows(p); 839 scan = sysctl_numa_balancing_scan_period_min / task_nr_scan_windows(p);
@@ -1164,9 +1165,19 @@ static void task_numa_compare(struct task_numa_env *env,
1164 long moveimp = imp; 1165 long moveimp = imp;
1165 1166
1166 rcu_read_lock(); 1167 rcu_read_lock();
1167 cur = ACCESS_ONCE(dst_rq->curr); 1168
1168 if (cur->pid == 0) /* idle */ 1169 raw_spin_lock_irq(&dst_rq->lock);
1170 cur = dst_rq->curr;
1171 /*
1172 * No need to move the exiting task, and this ensures that ->curr
1173 * wasn't reaped and thus get_task_struct() in task_numa_assign()
1174 * is safe under RCU read lock.
1175 * Note that rcu_read_lock() itself can't protect from the final
1176 * put_task_struct() after the last schedule().
1177 */
1178 if ((cur->flags & PF_EXITING) || is_idle_task(cur))
1169 cur = NULL; 1179 cur = NULL;
1180 raw_spin_unlock_irq(&dst_rq->lock);
1170 1181
1171 /* 1182 /*
1172 * "imp" is the fault differential for the source task between the 1183 * "imp" is the fault differential for the source task between the
@@ -1520,7 +1531,7 @@ static void update_task_scan_period(struct task_struct *p,
1520 * scanning faster if shared accesses dominate as it may 1531 * scanning faster if shared accesses dominate as it may
1521 * simply bounce migrations uselessly 1532 * simply bounce migrations uselessly
1522 */ 1533 */
1523 ratio = DIV_ROUND_UP(private * NUMA_PERIOD_SLOTS, (private + shared)); 1534 ratio = DIV_ROUND_UP(private * NUMA_PERIOD_SLOTS, (private + shared + 1));
1524 diff = (diff * ratio) / NUMA_PERIOD_SLOTS; 1535 diff = (diff * ratio) / NUMA_PERIOD_SLOTS;
1525 } 1536 }
1526 1537
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 4aada6d9fe74..15f2511a1b7c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -387,7 +387,8 @@ static struct ctl_table kern_table[] = {
387 .data = &sysctl_numa_balancing_scan_size, 387 .data = &sysctl_numa_balancing_scan_size,
388 .maxlen = sizeof(unsigned int), 388 .maxlen = sizeof(unsigned int),
389 .mode = 0644, 389 .mode = 0644,
390 .proc_handler = proc_dointvec, 390 .proc_handler = proc_dointvec_minmax,
391 .extra1 = &one,
391 }, 392 },
392 { 393 {
393 .procname = "numa_balancing", 394 .procname = "numa_balancing",
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 9c94c19f1305..55449909f114 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -72,7 +72,7 @@ static u64 cev_delta2ns(unsigned long latch, struct clock_event_device *evt,
72 * Also omit the add if it would overflow the u64 boundary. 72 * Also omit the add if it would overflow the u64 boundary.
73 */ 73 */
74 if ((~0ULL - clc > rnd) && 74 if ((~0ULL - clc > rnd) &&
75 (!ismax || evt->mult <= (1U << evt->shift))) 75 (!ismax || evt->mult <= (1ULL << evt->shift)))
76 clc += rnd; 76 clc += rnd;
77 77
78 do_div(clc, evt->mult); 78 do_div(clc, evt->mult);
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 42b463ad90f2..31ea01f42e1f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -636,6 +636,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
636 goto out; 636 goto out;
637 } 637 }
638 } else { 638 } else {
639 memset(&event.sigev_value, 0, sizeof(event.sigev_value));
639 event.sigev_notify = SIGEV_SIGNAL; 640 event.sigev_notify = SIGEV_SIGNAL;
640 event.sigev_signo = SIGALRM; 641 event.sigev_signo = SIGALRM;
641 event.sigev_value.sival_int = new_timer->it_id; 642 event.sigev_value.sival_int = new_timer->it_id;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index fb186b9ddf51..31c90fec4158 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1925,8 +1925,16 @@ ftrace_find_tramp_ops_curr(struct dyn_ftrace *rec)
1925 * when we are adding another op to the rec or removing the 1925 * when we are adding another op to the rec or removing the
1926 * current one. Thus, if the op is being added, we can 1926 * current one. Thus, if the op is being added, we can
1927 * ignore it because it hasn't attached itself to the rec 1927 * ignore it because it hasn't attached itself to the rec
1928 * yet. That means we just need to find the op that has a 1928 * yet.
1929 * trampoline and is not beeing added. 1929 *
1930 * If an ops is being modified (hooking to different functions)
1931 * then we don't care about the new functions that are being
1932 * added, just the old ones (that are probably being removed).
1933 *
1934 * If we are adding an ops to a function that already is using
1935 * a trampoline, it needs to be removed (trampolines are only
1936 * for single ops connected), then an ops that is not being
1937 * modified also needs to be checked.
1930 */ 1938 */
1931 do_for_each_ftrace_op(op, ftrace_ops_list) { 1939 do_for_each_ftrace_op(op, ftrace_ops_list) {
1932 1940
@@ -1940,17 +1948,23 @@ ftrace_find_tramp_ops_curr(struct dyn_ftrace *rec)
1940 if (op->flags & FTRACE_OPS_FL_ADDING) 1948 if (op->flags & FTRACE_OPS_FL_ADDING)
1941 continue; 1949 continue;
1942 1950
1951
1943 /* 1952 /*
1944 * If the ops is not being added and has a trampoline, 1953 * If the ops is being modified and is in the old
1945 * then it must be the one that we want! 1954 * hash, then it is probably being removed from this
1955 * function.
1946 */ 1956 */
1947 if (hash_contains_ip(ip, op->func_hash))
1948 return op;
1949
1950 /* If the ops is being modified, it may be in the old hash. */
1951 if ((op->flags & FTRACE_OPS_FL_MODIFYING) && 1957 if ((op->flags & FTRACE_OPS_FL_MODIFYING) &&
1952 hash_contains_ip(ip, &op->old_hash)) 1958 hash_contains_ip(ip, &op->old_hash))
1953 return op; 1959 return op;
1960 /*
1961 * If the ops is not being added or modified, and it's
1962 * in its normal filter hash, then this must be the one
1963 * we want!
1964 */
1965 if (!(op->flags & FTRACE_OPS_FL_MODIFYING) &&
1966 hash_contains_ip(ip, op->func_hash))
1967 return op;
1954 1968
1955 } while_for_each_ftrace_op(op); 1969 } while_for_each_ftrace_op(op);
1956 1970
@@ -2293,10 +2307,13 @@ static void ftrace_run_update_code(int command)
2293 FTRACE_WARN_ON(ret); 2307 FTRACE_WARN_ON(ret);
2294} 2308}
2295 2309
2296static void ftrace_run_modify_code(struct ftrace_ops *ops, int command) 2310static void ftrace_run_modify_code(struct ftrace_ops *ops, int command,
2311 struct ftrace_hash *old_hash)
2297{ 2312{
2298 ops->flags |= FTRACE_OPS_FL_MODIFYING; 2313 ops->flags |= FTRACE_OPS_FL_MODIFYING;
2314 ops->old_hash.filter_hash = old_hash;
2299 ftrace_run_update_code(command); 2315 ftrace_run_update_code(command);
2316 ops->old_hash.filter_hash = NULL;
2300 ops->flags &= ~FTRACE_OPS_FL_MODIFYING; 2317 ops->flags &= ~FTRACE_OPS_FL_MODIFYING;
2301} 2318}
2302 2319
@@ -3340,7 +3357,7 @@ static struct ftrace_ops trace_probe_ops __read_mostly =
3340 3357
3341static int ftrace_probe_registered; 3358static int ftrace_probe_registered;
3342 3359
3343static void __enable_ftrace_function_probe(void) 3360static void __enable_ftrace_function_probe(struct ftrace_hash *old_hash)
3344{ 3361{
3345 int ret; 3362 int ret;
3346 int i; 3363 int i;
@@ -3348,7 +3365,8 @@ static void __enable_ftrace_function_probe(void)
3348 if (ftrace_probe_registered) { 3365 if (ftrace_probe_registered) {
3349 /* still need to update the function call sites */ 3366 /* still need to update the function call sites */
3350 if (ftrace_enabled) 3367 if (ftrace_enabled)
3351 ftrace_run_modify_code(&trace_probe_ops, FTRACE_UPDATE_CALLS); 3368 ftrace_run_modify_code(&trace_probe_ops, FTRACE_UPDATE_CALLS,
3369 old_hash);
3352 return; 3370 return;
3353 } 3371 }
3354 3372
@@ -3477,13 +3495,14 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
3477 } while_for_each_ftrace_rec(); 3495 } while_for_each_ftrace_rec();
3478 3496
3479 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash); 3497 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash);
3498
3499 __enable_ftrace_function_probe(old_hash);
3500
3480 if (!ret) 3501 if (!ret)
3481 free_ftrace_hash_rcu(old_hash); 3502 free_ftrace_hash_rcu(old_hash);
3482 else 3503 else
3483 count = ret; 3504 count = ret;
3484 3505
3485 __enable_ftrace_function_probe();
3486
3487 out_unlock: 3506 out_unlock:
3488 mutex_unlock(&ftrace_lock); 3507 mutex_unlock(&ftrace_lock);
3489 out: 3508 out:
@@ -3764,10 +3783,11 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
3764 return add_hash_entry(hash, ip); 3783 return add_hash_entry(hash, ip);
3765} 3784}
3766 3785
3767static void ftrace_ops_update_code(struct ftrace_ops *ops) 3786static void ftrace_ops_update_code(struct ftrace_ops *ops,
3787 struct ftrace_hash *old_hash)
3768{ 3788{
3769 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled) 3789 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
3770 ftrace_run_modify_code(ops, FTRACE_UPDATE_CALLS); 3790 ftrace_run_modify_code(ops, FTRACE_UPDATE_CALLS, old_hash);
3771} 3791}
3772 3792
3773static int 3793static int
@@ -3813,7 +3833,7 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3813 old_hash = *orig_hash; 3833 old_hash = *orig_hash;
3814 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3834 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
3815 if (!ret) { 3835 if (!ret) {
3816 ftrace_ops_update_code(ops); 3836 ftrace_ops_update_code(ops, old_hash);
3817 free_ftrace_hash_rcu(old_hash); 3837 free_ftrace_hash_rcu(old_hash);
3818 } 3838 }
3819 mutex_unlock(&ftrace_lock); 3839 mutex_unlock(&ftrace_lock);
@@ -4058,7 +4078,7 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
4058 ret = ftrace_hash_move(iter->ops, filter_hash, 4078 ret = ftrace_hash_move(iter->ops, filter_hash,
4059 orig_hash, iter->hash); 4079 orig_hash, iter->hash);
4060 if (!ret) { 4080 if (!ret) {
4061 ftrace_ops_update_code(iter->ops); 4081 ftrace_ops_update_code(iter->ops, old_hash);
4062 free_ftrace_hash_rcu(old_hash); 4082 free_ftrace_hash_rcu(old_hash);
4063 } 4083 }
4064 mutex_unlock(&ftrace_lock); 4084 mutex_unlock(&ftrace_lock);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 4dc8b79c5f75..29228c4d5696 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -313,7 +313,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
313 int size; 313 int size;
314 314
315 syscall_nr = trace_get_syscall_nr(current, regs); 315 syscall_nr = trace_get_syscall_nr(current, regs);
316 if (syscall_nr < 0) 316 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
317 return; 317 return;
318 318
319 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */ 319 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */
@@ -360,7 +360,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
360 int syscall_nr; 360 int syscall_nr;
361 361
362 syscall_nr = trace_get_syscall_nr(current, regs); 362 syscall_nr = trace_get_syscall_nr(current, regs);
363 if (syscall_nr < 0) 363 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
364 return; 364 return;
365 365
366 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */ 366 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */
@@ -567,7 +567,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
567 int size; 567 int size;
568 568
569 syscall_nr = trace_get_syscall_nr(current, regs); 569 syscall_nr = trace_get_syscall_nr(current, regs);
570 if (syscall_nr < 0) 570 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
571 return; 571 return;
572 if (!test_bit(syscall_nr, enabled_perf_enter_syscalls)) 572 if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
573 return; 573 return;
@@ -641,7 +641,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
641 int size; 641 int size;
642 642
643 syscall_nr = trace_get_syscall_nr(current, regs); 643 syscall_nr = trace_get_syscall_nr(current, regs);
644 if (syscall_nr < 0) 644 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
645 return; 645 return;
646 if (!test_bit(syscall_nr, enabled_perf_exit_syscalls)) 646 if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
647 return; 647 return;
diff --git a/lib/bitmap.c b/lib/bitmap.c
index cd250a2e14cb..b499ab6ada29 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -131,7 +131,9 @@ void __bitmap_shift_right(unsigned long *dst,
131 lower = src[off + k]; 131 lower = src[off + k];
132 if (left && off + k == lim - 1) 132 if (left && off + k == lim - 1)
133 lower &= mask; 133 lower &= mask;
134 dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem; 134 dst[k] = lower >> rem;
135 if (rem)
136 dst[k] |= upper << (BITS_PER_LONG - rem);
135 if (left && k == lim - 1) 137 if (left && k == lim - 1)
136 dst[k] &= mask; 138 dst[k] &= mask;
137 } 139 }
@@ -172,7 +174,9 @@ void __bitmap_shift_left(unsigned long *dst,
172 upper = src[k]; 174 upper = src[k];
173 if (left && k == lim - 1) 175 if (left && k == lim - 1)
174 upper &= (1UL << left) - 1; 176 upper &= (1UL << left) - 1;
175 dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem; 177 dst[k + off] = upper << rem;
178 if (rem)
179 dst[k + off] |= lower >> (BITS_PER_LONG - rem);
176 if (left && k + off == lim - 1) 180 if (left && k + off == lim - 1)
177 dst[k + off] &= (1UL << left) - 1; 181 dst[k + off] &= (1UL << left) - 1;
178 } 182 }
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 9cdf62f8accd..c9f2e8c6ccc9 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -203,10 +203,10 @@ void __sg_free_table(struct sg_table *table, unsigned int max_ents,
203 } 203 }
204 204
205 table->orig_nents -= sg_size; 205 table->orig_nents -= sg_size;
206 if (!skip_first_chunk) { 206 if (skip_first_chunk)
207 free_fn(sgl, alloc_size);
208 skip_first_chunk = false; 207 skip_first_chunk = false;
209 } 208 else
209 free_fn(sgl, alloc_size);
210 sgl = next; 210 sgl = next;
211 } 211 }
212 212
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index b3cbe19f71b5..fcad8322ef36 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -68,11 +68,13 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
68 * to be released by the balloon driver. 68 * to be released by the balloon driver.
69 */ 69 */
70 if (trylock_page(page)) { 70 if (trylock_page(page)) {
71#ifdef CONFIG_BALLOON_COMPACTION
71 if (!PagePrivate(page)) { 72 if (!PagePrivate(page)) {
72 /* raced with isolation */ 73 /* raced with isolation */
73 unlock_page(page); 74 unlock_page(page);
74 continue; 75 continue;
75 } 76 }
77#endif
76 spin_lock_irqsave(&b_dev_info->pages_lock, flags); 78 spin_lock_irqsave(&b_dev_info->pages_lock, flags);
77 balloon_page_delete(page); 79 balloon_page_delete(page);
78 __count_vm_event(BALLOON_DEFLATE); 80 __count_vm_event(BALLOON_DEFLATE);
diff --git a/mm/cma.c b/mm/cma.c
index 963bc4add9af..fde706e1284f 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -124,6 +124,7 @@ static int __init cma_activate_area(struct cma *cma)
124 124
125err: 125err:
126 kfree(cma->bitmap); 126 kfree(cma->bitmap);
127 cma->count = 0;
127 return -EINVAL; 128 return -EINVAL;
128} 129}
129 130
@@ -217,9 +218,8 @@ int __init cma_declare_contiguous(phys_addr_t base,
217 phys_addr_t highmem_start = __pa(high_memory); 218 phys_addr_t highmem_start = __pa(high_memory);
218 int ret = 0; 219 int ret = 0;
219 220
220 pr_debug("%s(size %lx, base %08lx, limit %08lx alignment %08lx)\n", 221 pr_debug("%s(size %pa, base %pa, limit %pa alignment %pa)\n",
221 __func__, (unsigned long)size, (unsigned long)base, 222 __func__, &size, &base, &limit, &alignment);
222 (unsigned long)limit, (unsigned long)alignment);
223 223
224 if (cma_area_count == ARRAY_SIZE(cma_areas)) { 224 if (cma_area_count == ARRAY_SIZE(cma_areas)) {
225 pr_err("Not enough slots for CMA reserved regions!\n"); 225 pr_err("Not enough slots for CMA reserved regions!\n");
@@ -244,52 +244,72 @@ int __init cma_declare_contiguous(phys_addr_t base,
244 size = ALIGN(size, alignment); 244 size = ALIGN(size, alignment);
245 limit &= ~(alignment - 1); 245 limit &= ~(alignment - 1);
246 246
247 if (!base)
248 fixed = false;
249
247 /* size should be aligned with order_per_bit */ 250 /* size should be aligned with order_per_bit */
248 if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit)) 251 if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
249 return -EINVAL; 252 return -EINVAL;
250 253
251 /* 254 /*
252 * adjust limit to avoid crossing low/high memory boundary for 255 * If allocating at a fixed base the request region must not cross the
253 * automatically allocated regions 256 * low/high memory boundary.
254 */ 257 */
255 if (((limit == 0 || limit > memblock_end) && 258 if (fixed && base < highmem_start && base + size > highmem_start) {
256 (memblock_end - size < highmem_start &&
257 memblock_end > highmem_start)) ||
258 (!fixed && limit > highmem_start && limit - size < highmem_start)) {
259 limit = highmem_start;
260 }
261
262 if (fixed && base < highmem_start && base+size > highmem_start) {
263 ret = -EINVAL; 259 ret = -EINVAL;
264 pr_err("Region at %08lx defined on low/high memory boundary (%08lx)\n", 260 pr_err("Region at %pa defined on low/high memory boundary (%pa)\n",
265 (unsigned long)base, (unsigned long)highmem_start); 261 &base, &highmem_start);
266 goto err; 262 goto err;
267 } 263 }
268 264
265 /*
266 * If the limit is unspecified or above the memblock end, its effective
267 * value will be the memblock end. Set it explicitly to simplify further
268 * checks.
269 */
270 if (limit == 0 || limit > memblock_end)
271 limit = memblock_end;
272
269 /* Reserve memory */ 273 /* Reserve memory */
270 if (base && fixed) { 274 if (fixed) {
271 if (memblock_is_region_reserved(base, size) || 275 if (memblock_is_region_reserved(base, size) ||
272 memblock_reserve(base, size) < 0) { 276 memblock_reserve(base, size) < 0) {
273 ret = -EBUSY; 277 ret = -EBUSY;
274 goto err; 278 goto err;
275 } 279 }
276 } else { 280 } else {
277 phys_addr_t addr = memblock_alloc_range(size, alignment, base, 281 phys_addr_t addr = 0;
278 limit); 282
283 /*
284 * All pages in the reserved area must come from the same zone.
285 * If the requested region crosses the low/high memory boundary,
286 * try allocating from high memory first and fall back to low
287 * memory in case of failure.
288 */
289 if (base < highmem_start && limit > highmem_start) {
290 addr = memblock_alloc_range(size, alignment,
291 highmem_start, limit);
292 limit = highmem_start;
293 }
294
279 if (!addr) { 295 if (!addr) {
280 ret = -ENOMEM; 296 addr = memblock_alloc_range(size, alignment, base,
281 goto err; 297 limit);
282 } else { 298 if (!addr) {
283 base = addr; 299 ret = -ENOMEM;
300 goto err;
301 }
284 } 302 }
303
304 base = addr;
285 } 305 }
286 306
287 ret = cma_init_reserved_mem(base, size, order_per_bit, res_cma); 307 ret = cma_init_reserved_mem(base, size, order_per_bit, res_cma);
288 if (ret) 308 if (ret)
289 goto err; 309 goto err;
290 310
291 pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M, 311 pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
292 (unsigned long)base); 312 &base);
293 return 0; 313 return 0;
294 314
295err: 315err:
diff --git a/mm/compaction.c b/mm/compaction.c
index edba18aed173..ec74cf0123ef 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -784,6 +784,9 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
784 cc->nr_migratepages = 0; 784 cc->nr_migratepages = 0;
785 break; 785 break;
786 } 786 }
787
788 if (cc->nr_migratepages == COMPACT_CLUSTER_MAX)
789 break;
787 } 790 }
788 acct_isolated(cc->zone, cc); 791 acct_isolated(cc->zone, cc);
789 792
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 74c78aa8bc2f..de984159cf0b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -200,7 +200,7 @@ retry:
200 preempt_disable(); 200 preempt_disable();
201 if (cmpxchg(&huge_zero_page, NULL, zero_page)) { 201 if (cmpxchg(&huge_zero_page, NULL, zero_page)) {
202 preempt_enable(); 202 preempt_enable();
203 __free_page(zero_page); 203 __free_pages(zero_page, compound_order(zero_page));
204 goto retry; 204 goto retry;
205 } 205 }
206 206
@@ -232,7 +232,7 @@ static unsigned long shrink_huge_zero_page_scan(struct shrinker *shrink,
232 if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) { 232 if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) {
233 struct page *zero_page = xchg(&huge_zero_page, NULL); 233 struct page *zero_page = xchg(&huge_zero_page, NULL);
234 BUG_ON(zero_page == NULL); 234 BUG_ON(zero_page == NULL);
235 __free_page(zero_page); 235 __free_pages(zero_page, compound_order(zero_page));
236 return HPAGE_PMD_NR; 236 return HPAGE_PMD_NR;
237 } 237 }
238 238
@@ -803,7 +803,7 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
803 return VM_FAULT_FALLBACK; 803 return VM_FAULT_FALLBACK;
804 if (unlikely(anon_vma_prepare(vma))) 804 if (unlikely(anon_vma_prepare(vma)))
805 return VM_FAULT_OOM; 805 return VM_FAULT_OOM;
806 if (unlikely(khugepaged_enter(vma))) 806 if (unlikely(khugepaged_enter(vma, vma->vm_flags)))
807 return VM_FAULT_OOM; 807 return VM_FAULT_OOM;
808 if (!(flags & FAULT_FLAG_WRITE) && 808 if (!(flags & FAULT_FLAG_WRITE) &&
809 transparent_hugepage_use_zero_page()) { 809 transparent_hugepage_use_zero_page()) {
@@ -1970,7 +1970,7 @@ int hugepage_madvise(struct vm_area_struct *vma,
1970 * register it here without waiting a page fault that 1970 * register it here without waiting a page fault that
1971 * may not happen any time soon. 1971 * may not happen any time soon.
1972 */ 1972 */
1973 if (unlikely(khugepaged_enter_vma_merge(vma))) 1973 if (unlikely(khugepaged_enter_vma_merge(vma, *vm_flags)))
1974 return -ENOMEM; 1974 return -ENOMEM;
1975 break; 1975 break;
1976 case MADV_NOHUGEPAGE: 1976 case MADV_NOHUGEPAGE:
@@ -2071,7 +2071,8 @@ int __khugepaged_enter(struct mm_struct *mm)
2071 return 0; 2071 return 0;
2072} 2072}
2073 2073
2074int khugepaged_enter_vma_merge(struct vm_area_struct *vma) 2074int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
2075 unsigned long vm_flags)
2075{ 2076{
2076 unsigned long hstart, hend; 2077 unsigned long hstart, hend;
2077 if (!vma->anon_vma) 2078 if (!vma->anon_vma)
@@ -2083,11 +2084,11 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma)
2083 if (vma->vm_ops) 2084 if (vma->vm_ops)
2084 /* khugepaged not yet working on file or special mappings */ 2085 /* khugepaged not yet working on file or special mappings */
2085 return 0; 2086 return 0;
2086 VM_BUG_ON_VMA(vma->vm_flags & VM_NO_THP, vma); 2087 VM_BUG_ON_VMA(vm_flags & VM_NO_THP, vma);
2087 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; 2088 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
2088 hend = vma->vm_end & HPAGE_PMD_MASK; 2089 hend = vma->vm_end & HPAGE_PMD_MASK;
2089 if (hstart < hend) 2090 if (hstart < hend)
2090 return khugepaged_enter(vma); 2091 return khugepaged_enter(vma, vm_flags);
2091 return 0; 2092 return 0;
2092} 2093}
2093 2094
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 23976fd885fd..d6ac0e33e150 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1536,12 +1536,8 @@ int mem_cgroup_swappiness(struct mem_cgroup *memcg)
1536 * start move here. 1536 * start move here.
1537 */ 1537 */
1538 1538
1539/* for quick checking without looking up memcg */
1540atomic_t memcg_moving __read_mostly;
1541
1542static void mem_cgroup_start_move(struct mem_cgroup *memcg) 1539static void mem_cgroup_start_move(struct mem_cgroup *memcg)
1543{ 1540{
1544 atomic_inc(&memcg_moving);
1545 atomic_inc(&memcg->moving_account); 1541 atomic_inc(&memcg->moving_account);
1546 synchronize_rcu(); 1542 synchronize_rcu();
1547} 1543}
@@ -1552,10 +1548,8 @@ static void mem_cgroup_end_move(struct mem_cgroup *memcg)
1552 * Now, mem_cgroup_clear_mc() may call this function with NULL. 1548 * Now, mem_cgroup_clear_mc() may call this function with NULL.
1553 * We check NULL in callee rather than caller. 1549 * We check NULL in callee rather than caller.
1554 */ 1550 */
1555 if (memcg) { 1551 if (memcg)
1556 atomic_dec(&memcg_moving);
1557 atomic_dec(&memcg->moving_account); 1552 atomic_dec(&memcg->moving_account);
1558 }
1559} 1553}
1560 1554
1561/* 1555/*
@@ -2204,41 +2198,52 @@ cleanup:
2204 return true; 2198 return true;
2205} 2199}
2206 2200
2207/* 2201/**
2208 * Used to update mapped file or writeback or other statistics. 2202 * mem_cgroup_begin_page_stat - begin a page state statistics transaction
2203 * @page: page that is going to change accounted state
2204 * @locked: &memcg->move_lock slowpath was taken
2205 * @flags: IRQ-state flags for &memcg->move_lock
2209 * 2206 *
2210 * Notes: Race condition 2207 * This function must mark the beginning of an accounted page state
2208 * change to prevent double accounting when the page is concurrently
2209 * being moved to another memcg:
2211 * 2210 *
2212 * Charging occurs during page instantiation, while the page is 2211 * memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
2213 * unmapped and locked in page migration, or while the page table is 2212 * if (TestClearPageState(page))
2214 * locked in THP migration. No race is possible. 2213 * mem_cgroup_update_page_stat(memcg, state, -1);
2214 * mem_cgroup_end_page_stat(memcg, locked, flags);
2215 * 2215 *
2216 * Uncharge happens to pages with zero references, no race possible. 2216 * The RCU lock is held throughout the transaction. The fast path can
2217 * get away without acquiring the memcg->move_lock (@locked is false)
2218 * because page moving starts with an RCU grace period.
2217 * 2219 *
2218 * Charge moving between groups is protected by checking mm->moving 2220 * The RCU lock also protects the memcg from being freed when the page
2219 * account and taking the move_lock in the slowpath. 2221 * state that is going to change is the only thing preventing the page
2222 * from being uncharged. E.g. end-writeback clearing PageWriteback(),
2223 * which allows migration to go ahead and uncharge the page before the
2224 * account transaction might be complete.
2220 */ 2225 */
2221 2226struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page,
2222void __mem_cgroup_begin_update_page_stat(struct page *page, 2227 bool *locked,
2223 bool *locked, unsigned long *flags) 2228 unsigned long *flags)
2224{ 2229{
2225 struct mem_cgroup *memcg; 2230 struct mem_cgroup *memcg;
2226 struct page_cgroup *pc; 2231 struct page_cgroup *pc;
2227 2232
2233 rcu_read_lock();
2234
2235 if (mem_cgroup_disabled())
2236 return NULL;
2237
2228 pc = lookup_page_cgroup(page); 2238 pc = lookup_page_cgroup(page);
2229again: 2239again:
2230 memcg = pc->mem_cgroup; 2240 memcg = pc->mem_cgroup;
2231 if (unlikely(!memcg || !PageCgroupUsed(pc))) 2241 if (unlikely(!memcg || !PageCgroupUsed(pc)))
2232 return; 2242 return NULL;
2233 /* 2243
2234 * If this memory cgroup is not under account moving, we don't 2244 *locked = false;
2235 * need to take move_lock_mem_cgroup(). Because we already hold
2236 * rcu_read_lock(), any calls to move_account will be delayed until
2237 * rcu_read_unlock().
2238 */
2239 VM_BUG_ON(!rcu_read_lock_held());
2240 if (atomic_read(&memcg->moving_account) <= 0) 2245 if (atomic_read(&memcg->moving_account) <= 0)
2241 return; 2246 return memcg;
2242 2247
2243 move_lock_mem_cgroup(memcg, flags); 2248 move_lock_mem_cgroup(memcg, flags);
2244 if (memcg != pc->mem_cgroup || !PageCgroupUsed(pc)) { 2249 if (memcg != pc->mem_cgroup || !PageCgroupUsed(pc)) {
@@ -2246,36 +2251,40 @@ again:
2246 goto again; 2251 goto again;
2247 } 2252 }
2248 *locked = true; 2253 *locked = true;
2254
2255 return memcg;
2249} 2256}
2250 2257
2251void __mem_cgroup_end_update_page_stat(struct page *page, unsigned long *flags) 2258/**
2259 * mem_cgroup_end_page_stat - finish a page state statistics transaction
2260 * @memcg: the memcg that was accounted against
2261 * @locked: value received from mem_cgroup_begin_page_stat()
2262 * @flags: value received from mem_cgroup_begin_page_stat()
2263 */
2264void mem_cgroup_end_page_stat(struct mem_cgroup *memcg, bool locked,
2265 unsigned long flags)
2252{ 2266{
2253 struct page_cgroup *pc = lookup_page_cgroup(page); 2267 if (memcg && locked)
2268 move_unlock_mem_cgroup(memcg, &flags);
2254 2269
2255 /* 2270 rcu_read_unlock();
2256 * It's guaranteed that pc->mem_cgroup never changes while
2257 * lock is held because a routine modifies pc->mem_cgroup
2258 * should take move_lock_mem_cgroup().
2259 */
2260 move_unlock_mem_cgroup(pc->mem_cgroup, flags);
2261} 2271}
2262 2272
2263void mem_cgroup_update_page_stat(struct page *page, 2273/**
2274 * mem_cgroup_update_page_stat - update page state statistics
2275 * @memcg: memcg to account against
2276 * @idx: page state item to account
2277 * @val: number of pages (positive or negative)
2278 *
2279 * See mem_cgroup_begin_page_stat() for locking requirements.
2280 */
2281void mem_cgroup_update_page_stat(struct mem_cgroup *memcg,
2264 enum mem_cgroup_stat_index idx, int val) 2282 enum mem_cgroup_stat_index idx, int val)
2265{ 2283{
2266 struct mem_cgroup *memcg;
2267 struct page_cgroup *pc = lookup_page_cgroup(page);
2268 unsigned long uninitialized_var(flags);
2269
2270 if (mem_cgroup_disabled())
2271 return;
2272
2273 VM_BUG_ON(!rcu_read_lock_held()); 2284 VM_BUG_ON(!rcu_read_lock_held());
2274 memcg = pc->mem_cgroup;
2275 if (unlikely(!memcg || !PageCgroupUsed(pc)))
2276 return;
2277 2285
2278 this_cpu_add(memcg->stat->count[idx], val); 2286 if (memcg)
2287 this_cpu_add(memcg->stat->count[idx], val);
2279} 2288}
2280 2289
2281/* 2290/*
diff --git a/mm/memory.c b/mm/memory.c
index 1cc6bfbd872e..3e503831e042 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1147,6 +1147,7 @@ again:
1147 print_bad_pte(vma, addr, ptent, page); 1147 print_bad_pte(vma, addr, ptent, page);
1148 if (unlikely(!__tlb_remove_page(tlb, page))) { 1148 if (unlikely(!__tlb_remove_page(tlb, page))) {
1149 force_flush = 1; 1149 force_flush = 1;
1150 addr += PAGE_SIZE;
1150 break; 1151 break;
1151 } 1152 }
1152 continue; 1153 continue;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 29d8693d0c61..252e1dbbed86 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1912,7 +1912,6 @@ void try_offline_node(int nid)
1912 unsigned long start_pfn = pgdat->node_start_pfn; 1912 unsigned long start_pfn = pgdat->node_start_pfn;
1913 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 1913 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
1914 unsigned long pfn; 1914 unsigned long pfn;
1915 struct page *pgdat_page = virt_to_page(pgdat);
1916 int i; 1915 int i;
1917 1916
1918 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 1917 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
@@ -1941,10 +1940,6 @@ void try_offline_node(int nid)
1941 node_set_offline(nid); 1940 node_set_offline(nid);
1942 unregister_one_node(nid); 1941 unregister_one_node(nid);
1943 1942
1944 if (!PageSlab(pgdat_page) && !PageCompound(pgdat_page))
1945 /* node data is allocated from boot memory */
1946 return;
1947
1948 /* free waittable in each zone */ 1943 /* free waittable in each zone */
1949 for (i = 0; i < MAX_NR_ZONES; i++) { 1944 for (i = 0; i < MAX_NR_ZONES; i++) {
1950 struct zone *zone = pgdat->node_zones + i; 1945 struct zone *zone = pgdat->node_zones + i;
diff --git a/mm/mmap.c b/mm/mmap.c
index 7f855206e7fb..87e82b38453c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1080,7 +1080,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
1080 end, prev->vm_pgoff, NULL); 1080 end, prev->vm_pgoff, NULL);
1081 if (err) 1081 if (err)
1082 return NULL; 1082 return NULL;
1083 khugepaged_enter_vma_merge(prev); 1083 khugepaged_enter_vma_merge(prev, vm_flags);
1084 return prev; 1084 return prev;
1085 } 1085 }
1086 1086
@@ -1099,7 +1099,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
1099 next->vm_pgoff - pglen, NULL); 1099 next->vm_pgoff - pglen, NULL);
1100 if (err) 1100 if (err)
1101 return NULL; 1101 return NULL;
1102 khugepaged_enter_vma_merge(area); 1102 khugepaged_enter_vma_merge(area, vm_flags);
1103 return area; 1103 return area;
1104 } 1104 }
1105 1105
@@ -2208,7 +2208,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
2208 } 2208 }
2209 } 2209 }
2210 vma_unlock_anon_vma(vma); 2210 vma_unlock_anon_vma(vma);
2211 khugepaged_enter_vma_merge(vma); 2211 khugepaged_enter_vma_merge(vma, vma->vm_flags);
2212 validate_mm(vma->vm_mm); 2212 validate_mm(vma->vm_mm);
2213 return error; 2213 return error;
2214} 2214}
@@ -2277,7 +2277,7 @@ int expand_downwards(struct vm_area_struct *vma,
2277 } 2277 }
2278 } 2278 }
2279 vma_unlock_anon_vma(vma); 2279 vma_unlock_anon_vma(vma);
2280 khugepaged_enter_vma_merge(vma); 2280 khugepaged_enter_vma_merge(vma, vma->vm_flags);
2281 validate_mm(vma->vm_mm); 2281 validate_mm(vma->vm_mm);
2282 return error; 2282 return error;
2283} 2283}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index ff24c9d83112..19ceae87522d 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2116,23 +2116,6 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)
2116EXPORT_SYMBOL(account_page_dirtied); 2116EXPORT_SYMBOL(account_page_dirtied);
2117 2117
2118/* 2118/*
2119 * Helper function for set_page_writeback family.
2120 *
2121 * The caller must hold mem_cgroup_begin/end_update_page_stat() lock
2122 * while calling this function.
2123 * See test_set_page_writeback for example.
2124 *
2125 * NOTE: Unlike account_page_dirtied this does not rely on being atomic
2126 * wrt interrupts.
2127 */
2128void account_page_writeback(struct page *page)
2129{
2130 mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_WRITEBACK);
2131 inc_zone_page_state(page, NR_WRITEBACK);
2132}
2133EXPORT_SYMBOL(account_page_writeback);
2134
2135/*
2136 * For address_spaces which do not use buffers. Just tag the page as dirty in 2119 * For address_spaces which do not use buffers. Just tag the page as dirty in
2137 * its radix tree. 2120 * its radix tree.
2138 * 2121 *
@@ -2344,11 +2327,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);
2344int test_clear_page_writeback(struct page *page) 2327int test_clear_page_writeback(struct page *page)
2345{ 2328{
2346 struct address_space *mapping = page_mapping(page); 2329 struct address_space *mapping = page_mapping(page);
2347 int ret;
2348 bool locked;
2349 unsigned long memcg_flags; 2330 unsigned long memcg_flags;
2331 struct mem_cgroup *memcg;
2332 bool locked;
2333 int ret;
2350 2334
2351 mem_cgroup_begin_update_page_stat(page, &locked, &memcg_flags); 2335 memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags);
2352 if (mapping) { 2336 if (mapping) {
2353 struct backing_dev_info *bdi = mapping->backing_dev_info; 2337 struct backing_dev_info *bdi = mapping->backing_dev_info;
2354 unsigned long flags; 2338 unsigned long flags;
@@ -2369,22 +2353,23 @@ int test_clear_page_writeback(struct page *page)
2369 ret = TestClearPageWriteback(page); 2353 ret = TestClearPageWriteback(page);
2370 } 2354 }
2371 if (ret) { 2355 if (ret) {
2372 mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_WRITEBACK); 2356 mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
2373 dec_zone_page_state(page, NR_WRITEBACK); 2357 dec_zone_page_state(page, NR_WRITEBACK);
2374 inc_zone_page_state(page, NR_WRITTEN); 2358 inc_zone_page_state(page, NR_WRITTEN);
2375 } 2359 }
2376 mem_cgroup_end_update_page_stat(page, &locked, &memcg_flags); 2360 mem_cgroup_end_page_stat(memcg, locked, memcg_flags);
2377 return ret; 2361 return ret;
2378} 2362}
2379 2363
2380int __test_set_page_writeback(struct page *page, bool keep_write) 2364int __test_set_page_writeback(struct page *page, bool keep_write)
2381{ 2365{
2382 struct address_space *mapping = page_mapping(page); 2366 struct address_space *mapping = page_mapping(page);
2383 int ret;
2384 bool locked;
2385 unsigned long memcg_flags; 2367 unsigned long memcg_flags;
2368 struct mem_cgroup *memcg;
2369 bool locked;
2370 int ret;
2386 2371
2387 mem_cgroup_begin_update_page_stat(page, &locked, &memcg_flags); 2372 memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags);
2388 if (mapping) { 2373 if (mapping) {
2389 struct backing_dev_info *bdi = mapping->backing_dev_info; 2374 struct backing_dev_info *bdi = mapping->backing_dev_info;
2390 unsigned long flags; 2375 unsigned long flags;
@@ -2410,9 +2395,11 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
2410 } else { 2395 } else {
2411 ret = TestSetPageWriteback(page); 2396 ret = TestSetPageWriteback(page);
2412 } 2397 }
2413 if (!ret) 2398 if (!ret) {
2414 account_page_writeback(page); 2399 mem_cgroup_inc_page_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
2415 mem_cgroup_end_update_page_stat(page, &locked, &memcg_flags); 2400 inc_zone_page_state(page, NR_WRITEBACK);
2401 }
2402 mem_cgroup_end_page_stat(memcg, locked, memcg_flags);
2416 return ret; 2403 return ret;
2417 2404
2418} 2405}
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 3708264d2833..5331c2bd85a2 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -171,6 +171,7 @@ static void free_page_cgroup(void *addr)
171 sizeof(struct page_cgroup) * PAGES_PER_SECTION; 171 sizeof(struct page_cgroup) * PAGES_PER_SECTION;
172 172
173 BUG_ON(PageReserved(page)); 173 BUG_ON(PageReserved(page));
174 kmemleak_free(addr);
174 free_pages_exact(addr, table_size); 175 free_pages_exact(addr, table_size);
175 } 176 }
176} 177}
diff --git a/mm/rmap.c b/mm/rmap.c
index 116a5053415b..19886fb2f13a 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1042,15 +1042,46 @@ void page_add_new_anon_rmap(struct page *page,
1042 */ 1042 */
1043void page_add_file_rmap(struct page *page) 1043void page_add_file_rmap(struct page *page)
1044{ 1044{
1045 bool locked; 1045 struct mem_cgroup *memcg;
1046 unsigned long flags; 1046 unsigned long flags;
1047 bool locked;
1047 1048
1048 mem_cgroup_begin_update_page_stat(page, &locked, &flags); 1049 memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
1049 if (atomic_inc_and_test(&page->_mapcount)) { 1050 if (atomic_inc_and_test(&page->_mapcount)) {
1050 __inc_zone_page_state(page, NR_FILE_MAPPED); 1051 __inc_zone_page_state(page, NR_FILE_MAPPED);
1051 mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED); 1052 mem_cgroup_inc_page_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED);
1052 } 1053 }
1053 mem_cgroup_end_update_page_stat(page, &locked, &flags); 1054 mem_cgroup_end_page_stat(memcg, locked, flags);
1055}
1056
1057static void page_remove_file_rmap(struct page *page)
1058{
1059 struct mem_cgroup *memcg;
1060 unsigned long flags;
1061 bool locked;
1062
1063 memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
1064
1065 /* page still mapped by someone else? */
1066 if (!atomic_add_negative(-1, &page->_mapcount))
1067 goto out;
1068
1069 /* Hugepages are not counted in NR_FILE_MAPPED for now. */
1070 if (unlikely(PageHuge(page)))
1071 goto out;
1072
1073 /*
1074 * We use the irq-unsafe __{inc|mod}_zone_page_stat because
1075 * these counters are not modified in interrupt context, and
1076 * pte lock(a spinlock) is held, which implies preemption disabled.
1077 */
1078 __dec_zone_page_state(page, NR_FILE_MAPPED);
1079 mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED);
1080
1081 if (unlikely(PageMlocked(page)))
1082 clear_page_mlock(page);
1083out:
1084 mem_cgroup_end_page_stat(memcg, locked, flags);
1054} 1085}
1055 1086
1056/** 1087/**
@@ -1061,46 +1092,33 @@ void page_add_file_rmap(struct page *page)
1061 */ 1092 */
1062void page_remove_rmap(struct page *page) 1093void page_remove_rmap(struct page *page)
1063{ 1094{
1064 bool anon = PageAnon(page); 1095 if (!PageAnon(page)) {
1065 bool locked; 1096 page_remove_file_rmap(page);
1066 unsigned long flags; 1097 return;
1067 1098 }
1068 /*
1069 * The anon case has no mem_cgroup page_stat to update; but may
1070 * uncharge_page() below, where the lock ordering can deadlock if
1071 * we hold the lock against page_stat move: so avoid it on anon.
1072 */
1073 if (!anon)
1074 mem_cgroup_begin_update_page_stat(page, &locked, &flags);
1075 1099
1076 /* page still mapped by someone else? */ 1100 /* page still mapped by someone else? */
1077 if (!atomic_add_negative(-1, &page->_mapcount)) 1101 if (!atomic_add_negative(-1, &page->_mapcount))
1078 goto out; 1102 return;
1103
1104 /* Hugepages are not counted in NR_ANON_PAGES for now. */
1105 if (unlikely(PageHuge(page)))
1106 return;
1079 1107
1080 /* 1108 /*
1081 * Hugepages are not counted in NR_ANON_PAGES nor NR_FILE_MAPPED
1082 * and not charged by memcg for now.
1083 *
1084 * We use the irq-unsafe __{inc|mod}_zone_page_stat because 1109 * We use the irq-unsafe __{inc|mod}_zone_page_stat because
1085 * these counters are not modified in interrupt context, and 1110 * these counters are not modified in interrupt context, and
1086 * these counters are not modified in interrupt context, and
1087 * pte lock(a spinlock) is held, which implies preemption disabled. 1111 * pte lock(a spinlock) is held, which implies preemption disabled.
1088 */ 1112 */
1089 if (unlikely(PageHuge(page))) 1113 if (PageTransHuge(page))
1090 goto out; 1114 __dec_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
1091 if (anon) { 1115
1092 if (PageTransHuge(page)) 1116 __mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1093 __dec_zone_page_state(page, 1117 -hpage_nr_pages(page));
1094 NR_ANON_TRANSPARENT_HUGEPAGES); 1118
1095 __mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1096 -hpage_nr_pages(page));
1097 } else {
1098 __dec_zone_page_state(page, NR_FILE_MAPPED);
1099 mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED);
1100 mem_cgroup_end_update_page_stat(page, &locked, &flags);
1101 }
1102 if (unlikely(PageMlocked(page))) 1119 if (unlikely(PageMlocked(page)))
1103 clear_page_mlock(page); 1120 clear_page_mlock(page);
1121
1104 /* 1122 /*
1105 * It would be tidy to reset the PageAnon mapping here, 1123 * It would be tidy to reset the PageAnon mapping here,
1106 * but that might overwrite a racing page_add_anon_rmap 1124 * but that might overwrite a racing page_add_anon_rmap
@@ -1110,10 +1128,6 @@ void page_remove_rmap(struct page *page)
1110 * Leaving it set also helps swapoff to reinstate ptes 1128 * Leaving it set also helps swapoff to reinstate ptes
1111 * faster for those pages still in swapcache. 1129 * faster for those pages still in swapcache.
1112 */ 1130 */
1113 return;
1114out:
1115 if (!anon)
1116 mem_cgroup_end_update_page_stat(page, &locked, &flags);
1117} 1131}
1118 1132
1119/* 1133/*
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 3a6e0cfdf03a..406944207b61 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -93,16 +93,6 @@ static int kmem_cache_sanity_check(const char *name, size_t size)
93 s->object_size); 93 s->object_size);
94 continue; 94 continue;
95 } 95 }
96
97#if !defined(CONFIG_SLUB)
98 if (!strcmp(s->name, name)) {
99 pr_err("%s (%s): Cache name already exists.\n",
100 __func__, name);
101 dump_stack();
102 s = NULL;
103 return -EINVAL;
104 }
105#endif
106 } 96 }
107 97
108 WARN_ON(strchr(name, ' ')); /* It confuses parsers */ 98 WARN_ON(strchr(name, ' ')); /* It confuses parsers */
diff --git a/mm/truncate.c b/mm/truncate.c
index 261eaf6e5a19..f1e4d6052369 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -715,8 +715,9 @@ EXPORT_SYMBOL(truncate_pagecache);
715 * necessary) to @newsize. It will be typically be called from the filesystem's 715 * necessary) to @newsize. It will be typically be called from the filesystem's
716 * setattr function when ATTR_SIZE is passed in. 716 * setattr function when ATTR_SIZE is passed in.
717 * 717 *
718 * Must be called with inode_mutex held and before all filesystem specific 718 * Must be called with a lock serializing truncates and writes (generally
719 * block truncation has been performed. 719 * i_mutex but e.g. xfs uses a different lock) and before all filesystem
720 * specific block truncation has been performed.
720 */ 721 */
721void truncate_setsize(struct inode *inode, loff_t newsize) 722void truncate_setsize(struct inode *inode, loff_t newsize)
722{ 723{
@@ -755,7 +756,6 @@ void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to)
755 struct page *page; 756 struct page *page;
756 pgoff_t index; 757 pgoff_t index;
757 758
758 WARN_ON(!mutex_is_locked(&inode->i_mutex));
759 WARN_ON(to > inode->i_size); 759 WARN_ON(to > inode->i_size);
760 760
761 if (from >= to || bsize == PAGE_CACHE_SIZE) 761 if (from >= to || bsize == PAGE_CACHE_SIZE)
diff --git a/net/Kconfig b/net/Kconfig
index 6272420a721b..99815b5454bf 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -6,7 +6,7 @@ menuconfig NET
6 bool "Networking support" 6 bool "Networking support"
7 select NLATTR 7 select NLATTR
8 select GENERIC_NET_UTILS 8 select GENERIC_NET_UTILS
9 select ANON_INODES 9 select BPF
10 ---help--- 10 ---help---
11 Unless you really know what you are doing, you should say Y here. 11 Unless you really know what you are doing, you should say Y here.
12 The reason is that some programs need kernel networking support even 12 The reason is that some programs need kernel networking support even
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 992ec49a96aa..44cb786b925a 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -112,6 +112,7 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
112 112
113 kfree_skb(skb); 113 kfree_skb(skb);
114} 114}
115EXPORT_SYMBOL_GPL(br_deliver);
115 116
116/* called with rcu_read_lock */ 117/* called with rcu_read_lock */
117void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0) 118void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 1bada53bb195..1a4f32c09ad5 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -192,7 +192,6 @@ static inline void nf_bridge_save_header(struct sk_buff *skb)
192 192
193static int br_parse_ip_options(struct sk_buff *skb) 193static int br_parse_ip_options(struct sk_buff *skb)
194{ 194{
195 struct ip_options *opt;
196 const struct iphdr *iph; 195 const struct iphdr *iph;
197 struct net_device *dev = skb->dev; 196 struct net_device *dev = skb->dev;
198 u32 len; 197 u32 len;
@@ -201,7 +200,6 @@ static int br_parse_ip_options(struct sk_buff *skb)
201 goto inhdr_error; 200 goto inhdr_error;
202 201
203 iph = ip_hdr(skb); 202 iph = ip_hdr(skb);
204 opt = &(IPCB(skb)->opt);
205 203
206 /* Basic sanity checks */ 204 /* Basic sanity checks */
207 if (iph->ihl < 5 || iph->version != 4) 205 if (iph->ihl < 5 || iph->version != 4)
@@ -227,23 +225,11 @@ static int br_parse_ip_options(struct sk_buff *skb)
227 } 225 }
228 226
229 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); 227 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
230 if (iph->ihl == 5) 228 /* We should really parse IP options here but until
231 return 0; 229 * somebody who actually uses IP options complains to
232 230 * us we'll just silently ignore the options because
233 opt->optlen = iph->ihl*4 - sizeof(struct iphdr); 231 * we're lazy!
234 if (ip_options_compile(dev_net(dev), opt, skb)) 232 */
235 goto inhdr_error;
236
237 /* Check correct handling of SRR option */
238 if (unlikely(opt->srr)) {
239 struct in_device *in_dev = __in_dev_get_rcu(dev);
240 if (in_dev && !IN_DEV_SOURCE_ROUTE(in_dev))
241 goto drop;
242
243 if (ip_options_rcv_srr(skb))
244 goto drop;
245 }
246
247 return 0; 233 return 0;
248 234
249inhdr_error: 235inhdr_error:
diff --git a/net/bridge/netfilter/nf_tables_bridge.c b/net/bridge/netfilter/nf_tables_bridge.c
index da17a5eab8b4..074c557ab505 100644
--- a/net/bridge/netfilter/nf_tables_bridge.c
+++ b/net/bridge/netfilter/nf_tables_bridge.c
@@ -75,9 +75,11 @@ static const struct nf_chain_type filter_bridge = {
75 .type = NFT_CHAIN_T_DEFAULT, 75 .type = NFT_CHAIN_T_DEFAULT,
76 .family = NFPROTO_BRIDGE, 76 .family = NFPROTO_BRIDGE,
77 .owner = THIS_MODULE, 77 .owner = THIS_MODULE,
78 .hook_mask = (1 << NF_BR_LOCAL_IN) | 78 .hook_mask = (1 << NF_BR_PRE_ROUTING) |
79 (1 << NF_BR_LOCAL_IN) |
79 (1 << NF_BR_FORWARD) | 80 (1 << NF_BR_FORWARD) |
80 (1 << NF_BR_LOCAL_OUT), 81 (1 << NF_BR_LOCAL_OUT) |
82 (1 << NF_BR_POST_ROUTING),
81}; 83};
82 84
83static int __init nf_tables_bridge_init(void) 85static int __init nf_tables_bridge_init(void)
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index a76479535df2..654c9018e3e7 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -16,6 +16,238 @@
16#include <net/netfilter/nft_reject.h> 16#include <net/netfilter/nft_reject.h>
17#include <net/netfilter/ipv4/nf_reject.h> 17#include <net/netfilter/ipv4/nf_reject.h>
18#include <net/netfilter/ipv6/nf_reject.h> 18#include <net/netfilter/ipv6/nf_reject.h>
19#include <linux/ip.h>
20#include <net/ip.h>
21#include <linux/netfilter_bridge.h>
22#include "../br_private.h"
23
24static void nft_reject_br_push_etherhdr(struct sk_buff *oldskb,
25 struct sk_buff *nskb)
26{
27 struct ethhdr *eth;
28
29 eth = (struct ethhdr *)skb_push(nskb, ETH_HLEN);
30 skb_reset_mac_header(nskb);
31 ether_addr_copy(eth->h_source, eth_hdr(oldskb)->h_dest);
32 ether_addr_copy(eth->h_dest, eth_hdr(oldskb)->h_source);
33 eth->h_proto = eth_hdr(oldskb)->h_proto;
34 skb_pull(nskb, ETH_HLEN);
35}
36
37static int nft_reject_iphdr_validate(struct sk_buff *oldskb)
38{
39 struct iphdr *iph;
40 u32 len;
41
42 if (!pskb_may_pull(oldskb, sizeof(struct iphdr)))
43 return 0;
44
45 iph = ip_hdr(oldskb);
46 if (iph->ihl < 5 || iph->version != 4)
47 return 0;
48
49 len = ntohs(iph->tot_len);
50 if (oldskb->len < len)
51 return 0;
52 else if (len < (iph->ihl*4))
53 return 0;
54
55 if (!pskb_may_pull(oldskb, iph->ihl*4))
56 return 0;
57
58 return 1;
59}
60
61static void nft_reject_br_send_v4_tcp_reset(struct sk_buff *oldskb, int hook)
62{
63 struct sk_buff *nskb;
64 struct iphdr *niph;
65 const struct tcphdr *oth;
66 struct tcphdr _oth;
67
68 if (!nft_reject_iphdr_validate(oldskb))
69 return;
70
71 oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
72 if (!oth)
73 return;
74
75 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) +
76 LL_MAX_HEADER, GFP_ATOMIC);
77 if (!nskb)
78 return;
79
80 skb_reserve(nskb, LL_MAX_HEADER);
81 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
82 sysctl_ip_default_ttl);
83 nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
84 niph->ttl = sysctl_ip_default_ttl;
85 niph->tot_len = htons(nskb->len);
86 ip_send_check(niph);
87
88 nft_reject_br_push_etherhdr(oldskb, nskb);
89
90 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
91}
92
93static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb, int hook,
94 u8 code)
95{
96 struct sk_buff *nskb;
97 struct iphdr *niph;
98 struct icmphdr *icmph;
99 unsigned int len;
100 void *payload;
101 __wsum csum;
102
103 if (!nft_reject_iphdr_validate(oldskb))
104 return;
105
106 /* IP header checks: fragment. */
107 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
108 return;
109
110 /* RFC says return as much as we can without exceeding 576 bytes. */
111 len = min_t(unsigned int, 536, oldskb->len);
112
113 if (!pskb_may_pull(oldskb, len))
114 return;
115
116 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), 0))
117 return;
118
119 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmphdr) +
120 LL_MAX_HEADER + len, GFP_ATOMIC);
121 if (!nskb)
122 return;
123
124 skb_reserve(nskb, LL_MAX_HEADER);
125 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP,
126 sysctl_ip_default_ttl);
127
128 skb_reset_transport_header(nskb);
129 icmph = (struct icmphdr *)skb_put(nskb, sizeof(struct icmphdr));
130 memset(icmph, 0, sizeof(*icmph));
131 icmph->type = ICMP_DEST_UNREACH;
132 icmph->code = code;
133
134 payload = skb_put(nskb, len);
135 memcpy(payload, skb_network_header(oldskb), len);
136
137 csum = csum_partial((void *)icmph, len + sizeof(struct icmphdr), 0);
138 icmph->checksum = csum_fold(csum);
139
140 niph->tot_len = htons(nskb->len);
141 ip_send_check(niph);
142
143 nft_reject_br_push_etherhdr(oldskb, nskb);
144
145 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
146}
147
148static int nft_reject_ip6hdr_validate(struct sk_buff *oldskb)
149{
150 struct ipv6hdr *hdr;
151 u32 pkt_len;
152
153 if (!pskb_may_pull(oldskb, sizeof(struct ipv6hdr)))
154 return 0;
155
156 hdr = ipv6_hdr(oldskb);
157 if (hdr->version != 6)
158 return 0;
159
160 pkt_len = ntohs(hdr->payload_len);
161 if (pkt_len + sizeof(struct ipv6hdr) > oldskb->len)
162 return 0;
163
164 return 1;
165}
166
167static void nft_reject_br_send_v6_tcp_reset(struct net *net,
168 struct sk_buff *oldskb, int hook)
169{
170 struct sk_buff *nskb;
171 const struct tcphdr *oth;
172 struct tcphdr _oth;
173 unsigned int otcplen;
174 struct ipv6hdr *nip6h;
175
176 if (!nft_reject_ip6hdr_validate(oldskb))
177 return;
178
179 oth = nf_reject_ip6_tcphdr_get(oldskb, &_oth, &otcplen, hook);
180 if (!oth)
181 return;
182
183 nskb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(struct tcphdr) +
184 LL_MAX_HEADER, GFP_ATOMIC);
185 if (!nskb)
186 return;
187
188 skb_reserve(nskb, LL_MAX_HEADER);
189 nip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
190 net->ipv6.devconf_all->hop_limit);
191 nf_reject_ip6_tcphdr_put(nskb, oldskb, oth, otcplen);
192 nip6h->payload_len = htons(nskb->len - sizeof(struct ipv6hdr));
193
194 nft_reject_br_push_etherhdr(oldskb, nskb);
195
196 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
197}
198
199static void nft_reject_br_send_v6_unreach(struct net *net,
200 struct sk_buff *oldskb, int hook,
201 u8 code)
202{
203 struct sk_buff *nskb;
204 struct ipv6hdr *nip6h;
205 struct icmp6hdr *icmp6h;
206 unsigned int len;
207 void *payload;
208
209 if (!nft_reject_ip6hdr_validate(oldskb))
210 return;
211
212 /* Include "As much of invoking packet as possible without the ICMPv6
213 * packet exceeding the minimum IPv6 MTU" in the ICMP payload.
214 */
215 len = min_t(unsigned int, 1220, oldskb->len);
216
217 if (!pskb_may_pull(oldskb, len))
218 return;
219
220 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmp6hdr) +
221 LL_MAX_HEADER + len, GFP_ATOMIC);
222 if (!nskb)
223 return;
224
225 skb_reserve(nskb, LL_MAX_HEADER);
226 nip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_ICMPV6,
227 net->ipv6.devconf_all->hop_limit);
228
229 skb_reset_transport_header(nskb);
230 icmp6h = (struct icmp6hdr *)skb_put(nskb, sizeof(struct icmp6hdr));
231 memset(icmp6h, 0, sizeof(*icmp6h));
232 icmp6h->icmp6_type = ICMPV6_DEST_UNREACH;
233 icmp6h->icmp6_code = code;
234
235 payload = skb_put(nskb, len);
236 memcpy(payload, skb_network_header(oldskb), len);
237 nip6h->payload_len = htons(nskb->len - sizeof(struct ipv6hdr));
238
239 icmp6h->icmp6_cksum =
240 csum_ipv6_magic(&nip6h->saddr, &nip6h->daddr,
241 nskb->len - sizeof(struct ipv6hdr),
242 IPPROTO_ICMPV6,
243 csum_partial(icmp6h,
244 nskb->len - sizeof(struct ipv6hdr),
245 0));
246
247 nft_reject_br_push_etherhdr(oldskb, nskb);
248
249 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
250}
19 251
20static void nft_reject_bridge_eval(const struct nft_expr *expr, 252static void nft_reject_bridge_eval(const struct nft_expr *expr,
21 struct nft_data data[NFT_REG_MAX + 1], 253 struct nft_data data[NFT_REG_MAX + 1],
@@ -23,35 +255,46 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
23{ 255{
24 struct nft_reject *priv = nft_expr_priv(expr); 256 struct nft_reject *priv = nft_expr_priv(expr);
25 struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out); 257 struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
258 const unsigned char *dest = eth_hdr(pkt->skb)->h_dest;
259
260 if (is_broadcast_ether_addr(dest) ||
261 is_multicast_ether_addr(dest))
262 goto out;
26 263
27 switch (eth_hdr(pkt->skb)->h_proto) { 264 switch (eth_hdr(pkt->skb)->h_proto) {
28 case htons(ETH_P_IP): 265 case htons(ETH_P_IP):
29 switch (priv->type) { 266 switch (priv->type) {
30 case NFT_REJECT_ICMP_UNREACH: 267 case NFT_REJECT_ICMP_UNREACH:
31 nf_send_unreach(pkt->skb, priv->icmp_code); 268 nft_reject_br_send_v4_unreach(pkt->skb,
269 pkt->ops->hooknum,
270 priv->icmp_code);
32 break; 271 break;
33 case NFT_REJECT_TCP_RST: 272 case NFT_REJECT_TCP_RST:
34 nf_send_reset(pkt->skb, pkt->ops->hooknum); 273 nft_reject_br_send_v4_tcp_reset(pkt->skb,
274 pkt->ops->hooknum);
35 break; 275 break;
36 case NFT_REJECT_ICMPX_UNREACH: 276 case NFT_REJECT_ICMPX_UNREACH:
37 nf_send_unreach(pkt->skb, 277 nft_reject_br_send_v4_unreach(pkt->skb,
38 nft_reject_icmp_code(priv->icmp_code)); 278 pkt->ops->hooknum,
279 nft_reject_icmp_code(priv->icmp_code));
39 break; 280 break;
40 } 281 }
41 break; 282 break;
42 case htons(ETH_P_IPV6): 283 case htons(ETH_P_IPV6):
43 switch (priv->type) { 284 switch (priv->type) {
44 case NFT_REJECT_ICMP_UNREACH: 285 case NFT_REJECT_ICMP_UNREACH:
45 nf_send_unreach6(net, pkt->skb, priv->icmp_code, 286 nft_reject_br_send_v6_unreach(net, pkt->skb,
46 pkt->ops->hooknum); 287 pkt->ops->hooknum,
288 priv->icmp_code);
47 break; 289 break;
48 case NFT_REJECT_TCP_RST: 290 case NFT_REJECT_TCP_RST:
49 nf_send_reset6(net, pkt->skb, pkt->ops->hooknum); 291 nft_reject_br_send_v6_tcp_reset(net, pkt->skb,
292 pkt->ops->hooknum);
50 break; 293 break;
51 case NFT_REJECT_ICMPX_UNREACH: 294 case NFT_REJECT_ICMPX_UNREACH:
52 nf_send_unreach6(net, pkt->skb, 295 nft_reject_br_send_v6_unreach(net, pkt->skb,
53 nft_reject_icmpv6_code(priv->icmp_code), 296 pkt->ops->hooknum,
54 pkt->ops->hooknum); 297 nft_reject_icmpv6_code(priv->icmp_code));
55 break; 298 break;
56 } 299 }
57 break; 300 break;
@@ -59,15 +302,38 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
59 /* No explicit way to reject this protocol, drop it. */ 302 /* No explicit way to reject this protocol, drop it. */
60 break; 303 break;
61 } 304 }
305out:
62 data[NFT_REG_VERDICT].verdict = NF_DROP; 306 data[NFT_REG_VERDICT].verdict = NF_DROP;
63} 307}
64 308
309static int nft_reject_bridge_validate_hooks(const struct nft_chain *chain)
310{
311 struct nft_base_chain *basechain;
312
313 if (chain->flags & NFT_BASE_CHAIN) {
314 basechain = nft_base_chain(chain);
315
316 switch (basechain->ops[0].hooknum) {
317 case NF_BR_PRE_ROUTING:
318 case NF_BR_LOCAL_IN:
319 break;
320 default:
321 return -EOPNOTSUPP;
322 }
323 }
324 return 0;
325}
326
65static int nft_reject_bridge_init(const struct nft_ctx *ctx, 327static int nft_reject_bridge_init(const struct nft_ctx *ctx,
66 const struct nft_expr *expr, 328 const struct nft_expr *expr,
67 const struct nlattr * const tb[]) 329 const struct nlattr * const tb[])
68{ 330{
69 struct nft_reject *priv = nft_expr_priv(expr); 331 struct nft_reject *priv = nft_expr_priv(expr);
70 int icmp_code; 332 int icmp_code, err;
333
334 err = nft_reject_bridge_validate_hooks(ctx->chain);
335 if (err < 0)
336 return err;
71 337
72 if (tb[NFTA_REJECT_TYPE] == NULL) 338 if (tb[NFTA_REJECT_TYPE] == NULL)
73 return -EINVAL; 339 return -EINVAL;
@@ -116,6 +382,13 @@ nla_put_failure:
116 return -1; 382 return -1;
117} 383}
118 384
385static int nft_reject_bridge_validate(const struct nft_ctx *ctx,
386 const struct nft_expr *expr,
387 const struct nft_data **data)
388{
389 return nft_reject_bridge_validate_hooks(ctx->chain);
390}
391
119static struct nft_expr_type nft_reject_bridge_type; 392static struct nft_expr_type nft_reject_bridge_type;
120static const struct nft_expr_ops nft_reject_bridge_ops = { 393static const struct nft_expr_ops nft_reject_bridge_ops = {
121 .type = &nft_reject_bridge_type, 394 .type = &nft_reject_bridge_type,
@@ -123,6 +396,7 @@ static const struct nft_expr_ops nft_reject_bridge_ops = {
123 .eval = nft_reject_bridge_eval, 396 .eval = nft_reject_bridge_eval,
124 .init = nft_reject_bridge_init, 397 .init = nft_reject_bridge_init,
125 .dump = nft_reject_bridge_dump, 398 .dump = nft_reject_bridge_dump,
399 .validate = nft_reject_bridge_validate,
126}; 400};
127 401
128static struct nft_expr_type nft_reject_bridge_type __read_mostly = { 402static struct nft_expr_type nft_reject_bridge_type __read_mostly = {
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index de6662b14e1f..7e38b729696a 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -149,6 +149,7 @@ static int process_one_ticket(struct ceph_auth_client *ac,
149 struct ceph_crypto_key old_key; 149 struct ceph_crypto_key old_key;
150 void *ticket_buf = NULL; 150 void *ticket_buf = NULL;
151 void *tp, *tpend; 151 void *tp, *tpend;
152 void **ptp;
152 struct ceph_timespec new_validity; 153 struct ceph_timespec new_validity;
153 struct ceph_crypto_key new_session_key; 154 struct ceph_crypto_key new_session_key;
154 struct ceph_buffer *new_ticket_blob; 155 struct ceph_buffer *new_ticket_blob;
@@ -208,25 +209,19 @@ static int process_one_ticket(struct ceph_auth_client *ac,
208 goto out; 209 goto out;
209 } 210 }
210 tp = ticket_buf; 211 tp = ticket_buf;
211 dlen = ceph_decode_32(&tp); 212 ptp = &tp;
213 tpend = *ptp + dlen;
212 } else { 214 } else {
213 /* unencrypted */ 215 /* unencrypted */
214 ceph_decode_32_safe(p, end, dlen, bad); 216 ptp = p;
215 ticket_buf = kmalloc(dlen, GFP_NOFS); 217 tpend = end;
216 if (!ticket_buf) {
217 ret = -ENOMEM;
218 goto out;
219 }
220 tp = ticket_buf;
221 ceph_decode_need(p, end, dlen, bad);
222 ceph_decode_copy(p, ticket_buf, dlen);
223 } 218 }
224 tpend = tp + dlen; 219 ceph_decode_32_safe(ptp, tpend, dlen, bad);
225 dout(" ticket blob is %d bytes\n", dlen); 220 dout(" ticket blob is %d bytes\n", dlen);
226 ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad); 221 ceph_decode_need(ptp, tpend, 1 + sizeof(u64), bad);
227 blob_struct_v = ceph_decode_8(&tp); 222 blob_struct_v = ceph_decode_8(ptp);
228 new_secret_id = ceph_decode_64(&tp); 223 new_secret_id = ceph_decode_64(ptp);
229 ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend); 224 ret = ceph_decode_buffer(&new_ticket_blob, ptp, tpend);
230 if (ret) 225 if (ret)
231 goto out; 226 goto out;
232 227
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 559c9f619c20..8d1653caffdb 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -484,7 +484,7 @@ static int ceph_tcp_connect(struct ceph_connection *con)
484 IPPROTO_TCP, &sock); 484 IPPROTO_TCP, &sock);
485 if (ret) 485 if (ret)
486 return ret; 486 return ret;
487 sock->sk->sk_allocation = GFP_NOFS; 487 sock->sk->sk_allocation = GFP_NOFS | __GFP_MEMALLOC;
488 488
489#ifdef CONFIG_LOCKDEP 489#ifdef CONFIG_LOCKDEP
490 lockdep_set_class(&sock->sk->sk_lock, &socket_class); 490 lockdep_set_class(&sock->sk->sk_lock, &socket_class);
@@ -509,6 +509,9 @@ static int ceph_tcp_connect(struct ceph_connection *con)
509 509
510 return ret; 510 return ret;
511 } 511 }
512
513 sk_set_memalloc(sock->sk);
514
512 con->sock = sock; 515 con->sock = sock;
513 return 0; 516 return 0;
514} 517}
@@ -2769,8 +2772,11 @@ static void con_work(struct work_struct *work)
2769{ 2772{
2770 struct ceph_connection *con = container_of(work, struct ceph_connection, 2773 struct ceph_connection *con = container_of(work, struct ceph_connection,
2771 work.work); 2774 work.work);
2775 unsigned long pflags = current->flags;
2772 bool fault; 2776 bool fault;
2773 2777
2778 current->flags |= PF_MEMALLOC;
2779
2774 mutex_lock(&con->mutex); 2780 mutex_lock(&con->mutex);
2775 while (true) { 2781 while (true) {
2776 int ret; 2782 int ret;
@@ -2824,6 +2830,8 @@ static void con_work(struct work_struct *work)
2824 con_fault_finish(con); 2830 con_fault_finish(con);
2825 2831
2826 con->ops->put(con); 2832 con->ops->put(con);
2833
2834 tsk_restore_flags(current, pflags, PF_MEMALLOC);
2827} 2835}
2828 2836
2829/* 2837/*
diff --git a/net/core/dev.c b/net/core/dev.c
index b793e3521a36..945bbd001359 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4157,6 +4157,10 @@ EXPORT_SYMBOL(napi_gro_receive);
4157 4157
4158static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) 4158static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
4159{ 4159{
4160 if (unlikely(skb->pfmemalloc)) {
4161 consume_skb(skb);
4162 return;
4163 }
4160 __skb_pull(skb, skb_headlen(skb)); 4164 __skb_pull(skb, skb_headlen(skb));
4161 /* restore the reserve we had after netdev_alloc_skb_ip_align() */ 4165 /* restore the reserve we had after netdev_alloc_skb_ip_align() */
4162 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN - skb_headroom(skb)); 4166 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN - skb_headroom(skb));
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 1600aa24d36b..06dfb293e5aa 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1036,7 +1036,8 @@ static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1036{ 1036{
1037 const struct ethtool_ops *ops = dev->ethtool_ops; 1037 const struct ethtool_ops *ops = dev->ethtool_ops;
1038 1038
1039 if (!ops->get_eeprom || !ops->get_eeprom_len) 1039 if (!ops->get_eeprom || !ops->get_eeprom_len ||
1040 !ops->get_eeprom_len(dev))
1040 return -EOPNOTSUPP; 1041 return -EOPNOTSUPP;
1041 1042
1042 return ethtool_get_any_eeprom(dev, useraddr, ops->get_eeprom, 1043 return ethtool_get_any_eeprom(dev, useraddr, ops->get_eeprom,
@@ -1052,7 +1053,8 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1052 u8 *data; 1053 u8 *data;
1053 int ret = 0; 1054 int ret = 0;
1054 1055
1055 if (!ops->set_eeprom || !ops->get_eeprom_len) 1056 if (!ops->set_eeprom || !ops->get_eeprom_len ||
1057 !ops->get_eeprom_len(dev))
1056 return -EOPNOTSUPP; 1058 return -EOPNOTSUPP;
1057 1059
1058 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) 1060 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a05ec95..c16615bfb61e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4070,15 +4070,22 @@ EXPORT_SYMBOL_GPL(skb_scrub_packet);
4070unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) 4070unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
4071{ 4071{
4072 const struct skb_shared_info *shinfo = skb_shinfo(skb); 4072 const struct skb_shared_info *shinfo = skb_shinfo(skb);
4073 unsigned int thlen = 0;
4073 4074
4074 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) 4075 if (skb->encapsulation) {
4075 return tcp_hdrlen(skb) + shinfo->gso_size; 4076 thlen = skb_inner_transport_header(skb) -
4077 skb_transport_header(skb);
4076 4078
4079 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
4080 thlen += inner_tcp_hdrlen(skb);
4081 } else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
4082 thlen = tcp_hdrlen(skb);
4083 }
4077 /* UFO sets gso_size to the size of the fragmentation 4084 /* UFO sets gso_size to the size of the fragmentation
4078 * payload, i.e. the size of the L4 (UDP) header is already 4085 * payload, i.e. the size of the L4 (UDP) header is already
4079 * accounted for. 4086 * accounted for.
4080 */ 4087 */
4081 return shinfo->gso_size; 4088 return thlen + shinfo->gso_size;
4082} 4089}
4083EXPORT_SYMBOL_GPL(skb_gso_transport_seglen); 4090EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
4084 4091
diff --git a/net/core/tso.c b/net/core/tso.c
index 8c3203c585b0..630b30b4fb53 100644
--- a/net/core/tso.c
+++ b/net/core/tso.c
@@ -1,6 +1,7 @@
1#include <linux/export.h> 1#include <linux/export.h>
2#include <net/ip.h> 2#include <net/ip.h>
3#include <net/tso.h> 3#include <net/tso.h>
4#include <asm/unaligned.h>
4 5
5/* Calculate expected number of TX descriptors */ 6/* Calculate expected number of TX descriptors */
6int tso_count_descs(struct sk_buff *skb) 7int tso_count_descs(struct sk_buff *skb)
@@ -23,7 +24,7 @@ void tso_build_hdr(struct sk_buff *skb, char *hdr, struct tso_t *tso,
23 iph->id = htons(tso->ip_id); 24 iph->id = htons(tso->ip_id);
24 iph->tot_len = htons(size + hdr_len - mac_hdr_len); 25 iph->tot_len = htons(size + hdr_len - mac_hdr_len);
25 tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb)); 26 tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb));
26 tcph->seq = htonl(tso->tcp_seq); 27 put_unaligned_be32(tso->tcp_seq, &tcph->seq);
27 tso->ip_id++; 28 tso->ip_id++;
28 29
29 if (!is_last) { 30 if (!is_last) {
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 22f34cf4cb27..6317b41c99b0 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -174,8 +174,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
174 dst->rcv = brcm_netdev_ops.rcv; 174 dst->rcv = brcm_netdev_ops.rcv;
175 break; 175 break;
176#endif 176#endif
177 default: 177 case DSA_TAG_PROTO_NONE:
178 break; 178 break;
179 default:
180 ret = -ENOPROTOOPT;
181 goto out;
179 } 182 }
180 183
181 dst->tag_protocol = drv->tag_protocol; 184 dst->tag_protocol = drv->tag_protocol;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 92db7a69f2b9..8b7fe5b03906 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1246,7 +1246,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1246 1246
1247 encap = SKB_GSO_CB(skb)->encap_level > 0; 1247 encap = SKB_GSO_CB(skb)->encap_level > 0;
1248 if (encap) 1248 if (encap)
1249 features = skb->dev->hw_enc_features & netif_skb_features(skb); 1249 features &= skb->dev->hw_enc_features;
1250 SKB_GSO_CB(skb)->encap_level += ihl; 1250 SKB_GSO_CB(skb)->encap_level += ihl;
1251 1251
1252 skb_reset_transport_header(skb); 1252 skb_reset_transport_header(skb);
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index ccda09628de7..bb5947b0ce2d 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -47,7 +47,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
47 47
48 greh = (struct gre_base_hdr *)skb_transport_header(skb); 48 greh = (struct gre_base_hdr *)skb_transport_header(skb);
49 49
50 ghl = skb_inner_network_header(skb) - skb_transport_header(skb); 50 ghl = skb_inner_mac_header(skb) - skb_transport_header(skb);
51 if (unlikely(ghl < sizeof(*greh))) 51 if (unlikely(ghl < sizeof(*greh)))
52 goto out; 52 goto out;
53 53
@@ -68,7 +68,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
68 skb->mac_len = skb_inner_network_offset(skb); 68 skb->mac_len = skb_inner_network_offset(skb);
69 69
70 /* segment inner packet. */ 70 /* segment inner packet. */
71 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 71 enc_features = skb->dev->hw_enc_features & features;
72 segs = skb_mac_gso_segment(skb, enc_features); 72 segs = skb_mac_gso_segment(skb, enc_features);
73 if (IS_ERR_OR_NULL(segs)) { 73 if (IS_ERR_OR_NULL(segs)) {
74 skb_gso_error_unwind(skb, protocol, ghl, mac_offset, mac_len); 74 skb_gso_error_unwind(skb, protocol, ghl, mac_offset, mac_len);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 9eb89f3f0ee4..19419b60cb37 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -146,7 +146,6 @@ evict_again:
146 atomic_inc(&fq->refcnt); 146 atomic_inc(&fq->refcnt);
147 spin_unlock(&hb->chain_lock); 147 spin_unlock(&hb->chain_lock);
148 del_timer_sync(&fq->timer); 148 del_timer_sync(&fq->timer);
149 WARN_ON(atomic_read(&fq->refcnt) != 1);
150 inet_frag_put(fq, f); 149 inet_frag_put(fq, f);
151 goto evict_again; 150 goto evict_again;
152 } 151 }
@@ -285,7 +284,8 @@ static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
285 struct inet_frag_bucket *hb; 284 struct inet_frag_bucket *hb;
286 285
287 hb = get_frag_bucket_locked(fq, f); 286 hb = get_frag_bucket_locked(fq, f);
288 hlist_del(&fq->list); 287 if (!(fq->flags & INET_FRAG_EVICTED))
288 hlist_del(&fq->list);
289 spin_unlock(&hb->chain_lock); 289 spin_unlock(&hb->chain_lock);
290} 290}
291 291
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 88e5ef2c7f51..bc6471d4abcd 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -231,7 +231,7 @@ static int ip_finish_output_gso(struct sk_buff *skb)
231 */ 231 */
232 features = netif_skb_features(skb); 232 features = netif_skb_features(skb);
233 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); 233 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
234 if (IS_ERR(segs)) { 234 if (IS_ERR_OR_NULL(segs)) {
235 kfree_skb(skb); 235 kfree_skb(skb);
236 return -ENOMEM; 236 return -ENOMEM;
237 } 237 }
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index b023b4eb1a96..1baaa83dfe5c 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -6,48 +6,45 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <linux/module.h>
9#include <net/ip.h> 10#include <net/ip.h>
10#include <net/tcp.h> 11#include <net/tcp.h>
11#include <net/route.h> 12#include <net/route.h>
12#include <net/dst.h> 13#include <net/dst.h>
13#include <linux/netfilter_ipv4.h> 14#include <linux/netfilter_ipv4.h>
15#include <net/netfilter/ipv4/nf_reject.h>
14 16
15/* Send RST reply */ 17const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
16void nf_send_reset(struct sk_buff *oldskb, int hook) 18 struct tcphdr *_oth, int hook)
17{ 19{
18 struct sk_buff *nskb;
19 const struct iphdr *oiph;
20 struct iphdr *niph;
21 const struct tcphdr *oth; 20 const struct tcphdr *oth;
22 struct tcphdr _otcph, *tcph;
23 21
24 /* IP header checks: fragment. */ 22 /* IP header checks: fragment. */
25 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET)) 23 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
26 return; 24 return NULL;
27 25
28 oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb), 26 oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb),
29 sizeof(_otcph), &_otcph); 27 sizeof(struct tcphdr), _oth);
30 if (oth == NULL) 28 if (oth == NULL)
31 return; 29 return NULL;
32 30
33 /* No RST for RST. */ 31 /* No RST for RST. */
34 if (oth->rst) 32 if (oth->rst)
35 return; 33 return NULL;
36
37 if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
38 return;
39 34
40 /* Check checksum */ 35 /* Check checksum */
41 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP)) 36 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP))
42 return; 37 return NULL;
43 oiph = ip_hdr(oldskb);
44 38
45 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) + 39 return oth;
46 LL_MAX_HEADER, GFP_ATOMIC); 40}
47 if (!nskb) 41EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_get);
48 return;
49 42
50 skb_reserve(nskb, LL_MAX_HEADER); 43struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
44 const struct sk_buff *oldskb,
45 __be16 protocol, int ttl)
46{
47 struct iphdr *niph, *oiph = ip_hdr(oldskb);
51 48
52 skb_reset_network_header(nskb); 49 skb_reset_network_header(nskb);
53 niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr)); 50 niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr));
@@ -56,10 +53,23 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
56 niph->tos = 0; 53 niph->tos = 0;
57 niph->id = 0; 54 niph->id = 0;
58 niph->frag_off = htons(IP_DF); 55 niph->frag_off = htons(IP_DF);
59 niph->protocol = IPPROTO_TCP; 56 niph->protocol = protocol;
60 niph->check = 0; 57 niph->check = 0;
61 niph->saddr = oiph->daddr; 58 niph->saddr = oiph->daddr;
62 niph->daddr = oiph->saddr; 59 niph->daddr = oiph->saddr;
60 niph->ttl = ttl;
61
62 nskb->protocol = htons(ETH_P_IP);
63
64 return niph;
65}
66EXPORT_SYMBOL_GPL(nf_reject_iphdr_put);
67
68void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
69 const struct tcphdr *oth)
70{
71 struct iphdr *niph = ip_hdr(nskb);
72 struct tcphdr *tcph;
63 73
64 skb_reset_transport_header(nskb); 74 skb_reset_transport_header(nskb);
65 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); 75 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
@@ -68,9 +78,9 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
68 tcph->dest = oth->source; 78 tcph->dest = oth->source;
69 tcph->doff = sizeof(struct tcphdr) / 4; 79 tcph->doff = sizeof(struct tcphdr) / 4;
70 80
71 if (oth->ack) 81 if (oth->ack) {
72 tcph->seq = oth->ack_seq; 82 tcph->seq = oth->ack_seq;
73 else { 83 } else {
74 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + 84 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin +
75 oldskb->len - ip_hdrlen(oldskb) - 85 oldskb->len - ip_hdrlen(oldskb) -
76 (oth->doff << 2)); 86 (oth->doff << 2));
@@ -83,16 +93,43 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
83 nskb->ip_summed = CHECKSUM_PARTIAL; 93 nskb->ip_summed = CHECKSUM_PARTIAL;
84 nskb->csum_start = (unsigned char *)tcph - nskb->head; 94 nskb->csum_start = (unsigned char *)tcph - nskb->head;
85 nskb->csum_offset = offsetof(struct tcphdr, check); 95 nskb->csum_offset = offsetof(struct tcphdr, check);
96}
97EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_put);
98
99/* Send RST reply */
100void nf_send_reset(struct sk_buff *oldskb, int hook)
101{
102 struct sk_buff *nskb;
103 const struct iphdr *oiph;
104 struct iphdr *niph;
105 const struct tcphdr *oth;
106 struct tcphdr _oth;
107
108 oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
109 if (!oth)
110 return;
111
112 if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
113 return;
114
115 oiph = ip_hdr(oldskb);
116
117 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) +
118 LL_MAX_HEADER, GFP_ATOMIC);
119 if (!nskb)
120 return;
86 121
87 /* ip_route_me_harder expects skb->dst to be set */ 122 /* ip_route_me_harder expects skb->dst to be set */
88 skb_dst_set_noref(nskb, skb_dst(oldskb)); 123 skb_dst_set_noref(nskb, skb_dst(oldskb));
89 124
90 nskb->protocol = htons(ETH_P_IP); 125 skb_reserve(nskb, LL_MAX_HEADER);
126 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
127 ip4_dst_hoplimit(skb_dst(nskb)));
128 nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
129
91 if (ip_route_me_harder(nskb, RTN_UNSPEC)) 130 if (ip_route_me_harder(nskb, RTN_UNSPEC))
92 goto free_nskb; 131 goto free_nskb;
93 132
94 niph->ttl = ip4_dst_hoplimit(skb_dst(nskb));
95
96 /* "Never happens" */ 133 /* "Never happens" */
97 if (nskb->len > dst_mtu(skb_dst(nskb))) 134 if (nskb->len > dst_mtu(skb_dst(nskb)))
98 goto free_nskb; 135 goto free_nskb;
@@ -125,3 +162,5 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
125 kfree_skb(nskb); 162 kfree_skb(nskb);
126} 163}
127EXPORT_SYMBOL_GPL(nf_send_reset); 164EXPORT_SYMBOL_GPL(nf_send_reset);
165
166MODULE_LICENSE("GPL");
diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c
index 1c636d6b5b50..c1023c445920 100644
--- a/net/ipv4/netfilter/nft_masq_ipv4.c
+++ b/net/ipv4/netfilter/nft_masq_ipv4.c
@@ -39,6 +39,7 @@ static const struct nft_expr_ops nft_masq_ipv4_ops = {
39 .eval = nft_masq_ipv4_eval, 39 .eval = nft_masq_ipv4_eval,
40 .init = nft_masq_init, 40 .init = nft_masq_init,
41 .dump = nft_masq_dump, 41 .dump = nft_masq_dump,
42 .validate = nft_masq_validate,
42}; 43};
43 44
44static struct nft_expr_type nft_masq_ipv4_type __read_mostly = { 45static struct nft_expr_type nft_masq_ipv4_type __read_mostly = {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2d4ae469b471..6a2155b02602 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1798,6 +1798,7 @@ local_input:
1798no_route: 1798no_route:
1799 RT_CACHE_STAT_INC(in_no_route); 1799 RT_CACHE_STAT_INC(in_no_route);
1800 res.type = RTN_UNREACHABLE; 1800 res.type = RTN_UNREACHABLE;
1801 res.fi = NULL;
1801 goto local_input; 1802 goto local_input;
1802 1803
1803 /* 1804 /*
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1bec4e76d88c..39ec0c379545 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2868,61 +2868,42 @@ EXPORT_SYMBOL(compat_tcp_getsockopt);
2868#endif 2868#endif
2869 2869
2870#ifdef CONFIG_TCP_MD5SIG 2870#ifdef CONFIG_TCP_MD5SIG
2871static struct tcp_md5sig_pool __percpu *tcp_md5sig_pool __read_mostly; 2871static DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);
2872static DEFINE_MUTEX(tcp_md5sig_mutex); 2872static DEFINE_MUTEX(tcp_md5sig_mutex);
2873 2873static bool tcp_md5sig_pool_populated = false;
2874static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool __percpu *pool)
2875{
2876 int cpu;
2877
2878 for_each_possible_cpu(cpu) {
2879 struct tcp_md5sig_pool *p = per_cpu_ptr(pool, cpu);
2880
2881 if (p->md5_desc.tfm)
2882 crypto_free_hash(p->md5_desc.tfm);
2883 }
2884 free_percpu(pool);
2885}
2886 2874
2887static void __tcp_alloc_md5sig_pool(void) 2875static void __tcp_alloc_md5sig_pool(void)
2888{ 2876{
2889 int cpu; 2877 int cpu;
2890 struct tcp_md5sig_pool __percpu *pool;
2891
2892 pool = alloc_percpu(struct tcp_md5sig_pool);
2893 if (!pool)
2894 return;
2895 2878
2896 for_each_possible_cpu(cpu) { 2879 for_each_possible_cpu(cpu) {
2897 struct crypto_hash *hash; 2880 if (!per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm) {
2898 2881 struct crypto_hash *hash;
2899 hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
2900 if (IS_ERR_OR_NULL(hash))
2901 goto out_free;
2902 2882
2903 per_cpu_ptr(pool, cpu)->md5_desc.tfm = hash; 2883 hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
2884 if (IS_ERR_OR_NULL(hash))
2885 return;
2886 per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm = hash;
2887 }
2904 } 2888 }
2905 /* before setting tcp_md5sig_pool, we must commit all writes 2889 /* before setting tcp_md5sig_pool_populated, we must commit all writes
2906 * to memory. See ACCESS_ONCE() in tcp_get_md5sig_pool() 2890 * to memory. See smp_rmb() in tcp_get_md5sig_pool()
2907 */ 2891 */
2908 smp_wmb(); 2892 smp_wmb();
2909 tcp_md5sig_pool = pool; 2893 tcp_md5sig_pool_populated = true;
2910 return;
2911out_free:
2912 __tcp_free_md5sig_pool(pool);
2913} 2894}
2914 2895
2915bool tcp_alloc_md5sig_pool(void) 2896bool tcp_alloc_md5sig_pool(void)
2916{ 2897{
2917 if (unlikely(!tcp_md5sig_pool)) { 2898 if (unlikely(!tcp_md5sig_pool_populated)) {
2918 mutex_lock(&tcp_md5sig_mutex); 2899 mutex_lock(&tcp_md5sig_mutex);
2919 2900
2920 if (!tcp_md5sig_pool) 2901 if (!tcp_md5sig_pool_populated)
2921 __tcp_alloc_md5sig_pool(); 2902 __tcp_alloc_md5sig_pool();
2922 2903
2923 mutex_unlock(&tcp_md5sig_mutex); 2904 mutex_unlock(&tcp_md5sig_mutex);
2924 } 2905 }
2925 return tcp_md5sig_pool != NULL; 2906 return tcp_md5sig_pool_populated;
2926} 2907}
2927EXPORT_SYMBOL(tcp_alloc_md5sig_pool); 2908EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2928 2909
@@ -2936,13 +2917,13 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2936 */ 2917 */
2937struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) 2918struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
2938{ 2919{
2939 struct tcp_md5sig_pool __percpu *p;
2940
2941 local_bh_disable(); 2920 local_bh_disable();
2942 p = ACCESS_ONCE(tcp_md5sig_pool);
2943 if (p)
2944 return raw_cpu_ptr(p);
2945 2921
2922 if (tcp_md5sig_pool_populated) {
2923 /* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */
2924 smp_rmb();
2925 return this_cpu_ptr(&tcp_md5sig_pool);
2926 }
2946 local_bh_enable(); 2927 local_bh_enable();
2947 return NULL; 2928 return NULL;
2948} 2929}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 94d1a7757ff7..9c7d7621466b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -206,8 +206,6 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
206 inet->inet_dport = usin->sin_port; 206 inet->inet_dport = usin->sin_port;
207 inet->inet_daddr = daddr; 207 inet->inet_daddr = daddr;
208 208
209 inet_set_txhash(sk);
210
211 inet_csk(sk)->icsk_ext_hdr_len = 0; 209 inet_csk(sk)->icsk_ext_hdr_len = 0;
212 if (inet_opt) 210 if (inet_opt)
213 inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 211 inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
@@ -224,6 +222,8 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
224 if (err) 222 if (err)
225 goto failure; 223 goto failure;
226 224
225 inet_set_txhash(sk);
226
227 rt = ip_route_newports(fl4, rt, orig_sport, orig_dport, 227 rt = ip_route_newports(fl4, rt, orig_sport, orig_dport,
228 inet->inet_sport, inet->inet_dport, sk); 228 inet->inet_sport, inet->inet_dport, sk);
229 if (IS_ERR(rt)) { 229 if (IS_ERR(rt)) {
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 3af21296d967..a3d453b94747 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2126,7 +2126,7 @@ bool tcp_schedule_loss_probe(struct sock *sk)
2126static bool skb_still_in_host_queue(const struct sock *sk, 2126static bool skb_still_in_host_queue(const struct sock *sk,
2127 const struct sk_buff *skb) 2127 const struct sk_buff *skb)
2128{ 2128{
2129 if (unlikely(skb_fclone_busy(skb))) { 2129 if (unlikely(skb_fclone_busy(sk, skb))) {
2130 NET_INC_STATS_BH(sock_net(sk), 2130 NET_INC_STATS_BH(sock_net(sk),
2131 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES); 2131 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES);
2132 return true; 2132 return true;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 507310ef4b56..6480cea7aa53 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -58,7 +58,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
58 skb->encap_hdr_csum = 1; 58 skb->encap_hdr_csum = 1;
59 59
60 /* segment inner packet. */ 60 /* segment inner packet. */
61 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 61 enc_features = skb->dev->hw_enc_features & features;
62 segs = gso_inner_segment(skb, enc_features); 62 segs = gso_inner_segment(skb, enc_features);
63 if (IS_ERR_OR_NULL(segs)) { 63 if (IS_ERR_OR_NULL(segs)) {
64 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset, 64 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 725c763270a0..0169ccf5aa4f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4531,6 +4531,7 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
4531 } 4531 }
4532 4532
4533 write_unlock_bh(&idev->lock); 4533 write_unlock_bh(&idev->lock);
4534 inet6_ifinfo_notify(RTM_NEWLINK, idev);
4534 addrconf_verify_rtnl(); 4535 addrconf_verify_rtnl();
4535 return 0; 4536 return 0;
4536} 4537}
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 91014d32488d..a071563a7e6e 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -90,7 +90,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
90 90
91 encap = SKB_GSO_CB(skb)->encap_level > 0; 91 encap = SKB_GSO_CB(skb)->encap_level > 0;
92 if (encap) 92 if (encap)
93 features = skb->dev->hw_enc_features & netif_skb_features(skb); 93 features &= skb->dev->hw_enc_features;
94 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h); 94 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h);
95 95
96 ipv6h = ipv6_hdr(skb); 96 ipv6h = ipv6_hdr(skb);
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 5f5f0438d74d..015eb8a80766 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -5,121 +5,109 @@
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8
9#include <linux/module.h>
8#include <net/ipv6.h> 10#include <net/ipv6.h>
9#include <net/ip6_route.h> 11#include <net/ip6_route.h>
10#include <net/ip6_fib.h> 12#include <net/ip6_fib.h>
11#include <net/ip6_checksum.h> 13#include <net/ip6_checksum.h>
12#include <linux/netfilter_ipv6.h> 14#include <linux/netfilter_ipv6.h>
15#include <net/netfilter/ipv6/nf_reject.h>
13 16
14void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook) 17const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
18 struct tcphdr *otcph,
19 unsigned int *otcplen, int hook)
15{ 20{
16 struct sk_buff *nskb;
17 struct tcphdr otcph, *tcph;
18 unsigned int otcplen, hh_len;
19 int tcphoff, needs_ack;
20 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb); 21 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
21 struct ipv6hdr *ip6h;
22#define DEFAULT_TOS_VALUE 0x0U
23 const __u8 tclass = DEFAULT_TOS_VALUE;
24 struct dst_entry *dst = NULL;
25 u8 proto; 22 u8 proto;
26 __be16 frag_off; 23 __be16 frag_off;
27 struct flowi6 fl6; 24 int tcphoff;
28
29 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
30 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) {
31 pr_debug("addr is not unicast.\n");
32 return;
33 }
34 25
35 proto = oip6h->nexthdr; 26 proto = oip6h->nexthdr;
36 tcphoff = ipv6_skip_exthdr(oldskb, ((u8*)(oip6h+1) - oldskb->data), &proto, &frag_off); 27 tcphoff = ipv6_skip_exthdr(oldskb, ((u8*)(oip6h+1) - oldskb->data),
28 &proto, &frag_off);
37 29
38 if ((tcphoff < 0) || (tcphoff > oldskb->len)) { 30 if ((tcphoff < 0) || (tcphoff > oldskb->len)) {
39 pr_debug("Cannot get TCP header.\n"); 31 pr_debug("Cannot get TCP header.\n");
40 return; 32 return NULL;
41 } 33 }
42 34
43 otcplen = oldskb->len - tcphoff; 35 *otcplen = oldskb->len - tcphoff;
44 36
45 /* IP header checks: fragment, too short. */ 37 /* IP header checks: fragment, too short. */
46 if (proto != IPPROTO_TCP || otcplen < sizeof(struct tcphdr)) { 38 if (proto != IPPROTO_TCP || *otcplen < sizeof(struct tcphdr)) {
47 pr_debug("proto(%d) != IPPROTO_TCP, " 39 pr_debug("proto(%d) != IPPROTO_TCP or too short (len = %d)\n",
48 "or too short. otcplen = %d\n", 40 proto, *otcplen);
49 proto, otcplen); 41 return NULL;
50 return;
51 } 42 }
52 43
53 if (skb_copy_bits(oldskb, tcphoff, &otcph, sizeof(struct tcphdr))) 44 otcph = skb_header_pointer(oldskb, tcphoff, sizeof(struct tcphdr),
54 BUG(); 45 otcph);
46 if (otcph == NULL)
47 return NULL;
55 48
56 /* No RST for RST. */ 49 /* No RST for RST. */
57 if (otcph.rst) { 50 if (otcph->rst) {
58 pr_debug("RST is set\n"); 51 pr_debug("RST is set\n");
59 return; 52 return NULL;
60 } 53 }
61 54
62 /* Check checksum. */ 55 /* Check checksum. */
63 if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) { 56 if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) {
64 pr_debug("TCP checksum is invalid\n"); 57 pr_debug("TCP checksum is invalid\n");
65 return; 58 return NULL;
66 } 59 }
67 60
68 memset(&fl6, 0, sizeof(fl6)); 61 return otcph;
69 fl6.flowi6_proto = IPPROTO_TCP; 62}
70 fl6.saddr = oip6h->daddr; 63EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_get);
71 fl6.daddr = oip6h->saddr;
72 fl6.fl6_sport = otcph.dest;
73 fl6.fl6_dport = otcph.source;
74 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
75 dst = ip6_route_output(net, NULL, &fl6);
76 if (dst == NULL || dst->error) {
77 dst_release(dst);
78 return;
79 }
80 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
81 if (IS_ERR(dst))
82 return;
83
84 hh_len = (dst->dev->hard_header_len + 15)&~15;
85 nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr)
86 + sizeof(struct tcphdr) + dst->trailer_len,
87 GFP_ATOMIC);
88
89 if (!nskb) {
90 net_dbg_ratelimited("cannot alloc skb\n");
91 dst_release(dst);
92 return;
93 }
94
95 skb_dst_set(nskb, dst);
96 64
97 skb_reserve(nskb, hh_len + dst->header_len); 65struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
66 const struct sk_buff *oldskb,
67 __be16 protocol, int hoplimit)
68{
69 struct ipv6hdr *ip6h;
70 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
71#define DEFAULT_TOS_VALUE 0x0U
72 const __u8 tclass = DEFAULT_TOS_VALUE;
98 73
99 skb_put(nskb, sizeof(struct ipv6hdr)); 74 skb_put(nskb, sizeof(struct ipv6hdr));
100 skb_reset_network_header(nskb); 75 skb_reset_network_header(nskb);
101 ip6h = ipv6_hdr(nskb); 76 ip6h = ipv6_hdr(nskb);
102 ip6_flow_hdr(ip6h, tclass, 0); 77 ip6_flow_hdr(ip6h, tclass, 0);
103 ip6h->hop_limit = ip6_dst_hoplimit(dst); 78 ip6h->hop_limit = hoplimit;
104 ip6h->nexthdr = IPPROTO_TCP; 79 ip6h->nexthdr = protocol;
105 ip6h->saddr = oip6h->daddr; 80 ip6h->saddr = oip6h->daddr;
106 ip6h->daddr = oip6h->saddr; 81 ip6h->daddr = oip6h->saddr;
107 82
83 nskb->protocol = htons(ETH_P_IPV6);
84
85 return ip6h;
86}
87EXPORT_SYMBOL_GPL(nf_reject_ip6hdr_put);
88
89void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
90 const struct sk_buff *oldskb,
91 const struct tcphdr *oth, unsigned int otcplen)
92{
93 struct tcphdr *tcph;
94 int needs_ack;
95
108 skb_reset_transport_header(nskb); 96 skb_reset_transport_header(nskb);
109 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); 97 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
110 /* Truncate to length (no data) */ 98 /* Truncate to length (no data) */
111 tcph->doff = sizeof(struct tcphdr)/4; 99 tcph->doff = sizeof(struct tcphdr)/4;
112 tcph->source = otcph.dest; 100 tcph->source = oth->dest;
113 tcph->dest = otcph.source; 101 tcph->dest = oth->source;
114 102
115 if (otcph.ack) { 103 if (oth->ack) {
116 needs_ack = 0; 104 needs_ack = 0;
117 tcph->seq = otcph.ack_seq; 105 tcph->seq = oth->ack_seq;
118 tcph->ack_seq = 0; 106 tcph->ack_seq = 0;
119 } else { 107 } else {
120 needs_ack = 1; 108 needs_ack = 1;
121 tcph->ack_seq = htonl(ntohl(otcph.seq) + otcph.syn + otcph.fin 109 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin +
122 + otcplen - (otcph.doff<<2)); 110 otcplen - (oth->doff<<2));
123 tcph->seq = 0; 111 tcph->seq = 0;
124 } 112 }
125 113
@@ -137,6 +125,63 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
137 sizeof(struct tcphdr), IPPROTO_TCP, 125 sizeof(struct tcphdr), IPPROTO_TCP,
138 csum_partial(tcph, 126 csum_partial(tcph,
139 sizeof(struct tcphdr), 0)); 127 sizeof(struct tcphdr), 0));
128}
129EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_put);
130
131void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
132{
133 struct sk_buff *nskb;
134 struct tcphdr _otcph;
135 const struct tcphdr *otcph;
136 unsigned int otcplen, hh_len;
137 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
138 struct ipv6hdr *ip6h;
139 struct dst_entry *dst = NULL;
140 struct flowi6 fl6;
141
142 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
143 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) {
144 pr_debug("addr is not unicast.\n");
145 return;
146 }
147
148 otcph = nf_reject_ip6_tcphdr_get(oldskb, &_otcph, &otcplen, hook);
149 if (!otcph)
150 return;
151
152 memset(&fl6, 0, sizeof(fl6));
153 fl6.flowi6_proto = IPPROTO_TCP;
154 fl6.saddr = oip6h->daddr;
155 fl6.daddr = oip6h->saddr;
156 fl6.fl6_sport = otcph->dest;
157 fl6.fl6_dport = otcph->source;
158 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
159 dst = ip6_route_output(net, NULL, &fl6);
160 if (dst == NULL || dst->error) {
161 dst_release(dst);
162 return;
163 }
164 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
165 if (IS_ERR(dst))
166 return;
167
168 hh_len = (dst->dev->hard_header_len + 15)&~15;
169 nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr)
170 + sizeof(struct tcphdr) + dst->trailer_len,
171 GFP_ATOMIC);
172
173 if (!nskb) {
174 net_dbg_ratelimited("cannot alloc skb\n");
175 dst_release(dst);
176 return;
177 }
178
179 skb_dst_set(nskb, dst);
180
181 skb_reserve(nskb, hh_len + dst->header_len);
182 ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
183 ip6_dst_hoplimit(dst));
184 nf_reject_ip6_tcphdr_put(nskb, oldskb, otcph, otcplen);
140 185
141 nf_ct_attach(nskb, oldskb); 186 nf_ct_attach(nskb, oldskb);
142 187
@@ -161,3 +206,5 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
161 ip6_local_out(nskb); 206 ip6_local_out(nskb);
162} 207}
163EXPORT_SYMBOL_GPL(nf_send_reset6); 208EXPORT_SYMBOL_GPL(nf_send_reset6);
209
210MODULE_LICENSE("GPL");
diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c
index 556262f40761..8a7ac685076d 100644
--- a/net/ipv6/netfilter/nft_masq_ipv6.c
+++ b/net/ipv6/netfilter/nft_masq_ipv6.c
@@ -39,6 +39,7 @@ static const struct nft_expr_ops nft_masq_ipv6_ops = {
39 .eval = nft_masq_ipv6_eval, 39 .eval = nft_masq_ipv6_eval,
40 .init = nft_masq_init, 40 .init = nft_masq_init,
41 .dump = nft_masq_dump, 41 .dump = nft_masq_dump,
42 .validate = nft_masq_validate,
42}; 43};
43 44
44static struct nft_expr_type nft_masq_ipv6_type __read_mostly = { 45static struct nft_expr_type nft_masq_ipv6_type __read_mostly = {
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index fc24c390af05..97f41a3e68d9 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -3,11 +3,45 @@
3 * not configured or static. These functions are needed by GSO/GRO implementation. 3 * not configured or static. These functions are needed by GSO/GRO implementation.
4 */ 4 */
5#include <linux/export.h> 5#include <linux/export.h>
6#include <net/ip.h>
6#include <net/ipv6.h> 7#include <net/ipv6.h>
7#include <net/ip6_fib.h> 8#include <net/ip6_fib.h>
8#include <net/addrconf.h> 9#include <net/addrconf.h>
9#include <net/secure_seq.h> 10#include <net/secure_seq.h>
10 11
12/* This function exists only for tap drivers that must support broken
13 * clients requesting UFO without specifying an IPv6 fragment ID.
14 *
15 * This is similar to ipv6_select_ident() but we use an independent hash
16 * seed to limit information leakage.
17 *
18 * The network header must be set before calling this.
19 */
20void ipv6_proxy_select_ident(struct sk_buff *skb)
21{
22 static u32 ip6_proxy_idents_hashrnd __read_mostly;
23 struct in6_addr buf[2];
24 struct in6_addr *addrs;
25 u32 hash, id;
26
27 addrs = skb_header_pointer(skb,
28 skb_network_offset(skb) +
29 offsetof(struct ipv6hdr, saddr),
30 sizeof(buf), buf);
31 if (!addrs)
32 return;
33
34 net_get_random_once(&ip6_proxy_idents_hashrnd,
35 sizeof(ip6_proxy_idents_hashrnd));
36
37 hash = __ipv6_addr_jhash(&addrs[1], ip6_proxy_idents_hashrnd);
38 hash = __ipv6_addr_jhash(&addrs[0], hash);
39
40 id = ip_idents_reserve(hash, 1);
41 skb_shinfo(skb)->ip6_frag_id = htonl(id);
42}
43EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
44
11int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) 45int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
12{ 46{
13 u16 offset = sizeof(struct ipv6hdr); 47 u16 offset = sizeof(struct ipv6hdr);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 831495529b82..ace29b60813c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -200,8 +200,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
200 sk->sk_v6_daddr = usin->sin6_addr; 200 sk->sk_v6_daddr = usin->sin6_addr;
201 np->flow_label = fl6.flowlabel; 201 np->flow_label = fl6.flowlabel;
202 202
203 ip6_set_txhash(sk);
204
205 /* 203 /*
206 * TCP over IPv4 204 * TCP over IPv4
207 */ 205 */
@@ -297,6 +295,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
297 if (err) 295 if (err)
298 goto late_failure; 296 goto late_failure;
299 297
298 ip6_set_txhash(sk);
299
300 if (!tp->write_seq && likely(!tp->repair)) 300 if (!tp->write_seq && likely(!tp->repair))
301 tp->write_seq = secure_tcpv6_sequence_number(np->saddr.s6_addr32, 301 tp->write_seq = secure_tcpv6_sequence_number(np->saddr.s6_addr32,
302 sk->sk_v6_daddr.s6_addr32, 302 sk->sk_v6_daddr.s6_addr32,
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index ac49f84fe2c3..5f983644373a 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -170,8 +170,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
170 case IPPROTO_DCCP: 170 case IPPROTO_DCCP:
171 if (!onlyproto && (nh + offset + 4 < skb->data || 171 if (!onlyproto && (nh + offset + 4 < skb->data ||
172 pskb_may_pull(skb, nh + offset + 4 - skb->data))) { 172 pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
173 __be16 *ports = (__be16 *)exthdr; 173 __be16 *ports;
174 174
175 nh = skb_network_header(skb);
176 ports = (__be16 *)(nh + offset);
175 fl6->fl6_sport = ports[!!reverse]; 177 fl6->fl6_sport = ports[!!reverse];
176 fl6->fl6_dport = ports[!reverse]; 178 fl6->fl6_dport = ports[!reverse];
177 } 179 }
@@ -180,8 +182,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
180 182
181 case IPPROTO_ICMPV6: 183 case IPPROTO_ICMPV6:
182 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) { 184 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
183 u8 *icmp = (u8 *)exthdr; 185 u8 *icmp;
184 186
187 nh = skb_network_header(skb);
188 icmp = (u8 *)(nh + offset);
185 fl6->fl6_icmp_type = icmp[0]; 189 fl6->fl6_icmp_type = icmp[0];
186 fl6->fl6_icmp_code = icmp[1]; 190 fl6->fl6_icmp_code = icmp[1];
187 } 191 }
@@ -192,8 +196,9 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
192 case IPPROTO_MH: 196 case IPPROTO_MH:
193 if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) { 197 if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
194 struct ip6_mh *mh; 198 struct ip6_mh *mh;
195 mh = (struct ip6_mh *)exthdr;
196 199
200 nh = skb_network_header(skb);
201 mh = (struct ip6_mh *)(nh + offset);
197 fl6->fl6_mh_type = mh->ip6mh_type; 202 fl6->fl6_mh_type = mh->ip6mh_type;
198 } 203 }
199 fl6->flowi6_proto = nexthdr; 204 fl6->flowi6_proto = nexthdr;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 92fafd485deb..3f3a6cbdceb7 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1064,8 +1064,6 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
1064 1064
1065 if (sk->sk_state != TCP_ESTABLISHED) { 1065 if (sk->sk_state != TCP_ESTABLISHED) {
1066 sock->state = SS_UNCONNECTED; 1066 sock->state = SS_UNCONNECTED;
1067 if (sk->sk_prot->disconnect(sk, flags))
1068 sock->state = SS_DISCONNECTING;
1069 err = sock_error(sk); 1067 err = sock_error(sk);
1070 if (!err) 1068 if (!err)
1071 err = -ECONNRESET; 1069 err = -ECONNRESET;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index fb6a1502b6df..343da1e35025 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3458,7 +3458,7 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3458 rcu_read_lock(); 3458 rcu_read_lock();
3459 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3459 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3460 if (chanctx_conf) { 3460 if (chanctx_conf) {
3461 *chandef = chanctx_conf->def; 3461 *chandef = sdata->vif.bss_conf.chandef;
3462 ret = 0; 3462 ret = 0;
3463 } else if (local->open_count > 0 && 3463 } else if (local->open_count > 0 &&
3464 local->open_count == local->monitors && 3464 local->open_count == local->monitors &&
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 8fdadfd94ba8..6081329784dd 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
448 */ 448 */
449 if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) { 449 if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
450 u32 basic_rates = vif->bss_conf.basic_rates; 450 u32 basic_rates = vif->bss_conf.basic_rates;
451 s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0; 451 s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
452 452
453 rate = &sband->bitrates[rates[0].idx]; 453 rate = &sband->bitrates[rates[0].idx];
454 454
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index edde723f9f00..2acab1bcaa4b 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -62,14 +62,14 @@ minstrel_stats_open(struct inode *inode, struct file *file)
62 unsigned int i, tp, prob, eprob; 62 unsigned int i, tp, prob, eprob;
63 char *p; 63 char *p;
64 64
65 ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL); 65 ms = kmalloc(2048, GFP_KERNEL);
66 if (!ms) 66 if (!ms)
67 return -ENOMEM; 67 return -ENOMEM;
68 68
69 file->private_data = ms; 69 file->private_data = ms;
70 p = ms->buf; 70 p = ms->buf;
71 p += sprintf(p, "rate throughput ewma prob this prob " 71 p += sprintf(p, "rate tpt eprob *prob"
72 "this succ/attempt success attempts\n"); 72 " *ok(*cum) ok( cum)\n");
73 for (i = 0; i < mi->n_rates; i++) { 73 for (i = 0; i < mi->n_rates; i++) {
74 struct minstrel_rate *mr = &mi->r[i]; 74 struct minstrel_rate *mr = &mi->r[i];
75 struct minstrel_rate_stats *mrs = &mi->r[i].stats; 75 struct minstrel_rate_stats *mrs = &mi->r[i].stats;
@@ -86,8 +86,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
86 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); 86 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
87 eprob = MINSTREL_TRUNC(mrs->probability * 1000); 87 eprob = MINSTREL_TRUNC(mrs->probability * 1000);
88 88
89 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 89 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u"
90 " %3u(%3u) %8llu %8llu\n", 90 " %4u(%4u) %9llu(%9llu)\n",
91 tp / 10, tp % 10, 91 tp / 10, tp % 10,
92 eprob / 10, eprob % 10, 92 eprob / 10, eprob % 10,
93 prob / 10, prob % 10, 93 prob / 10, prob % 10,
@@ -102,6 +102,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
102 mi->sample_packets); 102 mi->sample_packets);
103 ms->len = p - ms->buf; 103 ms->len = p - ms->buf;
104 104
105 WARN_ON(ms->len + sizeof(*ms) > 2048);
106
105 return 0; 107 return 0;
106} 108}
107 109
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index a72ad46f2a04..d537bec93754 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -63,8 +63,8 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
63 prob = MINSTREL_TRUNC(mr->cur_prob * 1000); 63 prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
64 eprob = MINSTREL_TRUNC(mr->probability * 1000); 64 eprob = MINSTREL_TRUNC(mr->probability * 1000);
65 65
66 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 66 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u "
67 "%3u %3u(%3u) %8llu %8llu\n", 67 "%3u %4u(%4u) %9llu(%9llu)\n",
68 tp / 10, tp % 10, 68 tp / 10, tp % 10,
69 eprob / 10, eprob % 10, 69 eprob / 10, eprob % 10,
70 prob / 10, prob % 10, 70 prob / 10, prob % 10,
@@ -96,14 +96,15 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
96 return ret; 96 return ret;
97 } 97 }
98 98
99 ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL); 99 ms = kmalloc(8192, GFP_KERNEL);
100 if (!ms) 100 if (!ms)
101 return -ENOMEM; 101 return -ENOMEM;
102 102
103 file->private_data = ms; 103 file->private_data = ms;
104 p = ms->buf; 104 p = ms->buf;
105 p += sprintf(p, "type rate throughput ewma prob " 105 p += sprintf(p, "type rate tpt eprob *prob "
106 "this prob retry this succ/attempt success attempts\n"); 106 "ret *ok(*cum) ok( cum)\n");
107
107 108
108 p = minstrel_ht_stats_dump(mi, max_mcs, p); 109 p = minstrel_ht_stats_dump(mi, max_mcs, p);
109 for (i = 0; i < max_mcs; i++) 110 for (i = 0; i < max_mcs; i++)
@@ -118,6 +119,8 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
118 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10); 119 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
119 ms->len = p - ms->buf; 120 ms->len = p - ms->buf;
120 121
122 WARN_ON(ms->len + sizeof(*ms) > 8192);
123
121 return nonseekable_open(inode, file); 124 return nonseekable_open(inode, file);
122} 125}
123 126
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 42f68cb8957e..bcda2ac7d844 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -336,6 +336,7 @@ struct ieee80211_tx_latency_stat {
336 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for 336 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for
337 * AP only. 337 * AP only.
338 * @cipher_scheme: optional cipher scheme for this station 338 * @cipher_scheme: optional cipher scheme for this station
339 * @last_tdls_pkt_time: holds the time in jiffies of last TDLS pkt ACKed
339 */ 340 */
340struct sta_info { 341struct sta_info {
341 /* General information, mostly static */ 342 /* General information, mostly static */
diff --git a/net/mpls/Makefile b/net/mpls/Makefile
index 0a3c171be537..6dec088c2d0f 100644
--- a/net/mpls/Makefile
+++ b/net/mpls/Makefile
@@ -1,4 +1,4 @@
1# 1#
2# Makefile for MPLS. 2# Makefile for MPLS.
3# 3#
4obj-y += mpls_gso.o 4obj-$(CONFIG_NET_MPLS_GSO) += mpls_gso.o
diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c
index e28ed2ef5b06..e3545f21a099 100644
--- a/net/mpls/mpls_gso.c
+++ b/net/mpls/mpls_gso.c
@@ -48,7 +48,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
48 __skb_push(skb, skb->mac_len); 48 __skb_push(skb, skb->mac_len);
49 49
50 /* Segment inner packet. */ 50 /* Segment inner packet. */
51 mpls_features = skb->dev->mpls_features & netif_skb_features(skb); 51 mpls_features = skb->dev->mpls_features & features;
52 segs = skb_mac_gso_segment(skb, mpls_features); 52 segs = skb_mac_gso_segment(skb, mpls_features);
53 53
54 54
@@ -59,8 +59,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
59 * above pulled. It will be re-pushed after returning 59 * above pulled. It will be re-pushed after returning
60 * skb_mac_gso_segment(), an indirect caller of this function. 60 * skb_mac_gso_segment(), an indirect caller of this function.
61 */ 61 */
62 __skb_push(skb, skb->data - skb_mac_header(skb)); 62 __skb_pull(skb, skb->data - skb_mac_header(skb));
63
64out: 63out:
65 return segs; 64 return segs;
66} 65}
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 912e5a05b79d..86f9d76b1464 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -659,7 +659,7 @@ ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index)
659 struct ip_set *set; 659 struct ip_set *set;
660 struct ip_set_net *inst = ip_set_pernet(net); 660 struct ip_set_net *inst = ip_set_pernet(net);
661 661
662 if (index > inst->ip_set_max) 662 if (index >= inst->ip_set_max)
663 return IPSET_INVALID_ID; 663 return IPSET_INVALID_ID;
664 664
665 nfnl_lock(NFNL_SUBSYS_IPSET); 665 nfnl_lock(NFNL_SUBSYS_IPSET);
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 91f17c1eb8a2..437a3663ad03 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -316,7 +316,7 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest,
316 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode, 316 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode,
317 local))) { 317 local))) {
318 IP_VS_DBG_RL("We are crossing local and non-local addresses" 318 IP_VS_DBG_RL("We are crossing local and non-local addresses"
319 " daddr=%pI4\n", &dest->addr.ip); 319 " daddr=%pI4\n", &daddr);
320 goto err_put; 320 goto err_put;
321 } 321 }
322 322
@@ -458,7 +458,7 @@ __ip_vs_get_out_rt_v6(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest,
458 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode, 458 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode,
459 local))) { 459 local))) {
460 IP_VS_DBG_RL("We are crossing local and non-local addresses" 460 IP_VS_DBG_RL("We are crossing local and non-local addresses"
461 " daddr=%pI6\n", &dest->addr.in6); 461 " daddr=%pI6\n", daddr);
462 goto err_put; 462 goto err_put;
463 } 463 }
464 464
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 44d1ea32570a..d87b6423ffb2 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -213,7 +213,7 @@ static const u8 tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
213 { 213 {
214/* REPLY */ 214/* REPLY */
215/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */ 215/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */
216/*syn*/ { sIV, sS2, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sS2 }, 216/*syn*/ { sIV, sS2, sIV, sIV, sIV, sIV, sIV, sSS, sIV, sS2 },
217/* 217/*
218 * sNO -> sIV Never reached. 218 * sNO -> sIV Never reached.
219 * sSS -> sS2 Simultaneous open 219 * sSS -> sS2 Simultaneous open
@@ -223,7 +223,7 @@ static const u8 tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
223 * sFW -> sIV 223 * sFW -> sIV
224 * sCW -> sIV 224 * sCW -> sIV
225 * sLA -> sIV 225 * sLA -> sIV
226 * sTW -> sIV Reopened connection, but server may not do it. 226 * sTW -> sSS Reopened connection, but server may have switched role
227 * sCL -> sIV 227 * sCL -> sIV
228 */ 228 */
229/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */ 229/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 556a0dfa4abc..11ab4b078f3b 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1328,10 +1328,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
1328 basechain->stats = stats; 1328 basechain->stats = stats;
1329 } else { 1329 } else {
1330 stats = netdev_alloc_pcpu_stats(struct nft_stats); 1330 stats = netdev_alloc_pcpu_stats(struct nft_stats);
1331 if (IS_ERR(stats)) { 1331 if (stats == NULL) {
1332 module_put(type->owner); 1332 module_put(type->owner);
1333 kfree(basechain); 1333 kfree(basechain);
1334 return PTR_ERR(stats); 1334 return -ENOMEM;
1335 } 1335 }
1336 rcu_assign_pointer(basechain->stats, stats); 1336 rcu_assign_pointer(basechain->stats, stats);
1337 } 1337 }
@@ -3744,6 +3744,20 @@ static const struct nfnetlink_subsystem nf_tables_subsys = {
3744 .abort = nf_tables_abort, 3744 .abort = nf_tables_abort,
3745}; 3745};
3746 3746
3747int nft_chain_validate_dependency(const struct nft_chain *chain,
3748 enum nft_chain_type type)
3749{
3750 const struct nft_base_chain *basechain;
3751
3752 if (chain->flags & NFT_BASE_CHAIN) {
3753 basechain = nft_base_chain(chain);
3754 if (basechain->type->type != type)
3755 return -EOPNOTSUPP;
3756 }
3757 return 0;
3758}
3759EXPORT_SYMBOL_GPL(nft_chain_validate_dependency);
3760
3747/* 3761/*
3748 * Loop detection - walk through the ruleset beginning at the destination chain 3762 * Loop detection - walk through the ruleset beginning at the destination chain
3749 * of a new jump until either the source chain is reached (loop) or all 3763 * of a new jump until either the source chain is reached (loop) or all
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index b1e3a0579416..5f1be5ba3559 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -43,7 +43,8 @@
43#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE 43#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE
44#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */ 44#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */
45#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */ 45#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */
46#define NFULNL_COPY_RANGE_MAX 0xFFFF /* max packet size is limited by 16-bit struct nfattr nfa_len field */ 46/* max packet size is limited by 16-bit struct nfattr nfa_len field */
47#define NFULNL_COPY_RANGE_MAX (0xFFFF - NLA_HDRLEN)
47 48
48#define PRINTR(x, args...) do { if (net_ratelimit()) \ 49#define PRINTR(x, args...) do { if (net_ratelimit()) \
49 printk(x, ## args); } while (0); 50 printk(x, ## args); } while (0);
@@ -252,6 +253,8 @@ nfulnl_set_mode(struct nfulnl_instance *inst, u_int8_t mode,
252 253
253 case NFULNL_COPY_PACKET: 254 case NFULNL_COPY_PACKET:
254 inst->copy_mode = mode; 255 inst->copy_mode = mode;
256 if (range == 0)
257 range = NFULNL_COPY_RANGE_MAX;
255 inst->copy_range = min_t(unsigned int, 258 inst->copy_range = min_t(unsigned int,
256 range, NFULNL_COPY_RANGE_MAX); 259 range, NFULNL_COPY_RANGE_MAX);
257 break; 260 break;
@@ -343,26 +346,25 @@ nfulnl_alloc_skb(struct net *net, u32 peer_portid, unsigned int inst_size,
343 return skb; 346 return skb;
344} 347}
345 348
346static int 349static void
347__nfulnl_send(struct nfulnl_instance *inst) 350__nfulnl_send(struct nfulnl_instance *inst)
348{ 351{
349 int status = -1;
350
351 if (inst->qlen > 1) { 352 if (inst->qlen > 1) {
352 struct nlmsghdr *nlh = nlmsg_put(inst->skb, 0, 0, 353 struct nlmsghdr *nlh = nlmsg_put(inst->skb, 0, 0,
353 NLMSG_DONE, 354 NLMSG_DONE,
354 sizeof(struct nfgenmsg), 355 sizeof(struct nfgenmsg),
355 0); 356 0);
356 if (!nlh) 357 if (WARN_ONCE(!nlh, "bad nlskb size: %u, tailroom %d\n",
358 inst->skb->len, skb_tailroom(inst->skb))) {
359 kfree_skb(inst->skb);
357 goto out; 360 goto out;
361 }
358 } 362 }
359 status = nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid, 363 nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
360 MSG_DONTWAIT); 364 MSG_DONTWAIT);
361 365out:
362 inst->qlen = 0; 366 inst->qlen = 0;
363 inst->skb = NULL; 367 inst->skb = NULL;
364out:
365 return status;
366} 368}
367 369
368static void 370static void
@@ -649,7 +651,8 @@ nfulnl_log_packet(struct net *net,
649 + nla_total_size(sizeof(u_int32_t)) /* gid */ 651 + nla_total_size(sizeof(u_int32_t)) /* gid */
650 + nla_total_size(plen) /* prefix */ 652 + nla_total_size(plen) /* prefix */
651 + nla_total_size(sizeof(struct nfulnl_msg_packet_hw)) 653 + nla_total_size(sizeof(struct nfulnl_msg_packet_hw))
652 + nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp)); 654 + nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp))
655 + nla_total_size(sizeof(struct nfgenmsg)); /* NLMSG_DONE */
653 656
654 if (in && skb_mac_header_was_set(skb)) { 657 if (in && skb_mac_header_was_set(skb)) {
655 size += nla_total_size(skb->dev->hard_header_len) 658 size += nla_total_size(skb->dev->hard_header_len)
@@ -678,8 +681,7 @@ nfulnl_log_packet(struct net *net,
678 break; 681 break;
679 682
680 case NFULNL_COPY_PACKET: 683 case NFULNL_COPY_PACKET:
681 if (inst->copy_range == 0 684 if (inst->copy_range > skb->len)
682 || inst->copy_range > skb->len)
683 data_len = skb->len; 685 data_len = skb->len;
684 else 686 else
685 data_len = inst->copy_range; 687 data_len = inst->copy_range;
@@ -692,8 +694,7 @@ nfulnl_log_packet(struct net *net,
692 goto unlock_and_release; 694 goto unlock_and_release;
693 } 695 }
694 696
695 if (inst->skb && 697 if (inst->skb && size > skb_tailroom(inst->skb)) {
696 size > skb_tailroom(inst->skb) - sizeof(struct nfgenmsg)) {
697 /* either the queue len is too high or we don't have 698 /* either the queue len is too high or we don't have
698 * enough room in the skb left. flush to userspace. */ 699 * enough room in the skb left. flush to userspace. */
699 __nfulnl_flush(inst); 700 __nfulnl_flush(inst);
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index a82077d9f59b..7c60ccd61a3e 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -665,7 +665,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
665 * returned by nf_queue. For instance, callers rely on -ECANCELED to 665 * returned by nf_queue. For instance, callers rely on -ECANCELED to
666 * mean 'ignore this hook'. 666 * mean 'ignore this hook'.
667 */ 667 */
668 if (IS_ERR(segs)) 668 if (IS_ERR_OR_NULL(segs))
669 goto out_err; 669 goto out_err;
670 queued = 0; 670 queued = 0;
671 err = 0; 671 err = 0;
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 7e2683c8a44a..9d6d6f60a80f 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -19,9 +19,52 @@
19#include <linux/netfilter/x_tables.h> 19#include <linux/netfilter/x_tables.h>
20#include <linux/netfilter_ipv4/ip_tables.h> 20#include <linux/netfilter_ipv4/ip_tables.h>
21#include <linux/netfilter_ipv6/ip6_tables.h> 21#include <linux/netfilter_ipv6/ip6_tables.h>
22#include <asm/uaccess.h> /* for set_fs */
23#include <net/netfilter/nf_tables.h> 22#include <net/netfilter/nf_tables.h>
24 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,
49 const struct nft_chain *chain)
50{
51 enum nft_chain_type type;
52 const struct nft_base_chain *basechain;
53
54 if (!tablename || !(chain->flags & NFT_BASE_CHAIN))
55 return 0;
56
57 type = nft_compat_table_to_chaintype(tablename);
58 if (type < 0)
59 return -EINVAL;
60
61 basechain = nft_base_chain(chain);
62 if (basechain->type->type != type)
63 return -EINVAL;
64
65 return 0;
66}
67
25union nft_entry { 68union nft_entry {
26 struct ipt_entry e4; 69 struct ipt_entry e4;
27 struct ip6t_entry e6; 70 struct ip6t_entry e6;
@@ -95,6 +138,8 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
95 const struct nf_hook_ops *ops = &basechain->ops[0]; 138 const struct nf_hook_ops *ops = &basechain->ops[0];
96 139
97 par->hook_mask = 1 << ops->hooknum; 140 par->hook_mask = 1 << ops->hooknum;
141 } else {
142 par->hook_mask = 0;
98 } 143 }
99 par->family = ctx->afi->family; 144 par->family = ctx->afi->family;
100} 145}
@@ -151,6 +196,10 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
151 union nft_entry e = {}; 196 union nft_entry e = {};
152 int ret; 197 int ret;
153 198
199 ret = nft_compat_chain_validate_dependency(target->table, ctx->chain);
200 if (ret < 0)
201 goto err;
202
154 target_compat_from_user(target, nla_data(tb[NFTA_TARGET_INFO]), info); 203 target_compat_from_user(target, nla_data(tb[NFTA_TARGET_INFO]), info);
155 204
156 if (ctx->nla[NFTA_RULE_COMPAT]) { 205 if (ctx->nla[NFTA_RULE_COMPAT]) {
@@ -216,6 +265,7 @@ static int nft_target_validate(const struct nft_ctx *ctx,
216{ 265{
217 struct xt_target *target = expr->ops->data; 266 struct xt_target *target = expr->ops->data;
218 unsigned int hook_mask = 0; 267 unsigned int hook_mask = 0;
268 int ret;
219 269
220 if (ctx->chain->flags & NFT_BASE_CHAIN) { 270 if (ctx->chain->flags & NFT_BASE_CHAIN) {
221 const struct nft_base_chain *basechain = 271 const struct nft_base_chain *basechain =
@@ -223,11 +273,13 @@ static int nft_target_validate(const struct nft_ctx *ctx,
223 const struct nf_hook_ops *ops = &basechain->ops[0]; 273 const struct nf_hook_ops *ops = &basechain->ops[0];
224 274
225 hook_mask = 1 << ops->hooknum; 275 hook_mask = 1 << ops->hooknum;
226 if (hook_mask & target->hooks) 276 if (!(hook_mask & target->hooks))
227 return 0; 277 return -EINVAL;
228 278
229 /* This target is being called from an invalid chain */ 279 ret = nft_compat_chain_validate_dependency(target->table,
230 return -EINVAL; 280 ctx->chain);
281 if (ret < 0)
282 return ret;
231 } 283 }
232 return 0; 284 return 0;
233} 285}
@@ -293,6 +345,8 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
293 const struct nf_hook_ops *ops = &basechain->ops[0]; 345 const struct nf_hook_ops *ops = &basechain->ops[0];
294 346
295 par->hook_mask = 1 << ops->hooknum; 347 par->hook_mask = 1 << ops->hooknum;
348 } else {
349 par->hook_mask = 0;
296 } 350 }
297 par->family = ctx->afi->family; 351 par->family = ctx->afi->family;
298} 352}
@@ -320,6 +374,10 @@ nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
320 union nft_entry e = {}; 374 union nft_entry e = {};
321 int ret; 375 int ret;
322 376
377 ret = nft_compat_chain_validate_dependency(match->name, ctx->chain);
378 if (ret < 0)
379 goto err;
380
323 match_compat_from_user(match, nla_data(tb[NFTA_MATCH_INFO]), info); 381 match_compat_from_user(match, nla_data(tb[NFTA_MATCH_INFO]), info);
324 382
325 if (ctx->nla[NFTA_RULE_COMPAT]) { 383 if (ctx->nla[NFTA_RULE_COMPAT]) {
@@ -379,6 +437,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
379{ 437{
380 struct xt_match *match = expr->ops->data; 438 struct xt_match *match = expr->ops->data;
381 unsigned int hook_mask = 0; 439 unsigned int hook_mask = 0;
440 int ret;
382 441
383 if (ctx->chain->flags & NFT_BASE_CHAIN) { 442 if (ctx->chain->flags & NFT_BASE_CHAIN) {
384 const struct nft_base_chain *basechain = 443 const struct nft_base_chain *basechain =
@@ -386,11 +445,13 @@ static int nft_match_validate(const struct nft_ctx *ctx,
386 const struct nf_hook_ops *ops = &basechain->ops[0]; 445 const struct nf_hook_ops *ops = &basechain->ops[0];
387 446
388 hook_mask = 1 << ops->hooknum; 447 hook_mask = 1 << ops->hooknum;
389 if (hook_mask & match->hooks) 448 if (!(hook_mask & match->hooks))
390 return 0; 449 return -EINVAL;
391 450
392 /* This match is being called from an invalid chain */ 451 ret = nft_compat_chain_validate_dependency(match->name,
393 return -EINVAL; 452 ctx->chain);
453 if (ret < 0)
454 return ret;
394 } 455 }
395 return 0; 456 return 0;
396} 457}
@@ -611,7 +672,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
611 family = ctx->afi->family; 672 family = ctx->afi->family;
612 673
613 /* Re-use the existing target if it's already loaded. */ 674 /* Re-use the existing target if it's already loaded. */
614 list_for_each_entry(nft_target, &nft_match_list, head) { 675 list_for_each_entry(nft_target, &nft_target_list, head) {
615 struct xt_target *target = nft_target->ops.data; 676 struct xt_target *target = nft_target->ops.data;
616 677
617 if (strcmp(target->name, tg_name) == 0 && 678 if (strcmp(target->name, tg_name) == 0 &&
diff --git a/net/netfilter/nft_masq.c b/net/netfilter/nft_masq.c
index 6637bab00567..d1ffd5eb3a9b 100644
--- a/net/netfilter/nft_masq.c
+++ b/net/netfilter/nft_masq.c
@@ -26,6 +26,11 @@ int nft_masq_init(const struct nft_ctx *ctx,
26 const struct nlattr * const tb[]) 26 const struct nlattr * const tb[])
27{ 27{
28 struct nft_masq *priv = nft_expr_priv(expr); 28 struct nft_masq *priv = nft_expr_priv(expr);
29 int err;
30
31 err = nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
32 if (err < 0)
33 return err;
29 34
30 if (tb[NFTA_MASQ_FLAGS] == NULL) 35 if (tb[NFTA_MASQ_FLAGS] == NULL)
31 return 0; 36 return 0;
@@ -55,5 +60,12 @@ nla_put_failure:
55} 60}
56EXPORT_SYMBOL_GPL(nft_masq_dump); 61EXPORT_SYMBOL_GPL(nft_masq_dump);
57 62
63int nft_masq_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
64 const struct nft_data **data)
65{
66 return nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
67}
68EXPORT_SYMBOL_GPL(nft_masq_validate);
69
58MODULE_LICENSE("GPL"); 70MODULE_LICENSE("GPL");
59MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>"); 71MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>");
diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
index 799550b476fb..afe2b0b45ec4 100644
--- a/net/netfilter/nft_nat.c
+++ b/net/netfilter/nft_nat.c
@@ -95,7 +95,13 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
95 u32 family; 95 u32 family;
96 int err; 96 int err;
97 97
98 if (tb[NFTA_NAT_TYPE] == NULL) 98 err = nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
99 if (err < 0)
100 return err;
101
102 if (tb[NFTA_NAT_TYPE] == NULL ||
103 (tb[NFTA_NAT_REG_ADDR_MIN] == NULL &&
104 tb[NFTA_NAT_REG_PROTO_MIN] == NULL))
99 return -EINVAL; 105 return -EINVAL;
100 106
101 switch (ntohl(nla_get_be32(tb[NFTA_NAT_TYPE]))) { 107 switch (ntohl(nla_get_be32(tb[NFTA_NAT_TYPE]))) {
@@ -120,38 +126,44 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
120 priv->family = family; 126 priv->family = family;
121 127
122 if (tb[NFTA_NAT_REG_ADDR_MIN]) { 128 if (tb[NFTA_NAT_REG_ADDR_MIN]) {
123 priv->sreg_addr_min = ntohl(nla_get_be32( 129 priv->sreg_addr_min =
124 tb[NFTA_NAT_REG_ADDR_MIN])); 130 ntohl(nla_get_be32(tb[NFTA_NAT_REG_ADDR_MIN]));
131
125 err = nft_validate_input_register(priv->sreg_addr_min); 132 err = nft_validate_input_register(priv->sreg_addr_min);
126 if (err < 0) 133 if (err < 0)
127 return err; 134 return err;
128 }
129 135
130 if (tb[NFTA_NAT_REG_ADDR_MAX]) { 136 if (tb[NFTA_NAT_REG_ADDR_MAX]) {
131 priv->sreg_addr_max = ntohl(nla_get_be32( 137 priv->sreg_addr_max =
132 tb[NFTA_NAT_REG_ADDR_MAX])); 138 ntohl(nla_get_be32(tb[NFTA_NAT_REG_ADDR_MAX]));
133 err = nft_validate_input_register(priv->sreg_addr_max); 139
134 if (err < 0) 140 err = nft_validate_input_register(priv->sreg_addr_max);
135 return err; 141 if (err < 0)
136 } else 142 return err;
137 priv->sreg_addr_max = priv->sreg_addr_min; 143 } else {
144 priv->sreg_addr_max = priv->sreg_addr_min;
145 }
146 }
138 147
139 if (tb[NFTA_NAT_REG_PROTO_MIN]) { 148 if (tb[NFTA_NAT_REG_PROTO_MIN]) {
140 priv->sreg_proto_min = ntohl(nla_get_be32( 149 priv->sreg_proto_min =
141 tb[NFTA_NAT_REG_PROTO_MIN])); 150 ntohl(nla_get_be32(tb[NFTA_NAT_REG_PROTO_MIN]));
151
142 err = nft_validate_input_register(priv->sreg_proto_min); 152 err = nft_validate_input_register(priv->sreg_proto_min);
143 if (err < 0) 153 if (err < 0)
144 return err; 154 return err;
145 }
146 155
147 if (tb[NFTA_NAT_REG_PROTO_MAX]) { 156 if (tb[NFTA_NAT_REG_PROTO_MAX]) {
148 priv->sreg_proto_max = ntohl(nla_get_be32( 157 priv->sreg_proto_max =
149 tb[NFTA_NAT_REG_PROTO_MAX])); 158 ntohl(nla_get_be32(tb[NFTA_NAT_REG_PROTO_MAX]));
150 err = nft_validate_input_register(priv->sreg_proto_max); 159
151 if (err < 0) 160 err = nft_validate_input_register(priv->sreg_proto_max);
152 return err; 161 if (err < 0)
153 } else 162 return err;
154 priv->sreg_proto_max = priv->sreg_proto_min; 163 } else {
164 priv->sreg_proto_max = priv->sreg_proto_min;
165 }
166 }
155 167
156 if (tb[NFTA_NAT_FLAGS]) { 168 if (tb[NFTA_NAT_FLAGS]) {
157 priv->flags = ntohl(nla_get_be32(tb[NFTA_NAT_FLAGS])); 169 priv->flags = ntohl(nla_get_be32(tb[NFTA_NAT_FLAGS]));
@@ -179,17 +191,19 @@ static int nft_nat_dump(struct sk_buff *skb, const struct nft_expr *expr)
179 191
180 if (nla_put_be32(skb, NFTA_NAT_FAMILY, htonl(priv->family))) 192 if (nla_put_be32(skb, NFTA_NAT_FAMILY, htonl(priv->family)))
181 goto nla_put_failure; 193 goto nla_put_failure;
182 if (nla_put_be32(skb, 194
183 NFTA_NAT_REG_ADDR_MIN, htonl(priv->sreg_addr_min))) 195 if (priv->sreg_addr_min) {
184 goto nla_put_failure; 196 if (nla_put_be32(skb, NFTA_NAT_REG_ADDR_MIN,
185 if (nla_put_be32(skb, 197 htonl(priv->sreg_addr_min)) ||
186 NFTA_NAT_REG_ADDR_MAX, htonl(priv->sreg_addr_max))) 198 nla_put_be32(skb, NFTA_NAT_REG_ADDR_MAX,
187 goto nla_put_failure; 199 htonl(priv->sreg_addr_max)))
200 goto nla_put_failure;
201 }
202
188 if (priv->sreg_proto_min) { 203 if (priv->sreg_proto_min) {
189 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MIN, 204 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MIN,
190 htonl(priv->sreg_proto_min))) 205 htonl(priv->sreg_proto_min)) ||
191 goto nla_put_failure; 206 nla_put_be32(skb, NFTA_NAT_REG_PROTO_MAX,
192 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MAX,
193 htonl(priv->sreg_proto_max))) 207 htonl(priv->sreg_proto_max)))
194 goto nla_put_failure; 208 goto nla_put_failure;
195 } 209 }
@@ -205,6 +219,13 @@ nla_put_failure:
205 return -1; 219 return -1;
206} 220}
207 221
222static int nft_nat_validate(const struct nft_ctx *ctx,
223 const struct nft_expr *expr,
224 const struct nft_data **data)
225{
226 return nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
227}
228
208static struct nft_expr_type nft_nat_type; 229static struct nft_expr_type nft_nat_type;
209static const struct nft_expr_ops nft_nat_ops = { 230static const struct nft_expr_ops nft_nat_ops = {
210 .type = &nft_nat_type, 231 .type = &nft_nat_type,
@@ -212,6 +233,7 @@ static const struct nft_expr_ops nft_nat_ops = {
212 .eval = nft_nat_eval, 233 .eval = nft_nat_eval,
213 .init = nft_nat_init, 234 .init = nft_nat_init,
214 .dump = nft_nat_dump, 235 .dump = nft_nat_dump,
236 .validate = nft_nat_validate,
215}; 237};
216 238
217static struct nft_expr_type nft_nat_type __read_mostly = { 239static struct nft_expr_type nft_nat_type __read_mostly = {
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 7a186e74b1b3..f1de72de273e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -96,6 +96,14 @@ static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
96static int netlink_dump(struct sock *sk); 96static int netlink_dump(struct sock *sk);
97static void netlink_skb_destructor(struct sk_buff *skb); 97static void netlink_skb_destructor(struct sk_buff *skb);
98 98
99/* nl_table locking explained:
100 * Lookup and traversal are protected with nl_sk_hash_lock or nl_table_lock
101 * combined with an RCU read-side lock. Insertion and removal are protected
102 * with nl_sk_hash_lock while using RCU list modification primitives and may
103 * run in parallel to nl_table_lock protected lookups. Destruction of the
104 * Netlink socket may only occur *after* nl_table_lock has been acquired
105 * either during or after the socket has been removed from the list.
106 */
99DEFINE_RWLOCK(nl_table_lock); 107DEFINE_RWLOCK(nl_table_lock);
100EXPORT_SYMBOL_GPL(nl_table_lock); 108EXPORT_SYMBOL_GPL(nl_table_lock);
101static atomic_t nl_table_users = ATOMIC_INIT(0); 109static atomic_t nl_table_users = ATOMIC_INIT(0);
@@ -109,10 +117,10 @@ EXPORT_SYMBOL_GPL(nl_sk_hash_lock);
109static int lockdep_nl_sk_hash_is_held(void) 117static int lockdep_nl_sk_hash_is_held(void)
110{ 118{
111#ifdef CONFIG_LOCKDEP 119#ifdef CONFIG_LOCKDEP
112 return (debug_locks) ? lockdep_is_held(&nl_sk_hash_lock) : 1; 120 if (debug_locks)
113#else 121 return lockdep_is_held(&nl_sk_hash_lock) || lockdep_is_held(&nl_table_lock);
114 return 1;
115#endif 122#endif
123 return 1;
116} 124}
117 125
118static ATOMIC_NOTIFIER_HEAD(netlink_chain); 126static ATOMIC_NOTIFIER_HEAD(netlink_chain);
@@ -1028,11 +1036,13 @@ static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid)
1028 struct netlink_table *table = &nl_table[protocol]; 1036 struct netlink_table *table = &nl_table[protocol];
1029 struct sock *sk; 1037 struct sock *sk;
1030 1038
1039 read_lock(&nl_table_lock);
1031 rcu_read_lock(); 1040 rcu_read_lock();
1032 sk = __netlink_lookup(table, portid, net); 1041 sk = __netlink_lookup(table, portid, net);
1033 if (sk) 1042 if (sk)
1034 sock_hold(sk); 1043 sock_hold(sk);
1035 rcu_read_unlock(); 1044 rcu_read_unlock();
1045 read_unlock(&nl_table_lock);
1036 1046
1037 return sk; 1047 return sk;
1038} 1048}
@@ -1257,9 +1267,6 @@ static int netlink_release(struct socket *sock)
1257 } 1267 }
1258 netlink_table_ungrab(); 1268 netlink_table_ungrab();
1259 1269
1260 /* Wait for readers to complete */
1261 synchronize_net();
1262
1263 kfree(nlk->groups); 1270 kfree(nlk->groups);
1264 nlk->groups = NULL; 1271 nlk->groups = NULL;
1265 1272
@@ -1281,6 +1288,7 @@ static int netlink_autobind(struct socket *sock)
1281 1288
1282retry: 1289retry:
1283 cond_resched(); 1290 cond_resched();
1291 netlink_table_grab();
1284 rcu_read_lock(); 1292 rcu_read_lock();
1285 if (__netlink_lookup(table, portid, net)) { 1293 if (__netlink_lookup(table, portid, net)) {
1286 /* Bind collision, search negative portid values. */ 1294 /* Bind collision, search negative portid values. */
@@ -1288,9 +1296,11 @@ retry:
1288 if (rover > -4097) 1296 if (rover > -4097)
1289 rover = -4097; 1297 rover = -4097;
1290 rcu_read_unlock(); 1298 rcu_read_unlock();
1299 netlink_table_ungrab();
1291 goto retry; 1300 goto retry;
1292 } 1301 }
1293 rcu_read_unlock(); 1302 rcu_read_unlock();
1303 netlink_table_ungrab();
1294 1304
1295 err = netlink_insert(sk, net, portid); 1305 err = netlink_insert(sk, net, portid);
1296 if (err == -EADDRINUSE) 1306 if (err == -EADDRINUSE)
@@ -2921,14 +2931,16 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
2921} 2931}
2922 2932
2923static void *netlink_seq_start(struct seq_file *seq, loff_t *pos) 2933static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
2924 __acquires(RCU) 2934 __acquires(nl_table_lock) __acquires(RCU)
2925{ 2935{
2936 read_lock(&nl_table_lock);
2926 rcu_read_lock(); 2937 rcu_read_lock();
2927 return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN; 2938 return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN;
2928} 2939}
2929 2940
2930static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2941static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2931{ 2942{
2943 struct rhashtable *ht;
2932 struct netlink_sock *nlk; 2944 struct netlink_sock *nlk;
2933 struct nl_seq_iter *iter; 2945 struct nl_seq_iter *iter;
2934 struct net *net; 2946 struct net *net;
@@ -2943,19 +2955,19 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2943 iter = seq->private; 2955 iter = seq->private;
2944 nlk = v; 2956 nlk = v;
2945 2957
2946 rht_for_each_entry_rcu(nlk, nlk->node.next, node) 2958 i = iter->link;
2959 ht = &nl_table[i].hash;
2960 rht_for_each_entry(nlk, nlk->node.next, ht, node)
2947 if (net_eq(sock_net((struct sock *)nlk), net)) 2961 if (net_eq(sock_net((struct sock *)nlk), net))
2948 return nlk; 2962 return nlk;
2949 2963
2950 i = iter->link;
2951 j = iter->hash_idx + 1; 2964 j = iter->hash_idx + 1;
2952 2965
2953 do { 2966 do {
2954 struct rhashtable *ht = &nl_table[i].hash;
2955 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht); 2967 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
2956 2968
2957 for (; j < tbl->size; j++) { 2969 for (; j < tbl->size; j++) {
2958 rht_for_each_entry_rcu(nlk, tbl->buckets[j], node) { 2970 rht_for_each_entry(nlk, tbl->buckets[j], ht, node) {
2959 if (net_eq(sock_net((struct sock *)nlk), net)) { 2971 if (net_eq(sock_net((struct sock *)nlk), net)) {
2960 iter->link = i; 2972 iter->link = i;
2961 iter->hash_idx = j; 2973 iter->hash_idx = j;
@@ -2971,9 +2983,10 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2971} 2983}
2972 2984
2973static void netlink_seq_stop(struct seq_file *seq, void *v) 2985static void netlink_seq_stop(struct seq_file *seq, void *v)
2974 __releases(RCU) 2986 __releases(RCU) __releases(nl_table_lock)
2975{ 2987{
2976 rcu_read_unlock(); 2988 rcu_read_unlock();
2989 read_unlock(&nl_table_lock);
2977} 2990}
2978 2991
2979 2992
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 2e31d9e7f4dc..e6d7255183eb 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -324,6 +324,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
324 segs = __skb_gso_segment(skb, NETIF_F_SG, false); 324 segs = __skb_gso_segment(skb, NETIF_F_SG, false);
325 if (IS_ERR(segs)) 325 if (IS_ERR(segs))
326 return PTR_ERR(segs); 326 return PTR_ERR(segs);
327 if (segs == NULL)
328 return -EINVAL;
327 329
328 /* Queue all of the segments. */ 330 /* Queue all of the segments. */
329 skb = segs; 331 skb = segs;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 2cf61b3e633c..76f402e05bd6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -947,7 +947,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
947 if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) { 947 if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) {
948 if (qdisc_is_percpu_stats(sch)) { 948 if (qdisc_is_percpu_stats(sch)) {
949 sch->cpu_bstats = 949 sch->cpu_bstats =
950 alloc_percpu(struct gnet_stats_basic_cpu); 950 netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
951 if (!sch->cpu_bstats) 951 if (!sch->cpu_bstats)
952 goto err_out4; 952 goto err_out4;
953 953
diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
index 33d7a98a7a97..b783a446d884 100644
--- a/net/sched/sch_pie.c
+++ b/net/sched/sch_pie.c
@@ -445,7 +445,6 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt)
445 sch->limit = q->params.limit; 445 sch->limit = q->params.limit;
446 446
447 setup_timer(&q->adapt_timer, pie_timer, (unsigned long)sch); 447 setup_timer(&q->adapt_timer, pie_timer, (unsigned long)sch);
448 mod_timer(&q->adapt_timer, jiffies + HZ / 2);
449 448
450 if (opt) { 449 if (opt) {
451 int err = pie_change(sch, opt); 450 int err = pie_change(sch, opt);
@@ -454,6 +453,7 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt)
454 return err; 453 return err;
455 } 454 }
456 455
456 mod_timer(&q->adapt_timer, jiffies + HZ / 2);
457 return 0; 457 return 0;
458} 458}
459 459
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 90cee4a6fce4..5781634e957d 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -219,11 +219,11 @@ void tipc_node_abort_sock_conns(struct list_head *conns)
219void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 219void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
220{ 220{
221 struct tipc_link **active = &n_ptr->active_links[0]; 221 struct tipc_link **active = &n_ptr->active_links[0];
222 u32 addr = n_ptr->addr;
223 222
224 n_ptr->working_links++; 223 n_ptr->working_links++;
225 tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr, TIPC_NODE_SCOPE, 224 n_ptr->action_flags |= TIPC_NOTIFY_LINK_UP;
226 l_ptr->bearer_id, addr); 225 n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id;
226
227 pr_info("Established link <%s> on network plane %c\n", 227 pr_info("Established link <%s> on network plane %c\n",
228 l_ptr->name, l_ptr->net_plane); 228 l_ptr->name, l_ptr->net_plane);
229 229
@@ -284,10 +284,10 @@ static void node_select_active_links(struct tipc_node *n_ptr)
284void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 284void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
285{ 285{
286 struct tipc_link **active; 286 struct tipc_link **active;
287 u32 addr = n_ptr->addr;
288 287
289 n_ptr->working_links--; 288 n_ptr->working_links--;
290 tipc_nametbl_withdraw(TIPC_LINK_STATE, addr, l_ptr->bearer_id, addr); 289 n_ptr->action_flags |= TIPC_NOTIFY_LINK_DOWN;
290 n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id;
291 291
292 if (!tipc_link_is_active(l_ptr)) { 292 if (!tipc_link_is_active(l_ptr)) {
293 pr_info("Lost standby link <%s> on network plane %c\n", 293 pr_info("Lost standby link <%s> on network plane %c\n",
@@ -552,28 +552,30 @@ void tipc_node_unlock(struct tipc_node *node)
552 LIST_HEAD(conn_sks); 552 LIST_HEAD(conn_sks);
553 struct sk_buff_head waiting_sks; 553 struct sk_buff_head waiting_sks;
554 u32 addr = 0; 554 u32 addr = 0;
555 unsigned int flags = node->action_flags; 555 int flags = node->action_flags;
556 u32 link_id = 0;
556 557
557 if (likely(!node->action_flags)) { 558 if (likely(!flags)) {
558 spin_unlock_bh(&node->lock); 559 spin_unlock_bh(&node->lock);
559 return; 560 return;
560 } 561 }
561 562
563 addr = node->addr;
564 link_id = node->link_id;
562 __skb_queue_head_init(&waiting_sks); 565 __skb_queue_head_init(&waiting_sks);
563 if (node->action_flags & TIPC_WAKEUP_USERS) { 566
567 if (flags & TIPC_WAKEUP_USERS)
564 skb_queue_splice_init(&node->waiting_sks, &waiting_sks); 568 skb_queue_splice_init(&node->waiting_sks, &waiting_sks);
565 node->action_flags &= ~TIPC_WAKEUP_USERS; 569
566 } 570 if (flags & TIPC_NOTIFY_NODE_DOWN) {
567 if (node->action_flags & TIPC_NOTIFY_NODE_DOWN) {
568 list_replace_init(&node->nsub, &nsub_list); 571 list_replace_init(&node->nsub, &nsub_list);
569 list_replace_init(&node->conn_sks, &conn_sks); 572 list_replace_init(&node->conn_sks, &conn_sks);
570 node->action_flags &= ~TIPC_NOTIFY_NODE_DOWN;
571 } 573 }
572 if (node->action_flags & TIPC_NOTIFY_NODE_UP) { 574 node->action_flags &= ~(TIPC_WAKEUP_USERS | TIPC_NOTIFY_NODE_DOWN |
573 node->action_flags &= ~TIPC_NOTIFY_NODE_UP; 575 TIPC_NOTIFY_NODE_UP | TIPC_NOTIFY_LINK_UP |
574 addr = node->addr; 576 TIPC_NOTIFY_LINK_DOWN |
575 } 577 TIPC_WAKEUP_BCAST_USERS);
576 node->action_flags &= ~TIPC_WAKEUP_BCAST_USERS; 578
577 spin_unlock_bh(&node->lock); 579 spin_unlock_bh(&node->lock);
578 580
579 while (!skb_queue_empty(&waiting_sks)) 581 while (!skb_queue_empty(&waiting_sks))
@@ -588,6 +590,14 @@ void tipc_node_unlock(struct tipc_node *node)
588 if (flags & TIPC_WAKEUP_BCAST_USERS) 590 if (flags & TIPC_WAKEUP_BCAST_USERS)
589 tipc_bclink_wakeup_users(); 591 tipc_bclink_wakeup_users();
590 592
591 if (addr) 593 if (flags & TIPC_NOTIFY_NODE_UP)
592 tipc_named_node_up(addr); 594 tipc_named_node_up(addr);
595
596 if (flags & TIPC_NOTIFY_LINK_UP)
597 tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr,
598 TIPC_NODE_SCOPE, link_id, addr);
599
600 if (flags & TIPC_NOTIFY_LINK_DOWN)
601 tipc_nametbl_withdraw(TIPC_LINK_STATE, addr,
602 link_id, addr);
593} 603}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 67513c3c852c..04e91458bb29 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -53,6 +53,7 @@
53 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down 53 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
54 * TIPC_NOTIFY_NODE_DOWN: notify node is down 54 * TIPC_NOTIFY_NODE_DOWN: notify node is down
55 * TIPC_NOTIFY_NODE_UP: notify node is up 55 * TIPC_NOTIFY_NODE_UP: notify node is up
56 * TIPC_DISTRIBUTE_NAME: publish or withdraw link state name type
56 */ 57 */
57enum { 58enum {
58 TIPC_WAIT_PEER_LINKS_DOWN = (1 << 1), 59 TIPC_WAIT_PEER_LINKS_DOWN = (1 << 1),
@@ -60,7 +61,9 @@ enum {
60 TIPC_NOTIFY_NODE_DOWN = (1 << 3), 61 TIPC_NOTIFY_NODE_DOWN = (1 << 3),
61 TIPC_NOTIFY_NODE_UP = (1 << 4), 62 TIPC_NOTIFY_NODE_UP = (1 << 4),
62 TIPC_WAKEUP_USERS = (1 << 5), 63 TIPC_WAKEUP_USERS = (1 << 5),
63 TIPC_WAKEUP_BCAST_USERS = (1 << 6) 64 TIPC_WAKEUP_BCAST_USERS = (1 << 6),
65 TIPC_NOTIFY_LINK_UP = (1 << 7),
66 TIPC_NOTIFY_LINK_DOWN = (1 << 8)
64}; 67};
65 68
66/** 69/**
@@ -100,6 +103,7 @@ struct tipc_node_bclink {
100 * @working_links: number of working links to node (both active and standby) 103 * @working_links: number of working links to node (both active and standby)
101 * @link_cnt: number of links to node 104 * @link_cnt: number of links to node
102 * @signature: node instance identifier 105 * @signature: node instance identifier
106 * @link_id: local and remote bearer ids of changing link, if any
103 * @nsub: list of "node down" subscriptions monitoring node 107 * @nsub: list of "node down" subscriptions monitoring node
104 * @rcu: rcu struct for tipc_node 108 * @rcu: rcu struct for tipc_node
105 */ 109 */
@@ -116,6 +120,7 @@ struct tipc_node {
116 int link_cnt; 120 int link_cnt;
117 int working_links; 121 int working_links;
118 u32 signature; 122 u32 signature;
123 u32 link_id;
119 struct list_head nsub; 124 struct list_head nsub;
120 struct sk_buff_head waiting_sks; 125 struct sk_buff_head waiting_sks;
121 struct list_head conn_sks; 126 struct list_head conn_sks;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 75275c5cf929..51bddc236a15 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1776,7 +1776,7 @@ int tipc_sk_rcv(struct sk_buff *buf)
1776 sk = &tsk->sk; 1776 sk = &tsk->sk;
1777 1777
1778 /* Queue message */ 1778 /* Queue message */
1779 bh_lock_sock(sk); 1779 spin_lock_bh(&sk->sk_lock.slock);
1780 1780
1781 if (!sock_owned_by_user(sk)) { 1781 if (!sock_owned_by_user(sk)) {
1782 rc = filter_rcv(sk, buf); 1782 rc = filter_rcv(sk, buf);
@@ -1787,7 +1787,7 @@ int tipc_sk_rcv(struct sk_buff *buf)
1787 if (sk_add_backlog(sk, buf, limit)) 1787 if (sk_add_backlog(sk, buf, limit))
1788 rc = -TIPC_ERR_OVERLOAD; 1788 rc = -TIPC_ERR_OVERLOAD;
1789 } 1789 }
1790 bh_unlock_sock(sk); 1790 spin_unlock_bh(&sk->sk_lock.slock);
1791 tipc_sk_put(tsk); 1791 tipc_sk_put(tsk);
1792 if (likely(!rc)) 1792 if (likely(!rc))
1793 return 0; 1793 return 0;
@@ -2673,7 +2673,7 @@ static int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg)
2673 case SIOCGETLINKNAME: 2673 case SIOCGETLINKNAME:
2674 if (copy_from_user(&lnr, argp, sizeof(lnr))) 2674 if (copy_from_user(&lnr, argp, sizeof(lnr)))
2675 return -EFAULT; 2675 return -EFAULT;
2676 if (!tipc_node_get_linkname(lnr.bearer_id, lnr.peer, 2676 if (!tipc_node_get_linkname(lnr.bearer_id & 0xffff, lnr.peer,
2677 lnr.linkname, TIPC_MAX_LINK_NAME)) { 2677 lnr.linkname, TIPC_MAX_LINK_NAME)) {
2678 if (copy_to_user(argp, &lnr, sizeof(lnr))) 2678 if (copy_to_user(argp, &lnr, sizeof(lnr)))
2679 return -EFAULT; 2679 return -EFAULT;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cb9f5a44ffad..5839c85075f1 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5927,6 +5927,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5927 int err; 5927 int err;
5928 bool need_new_beacon = false; 5928 bool need_new_beacon = false;
5929 int len, i; 5929 int len, i;
5930 u32 cs_count;
5930 5931
5931 if (!rdev->ops->channel_switch || 5932 if (!rdev->ops->channel_switch ||
5932 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) 5933 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
@@ -5963,7 +5964,14 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5963 if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES]) 5964 if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES])
5964 return -EINVAL; 5965 return -EINVAL;
5965 5966
5966 params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]); 5967 /* Even though the attribute is u32, the specification says
5968 * u8, so let's make sure we don't overflow.
5969 */
5970 cs_count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
5971 if (cs_count > 255)
5972 return -EINVAL;
5973
5974 params.count = cs_count;
5967 5975
5968 if (!need_new_beacon) 5976 if (!need_new_beacon)
5969 goto skip_beacons; 5977 goto skip_beacons;
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 499d6c18a8ce..7c532856b398 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -157,6 +157,8 @@ static int xfrm_output_gso(struct sk_buff *skb)
157 kfree_skb(skb); 157 kfree_skb(skb);
158 if (IS_ERR(segs)) 158 if (IS_ERR(segs))
159 return PTR_ERR(segs); 159 return PTR_ERR(segs);
160 if (segs == NULL)
161 return -EINVAL;
160 162
161 do { 163 do {
162 struct sk_buff *nskb = segs->next; 164 struct sk_buff *nskb = segs->next;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 4c4e457e7888..88bf289abdc9 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1962,7 +1962,7 @@ static int xdst_queue_output(struct sock *sk, struct sk_buff *skb)
1962 struct xfrm_policy *pol = xdst->pols[0]; 1962 struct xfrm_policy *pol = xdst->pols[0];
1963 struct xfrm_policy_queue *pq = &pol->polq; 1963 struct xfrm_policy_queue *pq = &pol->polq;
1964 1964
1965 if (unlikely(skb_fclone_busy(skb))) { 1965 if (unlikely(skb_fclone_busy(sk, skb))) {
1966 kfree_skb(skb); 1966 kfree_skb(skb);
1967 return 0; 1967 return 0;
1968 } 1968 }
diff --git a/samples/bpf/test_verifier.c b/samples/bpf/test_verifier.c
index f44ef11f65a7..eb4bec0ad8af 100644
--- a/samples/bpf/test_verifier.c
+++ b/samples/bpf/test_verifier.c
@@ -209,6 +209,17 @@ static struct bpf_test tests[] = {
209 .result = REJECT, 209 .result = REJECT,
210 }, 210 },
211 { 211 {
212 "program doesn't init R0 before exit in all branches",
213 .insns = {
214 BPF_JMP_IMM(BPF_JGE, BPF_REG_1, 0, 2),
215 BPF_MOV64_IMM(BPF_REG_0, 1),
216 BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 2),
217 BPF_EXIT_INSN(),
218 },
219 .errstr = "R0 !read_ok",
220 .result = REJECT,
221 },
222 {
212 "stack out of bounds", 223 "stack out of bounds",
213 .insns = { 224 .insns = {
214 BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0), 225 BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0),
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 9685af330de5..c5ee1a7c5e8a 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -319,9 +319,12 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
319{ 319{
320 const struct evm_ima_xattr_data *xattr_data = xattr_value; 320 const struct evm_ima_xattr_data *xattr_data = xattr_value;
321 321
322 if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0) 322 if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
323 && (xattr_data->type == EVM_XATTR_HMAC)) 323 if (!xattr_value_len)
324 return -EPERM; 324 return -EINVAL;
325 if (xattr_data->type != EVM_IMA_XATTR_DIGSIG)
326 return -EPERM;
327 }
325 return evm_protect_xattr(dentry, xattr_name, xattr_value, 328 return evm_protect_xattr(dentry, xattr_name, xattr_value,
326 xattr_value_len); 329 xattr_value_len);
327} 330}
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 922685483bd3..7c8f41e618b6 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -378,6 +378,8 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
378 result = ima_protect_xattr(dentry, xattr_name, xattr_value, 378 result = ima_protect_xattr(dentry, xattr_name, xattr_value,
379 xattr_value_len); 379 xattr_value_len);
380 if (result == 1) { 380 if (result == 1) {
381 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
382 return -EINVAL;
381 ima_reset_appraise_flags(dentry->d_inode, 383 ima_reset_appraise_flags(dentry->d_inode,
382 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0); 384 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0);
383 result = 0; 385 result = 0;
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index c0379d13dbe1..9d1c2ebfe12a 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -61,6 +61,7 @@ enum evm_ima_xattr_type {
61 EVM_XATTR_HMAC, 61 EVM_XATTR_HMAC,
62 EVM_IMA_XATTR_DIGSIG, 62 EVM_IMA_XATTR_DIGSIG,
63 IMA_XATTR_DIGEST_NG, 63 IMA_XATTR_DIGEST_NG,
64 IMA_XATTR_LAST
64}; 65};
65 66
66struct evm_ima_xattr_data { 67struct evm_ima_xattr_data {
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 102e8fd1d450..2d957ba63557 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -210,6 +210,8 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
210 if (err < 0) 210 if (err < 0)
211 return err; 211 return err;
212 212
213 if (clear_user(src, sizeof(*src)))
214 return -EFAULT;
213 if (put_user(status.state, &src->state) || 215 if (put_user(status.state, &src->state) ||
214 compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || 216 compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
215 compat_put_timespec(&status.tstamp, &src->tstamp) || 217 compat_put_timespec(&status.tstamp, &src->tstamp) ||
diff --git a/sound/firewire/bebob/bebob_focusrite.c b/sound/firewire/bebob/bebob_focusrite.c
index 45a0eed6d5b1..3b052ed0fbf5 100644
--- a/sound/firewire/bebob/bebob_focusrite.c
+++ b/sound/firewire/bebob/bebob_focusrite.c
@@ -27,12 +27,14 @@
27#define SAFFIRE_CLOCK_SOURCE_INTERNAL 0 27#define SAFFIRE_CLOCK_SOURCE_INTERNAL 0
28#define SAFFIRE_CLOCK_SOURCE_SPDIF 1 28#define SAFFIRE_CLOCK_SOURCE_SPDIF 1
29 29
30/* '1' is absent, why... */ 30/* clock sources as returned from register of Saffire Pro 10 and 26 */
31#define SAFFIREPRO_CLOCK_SOURCE_INTERNAL 0 31#define SAFFIREPRO_CLOCK_SOURCE_INTERNAL 0
32#define SAFFIREPRO_CLOCK_SOURCE_SKIP 1 /* never used on hardware */
32#define SAFFIREPRO_CLOCK_SOURCE_SPDIF 2 33#define SAFFIREPRO_CLOCK_SOURCE_SPDIF 2
33#define SAFFIREPRO_CLOCK_SOURCE_ADAT1 3 34#define SAFFIREPRO_CLOCK_SOURCE_ADAT1 3 /* not used on s.pro. 10 */
34#define SAFFIREPRO_CLOCK_SOURCE_ADAT2 4 35#define SAFFIREPRO_CLOCK_SOURCE_ADAT2 4 /* not used on s.pro. 10 */
35#define SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK 5 36#define SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK 5
37#define SAFFIREPRO_CLOCK_SOURCE_COUNT 6
36 38
37/* S/PDIF, ADAT1, ADAT2 is enabled or not. three quadlets */ 39/* S/PDIF, ADAT1, ADAT2 is enabled or not. three quadlets */
38#define SAFFIREPRO_ENABLE_DIG_IFACES 0x01a4 40#define SAFFIREPRO_ENABLE_DIG_IFACES 0x01a4
@@ -101,13 +103,34 @@ saffire_write_quad(struct snd_bebob *bebob, u64 offset, u32 value)
101 &data, sizeof(__be32), 0); 103 &data, sizeof(__be32), 0);
102} 104}
103 105
106static char *const saffirepro_10_clk_src_labels[] = {
107 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock"
108};
104static char *const saffirepro_26_clk_src_labels[] = { 109static char *const saffirepro_26_clk_src_labels[] = {
105 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock" 110 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock"
106}; 111};
107 112/* Value maps between registers and labels for SaffirePro 10/26. */
108static char *const saffirepro_10_clk_src_labels[] = { 113static const signed char saffirepro_clk_maps[][SAFFIREPRO_CLOCK_SOURCE_COUNT] = {
109 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock" 114 /* SaffirePro 10 */
115 [0] = {
116 [SAFFIREPRO_CLOCK_SOURCE_INTERNAL] = 0,
117 [SAFFIREPRO_CLOCK_SOURCE_SKIP] = -1, /* not supported */
118 [SAFFIREPRO_CLOCK_SOURCE_SPDIF] = 1,
119 [SAFFIREPRO_CLOCK_SOURCE_ADAT1] = -1, /* not supported */
120 [SAFFIREPRO_CLOCK_SOURCE_ADAT2] = -1, /* not supported */
121 [SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK] = 2,
122 },
123 /* SaffirePro 26 */
124 [1] = {
125 [SAFFIREPRO_CLOCK_SOURCE_INTERNAL] = 0,
126 [SAFFIREPRO_CLOCK_SOURCE_SKIP] = -1, /* not supported */
127 [SAFFIREPRO_CLOCK_SOURCE_SPDIF] = 1,
128 [SAFFIREPRO_CLOCK_SOURCE_ADAT1] = 2,
129 [SAFFIREPRO_CLOCK_SOURCE_ADAT2] = 3,
130 [SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK] = 4,
131 }
110}; 132};
133
111static int 134static int
112saffirepro_both_clk_freq_get(struct snd_bebob *bebob, unsigned int *rate) 135saffirepro_both_clk_freq_get(struct snd_bebob *bebob, unsigned int *rate)
113{ 136{
@@ -138,24 +161,35 @@ saffirepro_both_clk_freq_set(struct snd_bebob *bebob, unsigned int rate)
138 161
139 return saffire_write_quad(bebob, SAFFIREPRO_RATE_NOREBOOT, id); 162 return saffire_write_quad(bebob, SAFFIREPRO_RATE_NOREBOOT, id);
140} 163}
164
165/*
166 * query hardware for current clock source, return our internally
167 * used clock index in *id, depending on hardware.
168 */
141static int 169static int
142saffirepro_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) 170saffirepro_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
143{ 171{
144 int err; 172 int err;
145 u32 value; 173 u32 value; /* clock source read from hw register */
174 const signed char *map;
146 175
147 err = saffire_read_quad(bebob, SAFFIREPRO_OFFSET_CLOCK_SOURCE, &value); 176 err = saffire_read_quad(bebob, SAFFIREPRO_OFFSET_CLOCK_SOURCE, &value);
148 if (err < 0) 177 if (err < 0)
149 goto end; 178 goto end;
150 179
151 if (bebob->spec->clock->labels == saffirepro_10_clk_src_labels) { 180 /* depending on hardware, use a different mapping */
152 if (value == SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK) 181 if (bebob->spec->clock->labels == saffirepro_10_clk_src_labels)
153 *id = 2; 182 map = saffirepro_clk_maps[0];
154 else if (value == SAFFIREPRO_CLOCK_SOURCE_SPDIF) 183 else
155 *id = 1; 184 map = saffirepro_clk_maps[1];
156 } else if (value > 1) { 185
157 *id = value - 1; 186 /* In a case that this driver cannot handle the value of register. */
187 if (value >= SAFFIREPRO_CLOCK_SOURCE_COUNT || map[value] < 0) {
188 err = -EIO;
189 goto end;
158 } 190 }
191
192 *id = (unsigned int)map[value];
159end: 193end:
160 return err; 194 return err;
161} 195}
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index ef4d0c9f6578..1aab0a32870c 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -129,12 +129,24 @@ snd_bebob_stream_check_internal_clock(struct snd_bebob *bebob, bool *internal)
129 /* 1.The device has its own operation to switch source of clock */ 129 /* 1.The device has its own operation to switch source of clock */
130 if (clk_spec) { 130 if (clk_spec) {
131 err = clk_spec->get(bebob, &id); 131 err = clk_spec->get(bebob, &id);
132 if (err < 0) 132 if (err < 0) {
133 dev_err(&bebob->unit->device, 133 dev_err(&bebob->unit->device,
134 "fail to get clock source: %d\n", err); 134 "fail to get clock source: %d\n", err);
135 else if (strncmp(clk_spec->labels[id], SND_BEBOB_CLOCK_INTERNAL, 135 goto end;
136 strlen(SND_BEBOB_CLOCK_INTERNAL)) == 0) 136 }
137
138 if (id >= clk_spec->num) {
139 dev_err(&bebob->unit->device,
140 "clock source %d out of range 0..%d\n",
141 id, clk_spec->num - 1);
142 err = -EIO;
143 goto end;
144 }
145
146 if (strncmp(clk_spec->labels[id], SND_BEBOB_CLOCK_INTERNAL,
147 strlen(SND_BEBOB_CLOCK_INTERNAL)) == 0)
137 *internal = true; 148 *internal = true;
149
138 goto end; 150 goto end;
139 } 151 }
140 152
diff --git a/sound/firewire/bebob/bebob_terratec.c b/sound/firewire/bebob/bebob_terratec.c
index 0e4c0bfc463b..9940611f2e1b 100644
--- a/sound/firewire/bebob/bebob_terratec.c
+++ b/sound/firewire/bebob/bebob_terratec.c
@@ -24,7 +24,12 @@ phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
24 if (err < 0) 24 if (err < 0)
25 goto end; 25 goto end;
26 26
27 *id = (enable_ext & 0x01) | ((enable_word & 0x01) << 1); 27 if (enable_ext == 0)
28 *id = 0;
29 else if (enable_word == 0)
30 *id = 1;
31 else
32 *id = 2;
28end: 33end:
29 return err; 34 return err;
30} 35}
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 7bfdf9c51416..1610c38337af 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -681,7 +681,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
681 681
682 /* WARQ is at offset 12 */ 682 /* WARQ is at offset 12 */
683 tmp = (reg & AD_DS_WSMC_WARQ) ? 683 tmp = (reg & AD_DS_WSMC_WARQ) ?
684 (((reg & AD_DS_WSMC_WARQ >> 12) & 0x01) ? 12 : 18) : 4; 684 ((((reg & AD_DS_WSMC_WARQ) >> 12) & 0x01) ? 12 : 18) : 4;
685 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; 685 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
686 686
687 snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp, 687 snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp,
@@ -693,7 +693,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
693 693
694 /* SYRQ is at offset 4 */ 694 /* SYRQ is at offset 4 */
695 tmp = (reg & AD_DS_WSMC_SYRQ) ? 695 tmp = (reg & AD_DS_WSMC_SYRQ) ?
696 (((reg & AD_DS_WSMC_SYRQ >> 4) & 0x01) ? 12 : 18) : 4; 696 ((((reg & AD_DS_WSMC_SYRQ) >> 4) & 0x01) ? 12 : 18) : 4;
697 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; 697 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
698 698
699 snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp, 699 snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp,
@@ -709,7 +709,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
709 709
710 /* ACRQ is at offset 4 */ 710 /* ACRQ is at offset 4 */
711 tmp = (reg & AD_DS_RAMC_ACRQ) ? 711 tmp = (reg & AD_DS_RAMC_ACRQ) ?
712 (((reg & AD_DS_RAMC_ACRQ >> 4) & 0x01) ? 12 : 18) : 4; 712 ((((reg & AD_DS_RAMC_ACRQ) >> 4) & 0x01) ? 12 : 18) : 4;
713 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; 713 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
714 714
715 snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp, 715 snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp,
@@ -720,7 +720,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
720 720
721 /* RERQ is at offset 12 */ 721 /* RERQ is at offset 12 */
722 tmp = (reg & AD_DS_RAMC_RERQ) ? 722 tmp = (reg & AD_DS_RAMC_RERQ) ?
723 (((reg & AD_DS_RAMC_RERQ >> 12) & 0x01) ? 12 : 18) : 4; 723 ((((reg & AD_DS_RAMC_RERQ) >> 12) & 0x01) ? 12 : 18) : 4;
724 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; 724 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
725 725
726 snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp, 726 snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp,
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index cfcca4c30d4d..9ab1e631cb32 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -374,6 +374,8 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool
374#ifdef CONFIG_SND_DMA_SGBUF 374#ifdef CONFIG_SND_DMA_SGBUF
375 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { 375 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) {
376 struct snd_sg_buf *sgbuf = dmab->private_data; 376 struct snd_sg_buf *sgbuf = dmab->private_data;
377 if (chip->driver_type == AZX_DRIVER_CMEDIA)
378 return; /* deal with only CORB/RIRB buffers */
377 if (on) 379 if (on)
378 set_pages_array_wc(sgbuf->page_table, sgbuf->pages); 380 set_pages_array_wc(sgbuf->page_table, sgbuf->pages);
379 else 381 else
@@ -1769,7 +1771,7 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
1769#ifdef CONFIG_X86 1771#ifdef CONFIG_X86
1770 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1772 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1771 struct azx *chip = apcm->chip; 1773 struct azx *chip = apcm->chip;
1772 if (!azx_snoop(chip)) 1774 if (!azx_snoop(chip) && chip->driver_type != AZX_DRIVER_CMEDIA)
1773 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); 1775 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
1774#endif 1776#endif
1775} 1777}
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 34b7bdb510c7..da03693099eb 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -291,18 +291,14 @@ static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
291/* additional initialization for ALC888 variants */ 291/* additional initialization for ALC888 variants */
292static void alc888_coef_init(struct hda_codec *codec) 292static void alc888_coef_init(struct hda_codec *codec)
293{ 293{
294 if (alc_get_coef0(codec) == 0x20) 294 switch (alc_get_coef0(codec) & 0x00f0) {
295 /* alc888S-VC */ 295 /* alc888-VA */
296 alc_write_coef_idx(codec, 7, 0x830); 296 case 0x00:
297 else 297 /* alc888-VB */
298 /* alc888-VB */ 298 case 0x10:
299 alc_write_coef_idx(codec, 7, 0x3030); 299 alc_update_coef_idx(codec, 7, 0, 0x2030); /* Turn EAPD to High */
300} 300 break;
301 301 }
302/* additional initialization for ALC889 variants */
303static void alc889_coef_init(struct hda_codec *codec)
304{
305 alc_update_coef_idx(codec, 7, 0, 0x2010);
306} 302}
307 303
308/* turn on/off EAPD control (only if available) */ 304/* turn on/off EAPD control (only if available) */
@@ -359,25 +355,15 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type)
359 case 0x10ec0260: 355 case 0x10ec0260:
360 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010); 356 alc_update_coefex_idx(codec, 0x1a, 7, 0, 0x2010);
361 break; 357 break;
362 case 0x10ec0262:
363 case 0x10ec0880: 358 case 0x10ec0880:
364 case 0x10ec0882: 359 case 0x10ec0882:
365 case 0x10ec0883: 360 case 0x10ec0883:
366 case 0x10ec0885: 361 case 0x10ec0885:
367 case 0x10ec0887: 362 alc_update_coef_idx(codec, 7, 0, 0x2030);
368 /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
369 case 0x10ec0900:
370 alc889_coef_init(codec);
371 break; 363 break;
372 case 0x10ec0888: 364 case 0x10ec0888:
373 alc888_coef_init(codec); 365 alc888_coef_init(codec);
374 break; 366 break;
375#if 0 /* XXX: This may cause the silent output on speaker on some machines */
376 case 0x10ec0267:
377 case 0x10ec0268:
378 alc_update_coef_idx(codec, 7, 0, 0x3000);
379 break;
380#endif /* XXX */
381 } 367 }
382 break; 368 break;
383 } 369 }
@@ -1710,7 +1696,7 @@ static void alc889_fixup_coef(struct hda_codec *codec,
1710{ 1696{
1711 if (action != HDA_FIXUP_ACT_INIT) 1697 if (action != HDA_FIXUP_ACT_INIT)
1712 return; 1698 return;
1713 alc889_coef_init(codec); 1699 alc_update_coef_idx(codec, 7, 0, 0x2030);
1714} 1700}
1715 1701
1716/* toggle speaker-output according to the hp-jack state */ 1702/* toggle speaker-output according to the hp-jack state */
@@ -2675,7 +2661,7 @@ static void alc269_shutup(struct hda_codec *codec)
2675 2661
2676static struct coef_fw alc282_coefs[] = { 2662static struct coef_fw alc282_coefs[] = {
2677 WRITE_COEF(0x03, 0x0002), /* Power Down Control */ 2663 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2678 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */ 2664 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2679 WRITE_COEF(0x07, 0x0200), /* DMIC control */ 2665 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2680 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */ 2666 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2681 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */ 2667 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
@@ -2786,7 +2772,7 @@ static void alc282_shutup(struct hda_codec *codec)
2786 2772
2787static struct coef_fw alc283_coefs[] = { 2773static struct coef_fw alc283_coefs[] = {
2788 WRITE_COEF(0x03, 0x0002), /* Power Down Control */ 2774 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2789 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */ 2775 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2790 WRITE_COEF(0x07, 0x0200), /* DMIC control */ 2776 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2791 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */ 2777 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2792 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */ 2778 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
@@ -2817,6 +2803,7 @@ static struct coef_fw alc283_coefs[] = {
2817 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */ 2803 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
2818 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */ 2804 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
2819 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */ 2805 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
2806 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
2820 {} 2807 {}
2821}; 2808};
2822 2809
@@ -3349,6 +3336,27 @@ static void alc269_fixup_hp_gpio_mic1_led(struct hda_codec *codec,
3349 } 3336 }
3350} 3337}
3351 3338
3339static void alc280_fixup_hp_gpio4(struct hda_codec *codec,
3340 const struct hda_fixup *fix, int action)
3341{
3342 /* Like hp_gpio_mic1_led, but also needs GPIO4 low to enable headphone amp */
3343 struct alc_spec *spec = codec->spec;
3344 static const struct hda_verb gpio_init[] = {
3345 { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
3346 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
3347 {}
3348 };
3349
3350 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3351 spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
3352 spec->gen.cap_sync_hook = alc269_fixup_hp_cap_mic_mute_hook;
3353 spec->gpio_led = 0;
3354 spec->cap_mute_led_nid = 0x18;
3355 snd_hda_add_verbs(codec, gpio_init);
3356 codec->power_filter = led_power_filter;
3357 }
3358}
3359
3352static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec, 3360static void alc269_fixup_hp_line1_mic1_led(struct hda_codec *codec,
3353 const struct hda_fixup *fix, int action) 3361 const struct hda_fixup *fix, int action)
3354{ 3362{
@@ -4216,6 +4224,7 @@ enum {
4216 ALC283_FIXUP_BXBT2807_MIC, 4224 ALC283_FIXUP_BXBT2807_MIC,
4217 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED, 4225 ALC255_FIXUP_DELL_WMI_MIC_MUTE_LED,
4218 ALC282_FIXUP_ASPIRE_V5_PINS, 4226 ALC282_FIXUP_ASPIRE_V5_PINS,
4227 ALC280_FIXUP_HP_GPIO4,
4219}; 4228};
4220 4229
4221static const struct hda_fixup alc269_fixups[] = { 4230static const struct hda_fixup alc269_fixups[] = {
@@ -4679,7 +4688,10 @@ static const struct hda_fixup alc269_fixups[] = {
4679 { }, 4688 { },
4680 }, 4689 },
4681 }, 4690 },
4682 4691 [ALC280_FIXUP_HP_GPIO4] = {
4692 .type = HDA_FIXUP_FUNC,
4693 .v.func = alc280_fixup_hp_gpio4,
4694 },
4683}; 4695};
4684 4696
4685static const struct snd_pci_quirk alc269_fixup_tbl[] = { 4697static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4727,21 +4739,16 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4727 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4739 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4728 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4740 SND_PCI_QUIRK(0x103c, 0x22dc, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4729 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4741 SND_PCI_QUIRK(0x103c, 0x22fb, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4730 SND_PCI_QUIRK(0x103c, 0x8004, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4731 /* ALC290 */ 4742 /* ALC290 */
4732 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4743 SND_PCI_QUIRK(0x103c, 0x221b, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4733 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4744 SND_PCI_QUIRK(0x103c, 0x2221, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4734 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4745 SND_PCI_QUIRK(0x103c, 0x2225, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4735 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4746 SND_PCI_QUIRK(0x103c, 0x2246, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4736 SND_PCI_QUIRK(0x103c, 0x2247, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4737 SND_PCI_QUIRK(0x103c, 0x2248, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4738 SND_PCI_QUIRK(0x103c, 0x2249, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4739 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4747 SND_PCI_QUIRK(0x103c, 0x2253, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4740 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4748 SND_PCI_QUIRK(0x103c, 0x2254, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4741 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4749 SND_PCI_QUIRK(0x103c, 0x2255, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4742 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4750 SND_PCI_QUIRK(0x103c, 0x2256, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4743 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4751 SND_PCI_QUIRK(0x103c, 0x2257, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4744 SND_PCI_QUIRK(0x103c, 0x2258, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4745 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4752 SND_PCI_QUIRK(0x103c, 0x2259, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4746 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4753 SND_PCI_QUIRK(0x103c, 0x225a, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4747 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4754 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
@@ -4750,7 +4757,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4750 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4757 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4751 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4758 SND_PCI_QUIRK(0x103c, 0x2272, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4752 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4759 SND_PCI_QUIRK(0x103c, 0x2273, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4753 SND_PCI_QUIRK(0x103c, 0x2277, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4754 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED), 4760 SND_PCI_QUIRK(0x103c, 0x2278, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED),
4755 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4761 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4756 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4762 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
@@ -4803,7 +4809,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4803 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK), 4809 SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
4804 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK), 4810 SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
4805 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK), 4811 SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad T440", ALC292_FIXUP_TPT440_DOCK),
4806 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 4812 SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad X240", ALC292_FIXUP_TPT440_DOCK),
4807 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 4813 SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
4808 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP), 4814 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
4809 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 4815 SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -4983,6 +4989,19 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
4983 {0x17, 0x40000000}, 4989 {0x17, 0x40000000},
4984 {0x1d, 0x40700001}, 4990 {0x1d, 0x40700001},
4985 {0x21, 0x02211040}), 4991 {0x21, 0x02211040}),
4992 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
4993 {0x12, 0x90a60130},
4994 {0x13, 0x40000000},
4995 {0x14, 0x90170110},
4996 {0x15, 0x0421101f},
4997 {0x16, 0x411111f0},
4998 {0x17, 0x411111f0},
4999 {0x18, 0x411111f0},
5000 {0x19, 0x411111f0},
5001 {0x1a, 0x04a11020},
5002 {0x1b, 0x411111f0},
5003 {0x1d, 0x40748605},
5004 {0x1e, 0x411111f0}),
4986 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED, 5005 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC269_FIXUP_HP_GPIO_MIC1_LED,
4987 {0x12, 0x90a60140}, 5006 {0x12, 0x90a60140},
4988 {0x13, 0x40000000}, 5007 {0x13, 0x40000000},
@@ -5650,6 +5669,35 @@ static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5650 } 5669 }
5651} 5670}
5652 5671
5672static struct coef_fw alc668_coefs[] = {
5673 WRITE_COEF(0x01, 0xbebe), WRITE_COEF(0x02, 0xaaaa), WRITE_COEF(0x03, 0x0),
5674 WRITE_COEF(0x04, 0x0180), WRITE_COEF(0x06, 0x0), WRITE_COEF(0x07, 0x0f80),
5675 WRITE_COEF(0x08, 0x0031), WRITE_COEF(0x0a, 0x0060), WRITE_COEF(0x0b, 0x0),
5676 WRITE_COEF(0x0c, 0x7cf7), WRITE_COEF(0x0d, 0x1080), WRITE_COEF(0x0e, 0x7f7f),
5677 WRITE_COEF(0x0f, 0xcccc), WRITE_COEF(0x10, 0xddcc), WRITE_COEF(0x11, 0x0001),
5678 WRITE_COEF(0x13, 0x0), WRITE_COEF(0x14, 0x2aa0), WRITE_COEF(0x17, 0xa940),
5679 WRITE_COEF(0x19, 0x0), WRITE_COEF(0x1a, 0x0), WRITE_COEF(0x1b, 0x0),
5680 WRITE_COEF(0x1c, 0x0), WRITE_COEF(0x1d, 0x0), WRITE_COEF(0x1e, 0x7418),
5681 WRITE_COEF(0x1f, 0x0804), WRITE_COEF(0x20, 0x4200), WRITE_COEF(0x21, 0x0468),
5682 WRITE_COEF(0x22, 0x8ccc), WRITE_COEF(0x23, 0x0250), WRITE_COEF(0x24, 0x7418),
5683 WRITE_COEF(0x27, 0x0), WRITE_COEF(0x28, 0x8ccc), WRITE_COEF(0x2a, 0xff00),
5684 WRITE_COEF(0x2b, 0x8000), WRITE_COEF(0xa7, 0xff00), WRITE_COEF(0xa8, 0x8000),
5685 WRITE_COEF(0xaa, 0x2e17), WRITE_COEF(0xab, 0xa0c0), WRITE_COEF(0xac, 0x0),
5686 WRITE_COEF(0xad, 0x0), WRITE_COEF(0xae, 0x2ac6), WRITE_COEF(0xaf, 0xa480),
5687 WRITE_COEF(0xb0, 0x0), WRITE_COEF(0xb1, 0x0), WRITE_COEF(0xb2, 0x0),
5688 WRITE_COEF(0xb3, 0x0), WRITE_COEF(0xb4, 0x0), WRITE_COEF(0xb5, 0x1040),
5689 WRITE_COEF(0xb6, 0xd697), WRITE_COEF(0xb7, 0x902b), WRITE_COEF(0xb8, 0xd697),
5690 WRITE_COEF(0xb9, 0x902b), WRITE_COEF(0xba, 0xb8ba), WRITE_COEF(0xbb, 0xaaab),
5691 WRITE_COEF(0xbc, 0xaaaf), WRITE_COEF(0xbd, 0x6aaa), WRITE_COEF(0xbe, 0x1c02),
5692 WRITE_COEF(0xc0, 0x00ff), WRITE_COEF(0xc1, 0x0fa6),
5693 {}
5694};
5695
5696static void alc668_restore_default_value(struct hda_codec *codec)
5697{
5698 alc_process_coef_fw(codec, alc668_coefs);
5699}
5700
5653enum { 5701enum {
5654 ALC662_FIXUP_ASPIRE, 5702 ALC662_FIXUP_ASPIRE,
5655 ALC662_FIXUP_LED_GPIO1, 5703 ALC662_FIXUP_LED_GPIO1,
@@ -5922,6 +5970,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5922 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5970 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5923 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5971 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5924 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5972 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5973 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5925 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 5974 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5926 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A), 5975 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
5927 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 5976 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
@@ -6116,8 +6165,15 @@ static int patch_alc662(struct hda_codec *codec)
6116 6165
6117 alc_fix_pll_init(codec, 0x20, 0x04, 15); 6166 alc_fix_pll_init(codec, 0x20, 0x04, 15);
6118 6167
6119 spec->init_hook = alc662_fill_coef; 6168 switch (codec->vendor_id) {
6120 alc662_fill_coef(codec); 6169 case 0x10ec0668:
6170 spec->init_hook = alc668_restore_default_value;
6171 break;
6172 default:
6173 spec->init_hook = alc662_fill_coef;
6174 alc662_fill_coef(codec);
6175 break;
6176 }
6121 6177
6122 snd_hda_pick_fixup(codec, alc662_fixup_models, 6178 snd_hda_pick_fixup(codec, alc662_fixup_models,
6123 alc662_fixup_tbl, alc662_fixups); 6179 alc662_fixup_tbl, alc662_fixups);
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 0e9623368ab0..7d5d6444a837 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -49,7 +49,6 @@ source "sound/soc/mxs/Kconfig"
49source "sound/soc/pxa/Kconfig" 49source "sound/soc/pxa/Kconfig"
50source "sound/soc/rockchip/Kconfig" 50source "sound/soc/rockchip/Kconfig"
51source "sound/soc/samsung/Kconfig" 51source "sound/soc/samsung/Kconfig"
52source "sound/soc/s6000/Kconfig"
53source "sound/soc/sh/Kconfig" 52source "sound/soc/sh/Kconfig"
54source "sound/soc/sirf/Kconfig" 53source "sound/soc/sirf/Kconfig"
55source "sound/soc/spear/Kconfig" 54source "sound/soc/spear/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 534714a1ca44..d88edfced8c4 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_SND_SOC) += kirkwood/
26obj-$(CONFIG_SND_SOC) += pxa/ 26obj-$(CONFIG_SND_SOC) += pxa/
27obj-$(CONFIG_SND_SOC) += rockchip/ 27obj-$(CONFIG_SND_SOC) += rockchip/
28obj-$(CONFIG_SND_SOC) += samsung/ 28obj-$(CONFIG_SND_SOC) += samsung/
29obj-$(CONFIG_SND_SOC) += s6000/
30obj-$(CONFIG_SND_SOC) += sh/ 29obj-$(CONFIG_SND_SOC) += sh/
31obj-$(CONFIG_SND_SOC) += sirf/ 30obj-$(CONFIG_SND_SOC) += sirf/
32obj-$(CONFIG_SND_SOC) += spear/ 31obj-$(CONFIG_SND_SOC) += spear/
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index 5518ebd6947c..91f60282fd2f 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -405,6 +405,7 @@ static const struct snd_soc_dapm_widget adau1761_dapm_widgets[] = {
405 2, 0, NULL, 0), 405 2, 0, NULL, 0),
406 406
407 SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0), 407 SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0),
408 SND_SOC_DAPM_SUPPLY("ALC Clock", ADAU1761_CLK_ENABLE0, 5, 0, NULL, 0),
408 409
409 SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1, 410 SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1,
410 0, 0, NULL, 0), 411 0, 0, NULL, 0),
@@ -436,6 +437,9 @@ static const struct snd_soc_dapm_route adau1761_dapm_routes[] = {
436 { "Right Playback Mixer", NULL, "Slew Clock" }, 437 { "Right Playback Mixer", NULL, "Slew Clock" },
437 { "Left Playback Mixer", NULL, "Slew Clock" }, 438 { "Left Playback Mixer", NULL, "Slew Clock" },
438 439
440 { "Left Input Mixer", NULL, "ALC Clock" },
441 { "Right Input Mixer", NULL, "ALC Clock" },
442
439 { "Digital Clock 0", NULL, "SYSCLK" }, 443 { "Digital Clock 0", NULL, "SYSCLK" },
440 { "Digital Clock 1", NULL, "SYSCLK" }, 444 { "Digital Clock 1", NULL, "SYSCLK" },
441}; 445};
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 3b145313f93e..ed866e9a2928 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -792,7 +792,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)
792 return -ENOMEM; 792 return -ENOMEM;
793 793
794 asrc_priv->pdev = pdev; 794 asrc_priv->pdev = pdev;
795 strcpy(asrc_priv->name, np->name); 795 strncpy(asrc_priv->name, np->name, sizeof(asrc_priv->name) - 1);
796 796
797 /* Get the addresses and IRQ */ 797 /* Get the addresses and IRQ */
798 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 798 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 8bcdfda09d7a..a645e296199e 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -734,7 +734,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
734 return -ENOMEM; 734 return -ENOMEM;
735 735
736 esai_priv->pdev = pdev; 736 esai_priv->pdev = pdev;
737 strcpy(esai_priv->name, np->name); 737 strncpy(esai_priv->name, np->name, sizeof(esai_priv->name) - 1);
738 738
739 /* Get the addresses and IRQ */ 739 /* Get the addresses and IRQ */
740 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 740 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c
index 33fc5c3abf55..4df867cbb92a 100644
--- a/sound/soc/intel/sst-haswell-pcm.c
+++ b/sound/soc/intel/sst-haswell-pcm.c
@@ -691,9 +691,7 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
691} 691}
692 692
693#define HSW_FORMATS \ 693#define HSW_FORMATS \
694 (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ 694 (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
695 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE |\
696 SNDRV_PCM_FMTBIT_S8)
697 695
698static struct snd_soc_dai_driver hsw_dais[] = { 696static struct snd_soc_dai_driver hsw_dais[] = {
699 { 697 {
diff --git a/sound/soc/s6000/Kconfig b/sound/soc/s6000/Kconfig
deleted file mode 100644
index f244a2566f20..000000000000
--- a/sound/soc/s6000/Kconfig
+++ /dev/null
@@ -1,26 +0,0 @@
1config SND_S6000_SOC
2 tristate "SoC Audio for the Stretch s6000 family"
3 depends on XTENSA_VARIANT_S6000 || COMPILE_TEST
4 depends on HAS_IOMEM
5 select SND_S6000_SOC_PCM if XTENSA_VARIANT_S6000
6 help
7 Say Y or M if you want to add support for codecs attached to
8 s6000 family chips. You will also need to select the platform
9 to support below.
10
11config SND_S6000_SOC_PCM
12 tristate
13
14config SND_S6000_SOC_I2S
15 tristate
16
17config SND_S6000_SOC_S6IPCAM
18 bool "SoC Audio support for Stretch 6105 IP Camera"
19 depends on SND_S6000_SOC=y
20 depends on I2C=y
21 depends on XTENSA_PLATFORM_S6105 || COMPILE_TEST
22 select SND_S6000_SOC_I2S
23 select SND_SOC_TLV320AIC3X
24 help
25 Say Y if you want to add support for SoC audio on the
26 Stretch s6105 IP Camera Reference Design.
diff --git a/sound/soc/s6000/Makefile b/sound/soc/s6000/Makefile
deleted file mode 100644
index 0f0ae2a012aa..000000000000
--- a/sound/soc/s6000/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1# s6000 Platform Support
2snd-soc-s6000-objs := s6000-pcm.o
3snd-soc-s6000-i2s-objs := s6000-i2s.o
4
5obj-$(CONFIG_SND_S6000_SOC_PCM) += snd-soc-s6000.o
6obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o
7
8# s6105 Machine Support
9snd-soc-s6ipcam-objs := s6105-ipcam.o
10
11obj-$(CONFIG_SND_S6000_SOC_S6IPCAM) += snd-soc-s6ipcam.o
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c
deleted file mode 100644
index 1c8d01166e5b..000000000000
--- a/sound/soc/s6000/s6000-i2s.c
+++ /dev/null
@@ -1,617 +0,0 @@
1/*
2 * ALSA SoC I2S Audio Layer for the Stretch S6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/device.h>
15#include <linux/delay.h>
16#include <linux/clk.h>
17#include <linux/interrupt.h>
18#include <linux/io.h>
19#include <linux/slab.h>
20
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/initval.h>
25#include <sound/soc.h>
26
27#include "s6000-i2s.h"
28#include "s6000-pcm.h"
29
30struct s6000_i2s_dev {
31 dma_addr_t sifbase;
32 u8 __iomem *scbbase;
33 unsigned int wide;
34 unsigned int channel_in;
35 unsigned int channel_out;
36 unsigned int lines_in;
37 unsigned int lines_out;
38 struct s6000_pcm_dma_params dma_params;
39};
40
41#define S6_I2S_INTERRUPT_STATUS 0x00
42#define S6_I2S_INT_OVERRUN 1
43#define S6_I2S_INT_UNDERRUN 2
44#define S6_I2S_INT_ALIGNMENT 4
45#define S6_I2S_INTERRUPT_ENABLE 0x04
46#define S6_I2S_INTERRUPT_RAW 0x08
47#define S6_I2S_INTERRUPT_CLEAR 0x0C
48#define S6_I2S_INTERRUPT_SET 0x10
49#define S6_I2S_MODE 0x20
50#define S6_I2S_DUAL 0
51#define S6_I2S_WIDE 1
52#define S6_I2S_TX_DEFAULT 0x24
53#define S6_I2S_DATA_CFG(c) (0x40 + 0x10 * (c))
54#define S6_I2S_IN 0
55#define S6_I2S_OUT 1
56#define S6_I2S_UNUSED 2
57#define S6_I2S_INTERFACE_CFG(c) (0x44 + 0x10 * (c))
58#define S6_I2S_DIV_MASK 0x001fff
59#define S6_I2S_16BIT 0x000000
60#define S6_I2S_20BIT 0x002000
61#define S6_I2S_24BIT 0x004000
62#define S6_I2S_32BIT 0x006000
63#define S6_I2S_BITS_MASK 0x006000
64#define S6_I2S_MEM_16BIT 0x000000
65#define S6_I2S_MEM_32BIT 0x008000
66#define S6_I2S_MEM_MASK 0x008000
67#define S6_I2S_CHANNELS_SHIFT 16
68#define S6_I2S_CHANNELS_MASK 0x030000
69#define S6_I2S_SCK_IN 0x000000
70#define S6_I2S_SCK_OUT 0x040000
71#define S6_I2S_SCK_DIR 0x040000
72#define S6_I2S_WS_IN 0x000000
73#define S6_I2S_WS_OUT 0x080000
74#define S6_I2S_WS_DIR 0x080000
75#define S6_I2S_LEFT_FIRST 0x000000
76#define S6_I2S_RIGHT_FIRST 0x100000
77#define S6_I2S_FIRST 0x100000
78#define S6_I2S_CUR_SCK 0x200000
79#define S6_I2S_CUR_WS 0x400000
80#define S6_I2S_ENABLE(c) (0x48 + 0x10 * (c))
81#define S6_I2S_DISABLE_IF 0x02
82#define S6_I2S_ENABLE_IF 0x03
83#define S6_I2S_IS_BUSY 0x04
84#define S6_I2S_DMA_ACTIVE 0x08
85#define S6_I2S_IS_ENABLED 0x10
86
87#define S6_I2S_NUM_LINES 4
88
89#define S6_I2S_SIF_PORT0 0x0000000
90#define S6_I2S_SIF_PORT1 0x0000080 /* docs say 0x0000010 */
91
92static inline void s6_i2s_write_reg(struct s6000_i2s_dev *dev, int reg, u32 val)
93{
94 writel(val, dev->scbbase + reg);
95}
96
97static inline u32 s6_i2s_read_reg(struct s6000_i2s_dev *dev, int reg)
98{
99 return readl(dev->scbbase + reg);
100}
101
102static inline void s6_i2s_mod_reg(struct s6000_i2s_dev *dev, int reg,
103 u32 mask, u32 val)
104{
105 val ^= s6_i2s_read_reg(dev, reg) & ~mask;
106 s6_i2s_write_reg(dev, reg, val);
107}
108
109static void s6000_i2s_start_channel(struct s6000_i2s_dev *dev, int channel)
110{
111 int i, j, cur, prev;
112
113 /*
114 * Wait for WCLK to toggle 5 times before enabling the channel
115 * s6000 Family Datasheet 3.6.4:
116 * "At least two cycles of WS must occur between commands
117 * to disable or enable the interface"
118 */
119 j = 0;
120 prev = ~S6_I2S_CUR_WS;
121 for (i = 1000000; --i && j < 6; ) {
122 cur = s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(channel))
123 & S6_I2S_CUR_WS;
124 if (prev != cur) {
125 prev = cur;
126 j++;
127 }
128 }
129 if (j < 6)
130 printk(KERN_WARNING "s6000-i2s: timeout waiting for WCLK\n");
131
132 s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_ENABLE_IF);
133}
134
135static void s6000_i2s_stop_channel(struct s6000_i2s_dev *dev, int channel)
136{
137 s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_DISABLE_IF);
138}
139
140static void s6000_i2s_start(struct snd_pcm_substream *substream)
141{
142 struct snd_soc_pcm_runtime *rtd = substream->private_data;
143 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai);
144 int channel;
145
146 channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
147 dev->channel_out : dev->channel_in;
148
149 s6000_i2s_start_channel(dev, channel);
150}
151
152static void s6000_i2s_stop(struct snd_pcm_substream *substream)
153{
154 struct snd_soc_pcm_runtime *rtd = substream->private_data;
155 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai);
156 int channel;
157
158 channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
159 dev->channel_out : dev->channel_in;
160
161 s6000_i2s_stop_channel(dev, channel);
162}
163
164static int s6000_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
165 int after)
166{
167 switch (cmd) {
168 case SNDRV_PCM_TRIGGER_START:
169 case SNDRV_PCM_TRIGGER_RESUME:
170 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
171 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ^ !after)
172 s6000_i2s_start(substream);
173 break;
174 case SNDRV_PCM_TRIGGER_STOP:
175 case SNDRV_PCM_TRIGGER_SUSPEND:
176 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
177 if (!after)
178 s6000_i2s_stop(substream);
179 }
180 return 0;
181}
182
183static unsigned int s6000_i2s_int_sources(struct s6000_i2s_dev *dev)
184{
185 unsigned int pending;
186 pending = s6_i2s_read_reg(dev, S6_I2S_INTERRUPT_RAW);
187 pending &= S6_I2S_INT_ALIGNMENT |
188 S6_I2S_INT_UNDERRUN |
189 S6_I2S_INT_OVERRUN;
190 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR, pending);
191
192 return pending;
193}
194
195static unsigned int s6000_i2s_check_xrun(struct snd_soc_dai *cpu_dai)
196{
197 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
198 unsigned int errors;
199 unsigned int ret;
200
201 errors = s6000_i2s_int_sources(dev);
202 if (likely(!errors))
203 return 0;
204
205 ret = 0;
206 if (errors & S6_I2S_INT_ALIGNMENT)
207 printk(KERN_ERR "s6000-i2s: WCLK misaligned\n");
208 if (errors & S6_I2S_INT_UNDERRUN)
209 ret |= 1 << SNDRV_PCM_STREAM_PLAYBACK;
210 if (errors & S6_I2S_INT_OVERRUN)
211 ret |= 1 << SNDRV_PCM_STREAM_CAPTURE;
212 return ret;
213}
214
215static void s6000_i2s_wait_disabled(struct s6000_i2s_dev *dev)
216{
217 int channel;
218 int n = 50;
219 for (channel = 0; channel < 2; channel++) {
220 while (--n >= 0) {
221 int v = s6_i2s_read_reg(dev, S6_I2S_ENABLE(channel));
222 if ((v & S6_I2S_IS_ENABLED)
223 || !(v & (S6_I2S_DMA_ACTIVE | S6_I2S_IS_BUSY)))
224 break;
225 udelay(20);
226 }
227 }
228 if (n < 0)
229 printk(KERN_WARNING "s6000-i2s: timeout disabling interfaces");
230}
231
232static int s6000_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
233 unsigned int fmt)
234{
235 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
236 u32 w;
237
238 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
239 case SND_SOC_DAIFMT_CBM_CFM:
240 w = S6_I2S_SCK_IN | S6_I2S_WS_IN;
241 break;
242 case SND_SOC_DAIFMT_CBS_CFM:
243 w = S6_I2S_SCK_OUT | S6_I2S_WS_IN;
244 break;
245 case SND_SOC_DAIFMT_CBM_CFS:
246 w = S6_I2S_SCK_IN | S6_I2S_WS_OUT;
247 break;
248 case SND_SOC_DAIFMT_CBS_CFS:
249 w = S6_I2S_SCK_OUT | S6_I2S_WS_OUT;
250 break;
251 default:
252 return -EINVAL;
253 }
254
255 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
256 case SND_SOC_DAIFMT_NB_NF:
257 w |= S6_I2S_LEFT_FIRST;
258 break;
259 case SND_SOC_DAIFMT_NB_IF:
260 w |= S6_I2S_RIGHT_FIRST;
261 break;
262 default:
263 return -EINVAL;
264 }
265
266 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(0),
267 S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w);
268 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(1),
269 S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w);
270
271 return 0;
272}
273
274static int s6000_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
275{
276 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
277
278 if (!div || (div & 1) || div > (S6_I2S_DIV_MASK + 1) * 2)
279 return -EINVAL;
280
281 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(div_id),
282 S6_I2S_DIV_MASK, div / 2 - 1);
283 return 0;
284}
285
286static int s6000_i2s_hw_params(struct snd_pcm_substream *substream,
287 struct snd_pcm_hw_params *params,
288 struct snd_soc_dai *dai)
289{
290 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
291 int interf;
292 u32 w = 0;
293
294 if (dev->wide)
295 interf = 0;
296 else {
297 w |= (((params_channels(params) - 2) / 2)
298 << S6_I2S_CHANNELS_SHIFT) & S6_I2S_CHANNELS_MASK;
299 interf = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
300 ? dev->channel_out : dev->channel_in;
301 }
302
303 switch (params_format(params)) {
304 case SNDRV_PCM_FORMAT_S16_LE:
305 w |= S6_I2S_16BIT | S6_I2S_MEM_16BIT;
306 break;
307 case SNDRV_PCM_FORMAT_S32_LE:
308 w |= S6_I2S_32BIT | S6_I2S_MEM_32BIT;
309 break;
310 default:
311 printk(KERN_WARNING "s6000-i2s: unsupported PCM format %x\n",
312 params_format(params));
313 return -EINVAL;
314 }
315
316 if (s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(interf))
317 & S6_I2S_IS_ENABLED) {
318 printk(KERN_ERR "s6000-i2s: interface already enabled\n");
319 return -EBUSY;
320 }
321
322 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(interf),
323 S6_I2S_CHANNELS_MASK|S6_I2S_MEM_MASK|S6_I2S_BITS_MASK,
324 w);
325
326 return 0;
327}
328
329static int s6000_i2s_dai_probe(struct snd_soc_dai *dai)
330{
331 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
332 struct s6000_snd_platform_data *pdata = dai->dev->platform_data;
333
334 if (!pdata)
335 return -EINVAL;
336
337 dai->capture_dma_data = &dev->dma_params;
338 dai->playback_dma_data = &dev->dma_params;
339
340 dev->wide = pdata->wide;
341 dev->channel_in = pdata->channel_in;
342 dev->channel_out = pdata->channel_out;
343 dev->lines_in = pdata->lines_in;
344 dev->lines_out = pdata->lines_out;
345
346 s6_i2s_write_reg(dev, S6_I2S_MODE,
347 dev->wide ? S6_I2S_WIDE : S6_I2S_DUAL);
348
349 if (dev->wide) {
350 int i;
351
352 if (dev->lines_in + dev->lines_out > S6_I2S_NUM_LINES)
353 return -EINVAL;
354
355 dev->channel_in = 0;
356 dev->channel_out = 1;
357 dai->driver->capture.channels_min = 2 * dev->lines_in;
358 dai->driver->capture.channels_max = dai->driver->capture.channels_min;
359 dai->driver->playback.channels_min = 2 * dev->lines_out;
360 dai->driver->playback.channels_max = dai->driver->playback.channels_min;
361
362 for (i = 0; i < dev->lines_out; i++)
363 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_OUT);
364
365 for (; i < S6_I2S_NUM_LINES - dev->lines_in; i++)
366 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i),
367 S6_I2S_UNUSED);
368
369 for (; i < S6_I2S_NUM_LINES; i++)
370 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_IN);
371 } else {
372 unsigned int cfg[2] = {S6_I2S_UNUSED, S6_I2S_UNUSED};
373
374 if (dev->lines_in > 1 || dev->lines_out > 1)
375 return -EINVAL;
376
377 dai->driver->capture.channels_min = 2 * dev->lines_in;
378 dai->driver->capture.channels_max = 8 * dev->lines_in;
379 dai->driver->playback.channels_min = 2 * dev->lines_out;
380 dai->driver->playback.channels_max = 8 * dev->lines_out;
381
382 if (dev->lines_in)
383 cfg[dev->channel_in] = S6_I2S_IN;
384 if (dev->lines_out)
385 cfg[dev->channel_out] = S6_I2S_OUT;
386
387 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(0), cfg[0]);
388 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(1), cfg[1]);
389 }
390
391 if (dev->lines_out) {
392 if (dev->lines_in) {
393 if (!dev->dma_params.dma_out)
394 return -ENODEV;
395 } else {
396 dev->dma_params.dma_out = dev->dma_params.dma_in;
397 dev->dma_params.dma_in = 0;
398 }
399 }
400 dev->dma_params.sif_in = dev->sifbase + (dev->channel_in ?
401 S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0);
402 dev->dma_params.sif_out = dev->sifbase + (dev->channel_out ?
403 S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0);
404 dev->dma_params.same_rate = pdata->same_rate | pdata->wide;
405 return 0;
406}
407
408#define S6000_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
409#define S6000_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
410
411static const struct snd_soc_dai_ops s6000_i2s_dai_ops = {
412 .set_fmt = s6000_i2s_set_dai_fmt,
413 .set_clkdiv = s6000_i2s_set_clkdiv,
414 .hw_params = s6000_i2s_hw_params,
415};
416
417static struct snd_soc_dai_driver s6000_i2s_dai = {
418 .probe = s6000_i2s_dai_probe,
419 .playback = {
420 .channels_min = 2,
421 .channels_max = 8,
422 .formats = S6000_I2S_FORMATS,
423 .rates = S6000_I2S_RATES,
424 .rate_min = 0,
425 .rate_max = 1562500,
426 },
427 .capture = {
428 .channels_min = 2,
429 .channels_max = 8,
430 .formats = S6000_I2S_FORMATS,
431 .rates = S6000_I2S_RATES,
432 .rate_min = 0,
433 .rate_max = 1562500,
434 },
435 .ops = &s6000_i2s_dai_ops,
436};
437
438static const struct snd_soc_component_driver s6000_i2s_component = {
439 .name = "s6000-i2s",
440};
441
442static int s6000_i2s_probe(struct platform_device *pdev)
443{
444 struct s6000_i2s_dev *dev;
445 struct resource *scbmem, *sifmem, *region, *dma1, *dma2;
446 u8 __iomem *mmio;
447 int ret;
448
449 scbmem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
450 if (!scbmem) {
451 dev_err(&pdev->dev, "no mem resource?\n");
452 ret = -ENODEV;
453 goto err_release_none;
454 }
455
456 region = request_mem_region(scbmem->start, resource_size(scbmem),
457 pdev->name);
458 if (!region) {
459 dev_err(&pdev->dev, "I2S SCB region already claimed\n");
460 ret = -EBUSY;
461 goto err_release_none;
462 }
463
464 mmio = ioremap(scbmem->start, resource_size(scbmem));
465 if (!mmio) {
466 dev_err(&pdev->dev, "can't ioremap SCB region\n");
467 ret = -ENOMEM;
468 goto err_release_scb;
469 }
470
471 sifmem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
472 if (!sifmem) {
473 dev_err(&pdev->dev, "no second mem resource?\n");
474 ret = -ENODEV;
475 goto err_release_map;
476 }
477
478 region = request_mem_region(sifmem->start, resource_size(sifmem),
479 pdev->name);
480 if (!region) {
481 dev_err(&pdev->dev, "I2S SIF region already claimed\n");
482 ret = -EBUSY;
483 goto err_release_map;
484 }
485
486 dma1 = platform_get_resource(pdev, IORESOURCE_DMA, 0);
487 if (!dma1) {
488 dev_err(&pdev->dev, "no dma resource?\n");
489 ret = -ENODEV;
490 goto err_release_sif;
491 }
492
493 region = request_mem_region(dma1->start, resource_size(dma1),
494 pdev->name);
495 if (!region) {
496 dev_err(&pdev->dev, "I2S DMA region already claimed\n");
497 ret = -EBUSY;
498 goto err_release_sif;
499 }
500
501 dma2 = platform_get_resource(pdev, IORESOURCE_DMA, 1);
502 if (dma2) {
503 region = request_mem_region(dma2->start, resource_size(dma2),
504 pdev->name);
505 if (!region) {
506 dev_err(&pdev->dev,
507 "I2S DMA region already claimed\n");
508 ret = -EBUSY;
509 goto err_release_dma1;
510 }
511 }
512
513 dev = kzalloc(sizeof(struct s6000_i2s_dev), GFP_KERNEL);
514 if (!dev) {
515 ret = -ENOMEM;
516 goto err_release_dma2;
517 }
518 dev_set_drvdata(&pdev->dev, dev);
519
520 dev->sifbase = sifmem->start;
521 dev->scbbase = mmio;
522
523 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0);
524 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR,
525 S6_I2S_INT_ALIGNMENT |
526 S6_I2S_INT_UNDERRUN |
527 S6_I2S_INT_OVERRUN);
528
529 s6000_i2s_stop_channel(dev, 0);
530 s6000_i2s_stop_channel(dev, 1);
531 s6000_i2s_wait_disabled(dev);
532
533 dev->dma_params.check_xrun = s6000_i2s_check_xrun;
534 dev->dma_params.trigger = s6000_i2s_trigger;
535 dev->dma_params.dma_in = dma1->start;
536 dev->dma_params.dma_out = dma2 ? dma2->start : 0;
537 dev->dma_params.irq = platform_get_irq(pdev, 0);
538 if (dev->dma_params.irq < 0) {
539 dev_err(&pdev->dev, "no irq resource?\n");
540 ret = -ENODEV;
541 goto err_release_dev;
542 }
543
544 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE,
545 S6_I2S_INT_ALIGNMENT |
546 S6_I2S_INT_UNDERRUN |
547 S6_I2S_INT_OVERRUN);
548
549 ret = snd_soc_register_component(&pdev->dev, &s6000_i2s_component,
550 &s6000_i2s_dai, 1);
551 if (ret)
552 goto err_release_dev;
553
554 return 0;
555
556err_release_dev:
557 kfree(dev);
558err_release_dma2:
559 if (dma2)
560 release_mem_region(dma2->start, resource_size(dma2));
561err_release_dma1:
562 release_mem_region(dma1->start, resource_size(dma1));
563err_release_sif:
564 release_mem_region(sifmem->start, resource_size(sifmem));
565err_release_map:
566 iounmap(mmio);
567err_release_scb:
568 release_mem_region(scbmem->start, resource_size(scbmem));
569err_release_none:
570 return ret;
571}
572
573static int s6000_i2s_remove(struct platform_device *pdev)
574{
575 struct s6000_i2s_dev *dev = dev_get_drvdata(&pdev->dev);
576 struct resource *region;
577 void __iomem *mmio = dev->scbbase;
578
579 snd_soc_unregister_component(&pdev->dev);
580
581 s6000_i2s_stop_channel(dev, 0);
582 s6000_i2s_stop_channel(dev, 1);
583
584 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0);
585 kfree(dev);
586
587 region = platform_get_resource(pdev, IORESOURCE_DMA, 0);
588 release_mem_region(region->start, resource_size(region));
589
590 region = platform_get_resource(pdev, IORESOURCE_DMA, 1);
591 if (region)
592 release_mem_region(region->start, resource_size(region));
593
594 region = platform_get_resource(pdev, IORESOURCE_MEM, 0);
595 release_mem_region(region->start, resource_size(region));
596
597 iounmap(mmio);
598 region = platform_get_resource(pdev, IORESOURCE_IO, 0);
599 release_mem_region(region->start, resource_size(region));
600
601 return 0;
602}
603
604static struct platform_driver s6000_i2s_driver = {
605 .probe = s6000_i2s_probe,
606 .remove = s6000_i2s_remove,
607 .driver = {
608 .name = "s6000-i2s",
609 .owner = THIS_MODULE,
610 },
611};
612
613module_platform_driver(s6000_i2s_driver);
614
615MODULE_AUTHOR("Daniel Gloeckner");
616MODULE_DESCRIPTION("Stretch s6000 family I2S SoC Interface");
617MODULE_LICENSE("GPL");
diff --git a/sound/soc/s6000/s6000-i2s.h b/sound/soc/s6000/s6000-i2s.h
deleted file mode 100644
index 86aa1921c89e..000000000000
--- a/sound/soc/s6000/s6000-i2s.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * ALSA SoC I2S Audio Layer for the Stretch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _S6000_I2S_H
13#define _S6000_I2S_H
14
15struct s6000_snd_platform_data {
16 int lines_in;
17 int lines_out;
18 int channel_in;
19 int channel_out;
20 int wide;
21 int same_rate;
22};
23#endif
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
deleted file mode 100644
index fb8461e1b1f6..000000000000
--- a/sound/soc/s6000/s6000-pcm.c
+++ /dev/null
@@ -1,521 +0,0 @@
1/*
2 * ALSA PCM interface for the Stetch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/slab.h>
16#include <linux/dma-mapping.h>
17#include <linux/interrupt.h>
18
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/soc.h>
23
24#include <asm/dma.h>
25#include <variant/dmac.h>
26
27#include "s6000-pcm.h"
28
29#define S6_PCM_PREALLOCATE_SIZE (96 * 1024)
30#define S6_PCM_PREALLOCATE_MAX (2048 * 1024)
31
32static struct snd_pcm_hardware s6000_pcm_hardware = {
33 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
34 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
35 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_JOINT_DUPLEX),
36 .buffer_bytes_max = 0x7ffffff0,
37 .period_bytes_min = 16,
38 .period_bytes_max = 0xfffff0,
39 .periods_min = 2,
40 .periods_max = 1024, /* no limit */
41 .fifo_size = 0,
42};
43
44struct s6000_runtime_data {
45 spinlock_t lock;
46 int period; /* current DMA period */
47};
48
49static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream)
50{
51 struct snd_pcm_runtime *runtime = substream->runtime;
52 struct s6000_runtime_data *prtd = runtime->private_data;
53 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
54 struct s6000_pcm_dma_params *par;
55 int channel;
56 unsigned int period_size;
57 unsigned int dma_offset;
58 dma_addr_t dma_pos;
59 dma_addr_t src, dst;
60
61 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
62
63 period_size = snd_pcm_lib_period_bytes(substream);
64 dma_offset = prtd->period * period_size;
65 dma_pos = runtime->dma_addr + dma_offset;
66
67 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
68 src = dma_pos;
69 dst = par->sif_out;
70 channel = par->dma_out;
71 } else {
72 src = par->sif_in;
73 dst = dma_pos;
74 channel = par->dma_in;
75 }
76
77 if (!s6dmac_channel_enabled(DMA_MASK_DMAC(channel),
78 DMA_INDEX_CHNL(channel)))
79 return;
80
81 if (s6dmac_fifo_full(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel))) {
82 printk(KERN_ERR "s6000-pcm: fifo full\n");
83 return;
84 }
85
86 if (WARN_ON(period_size & 15))
87 return;
88 s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel),
89 src, dst, period_size);
90
91 prtd->period++;
92 if (unlikely(prtd->period >= runtime->periods))
93 prtd->period = 0;
94}
95
96static irqreturn_t s6000_pcm_irq(int irq, void *data)
97{
98 struct snd_pcm *pcm = data;
99 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
100 struct s6000_runtime_data *prtd;
101 unsigned int has_xrun;
102 int i, ret = IRQ_NONE;
103
104 for (i = 0; i < 2; ++i) {
105 struct snd_pcm_substream *substream = pcm->streams[i].substream;
106 struct s6000_pcm_dma_params *params =
107 snd_soc_dai_get_dma_data(runtime->cpu_dai, substream);
108 u32 channel;
109 unsigned int pending;
110
111 if (substream == SNDRV_PCM_STREAM_PLAYBACK)
112 channel = params->dma_out;
113 else
114 channel = params->dma_in;
115
116 has_xrun = params->check_xrun(runtime->cpu_dai);
117
118 if (!channel)
119 continue;
120
121 if (unlikely(has_xrun & (1 << i)) &&
122 substream->runtime &&
123 snd_pcm_running(substream)) {
124 dev_dbg(pcm->dev, "xrun\n");
125 snd_pcm_stream_lock(substream);
126 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
127 snd_pcm_stream_unlock(substream);
128 ret = IRQ_HANDLED;
129 }
130
131 pending = s6dmac_int_sources(DMA_MASK_DMAC(channel),
132 DMA_INDEX_CHNL(channel));
133
134 if (pending & 1) {
135 ret = IRQ_HANDLED;
136 if (likely(substream->runtime &&
137 snd_pcm_running(substream))) {
138 snd_pcm_period_elapsed(substream);
139 dev_dbg(pcm->dev, "period elapsed %x %x\n",
140 s6dmac_cur_src(DMA_MASK_DMAC(channel),
141 DMA_INDEX_CHNL(channel)),
142 s6dmac_cur_dst(DMA_MASK_DMAC(channel),
143 DMA_INDEX_CHNL(channel)));
144 prtd = substream->runtime->private_data;
145 spin_lock(&prtd->lock);
146 s6000_pcm_enqueue_dma(substream);
147 spin_unlock(&prtd->lock);
148 }
149 }
150
151 if (unlikely(pending & ~7)) {
152 if (pending & (1 << 3))
153 printk(KERN_WARNING
154 "s6000-pcm: DMA %x Underflow\n",
155 channel);
156 if (pending & (1 << 4))
157 printk(KERN_WARNING
158 "s6000-pcm: DMA %x Overflow\n",
159 channel);
160 if (pending & 0x1e0)
161 printk(KERN_WARNING
162 "s6000-pcm: DMA %x Master Error "
163 "(mask %x)\n",
164 channel, pending >> 5);
165
166 }
167 }
168
169 return ret;
170}
171
172static int s6000_pcm_start(struct snd_pcm_substream *substream)
173{
174 struct s6000_runtime_data *prtd = substream->runtime->private_data;
175 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
176 struct s6000_pcm_dma_params *par;
177 unsigned long flags;
178 int srcinc;
179 u32 dma;
180
181 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
182
183 spin_lock_irqsave(&prtd->lock, flags);
184
185 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
186 srcinc = 1;
187 dma = par->dma_out;
188 } else {
189 srcinc = 0;
190 dma = par->dma_in;
191 }
192 s6dmac_enable_chan(DMA_MASK_DMAC(dma), DMA_INDEX_CHNL(dma),
193 1 /* priority 1 (0 is max) */,
194 0 /* peripheral requests w/o xfer length mode */,
195 srcinc /* source address increment */,
196 srcinc^1 /* destination address increment */,
197 0 /* chunksize 0 (skip impossible on this dma) */,
198 0 /* source skip after chunk (impossible) */,
199 0 /* destination skip after chunk (impossible) */,
200 4 /* 16 byte burst size */,
201 -1 /* don't conserve bandwidth */,
202 0 /* low watermark irq descriptor threshold */,
203 0 /* disable hardware timestamps */,
204 1 /* enable channel */);
205
206 s6000_pcm_enqueue_dma(substream);
207 s6000_pcm_enqueue_dma(substream);
208
209 spin_unlock_irqrestore(&prtd->lock, flags);
210
211 return 0;
212}
213
214static int s6000_pcm_stop(struct snd_pcm_substream *substream)
215{
216 struct s6000_runtime_data *prtd = substream->runtime->private_data;
217 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
218 struct s6000_pcm_dma_params *par;
219 unsigned long flags;
220 u32 channel;
221
222 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
223
224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
225 channel = par->dma_out;
226 else
227 channel = par->dma_in;
228
229 s6dmac_set_terminal_count(DMA_MASK_DMAC(channel),
230 DMA_INDEX_CHNL(channel), 0);
231
232 spin_lock_irqsave(&prtd->lock, flags);
233
234 s6dmac_disable_chan(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel));
235
236 spin_unlock_irqrestore(&prtd->lock, flags);
237
238 return 0;
239}
240
241static int s6000_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
242{
243 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
244 struct s6000_pcm_dma_params *par;
245 int ret;
246
247 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
248
249 ret = par->trigger(substream, cmd, 0);
250 if (ret < 0)
251 return ret;
252
253 switch (cmd) {
254 case SNDRV_PCM_TRIGGER_START:
255 case SNDRV_PCM_TRIGGER_RESUME:
256 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
257 ret = s6000_pcm_start(substream);
258 break;
259 case SNDRV_PCM_TRIGGER_STOP:
260 case SNDRV_PCM_TRIGGER_SUSPEND:
261 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
262 ret = s6000_pcm_stop(substream);
263 break;
264 default:
265 ret = -EINVAL;
266 }
267 if (ret < 0)
268 return ret;
269
270 return par->trigger(substream, cmd, 1);
271}
272
273static int s6000_pcm_prepare(struct snd_pcm_substream *substream)
274{
275 struct s6000_runtime_data *prtd = substream->runtime->private_data;
276
277 prtd->period = 0;
278
279 return 0;
280}
281
282static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream)
283{
284 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
285 struct s6000_pcm_dma_params *par;
286 struct snd_pcm_runtime *runtime = substream->runtime;
287 struct s6000_runtime_data *prtd = runtime->private_data;
288 unsigned long flags;
289 unsigned int offset;
290 dma_addr_t count;
291
292 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
293
294 spin_lock_irqsave(&prtd->lock, flags);
295
296 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
297 count = s6dmac_cur_src(DMA_MASK_DMAC(par->dma_out),
298 DMA_INDEX_CHNL(par->dma_out));
299 else
300 count = s6dmac_cur_dst(DMA_MASK_DMAC(par->dma_in),
301 DMA_INDEX_CHNL(par->dma_in));
302
303 count -= runtime->dma_addr;
304
305 spin_unlock_irqrestore(&prtd->lock, flags);
306
307 offset = bytes_to_frames(runtime, count);
308 if (unlikely(offset >= runtime->buffer_size))
309 offset = 0;
310
311 return offset;
312}
313
314static int s6000_pcm_open(struct snd_pcm_substream *substream)
315{
316 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
317 struct s6000_pcm_dma_params *par;
318 struct snd_pcm_runtime *runtime = substream->runtime;
319 struct s6000_runtime_data *prtd;
320 int ret;
321
322 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
323 snd_soc_set_runtime_hwparams(substream, &s6000_pcm_hardware);
324
325 ret = snd_pcm_hw_constraint_step(runtime, 0,
326 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);
327 if (ret < 0)
328 return ret;
329 ret = snd_pcm_hw_constraint_step(runtime, 0,
330 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 16);
331 if (ret < 0)
332 return ret;
333 ret = snd_pcm_hw_constraint_integer(runtime,
334 SNDRV_PCM_HW_PARAM_PERIODS);
335 if (ret < 0)
336 return ret;
337
338 if (par->same_rate) {
339 int rate;
340 spin_lock(&par->lock); /* needed? */
341 rate = par->rate;
342 spin_unlock(&par->lock);
343 if (rate != -1) {
344 ret = snd_pcm_hw_constraint_minmax(runtime,
345 SNDRV_PCM_HW_PARAM_RATE,
346 rate, rate);
347 if (ret < 0)
348 return ret;
349 }
350 }
351
352 prtd = kzalloc(sizeof(struct s6000_runtime_data), GFP_KERNEL);
353 if (prtd == NULL)
354 return -ENOMEM;
355
356 spin_lock_init(&prtd->lock);
357
358 runtime->private_data = prtd;
359
360 return 0;
361}
362
363static int s6000_pcm_close(struct snd_pcm_substream *substream)
364{
365 struct snd_pcm_runtime *runtime = substream->runtime;
366 struct s6000_runtime_data *prtd = runtime->private_data;
367
368 kfree(prtd);
369
370 return 0;
371}
372
373static int s6000_pcm_hw_params(struct snd_pcm_substream *substream,
374 struct snd_pcm_hw_params *hw_params)
375{
376 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
377 struct s6000_pcm_dma_params *par;
378 int ret;
379 ret = snd_pcm_lib_malloc_pages(substream,
380 params_buffer_bytes(hw_params));
381 if (ret < 0) {
382 printk(KERN_WARNING "s6000-pcm: allocation of memory failed\n");
383 return ret;
384 }
385
386 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
387
388 if (par->same_rate) {
389 spin_lock(&par->lock);
390 if (par->rate == -1 ||
391 !(par->in_use & ~(1 << substream->stream))) {
392 par->rate = params_rate(hw_params);
393 par->in_use |= 1 << substream->stream;
394 } else if (params_rate(hw_params) != par->rate) {
395 snd_pcm_lib_free_pages(substream);
396 par->in_use &= ~(1 << substream->stream);
397 ret = -EBUSY;
398 }
399 spin_unlock(&par->lock);
400 }
401 return ret;
402}
403
404static int s6000_pcm_hw_free(struct snd_pcm_substream *substream)
405{
406 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
407 struct s6000_pcm_dma_params *par =
408 snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
409
410 spin_lock(&par->lock);
411 par->in_use &= ~(1 << substream->stream);
412 if (!par->in_use)
413 par->rate = -1;
414 spin_unlock(&par->lock);
415
416 return snd_pcm_lib_free_pages(substream);
417}
418
419static struct snd_pcm_ops s6000_pcm_ops = {
420 .open = s6000_pcm_open,
421 .close = s6000_pcm_close,
422 .ioctl = snd_pcm_lib_ioctl,
423 .hw_params = s6000_pcm_hw_params,
424 .hw_free = s6000_pcm_hw_free,
425 .trigger = s6000_pcm_trigger,
426 .prepare = s6000_pcm_prepare,
427 .pointer = s6000_pcm_pointer,
428};
429
430static void s6000_pcm_free(struct snd_pcm *pcm)
431{
432 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
433 struct s6000_pcm_dma_params *params =
434 snd_soc_dai_get_dma_data(runtime->cpu_dai,
435 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
436
437 free_irq(params->irq, pcm);
438 snd_pcm_lib_preallocate_free_for_all(pcm);
439}
440
441static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
442{
443 struct snd_card *card = runtime->card->snd_card;
444 struct snd_pcm *pcm = runtime->pcm;
445 struct s6000_pcm_dma_params *params;
446 int res;
447
448 params = snd_soc_dai_get_dma_data(runtime->cpu_dai,
449 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
450
451 res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
452 if (res)
453 return res;
454
455 if (params->dma_in) {
456 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
457 DMA_INDEX_CHNL(params->dma_in));
458 s6dmac_int_sources(DMA_MASK_DMAC(params->dma_in),
459 DMA_INDEX_CHNL(params->dma_in));
460 }
461
462 if (params->dma_out) {
463 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_out),
464 DMA_INDEX_CHNL(params->dma_out));
465 s6dmac_int_sources(DMA_MASK_DMAC(params->dma_out),
466 DMA_INDEX_CHNL(params->dma_out));
467 }
468
469 res = request_irq(params->irq, s6000_pcm_irq, IRQF_SHARED,
470 "s6000-audio", pcm);
471 if (res) {
472 printk(KERN_ERR "s6000-pcm couldn't get IRQ\n");
473 return res;
474 }
475
476 res = snd_pcm_lib_preallocate_pages_for_all(pcm,
477 SNDRV_DMA_TYPE_DEV,
478 card->dev,
479 S6_PCM_PREALLOCATE_SIZE,
480 S6_PCM_PREALLOCATE_MAX);
481 if (res)
482 printk(KERN_WARNING "s6000-pcm: preallocation failed\n");
483
484 spin_lock_init(&params->lock);
485 params->in_use = 0;
486 params->rate = -1;
487 return 0;
488}
489
490static struct snd_soc_platform_driver s6000_soc_platform = {
491 .ops = &s6000_pcm_ops,
492 .pcm_new = s6000_pcm_new,
493 .pcm_free = s6000_pcm_free,
494};
495
496static int s6000_soc_platform_probe(struct platform_device *pdev)
497{
498 return snd_soc_register_platform(&pdev->dev, &s6000_soc_platform);
499}
500
501static int s6000_soc_platform_remove(struct platform_device *pdev)
502{
503 snd_soc_unregister_platform(&pdev->dev);
504 return 0;
505}
506
507static struct platform_driver s6000_pcm_driver = {
508 .driver = {
509 .name = "s6000-pcm-audio",
510 .owner = THIS_MODULE,
511 },
512
513 .probe = s6000_soc_platform_probe,
514 .remove = s6000_soc_platform_remove,
515};
516
517module_platform_driver(s6000_pcm_driver);
518
519MODULE_AUTHOR("Daniel Gloeckner");
520MODULE_DESCRIPTION("Stretch s6000 family PCM DMA module");
521MODULE_LICENSE("GPL");
diff --git a/sound/soc/s6000/s6000-pcm.h b/sound/soc/s6000/s6000-pcm.h
deleted file mode 100644
index 09d9b883e58b..000000000000
--- a/sound/soc/s6000/s6000-pcm.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * ALSA PCM interface for the Stretch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _S6000_PCM_H
13#define _S6000_PCM_H
14
15struct snd_soc_dai;
16struct snd_pcm_substream;
17
18struct s6000_pcm_dma_params {
19 unsigned int (*check_xrun)(struct snd_soc_dai *cpu_dai);
20 int (*trigger)(struct snd_pcm_substream *substream, int cmd, int after);
21 dma_addr_t sif_in;
22 dma_addr_t sif_out;
23 u32 dma_in;
24 u32 dma_out;
25 int irq;
26 int same_rate;
27
28 spinlock_t lock;
29 int in_use;
30 int rate;
31};
32
33#endif
diff --git a/sound/soc/s6000/s6105-ipcam.c b/sound/soc/s6000/s6105-ipcam.c
deleted file mode 100644
index 3510c01f8a6a..000000000000
--- a/sound/soc/s6000/s6105-ipcam.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/*
2 * ASoC driver for Stretch s6105 IP camera platform
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/timer.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/i2c.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/soc.h>
21
22#include "s6000-pcm.h"
23#include "s6000-i2s.h"
24
25#define S6105_CAM_CODEC_CLOCK 12288000
26
27static int s6105_hw_params(struct snd_pcm_substream *substream,
28 struct snd_pcm_hw_params *params)
29{
30 struct snd_soc_pcm_runtime *rtd = substream->private_data;
31 struct snd_soc_dai *codec_dai = rtd->codec_dai;
32 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
33 int ret = 0;
34
35 /* set codec DAI configuration */
36 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
37 SND_SOC_DAIFMT_CBM_CFM);
38 if (ret < 0)
39 return ret;
40
41 /* set cpu DAI configuration */
42 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM |
43 SND_SOC_DAIFMT_NB_NF);
44 if (ret < 0)
45 return ret;
46
47 /* set the codec system clock */
48 ret = snd_soc_dai_set_sysclk(codec_dai, 0, S6105_CAM_CODEC_CLOCK,
49 SND_SOC_CLOCK_OUT);
50 if (ret < 0)
51 return ret;
52
53 return 0;
54}
55
56static struct snd_soc_ops s6105_ops = {
57 .hw_params = s6105_hw_params,
58};
59
60/* s6105 machine dapm widgets */
61static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
62 SND_SOC_DAPM_LINE("Audio Out Differential", NULL),
63 SND_SOC_DAPM_LINE("Audio Out Stereo", NULL),
64 SND_SOC_DAPM_LINE("Audio In", NULL),
65};
66
67/* s6105 machine audio_mapnections to the codec pins */
68static const struct snd_soc_dapm_route audio_map[] = {
69 /* Audio Out connected to HPLOUT, HPLCOM, HPROUT */
70 {"Audio Out Differential", NULL, "HPLOUT"},
71 {"Audio Out Differential", NULL, "HPLCOM"},
72 {"Audio Out Stereo", NULL, "HPLOUT"},
73 {"Audio Out Stereo", NULL, "HPROUT"},
74
75 /* Audio In connected to LINE1L, LINE1R */
76 {"LINE1L", NULL, "Audio In"},
77 {"LINE1R", NULL, "Audio In"},
78};
79
80static int output_type_info(struct snd_kcontrol *kcontrol,
81 struct snd_ctl_elem_info *uinfo)
82{
83 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
84 uinfo->count = 1;
85 uinfo->value.enumerated.items = 2;
86 if (uinfo->value.enumerated.item) {
87 uinfo->value.enumerated.item = 1;
88 strcpy(uinfo->value.enumerated.name, "HPLOUT/HPROUT");
89 } else {
90 strcpy(uinfo->value.enumerated.name, "HPLOUT/HPLCOM");
91 }
92 return 0;
93}
94
95static int output_type_get(struct snd_kcontrol *kcontrol,
96 struct snd_ctl_elem_value *ucontrol)
97{
98 ucontrol->value.enumerated.item[0] = kcontrol->private_value;
99 return 0;
100}
101
102static int output_type_put(struct snd_kcontrol *kcontrol,
103 struct snd_ctl_elem_value *ucontrol)
104{
105 struct snd_soc_card *card = kcontrol->private_data;
106 struct snd_soc_dapm_context *dapm = &card->dapm;
107 unsigned int val = (ucontrol->value.enumerated.item[0] != 0);
108 char *differential = "Audio Out Differential";
109 char *stereo = "Audio Out Stereo";
110
111 if (kcontrol->private_value == val)
112 return 0;
113 kcontrol->private_value = val;
114 snd_soc_dapm_disable_pin(dapm, val ? differential : stereo);
115 snd_soc_dapm_sync(dapm);
116 snd_soc_dapm_enable_pin(dapm, val ? stereo : differential);
117 snd_soc_dapm_sync(dapm);
118
119 return 1;
120}
121
122static const struct snd_kcontrol_new audio_out_mux = {
123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
124 .name = "Master Output Mux",
125 .index = 0,
126 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
127 .info = output_type_info,
128 .get = output_type_get,
129 .put = output_type_put,
130 .private_value = 1 /* default to stereo */
131};
132
133/* Logic for a aic3x as connected on the s6105 ip camera ref design */
134static int s6105_aic3x_init(struct snd_soc_pcm_runtime *rtd)
135{
136 struct snd_soc_card *card = rtd->card;
137
138 /* must correspond to audio_out_mux.private_value initializer */
139 snd_soc_dapm_disable_pin(&card->dapm, "Audio Out Differential");
140
141 snd_ctl_add(card->snd_card, snd_ctl_new1(&audio_out_mux, card));
142
143 return 0;
144}
145
146/* s6105 digital audio interface glue - connects codec <--> CPU */
147static struct snd_soc_dai_link s6105_dai = {
148 .name = "TLV320AIC31",
149 .stream_name = "AIC31",
150 .cpu_dai_name = "s6000-i2s",
151 .codec_dai_name = "tlv320aic3x-hifi",
152 .platform_name = "s6000-pcm-audio",
153 .codec_name = "tlv320aic3x-codec.0-001a",
154 .init = s6105_aic3x_init,
155 .ops = &s6105_ops,
156};
157
158/* s6105 audio machine driver */
159static struct snd_soc_card snd_soc_card_s6105 = {
160 .name = "Stretch IP Camera",
161 .owner = THIS_MODULE,
162 .dai_link = &s6105_dai,
163 .num_links = 1,
164
165 .dapm_widgets = aic3x_dapm_widgets,
166 .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets),
167 .dapm_routes = audio_map,
168 .num_dapm_routes = ARRAY_SIZE(audio_map),
169 .fully_routed = true,
170};
171
172static struct s6000_snd_platform_data s6105_snd_data __initdata = {
173 .wide = 0,
174 .channel_in = 0,
175 .channel_out = 1,
176 .lines_in = 1,
177 .lines_out = 1,
178 .same_rate = 1,
179};
180
181static struct platform_device *s6105_snd_device;
182
183/* temporary i2c device creation until this can be moved into the machine
184 * support file.
185*/
186static struct i2c_board_info i2c_device[] = {
187 { I2C_BOARD_INFO("tlv320aic33", 0x18), }
188};
189
190static int __init s6105_init(void)
191{
192 int ret;
193
194 i2c_register_board_info(0, i2c_device, ARRAY_SIZE(i2c_device));
195
196 s6105_snd_device = platform_device_alloc("soc-audio", -1);
197 if (!s6105_snd_device)
198 return -ENOMEM;
199
200 platform_set_drvdata(s6105_snd_device, &snd_soc_card_s6105);
201 platform_device_add_data(s6105_snd_device, &s6105_snd_data,
202 sizeof(s6105_snd_data));
203
204 ret = platform_device_add(s6105_snd_device);
205 if (ret)
206 platform_device_put(s6105_snd_device);
207
208 return ret;
209}
210
211static void __exit s6105_exit(void)
212{
213 platform_device_unregister(s6105_snd_device);
214}
215
216module_init(s6105_init);
217module_exit(s6105_exit);
218
219MODULE_AUTHOR("Daniel Gloeckner");
220MODULE_DESCRIPTION("Stretch s6105 IP camera ASoC driver");
221MODULE_LICENSE("GPL");
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 7ecd0e8a5c51..f61ebb17cc64 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -591,18 +591,19 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
591{ 591{
592 struct snd_card *card; 592 struct snd_card *card;
593 struct list_head *p; 593 struct list_head *p;
594 bool was_shutdown;
594 595
595 if (chip == (void *)-1L) 596 if (chip == (void *)-1L)
596 return; 597 return;
597 598
598 card = chip->card; 599 card = chip->card;
599 down_write(&chip->shutdown_rwsem); 600 down_write(&chip->shutdown_rwsem);
601 was_shutdown = chip->shutdown;
600 chip->shutdown = 1; 602 chip->shutdown = 1;
601 up_write(&chip->shutdown_rwsem); 603 up_write(&chip->shutdown_rwsem);
602 604
603 mutex_lock(&register_mutex); 605 mutex_lock(&register_mutex);
604 chip->num_interfaces--; 606 if (!was_shutdown) {
605 if (chip->num_interfaces <= 0) {
606 struct snd_usb_endpoint *ep; 607 struct snd_usb_endpoint *ep;
607 608
608 snd_card_disconnect(card); 609 snd_card_disconnect(card);
@@ -622,6 +623,10 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
622 list_for_each(p, &chip->mixer_list) { 623 list_for_each(p, &chip->mixer_list) {
623 snd_usb_mixer_disconnect(p); 624 snd_usb_mixer_disconnect(p);
624 } 625 }
626 }
627
628 chip->num_interfaces--;
629 if (chip->num_interfaces <= 0) {
625 usb_chip[chip->index] = NULL; 630 usb_chip[chip->index] = NULL;
626 mutex_unlock(&register_mutex); 631 mutex_unlock(&register_mutex);
627 snd_card_free_when_closed(card); 632 snd_card_free_when_closed(card);
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 8c5c11ca8c53..25114c9a6801 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1142,6 +1142,11 @@ static int data_init(int argc, const char **argv)
1142 1142
1143int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) 1143int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
1144{ 1144{
1145 int ret = hists__init();
1146
1147 if (ret < 0)
1148 return ret;
1149
1145 perf_config(perf_default_config, NULL); 1150 perf_config(perf_default_config, NULL);
1146 1151
1147 argc = parse_options(argc, argv, options, diff_usage, 0); 1152 argc = parse_options(argc, argv, options, diff_usage, 0);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 04412b4770a2..7af26acf06d9 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -375,7 +375,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
375 OPT_CALLBACK('x', "exec", NULL, "executable|path", 375 OPT_CALLBACK('x', "exec", NULL, "executable|path",
376 "target executable name or path", opt_set_target), 376 "target executable name or path", opt_set_target),
377 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle, 377 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
378 "Disable symbol demangling"), 378 "Enable symbol demangling"),
379 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, 379 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
380 "Enable kernel symbol demangling"), 380 "Enable kernel symbol demangling"),
381 OPT_END() 381 OPT_END()
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 937e4324ad94..a3b13d7dc1d4 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -13,7 +13,7 @@
13#define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 13#define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
14#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 14#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
15#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 15#define cpu_relax() asm volatile("rep; nop" ::: "memory");
16#define CPUINFO_PROC "model name" 16#define CPUINFO_PROC {"model name"}
17#ifndef __NR_perf_event_open 17#ifndef __NR_perf_event_open
18# define __NR_perf_event_open 336 18# define __NR_perf_event_open 336
19#endif 19#endif
@@ -30,7 +30,7 @@
30#define wmb() asm volatile("sfence" ::: "memory") 30#define wmb() asm volatile("sfence" ::: "memory")
31#define rmb() asm volatile("lfence" ::: "memory") 31#define rmb() asm volatile("lfence" ::: "memory")
32#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 32#define cpu_relax() asm volatile("rep; nop" ::: "memory");
33#define CPUINFO_PROC "model name" 33#define CPUINFO_PROC {"model name"}
34#ifndef __NR_perf_event_open 34#ifndef __NR_perf_event_open
35# define __NR_perf_event_open 298 35# define __NR_perf_event_open 298
36#endif 36#endif
@@ -47,14 +47,14 @@
47#define mb() asm volatile ("sync" ::: "memory") 47#define mb() asm volatile ("sync" ::: "memory")
48#define wmb() asm volatile ("sync" ::: "memory") 48#define wmb() asm volatile ("sync" ::: "memory")
49#define rmb() asm volatile ("sync" ::: "memory") 49#define rmb() asm volatile ("sync" ::: "memory")
50#define CPUINFO_PROC "cpu" 50#define CPUINFO_PROC {"cpu"}
51#endif 51#endif
52 52
53#ifdef __s390__ 53#ifdef __s390__
54#define mb() asm volatile("bcr 15,0" ::: "memory") 54#define mb() asm volatile("bcr 15,0" ::: "memory")
55#define wmb() asm volatile("bcr 15,0" ::: "memory") 55#define wmb() asm volatile("bcr 15,0" ::: "memory")
56#define rmb() asm volatile("bcr 15,0" ::: "memory") 56#define rmb() asm volatile("bcr 15,0" ::: "memory")
57#define CPUINFO_PROC "vendor_id" 57#define CPUINFO_PROC {"vendor_id"}
58#endif 58#endif
59 59
60#ifdef __sh__ 60#ifdef __sh__
@@ -67,14 +67,14 @@
67# define wmb() asm volatile("" ::: "memory") 67# define wmb() asm volatile("" ::: "memory")
68# define rmb() asm volatile("" ::: "memory") 68# define rmb() asm volatile("" ::: "memory")
69#endif 69#endif
70#define CPUINFO_PROC "cpu type" 70#define CPUINFO_PROC {"cpu type"}
71#endif 71#endif
72 72
73#ifdef __hppa__ 73#ifdef __hppa__
74#define mb() asm volatile("" ::: "memory") 74#define mb() asm volatile("" ::: "memory")
75#define wmb() asm volatile("" ::: "memory") 75#define wmb() asm volatile("" ::: "memory")
76#define rmb() asm volatile("" ::: "memory") 76#define rmb() asm volatile("" ::: "memory")
77#define CPUINFO_PROC "cpu" 77#define CPUINFO_PROC {"cpu"}
78#endif 78#endif
79 79
80#ifdef __sparc__ 80#ifdef __sparc__
@@ -87,14 +87,14 @@
87#endif 87#endif
88#define wmb() asm volatile("":::"memory") 88#define wmb() asm volatile("":::"memory")
89#define rmb() asm volatile("":::"memory") 89#define rmb() asm volatile("":::"memory")
90#define CPUINFO_PROC "cpu" 90#define CPUINFO_PROC {"cpu"}
91#endif 91#endif
92 92
93#ifdef __alpha__ 93#ifdef __alpha__
94#define mb() asm volatile("mb" ::: "memory") 94#define mb() asm volatile("mb" ::: "memory")
95#define wmb() asm volatile("wmb" ::: "memory") 95#define wmb() asm volatile("wmb" ::: "memory")
96#define rmb() asm volatile("mb" ::: "memory") 96#define rmb() asm volatile("mb" ::: "memory")
97#define CPUINFO_PROC "cpu model" 97#define CPUINFO_PROC {"cpu model"}
98#endif 98#endif
99 99
100#ifdef __ia64__ 100#ifdef __ia64__
@@ -102,7 +102,7 @@
102#define wmb() asm volatile ("mf" ::: "memory") 102#define wmb() asm volatile ("mf" ::: "memory")
103#define rmb() asm volatile ("mf" ::: "memory") 103#define rmb() asm volatile ("mf" ::: "memory")
104#define cpu_relax() asm volatile ("hint @pause" ::: "memory") 104#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
105#define CPUINFO_PROC "model name" 105#define CPUINFO_PROC {"model name"}
106#endif 106#endif
107 107
108#ifdef __arm__ 108#ifdef __arm__
@@ -113,7 +113,7 @@
113#define mb() ((void(*)(void))0xffff0fa0)() 113#define mb() ((void(*)(void))0xffff0fa0)()
114#define wmb() ((void(*)(void))0xffff0fa0)() 114#define wmb() ((void(*)(void))0xffff0fa0)()
115#define rmb() ((void(*)(void))0xffff0fa0)() 115#define rmb() ((void(*)(void))0xffff0fa0)()
116#define CPUINFO_PROC "Processor" 116#define CPUINFO_PROC {"model name", "Processor"}
117#endif 117#endif
118 118
119#ifdef __aarch64__ 119#ifdef __aarch64__
@@ -133,28 +133,28 @@
133 : "memory") 133 : "memory")
134#define wmb() mb() 134#define wmb() mb()
135#define rmb() mb() 135#define rmb() mb()
136#define CPUINFO_PROC "cpu model" 136#define CPUINFO_PROC {"cpu model"}
137#endif 137#endif
138 138
139#ifdef __arc__ 139#ifdef __arc__
140#define mb() asm volatile("" ::: "memory") 140#define mb() asm volatile("" ::: "memory")
141#define wmb() asm volatile("" ::: "memory") 141#define wmb() asm volatile("" ::: "memory")
142#define rmb() asm volatile("" ::: "memory") 142#define rmb() asm volatile("" ::: "memory")
143#define CPUINFO_PROC "Processor" 143#define CPUINFO_PROC {"Processor"}
144#endif 144#endif
145 145
146#ifdef __metag__ 146#ifdef __metag__
147#define mb() asm volatile("" ::: "memory") 147#define mb() asm volatile("" ::: "memory")
148#define wmb() asm volatile("" ::: "memory") 148#define wmb() asm volatile("" ::: "memory")
149#define rmb() asm volatile("" ::: "memory") 149#define rmb() asm volatile("" ::: "memory")
150#define CPUINFO_PROC "CPU" 150#define CPUINFO_PROC {"CPU"}
151#endif 151#endif
152 152
153#ifdef __xtensa__ 153#ifdef __xtensa__
154#define mb() asm volatile("memw" ::: "memory") 154#define mb() asm volatile("memw" ::: "memory")
155#define wmb() asm volatile("memw" ::: "memory") 155#define wmb() asm volatile("memw" ::: "memory")
156#define rmb() asm volatile("" ::: "memory") 156#define rmb() asm volatile("" ::: "memory")
157#define CPUINFO_PROC "core ID" 157#define CPUINFO_PROC {"core ID"}
158#endif 158#endif
159 159
160#ifdef __tile__ 160#ifdef __tile__
@@ -162,7 +162,7 @@
162#define wmb() asm volatile ("mf" ::: "memory") 162#define wmb() asm volatile ("mf" ::: "memory")
163#define rmb() asm volatile ("mf" ::: "memory") 163#define rmb() asm volatile ("mf" ::: "memory")
164#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory") 164#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory")
165#define CPUINFO_PROC "model name" 165#define CPUINFO_PROC {"model name"}
166#endif 166#endif
167 167
168#define barrier() asm volatile ("" ::: "memory") 168#define barrier() asm volatile ("" ::: "memory")
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index ce0de00399da..26f5b2fe5dc8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -579,16 +579,12 @@ static int write_version(int fd, struct perf_header *h __maybe_unused,
579 return do_write_string(fd, perf_version_string); 579 return do_write_string(fd, perf_version_string);
580} 580}
581 581
582static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, 582static int __write_cpudesc(int fd, const char *cpuinfo_proc)
583 struct perf_evlist *evlist __maybe_unused)
584{ 583{
585#ifndef CPUINFO_PROC
586#define CPUINFO_PROC NULL
587#endif
588 FILE *file; 584 FILE *file;
589 char *buf = NULL; 585 char *buf = NULL;
590 char *s, *p; 586 char *s, *p;
591 const char *search = CPUINFO_PROC; 587 const char *search = cpuinfo_proc;
592 size_t len = 0; 588 size_t len = 0;
593 int ret = -1; 589 int ret = -1;
594 590
@@ -638,6 +634,25 @@ done:
638 return ret; 634 return ret;
639} 635}
640 636
637static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
638 struct perf_evlist *evlist __maybe_unused)
639{
640#ifndef CPUINFO_PROC
641#define CPUINFO_PROC {"model name", }
642#endif
643 const char *cpuinfo_procs[] = CPUINFO_PROC;
644 unsigned int i;
645
646 for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) {
647 int ret;
648 ret = __write_cpudesc(fd, cpuinfo_procs[i]);
649 if (ret >= 0)
650 return ret;
651 }
652 return -1;
653}
654
655
641static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, 656static int write_nrcpus(int fd, struct perf_header *h __maybe_unused,
642 struct perf_evlist *evlist __maybe_unused) 657 struct perf_evlist *evlist __maybe_unused)
643{ 658{
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 4906cd81cb56..9402885a77f3 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -373,6 +373,9 @@ struct sort_entry sort_cpu = {
373static int64_t 373static int64_t
374sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) 374sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
375{ 375{
376 if (!left->branch_info || !right->branch_info)
377 return cmp_null(left->branch_info, right->branch_info);
378
376 return _sort__dso_cmp(left->branch_info->from.map, 379 return _sort__dso_cmp(left->branch_info->from.map,
377 right->branch_info->from.map); 380 right->branch_info->from.map);
378} 381}
@@ -380,13 +383,19 @@ sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
380static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf, 383static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf,
381 size_t size, unsigned int width) 384 size_t size, unsigned int width)
382{ 385{
383 return _hist_entry__dso_snprintf(he->branch_info->from.map, 386 if (he->branch_info)
384 bf, size, width); 387 return _hist_entry__dso_snprintf(he->branch_info->from.map,
388 bf, size, width);
389 else
390 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
385} 391}
386 392
387static int64_t 393static int64_t
388sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) 394sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
389{ 395{
396 if (!left->branch_info || !right->branch_info)
397 return cmp_null(left->branch_info, right->branch_info);
398
390 return _sort__dso_cmp(left->branch_info->to.map, 399 return _sort__dso_cmp(left->branch_info->to.map,
391 right->branch_info->to.map); 400 right->branch_info->to.map);
392} 401}
@@ -394,8 +403,11 @@ sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
394static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf, 403static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf,
395 size_t size, unsigned int width) 404 size_t size, unsigned int width)
396{ 405{
397 return _hist_entry__dso_snprintf(he->branch_info->to.map, 406 if (he->branch_info)
398 bf, size, width); 407 return _hist_entry__dso_snprintf(he->branch_info->to.map,
408 bf, size, width);
409 else
410 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
399} 411}
400 412
401static int64_t 413static int64_t
@@ -404,6 +416,12 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
404 struct addr_map_symbol *from_l = &left->branch_info->from; 416 struct addr_map_symbol *from_l = &left->branch_info->from;
405 struct addr_map_symbol *from_r = &right->branch_info->from; 417 struct addr_map_symbol *from_r = &right->branch_info->from;
406 418
419 if (!left->branch_info || !right->branch_info)
420 return cmp_null(left->branch_info, right->branch_info);
421
422 from_l = &left->branch_info->from;
423 from_r = &right->branch_info->from;
424
407 if (!from_l->sym && !from_r->sym) 425 if (!from_l->sym && !from_r->sym)
408 return _sort__addr_cmp(from_l->addr, from_r->addr); 426 return _sort__addr_cmp(from_l->addr, from_r->addr);
409 427
@@ -413,8 +431,13 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
413static int64_t 431static int64_t
414sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) 432sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
415{ 433{
416 struct addr_map_symbol *to_l = &left->branch_info->to; 434 struct addr_map_symbol *to_l, *to_r;
417 struct addr_map_symbol *to_r = &right->branch_info->to; 435
436 if (!left->branch_info || !right->branch_info)
437 return cmp_null(left->branch_info, right->branch_info);
438
439 to_l = &left->branch_info->to;
440 to_r = &right->branch_info->to;
418 441
419 if (!to_l->sym && !to_r->sym) 442 if (!to_l->sym && !to_r->sym)
420 return _sort__addr_cmp(to_l->addr, to_r->addr); 443 return _sort__addr_cmp(to_l->addr, to_r->addr);
@@ -425,19 +448,27 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
425static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf, 448static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,
426 size_t size, unsigned int width) 449 size_t size, unsigned int width)
427{ 450{
428 struct addr_map_symbol *from = &he->branch_info->from; 451 if (he->branch_info) {
429 return _hist_entry__sym_snprintf(from->map, from->sym, from->addr, 452 struct addr_map_symbol *from = &he->branch_info->from;
430 he->level, bf, size, width);
431 453
454 return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
455 he->level, bf, size, width);
456 }
457
458 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
432} 459}
433 460
434static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf, 461static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,
435 size_t size, unsigned int width) 462 size_t size, unsigned int width)
436{ 463{
437 struct addr_map_symbol *to = &he->branch_info->to; 464 if (he->branch_info) {
438 return _hist_entry__sym_snprintf(to->map, to->sym, to->addr, 465 struct addr_map_symbol *to = &he->branch_info->to;
439 he->level, bf, size, width);
440 466
467 return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
468 he->level, bf, size, width);
469 }
470
471 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
441} 472}
442 473
443struct sort_entry sort_dso_from = { 474struct sort_entry sort_dso_from = {
@@ -471,11 +502,13 @@ struct sort_entry sort_sym_to = {
471static int64_t 502static int64_t
472sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) 503sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right)
473{ 504{
474 const unsigned char mp = left->branch_info->flags.mispred != 505 unsigned char mp, p;
475 right->branch_info->flags.mispred; 506
476 const unsigned char p = left->branch_info->flags.predicted != 507 if (!left->branch_info || !right->branch_info)
477 right->branch_info->flags.predicted; 508 return cmp_null(left->branch_info, right->branch_info);
478 509
510 mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred;
511 p = left->branch_info->flags.predicted != right->branch_info->flags.predicted;
479 return mp || p; 512 return mp || p;
480} 513}
481 514
@@ -483,10 +516,12 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
483 size_t size, unsigned int width){ 516 size_t size, unsigned int width){
484 static const char *out = "N/A"; 517 static const char *out = "N/A";
485 518
486 if (he->branch_info->flags.predicted) 519 if (he->branch_info) {
487 out = "N"; 520 if (he->branch_info->flags.predicted)
488 else if (he->branch_info->flags.mispred) 521 out = "N";
489 out = "Y"; 522 else if (he->branch_info->flags.mispred)
523 out = "Y";
524 }
490 525
491 return repsep_snprintf(bf, size, "%-*.*s", width, width, out); 526 return repsep_snprintf(bf, size, "%-*.*s", width, width, out);
492} 527}
@@ -989,6 +1024,9 @@ struct sort_entry sort_mem_dcacheline = {
989static int64_t 1024static int64_t
990sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) 1025sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
991{ 1026{
1027 if (!left->branch_info || !right->branch_info)
1028 return cmp_null(left->branch_info, right->branch_info);
1029
992 return left->branch_info->flags.abort != 1030 return left->branch_info->flags.abort !=
993 right->branch_info->flags.abort; 1031 right->branch_info->flags.abort;
994} 1032}
@@ -996,10 +1034,15 @@ sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
996static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf, 1034static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf,
997 size_t size, unsigned int width) 1035 size_t size, unsigned int width)
998{ 1036{
999 static const char *out = "."; 1037 static const char *out = "N/A";
1038
1039 if (he->branch_info) {
1040 if (he->branch_info->flags.abort)
1041 out = "A";
1042 else
1043 out = ".";
1044 }
1000 1045
1001 if (he->branch_info->flags.abort)
1002 out = "A";
1003 return repsep_snprintf(bf, size, "%-*s", width, out); 1046 return repsep_snprintf(bf, size, "%-*s", width, out);
1004} 1047}
1005 1048
@@ -1013,6 +1056,9 @@ struct sort_entry sort_abort = {
1013static int64_t 1056static int64_t
1014sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right) 1057sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
1015{ 1058{
1059 if (!left->branch_info || !right->branch_info)
1060 return cmp_null(left->branch_info, right->branch_info);
1061
1016 return left->branch_info->flags.in_tx != 1062 return left->branch_info->flags.in_tx !=
1017 right->branch_info->flags.in_tx; 1063 right->branch_info->flags.in_tx;
1018} 1064}
@@ -1020,10 +1066,14 @@ sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
1020static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf, 1066static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf,
1021 size_t size, unsigned int width) 1067 size_t size, unsigned int width)
1022{ 1068{
1023 static const char *out = "."; 1069 static const char *out = "N/A";
1024 1070
1025 if (he->branch_info->flags.in_tx) 1071 if (he->branch_info) {
1026 out = "T"; 1072 if (he->branch_info->flags.in_tx)
1073 out = "T";
1074 else
1075 out = ".";
1076 }
1027 1077
1028 return repsep_snprintf(bf, size, "%-*s", width, out); 1078 return repsep_snprintf(bf, size, "%-*s", width, out);
1029} 1079}
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 2b7b2d91c016..c41411726c7a 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -117,6 +117,9 @@ int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,
117 if (!new) 117 if (!new)
118 return -ENOMEM; 118 return -ENOMEM;
119 list_add(&new->list, &thread->comm_list); 119 list_add(&new->list, &thread->comm_list);
120
121 if (exec)
122 unwind__flush_access(thread);
120 } 123 }
121 124
122 thread->comm_set = true; 125 thread->comm_set = true;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index e060386165c5..4d45c0dfe343 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -539,11 +539,23 @@ int unwind__prepare_access(struct thread *thread)
539 return -ENOMEM; 539 return -ENOMEM;
540 } 540 }
541 541
542 unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
542 thread__set_priv(thread, addr_space); 543 thread__set_priv(thread, addr_space);
543 544
544 return 0; 545 return 0;
545} 546}
546 547
548void unwind__flush_access(struct thread *thread)
549{
550 unw_addr_space_t addr_space;
551
552 if (callchain_param.record_mode != CALLCHAIN_DWARF)
553 return;
554
555 addr_space = thread__priv(thread);
556 unw_flush_cache(addr_space, 0, 0);
557}
558
547void unwind__finish_access(struct thread *thread) 559void unwind__finish_access(struct thread *thread)
548{ 560{
549 unw_addr_space_t addr_space; 561 unw_addr_space_t addr_space;
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index c17c4855bdbc..f50b737235eb 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -23,6 +23,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
23#ifdef HAVE_LIBUNWIND_SUPPORT 23#ifdef HAVE_LIBUNWIND_SUPPORT
24int libunwind__arch_reg_id(int regnum); 24int libunwind__arch_reg_id(int regnum);
25int unwind__prepare_access(struct thread *thread); 25int unwind__prepare_access(struct thread *thread);
26void unwind__flush_access(struct thread *thread);
26void unwind__finish_access(struct thread *thread); 27void unwind__finish_access(struct thread *thread);
27#else 28#else
28static inline int unwind__prepare_access(struct thread *thread __maybe_unused) 29static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
@@ -30,6 +31,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
30 return 0; 31 return 0;
31} 32}
32 33
34static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
33static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 35static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
34#endif 36#endif
35#else 37#else
@@ -49,6 +51,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
49 return 0; 51 return 0;
50} 52}
51 53
54static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
52static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 55static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
53#endif /* HAVE_DWARF_UNWIND_SUPPORT */ 56#endif /* HAVE_DWARF_UNWIND_SUPPORT */
54#endif /* __UNWIND_H */ 57#endif /* __UNWIND_H */
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index a8f81c782856..515247601df4 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -82,7 +82,7 @@ parse_opts() { # opts
82} 82}
83 83
84# Parameters 84# Parameters
85DEBUGFS_DIR=`grep debugfs /proc/mounts | cut -f2 -d' '` 85DEBUGFS_DIR=`grep debugfs /proc/mounts | cut -f2 -d' ' | head -1`
86TRACING_DIR=$DEBUGFS_DIR/tracing 86TRACING_DIR=$DEBUGFS_DIR/tracing
87TOP_DIR=`absdir $0` 87TOP_DIR=`absdir $0`
88TEST_DIR=$TOP_DIR/test.d 88TEST_DIR=$TOP_DIR/test.d