aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap2
-rw-r--r--Documentation/ABI/stable/sysfs-devices2
-rw-r--r--Documentation/PCI/pci.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt7
-rw-r--r--Documentation/devicetree/bindings/serial/8250.txt19
-rw-r--r--Documentation/filesystems/overlayfs.txt8
-rw-r--r--Documentation/networking/dsa/dsa.txt20
-rw-r--r--Documentation/powerpc/transactional_memory.txt2
-rw-r--r--Documentation/rapidio/mport_cdev.txt4
-rw-r--r--MAINTAINERS23
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/rk3066a.dtsi2
-rw-r--r--arch/arm/boot/dts/rk3288.dtsi2
-rw-r--r--arch/arm/boot/dts/rk3xxx.dtsi2
-rw-r--r--arch/arm/mach-pxa/idp.c3
-rw-r--r--arch/arm/mach-pxa/xcep.c3
-rw-r--r--arch/arm/mach-realview/core.c3
-rw-r--r--arch/arm/mach-sa1100/pleb.c2
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3368.dtsi2
-rw-r--r--arch/arm64/mm/proc.S9
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c3
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c3
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/configs/c8000_defconfig1
-rw-r--r--arch/parisc/configs/generic-64bit_defconfig1
-rw-r--r--arch/parisc/include/asm/uaccess.h22
-rw-r--r--arch/powerpc/include/asm/cputhreads.h1
-rw-r--r--arch/powerpc/include/asm/hmi.h2
-rw-r--r--arch/powerpc/include/asm/paca.h12
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h1
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/entry_64.S12
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S29
-rw-r--r--arch/powerpc/kernel/kprobes.c2
-rw-r--r--arch/powerpc/kernel/pci-common.c36
-rw-r--r--arch/powerpc/kernel/prom_init.c9
-rw-r--r--arch/powerpc/kernel/signal_32.c14
-rw-r--r--arch/powerpc/kernel/signal_64.c14
-rw-r--r--arch/powerpc/kernel/smp.c2
-rw-r--r--arch/powerpc/kernel/traps.c3
-rw-r--r--arch/powerpc/kvm/Makefile1
-rw-r--r--arch/powerpc/kvm/book3s_hv_hmi.c (renamed from arch/powerpc/kernel/hmi.c)0
-rw-r--r--arch/powerpc/mm/fault.c2
-rw-r--r--arch/powerpc/platforms/512x/mpc512x_lpbfifo.c1
-rw-r--r--arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c1
-rw-r--r--arch/powerpc/platforms/embedded6xx/holly.c2
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c2
-rw-r--r--arch/powerpc/platforms/powernv/opal-dump.c7
-rw-r--r--arch/powerpc/platforms/powernv/opal-elog.c7
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c2
-rw-r--r--arch/powerpc/platforms/pseries/pci.c4
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c7
-rw-r--r--arch/powerpc/sysdev/cpm1.c6
-rw-r--r--arch/powerpc/sysdev/cpm_common.c3
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c2
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/configs/default_defconfig1
-rw-r--r--arch/s390/configs/gcov_defconfig1
-rw-r--r--arch/s390/configs/performance_defconfig1
-rw-r--r--arch/s390/defconfig1
-rw-r--r--arch/s390/include/asm/uaccess.h19
-rw-r--r--arch/tile/Kconfig1
-rw-r--r--arch/tile/include/asm/uaccess.h22
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/configs/tiny.config2
-rw-r--r--arch/x86/include/asm/uaccess.h69
-rw-r--r--arch/x86/kernel/cpu/amd.c12
-rw-r--r--arch/x86/kernel/paravirt.c4
-rw-r--r--crypto/cryptd.c3
-rw-r--r--drivers/acpi/scan.c6
-rw-r--r--drivers/ata/libahci.c2
-rw-r--r--drivers/ata/pata_ninja32.c2
-rw-r--r--drivers/base/power/runtime.c10
-rw-r--r--drivers/char/hw_random/Kconfig2
-rw-r--r--drivers/char/tpm/tpm2-cmd.c3
-rw-r--r--drivers/clk/renesas/r8a7795-cpg-mssr.c9
-rw-r--r--drivers/clk/rockchip/clk-rk3399.c11
-rw-r--r--drivers/clk/sunxi-ng/ccu_common.c2
-rw-r--r--drivers/clk/tegra/clk-tegra114.c4
-rw-r--r--drivers/clocksource/timer-atmel-pit.c1
-rw-r--r--drivers/cpufreq/cpufreq-dt-platdev.c2
-rw-r--r--drivers/crypto/caam/caamalg.c77
-rw-r--r--drivers/crypto/qat/qat_common/qat_algs.c4
-rw-r--r--drivers/crypto/vmx/aes_xts.c2
-rw-r--r--drivers/dma/at_xdmac.c4
-rw-r--r--drivers/dma/fsl_raid.c1
-rw-r--r--drivers/dma/img-mdc-dma.c4
-rw-r--r--drivers/dma/pxa_dma.c11
-rw-r--r--drivers/dma/sh/usb-dmac.c19
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c5
-rw-r--r--drivers/gpu/drm/amd/amdgpu/cik_sdma.c3
-rw-r--r--drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c12
-rw-r--r--drivers/gpu/drm/imx/imx-drm-core.c26
-rw-r--r--drivers/gpu/drm/imx/ipuv3-crtc.c4
-rw-r--r--drivers/gpu/drm/imx/ipuv3-plane.c21
-rw-r--r--drivers/gpu/drm/msm/msm_drv.h6
-rw-r--r--drivers/gpu/drm/msm/msm_gem.c9
-rw-r--r--drivers/gpu/drm/msm/msm_gem_submit.c30
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_acpi.c11
-rw-r--r--drivers/gpu/drm/vc4/vc4_drv.c6
-rw-r--r--drivers/gpu/drm/vc4/vc4_drv.h9
-rw-r--r--drivers/gpu/drm/vc4/vc4_gem.c18
-rw-r--r--drivers/gpu/drm/vc4/vc4_irq.c4
-rw-r--r--drivers/hwmon/it87.c1
-rw-r--r--drivers/iio/accel/Kconfig5
-rw-r--r--drivers/iio/accel/bma220_spi.c2
-rw-r--r--drivers/iio/accel/kxsd9.c1
-rw-r--r--drivers/iio/adc/Kconfig1
-rw-r--r--drivers/iio/adc/ad799x.c1
-rw-r--r--drivers/iio/adc/at91_adc.c4
-rw-r--r--drivers/iio/adc/rockchip_saradc.c30
-rw-r--r--drivers/iio/adc/ti-ads1015.c3
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c16
-rw-r--r--drivers/iio/chemical/atlas-ph-sensor.c2
-rw-r--r--drivers/iio/dac/stx104.c38
-rw-r--r--drivers/iio/humidity/Kconfig2
-rw-r--r--drivers/iio/humidity/am2315.c2
-rw-r--r--drivers/iio/humidity/hdc100x.c27
-rw-r--r--drivers/iio/industrialio-buffer.c23
-rw-r--r--drivers/iio/light/Kconfig3
-rw-r--r--drivers/iio/pressure/bmp280-core.c8
-rw-r--r--drivers/iio/proximity/as3935.c2
-rw-r--r--drivers/macintosh/ams/ams-i2c.c1
-rw-r--r--drivers/macintosh/windfarm_pm112.c1
-rw-r--r--drivers/macintosh/windfarm_pm72.c1
-rw-r--r--drivers/macintosh/windfarm_rm31.c1
-rw-r--r--drivers/md/bitmap.c47
-rw-r--r--drivers/md/dm-bufio.c2
-rw-r--r--drivers/md/dm-crypt.c9
-rw-r--r--drivers/md/dm-log-writes.c10
-rw-r--r--drivers/md/md-cluster.c12
-rw-r--r--drivers/md/md.c28
-rw-r--r--drivers/md/raid10.c13
-rw-r--r--drivers/md/raid5.c64
-rw-r--r--drivers/misc/Kconfig10
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/bh1780gli.c259
-rw-r--r--drivers/misc/cxl/vphb.c10
-rw-r--r--drivers/misc/lkdtm_rodata.c2
-rw-r--r--drivers/misc/mei/hw-me.c10
-rw-r--r--drivers/misc/mei/pci-me.c4
-rw-r--r--drivers/net/dsa/bcm_sf2.h2
-rw-r--r--drivers/net/dsa/mv88e6xxx/chip.c8
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c2
-rw-r--r--drivers/net/ethernet/atheros/alx/reg.h1
-rw-r--r--drivers/net/ethernet/broadcom/bgmac-bcma.c2
-rw-r--r--drivers/net/ethernet/cavium/thunder/nic_reg.h1
-rw-r--r--drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c5
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c10
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c20
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h3
-rw-r--r--drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c3
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_client.c41
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c85
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h21
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_common.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c21
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c93
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c112
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rx.c41
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_stats.h4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tc.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_tx.c68
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c6
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.c16
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c26
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c11
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c59
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/port.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum.c43
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c2
-rw-r--r--drivers/net/ethernet/nxp/lpc_eth.c20
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed.h11
-rw-r--r--drivers/net/ethernet/qlogic/qede/qede_main.c5
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c2
-rw-r--r--drivers/net/ethernet/sfc/ef10.c3
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c7
-rw-r--r--drivers/net/ethernet/smsc/smc91x.h65
-rw-r--r--drivers/net/ethernet/synopsys/dwc_eth_qos.c17
-rw-r--r--drivers/net/ethernet/tehuti/tehuti.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c8
-rw-r--r--drivers/net/phy/micrel.c2
-rw-r--r--drivers/net/phy/phy.c6
-rw-r--r--drivers/net/team/team_mode_loadbalance.c15
-rw-r--r--drivers/net/tun.c6
-rw-r--r--drivers/net/usb/kaweth.c10
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c4
-rw-r--r--drivers/net/vmxnet3/vmxnet3_int.h4
-rw-r--r--drivers/nvme/host/Kconfig2
-rw-r--r--drivers/nvme/host/fabrics.c23
-rw-r--r--drivers/nvme/host/fabrics.h2
-rw-r--r--drivers/nvme/host/rdma.c46
-rw-r--r--drivers/nvme/target/Kconfig2
-rw-r--r--drivers/nvme/target/loop.c4
-rw-r--r--drivers/nvme/target/rdma.c7
-rw-r--r--drivers/pci/host-bridge.c1
-rw-r--r--drivers/pci/quirks.c7
-rw-r--r--drivers/perf/arm_pmu.c3
-rw-r--r--drivers/phy/phy-brcm-sata.c2
-rw-r--r--drivers/phy/phy-sun4i-usb.c68
-rw-r--r--drivers/phy/phy-sun9i-usb.c4
-rw-r--r--drivers/pinctrl/intel/pinctrl-cherryview.c5
-rw-r--r--drivers/pinctrl/pinctrl-pistachio.c12
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c4
-rw-r--r--drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c4
-rw-r--r--drivers/platform/olpc/olpc-ec.c8
-rw-r--r--drivers/platform/x86/intel_pmic_gpio.c8
-rw-r--r--drivers/rapidio/devices/tsi721.c2
-rw-r--r--drivers/regulator/max14577-regulator.c4
-rw-r--r--drivers/regulator/max77693-regulator.c4
-rw-r--r--drivers/regulator/qcom_smd-regulator.c30
-rw-r--r--drivers/scsi/wd719x.c2
-rw-r--r--drivers/spi/spi-img-spfi.c2
-rw-r--r--drivers/spi/spi-mt65xx.c1
-rw-r--r--drivers/spi/spi-pxa2xx-pci.c1
-rw-r--r--drivers/spi/spi-qup.c1
-rw-r--r--drivers/spi/spi-sh-msiof.c3
-rw-r--r--drivers/spi/spi.c10
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1760.c1
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c46
-rw-r--r--drivers/staging/comedi/drivers/daqboard2000.c2
-rw-r--r--drivers/staging/comedi/drivers/dt2811.c4
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c12
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c43
-rw-r--r--drivers/staging/wilc1000/host_interface.c3
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c2
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.c4
-rw-r--r--drivers/thunderbolt/nhi.c6
-rw-r--r--drivers/thunderbolt/switch.c4
-rw-r--r--drivers/tty/serial/8250/8250.h35
-rw-r--r--drivers/tty/serial/8250/8250_core.c9
-rw-r--r--drivers/tty/serial/8250/8250_fintek.c4
-rw-r--r--drivers/tty/serial/8250/8250_mid.c3
-rw-r--r--drivers/tty/serial/8250/8250_omap.c31
-rw-r--r--drivers/tty/serial/8250/8250_pci.c139
-rw-r--r--drivers/tty/serial/8250/8250_port.c7
-rw-r--r--drivers/tty/serial/8250/Kconfig1
-rw-r--r--drivers/usb/chipidea/udc.c7
-rw-r--r--drivers/usb/core/config.c2
-rw-r--r--drivers/usb/core/devio.c16
-rw-r--r--drivers/usb/dwc2/core.h1
-rw-r--r--drivers/usb/dwc2/platform.c22
-rw-r--r--drivers/usb/dwc3/core.c1
-rw-r--r--drivers/usb/dwc3/debug.h2
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c9
-rw-r--r--drivers/usb/dwc3/gadget.c11
-rw-r--r--drivers/usb/gadget/function/f_eem.c10
-rw-r--r--drivers/usb/gadget/function/f_rndis.c3
-rw-r--r--drivers/usb/gadget/function/u_serial.c7
-rw-r--r--drivers/usb/gadget/udc/core.c2
-rw-r--r--drivers/usb/gadget/udc/fsl_qe_udc.c7
-rw-r--r--drivers/usb/musb/musb_virthub.c7
-rw-r--r--drivers/usb/renesas_usbhs/mod_gadget.c2
-rw-r--r--drivers/usb/serial/mos7720.c2
-rw-r--r--drivers/usb/serial/mos7840.c4
-rw-r--r--drivers/usb/serial/option.c9
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/btrfs/extent-tree.c10
-rw-r--r--fs/btrfs/relocation.c8
-rw-r--r--fs/btrfs/send.c8
-rw-r--r--fs/devpts/inode.c3
-rw-r--r--fs/ext4/inode.c2
-rw-r--r--fs/ext4/super.c18
-rw-r--r--fs/ext4/xattr.c53
-rw-r--r--fs/ext4/xattr.h1
-rw-r--r--fs/iomap.c5
-rw-r--r--fs/kernfs/file.c28
-rw-r--r--fs/nfs/blocklayout/blocklayout.c2
-rw-r--r--fs/nfs/blocklayout/blocklayout.h3
-rw-r--r--fs/nfs/blocklayout/extent_tree.c10
-rw-r--r--fs/nfs/callback.c1
-rw-r--r--fs/nfs/callback_proc.c8
-rw-r--r--fs/nfs/client.c10
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c45
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.h2
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayoutdev.c23
-rw-r--r--fs/nfs/internal.h5
-rw-r--r--fs/nfs/nfs42proc.c34
-rw-r--r--fs/nfs/nfs4client.c5
-rw-r--r--fs/nfs/nfs4proc.c89
-rw-r--r--fs/nfs/nfs4session.c53
-rw-r--r--fs/nfs/nfs4session.h7
-rw-r--r--fs/nfs/pnfs.c2
-rw-r--r--fs/nfs/super.c19
-rw-r--r--fs/overlayfs/copy_up.c2
-rw-r--r--fs/overlayfs/dir.c58
-rw-r--r--fs/overlayfs/inode.c108
-rw-r--r--fs/overlayfs/overlayfs.h17
-rw-r--r--fs/overlayfs/readdir.c63
-rw-r--r--fs/overlayfs/super.c93
-rw-r--r--fs/proc/base.c7
-rw-r--r--fs/sysfs/file.c8
-rw-r--r--fs/xfs/libxfs/xfs_alloc.c2
-rw-r--r--fs/xfs/libxfs/xfs_btree.c14
-rw-r--r--fs/xfs/libxfs/xfs_defer.c17
-rw-r--r--fs/xfs/libxfs/xfs_defer.h2
-rw-r--r--fs/xfs/libxfs/xfs_format.h6
-rw-r--r--fs/xfs/libxfs/xfs_sb.c3
-rw-r--r--fs/xfs/xfs_buf.c2
-rw-r--r--fs/xfs/xfs_super.c9
-rw-r--r--fs/xfs/xfs_trace.h2
-rw-r--r--include/asm-generic/uaccess.h1
-rw-r--r--include/linux/acpi.h2
-rw-r--r--include/linux/compiler-gcc.h2
-rw-r--r--include/linux/fence.h2
-rw-r--r--include/linux/fs.h1
-rw-r--r--include/linux/iio/sw_trigger.h2
-rw-r--r--include/linux/iomap.h8
-rw-r--r--include/linux/mempolicy.h4
-rw-r--r--include/linux/mfd/da8xx-cfgchip.h153
-rw-r--r--include/linux/mfd/ti_am335x_tscadc.h8
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/mmzone.h16
-rw-r--r--include/linux/netfilter/nfnetlink_acct.h4
-rw-r--r--include/linux/nvme.h2
-rw-r--r--include/linux/pci.h9
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/linux/smc91x.h10
-rw-r--r--include/net/tcp.h2
-rw-r--r--include/uapi/linux/atm_zatm.h1
-rw-r--r--include/uapi/linux/if_pppol2tp.h3
-rw-r--r--include/uapi/linux/if_pppox.h3
-rw-r--r--include/uapi/linux/if_tunnel.h3
-rw-r--r--include/uapi/linux/ipx.h13
-rw-r--r--include/uapi/linux/libc-compat.h26
-rw-r--r--include/uapi/linux/openvswitch.h6
-rw-r--r--kernel/audit_watch.c8
-rw-r--r--kernel/configs/tiny.config8
-rw-r--r--kernel/cpuset.c15
-rw-r--r--kernel/exit.c7
-rw-r--r--kernel/fork.c37
-rw-r--r--kernel/kexec_file.c3
-rw-r--r--kernel/printk/nmi.c38
-rw-r--r--kernel/seccomp.c12
-rw-r--r--kernel/time/tick-sched.c3
-rw-r--r--lib/Kconfig.debug18
-rw-r--r--lib/Makefile1
-rw-r--r--lib/rhashtable.c7
-rw-r--r--lib/test_hash.c26
-rw-r--r--lib/usercopy.c9
-rw-r--r--mm/mempolicy.c17
-rw-r--r--mm/page_alloc.c55
-rw-r--r--mm/vmscan.c22
-rw-r--r--net/bluetooth/af_bluetooth.c2
-rw-r--r--net/bluetooth/hci_request.c2
-rw-r--r--net/bluetooth/hci_sock.c2
-rw-r--r--net/bluetooth/l2cap_core.c8
-rw-r--r--net/bluetooth/l2cap_sock.c14
-rw-r--r--net/ipv4/fib_trie.c4
-rw-r--r--net/ipv4/ip_tunnel_core.c8
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_diag.c7
-rw-r--r--net/ipv4/tcp_ipv4.c8
-rw-r--r--net/ipv4/udp.c13
-rw-r--r--net/ipv4/udplite.c1
-rw-r--r--net/ipv6/addrconf.c34
-rw-r--r--net/ipv6/tcp_ipv6.c8
-rw-r--r--net/ipv6/udp.c1
-rw-r--r--net/ipv6/udplite.c1
-rw-r--r--net/l2tp/l2tp_ppp.c2
-rw-r--r--net/netfilter/nf_conntrack_standalone.c4
-rw-r--r--net/netfilter/nfnetlink_acct.c17
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c16
-rw-r--r--net/netfilter/nfnetlink_log.c1
-rw-r--r--net/netfilter/xt_TPROXY.c4
-rw-r--r--net/netfilter/xt_nfacct.c2
-rw-r--r--net/sched/act_ife.c18
-rw-r--r--net/sched/sch_generic.c9
-rw-r--r--net/sctp/input.c11
-rw-r--r--net/sctp/inqueue.c13
-rw-r--r--net/sctp/sctp_diag.c6
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/tipc/udp_media.c5
-rwxr-xr-xscripts/checkpatch.pl9
-rwxr-xr-xscripts/package/builddeb4
-rwxr-xr-xscripts/tags.sh1
-rw-r--r--tools/iio/iio_generic_buffer.c2
384 files changed, 2992 insertions, 1840 deletions
diff --git a/.mailmap b/.mailmap
index 2a91c14c80bf..093a8ac9996e 100644
--- a/.mailmap
+++ b/.mailmap
@@ -158,6 +158,8 @@ Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
158Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com> 158Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com>
159Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com> 159Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com>
160Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com> 160Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com>
161Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com>
162Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
161Takashi YOSHII <takashi.yoshii.zj@renesas.com> 163Takashi YOSHII <takashi.yoshii.zj@renesas.com>
162Yusuke Goda <goda.yusuke@renesas.com> 164Yusuke Goda <goda.yusuke@renesas.com>
163Gustavo Padovan <gustavo@las.ic.unicamp.br> 165Gustavo Padovan <gustavo@las.ic.unicamp.br>
diff --git a/Documentation/ABI/stable/sysfs-devices b/Documentation/ABI/stable/sysfs-devices
index 43f78b88da28..df449d79b563 100644
--- a/Documentation/ABI/stable/sysfs-devices
+++ b/Documentation/ABI/stable/sysfs-devices
@@ -1,7 +1,7 @@
1# Note: This documents additional properties of any device beyond what 1# Note: This documents additional properties of any device beyond what
2# is documented in Documentation/sysfs-rules.txt 2# is documented in Documentation/sysfs-rules.txt
3 3
4What: /sys/devices/*/of_path 4What: /sys/devices/*/of_node
5Date: February 2015 5Date: February 2015
6Contact: Device Tree mailing list <devicetree@vger.kernel.org> 6Contact: Device Tree mailing list <devicetree@vger.kernel.org>
7Description: 7Description:
diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.txt
index 123881f62219..77f49dc5be23 100644
--- a/Documentation/PCI/pci.txt
+++ b/Documentation/PCI/pci.txt
@@ -124,7 +124,6 @@ initialization with a pointer to a structure describing the driver
124 124
125The ID table is an array of struct pci_device_id entries ending with an 125The ID table is an array of struct pci_device_id entries ending with an
126all-zero entry. Definitions with static const are generally preferred. 126all-zero entry. Definitions with static const are generally preferred.
127Use of the deprecated macro DEFINE_PCI_DEVICE_TABLE should be avoided.
128 127
129Each entry consists of: 128Each entry consists of:
130 129
diff --git a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
index bf99e2f24788..205593f56fe7 100644
--- a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
@@ -16,6 +16,11 @@ Required properties:
16- vref-supply: The regulator supply ADC reference voltage. 16- vref-supply: The regulator supply ADC reference voltage.
17- #io-channel-cells: Should be 1, see ../iio-bindings.txt 17- #io-channel-cells: Should be 1, see ../iio-bindings.txt
18 18
19Optional properties:
20- resets: Must contain an entry for each entry in reset-names if need support
21 this option. See ../reset/reset.txt for details.
22- reset-names: Must include the name "saradc-apb".
23
19Example: 24Example:
20 saradc: saradc@2006c000 { 25 saradc: saradc@2006c000 {
21 compatible = "rockchip,saradc"; 26 compatible = "rockchip,saradc";
@@ -23,6 +28,8 @@ Example:
23 interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; 28 interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
24 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; 29 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
25 clock-names = "saradc", "apb_pclk"; 30 clock-names = "saradc", "apb_pclk";
31 resets = <&cru SRST_SARADC>;
32 reset-names = "saradc-apb";
26 #io-channel-cells = <1>; 33 #io-channel-cells = <1>;
27 vref-supply = <&vcc18>; 34 vref-supply = <&vcc18>;
28 }; 35 };
diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt
index f5561ac7e17e..936ab5b87324 100644
--- a/Documentation/devicetree/bindings/serial/8250.txt
+++ b/Documentation/devicetree/bindings/serial/8250.txt
@@ -42,9 +42,6 @@ Optional properties:
42- auto-flow-control: one way to enable automatic flow control support. The 42- auto-flow-control: one way to enable automatic flow control support. The
43 driver is allowed to detect support for the capability even without this 43 driver is allowed to detect support for the capability even without this
44 property. 44 property.
45- {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD
46 line respectively. It will use specified GPIO instead of the peripheral
47 function pin for the UART feature. If unsure, don't specify this property.
48 45
49Note: 46Note:
50* fsl,ns16550: 47* fsl,ns16550:
@@ -66,19 +63,3 @@ Example:
66 interrupts = <10>; 63 interrupts = <10>;
67 reg-shift = <2>; 64 reg-shift = <2>;
68 }; 65 };
69
70Example for OMAP UART using GPIO-based modem control signals:
71
72 uart4: serial@49042000 {
73 compatible = "ti,omap3-uart";
74 reg = <0x49042000 0x400>;
75 interrupts = <80>;
76 ti,hwmods = "uart4";
77 clock-frequency = <48000000>;
78 cts-gpios = <&gpio3 5 GPIO_ACTIVE_LOW>;
79 rts-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;
80 dtr-gpios = <&gpio1 12 GPIO_ACTIVE_LOW>;
81 dsr-gpios = <&gpio1 13 GPIO_ACTIVE_LOW>;
82 dcd-gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
83 rng-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>;
84 };
diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt
index d6259c786316..bcbf9710e4af 100644
--- a/Documentation/filesystems/overlayfs.txt
+++ b/Documentation/filesystems/overlayfs.txt
@@ -183,12 +183,10 @@ The copy_up operation essentially creates a new, identical file and
183moves it over to the old name. The new file may be on a different 183moves it over to the old name. The new file may be on a different
184filesystem, so both st_dev and st_ino of the file may change. 184filesystem, so both st_dev and st_ino of the file may change.
185 185
186Any open files referring to this inode will access the old data and 186Any open files referring to this inode will access the old data.
187metadata. Similarly any file locks obtained before copy_up will not
188apply to the copied up file.
189 187
190On a file opened with O_RDONLY fchmod(2), fchown(2), futimesat(2) and 188Any file locks (and leases) obtained before copy_up will not apply
191fsetxattr(2) will fail with EROFS. 189to the copied up file.
192 190
193If a file with multiple hard links is copied up, then this will 191If a file with multiple hard links is copied up, then this will
194"break" the link. Changes will not be propagated to other names 192"break" the link. Changes will not be propagated to other names
diff --git a/Documentation/networking/dsa/dsa.txt b/Documentation/networking/dsa/dsa.txt
index 9d05ed7f7da5..f20c884c048a 100644
--- a/Documentation/networking/dsa/dsa.txt
+++ b/Documentation/networking/dsa/dsa.txt
@@ -587,26 +587,6 @@ of DSA, would be the its port-based VLAN, used by the associated bridge device.
587TODO 587TODO
588==== 588====
589 589
590The platform device problem
591---------------------------
592DSA is currently implemented as a platform device driver which is far from ideal
593as was discussed in this thread:
594
595http://permalink.gmane.org/gmane.linux.network/329848
596
597This basically prevents the device driver model to be properly used and applied,
598and support non-MDIO, non-MMIO Ethernet connected switches.
599
600Another problem with the platform device driver approach is that it prevents the
601use of a modular switch drivers build due to a circular dependency, illustrated
602here:
603
604http://comments.gmane.org/gmane.linux.network/345803
605
606Attempts of reworking this has been done here:
607
608https://lwn.net/Articles/643149/
609
610Making SWITCHDEV and DSA converge towards an unified codebase 590Making SWITCHDEV and DSA converge towards an unified codebase
611------------------------------------------------------------- 591-------------------------------------------------------------
612 592
diff --git a/Documentation/powerpc/transactional_memory.txt b/Documentation/powerpc/transactional_memory.txt
index ba0a2a4a54ba..e32fdbb4c9a7 100644
--- a/Documentation/powerpc/transactional_memory.txt
+++ b/Documentation/powerpc/transactional_memory.txt
@@ -167,6 +167,8 @@ signal will be rolled back anyway.
167For signals taken in non-TM or suspended mode, we use the 167For signals taken in non-TM or suspended mode, we use the
168normal/non-checkpointed stack pointer. 168normal/non-checkpointed stack pointer.
169 169
170Any transaction initiated inside a sighandler and suspended on return
171from the sighandler to the kernel will get reclaimed and discarded.
170 172
171Failure cause codes used by kernel 173Failure cause codes used by kernel
172================================== 174==================================
diff --git a/Documentation/rapidio/mport_cdev.txt b/Documentation/rapidio/mport_cdev.txt
index 6e491a662461..a53f786ee2e9 100644
--- a/Documentation/rapidio/mport_cdev.txt
+++ b/Documentation/rapidio/mport_cdev.txt
@@ -80,6 +80,10 @@ functionality of their platform when planning to use this driver:
80 80
81III. Module parameters 81III. Module parameters
82 82
83- 'dma_timeout' - DMA transfer completion timeout (in msec, default value 3000).
84 This parameter set a maximum completion wait time for SYNC mode DMA
85 transfer requests and for RIO_WAIT_FOR_ASYNC ioctl requests.
86
83- 'dbg_level' - This parameter allows to control amount of debug information 87- 'dbg_level' - This parameter allows to control amount of debug information
84 generated by this device driver. This parameter is formed by set of 88 generated by this device driver. This parameter is formed by set of
85 bit masks that correspond to the specific functional blocks. 89 bit masks that correspond to the specific functional blocks.
diff --git a/MAINTAINERS b/MAINTAINERS
index 71aa5daeae8f..1fbd77d2de77 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -798,6 +798,7 @@ M: Laura Abbott <labbott@redhat.com>
798M: Sumit Semwal <sumit.semwal@linaro.org> 798M: Sumit Semwal <sumit.semwal@linaro.org>
799L: devel@driverdev.osuosl.org 799L: devel@driverdev.osuosl.org
800S: Supported 800S: Supported
801F: Documentation/devicetree/bindings/staging/ion/
801F: drivers/staging/android/ion 802F: drivers/staging/android/ion
802F: drivers/staging/android/uapi/ion.h 803F: drivers/staging/android/uapi/ion.h
803F: drivers/staging/android/uapi/ion_test.h 804F: drivers/staging/android/uapi/ion_test.h
@@ -1643,7 +1644,6 @@ F: drivers/*/*s3c64xx*
1643F: drivers/*/*s5pv210* 1644F: drivers/*/*s5pv210*
1644F: drivers/memory/samsung/* 1645F: drivers/memory/samsung/*
1645F: drivers/soc/samsung/* 1646F: drivers/soc/samsung/*
1646F: drivers/spi/spi-s3c*
1647F: Documentation/arm/Samsung/ 1647F: Documentation/arm/Samsung/
1648F: Documentation/devicetree/bindings/arm/samsung/ 1648F: Documentation/devicetree/bindings/arm/samsung/
1649F: Documentation/devicetree/bindings/sram/samsung-sram.txt 1649F: Documentation/devicetree/bindings/sram/samsung-sram.txt
@@ -3247,7 +3247,7 @@ F: kernel/cpuset.c
3247CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG) 3247CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)
3248M: Johannes Weiner <hannes@cmpxchg.org> 3248M: Johannes Weiner <hannes@cmpxchg.org>
3249M: Michal Hocko <mhocko@kernel.org> 3249M: Michal Hocko <mhocko@kernel.org>
3250M: Vladimir Davydov <vdavydov@virtuozzo.com> 3250M: Vladimir Davydov <vdavydov.dev@gmail.com>
3251L: cgroups@vger.kernel.org 3251L: cgroups@vger.kernel.org
3252L: linux-mm@kvack.org 3252L: linux-mm@kvack.org
3253S: Maintained 3253S: Maintained
@@ -10253,6 +10253,17 @@ S: Supported
10253L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers) 10253L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
10254F: drivers/clk/samsung/ 10254F: drivers/clk/samsung/
10255 10255
10256SAMSUNG SPI DRIVERS
10257M: Kukjin Kim <kgene@kernel.org>
10258M: Krzysztof Kozlowski <krzk@kernel.org>
10259M: Andi Shyti <andi.shyti@samsung.com>
10260L: linux-spi@vger.kernel.org
10261L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
10262S: Maintained
10263F: Documentation/devicetree/bindings/spi/spi-samsung.txt
10264F: drivers/spi/spi-s3c*
10265F: include/linux/platform_data/spi-s3c64xx.h
10266
10256SAMSUNG SXGBE DRIVERS 10267SAMSUNG SXGBE DRIVERS
10257M: Byungho An <bh74.an@samsung.com> 10268M: Byungho An <bh74.an@samsung.com>
10258M: Girish K S <ks.giri@samsung.com> 10269M: Girish K S <ks.giri@samsung.com>
@@ -11232,12 +11243,8 @@ S: Odd Fixes
11232F: drivers/staging/vt665?/ 11243F: drivers/staging/vt665?/
11233 11244
11234STAGING - WILC1000 WIFI DRIVER 11245STAGING - WILC1000 WIFI DRIVER
11235M: Johnny Kim <johnny.kim@atmel.com> 11246M: Aditya Shankar <aditya.shankar@microchip.com>
11236M: Austin Shin <austin.shin@atmel.com> 11247M: Ganesh Krishna <ganesh.krishna@microchip.com>
11237M: Chris Park <chris.park@atmel.com>
11238M: Tony Cho <tony.cho@atmel.com>
11239M: Glen Lee <glen.lee@atmel.com>
11240M: Leo Kim <leo.kim@atmel.com>
11241L: linux-wireless@vger.kernel.org 11248L: linux-wireless@vger.kernel.org
11242S: Supported 11249S: Supported
11243F: drivers/staging/wilc1000/ 11250F: drivers/staging/wilc1000/
diff --git a/Makefile b/Makefile
index 67f42d57e6e7..a4e6cc531f81 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 8 2PATCHLEVEL = 8
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc5
5NAME = Psychotic Stoned Sheep 5NAME = Psychotic Stoned Sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/rk3066a.dtsi b/arch/arm/boot/dts/rk3066a.dtsi
index c0ba86c3a2ab..0d0dae3a1694 100644
--- a/arch/arm/boot/dts/rk3066a.dtsi
+++ b/arch/arm/boot/dts/rk3066a.dtsi
@@ -197,6 +197,8 @@
197 clock-names = "saradc", "apb_pclk"; 197 clock-names = "saradc", "apb_pclk";
198 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; 198 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
199 #io-channel-cells = <1>; 199 #io-channel-cells = <1>;
200 resets = <&cru SRST_SARADC>;
201 reset-names = "saradc-apb";
200 status = "disabled"; 202 status = "disabled";
201 }; 203 };
202 204
diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index cd33f0170890..91c4b3c7a8d5 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -279,6 +279,8 @@
279 #io-channel-cells = <1>; 279 #io-channel-cells = <1>;
280 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; 280 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
281 clock-names = "saradc", "apb_pclk"; 281 clock-names = "saradc", "apb_pclk";
282 resets = <&cru SRST_SARADC>;
283 reset-names = "saradc-apb";
282 status = "disabled"; 284 status = "disabled";
283 }; 285 };
284 286
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi
index 99bbcc2c9b89..e2cd683b4e4b 100644
--- a/arch/arm/boot/dts/rk3xxx.dtsi
+++ b/arch/arm/boot/dts/rk3xxx.dtsi
@@ -399,6 +399,8 @@
399 #io-channel-cells = <1>; 399 #io-channel-cells = <1>;
400 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; 400 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
401 clock-names = "saradc", "apb_pclk"; 401 clock-names = "saradc", "apb_pclk";
402 resets = <&cru SRST_SARADC>;
403 reset-names = "saradc-apb";
402 status = "disabled"; 404 status = "disabled";
403 }; 405 };
404 406
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c
index c410d84b243d..66070acaa888 100644
--- a/arch/arm/mach-pxa/idp.c
+++ b/arch/arm/mach-pxa/idp.c
@@ -83,7 +83,8 @@ static struct resource smc91x_resources[] = {
83}; 83};
84 84
85static struct smc91x_platdata smc91x_platdata = { 85static struct smc91x_platdata smc91x_platdata = {
86 .flags = SMC91X_USE_32BIT | SMC91X_USE_DMA | SMC91X_NOWAIT, 86 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
87 SMC91X_USE_DMA | SMC91X_NOWAIT,
87}; 88};
88 89
89static struct platform_device smc91x_device = { 90static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c
index 3f06cd90567a..056369ef250e 100644
--- a/arch/arm/mach-pxa/xcep.c
+++ b/arch/arm/mach-pxa/xcep.c
@@ -120,7 +120,8 @@ static struct resource smc91x_resources[] = {
120}; 120};
121 121
122static struct smc91x_platdata xcep_smc91x_info = { 122static struct smc91x_platdata xcep_smc91x_info = {
123 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT | SMC91X_USE_DMA, 123 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
124 SMC91X_NOWAIT | SMC91X_USE_DMA,
124}; 125};
125 126
126static struct platform_device smc91x_device = { 127static struct platform_device smc91x_device = {
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index baf174542e36..a0ead0ae23d6 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -93,7 +93,8 @@ static struct smsc911x_platform_config smsc911x_config = {
93}; 93};
94 94
95static struct smc91x_platdata smc91x_platdata = { 95static struct smc91x_platdata smc91x_platdata = {
96 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 96 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
97 SMC91X_NOWAIT,
97}; 98};
98 99
99static struct platform_device realview_eth_device = { 100static struct platform_device realview_eth_device = {
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
index 1525d7b5f1b7..88149f85bc49 100644
--- a/arch/arm/mach-sa1100/pleb.c
+++ b/arch/arm/mach-sa1100/pleb.c
@@ -45,7 +45,7 @@ static struct resource smc91x_resources[] = {
45}; 45};
46 46
47static struct smc91x_platdata smc91x_platdata = { 47static struct smc91x_platdata smc91x_platdata = {
48 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, 48 .flags = SMC91X_USE_16BIT | SMC91X_USE_8BIT | SMC91X_NOWAIT,
49}; 49};
50 50
51static struct platform_device smc91x_device = { 51static struct platform_device smc91x_device = {
diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index d02a900378e1..4f44d1191bfd 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -270,6 +270,8 @@
270 #io-channel-cells = <1>; 270 #io-channel-cells = <1>;
271 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>; 271 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
272 clock-names = "saradc", "apb_pclk"; 272 clock-names = "saradc", "apb_pclk";
273 resets = <&cru SRST_SARADC>;
274 reset-names = "saradc-apb";
273 status = "disabled"; 275 status = "disabled";
274 }; 276 };
275 277
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 5bb61de23201..9d37e967fa19 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -100,7 +100,16 @@ ENTRY(cpu_do_resume)
100 100
101 msr tcr_el1, x8 101 msr tcr_el1, x8
102 msr vbar_el1, x9 102 msr vbar_el1, x9
103
104 /*
105 * __cpu_setup() cleared MDSCR_EL1.MDE and friends, before unmasking
106 * debug exceptions. By restoring MDSCR_EL1 here, we may take a debug
107 * exception. Mask them until local_dbg_restore() in cpu_suspend()
108 * resets them.
109 */
110 disable_dbg
103 msr mdscr_el1, x10 111 msr mdscr_el1, x10
112
104 msr sctlr_el1, x12 113 msr sctlr_el1, x12
105 /* 114 /*
106 * Restore oslsr_el1 by writing oslar_el1 115 * Restore oslsr_el1 by writing oslar_el1
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
index c6db52ba3a06..10c57771822d 100644
--- a/arch/blackfin/mach-bf561/boards/cm_bf561.c
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -146,7 +146,8 @@ static struct platform_device hitachi_fb_device = {
146#include <linux/smc91x.h> 146#include <linux/smc91x.h>
147 147
148static struct smc91x_platdata smc91x_info = { 148static struct smc91x_platdata smc91x_info = {
149 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 149 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
150 SMC91X_NOWAIT,
150 .leda = RPC_LED_100_10, 151 .leda = RPC_LED_100_10,
151 .ledb = RPC_LED_TX_RX, 152 .ledb = RPC_LED_TX_RX,
152}; 153};
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index f35525b55819..57d1c43726d9 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -134,7 +134,8 @@ static struct platform_device net2272_bfin_device = {
134#include <linux/smc91x.h> 134#include <linux/smc91x.h>
135 135
136static struct smc91x_platdata smc91x_info = { 136static struct smc91x_platdata smc91x_info = {
137 .flags = SMC91X_USE_32BIT | SMC91X_NOWAIT, 137 .flags = SMC91X_USE_8BIT | SMC91X_USE_16BIT | SMC91X_USE_32BIT |
138 SMC91X_NOWAIT,
138 .leda = RPC_LED_100_10, 139 .leda = RPC_LED_100_10,
139 .ledb = RPC_LED_TX_RX, 140 .ledb = RPC_LED_TX_RX,
140}; 141};
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index cd8778103165..af12c2db9bb8 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -1,6 +1,5 @@
1config PARISC 1config PARISC
2 def_bool y 2 def_bool y
3 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
4 select ARCH_MIGHT_HAVE_PC_PARPORT 3 select ARCH_MIGHT_HAVE_PC_PARPORT
5 select HAVE_IDE 4 select HAVE_IDE
6 select HAVE_OPROFILE 5 select HAVE_OPROFILE
diff --git a/arch/parisc/configs/c8000_defconfig b/arch/parisc/configs/c8000_defconfig
index 1a8f6f95689e..f6a4c016304b 100644
--- a/arch/parisc/configs/c8000_defconfig
+++ b/arch/parisc/configs/c8000_defconfig
@@ -245,7 +245,6 @@ CONFIG_DEBUG_RT_MUTEXES=y
245CONFIG_PROVE_RCU_DELAY=y 245CONFIG_PROVE_RCU_DELAY=y
246CONFIG_DEBUG_BLOCK_EXT_DEVT=y 246CONFIG_DEBUG_BLOCK_EXT_DEVT=y
247CONFIG_LATENCYTOP=y 247CONFIG_LATENCYTOP=y
248CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
249CONFIG_KEYS=y 248CONFIG_KEYS=y
250# CONFIG_CRYPTO_HW is not set 249# CONFIG_CRYPTO_HW is not set
251CONFIG_FONTS=y 250CONFIG_FONTS=y
diff --git a/arch/parisc/configs/generic-64bit_defconfig b/arch/parisc/configs/generic-64bit_defconfig
index 7e0792658952..c564e6e1fa23 100644
--- a/arch/parisc/configs/generic-64bit_defconfig
+++ b/arch/parisc/configs/generic-64bit_defconfig
@@ -291,7 +291,6 @@ CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y
291CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y 291CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y
292# CONFIG_SCHED_DEBUG is not set 292# CONFIG_SCHED_DEBUG is not set
293CONFIG_TIMER_STATS=y 293CONFIG_TIMER_STATS=y
294CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
295CONFIG_CRYPTO_MANAGER=y 294CONFIG_CRYPTO_MANAGER=y
296CONFIG_CRYPTO_ECB=m 295CONFIG_CRYPTO_ECB=m
297CONFIG_CRYPTO_PCBC=m 296CONFIG_CRYPTO_PCBC=m
diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
index 0f59fd9ca205..e9150487e20d 100644
--- a/arch/parisc/include/asm/uaccess.h
+++ b/arch/parisc/include/asm/uaccess.h
@@ -208,13 +208,13 @@ unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned lo
208#define __copy_to_user_inatomic __copy_to_user 208#define __copy_to_user_inatomic __copy_to_user
209#define __copy_from_user_inatomic __copy_from_user 209#define __copy_from_user_inatomic __copy_from_user
210 210
211extern void copy_from_user_overflow(void) 211extern void __compiletime_error("usercopy buffer size is too small")
212#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 212__bad_copy_user(void);
213 __compiletime_error("copy_from_user() buffer size is not provably correct") 213
214#else 214static inline void copy_user_overflow(int size, unsigned long count)
215 __compiletime_warning("copy_from_user() buffer size is not provably correct") 215{
216#endif 216 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
217; 217}
218 218
219static inline unsigned long __must_check copy_from_user(void *to, 219static inline unsigned long __must_check copy_from_user(void *to,
220 const void __user *from, 220 const void __user *from,
@@ -223,10 +223,12 @@ static inline unsigned long __must_check copy_from_user(void *to,
223 int sz = __compiletime_object_size(to); 223 int sz = __compiletime_object_size(to);
224 int ret = -EFAULT; 224 int ret = -EFAULT;
225 225
226 if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) 226 if (likely(sz == -1 || sz >= n))
227 ret = __copy_from_user(to, from, n); 227 ret = __copy_from_user(to, from, n);
228 else 228 else if (!__builtin_constant_p(n))
229 copy_from_user_overflow(); 229 copy_user_overflow(sz, n);
230 else
231 __bad_copy_user();
230 232
231 return ret; 233 return ret;
232} 234}
diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index 666bef4ebfae..9377bdf42eb8 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -3,6 +3,7 @@
3 3
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5#include <linux/cpumask.h> 5#include <linux/cpumask.h>
6#include <asm/cpu_has_feature.h>
6 7
7/* 8/*
8 * Mapping of threads to cores 9 * Mapping of threads to cores
diff --git a/arch/powerpc/include/asm/hmi.h b/arch/powerpc/include/asm/hmi.h
index 88b4901ac4ee..85b7a1a21e22 100644
--- a/arch/powerpc/include/asm/hmi.h
+++ b/arch/powerpc/include/asm/hmi.h
@@ -21,7 +21,7 @@
21#ifndef __ASM_PPC64_HMI_H__ 21#ifndef __ASM_PPC64_HMI_H__
22#define __ASM_PPC64_HMI_H__ 22#define __ASM_PPC64_HMI_H__
23 23
24#ifdef CONFIG_PPC_BOOK3S_64 24#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
25 25
26#define CORE_TB_RESYNC_REQ_BIT 63 26#define CORE_TB_RESYNC_REQ_BIT 63
27#define MAX_SUBCORE_PER_CORE 4 27#define MAX_SUBCORE_PER_CORE 4
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 148303e7771f..6a6792bb39fb 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -183,11 +183,6 @@ struct paca_struct {
183 */ 183 */
184 u16 in_mce; 184 u16 in_mce;
185 u8 hmi_event_available; /* HMI event is available */ 185 u8 hmi_event_available; /* HMI event is available */
186 /*
187 * Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for
188 * more details
189 */
190 struct sibling_subcore_state *sibling_subcore_state;
191#endif 186#endif
192 187
193 /* Stuff for accurate time accounting */ 188 /* Stuff for accurate time accounting */
@@ -202,6 +197,13 @@ struct paca_struct {
202 struct kvmppc_book3s_shadow_vcpu shadow_vcpu; 197 struct kvmppc_book3s_shadow_vcpu shadow_vcpu;
203#endif 198#endif
204 struct kvmppc_host_state kvm_hstate; 199 struct kvmppc_host_state kvm_hstate;
200#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
201 /*
202 * Bitmap for sibling subcore status. See kvm/book3s_hv_ras.c for
203 * more details
204 */
205 struct sibling_subcore_state *sibling_subcore_state;
206#endif
205#endif 207#endif
206}; 208};
207 209
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index b5e88e4a171a..c0309c59bed8 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -301,6 +301,7 @@ extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
301/* Allocate & free a PCI host bridge structure */ 301/* Allocate & free a PCI host bridge structure */
302extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev); 302extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
303extern void pcibios_free_controller(struct pci_controller *phb); 303extern void pcibios_free_controller(struct pci_controller *phb);
304extern void pcibios_free_controller_deferred(struct pci_host_bridge *bridge);
304 305
305#ifdef CONFIG_PCI 306#ifdef CONFIG_PCI
306extern int pcibios_vaddr_is_ioport(void __iomem *address); 307extern int pcibios_vaddr_is_ioport(void __iomem *address);
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index b2027a5cf508..fe4c075bcf50 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_VDSO32) += vdso32/
41obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 41obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
42obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o 42obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o
43obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o 43obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_power.o
44obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o hmi.o 44obj-$(CONFIG_PPC_BOOK3S_64) += mce.o mce_power.o
45obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o 45obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o idle_book3e.o
46obj-$(CONFIG_PPC64) += vdso64/ 46obj-$(CONFIG_PPC64) += vdso64/
47obj-$(CONFIG_ALTIVEC) += vecemu.o 47obj-$(CONFIG_ALTIVEC) += vecemu.o
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 6b8bc0dd09d4..5afd03e5e8b8 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -368,13 +368,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
368tabort_syscall: 368tabort_syscall:
369 /* Firstly we need to enable TM in the kernel */ 369 /* Firstly we need to enable TM in the kernel */
370 mfmsr r10 370 mfmsr r10
371 li r13, 1 371 li r9, 1
372 rldimi r10, r13, MSR_TM_LG, 63-MSR_TM_LG 372 rldimi r10, r9, MSR_TM_LG, 63-MSR_TM_LG
373 mtmsrd r10, 0 373 mtmsrd r10, 0
374 374
375 /* tabort, this dooms the transaction, nothing else */ 375 /* tabort, this dooms the transaction, nothing else */
376 li r13, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT) 376 li r9, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT)
377 TABORT(R13) 377 TABORT(R9)
378 378
379 /* 379 /*
380 * Return directly to userspace. We have corrupted user register state, 380 * Return directly to userspace. We have corrupted user register state,
@@ -382,8 +382,8 @@ tabort_syscall:
382 * resume after the tbegin of the aborted transaction with the 382 * resume after the tbegin of the aborted transaction with the
383 * checkpointed register state. 383 * checkpointed register state.
384 */ 384 */
385 li r13, MSR_RI 385 li r9, MSR_RI
386 andc r10, r10, r13 386 andc r10, r10, r9
387 mtmsrd r10, 1 387 mtmsrd r10, 1
388 mtspr SPRN_SRR0, r11 388 mtspr SPRN_SRR0, r11
389 mtspr SPRN_SRR1, r12 389 mtspr SPRN_SRR1, r12
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index df6d45eb4115..bffec73dbffc 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -485,7 +485,23 @@ machine_check_fwnmi:
485 EXCEPTION_PROLOG_0(PACA_EXMC) 485 EXCEPTION_PROLOG_0(PACA_EXMC)
486machine_check_pSeries_0: 486machine_check_pSeries_0:
487 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200) 487 EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST, 0x200)
488 EXCEPTION_PROLOG_PSERIES_1(machine_check_common, EXC_STD) 488 /*
489 * The following is essentially EXCEPTION_PROLOG_PSERIES_1 with the
490 * difference that MSR_RI is not enabled, because PACA_EXMC is being
491 * used, so nested machine check corrupts it. machine_check_common
492 * enables MSR_RI.
493 */
494 ld r12,PACAKBASE(r13)
495 ld r10,PACAKMSR(r13)
496 xori r10,r10,MSR_RI
497 mfspr r11,SPRN_SRR0
498 LOAD_HANDLER(r12, machine_check_common)
499 mtspr SPRN_SRR0,r12
500 mfspr r12,SPRN_SRR1
501 mtspr SPRN_SRR1,r10
502 rfid
503 b . /* prevent speculative execution */
504
489 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200) 505 KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
490 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300) 506 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
491 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380) 507 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
@@ -969,14 +985,17 @@ ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
969machine_check_common: 985machine_check_common:
970 986
971 mfspr r10,SPRN_DAR 987 mfspr r10,SPRN_DAR
972 std r10,PACA_EXGEN+EX_DAR(r13) 988 std r10,PACA_EXMC+EX_DAR(r13)
973 mfspr r10,SPRN_DSISR 989 mfspr r10,SPRN_DSISR
974 stw r10,PACA_EXGEN+EX_DSISR(r13) 990 stw r10,PACA_EXMC+EX_DSISR(r13)
975 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC) 991 EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
976 FINISH_NAP 992 FINISH_NAP
977 RECONCILE_IRQ_STATE(r10, r11) 993 RECONCILE_IRQ_STATE(r10, r11)
978 ld r3,PACA_EXGEN+EX_DAR(r13) 994 ld r3,PACA_EXMC+EX_DAR(r13)
979 lwz r4,PACA_EXGEN+EX_DSISR(r13) 995 lwz r4,PACA_EXMC+EX_DSISR(r13)
996 /* Enable MSR_RI when finished with PACA_EXMC */
997 li r10,MSR_RI
998 mtmsrd r10,1
980 std r3,_DAR(r1) 999 std r3,_DAR(r1)
981 std r4,_DSISR(r1) 1000 std r4,_DSISR(r1)
982 bl save_nvgprs 1001 bl save_nvgprs
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 3ed8ec09b5c9..e785cc9e1ecd 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -29,7 +29,7 @@
29#include <linux/kprobes.h> 29#include <linux/kprobes.h>
30#include <linux/ptrace.h> 30#include <linux/ptrace.h>
31#include <linux/preempt.h> 31#include <linux/preempt.h>
32#include <linux/module.h> 32#include <linux/extable.h>
33#include <linux/kdebug.h> 33#include <linux/kdebug.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <asm/code-patching.h> 35#include <asm/code-patching.h>
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 7fdf324d5b51..e58908066b0e 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -154,6 +154,42 @@ void pcibios_free_controller(struct pci_controller *phb)
154EXPORT_SYMBOL_GPL(pcibios_free_controller); 154EXPORT_SYMBOL_GPL(pcibios_free_controller);
155 155
156/* 156/*
157 * This function is used to call pcibios_free_controller()
158 * in a deferred manner: a callback from the PCI subsystem.
159 *
160 * _*DO NOT*_ call pcibios_free_controller() explicitly if
161 * this is used (or it may access an invalid *phb pointer).
162 *
163 * The callback occurs when all references to the root bus
164 * are dropped (e.g., child buses/devices and their users).
165 *
166 * It's called as .release_fn() of 'struct pci_host_bridge'
167 * which is associated with the 'struct pci_controller.bus'
168 * (root bus) - it expects .release_data to hold a pointer
169 * to 'struct pci_controller'.
170 *
171 * In order to use it, register .release_fn()/release_data
172 * like this:
173 *
174 * pci_set_host_bridge_release(bridge,
175 * pcibios_free_controller_deferred
176 * (void *) phb);
177 *
178 * e.g. in the pcibios_root_bridge_prepare() callback from
179 * pci_create_root_bus().
180 */
181void pcibios_free_controller_deferred(struct pci_host_bridge *bridge)
182{
183 struct pci_controller *phb = (struct pci_controller *)
184 bridge->release_data;
185
186 pr_debug("domain %d, dynamic %d\n", phb->global_number, phb->is_dynamic);
187
188 pcibios_free_controller(phb);
189}
190EXPORT_SYMBOL_GPL(pcibios_free_controller_deferred);
191
192/*
157 * The function is used to return the minimal alignment 193 * The function is used to return the minimal alignment
158 * for memory or I/O windows of the associated P2P bridge. 194 * for memory or I/O windows of the associated P2P bridge.
159 * By default, 4KiB alignment for I/O windows and 1MiB for 195 * By default, 4KiB alignment for I/O windows and 1MiB for
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4e74fc588a3f..d3eff99e938c 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -695,7 +695,7 @@ unsigned char ibm_architecture_vec[] = {
695 OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */ 695 OV4_MIN_ENT_CAP, /* minimum VP entitled capacity */
696 696
697 /* option vector 5: PAPR/OF options */ 697 /* option vector 5: PAPR/OF options */
698 VECTOR_LENGTH(18), /* length */ 698 VECTOR_LENGTH(21), /* length */
699 0, /* don't ignore, don't halt */ 699 0, /* don't ignore, don't halt */
700 OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) | 700 OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) |
701 OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) | 701 OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) |
@@ -726,8 +726,11 @@ unsigned char ibm_architecture_vec[] = {
726 0, 726 0,
727 0, 727 0,
728 OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) | 728 OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) |
729 OV5_FEAT(OV5_PFO_HW_842), 729 OV5_FEAT(OV5_PFO_HW_842), /* Byte 17 */
730 OV5_FEAT(OV5_SUB_PROCESSORS), 730 0, /* Byte 18 */
731 0, /* Byte 19 */
732 0, /* Byte 20 */
733 OV5_FEAT(OV5_SUB_PROCESSORS), /* Byte 21 */
731 734
732 /* option vector 6: IBM PAPR hints */ 735 /* option vector 6: IBM PAPR hints */
733 VECTOR_LENGTH(3), /* length */ 736 VECTOR_LENGTH(3), /* length */
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index b6aa378aff63..a7daf749b97f 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -1226,7 +1226,21 @@ long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
1226 (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16); 1226 (regs->gpr[1] + __SIGNAL_FRAMESIZE + 16);
1227 if (!access_ok(VERIFY_READ, rt_sf, sizeof(*rt_sf))) 1227 if (!access_ok(VERIFY_READ, rt_sf, sizeof(*rt_sf)))
1228 goto bad; 1228 goto bad;
1229
1229#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1230#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1231 /*
1232 * If there is a transactional state then throw it away.
1233 * The purpose of a sigreturn is to destroy all traces of the
1234 * signal frame, this includes any transactional state created
1235 * within in. We only check for suspended as we can never be
1236 * active in the kernel, we are active, there is nothing better to
1237 * do than go ahead and Bad Thing later.
1238 * The cause is not important as there will never be a
1239 * recheckpoint so it's not user visible.
1240 */
1241 if (MSR_TM_SUSPENDED(mfmsr()))
1242 tm_reclaim_current(0);
1243
1230 if (__get_user(tmp, &rt_sf->uc.uc_link)) 1244 if (__get_user(tmp, &rt_sf->uc.uc_link))
1231 goto bad; 1245 goto bad;
1232 uc_transact = (struct ucontext __user *)(uintptr_t)tmp; 1246 uc_transact = (struct ucontext __user *)(uintptr_t)tmp;
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 7e49984d4331..70409bb90a95 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -676,7 +676,21 @@ int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
676 if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) 676 if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
677 goto badframe; 677 goto badframe;
678 set_current_blocked(&set); 678 set_current_blocked(&set);
679
679#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 680#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
681 /*
682 * If there is a transactional state then throw it away.
683 * The purpose of a sigreturn is to destroy all traces of the
684 * signal frame, this includes any transactional state created
685 * within in. We only check for suspended as we can never be
686 * active in the kernel, we are active, there is nothing better to
687 * do than go ahead and Bad Thing later.
688 * The cause is not important as there will never be a
689 * recheckpoint so it's not user visible.
690 */
691 if (MSR_TM_SUSPENDED(mfmsr()))
692 tm_reclaim_current(0);
693
680 if (__get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR])) 694 if (__get_user(msr, &uc->uc_mcontext.gp_regs[PT_MSR]))
681 goto badframe; 695 goto badframe;
682 if (MSR_TM_ACTIVE(msr)) { 696 if (MSR_TM_ACTIVE(msr)) {
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 25a39052bf6b..9c6f3fd58059 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -830,7 +830,7 @@ int __cpu_disable(void)
830 830
831 /* Update sibling maps */ 831 /* Update sibling maps */
832 base = cpu_first_thread_sibling(cpu); 832 base = cpu_first_thread_sibling(cpu);
833 for (i = 0; i < threads_per_core; i++) { 833 for (i = 0; i < threads_per_core && base + i < nr_cpu_ids; i++) {
834 cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i)); 834 cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i));
835 cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu)); 835 cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu));
836 cpumask_clear_cpu(cpu, cpu_core_mask(base + i)); 836 cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 2cb589264cb7..62859ebe0062 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -25,7 +25,8 @@
25#include <linux/user.h> 25#include <linux/user.h>
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/module.h> 28#include <linux/extable.h>
29#include <linux/module.h> /* print_modules */
29#include <linux/prctl.h> 30#include <linux/prctl.h>
30#include <linux/delay.h> 31#include <linux/delay.h>
31#include <linux/kprobes.h> 32#include <linux/kprobes.h>
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index 1f9e5529e692..855d4b95d752 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -78,6 +78,7 @@ kvm-book3s_64-builtin-xics-objs-$(CONFIG_KVM_XICS) := \
78 78
79ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 79ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
80kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \ 80kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
81 book3s_hv_hmi.o \
81 book3s_hv_rmhandlers.o \ 82 book3s_hv_rmhandlers.o \
82 book3s_hv_rm_mmu.o \ 83 book3s_hv_rm_mmu.o \
83 book3s_hv_ras.o \ 84 book3s_hv_ras.o \
diff --git a/arch/powerpc/kernel/hmi.c b/arch/powerpc/kvm/book3s_hv_hmi.c
index e3f738eb1cac..e3f738eb1cac 100644
--- a/arch/powerpc/kernel/hmi.c
+++ b/arch/powerpc/kvm/book3s_hv_hmi.c
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index a4db22f65021..bb1ffc559f38 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -26,7 +26,7 @@
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29#include <linux/module.h> 29#include <linux/extable.h>
30#include <linux/kprobes.h> 30#include <linux/kprobes.h>
31#include <linux/kdebug.h> 31#include <linux/kdebug.h>
32#include <linux/perf_event.h> 32#include <linux/perf_event.h>
diff --git a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
index 8eb82b043dd8..d93dd4acf40b 100644
--- a/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
+++ b/arch/powerpc/platforms/512x/mpc512x_lpbfifo.c
@@ -528,7 +528,6 @@ static struct platform_driver mpc512x_lpbfifo_driver = {
528 .remove = mpc512x_lpbfifo_remove, 528 .remove = mpc512x_lpbfifo_remove,
529 .driver = { 529 .driver = {
530 .name = DRV_NAME, 530 .name = DRV_NAME,
531 .owner = THIS_MODULE,
532 .of_match_table = mpc512x_lpbfifo_match, 531 .of_match_table = mpc512x_lpbfifo_match,
533 }, 532 },
534}; 533};
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index dbcd0303afed..63c5ab6489c9 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -222,7 +222,6 @@ static const struct of_device_id mcu_of_match_table[] = {
222static struct i2c_driver mcu_driver = { 222static struct i2c_driver mcu_driver = {
223 .driver = { 223 .driver = {
224 .name = "mcu-mpc8349emitx", 224 .name = "mcu-mpc8349emitx",
225 .owner = THIS_MODULE,
226 .of_match_table = mcu_of_match_table, 225 .of_match_table = mcu_of_match_table,
227 }, 226 },
228 .probe = mcu_probe, 227 .probe = mcu_probe,
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index dafba1057a47..dfd310031549 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -26,7 +26,7 @@
26#include <linux/tty.h> 26#include <linux/tty.h>
27#include <linux/serial_core.h> 27#include <linux/serial_core.h>
28#include <linux/of_platform.h> 28#include <linux/of_platform.h>
29#include <linux/module.h> 29#include <linux/extable.h>
30 30
31#include <asm/time.h> 31#include <asm/time.h>
32#include <asm/machdep.h> 32#include <asm/machdep.h>
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 80804f9916ee..f97bab8e37a2 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -23,7 +23,7 @@
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/kdev_t.h> 24#include <linux/kdev_t.h>
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/module.h> 26#include <linux/extable.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/irq.h> 28#include <linux/irq.h>
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
index 2ee96431f736..4c827826c05e 100644
--- a/arch/powerpc/platforms/powernv/opal-dump.c
+++ b/arch/powerpc/platforms/powernv/opal-dump.c
@@ -370,6 +370,7 @@ static irqreturn_t process_dump(int irq, void *data)
370 uint32_t dump_id, dump_size, dump_type; 370 uint32_t dump_id, dump_size, dump_type;
371 struct dump_obj *dump; 371 struct dump_obj *dump;
372 char name[22]; 372 char name[22];
373 struct kobject *kobj;
373 374
374 rc = dump_read_info(&dump_id, &dump_size, &dump_type); 375 rc = dump_read_info(&dump_id, &dump_size, &dump_type);
375 if (rc != OPAL_SUCCESS) 376 if (rc != OPAL_SUCCESS)
@@ -381,8 +382,12 @@ static irqreturn_t process_dump(int irq, void *data)
381 * that gracefully and not create two conflicting 382 * that gracefully and not create two conflicting
382 * entries. 383 * entries.
383 */ 384 */
384 if (kset_find_obj(dump_kset, name)) 385 kobj = kset_find_obj(dump_kset, name);
386 if (kobj) {
387 /* Drop reference added by kset_find_obj() */
388 kobject_put(kobj);
385 return 0; 389 return 0;
390 }
386 391
387 dump = create_dump_obj(dump_id, dump_size, dump_type); 392 dump = create_dump_obj(dump_id, dump_size, dump_type);
388 if (!dump) 393 if (!dump)
diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
index 37f959bf392e..f2344cbd2f46 100644
--- a/arch/powerpc/platforms/powernv/opal-elog.c
+++ b/arch/powerpc/platforms/powernv/opal-elog.c
@@ -247,6 +247,7 @@ static irqreturn_t elog_event(int irq, void *data)
247 uint64_t elog_type; 247 uint64_t elog_type;
248 int rc; 248 int rc;
249 char name[2+16+1]; 249 char name[2+16+1];
250 struct kobject *kobj;
250 251
251 rc = opal_get_elog_size(&id, &size, &type); 252 rc = opal_get_elog_size(&id, &size, &type);
252 if (rc != OPAL_SUCCESS) { 253 if (rc != OPAL_SUCCESS) {
@@ -269,8 +270,12 @@ static irqreturn_t elog_event(int irq, void *data)
269 * that gracefully and not create two conflicting 270 * that gracefully and not create two conflicting
270 * entries. 271 * entries.
271 */ 272 */
272 if (kset_find_obj(elog_kset, name)) 273 kobj = kset_find_obj(elog_kset, name);
274 if (kobj) {
275 /* Drop reference added by kset_find_obj() */
276 kobject_put(kobj);
273 return IRQ_HANDLED; 277 return IRQ_HANDLED;
278 }
274 279
275 create_elog_obj(log_id, elog_size, elog_type); 280 create_elog_obj(log_id, elog_size, elog_type);
276 281
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index fd9444f9fb0c..13218263e66e 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -149,7 +149,7 @@ static void pnv_ioda_reserve_pe(struct pnv_phb *phb, int pe_no)
149 149
150static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb) 150static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb)
151{ 151{
152 unsigned long pe = phb->ioda.total_pe_num - 1; 152 long pe;
153 153
154 for (pe = phb->ioda.total_pe_num - 1; pe >= 0; pe--) { 154 for (pe = phb->ioda.total_pe_num - 1; pe >= 0; pe--) {
155 if (!test_and_set_bit(pe, phb->ioda.pe_alloc)) 155 if (!test_and_set_bit(pe, phb->ioda.pe_alloc))
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fe16a50700de..09eba5a9929a 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -119,6 +119,10 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
119 119
120 bus = bridge->bus; 120 bus = bridge->bus;
121 121
122 /* Rely on the pcibios_free_controller_deferred() callback. */
123 pci_set_host_bridge_release(bridge, pcibios_free_controller_deferred,
124 (void *) pci_bus_to_host(bus));
125
122 dn = pcibios_get_phb_of_node(bus); 126 dn = pcibios_get_phb_of_node(bus);
123 if (!dn) 127 if (!dn)
124 return 0; 128 return 0;
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 906dbaa97fe2..547fd13e4f8e 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -106,8 +106,11 @@ int remove_phb_dynamic(struct pci_controller *phb)
106 release_resource(res); 106 release_resource(res);
107 } 107 }
108 108
109 /* Free pci_controller data structure */ 109 /*
110 pcibios_free_controller(phb); 110 * The pci_controller data structure is freed by
111 * the pcibios_free_controller_deferred() callback;
112 * see pseries_root_bridge_prepare().
113 */
111 114
112 return 0; 115 return 0;
113} 116}
diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c
index 6c110994d902..81d49476c47e 100644
--- a/arch/powerpc/sysdev/cpm1.c
+++ b/arch/powerpc/sysdev/cpm1.c
@@ -534,7 +534,8 @@ struct cpm1_gpio16_chip {
534 534
535static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc) 535static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc)
536{ 536{
537 struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 537 struct cpm1_gpio16_chip *cpm1_gc =
538 container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc);
538 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 539 struct cpm_ioport16 __iomem *iop = mm_gc->regs;
539 540
540 cpm1_gc->cpdata = in_be16(&iop->dat); 541 cpm1_gc->cpdata = in_be16(&iop->dat);
@@ -649,7 +650,8 @@ struct cpm1_gpio32_chip {
649 650
650static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 651static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc)
651{ 652{
652 struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 653 struct cpm1_gpio32_chip *cpm1_gc =
654 container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc);
653 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 655 struct cpm_ioport32b __iomem *iop = mm_gc->regs;
654 656
655 cpm1_gc->cpdata = in_be32(&iop->dat); 657 cpm1_gc->cpdata = in_be32(&iop->dat);
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index 911456d17713..947f42007734 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -94,7 +94,8 @@ struct cpm2_gpio32_chip {
94 94
95static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 95static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc)
96{ 96{
97 struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc); 97 struct cpm2_gpio32_chip *cpm2_gc =
98 container_of(mm_gc, struct cpm2_gpio32_chip, mm_gc);
98 struct cpm2_ioports __iomem *iop = mm_gc->regs; 99 struct cpm2_ioports __iomem *iop = mm_gc->regs;
99 100
100 cpm2_gc->cpdata = in_be32(&iop->dat); 101 cpm2_gc->cpdata = in_be32(&iop->dat);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 68e7c0dd2e45..3cc7cace194a 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/extable.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/interrupt.h> 29#include <linux/interrupt.h>
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index e751fe25d6ab..c109f073d454 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -68,7 +68,6 @@ config DEBUG_RODATA
68config S390 68config S390
69 def_bool y 69 def_bool y
70 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 70 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
71 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
72 select ARCH_HAS_DEVMEM_IS_ALLOWED 71 select ARCH_HAS_DEVMEM_IS_ALLOWED
73 select ARCH_HAS_ELF_RANDOMIZE 72 select ARCH_HAS_ELF_RANDOMIZE
74 select ARCH_HAS_GCOV_PROFILE_ALL 73 select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/s390/configs/default_defconfig b/arch/s390/configs/default_defconfig
index 26e0c7f08814..412b1bd21029 100644
--- a/arch/s390/configs/default_defconfig
+++ b/arch/s390/configs/default_defconfig
@@ -602,7 +602,6 @@ CONFIG_FAIL_FUTEX=y
602CONFIG_FAULT_INJECTION_DEBUG_FS=y 602CONFIG_FAULT_INJECTION_DEBUG_FS=y
603CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y 603CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
604CONFIG_LATENCYTOP=y 604CONFIG_LATENCYTOP=y
605CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
606CONFIG_IRQSOFF_TRACER=y 605CONFIG_IRQSOFF_TRACER=y
607CONFIG_PREEMPT_TRACER=y 606CONFIG_PREEMPT_TRACER=y
608CONFIG_SCHED_TRACER=y 607CONFIG_SCHED_TRACER=y
diff --git a/arch/s390/configs/gcov_defconfig b/arch/s390/configs/gcov_defconfig
index 24879dab47bc..bec279eb4b93 100644
--- a/arch/s390/configs/gcov_defconfig
+++ b/arch/s390/configs/gcov_defconfig
@@ -552,7 +552,6 @@ CONFIG_NOTIFIER_ERROR_INJECTION=m
552CONFIG_CPU_NOTIFIER_ERROR_INJECT=m 552CONFIG_CPU_NOTIFIER_ERROR_INJECT=m
553CONFIG_PM_NOTIFIER_ERROR_INJECT=m 553CONFIG_PM_NOTIFIER_ERROR_INJECT=m
554CONFIG_LATENCYTOP=y 554CONFIG_LATENCYTOP=y
555CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
556CONFIG_BLK_DEV_IO_TRACE=y 555CONFIG_BLK_DEV_IO_TRACE=y
557# CONFIG_KPROBE_EVENT is not set 556# CONFIG_KPROBE_EVENT is not set
558CONFIG_TRACE_ENUM_MAP_FILE=y 557CONFIG_TRACE_ENUM_MAP_FILE=y
diff --git a/arch/s390/configs/performance_defconfig b/arch/s390/configs/performance_defconfig
index a5c1e5f2a0ca..1751446a5bbb 100644
--- a/arch/s390/configs/performance_defconfig
+++ b/arch/s390/configs/performance_defconfig
@@ -549,7 +549,6 @@ CONFIG_TIMER_STATS=y
549CONFIG_RCU_TORTURE_TEST=m 549CONFIG_RCU_TORTURE_TEST=m
550CONFIG_RCU_CPU_STALL_TIMEOUT=60 550CONFIG_RCU_CPU_STALL_TIMEOUT=60
551CONFIG_LATENCYTOP=y 551CONFIG_LATENCYTOP=y
552CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
553CONFIG_SCHED_TRACER=y 552CONFIG_SCHED_TRACER=y
554CONFIG_FTRACE_SYSCALLS=y 553CONFIG_FTRACE_SYSCALLS=y
555CONFIG_STACK_TRACER=y 554CONFIG_STACK_TRACER=y
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index 73610f2e3b4f..2d40ef0a6295 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -172,7 +172,6 @@ CONFIG_DEBUG_NOTIFIERS=y
172CONFIG_RCU_CPU_STALL_TIMEOUT=60 172CONFIG_RCU_CPU_STALL_TIMEOUT=60
173CONFIG_RCU_TRACE=y 173CONFIG_RCU_TRACE=y
174CONFIG_LATENCYTOP=y 174CONFIG_LATENCYTOP=y
175CONFIG_DEBUG_STRICT_USER_COPY_CHECKS=y
176CONFIG_SCHED_TRACER=y 175CONFIG_SCHED_TRACER=y
177CONFIG_FTRACE_SYSCALLS=y 176CONFIG_FTRACE_SYSCALLS=y
178CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y 177CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 9b49cf1daa8f..95aefdba4be2 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -311,6 +311,14 @@ int __get_user_bad(void) __attribute__((noreturn));
311#define __put_user_unaligned __put_user 311#define __put_user_unaligned __put_user
312#define __get_user_unaligned __get_user 312#define __get_user_unaligned __get_user
313 313
314extern void __compiletime_error("usercopy buffer size is too small")
315__bad_copy_user(void);
316
317static inline void copy_user_overflow(int size, unsigned long count)
318{
319 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
320}
321
314/** 322/**
315 * copy_to_user: - Copy a block of data into user space. 323 * copy_to_user: - Copy a block of data into user space.
316 * @to: Destination address, in user space. 324 * @to: Destination address, in user space.
@@ -332,12 +340,6 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
332 return __copy_to_user(to, from, n); 340 return __copy_to_user(to, from, n);
333} 341}
334 342
335void copy_from_user_overflow(void)
336#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
337__compiletime_warning("copy_from_user() buffer size is not provably correct")
338#endif
339;
340
341/** 343/**
342 * copy_from_user: - Copy a block of data from user space. 344 * copy_from_user: - Copy a block of data from user space.
343 * @to: Destination address, in kernel space. 345 * @to: Destination address, in kernel space.
@@ -362,7 +364,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
362 364
363 might_fault(); 365 might_fault();
364 if (unlikely(sz != -1 && sz < n)) { 366 if (unlikely(sz != -1 && sz < n)) {
365 copy_from_user_overflow(); 367 if (!__builtin_constant_p(n))
368 copy_user_overflow(sz, n);
369 else
370 __bad_copy_user();
366 return n; 371 return n;
367 } 372 }
368 return __copy_from_user(to, from, n); 373 return __copy_from_user(to, from, n);
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 4820a02838ac..78da75b670bc 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -4,7 +4,6 @@
4config TILE 4config TILE
5 def_bool y 5 def_bool y
6 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 6 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
7 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
8 select ARCH_HAS_DEVMEM_IS_ALLOWED 7 select ARCH_HAS_DEVMEM_IS_ALLOWED
9 select ARCH_HAVE_NMI_SAFE_CMPXCHG 8 select ARCH_HAVE_NMI_SAFE_CMPXCHG
10 select ARCH_WANT_FRAME_POINTERS 9 select ARCH_WANT_FRAME_POINTERS
diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index 0a9c4265763b..a77369e91e54 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -416,14 +416,13 @@ _copy_from_user(void *to, const void __user *from, unsigned long n)
416 return n; 416 return n;
417} 417}
418 418
419#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 419extern void __compiletime_error("usercopy buffer size is too small")
420/* 420__bad_copy_user(void);
421 * There are still unprovable places in the generic code as of 2.6.34, so this 421
422 * option is not really compatible with -Werror, which is more useful in 422static inline void copy_user_overflow(int size, unsigned long count)
423 * general. 423{
424 */ 424 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
425extern void copy_from_user_overflow(void) 425}
426 __compiletime_warning("copy_from_user() size is not provably correct");
427 426
428static inline unsigned long __must_check copy_from_user(void *to, 427static inline unsigned long __must_check copy_from_user(void *to,
429 const void __user *from, 428 const void __user *from,
@@ -433,14 +432,13 @@ static inline unsigned long __must_check copy_from_user(void *to,
433 432
434 if (likely(sz == -1 || sz >= n)) 433 if (likely(sz == -1 || sz >= n))
435 n = _copy_from_user(to, from, n); 434 n = _copy_from_user(to, from, n);
435 else if (!__builtin_constant_p(n))
436 copy_user_overflow(sz, n);
436 else 437 else
437 copy_from_user_overflow(); 438 __bad_copy_user();
438 439
439 return n; 440 return n;
440} 441}
441#else
442#define copy_from_user _copy_from_user
443#endif
444 442
445#ifdef __tilegx__ 443#ifdef __tilegx__
446/** 444/**
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c580d8c33562..2a1f0ce7c59a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -24,7 +24,6 @@ config X86
24 select ARCH_DISCARD_MEMBLOCK 24 select ARCH_DISCARD_MEMBLOCK
25 select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI 25 select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
26 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 26 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
27 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
28 select ARCH_HAS_DEVMEM_IS_ALLOWED 27 select ARCH_HAS_DEVMEM_IS_ALLOWED
29 select ARCH_HAS_ELF_RANDOMIZE 28 select ARCH_HAS_ELF_RANDOMIZE
30 select ARCH_HAS_FAST_MULTIPLIER 29 select ARCH_HAS_FAST_MULTIPLIER
diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config
index 4e2ecfa23c15..4b429df40d7a 100644
--- a/arch/x86/configs/tiny.config
+++ b/arch/x86/configs/tiny.config
@@ -1 +1,3 @@
1CONFIG_NOHIGHMEM=y 1CONFIG_NOHIGHMEM=y
2# CONFIG_HIGHMEM4G is not set
3# CONFIG_HIGHMEM64G is not set
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index a0ae610b9280..c3f291195294 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -697,43 +697,14 @@ unsigned long __must_check _copy_from_user(void *to, const void __user *from,
697unsigned long __must_check _copy_to_user(void __user *to, const void *from, 697unsigned long __must_check _copy_to_user(void __user *to, const void *from,
698 unsigned n); 698 unsigned n);
699 699
700#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 700extern void __compiletime_error("usercopy buffer size is too small")
701# define copy_user_diag __compiletime_error 701__bad_copy_user(void);
702#else
703# define copy_user_diag __compiletime_warning
704#endif
705
706extern void copy_user_diag("copy_from_user() buffer size is too small")
707copy_from_user_overflow(void);
708extern void copy_user_diag("copy_to_user() buffer size is too small")
709copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
710
711#undef copy_user_diag
712
713#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
714
715extern void
716__compiletime_warning("copy_from_user() buffer size is not provably correct")
717__copy_from_user_overflow(void) __asm__("copy_from_user_overflow");
718#define __copy_from_user_overflow(size, count) __copy_from_user_overflow()
719
720extern void
721__compiletime_warning("copy_to_user() buffer size is not provably correct")
722__copy_to_user_overflow(void) __asm__("copy_from_user_overflow");
723#define __copy_to_user_overflow(size, count) __copy_to_user_overflow()
724
725#else
726 702
727static inline void 703static inline void copy_user_overflow(int size, unsigned long count)
728__copy_from_user_overflow(int size, unsigned long count)
729{ 704{
730 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); 705 WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
731} 706}
732 707
733#define __copy_to_user_overflow __copy_from_user_overflow
734
735#endif
736
737static inline unsigned long __must_check 708static inline unsigned long __must_check
738copy_from_user(void *to, const void __user *from, unsigned long n) 709copy_from_user(void *to, const void __user *from, unsigned long n)
739{ 710{
@@ -743,31 +714,13 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
743 714
744 kasan_check_write(to, n); 715 kasan_check_write(to, n);
745 716
746 /*
747 * While we would like to have the compiler do the checking for us
748 * even in the non-constant size case, any false positives there are
749 * a problem (especially when DEBUG_STRICT_USER_COPY_CHECKS, but even
750 * without - the [hopefully] dangerous looking nature of the warning
751 * would make people go look at the respecitive call sites over and
752 * over again just to find that there's no problem).
753 *
754 * And there are cases where it's just not realistic for the compiler
755 * to prove the count to be in range. For example when multiple call
756 * sites of a helper function - perhaps in different source files -
757 * all doing proper range checking, yet the helper function not doing
758 * so again.
759 *
760 * Therefore limit the compile time checking to the constant size
761 * case, and do only runtime checking for non-constant sizes.
762 */
763
764 if (likely(sz < 0 || sz >= n)) { 717 if (likely(sz < 0 || sz >= n)) {
765 check_object_size(to, n, false); 718 check_object_size(to, n, false);
766 n = _copy_from_user(to, from, n); 719 n = _copy_from_user(to, from, n);
767 } else if (__builtin_constant_p(n)) 720 } else if (!__builtin_constant_p(n))
768 copy_from_user_overflow(); 721 copy_user_overflow(sz, n);
769 else 722 else
770 __copy_from_user_overflow(sz, n); 723 __bad_copy_user();
771 724
772 return n; 725 return n;
773} 726}
@@ -781,21 +734,17 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
781 734
782 might_fault(); 735 might_fault();
783 736
784 /* See the comment in copy_from_user() above. */
785 if (likely(sz < 0 || sz >= n)) { 737 if (likely(sz < 0 || sz >= n)) {
786 check_object_size(from, n, true); 738 check_object_size(from, n, true);
787 n = _copy_to_user(to, from, n); 739 n = _copy_to_user(to, from, n);
788 } else if (__builtin_constant_p(n)) 740 } else if (!__builtin_constant_p(n))
789 copy_to_user_overflow(); 741 copy_user_overflow(sz, n);
790 else 742 else
791 __copy_to_user_overflow(sz, n); 743 __bad_copy_user();
792 744
793 return n; 745 return n;
794} 746}
795 747
796#undef __copy_from_user_overflow
797#undef __copy_to_user_overflow
798
799/* 748/*
800 * We rely on the nested NMI work to allow atomic faults from the NMI path; the 749 * We rely on the nested NMI work to allow atomic faults from the NMI path; the
801 * nested NMI paths are careful to preserve CR2. 750 * nested NMI paths are careful to preserve CR2.
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f5c69d8974e1..b81fe2d63e15 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -669,6 +669,17 @@ static void init_amd_gh(struct cpuinfo_x86 *c)
669 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); 669 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
670} 670}
671 671
672#define MSR_AMD64_DE_CFG 0xC0011029
673
674static void init_amd_ln(struct cpuinfo_x86 *c)
675{
676 /*
677 * Apply erratum 665 fix unconditionally so machines without a BIOS
678 * fix work.
679 */
680 msr_set_bit(MSR_AMD64_DE_CFG, 31);
681}
682
672static void init_amd_bd(struct cpuinfo_x86 *c) 683static void init_amd_bd(struct cpuinfo_x86 *c)
673{ 684{
674 u64 value; 685 u64 value;
@@ -726,6 +737,7 @@ static void init_amd(struct cpuinfo_x86 *c)
726 case 6: init_amd_k7(c); break; 737 case 6: init_amd_k7(c); break;
727 case 0xf: init_amd_k8(c); break; 738 case 0xf: init_amd_k8(c); break;
728 case 0x10: init_amd_gh(c); break; 739 case 0x10: init_amd_gh(c); break;
740 case 0x12: init_amd_ln(c); break;
729 case 0x15: init_amd_bd(c); break; 741 case 0x15: init_amd_bd(c); break;
730 } 742 }
731 743
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index ad5bc9578a73..1acfd76e3e26 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -56,12 +56,12 @@ asm (".pushsection .entry.text, \"ax\"\n"
56 ".popsection"); 56 ".popsection");
57 57
58/* identity function, which can be inlined */ 58/* identity function, which can be inlined */
59u32 _paravirt_ident_32(u32 x) 59u32 notrace _paravirt_ident_32(u32 x)
60{ 60{
61 return x; 61 return x;
62} 62}
63 63
64u64 _paravirt_ident_64(u64 x) 64u64 notrace _paravirt_ident_64(u64 x)
65{ 65{
66 return x; 66 return x;
67} 67}
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index cf8037a87b2d..77207b41940c 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -733,13 +733,14 @@ static void cryptd_aead_crypt(struct aead_request *req,
733 rctx = aead_request_ctx(req); 733 rctx = aead_request_ctx(req);
734 compl = rctx->complete; 734 compl = rctx->complete;
735 735
736 tfm = crypto_aead_reqtfm(req);
737
736 if (unlikely(err == -EINPROGRESS)) 738 if (unlikely(err == -EINPROGRESS))
737 goto out; 739 goto out;
738 aead_request_set_tfm(req, child); 740 aead_request_set_tfm(req, child);
739 err = crypt( req ); 741 err = crypt( req );
740 742
741out: 743out:
742 tfm = crypto_aead_reqtfm(req);
743 ctx = crypto_aead_ctx(tfm); 744 ctx = crypto_aead_ctx(tfm);
744 refcnt = atomic_read(&ctx->refcnt); 745 refcnt = atomic_read(&ctx->refcnt);
745 746
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index ad9fc84a8601..e878fc799af7 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2054,7 +2054,7 @@ int __init acpi_scan_init(void)
2054 2054
2055static struct acpi_probe_entry *ape; 2055static struct acpi_probe_entry *ape;
2056static int acpi_probe_count; 2056static int acpi_probe_count;
2057static DEFINE_SPINLOCK(acpi_probe_lock); 2057static DEFINE_MUTEX(acpi_probe_mutex);
2058 2058
2059static int __init acpi_match_madt(struct acpi_subtable_header *header, 2059static int __init acpi_match_madt(struct acpi_subtable_header *header,
2060 const unsigned long end) 2060 const unsigned long end)
@@ -2073,7 +2073,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
2073 if (acpi_disabled) 2073 if (acpi_disabled)
2074 return 0; 2074 return 0;
2075 2075
2076 spin_lock(&acpi_probe_lock); 2076 mutex_lock(&acpi_probe_mutex);
2077 for (ape = ap_head; nr; ape++, nr--) { 2077 for (ape = ap_head; nr; ape++, nr--) {
2078 if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) { 2078 if (ACPI_COMPARE_NAME(ACPI_SIG_MADT, ape->id)) {
2079 acpi_probe_count = 0; 2079 acpi_probe_count = 0;
@@ -2086,7 +2086,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
2086 count++; 2086 count++;
2087 } 2087 }
2088 } 2088 }
2089 spin_unlock(&acpi_probe_lock); 2089 mutex_unlock(&acpi_probe_mutex);
2090 2090
2091 return count; 2091 return count;
2092} 2092}
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 7461a587b39b..dcf2c724fd06 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -2524,7 +2524,7 @@ static int ahci_host_activate_multi_irqs(struct ata_host *host,
2524 2524
2525 /* Do not receive interrupts sent by dummy ports */ 2525 /* Do not receive interrupts sent by dummy ports */
2526 if (!pp) { 2526 if (!pp) {
2527 disable_irq(irq + i); 2527 disable_irq(irq);
2528 continue; 2528 continue;
2529 } 2529 }
2530 2530
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c
index 633aa2934a18..44f97ad3c88d 100644
--- a/drivers/ata/pata_ninja32.c
+++ b/drivers/ata/pata_ninja32.c
@@ -144,7 +144,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
144 ap->ioaddr.altstatus_addr = base + 0x1E; 144 ap->ioaddr.altstatus_addr = base + 0x1E;
145 ap->ioaddr.bmdma_addr = base; 145 ap->ioaddr.bmdma_addr = base;
146 ata_sff_std_ports(&ap->ioaddr); 146 ata_sff_std_ports(&ap->ioaddr);
147 ap->pflags = ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE; 147 ap->pflags |= ATA_PFLAG_PIO32 | ATA_PFLAG_PIO32CHANGE;
148 148
149 ninja32_program(base); 149 ninja32_program(base);
150 /* FIXME: Should we disable them at remove ? */ 150 /* FIXME: Should we disable them at remove ? */
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index e097d355cc04..17995fadebd7 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -301,7 +301,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
301 int (*callback)(struct device *); 301 int (*callback)(struct device *);
302 int retval; 302 int retval;
303 303
304 trace_rpm_idle(dev, rpmflags); 304 trace_rpm_idle_rcuidle(dev, rpmflags);
305 retval = rpm_check_suspend_allowed(dev); 305 retval = rpm_check_suspend_allowed(dev);
306 if (retval < 0) 306 if (retval < 0)
307 ; /* Conditions are wrong. */ 307 ; /* Conditions are wrong. */
@@ -337,7 +337,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
337 dev->power.request_pending = true; 337 dev->power.request_pending = true;
338 queue_work(pm_wq, &dev->power.work); 338 queue_work(pm_wq, &dev->power.work);
339 } 339 }
340 trace_rpm_return_int(dev, _THIS_IP_, 0); 340 trace_rpm_return_int_rcuidle(dev, _THIS_IP_, 0);
341 return 0; 341 return 0;
342 } 342 }
343 343
@@ -352,7 +352,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
352 wake_up_all(&dev->power.wait_queue); 352 wake_up_all(&dev->power.wait_queue);
353 353
354 out: 354 out:
355 trace_rpm_return_int(dev, _THIS_IP_, retval); 355 trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval);
356 return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO); 356 return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
357} 357}
358 358
@@ -601,7 +601,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
601 struct device *parent = NULL; 601 struct device *parent = NULL;
602 int retval = 0; 602 int retval = 0;
603 603
604 trace_rpm_resume(dev, rpmflags); 604 trace_rpm_resume_rcuidle(dev, rpmflags);
605 605
606 repeat: 606 repeat:
607 if (dev->power.runtime_error) 607 if (dev->power.runtime_error)
@@ -764,7 +764,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
764 spin_lock_irq(&dev->power.lock); 764 spin_lock_irq(&dev->power.lock);
765 } 765 }
766 766
767 trace_rpm_return_int(dev, _THIS_IP_, retval); 767 trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval);
768 768
769 return retval; 769 return retval;
770} 770}
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 56ad5a5936a9..8c0770bf8881 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -244,7 +244,7 @@ config HW_RANDOM_TX4939
244 244
245config HW_RANDOM_MXC_RNGA 245config HW_RANDOM_MXC_RNGA
246 tristate "Freescale i.MX RNGA Random Number Generator" 246 tristate "Freescale i.MX RNGA Random Number Generator"
247 depends on ARCH_HAS_RNGA 247 depends on SOC_IMX31
248 default HW_RANDOM 248 default HW_RANDOM
249 ---help--- 249 ---help---
250 This driver provides kernel-side support for the Random Number 250 This driver provides kernel-side support for the Random Number
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 08c7e23ed535..0c75c3f1689f 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -957,7 +957,7 @@ int tpm2_auto_startup(struct tpm_chip *chip)
957 goto out; 957 goto out;
958 958
959 rc = tpm2_do_selftest(chip); 959 rc = tpm2_do_selftest(chip);
960 if (rc != TPM2_RC_INITIALIZE) { 960 if (rc != 0 && rc != TPM2_RC_INITIALIZE) {
961 dev_err(&chip->dev, "TPM self test failed\n"); 961 dev_err(&chip->dev, "TPM self test failed\n");
962 goto out; 962 goto out;
963 } 963 }
@@ -974,7 +974,6 @@ int tpm2_auto_startup(struct tpm_chip *chip)
974 } 974 }
975 } 975 }
976 976
977 return rc;
978out: 977out:
979 if (rc > 0) 978 if (rc > 0)
980 rc = -ENODEV; 979 rc = -ENODEV;
diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c
index d359c92e13a6..e38bf60c0ff4 100644
--- a/drivers/clk/renesas/r8a7795-cpg-mssr.c
+++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c
@@ -69,6 +69,7 @@ static const struct cpg_core_clk r8a7795_core_clks[] __initconst = {
69 DEF_FIXED(".s1", CLK_S1, CLK_PLL1_DIV2, 3, 1), 69 DEF_FIXED(".s1", CLK_S1, CLK_PLL1_DIV2, 3, 1),
70 DEF_FIXED(".s2", CLK_S2, CLK_PLL1_DIV2, 4, 1), 70 DEF_FIXED(".s2", CLK_S2, CLK_PLL1_DIV2, 4, 1),
71 DEF_FIXED(".s3", CLK_S3, CLK_PLL1_DIV2, 6, 1), 71 DEF_FIXED(".s3", CLK_S3, CLK_PLL1_DIV2, 6, 1),
72 DEF_FIXED(".sdsrc", CLK_SDSRC, CLK_PLL1_DIV2, 2, 1),
72 73
73 /* Core Clock Outputs */ 74 /* Core Clock Outputs */
74 DEF_FIXED("ztr", R8A7795_CLK_ZTR, CLK_PLL1_DIV2, 6, 1), 75 DEF_FIXED("ztr", R8A7795_CLK_ZTR, CLK_PLL1_DIV2, 6, 1),
@@ -87,10 +88,10 @@ static const struct cpg_core_clk r8a7795_core_clks[] __initconst = {
87 DEF_FIXED("s3d2", R8A7795_CLK_S3D2, CLK_S3, 2, 1), 88 DEF_FIXED("s3d2", R8A7795_CLK_S3D2, CLK_S3, 2, 1),
88 DEF_FIXED("s3d4", R8A7795_CLK_S3D4, CLK_S3, 4, 1), 89 DEF_FIXED("s3d4", R8A7795_CLK_S3D4, CLK_S3, 4, 1),
89 90
90 DEF_GEN3_SD("sd0", R8A7795_CLK_SD0, CLK_PLL1_DIV2, 0x0074), 91 DEF_GEN3_SD("sd0", R8A7795_CLK_SD0, CLK_SDSRC, 0x0074),
91 DEF_GEN3_SD("sd1", R8A7795_CLK_SD1, CLK_PLL1_DIV2, 0x0078), 92 DEF_GEN3_SD("sd1", R8A7795_CLK_SD1, CLK_SDSRC, 0x0078),
92 DEF_GEN3_SD("sd2", R8A7795_CLK_SD2, CLK_PLL1_DIV2, 0x0268), 93 DEF_GEN3_SD("sd2", R8A7795_CLK_SD2, CLK_SDSRC, 0x0268),
93 DEF_GEN3_SD("sd3", R8A7795_CLK_SD3, CLK_PLL1_DIV2, 0x026c), 94 DEF_GEN3_SD("sd3", R8A7795_CLK_SD3, CLK_SDSRC, 0x026c),
94 95
95 DEF_FIXED("cl", R8A7795_CLK_CL, CLK_PLL1_DIV2, 48, 1), 96 DEF_FIXED("cl", R8A7795_CLK_CL, CLK_PLL1_DIV2, 48, 1),
96 DEF_FIXED("cp", R8A7795_CLK_CP, CLK_EXTAL, 2, 1), 97 DEF_FIXED("cp", R8A7795_CLK_CP, CLK_EXTAL, 2, 1),
diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
index c109d80e7a8a..cdfabeb9a034 100644
--- a/drivers/clk/rockchip/clk-rk3399.c
+++ b/drivers/clk/rockchip/clk-rk3399.c
@@ -833,9 +833,9 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
833 833
834 /* perihp */ 834 /* perihp */
835 GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED, 835 GATE(0, "cpll_aclk_perihp_src", "cpll", CLK_IGNORE_UNUSED,
836 RK3399_CLKGATE_CON(5), 0, GFLAGS),
837 GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED,
838 RK3399_CLKGATE_CON(5), 1, GFLAGS), 836 RK3399_CLKGATE_CON(5), 1, GFLAGS),
837 GATE(0, "gpll_aclk_perihp_src", "gpll", CLK_IGNORE_UNUSED,
838 RK3399_CLKGATE_CON(5), 0, GFLAGS),
839 COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED, 839 COMPOSITE(ACLK_PERIHP, "aclk_perihp", mux_aclk_perihp_p, CLK_IGNORE_UNUSED,
840 RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS, 840 RK3399_CLKSEL_CON(14), 7, 1, MFLAGS, 0, 5, DFLAGS,
841 RK3399_CLKGATE_CON(5), 2, GFLAGS), 841 RK3399_CLKGATE_CON(5), 2, GFLAGS),
@@ -923,9 +923,9 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
923 RK3399_CLKGATE_CON(6), 14, GFLAGS), 923 RK3399_CLKGATE_CON(6), 14, GFLAGS),
924 924
925 GATE(0, "cpll_aclk_emmc_src", "cpll", CLK_IGNORE_UNUSED, 925 GATE(0, "cpll_aclk_emmc_src", "cpll", CLK_IGNORE_UNUSED,
926 RK3399_CLKGATE_CON(6), 12, GFLAGS),
927 GATE(0, "gpll_aclk_emmc_src", "gpll", CLK_IGNORE_UNUSED,
928 RK3399_CLKGATE_CON(6), 13, GFLAGS), 926 RK3399_CLKGATE_CON(6), 13, GFLAGS),
927 GATE(0, "gpll_aclk_emmc_src", "gpll", CLK_IGNORE_UNUSED,
928 RK3399_CLKGATE_CON(6), 12, GFLAGS),
929 COMPOSITE_NOGATE(ACLK_EMMC, "aclk_emmc", mux_aclk_emmc_p, CLK_IGNORE_UNUSED, 929 COMPOSITE_NOGATE(ACLK_EMMC, "aclk_emmc", mux_aclk_emmc_p, CLK_IGNORE_UNUSED,
930 RK3399_CLKSEL_CON(21), 7, 1, MFLAGS, 0, 5, DFLAGS), 930 RK3399_CLKSEL_CON(21), 7, 1, MFLAGS, 0, 5, DFLAGS),
931 GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", CLK_IGNORE_UNUSED, 931 GATE(ACLK_EMMC_CORE, "aclk_emmccore", "aclk_emmc", CLK_IGNORE_UNUSED,
@@ -1071,7 +1071,7 @@ static struct rockchip_clk_branch rk3399_clk_branches[] __initdata = {
1071 /* vio */ 1071 /* vio */
1072 COMPOSITE(ACLK_VIO, "aclk_vio", mux_pll_src_cpll_gpll_ppll_p, CLK_IGNORE_UNUSED, 1072 COMPOSITE(ACLK_VIO, "aclk_vio", mux_pll_src_cpll_gpll_ppll_p, CLK_IGNORE_UNUSED,
1073 RK3399_CLKSEL_CON(42), 6, 2, MFLAGS, 0, 5, DFLAGS, 1073 RK3399_CLKSEL_CON(42), 6, 2, MFLAGS, 0, 5, DFLAGS,
1074 RK3399_CLKGATE_CON(11), 10, GFLAGS), 1074 RK3399_CLKGATE_CON(11), 0, GFLAGS),
1075 COMPOSITE_NOMUX(PCLK_VIO, "pclk_vio", "aclk_vio", 0, 1075 COMPOSITE_NOMUX(PCLK_VIO, "pclk_vio", "aclk_vio", 0,
1076 RK3399_CLKSEL_CON(43), 0, 5, DFLAGS, 1076 RK3399_CLKSEL_CON(43), 0, 5, DFLAGS,
1077 RK3399_CLKGATE_CON(11), 1, GFLAGS), 1077 RK3399_CLKGATE_CON(11), 1, GFLAGS),
@@ -1484,6 +1484,7 @@ static const char *const rk3399_cru_critical_clocks[] __initconst = {
1484 "hclk_perilp1", 1484 "hclk_perilp1",
1485 "hclk_perilp1_noc", 1485 "hclk_perilp1_noc",
1486 "aclk_dmac0_perilp", 1486 "aclk_dmac0_perilp",
1487 "aclk_emmc_noc",
1487 "gpll_hclk_perilp1_src", 1488 "gpll_hclk_perilp1_src",
1488 "gpll_aclk_perilp0_src", 1489 "gpll_aclk_perilp0_src",
1489 "gpll_aclk_perihp_src", 1490 "gpll_aclk_perihp_src",
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c
index fc17b5295e16..51d4bac97ab3 100644
--- a/drivers/clk/sunxi-ng/ccu_common.c
+++ b/drivers/clk/sunxi-ng/ccu_common.c
@@ -31,7 +31,7 @@ void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock)
31 return; 31 return;
32 32
33 WARN_ON(readl_relaxed_poll_timeout(common->base + common->reg, reg, 33 WARN_ON(readl_relaxed_poll_timeout(common->base + common->reg, reg,
34 !(reg & lock), 100, 70000)); 34 reg & lock, 100, 70000));
35} 35}
36 36
37int sunxi_ccu_probe(struct device_node *node, void __iomem *reg, 37int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c
index 64da7b79a6e4..933b5dd698b8 100644
--- a/drivers/clk/tegra/clk-tegra114.c
+++ b/drivers/clk/tegra/clk-tegra114.c
@@ -428,7 +428,7 @@ static struct tegra_clk_pll_params pll_d_params = {
428 .div_nmp = &pllp_nmp, 428 .div_nmp = &pllp_nmp,
429 .freq_table = pll_d_freq_table, 429 .freq_table = pll_d_freq_table,
430 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 430 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
431 TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 431 TEGRA_PLL_HAS_LOCK_ENABLE,
432}; 432};
433 433
434static struct tegra_clk_pll_params pll_d2_params = { 434static struct tegra_clk_pll_params pll_d2_params = {
@@ -446,7 +446,7 @@ static struct tegra_clk_pll_params pll_d2_params = {
446 .div_nmp = &pllp_nmp, 446 .div_nmp = &pllp_nmp,
447 .freq_table = pll_d_freq_table, 447 .freq_table = pll_d_freq_table,
448 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 448 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
449 TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE, 449 TEGRA_PLL_HAS_LOCK_ENABLE,
450}; 450};
451 451
452static const struct pdiv_map pllu_p[] = { 452static const struct pdiv_map pllu_p[] = {
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index 3494bc5a21d5..7f0f5b26d8c5 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -240,6 +240,7 @@ static int __init at91sam926x_pit_common_init(struct pit_data *data)
240static int __init at91sam926x_pit_dt_init(struct device_node *node) 240static int __init at91sam926x_pit_dt_init(struct device_node *node)
241{ 241{
242 struct pit_data *data; 242 struct pit_data *data;
243 int ret;
243 244
244 data = kzalloc(sizeof(*data), GFP_KERNEL); 245 data = kzalloc(sizeof(*data), GFP_KERNEL);
245 if (!data) 246 if (!data)
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index 0bb44d5b5df4..2ee40fd360ca 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -74,6 +74,8 @@ static const struct of_device_id machines[] __initconst = {
74 { .compatible = "ti,omap5", }, 74 { .compatible = "ti,omap5", },
75 75
76 { .compatible = "xlnx,zynq-7000", }, 76 { .compatible = "xlnx,zynq-7000", },
77
78 { }
77}; 79};
78 80
79static int __init cpufreq_dt_platdev_init(void) 81static int __init cpufreq_dt_platdev_init(void)
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
index 6dc597126b79..b3044219772c 100644
--- a/drivers/crypto/caam/caamalg.c
+++ b/drivers/crypto/caam/caamalg.c
@@ -556,7 +556,10 @@ skip_enc:
556 556
557 /* Read and write assoclen bytes */ 557 /* Read and write assoclen bytes */
558 append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ); 558 append_math_add(desc, VARSEQINLEN, ZERO, REG3, CAAM_CMD_SZ);
559 append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ); 559 if (alg->caam.geniv)
560 append_math_add_imm_u32(desc, VARSEQOUTLEN, REG3, IMM, ivsize);
561 else
562 append_math_add(desc, VARSEQOUTLEN, ZERO, REG3, CAAM_CMD_SZ);
560 563
561 /* Skip assoc data */ 564 /* Skip assoc data */
562 append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); 565 append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF);
@@ -565,6 +568,14 @@ skip_enc:
565 append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG | 568 append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS2 | FIFOLD_TYPE_MSG |
566 KEY_VLF); 569 KEY_VLF);
567 570
571 if (alg->caam.geniv) {
572 append_seq_load(desc, ivsize, LDST_CLASS_1_CCB |
573 LDST_SRCDST_BYTE_CONTEXT |
574 (ctx1_iv_off << LDST_OFFSET_SHIFT));
575 append_move(desc, MOVE_SRC_CLASS1CTX | MOVE_DEST_CLASS2INFIFO |
576 (ctx1_iv_off << MOVE_OFFSET_SHIFT) | ivsize);
577 }
578
568 /* Load Counter into CONTEXT1 reg */ 579 /* Load Counter into CONTEXT1 reg */
569 if (is_rfc3686) 580 if (is_rfc3686)
570 append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM | 581 append_load_imm_u32(desc, be32_to_cpu(1), LDST_IMM |
@@ -2150,7 +2161,7 @@ static void init_authenc_job(struct aead_request *req,
2150 2161
2151 init_aead_job(req, edesc, all_contig, encrypt); 2162 init_aead_job(req, edesc, all_contig, encrypt);
2152 2163
2153 if (ivsize && (is_rfc3686 || !(alg->caam.geniv && encrypt))) 2164 if (ivsize && ((is_rfc3686 && encrypt) || !alg->caam.geniv))
2154 append_load_as_imm(desc, req->iv, ivsize, 2165 append_load_as_imm(desc, req->iv, ivsize,
2155 LDST_CLASS_1_CCB | 2166 LDST_CLASS_1_CCB |
2156 LDST_SRCDST_BYTE_CONTEXT | 2167 LDST_SRCDST_BYTE_CONTEXT |
@@ -2537,20 +2548,6 @@ static int aead_decrypt(struct aead_request *req)
2537 return ret; 2548 return ret;
2538} 2549}
2539 2550
2540static int aead_givdecrypt(struct aead_request *req)
2541{
2542 struct crypto_aead *aead = crypto_aead_reqtfm(req);
2543 unsigned int ivsize = crypto_aead_ivsize(aead);
2544
2545 if (req->cryptlen < ivsize)
2546 return -EINVAL;
2547
2548 req->cryptlen -= ivsize;
2549 req->assoclen += ivsize;
2550
2551 return aead_decrypt(req);
2552}
2553
2554/* 2551/*
2555 * allocate and map the ablkcipher extended descriptor for ablkcipher 2552 * allocate and map the ablkcipher extended descriptor for ablkcipher
2556 */ 2553 */
@@ -3210,7 +3207,7 @@ static struct caam_aead_alg driver_aeads[] = {
3210 .setkey = aead_setkey, 3207 .setkey = aead_setkey,
3211 .setauthsize = aead_setauthsize, 3208 .setauthsize = aead_setauthsize,
3212 .encrypt = aead_encrypt, 3209 .encrypt = aead_encrypt,
3213 .decrypt = aead_givdecrypt, 3210 .decrypt = aead_decrypt,
3214 .ivsize = AES_BLOCK_SIZE, 3211 .ivsize = AES_BLOCK_SIZE,
3215 .maxauthsize = MD5_DIGEST_SIZE, 3212 .maxauthsize = MD5_DIGEST_SIZE,
3216 }, 3213 },
@@ -3256,7 +3253,7 @@ static struct caam_aead_alg driver_aeads[] = {
3256 .setkey = aead_setkey, 3253 .setkey = aead_setkey,
3257 .setauthsize = aead_setauthsize, 3254 .setauthsize = aead_setauthsize,
3258 .encrypt = aead_encrypt, 3255 .encrypt = aead_encrypt,
3259 .decrypt = aead_givdecrypt, 3256 .decrypt = aead_decrypt,
3260 .ivsize = AES_BLOCK_SIZE, 3257 .ivsize = AES_BLOCK_SIZE,
3261 .maxauthsize = SHA1_DIGEST_SIZE, 3258 .maxauthsize = SHA1_DIGEST_SIZE,
3262 }, 3259 },
@@ -3302,7 +3299,7 @@ static struct caam_aead_alg driver_aeads[] = {
3302 .setkey = aead_setkey, 3299 .setkey = aead_setkey,
3303 .setauthsize = aead_setauthsize, 3300 .setauthsize = aead_setauthsize,
3304 .encrypt = aead_encrypt, 3301 .encrypt = aead_encrypt,
3305 .decrypt = aead_givdecrypt, 3302 .decrypt = aead_decrypt,
3306 .ivsize = AES_BLOCK_SIZE, 3303 .ivsize = AES_BLOCK_SIZE,
3307 .maxauthsize = SHA224_DIGEST_SIZE, 3304 .maxauthsize = SHA224_DIGEST_SIZE,
3308 }, 3305 },
@@ -3348,7 +3345,7 @@ static struct caam_aead_alg driver_aeads[] = {
3348 .setkey = aead_setkey, 3345 .setkey = aead_setkey,
3349 .setauthsize = aead_setauthsize, 3346 .setauthsize = aead_setauthsize,
3350 .encrypt = aead_encrypt, 3347 .encrypt = aead_encrypt,
3351 .decrypt = aead_givdecrypt, 3348 .decrypt = aead_decrypt,
3352 .ivsize = AES_BLOCK_SIZE, 3349 .ivsize = AES_BLOCK_SIZE,
3353 .maxauthsize = SHA256_DIGEST_SIZE, 3350 .maxauthsize = SHA256_DIGEST_SIZE,
3354 }, 3351 },
@@ -3394,7 +3391,7 @@ static struct caam_aead_alg driver_aeads[] = {
3394 .setkey = aead_setkey, 3391 .setkey = aead_setkey,
3395 .setauthsize = aead_setauthsize, 3392 .setauthsize = aead_setauthsize,
3396 .encrypt = aead_encrypt, 3393 .encrypt = aead_encrypt,
3397 .decrypt = aead_givdecrypt, 3394 .decrypt = aead_decrypt,
3398 .ivsize = AES_BLOCK_SIZE, 3395 .ivsize = AES_BLOCK_SIZE,
3399 .maxauthsize = SHA384_DIGEST_SIZE, 3396 .maxauthsize = SHA384_DIGEST_SIZE,
3400 }, 3397 },
@@ -3440,7 +3437,7 @@ static struct caam_aead_alg driver_aeads[] = {
3440 .setkey = aead_setkey, 3437 .setkey = aead_setkey,
3441 .setauthsize = aead_setauthsize, 3438 .setauthsize = aead_setauthsize,
3442 .encrypt = aead_encrypt, 3439 .encrypt = aead_encrypt,
3443 .decrypt = aead_givdecrypt, 3440 .decrypt = aead_decrypt,
3444 .ivsize = AES_BLOCK_SIZE, 3441 .ivsize = AES_BLOCK_SIZE,
3445 .maxauthsize = SHA512_DIGEST_SIZE, 3442 .maxauthsize = SHA512_DIGEST_SIZE,
3446 }, 3443 },
@@ -3486,7 +3483,7 @@ static struct caam_aead_alg driver_aeads[] = {
3486 .setkey = aead_setkey, 3483 .setkey = aead_setkey,
3487 .setauthsize = aead_setauthsize, 3484 .setauthsize = aead_setauthsize,
3488 .encrypt = aead_encrypt, 3485 .encrypt = aead_encrypt,
3489 .decrypt = aead_givdecrypt, 3486 .decrypt = aead_decrypt,
3490 .ivsize = DES3_EDE_BLOCK_SIZE, 3487 .ivsize = DES3_EDE_BLOCK_SIZE,
3491 .maxauthsize = MD5_DIGEST_SIZE, 3488 .maxauthsize = MD5_DIGEST_SIZE,
3492 }, 3489 },
@@ -3534,7 +3531,7 @@ static struct caam_aead_alg driver_aeads[] = {
3534 .setkey = aead_setkey, 3531 .setkey = aead_setkey,
3535 .setauthsize = aead_setauthsize, 3532 .setauthsize = aead_setauthsize,
3536 .encrypt = aead_encrypt, 3533 .encrypt = aead_encrypt,
3537 .decrypt = aead_givdecrypt, 3534 .decrypt = aead_decrypt,
3538 .ivsize = DES3_EDE_BLOCK_SIZE, 3535 .ivsize = DES3_EDE_BLOCK_SIZE,
3539 .maxauthsize = SHA1_DIGEST_SIZE, 3536 .maxauthsize = SHA1_DIGEST_SIZE,
3540 }, 3537 },
@@ -3582,7 +3579,7 @@ static struct caam_aead_alg driver_aeads[] = {
3582 .setkey = aead_setkey, 3579 .setkey = aead_setkey,
3583 .setauthsize = aead_setauthsize, 3580 .setauthsize = aead_setauthsize,
3584 .encrypt = aead_encrypt, 3581 .encrypt = aead_encrypt,
3585 .decrypt = aead_givdecrypt, 3582 .decrypt = aead_decrypt,
3586 .ivsize = DES3_EDE_BLOCK_SIZE, 3583 .ivsize = DES3_EDE_BLOCK_SIZE,
3587 .maxauthsize = SHA224_DIGEST_SIZE, 3584 .maxauthsize = SHA224_DIGEST_SIZE,
3588 }, 3585 },
@@ -3630,7 +3627,7 @@ static struct caam_aead_alg driver_aeads[] = {
3630 .setkey = aead_setkey, 3627 .setkey = aead_setkey,
3631 .setauthsize = aead_setauthsize, 3628 .setauthsize = aead_setauthsize,
3632 .encrypt = aead_encrypt, 3629 .encrypt = aead_encrypt,
3633 .decrypt = aead_givdecrypt, 3630 .decrypt = aead_decrypt,
3634 .ivsize = DES3_EDE_BLOCK_SIZE, 3631 .ivsize = DES3_EDE_BLOCK_SIZE,
3635 .maxauthsize = SHA256_DIGEST_SIZE, 3632 .maxauthsize = SHA256_DIGEST_SIZE,
3636 }, 3633 },
@@ -3678,7 +3675,7 @@ static struct caam_aead_alg driver_aeads[] = {
3678 .setkey = aead_setkey, 3675 .setkey = aead_setkey,
3679 .setauthsize = aead_setauthsize, 3676 .setauthsize = aead_setauthsize,
3680 .encrypt = aead_encrypt, 3677 .encrypt = aead_encrypt,
3681 .decrypt = aead_givdecrypt, 3678 .decrypt = aead_decrypt,
3682 .ivsize = DES3_EDE_BLOCK_SIZE, 3679 .ivsize = DES3_EDE_BLOCK_SIZE,
3683 .maxauthsize = SHA384_DIGEST_SIZE, 3680 .maxauthsize = SHA384_DIGEST_SIZE,
3684 }, 3681 },
@@ -3726,7 +3723,7 @@ static struct caam_aead_alg driver_aeads[] = {
3726 .setkey = aead_setkey, 3723 .setkey = aead_setkey,
3727 .setauthsize = aead_setauthsize, 3724 .setauthsize = aead_setauthsize,
3728 .encrypt = aead_encrypt, 3725 .encrypt = aead_encrypt,
3729 .decrypt = aead_givdecrypt, 3726 .decrypt = aead_decrypt,
3730 .ivsize = DES3_EDE_BLOCK_SIZE, 3727 .ivsize = DES3_EDE_BLOCK_SIZE,
3731 .maxauthsize = SHA512_DIGEST_SIZE, 3728 .maxauthsize = SHA512_DIGEST_SIZE,
3732 }, 3729 },
@@ -3772,7 +3769,7 @@ static struct caam_aead_alg driver_aeads[] = {
3772 .setkey = aead_setkey, 3769 .setkey = aead_setkey,
3773 .setauthsize = aead_setauthsize, 3770 .setauthsize = aead_setauthsize,
3774 .encrypt = aead_encrypt, 3771 .encrypt = aead_encrypt,
3775 .decrypt = aead_givdecrypt, 3772 .decrypt = aead_decrypt,
3776 .ivsize = DES_BLOCK_SIZE, 3773 .ivsize = DES_BLOCK_SIZE,
3777 .maxauthsize = MD5_DIGEST_SIZE, 3774 .maxauthsize = MD5_DIGEST_SIZE,
3778 }, 3775 },
@@ -3818,7 +3815,7 @@ static struct caam_aead_alg driver_aeads[] = {
3818 .setkey = aead_setkey, 3815 .setkey = aead_setkey,
3819 .setauthsize = aead_setauthsize, 3816 .setauthsize = aead_setauthsize,
3820 .encrypt = aead_encrypt, 3817 .encrypt = aead_encrypt,
3821 .decrypt = aead_givdecrypt, 3818 .decrypt = aead_decrypt,
3822 .ivsize = DES_BLOCK_SIZE, 3819 .ivsize = DES_BLOCK_SIZE,
3823 .maxauthsize = SHA1_DIGEST_SIZE, 3820 .maxauthsize = SHA1_DIGEST_SIZE,
3824 }, 3821 },
@@ -3864,7 +3861,7 @@ static struct caam_aead_alg driver_aeads[] = {
3864 .setkey = aead_setkey, 3861 .setkey = aead_setkey,
3865 .setauthsize = aead_setauthsize, 3862 .setauthsize = aead_setauthsize,
3866 .encrypt = aead_encrypt, 3863 .encrypt = aead_encrypt,
3867 .decrypt = aead_givdecrypt, 3864 .decrypt = aead_decrypt,
3868 .ivsize = DES_BLOCK_SIZE, 3865 .ivsize = DES_BLOCK_SIZE,
3869 .maxauthsize = SHA224_DIGEST_SIZE, 3866 .maxauthsize = SHA224_DIGEST_SIZE,
3870 }, 3867 },
@@ -3910,7 +3907,7 @@ static struct caam_aead_alg driver_aeads[] = {
3910 .setkey = aead_setkey, 3907 .setkey = aead_setkey,
3911 .setauthsize = aead_setauthsize, 3908 .setauthsize = aead_setauthsize,
3912 .encrypt = aead_encrypt, 3909 .encrypt = aead_encrypt,
3913 .decrypt = aead_givdecrypt, 3910 .decrypt = aead_decrypt,
3914 .ivsize = DES_BLOCK_SIZE, 3911 .ivsize = DES_BLOCK_SIZE,
3915 .maxauthsize = SHA256_DIGEST_SIZE, 3912 .maxauthsize = SHA256_DIGEST_SIZE,
3916 }, 3913 },
@@ -3956,7 +3953,7 @@ static struct caam_aead_alg driver_aeads[] = {
3956 .setkey = aead_setkey, 3953 .setkey = aead_setkey,
3957 .setauthsize = aead_setauthsize, 3954 .setauthsize = aead_setauthsize,
3958 .encrypt = aead_encrypt, 3955 .encrypt = aead_encrypt,
3959 .decrypt = aead_givdecrypt, 3956 .decrypt = aead_decrypt,
3960 .ivsize = DES_BLOCK_SIZE, 3957 .ivsize = DES_BLOCK_SIZE,
3961 .maxauthsize = SHA384_DIGEST_SIZE, 3958 .maxauthsize = SHA384_DIGEST_SIZE,
3962 }, 3959 },
@@ -4002,7 +3999,7 @@ static struct caam_aead_alg driver_aeads[] = {
4002 .setkey = aead_setkey, 3999 .setkey = aead_setkey,
4003 .setauthsize = aead_setauthsize, 4000 .setauthsize = aead_setauthsize,
4004 .encrypt = aead_encrypt, 4001 .encrypt = aead_encrypt,
4005 .decrypt = aead_givdecrypt, 4002 .decrypt = aead_decrypt,
4006 .ivsize = DES_BLOCK_SIZE, 4003 .ivsize = DES_BLOCK_SIZE,
4007 .maxauthsize = SHA512_DIGEST_SIZE, 4004 .maxauthsize = SHA512_DIGEST_SIZE,
4008 }, 4005 },
@@ -4051,7 +4048,7 @@ static struct caam_aead_alg driver_aeads[] = {
4051 .setkey = aead_setkey, 4048 .setkey = aead_setkey,
4052 .setauthsize = aead_setauthsize, 4049 .setauthsize = aead_setauthsize,
4053 .encrypt = aead_encrypt, 4050 .encrypt = aead_encrypt,
4054 .decrypt = aead_givdecrypt, 4051 .decrypt = aead_decrypt,
4055 .ivsize = CTR_RFC3686_IV_SIZE, 4052 .ivsize = CTR_RFC3686_IV_SIZE,
4056 .maxauthsize = MD5_DIGEST_SIZE, 4053 .maxauthsize = MD5_DIGEST_SIZE,
4057 }, 4054 },
@@ -4102,7 +4099,7 @@ static struct caam_aead_alg driver_aeads[] = {
4102 .setkey = aead_setkey, 4099 .setkey = aead_setkey,
4103 .setauthsize = aead_setauthsize, 4100 .setauthsize = aead_setauthsize,
4104 .encrypt = aead_encrypt, 4101 .encrypt = aead_encrypt,
4105 .decrypt = aead_givdecrypt, 4102 .decrypt = aead_decrypt,
4106 .ivsize = CTR_RFC3686_IV_SIZE, 4103 .ivsize = CTR_RFC3686_IV_SIZE,
4107 .maxauthsize = SHA1_DIGEST_SIZE, 4104 .maxauthsize = SHA1_DIGEST_SIZE,
4108 }, 4105 },
@@ -4153,7 +4150,7 @@ static struct caam_aead_alg driver_aeads[] = {
4153 .setkey = aead_setkey, 4150 .setkey = aead_setkey,
4154 .setauthsize = aead_setauthsize, 4151 .setauthsize = aead_setauthsize,
4155 .encrypt = aead_encrypt, 4152 .encrypt = aead_encrypt,
4156 .decrypt = aead_givdecrypt, 4153 .decrypt = aead_decrypt,
4157 .ivsize = CTR_RFC3686_IV_SIZE, 4154 .ivsize = CTR_RFC3686_IV_SIZE,
4158 .maxauthsize = SHA224_DIGEST_SIZE, 4155 .maxauthsize = SHA224_DIGEST_SIZE,
4159 }, 4156 },
@@ -4204,7 +4201,7 @@ static struct caam_aead_alg driver_aeads[] = {
4204 .setkey = aead_setkey, 4201 .setkey = aead_setkey,
4205 .setauthsize = aead_setauthsize, 4202 .setauthsize = aead_setauthsize,
4206 .encrypt = aead_encrypt, 4203 .encrypt = aead_encrypt,
4207 .decrypt = aead_givdecrypt, 4204 .decrypt = aead_decrypt,
4208 .ivsize = CTR_RFC3686_IV_SIZE, 4205 .ivsize = CTR_RFC3686_IV_SIZE,
4209 .maxauthsize = SHA256_DIGEST_SIZE, 4206 .maxauthsize = SHA256_DIGEST_SIZE,
4210 }, 4207 },
@@ -4255,7 +4252,7 @@ static struct caam_aead_alg driver_aeads[] = {
4255 .setkey = aead_setkey, 4252 .setkey = aead_setkey,
4256 .setauthsize = aead_setauthsize, 4253 .setauthsize = aead_setauthsize,
4257 .encrypt = aead_encrypt, 4254 .encrypt = aead_encrypt,
4258 .decrypt = aead_givdecrypt, 4255 .decrypt = aead_decrypt,
4259 .ivsize = CTR_RFC3686_IV_SIZE, 4256 .ivsize = CTR_RFC3686_IV_SIZE,
4260 .maxauthsize = SHA384_DIGEST_SIZE, 4257 .maxauthsize = SHA384_DIGEST_SIZE,
4261 }, 4258 },
@@ -4306,7 +4303,7 @@ static struct caam_aead_alg driver_aeads[] = {
4306 .setkey = aead_setkey, 4303 .setkey = aead_setkey,
4307 .setauthsize = aead_setauthsize, 4304 .setauthsize = aead_setauthsize,
4308 .encrypt = aead_encrypt, 4305 .encrypt = aead_encrypt,
4309 .decrypt = aead_givdecrypt, 4306 .decrypt = aead_decrypt,
4310 .ivsize = CTR_RFC3686_IV_SIZE, 4307 .ivsize = CTR_RFC3686_IV_SIZE,
4311 .maxauthsize = SHA512_DIGEST_SIZE, 4308 .maxauthsize = SHA512_DIGEST_SIZE,
4312 }, 4309 },
diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
index 769148dbaeb3..20f35df8a01f 100644
--- a/drivers/crypto/qat/qat_common/qat_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_algs.c
@@ -1260,8 +1260,8 @@ static struct crypto_alg qat_algs[] = { {
1260 .setkey = qat_alg_ablkcipher_xts_setkey, 1260 .setkey = qat_alg_ablkcipher_xts_setkey,
1261 .decrypt = qat_alg_ablkcipher_decrypt, 1261 .decrypt = qat_alg_ablkcipher_decrypt,
1262 .encrypt = qat_alg_ablkcipher_encrypt, 1262 .encrypt = qat_alg_ablkcipher_encrypt,
1263 .min_keysize = AES_MIN_KEY_SIZE, 1263 .min_keysize = 2 * AES_MIN_KEY_SIZE,
1264 .max_keysize = AES_MAX_KEY_SIZE, 1264 .max_keysize = 2 * AES_MAX_KEY_SIZE,
1265 .ivsize = AES_BLOCK_SIZE, 1265 .ivsize = AES_BLOCK_SIZE,
1266 }, 1266 },
1267 }, 1267 },
diff --git a/drivers/crypto/vmx/aes_xts.c b/drivers/crypto/vmx/aes_xts.c
index cfb25413917c..24353ec336c5 100644
--- a/drivers/crypto/vmx/aes_xts.c
+++ b/drivers/crypto/vmx/aes_xts.c
@@ -129,8 +129,8 @@ static int p8_aes_xts_crypt(struct blkcipher_desc *desc,
129 129
130 blkcipher_walk_init(&walk, dst, src, nbytes); 130 blkcipher_walk_init(&walk, dst, src, nbytes);
131 131
132 iv = (u8 *)walk.iv;
133 ret = blkcipher_walk_virt(desc, &walk); 132 ret = blkcipher_walk_virt(desc, &walk);
133 iv = walk.iv;
134 memset(tweak, 0, AES_BLOCK_SIZE); 134 memset(tweak, 0, AES_BLOCK_SIZE);
135 aes_p8_encrypt(iv, tweak, &ctx->tweak_key); 135 aes_p8_encrypt(iv, tweak, &ctx->tweak_key);
136 136
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index e434ffe7bc5c..832cbd647145 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -2067,7 +2067,7 @@ err_dma_unregister:
2067err_clk_disable: 2067err_clk_disable:
2068 clk_disable_unprepare(atxdmac->clk); 2068 clk_disable_unprepare(atxdmac->clk);
2069err_free_irq: 2069err_free_irq:
2070 free_irq(atxdmac->irq, atxdmac->dma.dev); 2070 free_irq(atxdmac->irq, atxdmac);
2071 return ret; 2071 return ret;
2072} 2072}
2073 2073
@@ -2081,7 +2081,7 @@ static int at_xdmac_remove(struct platform_device *pdev)
2081 dma_async_device_unregister(&atxdmac->dma); 2081 dma_async_device_unregister(&atxdmac->dma);
2082 clk_disable_unprepare(atxdmac->clk); 2082 clk_disable_unprepare(atxdmac->clk);
2083 2083
2084 free_irq(atxdmac->irq, atxdmac->dma.dev); 2084 free_irq(atxdmac->irq, atxdmac);
2085 2085
2086 for (i = 0; i < atxdmac->dma.chancnt; i++) { 2086 for (i = 0; i < atxdmac->dma.chancnt; i++) {
2087 struct at_xdmac_chan *atchan = &atxdmac->chan[i]; 2087 struct at_xdmac_chan *atchan = &atxdmac->chan[i];
diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c
index aad167eaaee8..de2a2a2b1d75 100644
--- a/drivers/dma/fsl_raid.c
+++ b/drivers/dma/fsl_raid.c
@@ -836,6 +836,7 @@ static int fsl_re_probe(struct platform_device *ofdev)
836 rc = of_property_read_u32(np, "reg", &off); 836 rc = of_property_read_u32(np, "reg", &off);
837 if (rc) { 837 if (rc) {
838 dev_err(dev, "Reg property not found in JQ node\n"); 838 dev_err(dev, "Reg property not found in JQ node\n");
839 of_node_put(np);
839 return -ENODEV; 840 return -ENODEV;
840 } 841 }
841 /* Find out the Job Rings present under each JQ */ 842 /* Find out the Job Rings present under each JQ */
diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c
index a4c53be482cf..624f1e1e9c55 100644
--- a/drivers/dma/img-mdc-dma.c
+++ b/drivers/dma/img-mdc-dma.c
@@ -861,7 +861,6 @@ static int mdc_dma_probe(struct platform_device *pdev)
861{ 861{
862 struct mdc_dma *mdma; 862 struct mdc_dma *mdma;
863 struct resource *res; 863 struct resource *res;
864 const struct of_device_id *match;
865 unsigned int i; 864 unsigned int i;
866 u32 val; 865 u32 val;
867 int ret; 866 int ret;
@@ -871,8 +870,7 @@ static int mdc_dma_probe(struct platform_device *pdev)
871 return -ENOMEM; 870 return -ENOMEM;
872 platform_set_drvdata(pdev, mdma); 871 platform_set_drvdata(pdev, mdma);
873 872
874 match = of_match_device(mdc_dma_of_match, &pdev->dev); 873 mdma->soc = of_device_get_match_data(&pdev->dev);
875 mdma->soc = match->data;
876 874
877 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 875 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
878 mdma->regs = devm_ioremap_resource(&pdev->dev, res); 876 mdma->regs = devm_ioremap_resource(&pdev->dev, res);
diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index dc7850a422b8..3f56f9ca4482 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -638,7 +638,7 @@ static bool pxad_try_hotchain(struct virt_dma_chan *vc,
638 vd_last_issued = list_entry(vc->desc_issued.prev, 638 vd_last_issued = list_entry(vc->desc_issued.prev,
639 struct virt_dma_desc, node); 639 struct virt_dma_desc, node);
640 pxad_desc_chain(vd_last_issued, vd); 640 pxad_desc_chain(vd_last_issued, vd);
641 if (is_chan_running(chan) || is_desc_completed(vd_last_issued)) 641 if (is_chan_running(chan) || is_desc_completed(vd))
642 return true; 642 return true;
643 } 643 }
644 644
@@ -671,6 +671,7 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
671 struct virt_dma_desc *vd, *tmp; 671 struct virt_dma_desc *vd, *tmp;
672 unsigned int dcsr; 672 unsigned int dcsr;
673 unsigned long flags; 673 unsigned long flags;
674 bool vd_completed;
674 dma_cookie_t last_started = 0; 675 dma_cookie_t last_started = 0;
675 676
676 BUG_ON(!chan); 677 BUG_ON(!chan);
@@ -681,15 +682,17 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
681 682
682 spin_lock_irqsave(&chan->vc.lock, flags); 683 spin_lock_irqsave(&chan->vc.lock, flags);
683 list_for_each_entry_safe(vd, tmp, &chan->vc.desc_issued, node) { 684 list_for_each_entry_safe(vd, tmp, &chan->vc.desc_issued, node) {
685 vd_completed = is_desc_completed(vd);
684 dev_dbg(&chan->vc.chan.dev->device, 686 dev_dbg(&chan->vc.chan.dev->device,
685 "%s(): checking txd %p[%x]: completed=%d\n", 687 "%s(): checking txd %p[%x]: completed=%d dcsr=0x%x\n",
686 __func__, vd, vd->tx.cookie, is_desc_completed(vd)); 688 __func__, vd, vd->tx.cookie, vd_completed,
689 dcsr);
687 last_started = vd->tx.cookie; 690 last_started = vd->tx.cookie;
688 if (to_pxad_sw_desc(vd)->cyclic) { 691 if (to_pxad_sw_desc(vd)->cyclic) {
689 vchan_cyclic_callback(vd); 692 vchan_cyclic_callback(vd);
690 break; 693 break;
691 } 694 }
692 if (is_desc_completed(vd)) { 695 if (vd_completed) {
693 list_del(&vd->node); 696 list_del(&vd->node);
694 vchan_cookie_complete(vd); 697 vchan_cookie_complete(vd);
695 } else { 698 } else {
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index 749f1bd5d65d..06ecdc38cee0 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -600,27 +600,30 @@ static irqreturn_t usb_dmac_isr_channel(int irq, void *dev)
600{ 600{
601 struct usb_dmac_chan *chan = dev; 601 struct usb_dmac_chan *chan = dev;
602 irqreturn_t ret = IRQ_NONE; 602 irqreturn_t ret = IRQ_NONE;
603 u32 mask = USB_DMACHCR_TE; 603 u32 mask = 0;
604 u32 check_bits = USB_DMACHCR_TE | USB_DMACHCR_SP;
605 u32 chcr; 604 u32 chcr;
605 bool xfer_end = false;
606 606
607 spin_lock(&chan->vc.lock); 607 spin_lock(&chan->vc.lock);
608 608
609 chcr = usb_dmac_chan_read(chan, USB_DMACHCR); 609 chcr = usb_dmac_chan_read(chan, USB_DMACHCR);
610 if (chcr & check_bits) 610 if (chcr & (USB_DMACHCR_TE | USB_DMACHCR_SP)) {
611 mask |= USB_DMACHCR_DE | check_bits; 611 mask |= USB_DMACHCR_DE | USB_DMACHCR_TE | USB_DMACHCR_SP;
612 if (chcr & USB_DMACHCR_DE)
613 xfer_end = true;
614 ret |= IRQ_HANDLED;
615 }
612 if (chcr & USB_DMACHCR_NULL) { 616 if (chcr & USB_DMACHCR_NULL) {
613 /* An interruption of TE will happen after we set FTE */ 617 /* An interruption of TE will happen after we set FTE */
614 mask |= USB_DMACHCR_NULL; 618 mask |= USB_DMACHCR_NULL;
615 chcr |= USB_DMACHCR_FTE; 619 chcr |= USB_DMACHCR_FTE;
616 ret |= IRQ_HANDLED; 620 ret |= IRQ_HANDLED;
617 } 621 }
618 usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask); 622 if (mask)
623 usb_dmac_chan_write(chan, USB_DMACHCR, chcr & ~mask);
619 624
620 if (chcr & check_bits) { 625 if (xfer_end)
621 usb_dmac_isr_transfer_end(chan); 626 usb_dmac_isr_transfer_end(chan);
622 ret |= IRQ_HANDLED;
623 }
624 627
625 spin_unlock(&chan->vc.lock); 628 spin_unlock(&chan->vc.lock);
626 629
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index a31d7ef3032c..ec1282af2479 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -280,7 +280,7 @@ void amdgpu_ib_pool_fini(struct amdgpu_device *adev)
280int amdgpu_ib_ring_tests(struct amdgpu_device *adev) 280int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
281{ 281{
282 unsigned i; 282 unsigned i;
283 int r; 283 int r, ret = 0;
284 284
285 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { 285 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
286 struct amdgpu_ring *ring = adev->rings[i]; 286 struct amdgpu_ring *ring = adev->rings[i];
@@ -301,10 +301,11 @@ int amdgpu_ib_ring_tests(struct amdgpu_device *adev)
301 } else { 301 } else {
302 /* still not good, but we can live with it */ 302 /* still not good, but we can live with it */
303 DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r); 303 DRM_ERROR("amdgpu: failed testing IB on ring %d (%d).\n", i, r);
304 ret = r;
304 } 305 }
305 } 306 }
306 } 307 }
307 return 0; 308 return ret;
308} 309}
309 310
310/* 311/*
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index ee6466912497..77fdd9911c3c 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -52,6 +52,7 @@ static void cik_sdma_set_ring_funcs(struct amdgpu_device *adev);
52static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev); 52static void cik_sdma_set_irq_funcs(struct amdgpu_device *adev);
53static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev); 53static void cik_sdma_set_buffer_funcs(struct amdgpu_device *adev);
54static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev); 54static void cik_sdma_set_vm_pte_funcs(struct amdgpu_device *adev);
55static int cik_sdma_soft_reset(void *handle);
55 56
56MODULE_FIRMWARE("radeon/bonaire_sdma.bin"); 57MODULE_FIRMWARE("radeon/bonaire_sdma.bin");
57MODULE_FIRMWARE("radeon/bonaire_sdma1.bin"); 58MODULE_FIRMWARE("radeon/bonaire_sdma1.bin");
@@ -1037,6 +1038,8 @@ static int cik_sdma_resume(void *handle)
1037{ 1038{
1038 struct amdgpu_device *adev = (struct amdgpu_device *)handle; 1039 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1039 1040
1041 cik_sdma_soft_reset(handle);
1042
1040 return cik_sdma_hw_init(adev); 1043 return cik_sdma_hw_init(adev);
1041} 1044}
1042 1045
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index d869d058ef24..425413fcaf02 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -2755,8 +2755,7 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev)
2755 u64 wb_gpu_addr; 2755 u64 wb_gpu_addr;
2756 u32 *buf; 2756 u32 *buf;
2757 struct bonaire_mqd *mqd; 2757 struct bonaire_mqd *mqd;
2758 2758 struct amdgpu_ring *ring;
2759 gfx_v7_0_cp_compute_enable(adev, true);
2760 2759
2761 /* fix up chicken bits */ 2760 /* fix up chicken bits */
2762 tmp = RREG32(mmCP_CPF_DEBUG); 2761 tmp = RREG32(mmCP_CPF_DEBUG);
@@ -2791,7 +2790,7 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev)
2791 2790
2792 /* init the queues. Just two for now. */ 2791 /* init the queues. Just two for now. */
2793 for (i = 0; i < adev->gfx.num_compute_rings; i++) { 2792 for (i = 0; i < adev->gfx.num_compute_rings; i++) {
2794 struct amdgpu_ring *ring = &adev->gfx.compute_ring[i]; 2793 ring = &adev->gfx.compute_ring[i];
2795 2794
2796 if (ring->mqd_obj == NULL) { 2795 if (ring->mqd_obj == NULL) {
2797 r = amdgpu_bo_create(adev, 2796 r = amdgpu_bo_create(adev,
@@ -2970,6 +2969,13 @@ static int gfx_v7_0_cp_compute_resume(struct amdgpu_device *adev)
2970 amdgpu_bo_unreserve(ring->mqd_obj); 2969 amdgpu_bo_unreserve(ring->mqd_obj);
2971 2970
2972 ring->ready = true; 2971 ring->ready = true;
2972 }
2973
2974 gfx_v7_0_cp_compute_enable(adev, true);
2975
2976 for (i = 0; i < adev->gfx.num_compute_rings; i++) {
2977 ring = &adev->gfx.compute_ring[i];
2978
2973 r = amdgpu_ring_test_ring(ring); 2979 r = amdgpu_ring_test_ring(ring);
2974 if (r) 2980 if (r)
2975 ring->ready = false; 2981 ring->ready = false;
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c
index 9f7dafce3a4c..7bf90e9e6139 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -171,10 +171,34 @@ static void imx_drm_output_poll_changed(struct drm_device *drm)
171 drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); 171 drm_fbdev_cma_hotplug_event(imxdrm->fbhelper);
172} 172}
173 173
174static int imx_drm_atomic_check(struct drm_device *dev,
175 struct drm_atomic_state *state)
176{
177 int ret;
178
179 ret = drm_atomic_helper_check_modeset(dev, state);
180 if (ret)
181 return ret;
182
183 ret = drm_atomic_helper_check_planes(dev, state);
184 if (ret)
185 return ret;
186
187 /*
188 * Check modeset again in case crtc_state->mode_changed is
189 * updated in plane's ->atomic_check callback.
190 */
191 ret = drm_atomic_helper_check_modeset(dev, state);
192 if (ret)
193 return ret;
194
195 return ret;
196}
197
174static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { 198static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
175 .fb_create = drm_fb_cma_create, 199 .fb_create = drm_fb_cma_create,
176 .output_poll_changed = imx_drm_output_poll_changed, 200 .output_poll_changed = imx_drm_output_poll_changed,
177 .atomic_check = drm_atomic_helper_check, 201 .atomic_check = imx_drm_atomic_check,
178 .atomic_commit = drm_atomic_helper_commit, 202 .atomic_commit = drm_atomic_helper_commit,
179}; 203};
180 204
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index 08e188bc10fc..462056e4b9e4 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -76,6 +76,8 @@ static void ipu_crtc_disable(struct drm_crtc *crtc)
76 crtc->state->event = NULL; 76 crtc->state->event = NULL;
77 } 77 }
78 spin_unlock_irq(&crtc->dev->event_lock); 78 spin_unlock_irq(&crtc->dev->event_lock);
79
80 drm_crtc_vblank_off(crtc);
79} 81}
80 82
81static void imx_drm_crtc_reset(struct drm_crtc *crtc) 83static void imx_drm_crtc_reset(struct drm_crtc *crtc)
@@ -175,6 +177,8 @@ static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
175static void ipu_crtc_atomic_begin(struct drm_crtc *crtc, 177static void ipu_crtc_atomic_begin(struct drm_crtc *crtc,
176 struct drm_crtc_state *old_crtc_state) 178 struct drm_crtc_state *old_crtc_state)
177{ 179{
180 drm_crtc_vblank_on(crtc);
181
178 spin_lock_irq(&crtc->dev->event_lock); 182 spin_lock_irq(&crtc->dev->event_lock);
179 if (crtc->state->event) { 183 if (crtc->state->event) {
180 WARN_ON(drm_crtc_vblank_get(crtc)); 184 WARN_ON(drm_crtc_vblank_get(crtc));
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c
index 4ad67d015ec7..29423e757d36 100644
--- a/drivers/gpu/drm/imx/ipuv3-plane.c
+++ b/drivers/gpu/drm/imx/ipuv3-plane.c
@@ -319,13 +319,14 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
319 return -EINVAL; 319 return -EINVAL;
320 320
321 /* 321 /*
322 * since we cannot touch active IDMAC channels, we do not support 322 * We support resizing active plane or changing its format by
323 * resizing the enabled plane or changing its format 323 * forcing CRTC mode change and disabling-enabling plane in plane's
324 * ->atomic_update callback.
324 */ 325 */
325 if (old_fb && (state->src_w != old_state->src_w || 326 if (old_fb && (state->src_w != old_state->src_w ||
326 state->src_h != old_state->src_h || 327 state->src_h != old_state->src_h ||
327 fb->pixel_format != old_fb->pixel_format)) 328 fb->pixel_format != old_fb->pixel_format))
328 return -EINVAL; 329 crtc_state->mode_changed = true;
329 330
330 eba = drm_plane_state_to_eba(state); 331 eba = drm_plane_state_to_eba(state);
331 332
@@ -336,7 +337,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
336 return -EINVAL; 337 return -EINVAL;
337 338
338 if (old_fb && fb->pitches[0] != old_fb->pitches[0]) 339 if (old_fb && fb->pitches[0] != old_fb->pitches[0])
339 return -EINVAL; 340 crtc_state->mode_changed = true;
340 341
341 switch (fb->pixel_format) { 342 switch (fb->pixel_format) {
342 case DRM_FORMAT_YUV420: 343 case DRM_FORMAT_YUV420:
@@ -372,7 +373,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
372 return -EINVAL; 373 return -EINVAL;
373 374
374 if (old_fb && old_fb->pitches[1] != fb->pitches[1]) 375 if (old_fb && old_fb->pitches[1] != fb->pitches[1])
375 return -EINVAL; 376 crtc_state->mode_changed = true;
376 } 377 }
377 378
378 return 0; 379 return 0;
@@ -392,8 +393,14 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
392 enum ipu_color_space ics; 393 enum ipu_color_space ics;
393 394
394 if (old_state->fb) { 395 if (old_state->fb) {
395 ipu_plane_atomic_set_base(ipu_plane, old_state); 396 struct drm_crtc_state *crtc_state = state->crtc->state;
396 return; 397
398 if (!crtc_state->mode_changed) {
399 ipu_plane_atomic_set_base(ipu_plane, old_state);
400 return;
401 }
402
403 ipu_disable_plane(plane);
397 } 404 }
398 405
399 switch (ipu_plane->dp_flow) { 406 switch (ipu_plane->dp_flow) {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index b4bc7f1ef717..d0da52f2a806 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -157,6 +157,12 @@ struct msm_drm_private {
157 struct shrinker shrinker; 157 struct shrinker shrinker;
158 158
159 struct msm_vblank_ctrl vblank_ctrl; 159 struct msm_vblank_ctrl vblank_ctrl;
160
161 /* task holding struct_mutex.. currently only used in submit path
162 * to detect and reject faults from copy_from_user() for submit
163 * ioctl.
164 */
165 struct task_struct *struct_mutex_task;
160}; 166};
161 167
162struct msm_format { 168struct msm_format {
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 6cd4af443139..85f3047e05ae 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -196,11 +196,20 @@ int msm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
196{ 196{
197 struct drm_gem_object *obj = vma->vm_private_data; 197 struct drm_gem_object *obj = vma->vm_private_data;
198 struct drm_device *dev = obj->dev; 198 struct drm_device *dev = obj->dev;
199 struct msm_drm_private *priv = dev->dev_private;
199 struct page **pages; 200 struct page **pages;
200 unsigned long pfn; 201 unsigned long pfn;
201 pgoff_t pgoff; 202 pgoff_t pgoff;
202 int ret; 203 int ret;
203 204
205 /* This should only happen if userspace tries to pass a mmap'd
206 * but unfaulted gem bo vaddr into submit ioctl, triggering
207 * a page fault while struct_mutex is already held. This is
208 * not a valid use-case so just bail.
209 */
210 if (priv->struct_mutex_task == current)
211 return VM_FAULT_SIGBUS;
212
204 /* Make sure we don't parallel update on a fault, nor move or remove 213 /* Make sure we don't parallel update on a fault, nor move or remove
205 * something from beneath our feet 214 * something from beneath our feet
206 */ 215 */
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 9766f9ae4b7d..880d6a9af7c8 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -64,6 +64,14 @@ void msm_gem_submit_free(struct msm_gem_submit *submit)
64 kfree(submit); 64 kfree(submit);
65} 65}
66 66
67static inline unsigned long __must_check
68copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
69{
70 if (access_ok(VERIFY_READ, from, n))
71 return __copy_from_user_inatomic(to, from, n);
72 return -EFAULT;
73}
74
67static int submit_lookup_objects(struct msm_gem_submit *submit, 75static int submit_lookup_objects(struct msm_gem_submit *submit,
68 struct drm_msm_gem_submit *args, struct drm_file *file) 76 struct drm_msm_gem_submit *args, struct drm_file *file)
69{ 77{
@@ -71,6 +79,7 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
71 int ret = 0; 79 int ret = 0;
72 80
73 spin_lock(&file->table_lock); 81 spin_lock(&file->table_lock);
82 pagefault_disable();
74 83
75 for (i = 0; i < args->nr_bos; i++) { 84 for (i = 0; i < args->nr_bos; i++) {
76 struct drm_msm_gem_submit_bo submit_bo; 85 struct drm_msm_gem_submit_bo submit_bo;
@@ -84,10 +93,15 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
84 */ 93 */
85 submit->bos[i].flags = 0; 94 submit->bos[i].flags = 0;
86 95
87 ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); 96 ret = copy_from_user_inatomic(&submit_bo, userptr, sizeof(submit_bo));
88 if (ret) { 97 if (unlikely(ret)) {
89 ret = -EFAULT; 98 pagefault_enable();
90 goto out_unlock; 99 spin_unlock(&file->table_lock);
100 ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo));
101 if (ret)
102 goto out;
103 spin_lock(&file->table_lock);
104 pagefault_disable();
91 } 105 }
92 106
93 if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) { 107 if (submit_bo.flags & ~MSM_SUBMIT_BO_FLAGS) {
@@ -127,9 +141,12 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
127 } 141 }
128 142
129out_unlock: 143out_unlock:
130 submit->nr_bos = i; 144 pagefault_enable();
131 spin_unlock(&file->table_lock); 145 spin_unlock(&file->table_lock);
132 146
147out:
148 submit->nr_bos = i;
149
133 return ret; 150 return ret;
134} 151}
135 152
@@ -377,6 +394,8 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
377 if (ret) 394 if (ret)
378 return ret; 395 return ret;
379 396
397 priv->struct_mutex_task = current;
398
380 submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds); 399 submit = submit_create(dev, gpu, args->nr_bos, args->nr_cmds);
381 if (!submit) { 400 if (!submit) {
382 ret = -ENOMEM; 401 ret = -ENOMEM;
@@ -468,6 +487,7 @@ out:
468 if (ret) 487 if (ret)
469 msm_gem_submit_free(submit); 488 msm_gem_submit_free(submit);
470out_unlock: 489out_unlock:
490 priv->struct_mutex_task = NULL;
471 mutex_unlock(&dev->struct_mutex); 491 mutex_unlock(&dev->struct_mutex);
472 return ret; 492 return ret;
473} 493}
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index f2ad17aa33f0..dc57b628e074 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -225,6 +225,17 @@ static bool nouveau_pr3_present(struct pci_dev *pdev)
225 if (!parent_pdev) 225 if (!parent_pdev)
226 return false; 226 return false;
227 227
228 if (!parent_pdev->bridge_d3) {
229 /*
230 * Parent PCI bridge is currently not power managed.
231 * Since userspace can change these afterwards to be on
232 * the safe side we stick with _DSM and prevent usage of
233 * _PR3 from the bridge.
234 */
235 pci_d3cold_disable(pdev);
236 return false;
237 }
238
228 parent_adev = ACPI_COMPANION(&parent_pdev->dev); 239 parent_adev = ACPI_COMPANION(&parent_pdev->dev);
229 if (!parent_adev) 240 if (!parent_adev)
230 return false; 241 return false;
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 8b42d31a7f0e..9ecef9385491 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -57,21 +57,21 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
57 switch (args->param) { 57 switch (args->param) {
58 case DRM_VC4_PARAM_V3D_IDENT0: 58 case DRM_VC4_PARAM_V3D_IDENT0:
59 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); 59 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
60 if (ret) 60 if (ret < 0)
61 return ret; 61 return ret;
62 args->value = V3D_READ(V3D_IDENT0); 62 args->value = V3D_READ(V3D_IDENT0);
63 pm_runtime_put(&vc4->v3d->pdev->dev); 63 pm_runtime_put(&vc4->v3d->pdev->dev);
64 break; 64 break;
65 case DRM_VC4_PARAM_V3D_IDENT1: 65 case DRM_VC4_PARAM_V3D_IDENT1:
66 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); 66 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
67 if (ret) 67 if (ret < 0)
68 return ret; 68 return ret;
69 args->value = V3D_READ(V3D_IDENT1); 69 args->value = V3D_READ(V3D_IDENT1);
70 pm_runtime_put(&vc4->v3d->pdev->dev); 70 pm_runtime_put(&vc4->v3d->pdev->dev);
71 break; 71 break;
72 case DRM_VC4_PARAM_V3D_IDENT2: 72 case DRM_VC4_PARAM_V3D_IDENT2:
73 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev); 73 ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
74 if (ret) 74 if (ret < 0)
75 return ret; 75 return ret;
76 args->value = V3D_READ(V3D_IDENT2); 76 args->value = V3D_READ(V3D_IDENT2);
77 pm_runtime_put(&vc4->v3d->pdev->dev); 77 pm_runtime_put(&vc4->v3d->pdev->dev);
diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 489e3de0c050..428e24919ef1 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -321,6 +321,15 @@ vc4_first_render_job(struct vc4_dev *vc4)
321 struct vc4_exec_info, head); 321 struct vc4_exec_info, head);
322} 322}
323 323
324static inline struct vc4_exec_info *
325vc4_last_render_job(struct vc4_dev *vc4)
326{
327 if (list_empty(&vc4->render_job_list))
328 return NULL;
329 return list_last_entry(&vc4->render_job_list,
330 struct vc4_exec_info, head);
331}
332
324/** 333/**
325 * struct vc4_texture_sample_info - saves the offsets into the UBO for texture 334 * struct vc4_texture_sample_info - saves the offsets into the UBO for texture
326 * setup parameters. 335 * setup parameters.
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 6155e8aca1c6..b262c5c26f10 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -534,8 +534,8 @@ vc4_cl_lookup_bos(struct drm_device *dev,
534 return -EINVAL; 534 return -EINVAL;
535 } 535 }
536 536
537 exec->bo = kcalloc(exec->bo_count, sizeof(struct drm_gem_cma_object *), 537 exec->bo = drm_calloc_large(exec->bo_count,
538 GFP_KERNEL); 538 sizeof(struct drm_gem_cma_object *));
539 if (!exec->bo) { 539 if (!exec->bo) {
540 DRM_ERROR("Failed to allocate validated BO pointers\n"); 540 DRM_ERROR("Failed to allocate validated BO pointers\n");
541 return -ENOMEM; 541 return -ENOMEM;
@@ -572,8 +572,8 @@ vc4_cl_lookup_bos(struct drm_device *dev,
572 spin_unlock(&file_priv->table_lock); 572 spin_unlock(&file_priv->table_lock);
573 573
574fail: 574fail:
575 kfree(handles); 575 drm_free_large(handles);
576 return 0; 576 return ret;
577} 577}
578 578
579static int 579static int
@@ -608,7 +608,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
608 * read the contents back for validation, and I think the 608 * read the contents back for validation, and I think the
609 * bo->vaddr is uncached access. 609 * bo->vaddr is uncached access.
610 */ 610 */
611 temp = kmalloc(temp_size, GFP_KERNEL); 611 temp = drm_malloc_ab(temp_size, 1);
612 if (!temp) { 612 if (!temp) {
613 DRM_ERROR("Failed to allocate storage for copying " 613 DRM_ERROR("Failed to allocate storage for copying "
614 "in bin/render CLs.\n"); 614 "in bin/render CLs.\n");
@@ -675,7 +675,7 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
675 ret = vc4_validate_shader_recs(dev, exec); 675 ret = vc4_validate_shader_recs(dev, exec);
676 676
677fail: 677fail:
678 kfree(temp); 678 drm_free_large(temp);
679 return ret; 679 return ret;
680} 680}
681 681
@@ -688,7 +688,7 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
688 if (exec->bo) { 688 if (exec->bo) {
689 for (i = 0; i < exec->bo_count; i++) 689 for (i = 0; i < exec->bo_count; i++)
690 drm_gem_object_unreference_unlocked(&exec->bo[i]->base); 690 drm_gem_object_unreference_unlocked(&exec->bo[i]->base);
691 kfree(exec->bo); 691 drm_free_large(exec->bo);
692 } 692 }
693 693
694 while (!list_empty(&exec->unref_list)) { 694 while (!list_empty(&exec->unref_list)) {
@@ -942,8 +942,8 @@ vc4_gem_destroy(struct drm_device *dev)
942 vc4->overflow_mem = NULL; 942 vc4->overflow_mem = NULL;
943 } 943 }
944 944
945 vc4_bo_cache_destroy(dev);
946
947 if (vc4->hang_state) 945 if (vc4->hang_state)
948 vc4_free_hang_state(dev, vc4->hang_state); 946 vc4_free_hang_state(dev, vc4->hang_state);
947
948 vc4_bo_cache_destroy(dev);
949} 949}
diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
index b0104a346a74..094bc6a475c1 100644
--- a/drivers/gpu/drm/vc4/vc4_irq.c
+++ b/drivers/gpu/drm/vc4/vc4_irq.c
@@ -83,8 +83,10 @@ vc4_overflow_mem_work(struct work_struct *work)
83 83
84 spin_lock_irqsave(&vc4->job_lock, irqflags); 84 spin_lock_irqsave(&vc4->job_lock, irqflags);
85 current_exec = vc4_first_bin_job(vc4); 85 current_exec = vc4_first_bin_job(vc4);
86 if (!current_exec)
87 current_exec = vc4_last_render_job(vc4);
86 if (current_exec) { 88 if (current_exec) {
87 vc4->overflow_mem->seqno = vc4->finished_seqno + 1; 89 vc4->overflow_mem->seqno = current_exec->seqno;
88 list_add_tail(&vc4->overflow_mem->unref_head, 90 list_add_tail(&vc4->overflow_mem->unref_head,
89 &current_exec->unref_list); 91 &current_exec->unref_list);
90 vc4->overflow_mem = NULL; 92 vc4->overflow_mem = NULL;
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index d0203a115eff..4667012b46b7 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -2015,6 +2015,7 @@ static struct attribute *it87_attributes_in[] = {
2015 &sensor_dev_attr_in10_input.dev_attr.attr, /* 41 */ 2015 &sensor_dev_attr_in10_input.dev_attr.attr, /* 41 */
2016 &sensor_dev_attr_in11_input.dev_attr.attr, /* 41 */ 2016 &sensor_dev_attr_in11_input.dev_attr.attr, /* 41 */
2017 &sensor_dev_attr_in12_input.dev_attr.attr, /* 41 */ 2017 &sensor_dev_attr_in12_input.dev_attr.attr, /* 41 */
2018 NULL
2018}; 2019};
2019 2020
2020static const struct attribute_group it87_group_in = { 2021static const struct attribute_group it87_group_in = {
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 89d78208de3f..78f148ea9d9f 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -20,6 +20,8 @@ config BMA180
20config BMA220 20config BMA220
21 tristate "Bosch BMA220 3-Axis Accelerometer Driver" 21 tristate "Bosch BMA220 3-Axis Accelerometer Driver"
22 depends on SPI 22 depends on SPI
23 select IIO_BUFFER
24 select IIO_TRIGGERED_BUFFER
23 help 25 help
24 Say yes here to add support for the Bosch BMA220 triaxial 26 Say yes here to add support for the Bosch BMA220 triaxial
25 acceleration sensor. 27 acceleration sensor.
@@ -234,7 +236,8 @@ config STK8312
234config STK8BA50 236config STK8BA50
235 tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" 237 tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver"
236 depends on I2C 238 depends on I2C
237 depends on IIO_TRIGGER 239 select IIO_BUFFER
240 select IIO_TRIGGERED_BUFFER
238 help 241 help
239 Say yes here to get support for the Sensortek STK8BA50 3-axis 242 Say yes here to get support for the Sensortek STK8BA50 3-axis
240 accelerometer. 243 accelerometer.
diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index 1098d10df8e8..5099f295dd37 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -253,7 +253,7 @@ static int bma220_probe(struct spi_device *spi)
253 if (ret < 0) 253 if (ret < 0)
254 return ret; 254 return ret;
255 255
256 ret = iio_triggered_buffer_setup(indio_dev, NULL, 256 ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
257 bma220_trigger_handler, NULL); 257 bma220_trigger_handler, NULL);
258 if (ret < 0) { 258 if (ret < 0) {
259 dev_err(&spi->dev, "iio triggered buffer setup failed\n"); 259 dev_err(&spi->dev, "iio triggered buffer setup failed\n");
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 3a9f106787d2..da5fb67ecb34 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -160,6 +160,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
160 if (ret < 0) 160 if (ret < 0)
161 goto error_ret; 161 goto error_ret;
162 *val = ret; 162 *val = ret;
163 ret = IIO_VAL_INT;
163 break; 164 break;
164 case IIO_CHAN_INFO_SCALE: 165 case IIO_CHAN_INFO_SCALE:
165 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C)); 166 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 1de31bdd4ce4..767577298ee3 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC
389config ROCKCHIP_SARADC 389config ROCKCHIP_SARADC
390 tristate "Rockchip SARADC driver" 390 tristate "Rockchip SARADC driver"
391 depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST) 391 depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
392 depends on RESET_CONTROLLER
392 help 393 help
393 Say yes here to build support for the SARADC found in SoCs from 394 Say yes here to build support for the SARADC found in SoCs from
394 Rockchip. 395 Rockchip.
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index b6163764489c..9704090b7908 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -527,6 +527,7 @@ static struct attribute_group ad799x_event_attrs_group = {
527static const struct iio_info ad7991_info = { 527static const struct iio_info ad7991_info = {
528 .read_raw = &ad799x_read_raw, 528 .read_raw = &ad799x_read_raw,
529 .driver_module = THIS_MODULE, 529 .driver_module = THIS_MODULE,
530 .update_scan_mode = ad799x_update_scan_mode,
530}; 531};
531 532
532static const struct iio_info ad7993_4_7_8_noirq_info = { 533static const struct iio_info ad7993_4_7_8_noirq_info = {
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 52430ba171f3..0438c68015e8 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
381 st->ts_bufferedmeasure = false; 381 st->ts_bufferedmeasure = false;
382 input_report_key(st->ts_input, BTN_TOUCH, 0); 382 input_report_key(st->ts_input, BTN_TOUCH, 0);
383 input_sync(st->ts_input); 383 input_sync(st->ts_input);
384 } else if (status & AT91_ADC_EOC(3)) { 384 } else if (status & AT91_ADC_EOC(3) && st->ts_input) {
385 /* Conversion finished */ 385 /* Conversion finished and we've a touchscreen */
386 if (st->ts_bufferedmeasure) { 386 if (st->ts_bufferedmeasure) {
387 /* 387 /*
388 * Last measurement is always discarded, since it can 388 * Last measurement is always discarded, since it can
diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index f9ad6c2d6821..85d701291654 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -21,6 +21,8 @@
21#include <linux/of_device.h> 21#include <linux/of_device.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/completion.h> 23#include <linux/completion.h>
24#include <linux/delay.h>
25#include <linux/reset.h>
24#include <linux/regulator/consumer.h> 26#include <linux/regulator/consumer.h>
25#include <linux/iio/iio.h> 27#include <linux/iio/iio.h>
26 28
@@ -53,6 +55,7 @@ struct rockchip_saradc {
53 struct clk *clk; 55 struct clk *clk;
54 struct completion completion; 56 struct completion completion;
55 struct regulator *vref; 57 struct regulator *vref;
58 struct reset_control *reset;
56 const struct rockchip_saradc_data *data; 59 const struct rockchip_saradc_data *data;
57 u16 last_val; 60 u16 last_val;
58}; 61};
@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
190}; 193};
191MODULE_DEVICE_TABLE(of, rockchip_saradc_match); 194MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
192 195
196/**
197 * Reset SARADC Controller.
198 */
199static void rockchip_saradc_reset_controller(struct reset_control *reset)
200{
201 reset_control_assert(reset);
202 usleep_range(10, 20);
203 reset_control_deassert(reset);
204}
205
193static int rockchip_saradc_probe(struct platform_device *pdev) 206static int rockchip_saradc_probe(struct platform_device *pdev)
194{ 207{
195 struct rockchip_saradc *info = NULL; 208 struct rockchip_saradc *info = NULL;
@@ -218,6 +231,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
218 if (IS_ERR(info->regs)) 231 if (IS_ERR(info->regs))
219 return PTR_ERR(info->regs); 232 return PTR_ERR(info->regs);
220 233
234 /*
235 * The reset should be an optional property, as it should work
236 * with old devicetrees as well
237 */
238 info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb");
239 if (IS_ERR(info->reset)) {
240 ret = PTR_ERR(info->reset);
241 if (ret != -ENOENT)
242 return ret;
243
244 dev_dbg(&pdev->dev, "no reset control found\n");
245 info->reset = NULL;
246 }
247
221 init_completion(&info->completion); 248 init_completion(&info->completion);
222 249
223 irq = platform_get_irq(pdev, 0); 250 irq = platform_get_irq(pdev, 0);
@@ -252,6 +279,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
252 return PTR_ERR(info->vref); 279 return PTR_ERR(info->vref);
253 } 280 }
254 281
282 if (info->reset)
283 rockchip_saradc_reset_controller(info->reset);
284
255 /* 285 /*
256 * Use a default value for the converter clock. 286 * Use a default value for the converter clock.
257 * This may become user-configurable in the future. 287 * This may become user-configurable in the future.
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 1ef398770a1f..066abaf80201 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -489,7 +489,8 @@ static struct iio_info ads1115_info = {
489#ifdef CONFIG_OF 489#ifdef CONFIG_OF
490static int ads1015_get_channels_config_of(struct i2c_client *client) 490static int ads1015_get_channels_config_of(struct i2c_client *client)
491{ 491{
492 struct ads1015_data *data = i2c_get_clientdata(client); 492 struct iio_dev *indio_dev = i2c_get_clientdata(client);
493 struct ads1015_data *data = iio_priv(indio_dev);
493 struct device_node *node; 494 struct device_node *node;
494 495
495 if (!client->dev.of_node || 496 if (!client->dev.of_node ||
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 8a368756881b..c3cfacca2541 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -32,6 +32,7 @@
32 32
33struct tiadc_device { 33struct tiadc_device {
34 struct ti_tscadc_dev *mfd_tscadc; 34 struct ti_tscadc_dev *mfd_tscadc;
35 struct mutex fifo1_lock; /* to protect fifo access */
35 int channels; 36 int channels;
36 u8 channel_line[8]; 37 u8 channel_line[8];
37 u8 channel_step[8]; 38 u8 channel_step[8];
@@ -359,6 +360,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
359 int *val, int *val2, long mask) 360 int *val, int *val2, long mask)
360{ 361{
361 struct tiadc_device *adc_dev = iio_priv(indio_dev); 362 struct tiadc_device *adc_dev = iio_priv(indio_dev);
363 int ret = IIO_VAL_INT;
362 int i, map_val; 364 int i, map_val;
363 unsigned int fifo1count, read, stepid; 365 unsigned int fifo1count, read, stepid;
364 bool found = false; 366 bool found = false;
@@ -372,13 +374,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
372 if (!step_en) 374 if (!step_en)
373 return -EINVAL; 375 return -EINVAL;
374 376
377 mutex_lock(&adc_dev->fifo1_lock);
375 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); 378 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
376 while (fifo1count--) 379 while (fifo1count--)
377 tiadc_readl(adc_dev, REG_FIFO1); 380 tiadc_readl(adc_dev, REG_FIFO1);
378 381
379 am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); 382 am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
380 383
381 timeout = jiffies + usecs_to_jiffies 384 timeout = jiffies + msecs_to_jiffies
382 (IDLE_TIMEOUT * adc_dev->channels); 385 (IDLE_TIMEOUT * adc_dev->channels);
383 /* Wait for Fifo threshold interrupt */ 386 /* Wait for Fifo threshold interrupt */
384 while (1) { 387 while (1) {
@@ -388,7 +391,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
388 391
389 if (time_after(jiffies, timeout)) { 392 if (time_after(jiffies, timeout)) {
390 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); 393 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
391 return -EAGAIN; 394 ret = -EAGAIN;
395 goto err_unlock;
392 } 396 }
393 } 397 }
394 map_val = adc_dev->channel_step[chan->scan_index]; 398 map_val = adc_dev->channel_step[chan->scan_index];
@@ -414,8 +418,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
414 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); 418 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
415 419
416 if (found == false) 420 if (found == false)
417 return -EBUSY; 421 ret = -EBUSY;
418 return IIO_VAL_INT; 422
423err_unlock:
424 mutex_unlock(&adc_dev->fifo1_lock);
425 return ret;
419} 426}
420 427
421static const struct iio_info tiadc_info = { 428static const struct iio_info tiadc_info = {
@@ -483,6 +490,7 @@ static int tiadc_probe(struct platform_device *pdev)
483 490
484 tiadc_step_config(indio_dev); 491 tiadc_step_config(indio_dev);
485 tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); 492 tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD);
493 mutex_init(&adc_dev->fifo1_lock);
486 494
487 err = tiadc_channel_init(indio_dev, adc_dev->channels); 495 err = tiadc_channel_init(indio_dev, adc_dev->channels);
488 if (err < 0) 496 if (err < 0)
diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c
index ae038a59d256..407f141a1eee 100644
--- a/drivers/iio/chemical/atlas-ph-sensor.c
+++ b/drivers/iio/chemical/atlas-ph-sensor.c
@@ -434,7 +434,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev,
434 break; 434 break;
435 case IIO_ELECTRICALCONDUCTIVITY: 435 case IIO_ELECTRICALCONDUCTIVITY:
436 *val = 1; /* 0.00001 */ 436 *val = 1; /* 0.00001 */
437 *val = 100000; 437 *val2 = 100000;
438 break; 438 break;
439 case IIO_CONCENTRATION: 439 case IIO_CONCENTRATION:
440 *val = 0; /* 0.000000001 */ 440 *val = 0; /* 0.000000001 */
diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
index 792a97164cb2..bebbd00304ce 100644
--- a/drivers/iio/dac/stx104.c
+++ b/drivers/iio/dac/stx104.c
@@ -65,6 +65,16 @@ struct stx104_gpio {
65 unsigned int out_state; 65 unsigned int out_state;
66}; 66};
67 67
68/**
69 * struct stx104_dev - STX104 device private data structure
70 * @indio_dev: IIO device
71 * @chip: instance of the gpio_chip
72 */
73struct stx104_dev {
74 struct iio_dev *indio_dev;
75 struct gpio_chip *chip;
76};
77
68static int stx104_read_raw(struct iio_dev *indio_dev, 78static int stx104_read_raw(struct iio_dev *indio_dev,
69 struct iio_chan_spec const *chan, int *val, int *val2, long mask) 79 struct iio_chan_spec const *chan, int *val, int *val2, long mask)
70{ 80{
@@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = {
107static int stx104_gpio_get_direction(struct gpio_chip *chip, 117static int stx104_gpio_get_direction(struct gpio_chip *chip,
108 unsigned int offset) 118 unsigned int offset)
109{ 119{
120 /* GPIO 0-3 are input only, while the rest are output only */
110 if (offset < 4) 121 if (offset < 4)
111 return 1; 122 return 1;
112 123
@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
169 struct iio_dev *indio_dev; 180 struct iio_dev *indio_dev;
170 struct stx104_iio *priv; 181 struct stx104_iio *priv;
171 struct stx104_gpio *stx104gpio; 182 struct stx104_gpio *stx104gpio;
183 struct stx104_dev *stx104dev;
172 int err; 184 int err;
173 185
174 indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); 186 indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id)
179 if (!stx104gpio) 191 if (!stx104gpio)
180 return -ENOMEM; 192 return -ENOMEM;
181 193
194 stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL);
195 if (!stx104dev)
196 return -ENOMEM;
197
182 if (!devm_request_region(dev, base[id], STX104_EXTENT, 198 if (!devm_request_region(dev, base[id], STX104_EXTENT,
183 dev_name(dev))) { 199 dev_name(dev))) {
184 dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", 200 dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id)
199 outw(0, base[id] + 4); 215 outw(0, base[id] + 4);
200 outw(0, base[id] + 6); 216 outw(0, base[id] + 6);
201 217
202 err = devm_iio_device_register(dev, indio_dev);
203 if (err) {
204 dev_err(dev, "IIO device registering failed (%d)\n", err);
205 return err;
206 }
207
208 stx104gpio->chip.label = dev_name(dev); 218 stx104gpio->chip.label = dev_name(dev);
209 stx104gpio->chip.parent = dev; 219 stx104gpio->chip.parent = dev;
210 stx104gpio->chip.owner = THIS_MODULE; 220 stx104gpio->chip.owner = THIS_MODULE;
@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id)
220 230
221 spin_lock_init(&stx104gpio->lock); 231 spin_lock_init(&stx104gpio->lock);
222 232
223 dev_set_drvdata(dev, stx104gpio); 233 stx104dev->indio_dev = indio_dev;
234 stx104dev->chip = &stx104gpio->chip;
235 dev_set_drvdata(dev, stx104dev);
224 236
225 err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); 237 err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
226 if (err) { 238 if (err) {
@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id)
228 return err; 240 return err;
229 } 241 }
230 242
243 err = iio_device_register(indio_dev);
244 if (err) {
245 dev_err(dev, "IIO device registering failed (%d)\n", err);
246 gpiochip_remove(&stx104gpio->chip);
247 return err;
248 }
249
231 return 0; 250 return 0;
232} 251}
233 252
234static int stx104_remove(struct device *dev, unsigned int id) 253static int stx104_remove(struct device *dev, unsigned int id)
235{ 254{
236 struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev); 255 struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
237 256
238 gpiochip_remove(&stx104gpio->chip); 257 iio_device_unregister(stx104dev->indio_dev);
258 gpiochip_remove(stx104dev->chip);
239 259
240 return 0; 260 return 0;
241} 261}
diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig
index 738a86d9e4a9..d04124345992 100644
--- a/drivers/iio/humidity/Kconfig
+++ b/drivers/iio/humidity/Kconfig
@@ -6,6 +6,8 @@ menu "Humidity sensors"
6config AM2315 6config AM2315
7 tristate "Aosong AM2315 relative humidity and temperature sensor" 7 tristate "Aosong AM2315 relative humidity and temperature sensor"
8 depends on I2C 8 depends on I2C
9 select IIO_BUFFER
10 select IIO_TRIGGERED_BUFFER
9 help 11 help
10 If you say yes here you get support for the Aosong AM2315 12 If you say yes here you get support for the Aosong AM2315
11 relative humidity and ambient temperature sensor. 13 relative humidity and ambient temperature sensor.
diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
index 3e200f69e886..ff96b6d0fdae 100644
--- a/drivers/iio/humidity/am2315.c
+++ b/drivers/iio/humidity/am2315.c
@@ -244,7 +244,7 @@ static int am2315_probe(struct i2c_client *client,
244 indio_dev->channels = am2315_channels; 244 indio_dev->channels = am2315_channels;
245 indio_dev->num_channels = ARRAY_SIZE(am2315_channels); 245 indio_dev->num_channels = ARRAY_SIZE(am2315_channels);
246 246
247 ret = iio_triggered_buffer_setup(indio_dev, NULL, 247 ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
248 am2315_trigger_handler, NULL); 248 am2315_trigger_handler, NULL);
249 if (ret < 0) { 249 if (ret < 0) {
250 dev_err(&client->dev, "iio triggered buffer setup failed\n"); 250 dev_err(&client->dev, "iio triggered buffer setup failed\n");
diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index a03832a5fc95..e0c9c70c2a4a 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -142,7 +142,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
142 struct i2c_client *client = data->client; 142 struct i2c_client *client = data->client;
143 int delay = data->adc_int_us[chan->address]; 143 int delay = data->adc_int_us[chan->address];
144 int ret; 144 int ret;
145 int val; 145 __be16 val;
146 146
147 /* start measurement */ 147 /* start measurement */
148 ret = i2c_smbus_write_byte(client, chan->address); 148 ret = i2c_smbus_write_byte(client, chan->address);
@@ -154,26 +154,13 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
154 /* wait for integration time to pass */ 154 /* wait for integration time to pass */
155 usleep_range(delay, delay + 1000); 155 usleep_range(delay, delay + 1000);
156 156
157 /* 157 /* read measurement */
158 * i2c_smbus_read_word_data cannot() be used here due to the command 158 ret = i2c_master_recv(data->client, (char *)&val, sizeof(val));
159 * value not being understood and causes NAKs preventing any reading
160 * from being accessed.
161 */
162 ret = i2c_smbus_read_byte(client);
163 if (ret < 0) { 159 if (ret < 0) {
164 dev_err(&client->dev, "cannot read high byte measurement"); 160 dev_err(&client->dev, "cannot read sensor data\n");
165 return ret; 161 return ret;
166 } 162 }
167 val = ret << 8; 163 return be16_to_cpu(val);
168
169 ret = i2c_smbus_read_byte(client);
170 if (ret < 0) {
171 dev_err(&client->dev, "cannot read low byte measurement");
172 return ret;
173 }
174 val |= ret;
175
176 return val;
177} 164}
178 165
179static int hdc100x_get_heater_status(struct hdc100x_data *data) 166static int hdc100x_get_heater_status(struct hdc100x_data *data)
@@ -272,8 +259,8 @@ static int hdc100x_probe(struct i2c_client *client,
272 struct iio_dev *indio_dev; 259 struct iio_dev *indio_dev;
273 struct hdc100x_data *data; 260 struct hdc100x_data *data;
274 261
275 if (!i2c_check_functionality(client->adapter, 262 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA |
276 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE)) 263 I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
277 return -EOPNOTSUPP; 264 return -EOPNOTSUPP;
278 265
279 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); 266 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 90462fcf5436..49bf9c59f117 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -107,6 +107,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
107{ 107{
108 struct iio_dev *indio_dev = filp->private_data; 108 struct iio_dev *indio_dev = filp->private_data;
109 struct iio_buffer *rb = indio_dev->buffer; 109 struct iio_buffer *rb = indio_dev->buffer;
110 DEFINE_WAIT_FUNC(wait, woken_wake_function);
110 size_t datum_size; 111 size_t datum_size;
111 size_t to_wait; 112 size_t to_wait;
112 int ret; 113 int ret;
@@ -131,19 +132,29 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
131 else 132 else
132 to_wait = min_t(size_t, n / datum_size, rb->watermark); 133 to_wait = min_t(size_t, n / datum_size, rb->watermark);
133 134
135 add_wait_queue(&rb->pollq, &wait);
134 do { 136 do {
135 ret = wait_event_interruptible(rb->pollq, 137 if (!indio_dev->info) {
136 iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)); 138 ret = -ENODEV;
137 if (ret) 139 break;
138 return ret; 140 }
139 141
140 if (!indio_dev->info) 142 if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) {
141 return -ENODEV; 143 if (signal_pending(current)) {
144 ret = -ERESTARTSYS;
145 break;
146 }
147
148 wait_woken(&wait, TASK_INTERRUPTIBLE,
149 MAX_SCHEDULE_TIMEOUT);
150 continue;
151 }
142 152
143 ret = rb->access->read_first_n(rb, n, buf); 153 ret = rb->access->read_first_n(rb, n, buf);
144 if (ret == 0 && (filp->f_flags & O_NONBLOCK)) 154 if (ret == 0 && (filp->f_flags & O_NONBLOCK))
145 ret = -EAGAIN; 155 ret = -EAGAIN;
146 } while (ret == 0); 156 } while (ret == 0);
157 remove_wait_queue(&rb->pollq, &wait);
147 158
148 return ret; 159 return ret;
149} 160}
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 7c566f516572..3574945183fe 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -76,7 +76,6 @@ config BH1750
76config BH1780 76config BH1780
77 tristate "ROHM BH1780 ambient light sensor" 77 tristate "ROHM BH1780 ambient light sensor"
78 depends on I2C 78 depends on I2C
79 depends on !SENSORS_BH1780
80 help 79 help
81 Say Y here to build support for the ROHM BH1780GLI ambient 80 Say Y here to build support for the ROHM BH1780GLI ambient
82 light sensor. 81 light sensor.
@@ -238,6 +237,8 @@ config MAX44000
238 tristate "MAX44000 Ambient and Infrared Proximity Sensor" 237 tristate "MAX44000 Ambient and Infrared Proximity Sensor"
239 depends on I2C 238 depends on I2C
240 select REGMAP_I2C 239 select REGMAP_I2C
240 select IIO_BUFFER
241 select IIO_TRIGGERED_BUFFER
241 help 242 help
242 Say Y here if you want to build support for Maxim Integrated's 243 Say Y here if you want to build support for Maxim Integrated's
243 MAX44000 ambient and infrared proximity sensor device. 244 MAX44000 ambient and infrared proximity sensor device.
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6943688e66df..e5a533cbd53f 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -970,7 +970,7 @@ int bmp280_common_probe(struct device *dev,
970 data->vdda = devm_regulator_get(dev, "vdda"); 970 data->vdda = devm_regulator_get(dev, "vdda");
971 if (IS_ERR(data->vdda)) { 971 if (IS_ERR(data->vdda)) {
972 dev_err(dev, "failed to get VDDA regulator\n"); 972 dev_err(dev, "failed to get VDDA regulator\n");
973 ret = PTR_ERR(data->vddd); 973 ret = PTR_ERR(data->vdda);
974 goto out_disable_vddd; 974 goto out_disable_vddd;
975 } 975 }
976 ret = regulator_enable(data->vdda); 976 ret = regulator_enable(data->vdda);
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
1079#ifdef CONFIG_PM 1079#ifdef CONFIG_PM
1080static int bmp280_runtime_suspend(struct device *dev) 1080static int bmp280_runtime_suspend(struct device *dev)
1081{ 1081{
1082 struct bmp280_data *data = dev_get_drvdata(dev); 1082 struct iio_dev *indio_dev = dev_get_drvdata(dev);
1083 struct bmp280_data *data = iio_priv(indio_dev);
1083 int ret; 1084 int ret;
1084 1085
1085 ret = regulator_disable(data->vdda); 1086 ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
1090 1091
1091static int bmp280_runtime_resume(struct device *dev) 1092static int bmp280_runtime_resume(struct device *dev)
1092{ 1093{
1093 struct bmp280_data *data = dev_get_drvdata(dev); 1094 struct iio_dev *indio_dev = dev_get_drvdata(dev);
1095 struct bmp280_data *data = iio_priv(indio_dev);
1094 int ret; 1096 int ret;
1095 1097
1096 ret = regulator_enable(data->vddd); 1098 ret = regulator_enable(data->vddd);
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index 2e3a70e1b245..5656deb17261 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -397,7 +397,7 @@ static int as3935_probe(struct spi_device *spi)
397 return ret; 397 return ret;
398 } 398 }
399 399
400 ret = iio_triggered_buffer_setup(indio_dev, NULL, 400 ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
401 &as3935_trigger_handler, NULL); 401 &as3935_trigger_handler, NULL);
402 402
403 if (ret) { 403 if (ret) {
diff --git a/drivers/macintosh/ams/ams-i2c.c b/drivers/macintosh/ams/ams-i2c.c
index 978eda8d6678..8a3ba565106f 100644
--- a/drivers/macintosh/ams/ams-i2c.c
+++ b/drivers/macintosh/ams/ams-i2c.c
@@ -73,7 +73,6 @@ MODULE_DEVICE_TABLE(i2c, ams_id);
73static struct i2c_driver ams_i2c_driver = { 73static struct i2c_driver ams_i2c_driver = {
74 .driver = { 74 .driver = {
75 .name = "ams", 75 .name = "ams",
76 .owner = THIS_MODULE,
77 }, 76 },
78 .probe = ams_i2c_probe, 77 .probe = ams_i2c_probe,
79 .remove = ams_i2c_remove, 78 .remove = ams_i2c_remove,
diff --git a/drivers/macintosh/windfarm_pm112.c b/drivers/macintosh/windfarm_pm112.c
index 3024685e4cca..96d16fca68b2 100644
--- a/drivers/macintosh/windfarm_pm112.c
+++ b/drivers/macintosh/windfarm_pm112.c
@@ -668,7 +668,6 @@ static struct platform_driver wf_pm112_driver = {
668 .remove = wf_pm112_remove, 668 .remove = wf_pm112_remove,
669 .driver = { 669 .driver = {
670 .name = "windfarm", 670 .name = "windfarm",
671 .owner = THIS_MODULE,
672 }, 671 },
673}; 672};
674 673
diff --git a/drivers/macintosh/windfarm_pm72.c b/drivers/macintosh/windfarm_pm72.c
index 2f506b9d5a52..e88cfb36a74d 100644
--- a/drivers/macintosh/windfarm_pm72.c
+++ b/drivers/macintosh/windfarm_pm72.c
@@ -789,7 +789,6 @@ static struct platform_driver wf_pm72_driver = {
789 .remove = wf_pm72_remove, 789 .remove = wf_pm72_remove,
790 .driver = { 790 .driver = {
791 .name = "windfarm", 791 .name = "windfarm",
792 .owner = THIS_MODULE,
793 }, 792 },
794}; 793};
795 794
diff --git a/drivers/macintosh/windfarm_rm31.c b/drivers/macintosh/windfarm_rm31.c
index 82fc86a90c1a..bdfcb8a8bfbb 100644
--- a/drivers/macintosh/windfarm_rm31.c
+++ b/drivers/macintosh/windfarm_rm31.c
@@ -682,7 +682,6 @@ static struct platform_driver wf_rm31_driver = {
682 .remove = wf_rm31_remove, 682 .remove = wf_rm31_remove,
683 .driver = { 683 .driver = {
684 .name = "windfarm", 684 .name = "windfarm",
685 .owner = THIS_MODULE,
686 }, 685 },
687}; 686};
688 687
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 6fff794e0c72..13041ee37ad6 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2183,19 +2183,29 @@ location_show(struct mddev *mddev, char *page)
2183static ssize_t 2183static ssize_t
2184location_store(struct mddev *mddev, const char *buf, size_t len) 2184location_store(struct mddev *mddev, const char *buf, size_t len)
2185{ 2185{
2186 int rv;
2186 2187
2188 rv = mddev_lock(mddev);
2189 if (rv)
2190 return rv;
2187 if (mddev->pers) { 2191 if (mddev->pers) {
2188 if (!mddev->pers->quiesce) 2192 if (!mddev->pers->quiesce) {
2189 return -EBUSY; 2193 rv = -EBUSY;
2190 if (mddev->recovery || mddev->sync_thread) 2194 goto out;
2191 return -EBUSY; 2195 }
2196 if (mddev->recovery || mddev->sync_thread) {
2197 rv = -EBUSY;
2198 goto out;
2199 }
2192 } 2200 }
2193 2201
2194 if (mddev->bitmap || mddev->bitmap_info.file || 2202 if (mddev->bitmap || mddev->bitmap_info.file ||
2195 mddev->bitmap_info.offset) { 2203 mddev->bitmap_info.offset) {
2196 /* bitmap already configured. Only option is to clear it */ 2204 /* bitmap already configured. Only option is to clear it */
2197 if (strncmp(buf, "none", 4) != 0) 2205 if (strncmp(buf, "none", 4) != 0) {
2198 return -EBUSY; 2206 rv = -EBUSY;
2207 goto out;
2208 }
2199 if (mddev->pers) { 2209 if (mddev->pers) {
2200 mddev->pers->quiesce(mddev, 1); 2210 mddev->pers->quiesce(mddev, 1);
2201 bitmap_destroy(mddev); 2211 bitmap_destroy(mddev);
@@ -2214,21 +2224,25 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
2214 /* nothing to be done */; 2224 /* nothing to be done */;
2215 else if (strncmp(buf, "file:", 5) == 0) { 2225 else if (strncmp(buf, "file:", 5) == 0) {
2216 /* Not supported yet */ 2226 /* Not supported yet */
2217 return -EINVAL; 2227 rv = -EINVAL;
2228 goto out;
2218 } else { 2229 } else {
2219 int rv;
2220 if (buf[0] == '+') 2230 if (buf[0] == '+')
2221 rv = kstrtoll(buf+1, 10, &offset); 2231 rv = kstrtoll(buf+1, 10, &offset);
2222 else 2232 else
2223 rv = kstrtoll(buf, 10, &offset); 2233 rv = kstrtoll(buf, 10, &offset);
2224 if (rv) 2234 if (rv)
2225 return rv; 2235 goto out;
2226 if (offset == 0) 2236 if (offset == 0) {
2227 return -EINVAL; 2237 rv = -EINVAL;
2238 goto out;
2239 }
2228 if (mddev->bitmap_info.external == 0 && 2240 if (mddev->bitmap_info.external == 0 &&
2229 mddev->major_version == 0 && 2241 mddev->major_version == 0 &&
2230 offset != mddev->bitmap_info.default_offset) 2242 offset != mddev->bitmap_info.default_offset) {
2231 return -EINVAL; 2243 rv = -EINVAL;
2244 goto out;
2245 }
2232 mddev->bitmap_info.offset = offset; 2246 mddev->bitmap_info.offset = offset;
2233 if (mddev->pers) { 2247 if (mddev->pers) {
2234 struct bitmap *bitmap; 2248 struct bitmap *bitmap;
@@ -2245,7 +2259,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
2245 mddev->pers->quiesce(mddev, 0); 2259 mddev->pers->quiesce(mddev, 0);
2246 if (rv) { 2260 if (rv) {
2247 bitmap_destroy(mddev); 2261 bitmap_destroy(mddev);
2248 return rv; 2262 goto out;
2249 } 2263 }
2250 } 2264 }
2251 } 2265 }
@@ -2257,6 +2271,11 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
2257 set_bit(MD_CHANGE_DEVS, &mddev->flags); 2271 set_bit(MD_CHANGE_DEVS, &mddev->flags);
2258 md_wakeup_thread(mddev->thread); 2272 md_wakeup_thread(mddev->thread);
2259 } 2273 }
2274 rv = 0;
2275out:
2276 mddev_unlock(mddev);
2277 if (rv)
2278 return rv;
2260 return len; 2279 return len;
2261} 2280}
2262 2281
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 6571c81465e1..8625040bae92 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1879,7 +1879,7 @@ static int __init dm_bufio_init(void)
1879 __cache_size_refresh(); 1879 __cache_size_refresh();
1880 mutex_unlock(&dm_bufio_clients_lock); 1880 mutex_unlock(&dm_bufio_clients_lock);
1881 1881
1882 dm_bufio_wq = create_singlethread_workqueue("dm_bufio_cache"); 1882 dm_bufio_wq = alloc_workqueue("dm_bufio_cache", WQ_MEM_RECLAIM, 0);
1883 if (!dm_bufio_wq) 1883 if (!dm_bufio_wq)
1884 return -ENOMEM; 1884 return -ENOMEM;
1885 1885
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index eedba67b0e3e..874295757caa 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1453,7 +1453,7 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
1453 unsigned i; 1453 unsigned i;
1454 int err; 1454 int err;
1455 1455
1456 cc->tfms = kmalloc(cc->tfms_count * sizeof(struct crypto_skcipher *), 1456 cc->tfms = kzalloc(cc->tfms_count * sizeof(struct crypto_skcipher *),
1457 GFP_KERNEL); 1457 GFP_KERNEL);
1458 if (!cc->tfms) 1458 if (!cc->tfms)
1459 return -ENOMEM; 1459 return -ENOMEM;
@@ -1924,6 +1924,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
1924 return DM_MAPIO_REMAPPED; 1924 return DM_MAPIO_REMAPPED;
1925 } 1925 }
1926 1926
1927 /*
1928 * Check if bio is too large, split as needed.
1929 */
1930 if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) &&
1931 bio_data_dir(bio) == WRITE)
1932 dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT));
1933
1927 io = dm_per_bio_data(bio, cc->per_bio_data_size); 1934 io = dm_per_bio_data(bio, cc->per_bio_data_size);
1928 crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector)); 1935 crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector));
1929 io->ctx.req = (struct skcipher_request *)(io + 1); 1936 io->ctx.req = (struct skcipher_request *)(io + 1);
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index 4ab68033f9d1..49e4d8d4558f 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -259,12 +259,12 @@ static int log_one_block(struct log_writes_c *lc,
259 goto out; 259 goto out;
260 sector++; 260 sector++;
261 261
262 bio = bio_alloc(GFP_KERNEL, block->vec_cnt); 262 atomic_inc(&lc->io_blocks);
263 bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt, BIO_MAX_PAGES));
263 if (!bio) { 264 if (!bio) {
264 DMERR("Couldn't alloc log bio"); 265 DMERR("Couldn't alloc log bio");
265 goto error; 266 goto error;
266 } 267 }
267 atomic_inc(&lc->io_blocks);
268 bio->bi_iter.bi_size = 0; 268 bio->bi_iter.bi_size = 0;
269 bio->bi_iter.bi_sector = sector; 269 bio->bi_iter.bi_sector = sector;
270 bio->bi_bdev = lc->logdev->bdev; 270 bio->bi_bdev = lc->logdev->bdev;
@@ -282,7 +282,7 @@ static int log_one_block(struct log_writes_c *lc,
282 if (ret != block->vecs[i].bv_len) { 282 if (ret != block->vecs[i].bv_len) {
283 atomic_inc(&lc->io_blocks); 283 atomic_inc(&lc->io_blocks);
284 submit_bio(bio); 284 submit_bio(bio);
285 bio = bio_alloc(GFP_KERNEL, block->vec_cnt - i); 285 bio = bio_alloc(GFP_KERNEL, min(block->vec_cnt - i, BIO_MAX_PAGES));
286 if (!bio) { 286 if (!bio) {
287 DMERR("Couldn't alloc log bio"); 287 DMERR("Couldn't alloc log bio");
288 goto error; 288 goto error;
@@ -459,9 +459,9 @@ static int log_writes_ctr(struct dm_target *ti, unsigned int argc, char **argv)
459 goto bad; 459 goto bad;
460 } 460 }
461 461
462 ret = -EINVAL;
463 lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write"); 462 lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write");
464 if (!lc->log_kthread) { 463 if (IS_ERR(lc->log_kthread)) {
464 ret = PTR_ERR(lc->log_kthread);
465 ti->error = "Couldn't alloc kthread"; 465 ti->error = "Couldn't alloc kthread";
466 dm_put_device(ti, lc->dev); 466 dm_put_device(ti, lc->dev);
467 dm_put_device(ti, lc->logdev); 467 dm_put_device(ti, lc->logdev);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 41573f1f626f..34a840d9df76 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -834,8 +834,10 @@ static int join(struct mddev *mddev, int nodes)
834 goto err; 834 goto err;
835 } 835 }
836 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); 836 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
837 if (!cinfo->ack_lockres) 837 if (!cinfo->ack_lockres) {
838 ret = -ENOMEM;
838 goto err; 839 goto err;
840 }
839 /* get sync CR lock on ACK. */ 841 /* get sync CR lock on ACK. */
840 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) 842 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
841 pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n", 843 pr_err("md-cluster: failed to get a sync CR lock on ACK!(%d)\n",
@@ -849,8 +851,10 @@ static int join(struct mddev *mddev, int nodes)
849 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); 851 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number);
850 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); 852 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1);
851 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); 853 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
852 if (!cinfo->bitmap_lockres) 854 if (!cinfo->bitmap_lockres) {
855 ret = -ENOMEM;
853 goto err; 856 goto err;
857 }
854 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { 858 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
855 pr_err("Failed to get bitmap lock\n"); 859 pr_err("Failed to get bitmap lock\n");
856 ret = -EINVAL; 860 ret = -EINVAL;
@@ -858,8 +862,10 @@ static int join(struct mddev *mddev, int nodes)
858 } 862 }
859 863
860 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); 864 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
861 if (!cinfo->resync_lockres) 865 if (!cinfo->resync_lockres) {
866 ret = -ENOMEM;
862 goto err; 867 goto err;
868 }
863 869
864 return 0; 870 return 0;
865err: 871err:
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d646f6e444f0..67642bacd597 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1604,11 +1604,8 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *rdev)
1604 mddev->new_chunk_sectors = mddev->chunk_sectors; 1604 mddev->new_chunk_sectors = mddev->chunk_sectors;
1605 } 1605 }
1606 1606
1607 if (le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL) { 1607 if (le32_to_cpu(sb->feature_map) & MD_FEATURE_JOURNAL)
1608 set_bit(MD_HAS_JOURNAL, &mddev->flags); 1608 set_bit(MD_HAS_JOURNAL, &mddev->flags);
1609 if (mddev->recovery_cp == MaxSector)
1610 set_bit(MD_JOURNAL_CLEAN, &mddev->flags);
1611 }
1612 } else if (mddev->pers == NULL) { 1609 } else if (mddev->pers == NULL) {
1613 /* Insist of good event counter while assembling, except for 1610 /* Insist of good event counter while assembling, except for
1614 * spares (which don't need an event count) */ 1611 * spares (which don't need an event count) */
@@ -5851,6 +5848,9 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
5851 working++; 5848 working++;
5852 if (test_bit(In_sync, &rdev->flags)) 5849 if (test_bit(In_sync, &rdev->flags))
5853 insync++; 5850 insync++;
5851 else if (test_bit(Journal, &rdev->flags))
5852 /* TODO: add journal count to md_u.h */
5853 ;
5854 else 5854 else
5855 spare++; 5855 spare++;
5856 } 5856 }
@@ -7862,6 +7862,7 @@ void md_do_sync(struct md_thread *thread)
7862 */ 7862 */
7863 7863
7864 do { 7864 do {
7865 int mddev2_minor = -1;
7865 mddev->curr_resync = 2; 7866 mddev->curr_resync = 2;
7866 7867
7867 try_again: 7868 try_again:
@@ -7891,10 +7892,14 @@ void md_do_sync(struct md_thread *thread)
7891 prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE); 7892 prepare_to_wait(&resync_wait, &wq, TASK_INTERRUPTIBLE);
7892 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) && 7893 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&
7893 mddev2->curr_resync >= mddev->curr_resync) { 7894 mddev2->curr_resync >= mddev->curr_resync) {
7894 printk(KERN_INFO "md: delaying %s of %s" 7895 if (mddev2_minor != mddev2->md_minor) {
7895 " until %s has finished (they" 7896 mddev2_minor = mddev2->md_minor;
7896 " share one or more physical units)\n", 7897 printk(KERN_INFO "md: delaying %s of %s"
7897 desc, mdname(mddev), mdname(mddev2)); 7898 " until %s has finished (they"
7899 " share one or more physical units)\n",
7900 desc, mdname(mddev),
7901 mdname(mddev2));
7902 }
7898 mddev_put(mddev2); 7903 mddev_put(mddev2);
7899 if (signal_pending(current)) 7904 if (signal_pending(current))
7900 flush_signals(current); 7905 flush_signals(current);
@@ -8275,16 +8280,13 @@ no_add:
8275static void md_start_sync(struct work_struct *ws) 8280static void md_start_sync(struct work_struct *ws)
8276{ 8281{
8277 struct mddev *mddev = container_of(ws, struct mddev, del_work); 8282 struct mddev *mddev = container_of(ws, struct mddev, del_work);
8278 int ret = 0;
8279 8283
8280 mddev->sync_thread = md_register_thread(md_do_sync, 8284 mddev->sync_thread = md_register_thread(md_do_sync,
8281 mddev, 8285 mddev,
8282 "resync"); 8286 "resync");
8283 if (!mddev->sync_thread) { 8287 if (!mddev->sync_thread) {
8284 if (!(mddev_is_clustered(mddev) && ret == -EAGAIN)) 8288 printk(KERN_ERR "%s: could not start resync thread...\n",
8285 printk(KERN_ERR "%s: could not start resync" 8289 mdname(mddev));
8286 " thread...\n",
8287 mdname(mddev));
8288 /* leave the spares where they are, it shouldn't hurt */ 8290 /* leave the spares where they are, it shouldn't hurt */
8289 clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); 8291 clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
8290 clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery); 8292 clear_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0e4efcd10795..be1a9fca3b2d 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1064,6 +1064,8 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
1064 int max_sectors; 1064 int max_sectors;
1065 int sectors; 1065 int sectors;
1066 1066
1067 md_write_start(mddev, bio);
1068
1067 /* 1069 /*
1068 * Register the new request and wait if the reconstruction 1070 * Register the new request and wait if the reconstruction
1069 * thread has put up a bar for new requests. 1071 * thread has put up a bar for new requests.
@@ -1445,8 +1447,6 @@ static void raid10_make_request(struct mddev *mddev, struct bio *bio)
1445 return; 1447 return;
1446 } 1448 }
1447 1449
1448 md_write_start(mddev, bio);
1449
1450 do { 1450 do {
1451 1451
1452 /* 1452 /*
@@ -2465,20 +2465,21 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
2465 2465
2466 while (sect_to_write) { 2466 while (sect_to_write) {
2467 struct bio *wbio; 2467 struct bio *wbio;
2468 sector_t wsector;
2468 if (sectors > sect_to_write) 2469 if (sectors > sect_to_write)
2469 sectors = sect_to_write; 2470 sectors = sect_to_write;
2470 /* Write at 'sector' for 'sectors' */ 2471 /* Write at 'sector' for 'sectors' */
2471 wbio = bio_clone_mddev(bio, GFP_NOIO, mddev); 2472 wbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
2472 bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors); 2473 bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
2473 wbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ 2474 wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector);
2474 choose_data_offset(r10_bio, rdev) + 2475 wbio->bi_iter.bi_sector = wsector +
2475 (sector - r10_bio->sector)); 2476 choose_data_offset(r10_bio, rdev);
2476 wbio->bi_bdev = rdev->bdev; 2477 wbio->bi_bdev = rdev->bdev;
2477 bio_set_op_attrs(wbio, REQ_OP_WRITE, 0); 2478 bio_set_op_attrs(wbio, REQ_OP_WRITE, 0);
2478 2479
2479 if (submit_bio_wait(wbio) < 0) 2480 if (submit_bio_wait(wbio) < 0)
2480 /* Failure! */ 2481 /* Failure! */
2481 ok = rdev_set_badblocks(rdev, sector, 2482 ok = rdev_set_badblocks(rdev, wsector,
2482 sectors, 0) 2483 sectors, 0)
2483 && ok; 2484 && ok;
2484 2485
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8912407a4dd0..da583bb43c84 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -659,6 +659,7 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector,
659{ 659{
660 struct stripe_head *sh; 660 struct stripe_head *sh;
661 int hash = stripe_hash_locks_hash(sector); 661 int hash = stripe_hash_locks_hash(sector);
662 int inc_empty_inactive_list_flag;
662 663
663 pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector); 664 pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector);
664 665
@@ -703,7 +704,12 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector,
703 atomic_inc(&conf->active_stripes); 704 atomic_inc(&conf->active_stripes);
704 BUG_ON(list_empty(&sh->lru) && 705 BUG_ON(list_empty(&sh->lru) &&
705 !test_bit(STRIPE_EXPANDING, &sh->state)); 706 !test_bit(STRIPE_EXPANDING, &sh->state));
707 inc_empty_inactive_list_flag = 0;
708 if (!list_empty(conf->inactive_list + hash))
709 inc_empty_inactive_list_flag = 1;
706 list_del_init(&sh->lru); 710 list_del_init(&sh->lru);
711 if (list_empty(conf->inactive_list + hash) && inc_empty_inactive_list_flag)
712 atomic_inc(&conf->empty_inactive_list_nr);
707 if (sh->group) { 713 if (sh->group) {
708 sh->group->stripes_cnt--; 714 sh->group->stripes_cnt--;
709 sh->group = NULL; 715 sh->group = NULL;
@@ -762,6 +768,7 @@ static void stripe_add_to_batch_list(struct r5conf *conf, struct stripe_head *sh
762 sector_t head_sector, tmp_sec; 768 sector_t head_sector, tmp_sec;
763 int hash; 769 int hash;
764 int dd_idx; 770 int dd_idx;
771 int inc_empty_inactive_list_flag;
765 772
766 /* Don't cross chunks, so stripe pd_idx/qd_idx is the same */ 773 /* Don't cross chunks, so stripe pd_idx/qd_idx is the same */
767 tmp_sec = sh->sector; 774 tmp_sec = sh->sector;
@@ -779,7 +786,12 @@ static void stripe_add_to_batch_list(struct r5conf *conf, struct stripe_head *sh
779 atomic_inc(&conf->active_stripes); 786 atomic_inc(&conf->active_stripes);
780 BUG_ON(list_empty(&head->lru) && 787 BUG_ON(list_empty(&head->lru) &&
781 !test_bit(STRIPE_EXPANDING, &head->state)); 788 !test_bit(STRIPE_EXPANDING, &head->state));
789 inc_empty_inactive_list_flag = 0;
790 if (!list_empty(conf->inactive_list + hash))
791 inc_empty_inactive_list_flag = 1;
782 list_del_init(&head->lru); 792 list_del_init(&head->lru);
793 if (list_empty(conf->inactive_list + hash) && inc_empty_inactive_list_flag)
794 atomic_inc(&conf->empty_inactive_list_nr);
783 if (head->group) { 795 if (head->group) {
784 head->group->stripes_cnt--; 796 head->group->stripes_cnt--;
785 head->group = NULL; 797 head->group = NULL;
@@ -993,7 +1005,6 @@ again:
993 1005
994 set_bit(STRIPE_IO_STARTED, &sh->state); 1006 set_bit(STRIPE_IO_STARTED, &sh->state);
995 1007
996 bio_reset(bi);
997 bi->bi_bdev = rdev->bdev; 1008 bi->bi_bdev = rdev->bdev;
998 bio_set_op_attrs(bi, op, op_flags); 1009 bio_set_op_attrs(bi, op, op_flags);
999 bi->bi_end_io = op_is_write(op) 1010 bi->bi_end_io = op_is_write(op)
@@ -1045,7 +1056,6 @@ again:
1045 1056
1046 set_bit(STRIPE_IO_STARTED, &sh->state); 1057 set_bit(STRIPE_IO_STARTED, &sh->state);
1047 1058
1048 bio_reset(rbi);
1049 rbi->bi_bdev = rrdev->bdev; 1059 rbi->bi_bdev = rrdev->bdev;
1050 bio_set_op_attrs(rbi, op, op_flags); 1060 bio_set_op_attrs(rbi, op, op_flags);
1051 BUG_ON(!op_is_write(op)); 1061 BUG_ON(!op_is_write(op));
@@ -1978,9 +1988,11 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
1978 put_cpu(); 1988 put_cpu();
1979} 1989}
1980 1990
1981static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp) 1991static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp,
1992 int disks)
1982{ 1993{
1983 struct stripe_head *sh; 1994 struct stripe_head *sh;
1995 int i;
1984 1996
1985 sh = kmem_cache_zalloc(sc, gfp); 1997 sh = kmem_cache_zalloc(sc, gfp);
1986 if (sh) { 1998 if (sh) {
@@ -1989,6 +2001,17 @@ static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp)
1989 INIT_LIST_HEAD(&sh->batch_list); 2001 INIT_LIST_HEAD(&sh->batch_list);
1990 INIT_LIST_HEAD(&sh->lru); 2002 INIT_LIST_HEAD(&sh->lru);
1991 atomic_set(&sh->count, 1); 2003 atomic_set(&sh->count, 1);
2004 for (i = 0; i < disks; i++) {
2005 struct r5dev *dev = &sh->dev[i];
2006
2007 bio_init(&dev->req);
2008 dev->req.bi_io_vec = &dev->vec;
2009 dev->req.bi_max_vecs = 1;
2010
2011 bio_init(&dev->rreq);
2012 dev->rreq.bi_io_vec = &dev->rvec;
2013 dev->rreq.bi_max_vecs = 1;
2014 }
1992 } 2015 }
1993 return sh; 2016 return sh;
1994} 2017}
@@ -1996,7 +2019,7 @@ static int grow_one_stripe(struct r5conf *conf, gfp_t gfp)
1996{ 2019{
1997 struct stripe_head *sh; 2020 struct stripe_head *sh;
1998 2021
1999 sh = alloc_stripe(conf->slab_cache, gfp); 2022 sh = alloc_stripe(conf->slab_cache, gfp, conf->pool_size);
2000 if (!sh) 2023 if (!sh)
2001 return 0; 2024 return 0;
2002 2025
@@ -2167,7 +2190,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
2167 mutex_lock(&conf->cache_size_mutex); 2190 mutex_lock(&conf->cache_size_mutex);
2168 2191
2169 for (i = conf->max_nr_stripes; i; i--) { 2192 for (i = conf->max_nr_stripes; i; i--) {
2170 nsh = alloc_stripe(sc, GFP_KERNEL); 2193 nsh = alloc_stripe(sc, GFP_KERNEL, newsize);
2171 if (!nsh) 2194 if (!nsh)
2172 break; 2195 break;
2173 2196
@@ -2299,6 +2322,7 @@ static void raid5_end_read_request(struct bio * bi)
2299 (unsigned long long)sh->sector, i, atomic_read(&sh->count), 2322 (unsigned long long)sh->sector, i, atomic_read(&sh->count),
2300 bi->bi_error); 2323 bi->bi_error);
2301 if (i == disks) { 2324 if (i == disks) {
2325 bio_reset(bi);
2302 BUG(); 2326 BUG();
2303 return; 2327 return;
2304 } 2328 }
@@ -2402,6 +2426,7 @@ static void raid5_end_read_request(struct bio * bi)
2402 clear_bit(R5_LOCKED, &sh->dev[i].flags); 2426 clear_bit(R5_LOCKED, &sh->dev[i].flags);
2403 set_bit(STRIPE_HANDLE, &sh->state); 2427 set_bit(STRIPE_HANDLE, &sh->state);
2404 raid5_release_stripe(sh); 2428 raid5_release_stripe(sh);
2429 bio_reset(bi);
2405} 2430}
2406 2431
2407static void raid5_end_write_request(struct bio *bi) 2432static void raid5_end_write_request(struct bio *bi)
@@ -2436,6 +2461,7 @@ static void raid5_end_write_request(struct bio *bi)
2436 (unsigned long long)sh->sector, i, atomic_read(&sh->count), 2461 (unsigned long long)sh->sector, i, atomic_read(&sh->count),
2437 bi->bi_error); 2462 bi->bi_error);
2438 if (i == disks) { 2463 if (i == disks) {
2464 bio_reset(bi);
2439 BUG(); 2465 BUG();
2440 return; 2466 return;
2441 } 2467 }
@@ -2479,22 +2505,13 @@ static void raid5_end_write_request(struct bio *bi)
2479 2505
2480 if (sh->batch_head && sh != sh->batch_head) 2506 if (sh->batch_head && sh != sh->batch_head)
2481 raid5_release_stripe(sh->batch_head); 2507 raid5_release_stripe(sh->batch_head);
2508 bio_reset(bi);
2482} 2509}
2483 2510
2484static void raid5_build_block(struct stripe_head *sh, int i, int previous) 2511static void raid5_build_block(struct stripe_head *sh, int i, int previous)
2485{ 2512{
2486 struct r5dev *dev = &sh->dev[i]; 2513 struct r5dev *dev = &sh->dev[i];
2487 2514
2488 bio_init(&dev->req);
2489 dev->req.bi_io_vec = &dev->vec;
2490 dev->req.bi_max_vecs = 1;
2491 dev->req.bi_private = sh;
2492
2493 bio_init(&dev->rreq);
2494 dev->rreq.bi_io_vec = &dev->rvec;
2495 dev->rreq.bi_max_vecs = 1;
2496 dev->rreq.bi_private = sh;
2497
2498 dev->flags = 0; 2515 dev->flags = 0;
2499 dev->sector = raid5_compute_blocknr(sh, i, previous); 2516 dev->sector = raid5_compute_blocknr(sh, i, previous);
2500} 2517}
@@ -4628,7 +4645,9 @@ finish:
4628 } 4645 }
4629 4646
4630 if (!bio_list_empty(&s.return_bi)) { 4647 if (!bio_list_empty(&s.return_bi)) {
4631 if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags)) { 4648 if (test_bit(MD_CHANGE_PENDING, &conf->mddev->flags) &&
4649 (s.failed <= conf->max_degraded ||
4650 conf->mddev->external == 0)) {
4632 spin_lock_irq(&conf->device_lock); 4651 spin_lock_irq(&conf->device_lock);
4633 bio_list_merge(&conf->return_bi, &s.return_bi); 4652 bio_list_merge(&conf->return_bi, &s.return_bi);
4634 spin_unlock_irq(&conf->device_lock); 4653 spin_unlock_irq(&conf->device_lock);
@@ -6826,11 +6845,14 @@ static int raid5_run(struct mddev *mddev)
6826 if (IS_ERR(conf)) 6845 if (IS_ERR(conf))
6827 return PTR_ERR(conf); 6846 return PTR_ERR(conf);
6828 6847
6829 if (test_bit(MD_HAS_JOURNAL, &mddev->flags) && !journal_dev) { 6848 if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
6830 printk(KERN_ERR "md/raid:%s: journal disk is missing, force array readonly\n", 6849 if (!journal_dev) {
6831 mdname(mddev)); 6850 pr_err("md/raid:%s: journal disk is missing, force array readonly\n",
6832 mddev->ro = 1; 6851 mdname(mddev));
6833 set_disk_ro(mddev->gendisk, 1); 6852 mddev->ro = 1;
6853 set_disk_ro(mddev->gendisk, 1);
6854 } else if (mddev->recovery_cp == MaxSector)
6855 set_bit(MD_JOURNAL_CLEAN, &mddev->flags);
6834 } 6856 }
6835 6857
6836 conf->min_offset_diff = min_offset_diff; 6858 conf->min_offset_diff = min_offset_diff;
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a216b4667742..d00252828966 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -345,16 +345,6 @@ config SENSORS_TSL2550
345 This driver can also be built as a module. If so, the module 345 This driver can also be built as a module. If so, the module
346 will be called tsl2550. 346 will be called tsl2550.
347 347
348config SENSORS_BH1780
349 tristate "ROHM BH1780GLI ambient light sensor"
350 depends on I2C && SYSFS
351 help
352 If you say yes here you get support for the ROHM BH1780GLI
353 ambient light sensor.
354
355 This driver can also be built as a module. If so, the module
356 will be called bh1780gli.
357
358config SENSORS_BH1770 348config SENSORS_BH1770
359 tristate "BH1770GLC / SFH7770 combined ALS - Proximity sensor" 349 tristate "BH1770GLC / SFH7770 combined ALS - Proximity sensor"
360 depends on I2C 350 depends on I2C
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 7410c6d9a34d..fb32516ddfe2 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_TIFM_CORE) += tifm_core.o
19obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 19obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
20obj-$(CONFIG_PHANTOM) += phantom.o 20obj-$(CONFIG_PHANTOM) += phantom.o
21obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o 21obj-$(CONFIG_QCOM_COINCELL) += qcom-coincell.o
22obj-$(CONFIG_SENSORS_BH1780) += bh1780gli.o
23obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o 22obj-$(CONFIG_SENSORS_BH1770) += bh1770glc.o
24obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o 23obj-$(CONFIG_SENSORS_APDS990X) += apds990x.o
25obj-$(CONFIG_SGI_IOC4) += ioc4.o 24obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c
deleted file mode 100644
index 7f90ce5a569a..000000000000
--- a/drivers/misc/bh1780gli.c
+++ /dev/null
@@ -1,259 +0,0 @@
1/*
2 * bh1780gli.c
3 * ROHM Ambient Light Sensor Driver
4 *
5 * Copyright (C) 2010 Texas Instruments
6 * Author: Hemanth V <hemanthv@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published by
10 * the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include <linux/i2c.h>
21#include <linux/slab.h>
22#include <linux/mutex.h>
23#include <linux/platform_device.h>
24#include <linux/delay.h>
25#include <linux/module.h>
26#include <linux/of.h>
27
28#define BH1780_REG_CONTROL 0x80
29#define BH1780_REG_PARTID 0x8A
30#define BH1780_REG_MANFID 0x8B
31#define BH1780_REG_DLOW 0x8C
32#define BH1780_REG_DHIGH 0x8D
33
34#define BH1780_REVMASK (0xf)
35#define BH1780_POWMASK (0x3)
36#define BH1780_POFF (0x0)
37#define BH1780_PON (0x3)
38
39/* power on settling time in ms */
40#define BH1780_PON_DELAY 2
41
42struct bh1780_data {
43 struct i2c_client *client;
44 int power_state;
45 /* lock for sysfs operations */
46 struct mutex lock;
47};
48
49static int bh1780_write(struct bh1780_data *ddata, u8 reg, u8 val, char *msg)
50{
51 int ret = i2c_smbus_write_byte_data(ddata->client, reg, val);
52 if (ret < 0)
53 dev_err(&ddata->client->dev,
54 "i2c_smbus_write_byte_data failed error %d Register (%s)\n",
55 ret, msg);
56 return ret;
57}
58
59static int bh1780_read(struct bh1780_data *ddata, u8 reg, char *msg)
60{
61 int ret = i2c_smbus_read_byte_data(ddata->client, reg);
62 if (ret < 0)
63 dev_err(&ddata->client->dev,
64 "i2c_smbus_read_byte_data failed error %d Register (%s)\n",
65 ret, msg);
66 return ret;
67}
68
69static ssize_t bh1780_show_lux(struct device *dev,
70 struct device_attribute *attr, char *buf)
71{
72 struct platform_device *pdev = to_platform_device(dev);
73 struct bh1780_data *ddata = platform_get_drvdata(pdev);
74 int lsb, msb;
75
76 lsb = bh1780_read(ddata, BH1780_REG_DLOW, "DLOW");
77 if (lsb < 0)
78 return lsb;
79
80 msb = bh1780_read(ddata, BH1780_REG_DHIGH, "DHIGH");
81 if (msb < 0)
82 return msb;
83
84 return sprintf(buf, "%d\n", (msb << 8) | lsb);
85}
86
87static ssize_t bh1780_show_power_state(struct device *dev,
88 struct device_attribute *attr,
89 char *buf)
90{
91 struct platform_device *pdev = to_platform_device(dev);
92 struct bh1780_data *ddata = platform_get_drvdata(pdev);
93 int state;
94
95 state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL");
96 if (state < 0)
97 return state;
98
99 return sprintf(buf, "%d\n", state & BH1780_POWMASK);
100}
101
102static ssize_t bh1780_store_power_state(struct device *dev,
103 struct device_attribute *attr,
104 const char *buf, size_t count)
105{
106 struct platform_device *pdev = to_platform_device(dev);
107 struct bh1780_data *ddata = platform_get_drvdata(pdev);
108 unsigned long val;
109 int error;
110
111 error = kstrtoul(buf, 0, &val);
112 if (error)
113 return error;
114
115 if (val < BH1780_POFF || val > BH1780_PON)
116 return -EINVAL;
117
118 mutex_lock(&ddata->lock);
119
120 error = bh1780_write(ddata, BH1780_REG_CONTROL, val, "CONTROL");
121 if (error < 0) {
122 mutex_unlock(&ddata->lock);
123 return error;
124 }
125
126 msleep(BH1780_PON_DELAY);
127 ddata->power_state = val;
128 mutex_unlock(&ddata->lock);
129
130 return count;
131}
132
133static DEVICE_ATTR(lux, S_IRUGO, bh1780_show_lux, NULL);
134
135static DEVICE_ATTR(power_state, S_IWUSR | S_IRUGO,
136 bh1780_show_power_state, bh1780_store_power_state);
137
138static struct attribute *bh1780_attributes[] = {
139 &dev_attr_power_state.attr,
140 &dev_attr_lux.attr,
141 NULL
142};
143
144static const struct attribute_group bh1780_attr_group = {
145 .attrs = bh1780_attributes,
146};
147
148static int bh1780_probe(struct i2c_client *client,
149 const struct i2c_device_id *id)
150{
151 int ret;
152 struct bh1780_data *ddata;
153 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
154
155 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
156 return -EIO;
157
158 ddata = devm_kzalloc(&client->dev, sizeof(struct bh1780_data),
159 GFP_KERNEL);
160 if (ddata == NULL)
161 return -ENOMEM;
162
163 ddata->client = client;
164 i2c_set_clientdata(client, ddata);
165
166 ret = bh1780_read(ddata, BH1780_REG_PARTID, "PART ID");
167 if (ret < 0)
168 return ret;
169
170 dev_info(&client->dev, "Ambient Light Sensor, Rev : %d\n",
171 (ret & BH1780_REVMASK));
172
173 mutex_init(&ddata->lock);
174
175 return sysfs_create_group(&client->dev.kobj, &bh1780_attr_group);
176}
177
178static int bh1780_remove(struct i2c_client *client)
179{
180 sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group);
181
182 return 0;
183}
184
185#ifdef CONFIG_PM_SLEEP
186static int bh1780_suspend(struct device *dev)
187{
188 struct bh1780_data *ddata;
189 int state, ret;
190 struct i2c_client *client = to_i2c_client(dev);
191
192 ddata = i2c_get_clientdata(client);
193 state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL");
194 if (state < 0)
195 return state;
196
197 ddata->power_state = state & BH1780_POWMASK;
198
199 ret = bh1780_write(ddata, BH1780_REG_CONTROL, BH1780_POFF,
200 "CONTROL");
201
202 if (ret < 0)
203 return ret;
204
205 return 0;
206}
207
208static int bh1780_resume(struct device *dev)
209{
210 struct bh1780_data *ddata;
211 int state, ret;
212 struct i2c_client *client = to_i2c_client(dev);
213
214 ddata = i2c_get_clientdata(client);
215 state = ddata->power_state;
216 ret = bh1780_write(ddata, BH1780_REG_CONTROL, state,
217 "CONTROL");
218
219 if (ret < 0)
220 return ret;
221
222 return 0;
223}
224#endif /* CONFIG_PM_SLEEP */
225
226static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume);
227
228static const struct i2c_device_id bh1780_id[] = {
229 { "bh1780", 0 },
230 { },
231};
232
233MODULE_DEVICE_TABLE(i2c, bh1780_id);
234
235#ifdef CONFIG_OF
236static const struct of_device_id of_bh1780_match[] = {
237 { .compatible = "rohm,bh1780gli", },
238 {},
239};
240
241MODULE_DEVICE_TABLE(of, of_bh1780_match);
242#endif
243
244static struct i2c_driver bh1780_driver = {
245 .probe = bh1780_probe,
246 .remove = bh1780_remove,
247 .id_table = bh1780_id,
248 .driver = {
249 .name = "bh1780",
250 .pm = &bh1780_pm,
251 .of_match_table = of_match_ptr(of_bh1780_match),
252 },
253};
254
255module_i2c_driver(bh1780_driver);
256
257MODULE_DESCRIPTION("BH1780GLI Ambient Light Sensor Driver");
258MODULE_LICENSE("GPL");
259MODULE_AUTHOR("Hemanth V <hemanthv@ti.com>");
diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 7ada5f1b7bb6..3519acebfdab 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -230,6 +230,11 @@ int cxl_pci_vphb_add(struct cxl_afu *afu)
230 if (phb->bus == NULL) 230 if (phb->bus == NULL)
231 return -ENXIO; 231 return -ENXIO;
232 232
233 /* Set release hook on root bus */
234 pci_set_host_bridge_release(to_pci_host_bridge(phb->bus->bridge),
235 pcibios_free_controller_deferred,
236 (void *) phb);
237
233 /* Claim resources. This might need some rework as well depending 238 /* Claim resources. This might need some rework as well depending
234 * whether we are doing probe-only or not, like assigning unassigned 239 * whether we are doing probe-only or not, like assigning unassigned
235 * resources etc... 240 * resources etc...
@@ -256,7 +261,10 @@ void cxl_pci_vphb_remove(struct cxl_afu *afu)
256 afu->phb = NULL; 261 afu->phb = NULL;
257 262
258 pci_remove_root_bus(phb->bus); 263 pci_remove_root_bus(phb->bus);
259 pcibios_free_controller(phb); 264 /*
265 * We don't free phb here - that's handled by
266 * pcibios_free_controller_deferred()
267 */
260} 268}
261 269
262static bool _cxl_pci_is_vphb_device(struct pci_controller *phb) 270static bool _cxl_pci_is_vphb_device(struct pci_controller *phb)
diff --git a/drivers/misc/lkdtm_rodata.c b/drivers/misc/lkdtm_rodata.c
index 166b1db3969f..3564477b8c2d 100644
--- a/drivers/misc/lkdtm_rodata.c
+++ b/drivers/misc/lkdtm_rodata.c
@@ -4,7 +4,7 @@
4 */ 4 */
5#include "lkdtm.h" 5#include "lkdtm.h"
6 6
7void lkdtm_rodata_do_nothing(void) 7void notrace lkdtm_rodata_do_nothing(void)
8{ 8{
9 /* Does nothing. We just want an architecture agnostic "return". */ 9 /* Does nothing. We just want an architecture agnostic "return". */
10} 10}
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index e2fb44cc5c37..dc3a854e02d3 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -1263,8 +1263,14 @@ static bool mei_me_fw_type_nm(struct pci_dev *pdev)
1263static bool mei_me_fw_type_sps(struct pci_dev *pdev) 1263static bool mei_me_fw_type_sps(struct pci_dev *pdev)
1264{ 1264{
1265 u32 reg; 1265 u32 reg;
1266 /* Read ME FW Status check for SPS Firmware */ 1266 unsigned int devfn;
1267 pci_read_config_dword(pdev, PCI_CFG_HFS_1, &reg); 1267
1268 /*
1269 * Read ME FW Status register to check for SPS Firmware
1270 * The SPS FW is only signaled in pci function 0
1271 */
1272 devfn = PCI_DEVFN(PCI_SLOT(pdev->devfn), 0);
1273 pci_bus_read_config_dword(pdev->bus, devfn, PCI_CFG_HFS_1, &reg);
1268 trace_mei_pci_cfg_read(&pdev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg); 1274 trace_mei_pci_cfg_read(&pdev->dev, "PCI_CFG_HFS_1", PCI_CFG_HFS_1, reg);
1269 /* if bits [19:16] = 15, running SPS Firmware */ 1275 /* if bits [19:16] = 15, running SPS Firmware */
1270 return (reg & 0xf0000) == 0xf0000; 1276 return (reg & 0xf0000) == 0xf0000;
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 64e64da6da44..71cea9b296b2 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -85,8 +85,8 @@ static const struct pci_device_id mei_me_pci_tbl[] = {
85 85
86 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT, mei_me_pch8_cfg)}, 86 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT, mei_me_pch8_cfg)},
87 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, mei_me_pch8_cfg)}, 87 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_2, mei_me_pch8_cfg)},
88 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, mei_me_pch8_cfg)}, 88 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H, mei_me_pch8_sps_cfg)},
89 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, mei_me_pch8_cfg)}, 89 {MEI_PCI_DEVICE(MEI_DEV_ID_SPT_H_2, mei_me_pch8_sps_cfg)},
90 90
91 {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, mei_me_pch8_cfg)}, 91 {MEI_PCI_DEVICE(MEI_DEV_ID_BXT_M, mei_me_pch8_cfg)},
92 {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, mei_me_pch8_cfg)}, 92 {MEI_PCI_DEVICE(MEI_DEV_ID_APL_I, mei_me_pch8_cfg)},
diff --git a/drivers/net/dsa/bcm_sf2.h b/drivers/net/dsa/bcm_sf2.h
index 463bed8cbe4c..dd446e466699 100644
--- a/drivers/net/dsa/bcm_sf2.h
+++ b/drivers/net/dsa/bcm_sf2.h
@@ -205,8 +205,8 @@ static inline void name##_writeq(struct bcm_sf2_priv *priv, u64 val, \
205static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \ 205static inline void intrl2_##which##_mask_clear(struct bcm_sf2_priv *priv, \
206 u32 mask) \ 206 u32 mask) \
207{ \ 207{ \
208 intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \
209 priv->irq##which##_mask &= ~(mask); \ 208 priv->irq##which##_mask &= ~(mask); \
209 intrl2_##which##_writel(priv, mask, INTRL2_CPU_MASK_CLEAR); \
210} \ 210} \
211static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \ 211static inline void intrl2_##which##_mask_set(struct bcm_sf2_priv *priv, \
212 u32 mask) \ 212 u32 mask) \
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index d1d9d3cf9139..710679067594 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2656,15 +2656,19 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
2656 return ret; 2656 return ret;
2657 } 2657 }
2658 2658
2659 /* Rate Control: disable ingress rate limiting. */
2659 if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) || 2660 if (mv88e6xxx_6352_family(chip) || mv88e6xxx_6351_family(chip) ||
2660 mv88e6xxx_6165_family(chip) || mv88e6xxx_6097_family(chip) || 2661 mv88e6xxx_6165_family(chip) || mv88e6xxx_6097_family(chip) ||
2661 mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip) ||
2662 mv88e6xxx_6320_family(chip)) { 2662 mv88e6xxx_6320_family(chip)) {
2663 /* Rate Control: disable ingress rate limiting. */
2664 ret = _mv88e6xxx_reg_write(chip, REG_PORT(port), 2663 ret = _mv88e6xxx_reg_write(chip, REG_PORT(port),
2665 PORT_RATE_CONTROL, 0x0001); 2664 PORT_RATE_CONTROL, 0x0001);
2666 if (ret) 2665 if (ret)
2667 return ret; 2666 return ret;
2667 } else if (mv88e6xxx_6185_family(chip) || mv88e6xxx_6095_family(chip)) {
2668 ret = _mv88e6xxx_reg_write(chip, REG_PORT(port),
2669 PORT_RATE_CONTROL, 0x0000);
2670 if (ret)
2671 return ret;
2668 } 2672 }
2669 2673
2670 /* Port Control 1: disable trunking, disable sending 2674 /* Port Control 1: disable trunking, disable sending
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 6453148d066a..4eb17daefc4f 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1545,6 +1545,8 @@ static const struct pci_device_id alx_pci_tbl[] = {
1545 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1545 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1546 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400), 1546 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400),
1547 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1547 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1548 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2500),
1549 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1548 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162), 1550 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162),
1549 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1551 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1550 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) }, 1552 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) },
diff --git a/drivers/net/ethernet/atheros/alx/reg.h b/drivers/net/ethernet/atheros/alx/reg.h
index 0959e6824cb6..1fc2d852249f 100644
--- a/drivers/net/ethernet/atheros/alx/reg.h
+++ b/drivers/net/ethernet/atheros/alx/reg.h
@@ -38,6 +38,7 @@
38#define ALX_DEV_ID_AR8161 0x1091 38#define ALX_DEV_ID_AR8161 0x1091
39#define ALX_DEV_ID_E2200 0xe091 39#define ALX_DEV_ID_E2200 0xe091
40#define ALX_DEV_ID_E2400 0xe0a1 40#define ALX_DEV_ID_E2400 0xe0a1
41#define ALX_DEV_ID_E2500 0xe0b1
41#define ALX_DEV_ID_AR8162 0x1090 42#define ALX_DEV_ID_AR8162 0x1090
42#define ALX_DEV_ID_AR8171 0x10A1 43#define ALX_DEV_ID_AR8171 0x10A1
43#define ALX_DEV_ID_AR8172 0x10A0 44#define ALX_DEV_ID_AR8172 0x10A0
diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c
index 9a9745c4047c..625235db644f 100644
--- a/drivers/net/ethernet/broadcom/bgmac-bcma.c
+++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c
@@ -159,7 +159,7 @@ static int bgmac_probe(struct bcma_device *core)
159 159
160 if (!bgmac_is_bcm4707_family(core)) { 160 if (!bgmac_is_bcm4707_family(core)) {
161 mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr); 161 mii_bus = bcma_mdio_mii_register(core, bgmac->phyaddr);
162 if (!IS_ERR(mii_bus)) { 162 if (IS_ERR(mii_bus)) {
163 err = PTR_ERR(mii_bus); 163 err = PTR_ERR(mii_bus);
164 goto err; 164 goto err;
165 } 165 }
diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h
index afb10e326b4f..fab35a593898 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_reg.h
+++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h
@@ -170,7 +170,6 @@
170#define NIC_QSET_SQ_0_7_DOOR (0x010838) 170#define NIC_QSET_SQ_0_7_DOOR (0x010838)
171#define NIC_QSET_SQ_0_7_STATUS (0x010840) 171#define NIC_QSET_SQ_0_7_STATUS (0x010840)
172#define NIC_QSET_SQ_0_7_DEBUG (0x010848) 172#define NIC_QSET_SQ_0_7_DEBUG (0x010848)
173#define NIC_QSET_SQ_0_7_CNM_CHG (0x010860)
174#define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900) 173#define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900)
175 174
176#define NIC_QSET_RBDR_0_1_CFG (0x010C00) 175#define NIC_QSET_RBDR_0_1_CFG (0x010C00)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
index d2d8ef270142..ad4fddb55421 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
@@ -382,7 +382,10 @@ static void nicvf_get_regs(struct net_device *dev,
382 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q); 382 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q);
383 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q); 383 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q);
384 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q); 384 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q);
385 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_CNM_CHG, q); 385 /* Padding, was NIC_QSET_SQ_0_7_CNM_CHG, which
386 * produces bus errors when read
387 */
388 p[i++] = 0;
386 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q); 389 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q);
387 reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3); 390 reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3);
388 p[i++] = nicvf_queue_reg_read(nic, reg_offset, q); 391 p[i++] = nicvf_queue_reg_read(nic, reg_offset, q);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c45de49dc963..c762a8c8c954 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4335,6 +4335,11 @@ static void cfg_queues(struct adapter *adap)
4335#endif 4335#endif
4336 int ciq_size; 4336 int ciq_size;
4337 4337
4338 /* Reduce memory usage in kdump environment, disable all offload.
4339 */
4340 if (is_kdump_kernel())
4341 adap->params.offload = 0;
4342
4338 for_each_port(adap, i) 4343 for_each_port(adap, i)
4339 n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg); 4344 n10g += is_x_10g_port(&adap2pinfo(adap, i)->link_cfg);
4340#ifdef CONFIG_CHELSIO_T4_DCB 4345#ifdef CONFIG_CHELSIO_T4_DCB
@@ -4365,11 +4370,6 @@ static void cfg_queues(struct adapter *adap)
4365 if (q10g > netif_get_num_default_rss_queues()) 4370 if (q10g > netif_get_num_default_rss_queues())
4366 q10g = netif_get_num_default_rss_queues(); 4371 q10g = netif_get_num_default_rss_queues();
4367 4372
4368 /* Reduce memory usage in kdump environment, disable all offload.
4369 */
4370 if (is_kdump_kernel())
4371 adap->params.offload = 0;
4372
4373 for_each_port(adap, i) { 4373 for_each_port(adap, i) {
4374 struct port_info *pi = adap2pinfo(adap, i); 4374 struct port_info *pi = adap2pinfo(adap, i);
4375 4375
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index d20935dc8399..4b4f5bc0e279 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2922,17 +2922,25 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus,
2922{ 2922{
2923 unsigned int size = lstatus & BD_LENGTH_MASK; 2923 unsigned int size = lstatus & BD_LENGTH_MASK;
2924 struct page *page = rxb->page; 2924 struct page *page = rxb->page;
2925 bool last = !!(lstatus & BD_LFLAG(RXBD_LAST));
2925 2926
2926 /* Remove the FCS from the packet length */ 2927 /* Remove the FCS from the packet length */
2927 if (likely(lstatus & BD_LFLAG(RXBD_LAST))) 2928 if (last)
2928 size -= ETH_FCS_LEN; 2929 size -= ETH_FCS_LEN;
2929 2930
2930 if (likely(first)) 2931 if (likely(first)) {
2931 skb_put(skb, size); 2932 skb_put(skb, size);
2932 else 2933 } else {
2933 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, 2934 /* the last fragments' length contains the full frame length */
2934 rxb->page_offset + RXBUF_ALIGNMENT, 2935 if (last)
2935 size, GFAR_RXB_TRUESIZE); 2936 size -= skb->len;
2937
2938 /* in case the last fragment consisted only of the FCS */
2939 if (size > 0)
2940 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
2941 rxb->page_offset + RXBUF_ALIGNMENT,
2942 size, GFAR_RXB_TRUESIZE);
2943 }
2936 2944
2937 /* try reuse page */ 2945 /* try reuse page */
2938 if (unlikely(page_count(page) != 1)) 2946 if (unlikely(page_count(page) != 1))
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 373fd094f2f3..6e8a9c8467b9 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -100,7 +100,8 @@ extern const char gfar_driver_version[];
100#define DEFAULT_RX_LFC_THR 16 100#define DEFAULT_RX_LFC_THR 16
101#define DEFAULT_LFC_PTVVAL 4 101#define DEFAULT_LFC_PTVVAL 4
102 102
103#define GFAR_RXB_SIZE 1536 103/* prevent fragmenation by HW in DSA environments */
104#define GFAR_RXB_SIZE roundup(1536 + 8, 64)
104#define GFAR_SKBFRAG_SIZE (RXBUF_ALIGNMENT + GFAR_RXB_SIZE \ 105#define GFAR_SKBFRAG_SIZE (RXBUF_ALIGNMENT + GFAR_RXB_SIZE \
105 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) 106 + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
106#define GFAR_RXB_TRUESIZE 2048 107#define GFAR_RXB_TRUESIZE 2048
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
index ff8b6a468b24..6ea872287307 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
@@ -328,9 +328,10 @@ static void hns_ppe_init_hw(struct hns_ppe_cb *ppe_cb)
328static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb) 328static void hns_ppe_uninit_hw(struct hns_ppe_cb *ppe_cb)
329{ 329{
330 u32 port; 330 u32 port;
331 struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev;
332 331
333 if (ppe_cb->ppe_common_cb) { 332 if (ppe_cb->ppe_common_cb) {
333 struct dsaf_device *dsaf_dev = ppe_cb->ppe_common_cb->dsaf_dev;
334
334 port = ppe_cb->index; 335 port = ppe_cb->index;
335 dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0); 336 dsaf_dev->misc_op->ppe_srst(dsaf_dev, port, 0);
336 } 337 }
diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c b/drivers/net/ethernet/intel/i40e/i40e_client.c
index e1370c556a3c..618f18436618 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -199,6 +199,7 @@ void i40e_notify_client_of_l2_param_changes(struct i40e_vsi *vsi)
199void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi) 199void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi)
200{ 200{
201 struct i40e_client_instance *cdev; 201 struct i40e_client_instance *cdev;
202 int ret = 0;
202 203
203 if (!vsi) 204 if (!vsi)
204 return; 205 return;
@@ -211,7 +212,14 @@ void i40e_notify_client_of_netdev_open(struct i40e_vsi *vsi)
211 "Cannot locate client instance open routine\n"); 212 "Cannot locate client instance open routine\n");
212 continue; 213 continue;
213 } 214 }
214 cdev->client->ops->open(&cdev->lan_info, cdev->client); 215 if (!(test_bit(__I40E_CLIENT_INSTANCE_OPENED,
216 &cdev->state))) {
217 ret = cdev->client->ops->open(&cdev->lan_info,
218 cdev->client);
219 if (!ret)
220 set_bit(__I40E_CLIENT_INSTANCE_OPENED,
221 &cdev->state);
222 }
215 } 223 }
216 } 224 }
217 mutex_unlock(&i40e_client_instance_mutex); 225 mutex_unlock(&i40e_client_instance_mutex);
@@ -407,12 +415,14 @@ struct i40e_vsi *i40e_vsi_lookup(struct i40e_pf *pf,
407 * i40e_client_add_instance - add a client instance struct to the instance list 415 * i40e_client_add_instance - add a client instance struct to the instance list
408 * @pf: pointer to the board struct 416 * @pf: pointer to the board struct
409 * @client: pointer to a client struct in the client list. 417 * @client: pointer to a client struct in the client list.
418 * @existing: if there was already an existing instance
410 * 419 *
411 * Returns cdev ptr on success, NULL on failure 420 * Returns cdev ptr on success or if already exists, NULL on failure
412 **/ 421 **/
413static 422static
414struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf, 423struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
415 struct i40e_client *client) 424 struct i40e_client *client,
425 bool *existing)
416{ 426{
417 struct i40e_client_instance *cdev; 427 struct i40e_client_instance *cdev;
418 struct netdev_hw_addr *mac = NULL; 428 struct netdev_hw_addr *mac = NULL;
@@ -421,7 +431,7 @@ struct i40e_client_instance *i40e_client_add_instance(struct i40e_pf *pf,
421 mutex_lock(&i40e_client_instance_mutex); 431 mutex_lock(&i40e_client_instance_mutex);
422 list_for_each_entry(cdev, &i40e_client_instances, list) { 432 list_for_each_entry(cdev, &i40e_client_instances, list) {
423 if ((cdev->lan_info.pf == pf) && (cdev->client == client)) { 433 if ((cdev->lan_info.pf == pf) && (cdev->client == client)) {
424 cdev = NULL; 434 *existing = true;
425 goto out; 435 goto out;
426 } 436 }
427 } 437 }
@@ -505,6 +515,7 @@ void i40e_client_subtask(struct i40e_pf *pf)
505{ 515{
506 struct i40e_client_instance *cdev; 516 struct i40e_client_instance *cdev;
507 struct i40e_client *client; 517 struct i40e_client *client;
518 bool existing = false;
508 int ret = 0; 519 int ret = 0;
509 520
510 if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED)) 521 if (!(pf->flags & I40E_FLAG_SERVICE_CLIENT_REQUESTED))
@@ -528,18 +539,25 @@ void i40e_client_subtask(struct i40e_pf *pf)
528 /* check if L2 VSI is up, if not we are not ready */ 539 /* check if L2 VSI is up, if not we are not ready */
529 if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state)) 540 if (test_bit(__I40E_DOWN, &pf->vsi[pf->lan_vsi]->state))
530 continue; 541 continue;
542 } else {
543 dev_warn(&pf->pdev->dev, "This client %s is being instanciated at probe\n",
544 client->name);
531 } 545 }
532 546
533 /* Add the client instance to the instance list */ 547 /* Add the client instance to the instance list */
534 cdev = i40e_client_add_instance(pf, client); 548 cdev = i40e_client_add_instance(pf, client, &existing);
535 if (!cdev) 549 if (!cdev)
536 continue; 550 continue;
537 551
538 /* Also up the ref_cnt of no. of instances of this client */ 552 if (!existing) {
539 atomic_inc(&client->ref_cnt); 553 /* Also up the ref_cnt for no. of instances of this
540 dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n", 554 * client.
541 client->name, pf->hw.pf_id, 555 */
542 pf->hw.bus.device, pf->hw.bus.func); 556 atomic_inc(&client->ref_cnt);
557 dev_info(&pf->pdev->dev, "Added instance of Client %s to PF%d bus=0x%02x func=0x%02x\n",
558 client->name, pf->hw.pf_id,
559 pf->hw.bus.device, pf->hw.bus.func);
560 }
543 561
544 /* Send an Open request to the client */ 562 /* Send an Open request to the client */
545 atomic_inc(&cdev->ref_cnt); 563 atomic_inc(&cdev->ref_cnt);
@@ -588,7 +606,8 @@ int i40e_lan_add_device(struct i40e_pf *pf)
588 pf->hw.pf_id, pf->hw.bus.device, pf->hw.bus.func); 606 pf->hw.pf_id, pf->hw.bus.device, pf->hw.bus.func);
589 607
590 /* Since in some cases register may have happened before a device gets 608 /* Since in some cases register may have happened before a device gets
591 * added, we can schedule a subtask to go initiate the clients. 609 * added, we can schedule a subtask to go initiate the clients if
610 * they can be launched at probe time.
592 */ 611 */
593 pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED; 612 pf->flags |= I40E_FLAG_SERVICE_CLIENT_REQUESTED;
594 i40e_service_event_schedule(pf); 613 i40e_service_event_schedule(pf);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index c6ac7a61812f..828ed28c3c14 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -5431,7 +5431,6 @@ int i40e_open(struct net_device *netdev)
5431 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16); 5431 wr32(&pf->hw, I40E_GLLAN_TSOMSK_L, be32_to_cpu(TCP_FLAG_CWR) >> 16);
5432 5432
5433 udp_tunnel_get_rx_info(netdev); 5433 udp_tunnel_get_rx_info(netdev);
5434 i40e_notify_client_of_netdev_open(vsi);
5435 5434
5436 return 0; 5435 return 0;
5437} 5436}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index b4217f30e89c..c47b605e8651 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -2958,8 +2958,10 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
2958 } 2958 }
2959 2959
2960 /* was that the last pool using this rar? */ 2960 /* was that the last pool using this rar? */
2961 if (mpsar_lo == 0 && mpsar_hi == 0 && rar != 0) 2961 if (mpsar_lo == 0 && mpsar_hi == 0 &&
2962 rar != 0 && rar != hw->mac.san_mac_rar_index)
2962 hw->mac.ops.clear_rar(hw, rar); 2963 hw->mac.ops.clear_rar(hw, rar);
2964
2963 return 0; 2965 return 0;
2964} 2966}
2965 2967
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index d6e2a1cae19a..c2ec01a22d55 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -143,13 +143,14 @@ static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx)
143 return cmd->cmd_buf + (idx << cmd->log_stride); 143 return cmd->cmd_buf + (idx << cmd->log_stride);
144} 144}
145 145
146static u8 xor8_buf(void *buf, int len) 146static u8 xor8_buf(void *buf, size_t offset, int len)
147{ 147{
148 u8 *ptr = buf; 148 u8 *ptr = buf;
149 u8 sum = 0; 149 u8 sum = 0;
150 int i; 150 int i;
151 int end = len + offset;
151 152
152 for (i = 0; i < len; i++) 153 for (i = offset; i < end; i++)
153 sum ^= ptr[i]; 154 sum ^= ptr[i];
154 155
155 return sum; 156 return sum;
@@ -157,41 +158,49 @@ static u8 xor8_buf(void *buf, int len)
157 158
158static int verify_block_sig(struct mlx5_cmd_prot_block *block) 159static int verify_block_sig(struct mlx5_cmd_prot_block *block)
159{ 160{
160 if (xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 1) != 0xff) 161 size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0);
162 int xor_len = sizeof(*block) - sizeof(block->data) - 1;
163
164 if (xor8_buf(block, rsvd0_off, xor_len) != 0xff)
161 return -EINVAL; 165 return -EINVAL;
162 166
163 if (xor8_buf(block, sizeof(*block)) != 0xff) 167 if (xor8_buf(block, 0, sizeof(*block)) != 0xff)
164 return -EINVAL; 168 return -EINVAL;
165 169
166 return 0; 170 return 0;
167} 171}
168 172
169static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, 173static void calc_block_sig(struct mlx5_cmd_prot_block *block)
170 int csum)
171{ 174{
172 block->token = token; 175 int ctrl_xor_len = sizeof(*block) - sizeof(block->data) - 2;
173 if (csum) { 176 size_t rsvd0_off = offsetof(struct mlx5_cmd_prot_block, rsvd0);
174 block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - 177
175 sizeof(block->data) - 2); 178 block->ctrl_sig = ~xor8_buf(block, rsvd0_off, ctrl_xor_len);
176 block->sig = ~xor8_buf(block, sizeof(*block) - 1); 179 block->sig = ~xor8_buf(block, 0, sizeof(*block) - 1);
177 }
178} 180}
179 181
180static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) 182static void calc_chain_sig(struct mlx5_cmd_msg *msg)
181{ 183{
182 struct mlx5_cmd_mailbox *next = msg->next; 184 struct mlx5_cmd_mailbox *next = msg->next;
183 185 int size = msg->len;
184 while (next) { 186 int blen = size - min_t(int, sizeof(msg->first.data), size);
185 calc_block_sig(next->buf, token, csum); 187 int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1)
188 / MLX5_CMD_DATA_BLOCK_SIZE;
189 int i = 0;
190
191 for (i = 0; i < n && next; i++) {
192 calc_block_sig(next->buf);
186 next = next->next; 193 next = next->next;
187 } 194 }
188} 195}
189 196
190static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) 197static void set_signature(struct mlx5_cmd_work_ent *ent, int csum)
191{ 198{
192 ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); 199 ent->lay->sig = ~xor8_buf(ent->lay, 0, sizeof(*ent->lay));
193 calc_chain_sig(ent->in, ent->token, csum); 200 if (csum) {
194 calc_chain_sig(ent->out, ent->token, csum); 201 calc_chain_sig(ent->in);
202 calc_chain_sig(ent->out);
203 }
195} 204}
196 205
197static void poll_timeout(struct mlx5_cmd_work_ent *ent) 206static void poll_timeout(struct mlx5_cmd_work_ent *ent)
@@ -222,12 +231,17 @@ static int verify_signature(struct mlx5_cmd_work_ent *ent)
222 struct mlx5_cmd_mailbox *next = ent->out->next; 231 struct mlx5_cmd_mailbox *next = ent->out->next;
223 int err; 232 int err;
224 u8 sig; 233 u8 sig;
234 int size = ent->out->len;
235 int blen = size - min_t(int, sizeof(ent->out->first.data), size);
236 int n = (blen + MLX5_CMD_DATA_BLOCK_SIZE - 1)
237 / MLX5_CMD_DATA_BLOCK_SIZE;
238 int i = 0;
225 239
226 sig = xor8_buf(ent->lay, sizeof(*ent->lay)); 240 sig = xor8_buf(ent->lay, 0, sizeof(*ent->lay));
227 if (sig != 0xff) 241 if (sig != 0xff)
228 return -EINVAL; 242 return -EINVAL;
229 243
230 while (next) { 244 for (i = 0; i < n && next; i++) {
231 err = verify_block_sig(next->buf); 245 err = verify_block_sig(next->buf);
232 if (err) 246 if (err)
233 return err; 247 return err;
@@ -656,7 +670,6 @@ static void cmd_work_handler(struct work_struct *work)
656 spin_unlock_irqrestore(&cmd->alloc_lock, flags); 670 spin_unlock_irqrestore(&cmd->alloc_lock, flags);
657 } 671 }
658 672
659 ent->token = alloc_token(cmd);
660 cmd->ent_arr[ent->idx] = ent; 673 cmd->ent_arr[ent->idx] = ent;
661 lay = get_inst(cmd, ent->idx); 674 lay = get_inst(cmd, ent->idx);
662 ent->lay = lay; 675 ent->lay = lay;
@@ -766,7 +779,8 @@ static u8 *get_status_ptr(struct mlx5_outbox_hdr *out)
766static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in, 779static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
767 struct mlx5_cmd_msg *out, void *uout, int uout_size, 780 struct mlx5_cmd_msg *out, void *uout, int uout_size,
768 mlx5_cmd_cbk_t callback, 781 mlx5_cmd_cbk_t callback,
769 void *context, int page_queue, u8 *status) 782 void *context, int page_queue, u8 *status,
783 u8 token)
770{ 784{
771 struct mlx5_cmd *cmd = &dev->cmd; 785 struct mlx5_cmd *cmd = &dev->cmd;
772 struct mlx5_cmd_work_ent *ent; 786 struct mlx5_cmd_work_ent *ent;
@@ -783,6 +797,8 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
783 if (IS_ERR(ent)) 797 if (IS_ERR(ent))
784 return PTR_ERR(ent); 798 return PTR_ERR(ent);
785 799
800 ent->token = token;
801
786 if (!callback) 802 if (!callback)
787 init_completion(&ent->done); 803 init_completion(&ent->done);
788 804
@@ -854,7 +870,8 @@ static const struct file_operations fops = {
854 .write = dbg_write, 870 .write = dbg_write,
855}; 871};
856 872
857static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size) 873static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size,
874 u8 token)
858{ 875{
859 struct mlx5_cmd_prot_block *block; 876 struct mlx5_cmd_prot_block *block;
860 struct mlx5_cmd_mailbox *next; 877 struct mlx5_cmd_mailbox *next;
@@ -880,6 +897,7 @@ static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size)
880 memcpy(block->data, from, copy); 897 memcpy(block->data, from, copy);
881 from += copy; 898 from += copy;
882 size -= copy; 899 size -= copy;
900 block->token = token;
883 next = next->next; 901 next = next->next;
884 } 902 }
885 903
@@ -949,7 +967,8 @@ static void free_cmd_box(struct mlx5_core_dev *dev,
949} 967}
950 968
951static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, 969static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev,
952 gfp_t flags, int size) 970 gfp_t flags, int size,
971 u8 token)
953{ 972{
954 struct mlx5_cmd_mailbox *tmp, *head = NULL; 973 struct mlx5_cmd_mailbox *tmp, *head = NULL;
955 struct mlx5_cmd_prot_block *block; 974 struct mlx5_cmd_prot_block *block;
@@ -978,6 +997,7 @@ static struct mlx5_cmd_msg *mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev,
978 tmp->next = head; 997 tmp->next = head;
979 block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0); 998 block->next = cpu_to_be64(tmp->next ? tmp->next->dma : 0);
980 block->block_num = cpu_to_be32(n - i - 1); 999 block->block_num = cpu_to_be32(n - i - 1);
1000 block->token = token;
981 head = tmp; 1001 head = tmp;
982 } 1002 }
983 msg->next = head; 1003 msg->next = head;
@@ -1352,7 +1372,7 @@ static struct mlx5_cmd_msg *alloc_msg(struct mlx5_core_dev *dev, int in_size,
1352 } 1372 }
1353 1373
1354 if (IS_ERR(msg)) 1374 if (IS_ERR(msg))
1355 msg = mlx5_alloc_cmd_msg(dev, gfp, in_size); 1375 msg = mlx5_alloc_cmd_msg(dev, gfp, in_size, 0);
1356 1376
1357 return msg; 1377 return msg;
1358} 1378}
@@ -1377,6 +1397,7 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
1377 int err; 1397 int err;
1378 u8 status = 0; 1398 u8 status = 0;
1379 u32 drv_synd; 1399 u32 drv_synd;
1400 u8 token;
1380 1401
1381 if (pci_channel_offline(dev->pdev) || 1402 if (pci_channel_offline(dev->pdev) ||
1382 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) { 1403 dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
@@ -1395,20 +1416,22 @@ static int cmd_exec(struct mlx5_core_dev *dev, void *in, int in_size, void *out,
1395 return err; 1416 return err;
1396 } 1417 }
1397 1418
1398 err = mlx5_copy_to_msg(inb, in, in_size); 1419 token = alloc_token(&dev->cmd);
1420
1421 err = mlx5_copy_to_msg(inb, in, in_size, token);
1399 if (err) { 1422 if (err) {
1400 mlx5_core_warn(dev, "err %d\n", err); 1423 mlx5_core_warn(dev, "err %d\n", err);
1401 goto out_in; 1424 goto out_in;
1402 } 1425 }
1403 1426
1404 outb = mlx5_alloc_cmd_msg(dev, gfp, out_size); 1427 outb = mlx5_alloc_cmd_msg(dev, gfp, out_size, token);
1405 if (IS_ERR(outb)) { 1428 if (IS_ERR(outb)) {
1406 err = PTR_ERR(outb); 1429 err = PTR_ERR(outb);
1407 goto out_in; 1430 goto out_in;
1408 } 1431 }
1409 1432
1410 err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context, 1433 err = mlx5_cmd_invoke(dev, inb, outb, out, out_size, callback, context,
1411 pages_queue, &status); 1434 pages_queue, &status, token);
1412 if (err) 1435 if (err)
1413 goto out_out; 1436 goto out_out;
1414 1437
@@ -1476,7 +1499,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev)
1476 INIT_LIST_HEAD(&cmd->cache.med.head); 1499 INIT_LIST_HEAD(&cmd->cache.med.head);
1477 1500
1478 for (i = 0; i < NUM_LONG_LISTS; i++) { 1501 for (i = 0; i < NUM_LONG_LISTS; i++) {
1479 msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE); 1502 msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, LONG_LIST_SIZE, 0);
1480 if (IS_ERR(msg)) { 1503 if (IS_ERR(msg)) {
1481 err = PTR_ERR(msg); 1504 err = PTR_ERR(msg);
1482 goto ex_err; 1505 goto ex_err;
@@ -1486,7 +1509,7 @@ static int create_msg_cache(struct mlx5_core_dev *dev)
1486 } 1509 }
1487 1510
1488 for (i = 0; i < NUM_MED_LISTS; i++) { 1511 for (i = 0; i < NUM_MED_LISTS; i++) {
1489 msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE); 1512 msg = mlx5_alloc_cmd_msg(dev, GFP_KERNEL, MED_LIST_SIZE, 0);
1490 if (IS_ERR(msg)) { 1513 if (IS_ERR(msg)) {
1491 err = PTR_ERR(msg); 1514 err = PTR_ERR(msg);
1492 goto ex_err; 1515 goto ex_err;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 1b495efa7490..bf722aa88cf0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -73,8 +73,12 @@
73#define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER) 73#define MLX5_MPWRQ_PAGES_PER_WQE BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
74#define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \ 74#define MLX5_MPWRQ_STRIDES_PER_PAGE (MLX5_MPWRQ_NUM_STRIDES >> \
75 MLX5_MPWRQ_WQE_PAGE_ORDER) 75 MLX5_MPWRQ_WQE_PAGE_ORDER)
76#define MLX5_CHANNEL_MAX_NUM_MTTS (ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8) * \ 76
77 BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW)) 77#define MLX5_MTT_OCTW(npages) (ALIGN(npages, 8) / 2)
78#define MLX5E_REQUIRED_MTTS(rqs, wqes)\
79 (rqs * wqes * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8))
80#define MLX5E_VALID_NUM_MTTS(num_mtts) (MLX5_MTT_OCTW(num_mtts) <= U16_MAX)
81
78#define MLX5_UMR_ALIGN (2048) 82#define MLX5_UMR_ALIGN (2048)
79#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128) 83#define MLX5_MPWRQ_SMALL_PACKET_THRESHOLD (128)
80 84
@@ -219,9 +223,8 @@ struct mlx5e_tstamp {
219}; 223};
220 224
221enum { 225enum {
222 MLX5E_RQ_STATE_POST_WQES_ENABLE, 226 MLX5E_RQ_STATE_FLUSH,
223 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, 227 MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
224 MLX5E_RQ_STATE_FLUSH_TIMEOUT,
225 MLX5E_RQ_STATE_AM, 228 MLX5E_RQ_STATE_AM,
226}; 229};
227 230
@@ -304,6 +307,7 @@ struct mlx5e_rq {
304 307
305 unsigned long state; 308 unsigned long state;
306 int ix; 309 int ix;
310 u32 mpwqe_mtt_offset;
307 311
308 struct mlx5e_rx_am am; /* Adaptive Moderation */ 312 struct mlx5e_rx_am am; /* Adaptive Moderation */
309 313
@@ -365,9 +369,8 @@ struct mlx5e_sq_dma {
365}; 369};
366 370
367enum { 371enum {
368 MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, 372 MLX5E_SQ_STATE_FLUSH,
369 MLX5E_SQ_STATE_BF_ENABLE, 373 MLX5E_SQ_STATE_BF_ENABLE,
370 MLX5E_SQ_STATE_TX_TIMEOUT,
371}; 374};
372 375
373struct mlx5e_ico_wqe_info { 376struct mlx5e_ico_wqe_info {
@@ -698,7 +701,6 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget);
698bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget); 701bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget);
699int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget); 702int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget);
700void mlx5e_free_tx_descs(struct mlx5e_sq *sq); 703void mlx5e_free_tx_descs(struct mlx5e_sq *sq);
701void mlx5e_free_rx_descs(struct mlx5e_rq *rq);
702 704
703void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 705void mlx5e_handle_rx_cqe(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
704void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); 706void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
@@ -814,11 +816,6 @@ static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
814 MLX5E_MAX_NUM_CHANNELS); 816 MLX5E_MAX_NUM_CHANNELS);
815} 817}
816 818
817static inline int mlx5e_get_mtt_octw(int npages)
818{
819 return ALIGN(npages, 8) / 2;
820}
821
822extern const struct ethtool_ops mlx5e_ethtool_ops; 819extern const struct ethtool_ops mlx5e_ethtool_ops;
823#ifdef CONFIG_MLX5_CORE_EN_DCB 820#ifdef CONFIG_MLX5_CORE_EN_DCB
824extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops; 821extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
index 673043ccd76c..9cce153e1035 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_common.c
@@ -139,7 +139,7 @@ int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev)
139 struct mlx5e_tir *tir; 139 struct mlx5e_tir *tir;
140 void *in; 140 void *in;
141 int inlen; 141 int inlen;
142 int err; 142 int err = 0;
143 143
144 inlen = MLX5_ST_SZ_BYTES(modify_tir_in); 144 inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
145 in = mlx5_vzalloc(inlen); 145 in = mlx5_vzalloc(inlen);
@@ -151,10 +151,11 @@ int mlx5e_refresh_tirs_self_loopback_enable(struct mlx5_core_dev *mdev)
151 list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) { 151 list_for_each_entry(tir, &mdev->mlx5e_res.td.tirs_list, list) {
152 err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen); 152 err = mlx5_core_modify_tir(mdev, tir->tirn, in, inlen);
153 if (err) 153 if (err)
154 return err; 154 goto out;
155 } 155 }
156 156
157out:
157 kvfree(in); 158 kvfree(in);
158 159
159 return 0; 160 return err;
160} 161}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index caa9a3ccc3f3..762af16ed021 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -127,29 +127,40 @@ int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets)
127 return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw); 127 return mlx5_set_port_tc_bw_alloc(mdev, tc_tx_bw);
128} 128}
129 129
130static int mlx5e_dbcnl_validate_ets(struct ieee_ets *ets) 130static int mlx5e_dbcnl_validate_ets(struct net_device *netdev,
131 struct ieee_ets *ets)
131{ 132{
132 int bw_sum = 0; 133 int bw_sum = 0;
133 int i; 134 int i;
134 135
135 /* Validate Priority */ 136 /* Validate Priority */
136 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 137 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
137 if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY) 138 if (ets->prio_tc[i] >= MLX5E_MAX_PRIORITY) {
139 netdev_err(netdev,
140 "Failed to validate ETS: priority value greater than max(%d)\n",
141 MLX5E_MAX_PRIORITY);
138 return -EINVAL; 142 return -EINVAL;
143 }
139 } 144 }
140 145
141 /* Validate Bandwidth Sum */ 146 /* Validate Bandwidth Sum */
142 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 147 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
143 if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) { 148 if (ets->tc_tsa[i] == IEEE_8021QAZ_TSA_ETS) {
144 if (!ets->tc_tx_bw[i]) 149 if (!ets->tc_tx_bw[i]) {
150 netdev_err(netdev,
151 "Failed to validate ETS: BW 0 is illegal\n");
145 return -EINVAL; 152 return -EINVAL;
153 }
146 154
147 bw_sum += ets->tc_tx_bw[i]; 155 bw_sum += ets->tc_tx_bw[i];
148 } 156 }
149 } 157 }
150 158
151 if (bw_sum != 0 && bw_sum != 100) 159 if (bw_sum != 0 && bw_sum != 100) {
160 netdev_err(netdev,
161 "Failed to validate ETS: BW sum is illegal\n");
152 return -EINVAL; 162 return -EINVAL;
163 }
153 return 0; 164 return 0;
154} 165}
155 166
@@ -159,7 +170,7 @@ static int mlx5e_dcbnl_ieee_setets(struct net_device *netdev,
159 struct mlx5e_priv *priv = netdev_priv(netdev); 170 struct mlx5e_priv *priv = netdev_priv(netdev);
160 int err; 171 int err;
161 172
162 err = mlx5e_dbcnl_validate_ets(ets); 173 err = mlx5e_dbcnl_validate_ets(netdev, ets);
163 if (err) 174 if (err)
164 return err; 175 return err;
165 176
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index 4a3757e60441..d0cf8fa22659 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -352,15 +352,61 @@ static void mlx5e_get_ethtool_stats(struct net_device *dev,
352 sq_stats_desc, j); 352 sq_stats_desc, j);
353} 353}
354 354
355static u32 mlx5e_rx_wqes_to_packets(struct mlx5e_priv *priv, int rq_wq_type,
356 int num_wqe)
357{
358 int packets_per_wqe;
359 int stride_size;
360 int num_strides;
361 int wqe_size;
362
363 if (rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
364 return num_wqe;
365
366 stride_size = 1 << priv->params.mpwqe_log_stride_sz;
367 num_strides = 1 << priv->params.mpwqe_log_num_strides;
368 wqe_size = stride_size * num_strides;
369
370 packets_per_wqe = wqe_size /
371 ALIGN(ETH_DATA_LEN, stride_size);
372 return (1 << (order_base_2(num_wqe * packets_per_wqe) - 1));
373}
374
375static u32 mlx5e_packets_to_rx_wqes(struct mlx5e_priv *priv, int rq_wq_type,
376 int num_packets)
377{
378 int packets_per_wqe;
379 int stride_size;
380 int num_strides;
381 int wqe_size;
382 int num_wqes;
383
384 if (rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
385 return num_packets;
386
387 stride_size = 1 << priv->params.mpwqe_log_stride_sz;
388 num_strides = 1 << priv->params.mpwqe_log_num_strides;
389 wqe_size = stride_size * num_strides;
390
391 num_packets = (1 << order_base_2(num_packets));
392
393 packets_per_wqe = wqe_size /
394 ALIGN(ETH_DATA_LEN, stride_size);
395 num_wqes = DIV_ROUND_UP(num_packets, packets_per_wqe);
396 return 1 << (order_base_2(num_wqes));
397}
398
355static void mlx5e_get_ringparam(struct net_device *dev, 399static void mlx5e_get_ringparam(struct net_device *dev,
356 struct ethtool_ringparam *param) 400 struct ethtool_ringparam *param)
357{ 401{
358 struct mlx5e_priv *priv = netdev_priv(dev); 402 struct mlx5e_priv *priv = netdev_priv(dev);
359 int rq_wq_type = priv->params.rq_wq_type; 403 int rq_wq_type = priv->params.rq_wq_type;
360 404
361 param->rx_max_pending = 1 << mlx5_max_log_rq_size(rq_wq_type); 405 param->rx_max_pending = mlx5e_rx_wqes_to_packets(priv, rq_wq_type,
406 1 << mlx5_max_log_rq_size(rq_wq_type));
362 param->tx_max_pending = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE; 407 param->tx_max_pending = 1 << MLX5E_PARAMS_MAXIMUM_LOG_SQ_SIZE;
363 param->rx_pending = 1 << priv->params.log_rq_size; 408 param->rx_pending = mlx5e_rx_wqes_to_packets(priv, rq_wq_type,
409 1 << priv->params.log_rq_size);
364 param->tx_pending = 1 << priv->params.log_sq_size; 410 param->tx_pending = 1 << priv->params.log_sq_size;
365} 411}
366 412
@@ -370,9 +416,13 @@ static int mlx5e_set_ringparam(struct net_device *dev,
370 struct mlx5e_priv *priv = netdev_priv(dev); 416 struct mlx5e_priv *priv = netdev_priv(dev);
371 bool was_opened; 417 bool was_opened;
372 int rq_wq_type = priv->params.rq_wq_type; 418 int rq_wq_type = priv->params.rq_wq_type;
419 u32 rx_pending_wqes;
420 u32 min_rq_size;
421 u32 max_rq_size;
373 u16 min_rx_wqes; 422 u16 min_rx_wqes;
374 u8 log_rq_size; 423 u8 log_rq_size;
375 u8 log_sq_size; 424 u8 log_sq_size;
425 u32 num_mtts;
376 int err = 0; 426 int err = 0;
377 427
378 if (param->rx_jumbo_pending) { 428 if (param->rx_jumbo_pending) {
@@ -385,18 +435,36 @@ static int mlx5e_set_ringparam(struct net_device *dev,
385 __func__); 435 __func__);
386 return -EINVAL; 436 return -EINVAL;
387 } 437 }
388 if (param->rx_pending < (1 << mlx5_min_log_rq_size(rq_wq_type))) { 438
439 min_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type,
440 1 << mlx5_min_log_rq_size(rq_wq_type));
441 max_rq_size = mlx5e_rx_wqes_to_packets(priv, rq_wq_type,
442 1 << mlx5_max_log_rq_size(rq_wq_type));
443 rx_pending_wqes = mlx5e_packets_to_rx_wqes(priv, rq_wq_type,
444 param->rx_pending);
445
446 if (param->rx_pending < min_rq_size) {
389 netdev_info(dev, "%s: rx_pending (%d) < min (%d)\n", 447 netdev_info(dev, "%s: rx_pending (%d) < min (%d)\n",
390 __func__, param->rx_pending, 448 __func__, param->rx_pending,
391 1 << mlx5_min_log_rq_size(rq_wq_type)); 449 min_rq_size);
392 return -EINVAL; 450 return -EINVAL;
393 } 451 }
394 if (param->rx_pending > (1 << mlx5_max_log_rq_size(rq_wq_type))) { 452 if (param->rx_pending > max_rq_size) {
395 netdev_info(dev, "%s: rx_pending (%d) > max (%d)\n", 453 netdev_info(dev, "%s: rx_pending (%d) > max (%d)\n",
396 __func__, param->rx_pending, 454 __func__, param->rx_pending,
397 1 << mlx5_max_log_rq_size(rq_wq_type)); 455 max_rq_size);
398 return -EINVAL; 456 return -EINVAL;
399 } 457 }
458
459 num_mtts = MLX5E_REQUIRED_MTTS(priv->params.num_channels,
460 rx_pending_wqes);
461 if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
462 !MLX5E_VALID_NUM_MTTS(num_mtts)) {
463 netdev_info(dev, "%s: rx_pending (%d) request can't be satisfied, try to reduce.\n",
464 __func__, param->rx_pending);
465 return -EINVAL;
466 }
467
400 if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) { 468 if (param->tx_pending < (1 << MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE)) {
401 netdev_info(dev, "%s: tx_pending (%d) < min (%d)\n", 469 netdev_info(dev, "%s: tx_pending (%d) < min (%d)\n",
402 __func__, param->tx_pending, 470 __func__, param->tx_pending,
@@ -410,9 +478,9 @@ static int mlx5e_set_ringparam(struct net_device *dev,
410 return -EINVAL; 478 return -EINVAL;
411 } 479 }
412 480
413 log_rq_size = order_base_2(param->rx_pending); 481 log_rq_size = order_base_2(rx_pending_wqes);
414 log_sq_size = order_base_2(param->tx_pending); 482 log_sq_size = order_base_2(param->tx_pending);
415 min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, param->rx_pending); 483 min_rx_wqes = mlx5_min_rx_wqes(rq_wq_type, rx_pending_wqes);
416 484
417 if (log_rq_size == priv->params.log_rq_size && 485 if (log_rq_size == priv->params.log_rq_size &&
418 log_sq_size == priv->params.log_sq_size && 486 log_sq_size == priv->params.log_sq_size &&
@@ -454,6 +522,7 @@ static int mlx5e_set_channels(struct net_device *dev,
454 unsigned int count = ch->combined_count; 522 unsigned int count = ch->combined_count;
455 bool arfs_enabled; 523 bool arfs_enabled;
456 bool was_opened; 524 bool was_opened;
525 u32 num_mtts;
457 int err = 0; 526 int err = 0;
458 527
459 if (!count) { 528 if (!count) {
@@ -472,6 +541,14 @@ static int mlx5e_set_channels(struct net_device *dev,
472 return -EINVAL; 541 return -EINVAL;
473 } 542 }
474 543
544 num_mtts = MLX5E_REQUIRED_MTTS(count, BIT(priv->params.log_rq_size));
545 if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
546 !MLX5E_VALID_NUM_MTTS(num_mtts)) {
547 netdev_info(dev, "%s: rx count (%d) request can't be satisfied, try to reduce.\n",
548 __func__, count);
549 return -EINVAL;
550 }
551
475 if (priv->params.num_channels == count) 552 if (priv->params.num_channels == count)
476 return 0; 553 return 0;
477 554
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 870bea37c57c..2459c7f3db8d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -39,13 +39,6 @@
39#include "eswitch.h" 39#include "eswitch.h"
40#include "vxlan.h" 40#include "vxlan.h"
41 41
42enum {
43 MLX5_EN_QP_FLUSH_TIMEOUT_MS = 5000,
44 MLX5_EN_QP_FLUSH_MSLEEP_QUANT = 20,
45 MLX5_EN_QP_FLUSH_MAX_ITER = MLX5_EN_QP_FLUSH_TIMEOUT_MS /
46 MLX5_EN_QP_FLUSH_MSLEEP_QUANT,
47};
48
49struct mlx5e_rq_param { 42struct mlx5e_rq_param {
50 u32 rqc[MLX5_ST_SZ_DW(rqc)]; 43 u32 rqc[MLX5_ST_SZ_DW(rqc)];
51 struct mlx5_wq_param wq; 44 struct mlx5_wq_param wq;
@@ -162,6 +155,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
162 s->tx_queue_stopped += sq_stats->stopped; 155 s->tx_queue_stopped += sq_stats->stopped;
163 s->tx_queue_wake += sq_stats->wake; 156 s->tx_queue_wake += sq_stats->wake;
164 s->tx_queue_dropped += sq_stats->dropped; 157 s->tx_queue_dropped += sq_stats->dropped;
158 s->tx_xmit_more += sq_stats->xmit_more;
165 s->tx_csum_partial_inner += sq_stats->csum_partial_inner; 159 s->tx_csum_partial_inner += sq_stats->csum_partial_inner;
166 tx_offload_none += sq_stats->csum_none; 160 tx_offload_none += sq_stats->csum_none;
167 } 161 }
@@ -340,6 +334,9 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
340 rq->alloc_wqe = mlx5e_alloc_rx_mpwqe; 334 rq->alloc_wqe = mlx5e_alloc_rx_mpwqe;
341 rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe; 335 rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
342 336
337 rq->mpwqe_mtt_offset = c->ix *
338 MLX5E_REQUIRED_MTTS(1, BIT(priv->params.log_rq_size));
339
343 rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz); 340 rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz);
344 rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides); 341 rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides);
345 rq->wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides; 342 rq->wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides;
@@ -428,7 +425,6 @@ static int mlx5e_enable_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param)
428 425
429 MLX5_SET(rqc, rqc, cqn, rq->cq.mcq.cqn); 426 MLX5_SET(rqc, rqc, cqn, rq->cq.mcq.cqn);
430 MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST); 427 MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST);
431 MLX5_SET(rqc, rqc, flush_in_error_en, 1);
432 MLX5_SET(rqc, rqc, vsd, priv->params.vlan_strip_disable); 428 MLX5_SET(rqc, rqc, vsd, priv->params.vlan_strip_disable);
433 MLX5_SET(wq, wq, log_wq_pg_sz, rq->wq_ctrl.buf.page_shift - 429 MLX5_SET(wq, wq, log_wq_pg_sz, rq->wq_ctrl.buf.page_shift -
434 MLX5_ADAPTER_PAGE_SHIFT); 430 MLX5_ADAPTER_PAGE_SHIFT);
@@ -525,6 +521,27 @@ static int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq)
525 return -ETIMEDOUT; 521 return -ETIMEDOUT;
526} 522}
527 523
524static void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
525{
526 struct mlx5_wq_ll *wq = &rq->wq;
527 struct mlx5e_rx_wqe *wqe;
528 __be16 wqe_ix_be;
529 u16 wqe_ix;
530
531 /* UMR WQE (if in progress) is always at wq->head */
532 if (test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state))
533 mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]);
534
535 while (!mlx5_wq_ll_is_empty(wq)) {
536 wqe_ix_be = *wq->tail_next;
537 wqe_ix = be16_to_cpu(wqe_ix_be);
538 wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix);
539 rq->dealloc_wqe(rq, wqe_ix);
540 mlx5_wq_ll_pop(&rq->wq, wqe_ix_be,
541 &wqe->next.next_wqe_index);
542 }
543}
544
528static int mlx5e_open_rq(struct mlx5e_channel *c, 545static int mlx5e_open_rq(struct mlx5e_channel *c,
529 struct mlx5e_rq_param *param, 546 struct mlx5e_rq_param *param,
530 struct mlx5e_rq *rq) 547 struct mlx5e_rq *rq)
@@ -548,8 +565,6 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
548 if (param->am_enabled) 565 if (param->am_enabled)
549 set_bit(MLX5E_RQ_STATE_AM, &c->rq.state); 566 set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
550 567
551 set_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state);
552
553 sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_NOP; 568 sq->ico_wqe_info[pi].opcode = MLX5_OPCODE_NOP;
554 sq->ico_wqe_info[pi].num_wqebbs = 1; 569 sq->ico_wqe_info[pi].num_wqebbs = 1;
555 mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */ 570 mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */
@@ -566,23 +581,8 @@ err_destroy_rq:
566 581
567static void mlx5e_close_rq(struct mlx5e_rq *rq) 582static void mlx5e_close_rq(struct mlx5e_rq *rq)
568{ 583{
569 int tout = 0; 584 set_bit(MLX5E_RQ_STATE_FLUSH, &rq->state);
570 int err;
571
572 clear_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state);
573 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */ 585 napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */
574
575 err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RDY, MLX5_RQC_STATE_ERR);
576 while (!mlx5_wq_ll_is_empty(&rq->wq) && !err &&
577 tout++ < MLX5_EN_QP_FLUSH_MAX_ITER)
578 msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT);
579
580 if (err || tout == MLX5_EN_QP_FLUSH_MAX_ITER)
581 set_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state);
582
583 /* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */
584 napi_synchronize(&rq->channel->napi);
585
586 cancel_work_sync(&rq->am.work); 586 cancel_work_sync(&rq->am.work);
587 587
588 mlx5e_disable_rq(rq); 588 mlx5e_disable_rq(rq);
@@ -821,7 +821,6 @@ static int mlx5e_open_sq(struct mlx5e_channel *c,
821 goto err_disable_sq; 821 goto err_disable_sq;
822 822
823 if (sq->txq) { 823 if (sq->txq) {
824 set_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state);
825 netdev_tx_reset_queue(sq->txq); 824 netdev_tx_reset_queue(sq->txq);
826 netif_tx_start_queue(sq->txq); 825 netif_tx_start_queue(sq->txq);
827 } 826 }
@@ -845,38 +844,20 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq)
845 844
846static void mlx5e_close_sq(struct mlx5e_sq *sq) 845static void mlx5e_close_sq(struct mlx5e_sq *sq)
847{ 846{
848 int tout = 0; 847 set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state);
849 int err; 848 /* prevent netif_tx_wake_queue */
849 napi_synchronize(&sq->channel->napi);
850 850
851 if (sq->txq) { 851 if (sq->txq) {
852 clear_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state);
853 /* prevent netif_tx_wake_queue */
854 napi_synchronize(&sq->channel->napi);
855 netif_tx_disable_queue(sq->txq); 852 netif_tx_disable_queue(sq->txq);
856 853
857 /* ensure hw is notified of all pending wqes */ 854 /* last doorbell out, godspeed .. */
858 if (mlx5e_sq_has_room_for(sq, 1)) 855 if (mlx5e_sq_has_room_for(sq, 1))
859 mlx5e_send_nop(sq, true); 856 mlx5e_send_nop(sq, true);
860
861 err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY,
862 MLX5_SQC_STATE_ERR, false, 0);
863 if (err)
864 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state);
865 }
866
867 /* wait till sq is empty, unless a TX timeout occurred on this SQ */
868 while (sq->cc != sq->pc &&
869 !test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state)) {
870 msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT);
871 if (tout++ > MLX5_EN_QP_FLUSH_MAX_ITER)
872 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state);
873 } 857 }
874 858
875 /* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */
876 napi_synchronize(&sq->channel->napi);
877
878 mlx5e_free_tx_descs(sq);
879 mlx5e_disable_sq(sq); 859 mlx5e_disable_sq(sq);
860 mlx5e_free_tx_descs(sq);
880 mlx5e_destroy_sq(sq); 861 mlx5e_destroy_sq(sq);
881} 862}
882 863
@@ -1826,10 +1807,6 @@ int mlx5e_open_locked(struct net_device *netdev)
1826 netif_set_real_num_tx_queues(netdev, num_txqs); 1807 netif_set_real_num_tx_queues(netdev, num_txqs);
1827 netif_set_real_num_rx_queues(netdev, priv->params.num_channels); 1808 netif_set_real_num_rx_queues(netdev, priv->params.num_channels);
1828 1809
1829 err = mlx5e_set_dev_port_mtu(netdev);
1830 if (err)
1831 goto err_clear_state_opened_flag;
1832
1833 err = mlx5e_open_channels(priv); 1810 err = mlx5e_open_channels(priv);
1834 if (err) { 1811 if (err) {
1835 netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n", 1812 netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n",
@@ -2573,6 +2550,7 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
2573 u16 max_mtu; 2550 u16 max_mtu;
2574 u16 min_mtu; 2551 u16 min_mtu;
2575 int err = 0; 2552 int err = 0;
2553 bool reset;
2576 2554
2577 mlx5_query_port_max_mtu(mdev, &max_mtu, 1); 2555 mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
2578 2556
@@ -2588,13 +2566,18 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
2588 2566
2589 mutex_lock(&priv->state_lock); 2567 mutex_lock(&priv->state_lock);
2590 2568
2569 reset = !priv->params.lro_en &&
2570 (priv->params.rq_wq_type !=
2571 MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ);
2572
2591 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state); 2573 was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
2592 if (was_opened) 2574 if (was_opened && reset)
2593 mlx5e_close_locked(netdev); 2575 mlx5e_close_locked(netdev);
2594 2576
2595 netdev->mtu = new_mtu; 2577 netdev->mtu = new_mtu;
2578 mlx5e_set_dev_port_mtu(netdev);
2596 2579
2597 if (was_opened) 2580 if (was_opened && reset)
2598 err = mlx5e_open_locked(netdev); 2581 err = mlx5e_open_locked(netdev);
2599 2582
2600 mutex_unlock(&priv->state_lock); 2583 mutex_unlock(&priv->state_lock);
@@ -2794,7 +2777,7 @@ static void mlx5e_tx_timeout(struct net_device *dev)
2794 if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i))) 2777 if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i)))
2795 continue; 2778 continue;
2796 sched_work = true; 2779 sched_work = true;
2797 set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state); 2780 set_bit(MLX5E_SQ_STATE_FLUSH, &sq->state);
2798 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n", 2781 netdev_err(dev, "TX timeout on queue: %d, SQ: 0x%x, CQ: 0x%x, SQ Cons: 0x%x SQ Prod: 0x%x\n",
2799 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc); 2782 i, sq->sqn, sq->cq.mcq.cqn, sq->cc, sq->pc);
2800 } 2783 }
@@ -3231,8 +3214,8 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv)
3231 struct mlx5_create_mkey_mbox_in *in; 3214 struct mlx5_create_mkey_mbox_in *in;
3232 struct mlx5_mkey_seg *mkc; 3215 struct mlx5_mkey_seg *mkc;
3233 int inlen = sizeof(*in); 3216 int inlen = sizeof(*in);
3234 u64 npages = 3217 u64 npages = MLX5E_REQUIRED_MTTS(priv->profile->max_nch(mdev),
3235 priv->profile->max_nch(mdev) * MLX5_CHANNEL_MAX_NUM_MTTS; 3218 BIT(MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW));
3236 int err; 3219 int err;
3237 3220
3238 in = mlx5_vzalloc(inlen); 3221 in = mlx5_vzalloc(inlen);
@@ -3246,10 +3229,12 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv)
3246 MLX5_PERM_LOCAL_WRITE | 3229 MLX5_PERM_LOCAL_WRITE |
3247 MLX5_ACCESS_MODE_MTT; 3230 MLX5_ACCESS_MODE_MTT;
3248 3231
3232 npages = min_t(u32, ALIGN(U16_MAX, 4) * 2, npages);
3233
3249 mkc->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); 3234 mkc->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
3250 mkc->flags_pd = cpu_to_be32(mdev->mlx5e_res.pdn); 3235 mkc->flags_pd = cpu_to_be32(mdev->mlx5e_res.pdn);
3251 mkc->len = cpu_to_be64(npages << PAGE_SHIFT); 3236 mkc->len = cpu_to_be64(npages << PAGE_SHIFT);
3252 mkc->xlt_oct_size = cpu_to_be32(mlx5e_get_mtt_octw(npages)); 3237 mkc->xlt_oct_size = cpu_to_be32(MLX5_MTT_OCTW(npages));
3253 mkc->log2_page_size = PAGE_SHIFT; 3238 mkc->log2_page_size = PAGE_SHIFT;
3254 3239
3255 err = mlx5_core_create_mkey(mdev, &priv->umr_mkey, in, inlen, NULL, 3240 err = mlx5_core_create_mkey(mdev, &priv->umr_mkey, in, inlen, NULL,
@@ -3385,6 +3370,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3385 queue_work(priv->wq, &priv->set_rx_mode_work); 3370 queue_work(priv->wq, &priv->set_rx_mode_work);
3386 3371
3387 if (MLX5_CAP_GEN(mdev, vport_group_manager)) { 3372 if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
3373 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
3388 rep.load = mlx5e_nic_rep_load; 3374 rep.load = mlx5e_nic_rep_load;
3389 rep.unload = mlx5e_nic_rep_unload; 3375 rep.unload = mlx5e_nic_rep_unload;
3390 rep.vport = 0; 3376 rep.vport = 0;
@@ -3463,6 +3449,8 @@ void *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
3463 3449
3464 mlx5e_init_l2_addr(priv); 3450 mlx5e_init_l2_addr(priv);
3465 3451
3452 mlx5e_set_dev_port_mtu(netdev);
3453
3466 err = register_netdev(netdev); 3454 err = register_netdev(netdev);
3467 if (err) { 3455 if (err) {
3468 mlx5_core_err(mdev, "register_netdev failed, %d\n", err); 3456 mlx5_core_err(mdev, "register_netdev failed, %d\n", err);
@@ -3501,16 +3489,20 @@ static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev)
3501 struct mlx5_eswitch *esw = mdev->priv.eswitch; 3489 struct mlx5_eswitch *esw = mdev->priv.eswitch;
3502 int total_vfs = MLX5_TOTAL_VPORTS(mdev); 3490 int total_vfs = MLX5_TOTAL_VPORTS(mdev);
3503 int vport; 3491 int vport;
3492 u8 mac[ETH_ALEN];
3504 3493
3505 if (!MLX5_CAP_GEN(mdev, vport_group_manager)) 3494 if (!MLX5_CAP_GEN(mdev, vport_group_manager))
3506 return; 3495 return;
3507 3496
3497 mlx5_query_nic_vport_mac_address(mdev, 0, mac);
3498
3508 for (vport = 1; vport < total_vfs; vport++) { 3499 for (vport = 1; vport < total_vfs; vport++) {
3509 struct mlx5_eswitch_rep rep; 3500 struct mlx5_eswitch_rep rep;
3510 3501
3511 rep.load = mlx5e_vport_rep_load; 3502 rep.load = mlx5e_vport_rep_load;
3512 rep.unload = mlx5e_vport_rep_unload; 3503 rep.unload = mlx5e_vport_rep_unload;
3513 rep.vport = vport; 3504 rep.vport = vport;
3505 ether_addr_copy(rep.hw_id, mac);
3514 mlx5_eswitch_register_vport_rep(esw, &rep); 3506 mlx5_eswitch_register_vport_rep(esw, &rep);
3515 } 3507 }
3516} 3508}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 1c7d8b8314bf..134de4a11f1d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -135,17 +135,16 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
135int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) 135int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
136{ 136{
137 struct mlx5e_priv *priv = netdev_priv(dev); 137 struct mlx5e_priv *priv = netdev_priv(dev);
138 struct mlx5_eswitch_rep *rep = priv->ppriv;
138 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 139 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
139 u8 mac[ETH_ALEN];
140 140
141 if (esw->mode == SRIOV_NONE) 141 if (esw->mode == SRIOV_NONE)
142 return -EOPNOTSUPP; 142 return -EOPNOTSUPP;
143 143
144 switch (attr->id) { 144 switch (attr->id) {
145 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: 145 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
146 mlx5_query_nic_vport_mac_address(priv->mdev, 0, mac);
147 attr->u.ppid.id_len = ETH_ALEN; 146 attr->u.ppid.id_len = ETH_ALEN;
148 memcpy(&attr->u.ppid.id, &mac, ETH_ALEN); 147 ether_addr_copy(attr->u.ppid.id, rep->hw_id);
149 break; 148 break;
150 default: 149 default:
151 return -EOPNOTSUPP; 150 return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 9f2a16a507e0..b6f8ebbdb487 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -324,9 +324,9 @@ mlx5e_copy_skb_header_fragmented_mpwqe(struct device *pdev,
324 } 324 }
325} 325}
326 326
327static u16 mlx5e_get_wqe_mtt_offset(u16 rq_ix, u16 wqe_ix) 327static u32 mlx5e_get_wqe_mtt_offset(struct mlx5e_rq *rq, u16 wqe_ix)
328{ 328{
329 return rq_ix * MLX5_CHANNEL_MAX_NUM_MTTS + 329 return rq->mpwqe_mtt_offset +
330 wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8); 330 wqe_ix * ALIGN(MLX5_MPWRQ_PAGES_PER_WQE, 8);
331} 331}
332 332
@@ -340,7 +340,7 @@ static void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,
340 struct mlx5_wqe_data_seg *dseg = &wqe->data; 340 struct mlx5_wqe_data_seg *dseg = &wqe->data;
341 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; 341 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
342 u8 ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS); 342 u8 ds_cnt = DIV_ROUND_UP(sizeof(*wqe), MLX5_SEND_WQE_DS);
343 u16 umr_wqe_mtt_offset = mlx5e_get_wqe_mtt_offset(rq->ix, ix); 343 u32 umr_wqe_mtt_offset = mlx5e_get_wqe_mtt_offset(rq, ix);
344 344
345 memset(wqe, 0, sizeof(*wqe)); 345 memset(wqe, 0, sizeof(*wqe));
346 cseg->opmod_idx_opcode = 346 cseg->opmod_idx_opcode =
@@ -353,9 +353,9 @@ static void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,
353 353
354 ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN; 354 ucseg->flags = MLX5_UMR_TRANSLATION_OFFSET_EN;
355 ucseg->klm_octowords = 355 ucseg->klm_octowords =
356 cpu_to_be16(mlx5e_get_mtt_octw(MLX5_MPWRQ_PAGES_PER_WQE)); 356 cpu_to_be16(MLX5_MTT_OCTW(MLX5_MPWRQ_PAGES_PER_WQE));
357 ucseg->bsf_octowords = 357 ucseg->bsf_octowords =
358 cpu_to_be16(mlx5e_get_mtt_octw(umr_wqe_mtt_offset)); 358 cpu_to_be16(MLX5_MTT_OCTW(umr_wqe_mtt_offset));
359 ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE); 359 ucseg->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE);
360 360
361 dseg->lkey = sq->mkey_be; 361 dseg->lkey = sq->mkey_be;
@@ -423,7 +423,7 @@ static int mlx5e_alloc_rx_fragmented_mpwqe(struct mlx5e_rq *rq,
423{ 423{
424 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix]; 424 struct mlx5e_mpw_info *wi = &rq->wqe_info[ix];
425 int mtt_sz = mlx5e_get_wqe_mtt_sz(); 425 int mtt_sz = mlx5e_get_wqe_mtt_sz();
426 u32 dma_offset = mlx5e_get_wqe_mtt_offset(rq->ix, ix) << PAGE_SHIFT; 426 u64 dma_offset = (u64)mlx5e_get_wqe_mtt_offset(rq, ix) << PAGE_SHIFT;
427 int i; 427 int i;
428 428
429 wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) * 429 wi->umr.dma_info = kmalloc(sizeof(*wi->umr.dma_info) *
@@ -506,6 +506,12 @@ void mlx5e_post_rx_fragmented_mpwqe(struct mlx5e_rq *rq)
506 struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head); 506 struct mlx5e_rx_wqe *wqe = mlx5_wq_ll_get_wqe(wq, wq->head);
507 507
508 clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state); 508 clear_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state);
509
510 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state))) {
511 mlx5e_free_rx_fragmented_mpwqe(rq, &rq->wqe_info[wq->head]);
512 return;
513 }
514
509 mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index)); 515 mlx5_wq_ll_push(wq, be16_to_cpu(wqe->next.next_wqe_index));
510 rq->stats.mpwqe_frag++; 516 rq->stats.mpwqe_frag++;
511 517
@@ -595,26 +601,9 @@ void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
595 wi->free_wqe(rq, wi); 601 wi->free_wqe(rq, wi);
596} 602}
597 603
598void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
599{
600 struct mlx5_wq_ll *wq = &rq->wq;
601 struct mlx5e_rx_wqe *wqe;
602 __be16 wqe_ix_be;
603 u16 wqe_ix;
604
605 while (!mlx5_wq_ll_is_empty(wq)) {
606 wqe_ix_be = *wq->tail_next;
607 wqe_ix = be16_to_cpu(wqe_ix_be);
608 wqe = mlx5_wq_ll_get_wqe(&rq->wq, wqe_ix);
609 rq->dealloc_wqe(rq, wqe_ix);
610 mlx5_wq_ll_pop(&rq->wq, wqe_ix_be,
611 &wqe->next.next_wqe_index);
612 }
613}
614
615#define RQ_CANNOT_POST(rq) \ 604#define RQ_CANNOT_POST(rq) \
616 (!test_bit(MLX5E_RQ_STATE_POST_WQES_ENABLE, &rq->state) || \ 605 (test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state) || \
617 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state)) 606 test_bit(MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS, &rq->state))
618 607
619bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq) 608bool mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
620{ 609{
@@ -916,7 +905,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
916 struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq); 905 struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq);
917 int work_done = 0; 906 int work_done = 0;
918 907
919 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH_TIMEOUT, &rq->state))) 908 if (unlikely(test_bit(MLX5E_RQ_STATE_FLUSH, &rq->state)))
920 return 0; 909 return 0;
921 910
922 if (cq->decmprs_left) 911 if (cq->decmprs_left)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index 7b9d8a989b52..499487ce3b53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -70,6 +70,7 @@ struct mlx5e_sw_stats {
70 u64 tx_queue_stopped; 70 u64 tx_queue_stopped;
71 u64 tx_queue_wake; 71 u64 tx_queue_wake;
72 u64 tx_queue_dropped; 72 u64 tx_queue_dropped;
73 u64 tx_xmit_more;
73 u64 rx_wqe_err; 74 u64 rx_wqe_err;
74 u64 rx_mpwqe_filler; 75 u64 rx_mpwqe_filler;
75 u64 rx_mpwqe_frag; 76 u64 rx_mpwqe_frag;
@@ -101,6 +102,7 @@ static const struct counter_desc sw_stats_desc[] = {
101 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) }, 102 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_stopped) },
102 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) }, 103 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_wake) },
103 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) }, 104 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_queue_dropped) },
105 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_xmit_more) },
104 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) }, 106 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_wqe_err) },
105 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) }, 107 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_filler) },
106 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) }, 108 { MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, rx_mpwqe_frag) },
@@ -298,6 +300,7 @@ struct mlx5e_sq_stats {
298 /* commonly accessed in data path */ 300 /* commonly accessed in data path */
299 u64 packets; 301 u64 packets;
300 u64 bytes; 302 u64 bytes;
303 u64 xmit_more;
301 u64 tso_packets; 304 u64 tso_packets;
302 u64 tso_bytes; 305 u64 tso_bytes;
303 u64 tso_inner_packets; 306 u64 tso_inner_packets;
@@ -324,6 +327,7 @@ static const struct counter_desc sq_stats_desc[] = {
324 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) }, 327 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, stopped) },
325 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) }, 328 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, wake) },
326 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) }, 329 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, dropped) },
330 { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) },
327}; 331};
328 332
329#define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc) 333#define NUM_SW_COUNTERS ARRAY_SIZE(sw_stats_desc)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index dc8b1cb0fdc8..22cfc4ac1837 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -170,7 +170,7 @@ static int parse_cls_flower(struct mlx5e_priv *priv, struct mlx5_flow_spec *spec
170 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) { 170 if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) {
171 struct flow_dissector_key_control *key = 171 struct flow_dissector_key_control *key =
172 skb_flow_dissector_target(f->dissector, 172 skb_flow_dissector_target(f->dissector,
173 FLOW_DISSECTOR_KEY_BASIC, 173 FLOW_DISSECTOR_KEY_CONTROL,
174 f->key); 174 f->key);
175 addr_type = key->addr_type; 175 addr_type = key->addr_type;
176 } 176 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index e073bf59890d..988eca99ee0f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -375,6 +375,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
375 375
376 sq->stats.packets++; 376 sq->stats.packets++;
377 sq->stats.bytes += num_bytes; 377 sq->stats.bytes += num_bytes;
378 sq->stats.xmit_more += skb->xmit_more;
378 return NETDEV_TX_OK; 379 return NETDEV_TX_OK;
379 380
380dma_unmap_wqe_err: 381dma_unmap_wqe_err:
@@ -394,35 +395,6 @@ netdev_tx_t mlx5e_xmit(struct sk_buff *skb, struct net_device *dev)
394 return mlx5e_sq_xmit(sq, skb); 395 return mlx5e_sq_xmit(sq, skb);
395} 396}
396 397
397void mlx5e_free_tx_descs(struct mlx5e_sq *sq)
398{
399 struct mlx5e_tx_wqe_info *wi;
400 struct sk_buff *skb;
401 u16 ci;
402 int i;
403
404 while (sq->cc != sq->pc) {
405 ci = sq->cc & sq->wq.sz_m1;
406 skb = sq->skb[ci];
407 wi = &sq->wqe_info[ci];
408
409 if (!skb) { /* nop */
410 sq->cc++;
411 continue;
412 }
413
414 for (i = 0; i < wi->num_dma; i++) {
415 struct mlx5e_sq_dma *dma =
416 mlx5e_dma_get(sq, sq->dma_fifo_cc++);
417
418 mlx5e_tx_dma_unmap(sq->pdev, dma);
419 }
420
421 dev_kfree_skb_any(skb);
422 sq->cc += wi->num_wqebbs;
423 }
424}
425
426bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget) 398bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
427{ 399{
428 struct mlx5e_sq *sq; 400 struct mlx5e_sq *sq;
@@ -434,7 +406,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
434 406
435 sq = container_of(cq, struct mlx5e_sq, cq); 407 sq = container_of(cq, struct mlx5e_sq, cq);
436 408
437 if (unlikely(test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, &sq->state))) 409 if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state)))
438 return false; 410 return false;
439 411
440 npkts = 0; 412 npkts = 0;
@@ -512,11 +484,39 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
512 netdev_tx_completed_queue(sq->txq, npkts, nbytes); 484 netdev_tx_completed_queue(sq->txq, npkts, nbytes);
513 485
514 if (netif_tx_queue_stopped(sq->txq) && 486 if (netif_tx_queue_stopped(sq->txq) &&
515 mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM) && 487 mlx5e_sq_has_room_for(sq, MLX5E_SQ_STOP_ROOM)) {
516 likely(test_bit(MLX5E_SQ_STATE_WAKE_TXQ_ENABLE, &sq->state))) { 488 netif_tx_wake_queue(sq->txq);
517 netif_tx_wake_queue(sq->txq); 489 sq->stats.wake++;
518 sq->stats.wake++;
519 } 490 }
520 491
521 return (i == MLX5E_TX_CQ_POLL_BUDGET); 492 return (i == MLX5E_TX_CQ_POLL_BUDGET);
522} 493}
494
495void mlx5e_free_tx_descs(struct mlx5e_sq *sq)
496{
497 struct mlx5e_tx_wqe_info *wi;
498 struct sk_buff *skb;
499 u16 ci;
500 int i;
501
502 while (sq->cc != sq->pc) {
503 ci = sq->cc & sq->wq.sz_m1;
504 skb = sq->skb[ci];
505 wi = &sq->wqe_info[ci];
506
507 if (!skb) { /* nop */
508 sq->cc++;
509 continue;
510 }
511
512 for (i = 0; i < wi->num_dma; i++) {
513 struct mlx5e_sq_dma *dma =
514 mlx5e_dma_get(sq, sq->dma_fifo_cc++);
515
516 mlx5e_tx_dma_unmap(sq->pdev, dma);
517 }
518
519 dev_kfree_skb_any(skb);
520 sq->cc += wi->num_wqebbs;
521 }
522}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
index 64ae2e800daa..9bf33bb69210 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
@@ -51,16 +51,18 @@ struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq)
51 51
52static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq) 52static void mlx5e_poll_ico_cq(struct mlx5e_cq *cq)
53{ 53{
54 struct mlx5e_sq *sq = container_of(cq, struct mlx5e_sq, cq);
54 struct mlx5_wq_cyc *wq; 55 struct mlx5_wq_cyc *wq;
55 struct mlx5_cqe64 *cqe; 56 struct mlx5_cqe64 *cqe;
56 struct mlx5e_sq *sq;
57 u16 sqcc; 57 u16 sqcc;
58 58
59 if (unlikely(test_bit(MLX5E_SQ_STATE_FLUSH, &sq->state)))
60 return;
61
59 cqe = mlx5e_get_cqe(cq); 62 cqe = mlx5e_get_cqe(cq);
60 if (likely(!cqe)) 63 if (likely(!cqe))
61 return; 64 return;
62 65
63 sq = container_of(cq, struct mlx5e_sq, cq);
64 wq = &sq->wq; 66 wq = &sq->wq;
65 67
66 /* sq->cc must be updated only after mlx5_cqwq_update_db_record(), 68 /* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index f6d667797ee1..8b78f156214e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1451,7 +1451,8 @@ static void esw_enable_vport(struct mlx5_eswitch *esw, int vport_num,
1451 1451
1452 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num); 1452 esw_debug(esw->dev, "Enabling VPORT(%d)\n", vport_num);
1453 1453
1454 if (vport_num) { /* Only VFs need ACLs for VST and spoofchk filtering */ 1454 /* Only VFs need ACLs for VST and spoofchk filtering */
1455 if (vport_num && esw->mode == SRIOV_LEGACY) {
1455 esw_vport_ingress_config(esw, vport); 1456 esw_vport_ingress_config(esw, vport);
1456 esw_vport_egress_config(esw, vport); 1457 esw_vport_egress_config(esw, vport);
1457 } 1458 }
@@ -1502,7 +1503,7 @@ static void esw_disable_vport(struct mlx5_eswitch *esw, int vport_num)
1502 */ 1503 */
1503 esw_vport_change_handle_locked(vport); 1504 esw_vport_change_handle_locked(vport);
1504 vport->enabled_events = 0; 1505 vport->enabled_events = 0;
1505 if (vport_num) { 1506 if (vport_num && esw->mode == SRIOV_LEGACY) {
1506 esw_vport_disable_egress_acl(esw, vport); 1507 esw_vport_disable_egress_acl(esw, vport);
1507 esw_vport_disable_ingress_acl(esw, vport); 1508 esw_vport_disable_ingress_acl(esw, vport);
1508 } 1509 }
@@ -1767,7 +1768,7 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
1767 vport, err); 1768 vport, err);
1768 1769
1769 mutex_lock(&esw->state_lock); 1770 mutex_lock(&esw->state_lock);
1770 if (evport->enabled) 1771 if (evport->enabled && esw->mode == SRIOV_LEGACY)
1771 err = esw_vport_ingress_config(esw, evport); 1772 err = esw_vport_ingress_config(esw, evport);
1772 mutex_unlock(&esw->state_lock); 1773 mutex_unlock(&esw->state_lock);
1773 return err; 1774 return err;
@@ -1839,7 +1840,7 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
1839 mutex_lock(&esw->state_lock); 1840 mutex_lock(&esw->state_lock);
1840 evport->vlan = vlan; 1841 evport->vlan = vlan;
1841 evport->qos = qos; 1842 evport->qos = qos;
1842 if (evport->enabled) { 1843 if (evport->enabled && esw->mode == SRIOV_LEGACY) {
1843 err = esw_vport_ingress_config(esw, evport); 1844 err = esw_vport_ingress_config(esw, evport);
1844 if (err) 1845 if (err)
1845 goto out; 1846 goto out;
@@ -1868,10 +1869,11 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
1868 mutex_lock(&esw->state_lock); 1869 mutex_lock(&esw->state_lock);
1869 pschk = evport->spoofchk; 1870 pschk = evport->spoofchk;
1870 evport->spoofchk = spoofchk; 1871 evport->spoofchk = spoofchk;
1871 if (evport->enabled) 1872 if (evport->enabled && esw->mode == SRIOV_LEGACY) {
1872 err = esw_vport_ingress_config(esw, evport); 1873 err = esw_vport_ingress_config(esw, evport);
1873 if (err) 1874 if (err)
1874 evport->spoofchk = pschk; 1875 evport->spoofchk = pschk;
1876 }
1875 mutex_unlock(&esw->state_lock); 1877 mutex_unlock(&esw->state_lock);
1876 1878
1877 return err; 1879 return err;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index c0b05603fc31..a96140971d77 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -174,6 +174,7 @@ struct mlx5_eswitch_rep {
174 void *priv_data; 174 void *priv_data;
175 struct list_head vport_sqs_list; 175 struct list_head vport_sqs_list;
176 bool valid; 176 bool valid;
177 u8 hw_id[ETH_ALEN];
177}; 178};
178 179
179struct mlx5_esw_offload { 180struct mlx5_esw_offload {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index a357e8eeeed8..3dc83a9459a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -113,7 +113,7 @@ mlx5_eswitch_add_send_to_vport_rule(struct mlx5_eswitch *esw, int vport, u32 sqn
113 dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT; 113 dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
114 dest.vport_num = vport; 114 dest.vport_num = vport;
115 115
116 flow_rule = mlx5_add_flow_rule(esw->fdb_table.fdb, spec, 116 flow_rule = mlx5_add_flow_rule(esw->fdb_table.offloads.fdb, spec,
117 MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, 117 MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
118 0, &dest); 118 0, &dest);
119 if (IS_ERR(flow_rule)) 119 if (IS_ERR(flow_rule))
@@ -535,7 +535,7 @@ void esw_offloads_cleanup(struct mlx5_eswitch *esw, int nvports)
535 esw_destroy_offloads_fdb_table(esw); 535 esw_destroy_offloads_fdb_table(esw);
536} 536}
537 537
538static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode) 538static int esw_mode_from_devlink(u16 mode, u16 *mlx5_mode)
539{ 539{
540 switch (mode) { 540 switch (mode) {
541 case DEVLINK_ESWITCH_MODE_LEGACY: 541 case DEVLINK_ESWITCH_MODE_LEGACY:
@@ -551,6 +551,22 @@ static int mlx5_esw_mode_from_devlink(u16 mode, u16 *mlx5_mode)
551 return 0; 551 return 0;
552} 552}
553 553
554static int esw_mode_to_devlink(u16 mlx5_mode, u16 *mode)
555{
556 switch (mlx5_mode) {
557 case SRIOV_LEGACY:
558 *mode = DEVLINK_ESWITCH_MODE_LEGACY;
559 break;
560 case SRIOV_OFFLOADS:
561 *mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
562 break;
563 default:
564 return -EINVAL;
565 }
566
567 return 0;
568}
569
554int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode) 570int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode)
555{ 571{
556 struct mlx5_core_dev *dev; 572 struct mlx5_core_dev *dev;
@@ -566,7 +582,7 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode)
566 if (cur_mlx5_mode == SRIOV_NONE) 582 if (cur_mlx5_mode == SRIOV_NONE)
567 return -EOPNOTSUPP; 583 return -EOPNOTSUPP;
568 584
569 if (mlx5_esw_mode_from_devlink(mode, &mlx5_mode)) 585 if (esw_mode_from_devlink(mode, &mlx5_mode))
570 return -EINVAL; 586 return -EINVAL;
571 587
572 if (cur_mlx5_mode == mlx5_mode) 588 if (cur_mlx5_mode == mlx5_mode)
@@ -592,9 +608,7 @@ int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)
592 if (dev->priv.eswitch->mode == SRIOV_NONE) 608 if (dev->priv.eswitch->mode == SRIOV_NONE)
593 return -EOPNOTSUPP; 609 return -EOPNOTSUPP;
594 610
595 *mode = dev->priv.eswitch->mode; 611 return esw_mode_to_devlink(dev->priv.eswitch->mode, mode);
596
597 return 0;
598} 612}
599 613
600void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw, 614void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 75bb8c864557..3d6c1f65e586 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -80,7 +80,7 @@
80 LEFTOVERS_NUM_PRIOS) 80 LEFTOVERS_NUM_PRIOS)
81 81
82#define ETHTOOL_PRIO_NUM_LEVELS 1 82#define ETHTOOL_PRIO_NUM_LEVELS 1
83#define ETHTOOL_NUM_PRIOS 10 83#define ETHTOOL_NUM_PRIOS 11
84#define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS) 84#define ETHTOOL_MIN_LEVEL (KERNEL_MIN_LEVEL + ETHTOOL_NUM_PRIOS)
85/* Vlan, mac, ttc, aRFS */ 85/* Vlan, mac, ttc, aRFS */
86#define KERNEL_NIC_PRIO_NUM_LEVELS 4 86#define KERNEL_NIC_PRIO_NUM_LEVELS 4
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
index c2877e9de8a1..3a9195b4169d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c
@@ -126,12 +126,21 @@ static struct rb_node *mlx5_fc_stats_query(struct mlx5_core_dev *dev,
126 for (node = &first->node; node; node = rb_next(node)) { 126 for (node = &first->node; node; node = rb_next(node)) {
127 struct mlx5_fc *counter = rb_entry(node, struct mlx5_fc, node); 127 struct mlx5_fc *counter = rb_entry(node, struct mlx5_fc, node);
128 struct mlx5_fc_cache *c = &counter->cache; 128 struct mlx5_fc_cache *c = &counter->cache;
129 u64 packets;
130 u64 bytes;
129 131
130 if (counter->id > last_id) 132 if (counter->id > last_id)
131 break; 133 break;
132 134
133 mlx5_cmd_fc_bulk_get(dev, b, 135 mlx5_cmd_fc_bulk_get(dev, b,
134 counter->id, &c->packets, &c->bytes); 136 counter->id, &packets, &bytes);
137
138 if (c->packets == packets)
139 continue;
140
141 c->packets = packets;
142 c->bytes = bytes;
143 c->lastuse = jiffies;
135 } 144 }
136 145
137out: 146out:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 4f491d43e77d..2385bae92672 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -1420,36 +1420,12 @@ static pci_ers_result_t mlx5_pci_err_detected(struct pci_dev *pdev,
1420 dev_info(&pdev->dev, "%s was called\n", __func__); 1420 dev_info(&pdev->dev, "%s was called\n", __func__);
1421 mlx5_enter_error_state(dev); 1421 mlx5_enter_error_state(dev);
1422 mlx5_unload_one(dev, priv); 1422 mlx5_unload_one(dev, priv);
1423 pci_save_state(pdev);
1423 mlx5_pci_disable_device(dev); 1424 mlx5_pci_disable_device(dev);
1424 return state == pci_channel_io_perm_failure ? 1425 return state == pci_channel_io_perm_failure ?
1425 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET; 1426 PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_NEED_RESET;
1426} 1427}
1427 1428
1428static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev)
1429{
1430 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1431 int err = 0;
1432
1433 dev_info(&pdev->dev, "%s was called\n", __func__);
1434
1435 err = mlx5_pci_enable_device(dev);
1436 if (err) {
1437 dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n"
1438 , __func__, err);
1439 return PCI_ERS_RESULT_DISCONNECT;
1440 }
1441 pci_set_master(pdev);
1442 pci_set_power_state(pdev, PCI_D0);
1443 pci_restore_state(pdev);
1444
1445 return err ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
1446}
1447
1448void mlx5_disable_device(struct mlx5_core_dev *dev)
1449{
1450 mlx5_pci_err_detected(dev->pdev, 0);
1451}
1452
1453/* wait for the device to show vital signs by waiting 1429/* wait for the device to show vital signs by waiting
1454 * for the health counter to start counting. 1430 * for the health counter to start counting.
1455 */ 1431 */
@@ -1477,21 +1453,44 @@ static int wait_vital(struct pci_dev *pdev)
1477 return -ETIMEDOUT; 1453 return -ETIMEDOUT;
1478} 1454}
1479 1455
1480static void mlx5_pci_resume(struct pci_dev *pdev) 1456static pci_ers_result_t mlx5_pci_slot_reset(struct pci_dev *pdev)
1481{ 1457{
1482 struct mlx5_core_dev *dev = pci_get_drvdata(pdev); 1458 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1483 struct mlx5_priv *priv = &dev->priv;
1484 int err; 1459 int err;
1485 1460
1486 dev_info(&pdev->dev, "%s was called\n", __func__); 1461 dev_info(&pdev->dev, "%s was called\n", __func__);
1487 1462
1488 pci_save_state(pdev); 1463 err = mlx5_pci_enable_device(dev);
1489 err = wait_vital(pdev);
1490 if (err) { 1464 if (err) {
1465 dev_err(&pdev->dev, "%s: mlx5_pci_enable_device failed with error code: %d\n"
1466 , __func__, err);
1467 return PCI_ERS_RESULT_DISCONNECT;
1468 }
1469
1470 pci_set_master(pdev);
1471 pci_restore_state(pdev);
1472
1473 if (wait_vital(pdev)) {
1491 dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__); 1474 dev_err(&pdev->dev, "%s: wait_vital timed out\n", __func__);
1492 return; 1475 return PCI_ERS_RESULT_DISCONNECT;
1493 } 1476 }
1494 1477
1478 return PCI_ERS_RESULT_RECOVERED;
1479}
1480
1481void mlx5_disable_device(struct mlx5_core_dev *dev)
1482{
1483 mlx5_pci_err_detected(dev->pdev, 0);
1484}
1485
1486static void mlx5_pci_resume(struct pci_dev *pdev)
1487{
1488 struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
1489 struct mlx5_priv *priv = &dev->priv;
1490 int err;
1491
1492 dev_info(&pdev->dev, "%s was called\n", __func__);
1493
1495 err = mlx5_load_one(dev, priv); 1494 err = mlx5_load_one(dev, priv);
1496 if (err) 1495 if (err)
1497 dev_err(&pdev->dev, "%s: mlx5_load_one failed with error code: %d\n" 1496 dev_err(&pdev->dev, "%s: mlx5_load_one failed with error code: %d\n"
diff --git a/drivers/net/ethernet/mellanox/mlxsw/port.h b/drivers/net/ethernet/mellanox/mlxsw/port.h
index f33b997f2b61..af371a82c35b 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/port.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/port.h
@@ -56,6 +56,7 @@
56#define MLXSW_PORT_PHY_BITS_MASK (MLXSW_PORT_MAX_PHY_PORTS - 1) 56#define MLXSW_PORT_PHY_BITS_MASK (MLXSW_PORT_MAX_PHY_PORTS - 1)
57 57
58#define MLXSW_PORT_CPU_PORT 0x0 58#define MLXSW_PORT_CPU_PORT 0x0
59#define MLXSW_PORT_ROUTER_PORT (MLXSW_PORT_MAX_PHY_PORTS + 2)
59 60
60#define MLXSW_PORT_DONT_CARE (MLXSW_PORT_MAX_PORTS) 61#define MLXSW_PORT_DONT_CARE (MLXSW_PORT_MAX_PORTS)
61 62
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 1f8168906811..7291f2c4b0c7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3324,6 +3324,39 @@ static struct mlxsw_sp_fid *mlxsw_sp_bridge_fid_get(struct mlxsw_sp *mlxsw_sp,
3324 return mlxsw_sp_fid_find(mlxsw_sp, fid); 3324 return mlxsw_sp_fid_find(mlxsw_sp, fid);
3325} 3325}
3326 3326
3327static enum mlxsw_flood_table_type mlxsw_sp_flood_table_type_get(u16 fid)
3328{
3329 return mlxsw_sp_fid_is_vfid(fid) ? MLXSW_REG_SFGC_TABLE_TYPE_FID :
3330 MLXSW_REG_SFGC_TABLE_TYPE_FID_OFFEST;
3331}
3332
3333static u16 mlxsw_sp_flood_table_index_get(u16 fid)
3334{
3335 return mlxsw_sp_fid_is_vfid(fid) ? mlxsw_sp_fid_to_vfid(fid) : fid;
3336}
3337
3338static int mlxsw_sp_router_port_flood_set(struct mlxsw_sp *mlxsw_sp, u16 fid,
3339 bool set)
3340{
3341 enum mlxsw_flood_table_type table_type;
3342 char *sftr_pl;
3343 u16 index;
3344 int err;
3345
3346 sftr_pl = kmalloc(MLXSW_REG_SFTR_LEN, GFP_KERNEL);
3347 if (!sftr_pl)
3348 return -ENOMEM;
3349
3350 table_type = mlxsw_sp_flood_table_type_get(fid);
3351 index = mlxsw_sp_flood_table_index_get(fid);
3352 mlxsw_reg_sftr_pack(sftr_pl, MLXSW_SP_FLOOD_TABLE_BM, index, table_type,
3353 1, MLXSW_PORT_ROUTER_PORT, set);
3354 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sftr), sftr_pl);
3355
3356 kfree(sftr_pl);
3357 return err;
3358}
3359
3327static enum mlxsw_reg_ritr_if_type mlxsw_sp_rif_type_get(u16 fid) 3360static enum mlxsw_reg_ritr_if_type mlxsw_sp_rif_type_get(u16 fid)
3328{ 3361{
3329 if (mlxsw_sp_fid_is_vfid(fid)) 3362 if (mlxsw_sp_fid_is_vfid(fid))
@@ -3360,10 +3393,14 @@ static int mlxsw_sp_rif_bridge_create(struct mlxsw_sp *mlxsw_sp,
3360 if (rif == MLXSW_SP_RIF_MAX) 3393 if (rif == MLXSW_SP_RIF_MAX)
3361 return -ERANGE; 3394 return -ERANGE;
3362 3395
3363 err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true); 3396 err = mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, true);
3364 if (err) 3397 if (err)
3365 return err; 3398 return err;
3366 3399
3400 err = mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, true);
3401 if (err)
3402 goto err_rif_bridge_op;
3403
3367 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, true); 3404 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, true);
3368 if (err) 3405 if (err)
3369 goto err_rif_fdb_op; 3406 goto err_rif_fdb_op;
@@ -3385,6 +3422,8 @@ err_rif_alloc:
3385 mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false); 3422 mlxsw_sp_rif_fdb_op(mlxsw_sp, l3_dev->dev_addr, f->fid, false);
3386err_rif_fdb_op: 3423err_rif_fdb_op:
3387 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); 3424 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false);
3425err_rif_bridge_op:
3426 mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false);
3388 return err; 3427 return err;
3389} 3428}
3390 3429
@@ -3404,6 +3443,8 @@ void mlxsw_sp_rif_bridge_destroy(struct mlxsw_sp *mlxsw_sp,
3404 3443
3405 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false); 3444 mlxsw_sp_rif_bridge_op(mlxsw_sp, l3_dev, f->fid, rif, false);
3406 3445
3446 mlxsw_sp_router_port_flood_set(mlxsw_sp, f->fid, false);
3447
3407 netdev_dbg(l3_dev, "RIF=%d destroyed\n", rif); 3448 netdev_dbg(l3_dev, "RIF=%d destroyed\n", rif);
3408} 3449}
3409 3450
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index 237418a0e6e0..953b214f38d0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -717,22 +717,18 @@ int mlxsw_sp_sb_tc_pool_bind_set(struct mlxsw_core_port *mlxsw_core_port,
717 u8 local_port = mlxsw_sp_port->local_port; 717 u8 local_port = mlxsw_sp_port->local_port;
718 u8 pg_buff = tc_index; 718 u8 pg_buff = tc_index;
719 enum mlxsw_reg_sbxx_dir dir = pool_type; 719 enum mlxsw_reg_sbxx_dir dir = pool_type;
720 u8 pool = pool_index; 720 u8 pool = pool_get(pool_index);
721 u32 max_buff; 721 u32 max_buff;
722 int err; 722 int err;
723 723
724 if (dir != dir_get(pool_index))
725 return -EINVAL;
726
724 err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir, 727 err = mlxsw_sp_sb_threshold_in(mlxsw_sp, pool, dir,
725 threshold, &max_buff); 728 threshold, &max_buff);
726 if (err) 729 if (err)
727 return err; 730 return err;
728 731
729 if (pool_type == DEVLINK_SB_POOL_TYPE_EGRESS) {
730 if (pool < MLXSW_SP_SB_POOL_COUNT)
731 return -EINVAL;
732 pool -= MLXSW_SP_SB_POOL_COUNT;
733 } else if (pool >= MLXSW_SP_SB_POOL_COUNT) {
734 return -EINVAL;
735 }
736 return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir, 732 return mlxsw_sp_sb_cm_write(mlxsw_sp, local_port, pg_buff, dir,
737 0, max_buff, pool); 733 0, max_buff, pool);
738} 734}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 90bb93b037ec..917ddd1e422f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -657,7 +657,7 @@ int mlxsw_sp_router_neigh_construct(struct net_device *dev,
657 return 0; 657 return 0;
658 } 658 }
659 659
660 r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); 660 r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, n->dev);
661 if (WARN_ON(!r)) 661 if (WARN_ON(!r))
662 return -EINVAL; 662 return -EINVAL;
663 663
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 4d4ecba0aad9..8e13ec84c538 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -475,14 +475,6 @@ static void __lpc_get_mac(struct netdata_local *pldat, u8 *mac)
475 mac[5] = tmp >> 8; 475 mac[5] = tmp >> 8;
476} 476}
477 477
478static void __lpc_eth_clock_enable(struct netdata_local *pldat, bool enable)
479{
480 if (enable)
481 clk_prepare_enable(pldat->clk);
482 else
483 clk_disable_unprepare(pldat->clk);
484}
485
486static void __lpc_params_setup(struct netdata_local *pldat) 478static void __lpc_params_setup(struct netdata_local *pldat)
487{ 479{
488 u32 tmp; 480 u32 tmp;
@@ -1056,7 +1048,7 @@ static int lpc_eth_close(struct net_device *ndev)
1056 writel(0, LPC_ENET_MAC2(pldat->net_base)); 1048 writel(0, LPC_ENET_MAC2(pldat->net_base));
1057 spin_unlock_irqrestore(&pldat->lock, flags); 1049 spin_unlock_irqrestore(&pldat->lock, flags);
1058 1050
1059 __lpc_eth_clock_enable(pldat, false); 1051 clk_disable_unprepare(pldat->clk);
1060 1052
1061 return 0; 1053 return 0;
1062} 1054}
@@ -1197,11 +1189,14 @@ static int lpc_eth_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
1197static int lpc_eth_open(struct net_device *ndev) 1189static int lpc_eth_open(struct net_device *ndev)
1198{ 1190{
1199 struct netdata_local *pldat = netdev_priv(ndev); 1191 struct netdata_local *pldat = netdev_priv(ndev);
1192 int ret;
1200 1193
1201 if (netif_msg_ifup(pldat)) 1194 if (netif_msg_ifup(pldat))
1202 dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name); 1195 dev_dbg(&pldat->pdev->dev, "enabling %s\n", ndev->name);
1203 1196
1204 __lpc_eth_clock_enable(pldat, true); 1197 ret = clk_prepare_enable(pldat->clk);
1198 if (ret)
1199 return ret;
1205 1200
1206 /* Suspended PHY makes LPC ethernet core block, so resume now */ 1201 /* Suspended PHY makes LPC ethernet core block, so resume now */
1207 phy_resume(ndev->phydev); 1202 phy_resume(ndev->phydev);
@@ -1320,7 +1315,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
1320 } 1315 }
1321 1316
1322 /* Enable network clock */ 1317 /* Enable network clock */
1323 __lpc_eth_clock_enable(pldat, true); 1318 ret = clk_prepare_enable(pldat->clk);
1319 if (ret)
1320 goto err_out_clk_put;
1324 1321
1325 /* Map IO space */ 1322 /* Map IO space */
1326 pldat->net_base = ioremap(res->start, resource_size(res)); 1323 pldat->net_base = ioremap(res->start, resource_size(res));
@@ -1454,6 +1451,7 @@ err_out_iounmap:
1454 iounmap(pldat->net_base); 1451 iounmap(pldat->net_base);
1455err_out_disable_clocks: 1452err_out_disable_clocks:
1456 clk_disable_unprepare(pldat->clk); 1453 clk_disable_unprepare(pldat->clk);
1454err_out_clk_put:
1457 clk_put(pldat->clk); 1455 clk_put(pldat->clk);
1458err_out_free_dev: 1456err_out_free_dev:
1459 free_netdev(ndev); 1457 free_netdev(ndev);
diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h
index 35e53771533f..45ab74676573 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -561,9 +561,18 @@ struct qed_dev {
561static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev, 561static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev,
562 u32 concrete_fid) 562 u32 concrete_fid)
563{ 563{
564 u8 vfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID);
564 u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID); 565 u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID);
566 u8 vf_valid = GET_FIELD(concrete_fid,
567 PXP_CONCRETE_FID_VFVALID);
568 u8 sw_fid;
565 569
566 return pfid; 570 if (vf_valid)
571 sw_fid = vfid + MAX_NUM_PFS;
572 else
573 sw_fid = pfid;
574
575 return sw_fid;
567} 576}
568 577
569#define PURE_LB_TC 8 578#define PURE_LB_TC 8
diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index e4bd02e46e57..a6eb6af8cbe8 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -722,11 +722,14 @@ netdev_tx_t qede_start_xmit(struct sk_buff *skb,
722 txq->tx_db.data.bd_prod = 722 txq->tx_db.data.bd_prod =
723 cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl)); 723 cpu_to_le16(qed_chain_get_prod_idx(&txq->tx_pbl));
724 724
725 if (!skb->xmit_more || netif_tx_queue_stopped(netdev_txq)) 725 if (!skb->xmit_more || netif_xmit_stopped(netdev_txq))
726 qede_update_tx_producer(txq); 726 qede_update_tx_producer(txq);
727 727
728 if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl) 728 if (unlikely(qed_chain_get_elem_left(&txq->tx_pbl)
729 < (MAX_SKB_FRAGS + 1))) { 729 < (MAX_SKB_FRAGS + 1))) {
730 if (skb->xmit_more)
731 qede_update_tx_producer(txq);
732
730 netif_tx_stop_queue(netdev_txq); 733 netif_tx_stop_queue(netdev_txq);
731 DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED, 734 DP_VERBOSE(edev, NETIF_MSG_TX_QUEUED,
732 "Stop queue was called\n"); 735 "Stop queue was called\n");
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index deae10d7426d..5297bf77211c 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -467,8 +467,8 @@ static int cp_rx_poll(struct napi_struct *napi, int budget)
467 unsigned int rx_tail = cp->rx_tail; 467 unsigned int rx_tail = cp->rx_tail;
468 int rx; 468 int rx;
469 469
470rx_status_loop:
471 rx = 0; 470 rx = 0;
471rx_status_loop:
472 cpw16(IntrStatus, cp_rx_intr_mask); 472 cpw16(IntrStatus, cp_rx_intr_mask);
473 473
474 while (rx < budget) { 474 while (rx < budget) {
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index f658fee74f18..e00a669e9e09 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -1517,13 +1517,14 @@ static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask)
1517 } 1517 }
1518 1518
1519#if BITS_PER_LONG == 64 1519#if BITS_PER_LONG == 64
1520 BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 2);
1520 mask[0] = raw_mask[0]; 1521 mask[0] = raw_mask[0];
1521 mask[1] = raw_mask[1]; 1522 mask[1] = raw_mask[1];
1522#else 1523#else
1524 BUILD_BUG_ON(BITS_TO_LONGS(EF10_STAT_COUNT) != 3);
1523 mask[0] = raw_mask[0] & 0xffffffff; 1525 mask[0] = raw_mask[0] & 0xffffffff;
1524 mask[1] = raw_mask[0] >> 32; 1526 mask[1] = raw_mask[0] >> 32;
1525 mask[2] = raw_mask[1] & 0xffffffff; 1527 mask[2] = raw_mask[1] & 0xffffffff;
1526 mask[3] = raw_mask[1] >> 32;
1527#endif 1528#endif
1528} 1529}
1529 1530
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 726b80f45906..503a3b6dce91 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -2275,6 +2275,13 @@ static int smc_drv_probe(struct platform_device *pdev)
2275 if (pd) { 2275 if (pd) {
2276 memcpy(&lp->cfg, pd, sizeof(lp->cfg)); 2276 memcpy(&lp->cfg, pd, sizeof(lp->cfg));
2277 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); 2277 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags);
2278
2279 if (!SMC_8BIT(lp) && !SMC_16BIT(lp)) {
2280 dev_err(&pdev->dev,
2281 "at least one of 8-bit or 16-bit access support is required.\n");
2282 ret = -ENXIO;
2283 goto out_free_netdev;
2284 }
2278 } 2285 }
2279 2286
2280#if IS_BUILTIN(CONFIG_OF) 2287#if IS_BUILTIN(CONFIG_OF)
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index 1a55c7976df0..e17671c9d1b0 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -37,6 +37,27 @@
37#include <linux/smc91x.h> 37#include <linux/smc91x.h>
38 38
39/* 39/*
40 * Any 16-bit access is performed with two 8-bit accesses if the hardware
41 * can't do it directly. Most registers are 16-bit so those are mandatory.
42 */
43#define SMC_outw_b(x, a, r) \
44 do { \
45 unsigned int __val16 = (x); \
46 unsigned int __reg = (r); \
47 SMC_outb(__val16, a, __reg); \
48 SMC_outb(__val16 >> 8, a, __reg + (1 << SMC_IO_SHIFT)); \
49 } while (0)
50
51#define SMC_inw_b(a, r) \
52 ({ \
53 unsigned int __val16; \
54 unsigned int __reg = r; \
55 __val16 = SMC_inb(a, __reg); \
56 __val16 |= SMC_inb(a, __reg + (1 << SMC_IO_SHIFT)) << 8; \
57 __val16; \
58 })
59
60/*
40 * Define your architecture specific bus configuration parameters here. 61 * Define your architecture specific bus configuration parameters here.
41 */ 62 */
42 63
@@ -55,10 +76,30 @@
55#define SMC_IO_SHIFT (lp->io_shift) 76#define SMC_IO_SHIFT (lp->io_shift)
56 77
57#define SMC_inb(a, r) readb((a) + (r)) 78#define SMC_inb(a, r) readb((a) + (r))
58#define SMC_inw(a, r) readw((a) + (r)) 79#define SMC_inw(a, r) \
80 ({ \
81 unsigned int __smc_r = r; \
82 SMC_16BIT(lp) ? readw((a) + __smc_r) : \
83 SMC_8BIT(lp) ? SMC_inw_b(a, __smc_r) : \
84 ({ BUG(); 0; }); \
85 })
86
59#define SMC_inl(a, r) readl((a) + (r)) 87#define SMC_inl(a, r) readl((a) + (r))
60#define SMC_outb(v, a, r) writeb(v, (a) + (r)) 88#define SMC_outb(v, a, r) writeb(v, (a) + (r))
89#define SMC_outw(v, a, r) \
90 do { \
91 unsigned int __v = v, __smc_r = r; \
92 if (SMC_16BIT(lp)) \
93 __SMC_outw(__v, a, __smc_r); \
94 else if (SMC_8BIT(lp)) \
95 SMC_outw_b(__v, a, __smc_r); \
96 else \
97 BUG(); \
98 } while (0)
99
61#define SMC_outl(v, a, r) writel(v, (a) + (r)) 100#define SMC_outl(v, a, r) writel(v, (a) + (r))
101#define SMC_insb(a, r, p, l) readsb((a) + (r), p, l)
102#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, l)
62#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) 103#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
63#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) 104#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
64#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) 105#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
@@ -66,7 +107,7 @@
66#define SMC_IRQ_FLAGS (-1) /* from resource */ 107#define SMC_IRQ_FLAGS (-1) /* from resource */
67 108
68/* We actually can't write halfwords properly if not word aligned */ 109/* We actually can't write halfwords properly if not word aligned */
69static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) 110static inline void __SMC_outw(u16 val, void __iomem *ioaddr, int reg)
70{ 111{
71 if ((machine_is_mainstone() || machine_is_stargate2() || 112 if ((machine_is_mainstone() || machine_is_stargate2() ||
72 machine_is_pxa_idp()) && reg & 2) { 113 machine_is_pxa_idp()) && reg & 2) {
@@ -416,24 +457,8 @@ smc_pxa_dma_insw(void __iomem *ioaddr, struct smc_local *lp, int reg, int dma,
416 457
417#if ! SMC_CAN_USE_16BIT 458#if ! SMC_CAN_USE_16BIT
418 459
419/* 460#define SMC_outw(x, ioaddr, reg) SMC_outw_b(x, ioaddr, reg)
420 * Any 16-bit access is performed with two 8-bit accesses if the hardware 461#define SMC_inw(ioaddr, reg) SMC_inw_b(ioaddr, reg)
421 * can't do it directly. Most registers are 16-bit so those are mandatory.
422 */
423#define SMC_outw(x, ioaddr, reg) \
424 do { \
425 unsigned int __val16 = (x); \
426 SMC_outb( __val16, ioaddr, reg ); \
427 SMC_outb( __val16 >> 8, ioaddr, reg + (1 << SMC_IO_SHIFT));\
428 } while (0)
429#define SMC_inw(ioaddr, reg) \
430 ({ \
431 unsigned int __val16; \
432 __val16 = SMC_inb( ioaddr, reg ); \
433 __val16 |= SMC_inb( ioaddr, reg + (1 << SMC_IO_SHIFT)) << 8; \
434 __val16; \
435 })
436
437#define SMC_insw(a, r, p, l) BUG() 462#define SMC_insw(a, r, p, l) BUG()
438#define SMC_outsw(a, r, p, l) BUG() 463#define SMC_outsw(a, r, p, l) BUG()
439 464
diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 9f159a775af3..5a3941bf250f 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -1622,13 +1622,7 @@ static void dwceqos_init_hw(struct net_local *lp)
1622 DWCEQOS_MMC_CTRL_RSTONRD); 1622 DWCEQOS_MMC_CTRL_RSTONRD);
1623 dwceqos_enable_mmc_interrupt(lp); 1623 dwceqos_enable_mmc_interrupt(lp);
1624 1624
1625 /* Enable Interrupts */ 1625 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE, 0);
1626 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE,
1627 DWCEQOS_DMA_CH0_IE_NIE |
1628 DWCEQOS_DMA_CH0_IE_RIE | DWCEQOS_DMA_CH0_IE_TIE |
1629 DWCEQOS_DMA_CH0_IE_AIE |
1630 DWCEQOS_DMA_CH0_IE_FBEE);
1631
1632 dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0); 1626 dwceqos_write(lp, REG_DWCEQOS_MAC_IE, 0);
1633 1627
1634 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC | 1628 dwceqos_write(lp, REG_DWCEQOS_MAC_CFG, DWCEQOS_MAC_CFG_IPC |
@@ -1905,6 +1899,15 @@ static int dwceqos_open(struct net_device *ndev)
1905 netif_start_queue(ndev); 1899 netif_start_queue(ndev);
1906 tasklet_enable(&lp->tx_bdreclaim_tasklet); 1900 tasklet_enable(&lp->tx_bdreclaim_tasklet);
1907 1901
1902 /* Enable Interrupts -- do this only after we enable NAPI and the
1903 * tasklet.
1904 */
1905 dwceqos_write(lp, REG_DWCEQOS_DMA_CH0_IE,
1906 DWCEQOS_DMA_CH0_IE_NIE |
1907 DWCEQOS_DMA_CH0_IE_RIE | DWCEQOS_DMA_CH0_IE_TIE |
1908 DWCEQOS_DMA_CH0_IE_AIE |
1909 DWCEQOS_DMA_CH0_IE_FBEE);
1910
1908 return 0; 1911 return 0;
1909} 1912}
1910 1913
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 7452b5f9d024..7108c68f16d3 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -1987,7 +1987,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1987 if ((readl(nic->regs + FPGA_VER) & 0xFFF) >= 378) { 1987 if ((readl(nic->regs + FPGA_VER) & 0xFFF) >= 378) {
1988 err = pci_enable_msi(pdev); 1988 err = pci_enable_msi(pdev);
1989 if (err) 1989 if (err)
1990 pr_err("Can't eneble msi. error is %d\n", err); 1990 pr_err("Can't enable msi. error is %d\n", err);
1991 else 1991 else
1992 nic->irq_type = IRQ_MSI; 1992 nic->irq_type = IRQ_MSI;
1993 } else 1993 } else
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 3cee84a24815..93dc10b10c09 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1131,11 +1131,13 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
1131 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong"); 1131 lp->rx_ping_pong = get_bool(ofdev, "xlnx,rx-ping-pong");
1132 mac_address = of_get_mac_address(ofdev->dev.of_node); 1132 mac_address = of_get_mac_address(ofdev->dev.of_node);
1133 1133
1134 if (mac_address) 1134 if (mac_address) {
1135 /* Set the MAC address. */ 1135 /* Set the MAC address. */
1136 memcpy(ndev->dev_addr, mac_address, ETH_ALEN); 1136 memcpy(ndev->dev_addr, mac_address, ETH_ALEN);
1137 else 1137 } else {
1138 dev_warn(dev, "No MAC address found\n"); 1138 dev_warn(dev, "No MAC address found, using random\n");
1139 eth_hw_addr_random(ndev);
1140 }
1139 1141
1140 /* Clear the Tx CSR's in case this is a restart */ 1142 /* Clear the Tx CSR's in case this is a restart */
1141 __raw_writel(0, lp->base_addr + XEL_TSR_OFFSET); 1143 __raw_writel(0, lp->base_addr + XEL_TSR_OFFSET);
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 053e87905b94..885ac9cbab5a 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -964,7 +964,7 @@ static struct phy_driver ksphy_driver[] = {
964 .get_strings = kszphy_get_strings, 964 .get_strings = kszphy_get_strings,
965 .get_stats = kszphy_get_stats, 965 .get_stats = kszphy_get_stats,
966 .suspend = genphy_suspend, 966 .suspend = genphy_suspend,
967 .resume = genphy_resume, 967 .resume = kszphy_resume,
968}, { 968}, {
969 .phy_id = PHY_ID_KSZ8873MLL, 969 .phy_id = PHY_ID_KSZ8873MLL,
970 .phy_id_mask = MICREL_PHY_ID_MASK, 970 .phy_id_mask = MICREL_PHY_ID_MASK,
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index c5dc2c363f96..c6f66832a1a6 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -722,8 +722,10 @@ phy_err:
722int phy_start_interrupts(struct phy_device *phydev) 722int phy_start_interrupts(struct phy_device *phydev)
723{ 723{
724 atomic_set(&phydev->irq_disable, 0); 724 atomic_set(&phydev->irq_disable, 0);
725 if (request_irq(phydev->irq, phy_interrupt, 0, "phy_interrupt", 725 if (request_irq(phydev->irq, phy_interrupt,
726 phydev) < 0) { 726 IRQF_SHARED,
727 "phy_interrupt",
728 phydev) < 0) {
727 pr_warn("%s: Can't get IRQ %d (PHY)\n", 729 pr_warn("%s: Can't get IRQ %d (PHY)\n",
728 phydev->mdio.bus->name, phydev->irq); 730 phydev->mdio.bus->name, phydev->irq);
729 phydev->irq = PHY_POLL; 731 phydev->irq = PHY_POLL;
diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/team_mode_loadbalance.c
index cdb19b385d42..b228bea7931f 100644
--- a/drivers/net/team/team_mode_loadbalance.c
+++ b/drivers/net/team/team_mode_loadbalance.c
@@ -14,9 +14,23 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/etherdevice.h>
17#include <linux/filter.h> 18#include <linux/filter.h>
18#include <linux/if_team.h> 19#include <linux/if_team.h>
19 20
21static rx_handler_result_t lb_receive(struct team *team, struct team_port *port,
22 struct sk_buff *skb)
23{
24 if (unlikely(skb->protocol == htons(ETH_P_SLOW))) {
25 /* LACPDU packets should go to exact delivery */
26 const unsigned char *dest = eth_hdr(skb)->h_dest;
27
28 if (is_link_local_ether_addr(dest) && dest[5] == 0x02)
29 return RX_HANDLER_EXACT;
30 }
31 return RX_HANDLER_ANOTHER;
32}
33
20struct lb_priv; 34struct lb_priv;
21 35
22typedef struct team_port *lb_select_tx_port_func_t(struct team *, 36typedef struct team_port *lb_select_tx_port_func_t(struct team *,
@@ -652,6 +666,7 @@ static const struct team_mode_ops lb_mode_ops = {
652 .port_enter = lb_port_enter, 666 .port_enter = lb_port_enter,
653 .port_leave = lb_port_leave, 667 .port_leave = lb_port_leave,
654 .port_disabled = lb_port_disabled, 668 .port_disabled = lb_port_disabled,
669 .receive = lb_receive,
655 .transmit = lb_transmit, 670 .transmit = lb_transmit,
656}; 671};
657 672
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 9c8b5bc2b9d8..6f9df375c5d4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -894,11 +894,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
894 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) 894 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
895 goto drop; 895 goto drop;
896 896
897 if (skb->sk && sk_fullsock(skb->sk)) { 897 skb_tx_timestamp(skb);
898 sock_tx_timestamp(skb->sk, skb->sk->sk_tsflags,
899 &skb_shinfo(skb)->tx_flags);
900 sw_tx_timestamp(skb);
901 }
902 898
903 /* Orphan the skb - required as we might hang on to it 899 /* Orphan the skb - required as we might hang on to it
904 * for indefinite time. 900 * for indefinite time.
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 770212baaf05..528b9c9c4e60 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -1009,6 +1009,7 @@ static int kaweth_probe(
1009 struct net_device *netdev; 1009 struct net_device *netdev;
1010 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 1010 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
1011 int result = 0; 1011 int result = 0;
1012 int rv = -EIO;
1012 1013
1013 dev_dbg(dev, 1014 dev_dbg(dev,
1014 "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", 1015 "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n",
@@ -1029,6 +1030,7 @@ static int kaweth_probe(
1029 kaweth = netdev_priv(netdev); 1030 kaweth = netdev_priv(netdev);
1030 kaweth->dev = udev; 1031 kaweth->dev = udev;
1031 kaweth->net = netdev; 1032 kaweth->net = netdev;
1033 kaweth->intf = intf;
1032 1034
1033 spin_lock_init(&kaweth->device_lock); 1035 spin_lock_init(&kaweth->device_lock);
1034 init_waitqueue_head(&kaweth->term_wait); 1036 init_waitqueue_head(&kaweth->term_wait);
@@ -1048,6 +1050,10 @@ static int kaweth_probe(
1048 /* Download the firmware */ 1050 /* Download the firmware */
1049 dev_info(dev, "Downloading firmware...\n"); 1051 dev_info(dev, "Downloading firmware...\n");
1050 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 1052 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
1053 if (!kaweth->firmware_buf) {
1054 rv = -ENOMEM;
1055 goto err_free_netdev;
1056 }
1051 if ((result = kaweth_download_firmware(kaweth, 1057 if ((result = kaweth_download_firmware(kaweth,
1052 "kaweth/new_code.bin", 1058 "kaweth/new_code.bin",
1053 100, 1059 100,
@@ -1139,8 +1145,6 @@ err_fw:
1139 1145
1140 dev_dbg(dev, "Initializing net device.\n"); 1146 dev_dbg(dev, "Initializing net device.\n");
1141 1147
1142 kaweth->intf = intf;
1143
1144 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1148 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1145 if (!kaweth->tx_urb) 1149 if (!kaweth->tx_urb)
1146 goto err_free_netdev; 1150 goto err_free_netdev;
@@ -1204,7 +1208,7 @@ err_only_tx:
1204err_free_netdev: 1208err_free_netdev:
1205 free_netdev(netdev); 1209 free_netdev(netdev);
1206 1210
1207 return -EIO; 1211 return rv;
1208} 1212}
1209 1213
1210/**************************************************************** 1214/****************************************************************
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index c68fe495d3f9..4244b9d4418e 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -914,7 +914,9 @@ vmxnet3_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
914{ 914{
915 struct Vmxnet3_TxDataDesc *tdd; 915 struct Vmxnet3_TxDataDesc *tdd;
916 916
917 tdd = tq->data_ring.base + tq->tx_ring.next2fill; 917 tdd = (struct Vmxnet3_TxDataDesc *)((u8 *)tq->data_ring.base +
918 tq->tx_ring.next2fill *
919 tq->txdata_desc_size);
918 920
919 memcpy(tdd->data, skb->data, ctx->copy_size); 921 memcpy(tdd->data, skb->data, ctx->copy_size);
920 netdev_dbg(adapter->netdev, 922 netdev_dbg(adapter->netdev,
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 74fc03072b87..7dc37a090549 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -69,10 +69,10 @@
69/* 69/*
70 * Version numbers 70 * Version numbers
71 */ 71 */
72#define VMXNET3_DRIVER_VERSION_STRING "1.4.9.0-k" 72#define VMXNET3_DRIVER_VERSION_STRING "1.4.a.0-k"
73 73
74/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 74/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
75#define VMXNET3_DRIVER_VERSION_NUM 0x01040900 75#define VMXNET3_DRIVER_VERSION_NUM 0x01040a00
76 76
77#if defined(CONFIG_PCI_MSI) 77#if defined(CONFIG_PCI_MSI)
78 /* RSS only makes sense if MSI-X is supported. */ 78 /* RSS only makes sense if MSI-X is supported. */
diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig
index db39d53cdfb9..0c644f7bdf80 100644
--- a/drivers/nvme/host/Kconfig
+++ b/drivers/nvme/host/Kconfig
@@ -31,7 +31,7 @@ config NVME_FABRICS
31config NVME_RDMA 31config NVME_RDMA
32 tristate "NVM Express over Fabrics RDMA host driver" 32 tristate "NVM Express over Fabrics RDMA host driver"
33 depends on INFINIBAND 33 depends on INFINIBAND
34 depends on BLK_DEV_NVME 34 select NVME_CORE
35 select NVME_FABRICS 35 select NVME_FABRICS
36 select SG_POOL 36 select SG_POOL
37 help 37 help
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index dc996761042f..4eff49174466 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -47,8 +47,10 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
47 47
48 mutex_lock(&nvmf_hosts_mutex); 48 mutex_lock(&nvmf_hosts_mutex);
49 host = __nvmf_host_find(hostnqn); 49 host = __nvmf_host_find(hostnqn);
50 if (host) 50 if (host) {
51 kref_get(&host->ref);
51 goto out_unlock; 52 goto out_unlock;
53 }
52 54
53 host = kmalloc(sizeof(*host), GFP_KERNEL); 55 host = kmalloc(sizeof(*host), GFP_KERNEL);
54 if (!host) 56 if (!host)
@@ -56,7 +58,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
56 58
57 kref_init(&host->ref); 59 kref_init(&host->ref);
58 memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE); 60 memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
59 uuid_le_gen(&host->id); 61 uuid_be_gen(&host->id);
60 62
61 list_add_tail(&host->list, &nvmf_hosts); 63 list_add_tail(&host->list, &nvmf_hosts);
62out_unlock: 64out_unlock:
@@ -73,9 +75,9 @@ static struct nvmf_host *nvmf_host_default(void)
73 return NULL; 75 return NULL;
74 76
75 kref_init(&host->ref); 77 kref_init(&host->ref);
76 uuid_le_gen(&host->id); 78 uuid_be_gen(&host->id);
77 snprintf(host->nqn, NVMF_NQN_SIZE, 79 snprintf(host->nqn, NVMF_NQN_SIZE,
78 "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id); 80 "nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
79 81
80 mutex_lock(&nvmf_hosts_mutex); 82 mutex_lock(&nvmf_hosts_mutex);
81 list_add_tail(&host->list, &nvmf_hosts); 83 list_add_tail(&host->list, &nvmf_hosts);
@@ -363,7 +365,14 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
363 cmd.connect.opcode = nvme_fabrics_command; 365 cmd.connect.opcode = nvme_fabrics_command;
364 cmd.connect.fctype = nvme_fabrics_type_connect; 366 cmd.connect.fctype = nvme_fabrics_type_connect;
365 cmd.connect.qid = 0; 367 cmd.connect.qid = 0;
366 cmd.connect.sqsize = cpu_to_le16(ctrl->sqsize); 368
369 /*
370 * fabrics spec sets a minimum of depth 32 for admin queue,
371 * so set the queue with this depth always until
372 * justification otherwise.
373 */
374 cmd.connect.sqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1);
375
367 /* 376 /*
368 * Set keep-alive timeout in seconds granularity (ms * 1000) 377 * Set keep-alive timeout in seconds granularity (ms * 1000)
369 * and add a grace period for controller kato enforcement 378 * and add a grace period for controller kato enforcement
@@ -375,7 +384,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
375 if (!data) 384 if (!data)
376 return -ENOMEM; 385 return -ENOMEM;
377 386
378 memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); 387 memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
379 data->cntlid = cpu_to_le16(0xffff); 388 data->cntlid = cpu_to_le16(0xffff);
380 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); 389 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
381 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); 390 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
@@ -434,7 +443,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
434 if (!data) 443 if (!data)
435 return -ENOMEM; 444 return -ENOMEM;
436 445
437 memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le)); 446 memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
438 data->cntlid = cpu_to_le16(ctrl->cntlid); 447 data->cntlid = cpu_to_le16(ctrl->cntlid);
439 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); 448 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
440 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); 449 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index 89df52c8be97..46e460aee52d 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -34,7 +34,7 @@ struct nvmf_host {
34 struct kref ref; 34 struct kref ref;
35 struct list_head list; 35 struct list_head list;
36 char nqn[NVMF_NQN_SIZE]; 36 char nqn[NVMF_NQN_SIZE];
37 uuid_le id; 37 uuid_be id;
38}; 38};
39 39
40/** 40/**
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 8d2875b4c56d..ab545fb347a0 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -43,10 +43,6 @@
43 43
44#define NVME_RDMA_MAX_INLINE_SEGMENTS 1 44#define NVME_RDMA_MAX_INLINE_SEGMENTS 1
45 45
46#define NVME_RDMA_MAX_PAGES_PER_MR 512
47
48#define NVME_RDMA_DEF_RECONNECT_DELAY 20
49
50/* 46/*
51 * We handle AEN commands ourselves and don't even let the 47 * We handle AEN commands ourselves and don't even let the
52 * block layer know about them. 48 * block layer know about them.
@@ -77,7 +73,6 @@ struct nvme_rdma_request {
77 u32 num_sge; 73 u32 num_sge;
78 int nents; 74 int nents;
79 bool inline_data; 75 bool inline_data;
80 bool need_inval;
81 struct ib_reg_wr reg_wr; 76 struct ib_reg_wr reg_wr;
82 struct ib_cqe reg_cqe; 77 struct ib_cqe reg_cqe;
83 struct nvme_rdma_queue *queue; 78 struct nvme_rdma_queue *queue;
@@ -286,7 +281,7 @@ static int nvme_rdma_reinit_request(void *data, struct request *rq)
286 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq); 281 struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
287 int ret = 0; 282 int ret = 0;
288 283
289 if (!req->need_inval) 284 if (!req->mr->need_inval)
290 goto out; 285 goto out;
291 286
292 ib_dereg_mr(req->mr); 287 ib_dereg_mr(req->mr);
@@ -298,7 +293,7 @@ static int nvme_rdma_reinit_request(void *data, struct request *rq)
298 req->mr = NULL; 293 req->mr = NULL;
299 } 294 }
300 295
301 req->need_inval = false; 296 req->mr->need_inval = false;
302 297
303out: 298out:
304 return ret; 299 return ret;
@@ -645,7 +640,8 @@ static int nvme_rdma_init_io_queues(struct nvme_rdma_ctrl *ctrl)
645 int i, ret; 640 int i, ret;
646 641
647 for (i = 1; i < ctrl->queue_count; i++) { 642 for (i = 1; i < ctrl->queue_count; i++) {
648 ret = nvme_rdma_init_queue(ctrl, i, ctrl->ctrl.sqsize); 643 ret = nvme_rdma_init_queue(ctrl, i,
644 ctrl->ctrl.opts->queue_size);
649 if (ret) { 645 if (ret) {
650 dev_info(ctrl->ctrl.device, 646 dev_info(ctrl->ctrl.device,
651 "failed to initialize i/o queue: %d\n", ret); 647 "failed to initialize i/o queue: %d\n", ret);
@@ -849,7 +845,7 @@ static void nvme_rdma_unmap_data(struct nvme_rdma_queue *queue,
849 if (!blk_rq_bytes(rq)) 845 if (!blk_rq_bytes(rq))
850 return; 846 return;
851 847
852 if (req->need_inval) { 848 if (req->mr->need_inval) {
853 res = nvme_rdma_inv_rkey(queue, req); 849 res = nvme_rdma_inv_rkey(queue, req);
854 if (res < 0) { 850 if (res < 0) {
855 dev_err(ctrl->ctrl.device, 851 dev_err(ctrl->ctrl.device,
@@ -935,7 +931,7 @@ static int nvme_rdma_map_sg_fr(struct nvme_rdma_queue *queue,
935 IB_ACCESS_REMOTE_READ | 931 IB_ACCESS_REMOTE_READ |
936 IB_ACCESS_REMOTE_WRITE; 932 IB_ACCESS_REMOTE_WRITE;
937 933
938 req->need_inval = true; 934 req->mr->need_inval = true;
939 935
940 sg->addr = cpu_to_le64(req->mr->iova); 936 sg->addr = cpu_to_le64(req->mr->iova);
941 put_unaligned_le24(req->mr->length, sg->length); 937 put_unaligned_le24(req->mr->length, sg->length);
@@ -958,7 +954,7 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue *queue,
958 954
959 req->num_sge = 1; 955 req->num_sge = 1;
960 req->inline_data = false; 956 req->inline_data = false;
961 req->need_inval = false; 957 req->mr->need_inval = false;
962 958
963 c->common.flags |= NVME_CMD_SGL_METABUF; 959 c->common.flags |= NVME_CMD_SGL_METABUF;
964 960
@@ -1145,7 +1141,7 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,
1145 1141
1146 if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) && 1142 if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) &&
1147 wc->ex.invalidate_rkey == req->mr->rkey) 1143 wc->ex.invalidate_rkey == req->mr->rkey)
1148 req->need_inval = false; 1144 req->mr->need_inval = false;
1149 1145
1150 blk_mq_complete_request(rq, status); 1146 blk_mq_complete_request(rq, status);
1151 1147
@@ -1278,8 +1274,22 @@ static int nvme_rdma_route_resolved(struct nvme_rdma_queue *queue)
1278 1274
1279 priv.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0); 1275 priv.recfmt = cpu_to_le16(NVME_RDMA_CM_FMT_1_0);
1280 priv.qid = cpu_to_le16(nvme_rdma_queue_idx(queue)); 1276 priv.qid = cpu_to_le16(nvme_rdma_queue_idx(queue));
1281 priv.hrqsize = cpu_to_le16(queue->queue_size); 1277 /*
1282 priv.hsqsize = cpu_to_le16(queue->queue_size); 1278 * set the admin queue depth to the minimum size
1279 * specified by the Fabrics standard.
1280 */
1281 if (priv.qid == 0) {
1282 priv.hrqsize = cpu_to_le16(NVMF_AQ_DEPTH);
1283 priv.hsqsize = cpu_to_le16(NVMF_AQ_DEPTH - 1);
1284 } else {
1285 /*
1286 * current interpretation of the fabrics spec
1287 * is at minimum you make hrqsize sqsize+1, or a
1288 * 1's based representation of sqsize.
1289 */
1290 priv.hrqsize = cpu_to_le16(queue->queue_size);
1291 priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize);
1292 }
1283 1293
1284 ret = rdma_connect(queue->cm_id, &param); 1294 ret = rdma_connect(queue->cm_id, &param);
1285 if (ret) { 1295 if (ret) {
@@ -1319,7 +1329,7 @@ out_destroy_queue_ib:
1319static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue) 1329static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue)
1320{ 1330{
1321 struct nvme_rdma_ctrl *ctrl = queue->ctrl; 1331 struct nvme_rdma_ctrl *ctrl = queue->ctrl;
1322 int ret; 1332 int ret = 0;
1323 1333
1324 /* Own the controller deletion */ 1334 /* Own the controller deletion */
1325 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING)) 1335 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING))
@@ -1461,7 +1471,7 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
1461 if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH) 1471 if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH)
1462 flush = true; 1472 flush = true;
1463 ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge, 1473 ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge,
1464 req->need_inval ? &req->reg_wr.wr : NULL, flush); 1474 req->mr->need_inval ? &req->reg_wr.wr : NULL, flush);
1465 if (ret) { 1475 if (ret) {
1466 nvme_rdma_unmap_data(queue, rq); 1476 nvme_rdma_unmap_data(queue, rq);
1467 goto err; 1477 goto err;
@@ -1816,7 +1826,7 @@ static int nvme_rdma_create_io_queues(struct nvme_rdma_ctrl *ctrl)
1816 1826
1817 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); 1827 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
1818 ctrl->tag_set.ops = &nvme_rdma_mq_ops; 1828 ctrl->tag_set.ops = &nvme_rdma_mq_ops;
1819 ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; 1829 ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size;
1820 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ 1830 ctrl->tag_set.reserved_tags = 1; /* fabric connect */
1821 ctrl->tag_set.numa_node = NUMA_NO_NODE; 1831 ctrl->tag_set.numa_node = NUMA_NO_NODE;
1822 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; 1832 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
@@ -1914,7 +1924,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
1914 spin_lock_init(&ctrl->lock); 1924 spin_lock_init(&ctrl->lock);
1915 1925
1916 ctrl->queue_count = opts->nr_io_queues + 1; /* +1 for admin queue */ 1926 ctrl->queue_count = opts->nr_io_queues + 1; /* +1 for admin queue */
1917 ctrl->ctrl.sqsize = opts->queue_size; 1927 ctrl->ctrl.sqsize = opts->queue_size - 1;
1918 ctrl->ctrl.kato = opts->kato; 1928 ctrl->ctrl.kato = opts->kato;
1919 1929
1920 ret = -ENOMEM; 1930 ret = -ENOMEM;
diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index a5c31cbeb481..3a5b9d0576cb 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -15,8 +15,8 @@ config NVME_TARGET
15 15
16config NVME_TARGET_LOOP 16config NVME_TARGET_LOOP
17 tristate "NVMe loopback device support" 17 tristate "NVMe loopback device support"
18 depends on BLK_DEV_NVME
19 depends on NVME_TARGET 18 depends on NVME_TARGET
19 select NVME_CORE
20 select NVME_FABRICS 20 select NVME_FABRICS
21 select SG_POOL 21 select SG_POOL
22 help 22 help
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 7affd40a6b33..395e60dad835 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -556,7 +556,7 @@ static int nvme_loop_create_io_queues(struct nvme_loop_ctrl *ctrl)
556 556
557 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set)); 557 memset(&ctrl->tag_set, 0, sizeof(ctrl->tag_set));
558 ctrl->tag_set.ops = &nvme_loop_mq_ops; 558 ctrl->tag_set.ops = &nvme_loop_mq_ops;
559 ctrl->tag_set.queue_depth = ctrl->ctrl.sqsize; 559 ctrl->tag_set.queue_depth = ctrl->ctrl.opts->queue_size;
560 ctrl->tag_set.reserved_tags = 1; /* fabric connect */ 560 ctrl->tag_set.reserved_tags = 1; /* fabric connect */
561 ctrl->tag_set.numa_node = NUMA_NO_NODE; 561 ctrl->tag_set.numa_node = NUMA_NO_NODE;
562 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; 562 ctrl->tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
@@ -620,7 +620,7 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
620 620
621 ret = -ENOMEM; 621 ret = -ENOMEM;
622 622
623 ctrl->ctrl.sqsize = opts->queue_size; 623 ctrl->ctrl.sqsize = opts->queue_size - 1;
624 ctrl->ctrl.kato = opts->kato; 624 ctrl->ctrl.kato = opts->kato;
625 625
626 ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues), 626 ctrl->queues = kcalloc(opts->nr_io_queues + 1, sizeof(*ctrl->queues),
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index b4d648536c3e..1cbe6e053b5b 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -978,10 +978,11 @@ static void nvmet_rdma_release_queue_work(struct work_struct *w)
978 container_of(w, struct nvmet_rdma_queue, release_work); 978 container_of(w, struct nvmet_rdma_queue, release_work);
979 struct rdma_cm_id *cm_id = queue->cm_id; 979 struct rdma_cm_id *cm_id = queue->cm_id;
980 struct nvmet_rdma_device *dev = queue->dev; 980 struct nvmet_rdma_device *dev = queue->dev;
981 enum nvmet_rdma_queue_state state = queue->state;
981 982
982 nvmet_rdma_free_queue(queue); 983 nvmet_rdma_free_queue(queue);
983 984
984 if (queue->state != NVMET_RDMA_IN_DEVICE_REMOVAL) 985 if (state != NVMET_RDMA_IN_DEVICE_REMOVAL)
985 rdma_destroy_id(cm_id); 986 rdma_destroy_id(cm_id);
986 987
987 kref_put(&dev->ref, nvmet_rdma_free_dev); 988 kref_put(&dev->ref, nvmet_rdma_free_dev);
@@ -1003,10 +1004,10 @@ nvmet_rdma_parse_cm_connect_req(struct rdma_conn_param *conn,
1003 queue->host_qid = le16_to_cpu(req->qid); 1004 queue->host_qid = le16_to_cpu(req->qid);
1004 1005
1005 /* 1006 /*
1006 * req->hsqsize corresponds to our recv queue size 1007 * req->hsqsize corresponds to our recv queue size plus 1
1007 * req->hrqsize corresponds to our send queue size 1008 * req->hrqsize corresponds to our send queue size
1008 */ 1009 */
1009 queue->recv_queue_size = le16_to_cpu(req->hsqsize); 1010 queue->recv_queue_size = le16_to_cpu(req->hsqsize) + 1;
1010 queue->send_queue_size = le16_to_cpu(req->hrqsize); 1011 queue->send_queue_size = le16_to_cpu(req->hrqsize);
1011 1012
1012 if (!queue->host_qid && queue->recv_queue_size > NVMF_AQ_DEPTH) 1013 if (!queue->host_qid && queue->recv_queue_size > NVMF_AQ_DEPTH)
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index 5f4a2e04c8d7..add66236215c 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -44,6 +44,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
44 bridge->release_fn = release_fn; 44 bridge->release_fn = release_fn;
45 bridge->release_data = release_data; 45 bridge->release_data = release_data;
46} 46}
47EXPORT_SYMBOL_GPL(pci_set_host_bridge_release);
47 48
48void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, 49void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
49 struct resource *res) 50 struct resource *res)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 37ff0158e45f..44e0ff37480b 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3327,9 +3327,9 @@ static void quirk_apple_wait_for_thunderbolt(struct pci_dev *dev)
3327 if (nhi->vendor != PCI_VENDOR_ID_INTEL 3327 if (nhi->vendor != PCI_VENDOR_ID_INTEL
3328 || (nhi->device != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && 3328 || (nhi->device != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE &&
3329 nhi->device != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && 3329 nhi->device != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C &&
3330 nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI &&
3330 nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI) 3331 nhi->device != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI)
3331 || nhi->subsystem_vendor != 0x2222 3332 || nhi->class != PCI_CLASS_SYSTEM_OTHER << 8)
3332 || nhi->subsystem_device != 0x1111)
3333 goto out; 3333 goto out;
3334 dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); 3334 dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n");
3335 device_pm_wait_for_dev(&dev->dev, &nhi->dev); 3335 device_pm_wait_for_dev(&dev->dev, &nhi->dev);
@@ -3344,6 +3344,9 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL,
3344 PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C, 3344 PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C,
3345 quirk_apple_wait_for_thunderbolt); 3345 quirk_apple_wait_for_thunderbolt);
3346DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, 3346DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL,
3347 PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE,
3348 quirk_apple_wait_for_thunderbolt);
3349DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL,
3347 PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE, 3350 PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE,
3348 quirk_apple_wait_for_thunderbolt); 3351 quirk_apple_wait_for_thunderbolt);
3349#endif 3352#endif
diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index c494613c1909..f5e1008a223d 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -925,6 +925,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
925 if (i > 0 && spi != using_spi) { 925 if (i > 0 && spi != using_spi) {
926 pr_err("PPI/SPI IRQ type mismatch for %s!\n", 926 pr_err("PPI/SPI IRQ type mismatch for %s!\n",
927 dn->name); 927 dn->name);
928 of_node_put(dn);
928 kfree(irqs); 929 kfree(irqs);
929 return -EINVAL; 930 return -EINVAL;
930 } 931 }
@@ -969,7 +970,7 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu)
969 if (cpumask_weight(&pmu->supported_cpus) == 0) { 970 if (cpumask_weight(&pmu->supported_cpus) == 0) {
970 int irq = platform_get_irq(pdev, 0); 971 int irq = platform_get_irq(pdev, 0);
971 972
972 if (irq_is_percpu(irq)) { 973 if (irq >= 0 && irq_is_percpu(irq)) {
973 /* If using PPIs, check the affinity of the partition */ 974 /* If using PPIs, check the affinity of the partition */
974 int ret; 975 int ret;
975 976
diff --git a/drivers/phy/phy-brcm-sata.c b/drivers/phy/phy-brcm-sata.c
index 18d662610075..8ffc44afdb75 100644
--- a/drivers/phy/phy-brcm-sata.c
+++ b/drivers/phy/phy-brcm-sata.c
@@ -367,7 +367,7 @@ static int brcm_sata_phy_init(struct phy *phy)
367 rc = -ENODEV; 367 rc = -ENODEV;
368 }; 368 };
369 369
370 return 0; 370 return rc;
371} 371}
372 372
373static const struct phy_ops phy_ops = { 373static const struct phy_ops phy_ops = {
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index 0a45bc6088ae..8c7eb335622e 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -40,6 +40,7 @@
40#include <linux/power_supply.h> 40#include <linux/power_supply.h>
41#include <linux/regulator/consumer.h> 41#include <linux/regulator/consumer.h>
42#include <linux/reset.h> 42#include <linux/reset.h>
43#include <linux/usb/of.h>
43#include <linux/workqueue.h> 44#include <linux/workqueue.h>
44 45
45#define REG_ISCR 0x00 46#define REG_ISCR 0x00
@@ -110,6 +111,7 @@ struct sun4i_usb_phy_cfg {
110struct sun4i_usb_phy_data { 111struct sun4i_usb_phy_data {
111 void __iomem *base; 112 void __iomem *base;
112 const struct sun4i_usb_phy_cfg *cfg; 113 const struct sun4i_usb_phy_cfg *cfg;
114 enum usb_dr_mode dr_mode;
113 struct mutex mutex; 115 struct mutex mutex;
114 struct sun4i_usb_phy { 116 struct sun4i_usb_phy {
115 struct phy *phy; 117 struct phy *phy;
@@ -120,6 +122,7 @@ struct sun4i_usb_phy_data {
120 bool regulator_on; 122 bool regulator_on;
121 int index; 123 int index;
122 } phys[MAX_PHYS]; 124 } phys[MAX_PHYS];
125 int first_phy;
123 /* phy0 / otg related variables */ 126 /* phy0 / otg related variables */
124 struct extcon_dev *extcon; 127 struct extcon_dev *extcon;
125 bool phy0_init; 128 bool phy0_init;
@@ -285,16 +288,10 @@ static int sun4i_usb_phy_init(struct phy *_phy)
285 sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_DPDM_PULLUP_EN); 288 sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_DPDM_PULLUP_EN);
286 sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_ID_PULLUP_EN); 289 sun4i_usb_phy0_update_iscr(_phy, 0, ISCR_ID_PULLUP_EN);
287 290
288 if (data->id_det_gpio) { 291 /* Force ISCR and cable state updates */
289 /* OTG mode, force ISCR and cable state updates */ 292 data->id_det = -1;
290 data->id_det = -1; 293 data->vbus_det = -1;
291 data->vbus_det = -1; 294 queue_delayed_work(system_wq, &data->detect, 0);
292 queue_delayed_work(system_wq, &data->detect, 0);
293 } else {
294 /* Host only mode */
295 sun4i_usb_phy0_set_id_detect(_phy, 0);
296 sun4i_usb_phy0_set_vbus_detect(_phy, 1);
297 }
298 } 295 }
299 296
300 return 0; 297 return 0;
@@ -319,6 +316,19 @@ static int sun4i_usb_phy_exit(struct phy *_phy)
319 return 0; 316 return 0;
320} 317}
321 318
319static int sun4i_usb_phy0_get_id_det(struct sun4i_usb_phy_data *data)
320{
321 switch (data->dr_mode) {
322 case USB_DR_MODE_OTG:
323 return gpiod_get_value_cansleep(data->id_det_gpio);
324 case USB_DR_MODE_HOST:
325 return 0;
326 case USB_DR_MODE_PERIPHERAL:
327 default:
328 return 1;
329 }
330}
331
322static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data) 332static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data)
323{ 333{
324 if (data->vbus_det_gpio) 334 if (data->vbus_det_gpio)
@@ -432,7 +442,10 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
432 struct phy *phy0 = data->phys[0].phy; 442 struct phy *phy0 = data->phys[0].phy;
433 int id_det, vbus_det, id_notify = 0, vbus_notify = 0; 443 int id_det, vbus_det, id_notify = 0, vbus_notify = 0;
434 444
435 id_det = gpiod_get_value_cansleep(data->id_det_gpio); 445 if (phy0 == NULL)
446 return;
447
448 id_det = sun4i_usb_phy0_get_id_det(data);
436 vbus_det = sun4i_usb_phy0_get_vbus_det(data); 449 vbus_det = sun4i_usb_phy0_get_vbus_det(data);
437 450
438 mutex_lock(&phy0->mutex); 451 mutex_lock(&phy0->mutex);
@@ -448,7 +461,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
448 * without vbus detection report vbus low for long enough for 461 * without vbus detection report vbus low for long enough for
449 * the musb-ip to end the current device session. 462 * the musb-ip to end the current device session.
450 */ 463 */
451 if (!sun4i_usb_phy0_have_vbus_det(data) && id_det == 0) { 464 if (data->dr_mode == USB_DR_MODE_OTG &&
465 !sun4i_usb_phy0_have_vbus_det(data) && id_det == 0) {
452 sun4i_usb_phy0_set_vbus_detect(phy0, 0); 466 sun4i_usb_phy0_set_vbus_detect(phy0, 0);
453 msleep(200); 467 msleep(200);
454 sun4i_usb_phy0_set_vbus_detect(phy0, 1); 468 sun4i_usb_phy0_set_vbus_detect(phy0, 1);
@@ -474,7 +488,8 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
474 * without vbus detection report vbus low for long enough to 488 * without vbus detection report vbus low for long enough to
475 * the musb-ip to end the current host session. 489 * the musb-ip to end the current host session.
476 */ 490 */
477 if (!sun4i_usb_phy0_have_vbus_det(data) && id_det == 1) { 491 if (data->dr_mode == USB_DR_MODE_OTG &&
492 !sun4i_usb_phy0_have_vbus_det(data) && id_det == 1) {
478 mutex_lock(&phy0->mutex); 493 mutex_lock(&phy0->mutex);
479 sun4i_usb_phy0_set_vbus_detect(phy0, 0); 494 sun4i_usb_phy0_set_vbus_detect(phy0, 0);
480 msleep(1000); 495 msleep(1000);
@@ -519,7 +534,8 @@ static struct phy *sun4i_usb_phy_xlate(struct device *dev,
519{ 534{
520 struct sun4i_usb_phy_data *data = dev_get_drvdata(dev); 535 struct sun4i_usb_phy_data *data = dev_get_drvdata(dev);
521 536
522 if (args->args[0] >= data->cfg->num_phys) 537 if (args->args[0] < data->first_phy ||
538 args->args[0] >= data->cfg->num_phys)
523 return ERR_PTR(-ENODEV); 539 return ERR_PTR(-ENODEV);
524 540
525 return data->phys[args->args[0]].phy; 541 return data->phys[args->args[0]].phy;
@@ -593,13 +609,17 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
593 return -EPROBE_DEFER; 609 return -EPROBE_DEFER;
594 } 610 }
595 611
596 /* vbus_det without id_det makes no sense, and is not supported */ 612 data->dr_mode = of_usb_get_dr_mode_by_phy(np, 0);
597 if (sun4i_usb_phy0_have_vbus_det(data) && !data->id_det_gpio) { 613 switch (data->dr_mode) {
598 dev_err(dev, "usb0_id_det missing or invalid\n"); 614 case USB_DR_MODE_OTG:
599 return -ENODEV; 615 /* otg without id_det makes no sense, and is not supported */
600 } 616 if (!data->id_det_gpio) {
601 617 dev_err(dev, "usb0_id_det missing or invalid\n");
602 if (data->id_det_gpio) { 618 return -ENODEV;
619 }
620 /* fall through */
621 case USB_DR_MODE_HOST:
622 case USB_DR_MODE_PERIPHERAL:
603 data->extcon = devm_extcon_dev_allocate(dev, 623 data->extcon = devm_extcon_dev_allocate(dev,
604 sun4i_usb_phy0_cable); 624 sun4i_usb_phy0_cable);
605 if (IS_ERR(data->extcon)) 625 if (IS_ERR(data->extcon))
@@ -610,9 +630,13 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
610 dev_err(dev, "failed to register extcon: %d\n", ret); 630 dev_err(dev, "failed to register extcon: %d\n", ret);
611 return ret; 631 return ret;
612 } 632 }
633 break;
634 default:
635 dev_info(dev, "dr_mode unknown, not registering usb phy0\n");
636 data->first_phy = 1;
613 } 637 }
614 638
615 for (i = 0; i < data->cfg->num_phys; i++) { 639 for (i = data->first_phy; i < data->cfg->num_phys; i++) {
616 struct sun4i_usb_phy *phy = data->phys + i; 640 struct sun4i_usb_phy *phy = data->phys + i;
617 char name[16]; 641 char name[16];
618 642
diff --git a/drivers/phy/phy-sun9i-usb.c b/drivers/phy/phy-sun9i-usb.c
index ac4f31abefe3..28fce4bce638 100644
--- a/drivers/phy/phy-sun9i-usb.c
+++ b/drivers/phy/phy-sun9i-usb.c
@@ -141,9 +141,9 @@ static int sun9i_usb_phy_probe(struct platform_device *pdev)
141 } 141 }
142 142
143 phy->hsic_clk = devm_clk_get(dev, "hsic_12M"); 143 phy->hsic_clk = devm_clk_get(dev, "hsic_12M");
144 if (IS_ERR(phy->clk)) { 144 if (IS_ERR(phy->hsic_clk)) {
145 dev_err(dev, "failed to get hsic_12M clock\n"); 145 dev_err(dev, "failed to get hsic_12M clock\n");
146 return PTR_ERR(phy->clk); 146 return PTR_ERR(phy->hsic_clk);
147 } 147 }
148 148
149 phy->reset = devm_reset_control_get(dev, "hsic"); 149 phy->reset = devm_reset_control_get(dev, "hsic");
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 5749a4eee746..0fe8fad25e4d 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1539,12 +1539,11 @@ static int chv_gpio_probe(struct chv_pinctrl *pctrl, int irq)
1539 offset += range->npins; 1539 offset += range->npins;
1540 } 1540 }
1541 1541
1542 /* Mask and clear all interrupts */ 1542 /* Clear all interrupts */
1543 chv_writel(0, pctrl->regs + CHV_INTMASK);
1544 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT); 1543 chv_writel(0xffff, pctrl->regs + CHV_INTSTAT);
1545 1544
1546 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0, 1545 ret = gpiochip_irqchip_add(chip, &chv_gpio_irqchip, 0,
1547 handle_simple_irq, IRQ_TYPE_NONE); 1546 handle_bad_irq, IRQ_TYPE_NONE);
1548 if (ret) { 1547 if (ret) {
1549 dev_err(pctrl->dev, "failed to add IRQ chip\n"); 1548 dev_err(pctrl->dev, "failed to add IRQ chip\n");
1550 goto fail; 1549 goto fail;
diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 7bad200bd67c..55375b1b3cc8 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -809,17 +809,17 @@ static const struct pistachio_pin_group pistachio_groups[] = {
809 PADS_FUNCTION_SELECT2, 12, 0x3), 809 PADS_FUNCTION_SELECT2, 12, 0x3),
810 MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, 810 MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
811 PADS_FUNCTION_SELECT2, 14, 0x3), 811 PADS_FUNCTION_SELECT2, 14, 0x3),
812 MFIO_MUX_PIN_GROUP(84, SYS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG, 812 MFIO_MUX_PIN_GROUP(84, AUDIO_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
813 PADS_FUNCTION_SELECT2, 16, 0x3), 813 PADS_FUNCTION_SELECT2, 16, 0x3),
814 MFIO_MUX_PIN_GROUP(85, WIFI_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, 814 MFIO_MUX_PIN_GROUP(85, RPU_V_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
815 PADS_FUNCTION_SELECT2, 18, 0x3), 815 PADS_FUNCTION_SELECT2, 18, 0x3),
816 MFIO_MUX_PIN_GROUP(86, BT_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG, 816 MFIO_MUX_PIN_GROUP(86, RPU_L_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
817 PADS_FUNCTION_SELECT2, 20, 0x3), 817 PADS_FUNCTION_SELECT2, 20, 0x3),
818 MFIO_MUX_PIN_GROUP(87, RPU_V_PLL_LOCK, DREQ2, SOCIF_DEBUG, 818 MFIO_MUX_PIN_GROUP(87, SYS_PLL_LOCK, DREQ2, SOCIF_DEBUG,
819 PADS_FUNCTION_SELECT2, 22, 0x3), 819 PADS_FUNCTION_SELECT2, 22, 0x3),
820 MFIO_MUX_PIN_GROUP(88, RPU_L_PLL_LOCK, DREQ3, SOCIF_DEBUG, 820 MFIO_MUX_PIN_GROUP(88, WIFI_PLL_LOCK, DREQ3, SOCIF_DEBUG,
821 PADS_FUNCTION_SELECT2, 24, 0x3), 821 PADS_FUNCTION_SELECT2, 24, 0x3),
822 MFIO_MUX_PIN_GROUP(89, AUDIO_PLL_LOCK, DREQ4, DREQ5, 822 MFIO_MUX_PIN_GROUP(89, BT_PLL_LOCK, DREQ4, DREQ5,
823 PADS_FUNCTION_SELECT2, 26, 0x3), 823 PADS_FUNCTION_SELECT2, 26, 0x3),
824 PIN_GROUP(TCK, "tck"), 824 PIN_GROUP(TCK, "tck"),
825 PIN_GROUP(TRSTN, "trstn"), 825 PIN_GROUP(TRSTN, "trstn"),
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
index ce483b03a263..f9d661e5c14a 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
@@ -485,12 +485,12 @@ static const struct sunxi_desc_pin sun8i_a23_pins[] = {
485 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), 485 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
486 SUNXI_FUNCTION(0x0, "gpio_in"), 486 SUNXI_FUNCTION(0x0, "gpio_in"),
487 SUNXI_FUNCTION(0x1, "gpio_out"), 487 SUNXI_FUNCTION(0x1, "gpio_out"),
488 SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ 488 SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
489 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */ 489 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */
490 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), 490 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
491 SUNXI_FUNCTION(0x0, "gpio_in"), 491 SUNXI_FUNCTION(0x0, "gpio_in"),
492 SUNXI_FUNCTION(0x1, "gpio_out"), 492 SUNXI_FUNCTION(0x1, "gpio_out"),
493 SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ 493 SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
494 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */ 494 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */
495 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), 495 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
496 SUNXI_FUNCTION(0x0, "gpio_in"), 496 SUNXI_FUNCTION(0x0, "gpio_in"),
diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
index 3040abe6f73a..3131cac2b76f 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
@@ -407,12 +407,12 @@ static const struct sunxi_desc_pin sun8i_a33_pins[] = {
407 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8), 407 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
408 SUNXI_FUNCTION(0x0, "gpio_in"), 408 SUNXI_FUNCTION(0x0, "gpio_in"),
409 SUNXI_FUNCTION(0x1, "gpio_out"), 409 SUNXI_FUNCTION(0x1, "gpio_out"),
410 SUNXI_FUNCTION(0x2, "uart2"), /* RTS */ 410 SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
411 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */ 411 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */
412 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9), 412 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
413 SUNXI_FUNCTION(0x0, "gpio_in"), 413 SUNXI_FUNCTION(0x0, "gpio_in"),
414 SUNXI_FUNCTION(0x1, "gpio_out"), 414 SUNXI_FUNCTION(0x1, "gpio_out"),
415 SUNXI_FUNCTION(0x2, "uart2"), /* CTS */ 415 SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
416 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */ 416 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */
417 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10), 417 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
418 SUNXI_FUNCTION(0x0, "gpio_in"), 418 SUNXI_FUNCTION(0x0, "gpio_in"),
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index f99b183d5296..374a8028fec7 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * Generic driver for the OLPC Embedded Controller. 2 * Generic driver for the OLPC Embedded Controller.
3 * 3 *
4 * Author: Andres Salomon <dilinger@queued.net>
5 *
4 * Copyright (C) 2011-2012 One Laptop per Child Foundation. 6 * Copyright (C) 2011-2012 One Laptop per Child Foundation.
5 * 7 *
6 * Licensed under the GPL v2 or later. 8 * Licensed under the GPL v2 or later.
@@ -12,7 +14,7 @@
12#include <linux/platform_device.h> 14#include <linux/platform_device.h>
13#include <linux/slab.h> 15#include <linux/slab.h>
14#include <linux/workqueue.h> 16#include <linux/workqueue.h>
15#include <linux/module.h> 17#include <linux/init.h>
16#include <linux/list.h> 18#include <linux/list.h>
17#include <linux/olpc-ec.h> 19#include <linux/olpc-ec.h>
18#include <asm/olpc.h> 20#include <asm/olpc.h>
@@ -326,8 +328,4 @@ static int __init olpc_ec_init_module(void)
326{ 328{
327 return platform_driver_register(&olpc_ec_plat_driver); 329 return platform_driver_register(&olpc_ec_plat_driver);
328} 330}
329
330arch_initcall(olpc_ec_init_module); 331arch_initcall(olpc_ec_init_module);
331
332MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
333MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/intel_pmic_gpio.c b/drivers/platform/x86/intel_pmic_gpio.c
index 63b371d6ee55..91ae58510d92 100644
--- a/drivers/platform/x86/intel_pmic_gpio.c
+++ b/drivers/platform/x86/intel_pmic_gpio.c
@@ -1,6 +1,8 @@
1/* Moorestown PMIC GPIO (access through IPC) driver 1/* Moorestown PMIC GPIO (access through IPC) driver
2 * Copyright (c) 2008 - 2009, Intel Corporation. 2 * Copyright (c) 2008 - 2009, Intel Corporation.
3 * 3 *
4 * Author: Alek Du <alek.du@intel.com>
5 *
4 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
@@ -21,7 +23,6 @@
21 23
22#define pr_fmt(fmt) "%s: " fmt, __func__ 24#define pr_fmt(fmt) "%s: " fmt, __func__
23 25
24#include <linux/module.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
26#include <linux/interrupt.h> 27#include <linux/interrupt.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
@@ -322,9 +323,4 @@ static int __init platform_pmic_gpio_init(void)
322{ 323{
323 return platform_driver_register(&platform_pmic_gpio_driver); 324 return platform_driver_register(&platform_pmic_gpio_driver);
324} 325}
325
326subsys_initcall(platform_pmic_gpio_init); 326subsys_initcall(platform_pmic_gpio_init);
327
328MODULE_AUTHOR("Alek Du <alek.du@intel.com>");
329MODULE_DESCRIPTION("Intel Moorestown PMIC GPIO driver");
330MODULE_LICENSE("GPL v2");
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
index 32f0f014a067..9d19b9a62011 100644
--- a/drivers/rapidio/devices/tsi721.c
+++ b/drivers/rapidio/devices/tsi721.c
@@ -1161,7 +1161,7 @@ static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
1161 } else if (ibw_start < (ib_win->rstart + ib_win->size) && 1161 } else if (ibw_start < (ib_win->rstart + ib_win->size) &&
1162 (ibw_start + ibw_size) > ib_win->rstart) { 1162 (ibw_start + ibw_size) > ib_win->rstart) {
1163 /* Return error if address translation involved */ 1163 /* Return error if address translation involved */
1164 if (direct && ib_win->xlat) { 1164 if (!direct || ib_win->xlat) {
1165 ret = -EFAULT; 1165 ret = -EFAULT;
1166 break; 1166 break;
1167 } 1167 }
diff --git a/drivers/regulator/max14577-regulator.c b/drivers/regulator/max14577-regulator.c
index b2daa6641417..c9ff26199711 100644
--- a/drivers/regulator/max14577-regulator.c
+++ b/drivers/regulator/max14577-regulator.c
@@ -2,7 +2,7 @@
2 * max14577.c - Regulator driver for the Maxim 14577/77836 2 * max14577.c - Regulator driver for the Maxim 14577/77836
3 * 3 *
4 * Copyright (C) 2013,2014 Samsung Electronics 4 * Copyright (C) 2013,2014 Samsung Electronics
5 * Krzysztof Kozlowski <k.kozlowski@samsung.com> 5 * Krzysztof Kozlowski <krzk@kernel.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -331,7 +331,7 @@ static void __exit max14577_regulator_exit(void)
331} 331}
332module_exit(max14577_regulator_exit); 332module_exit(max14577_regulator_exit);
333 333
334MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); 334MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
335MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver"); 335MODULE_DESCRIPTION("Maxim 14577/77836 regulator driver");
336MODULE_LICENSE("GPL"); 336MODULE_LICENSE("GPL");
337MODULE_ALIAS("platform:max14577-regulator"); 337MODULE_ALIAS("platform:max14577-regulator");
diff --git a/drivers/regulator/max77693-regulator.c b/drivers/regulator/max77693-regulator.c
index de730fd3f8a5..cfbb9512e486 100644
--- a/drivers/regulator/max77693-regulator.c
+++ b/drivers/regulator/max77693-regulator.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2013-2015 Samsung Electronics 4 * Copyright (C) 2013-2015 Samsung Electronics
5 * Jonghwa Lee <jonghwa3.lee@samsung.com> 5 * Jonghwa Lee <jonghwa3.lee@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski.k@gmail.com> 6 * Krzysztof Kozlowski <krzk@kernel.org>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -314,5 +314,5 @@ module_exit(max77693_pmic_cleanup);
314 314
315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver"); 315MODULE_DESCRIPTION("MAXIM 77693/77843 regulator driver");
316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); 316MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
317MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski.k@gmail.com>"); 317MODULE_AUTHOR("Krzysztof Kozlowski <krzk@kernel.org>");
318MODULE_LICENSE("GPL"); 318MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 5022fa8d10c6..8ed46a9a55c8 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -178,20 +178,21 @@ static const struct regulator_desc pma8084_hfsmps = {
178static const struct regulator_desc pma8084_ftsmps = { 178static const struct regulator_desc pma8084_ftsmps = {
179 .linear_ranges = (struct regulator_linear_range[]) { 179 .linear_ranges = (struct regulator_linear_range[]) {
180 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), 180 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
181 REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), 181 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
182 }, 182 },
183 .n_linear_ranges = 2, 183 .n_linear_ranges = 2,
184 .n_voltages = 340, 184 .n_voltages = 262,
185 .ops = &rpm_smps_ldo_ops, 185 .ops = &rpm_smps_ldo_ops,
186}; 186};
187 187
188static const struct regulator_desc pma8084_pldo = { 188static const struct regulator_desc pma8084_pldo = {
189 .linear_ranges = (struct regulator_linear_range[]) { 189 .linear_ranges = (struct regulator_linear_range[]) {
190 REGULATOR_LINEAR_RANGE(750000, 0, 30, 25000), 190 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
191 REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), 191 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
192 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
192 }, 193 },
193 .n_linear_ranges = 2, 194 .n_linear_ranges = 3,
194 .n_voltages = 100, 195 .n_voltages = 164,
195 .ops = &rpm_smps_ldo_ops, 196 .ops = &rpm_smps_ldo_ops,
196}; 197};
197 198
@@ -221,29 +222,30 @@ static const struct regulator_desc pm8x41_hfsmps = {
221static const struct regulator_desc pm8841_ftsmps = { 222static const struct regulator_desc pm8841_ftsmps = {
222 .linear_ranges = (struct regulator_linear_range[]) { 223 .linear_ranges = (struct regulator_linear_range[]) {
223 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), 224 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
224 REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), 225 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
225 }, 226 },
226 .n_linear_ranges = 2, 227 .n_linear_ranges = 2,
227 .n_voltages = 340, 228 .n_voltages = 262,
228 .ops = &rpm_smps_ldo_ops, 229 .ops = &rpm_smps_ldo_ops,
229}; 230};
230 231
231static const struct regulator_desc pm8941_boost = { 232static const struct regulator_desc pm8941_boost = {
232 .linear_ranges = (struct regulator_linear_range[]) { 233 .linear_ranges = (struct regulator_linear_range[]) {
233 REGULATOR_LINEAR_RANGE(4000000, 0, 15, 100000), 234 REGULATOR_LINEAR_RANGE(4000000, 0, 30, 50000),
234 }, 235 },
235 .n_linear_ranges = 1, 236 .n_linear_ranges = 1,
236 .n_voltages = 16, 237 .n_voltages = 31,
237 .ops = &rpm_smps_ldo_ops, 238 .ops = &rpm_smps_ldo_ops,
238}; 239};
239 240
240static const struct regulator_desc pm8941_pldo = { 241static const struct regulator_desc pm8941_pldo = {
241 .linear_ranges = (struct regulator_linear_range[]) { 242 .linear_ranges = (struct regulator_linear_range[]) {
242 REGULATOR_LINEAR_RANGE( 750000, 0, 30, 25000), 243 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
243 REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), 244 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
245 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
244 }, 246 },
245 .n_linear_ranges = 2, 247 .n_linear_ranges = 3,
246 .n_voltages = 100, 248 .n_voltages = 164,
247 .ops = &rpm_smps_ldo_ops, 249 .ops = &rpm_smps_ldo_ops,
248}; 250};
249 251
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index e3da1a2fdb66..2a9da2e0ea6b 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -962,7 +962,7 @@ static void wd719x_pci_remove(struct pci_dev *pdev)
962 scsi_host_put(sh); 962 scsi_host_put(sh);
963} 963}
964 964
965static DEFINE_PCI_DEVICE_TABLE(wd719x_pci_table) = { 965static const struct pci_device_id wd719x_pci_table[] = {
966 { PCI_DEVICE(PCI_VENDOR_ID_WD, 0x3296) }, 966 { PCI_DEVICE(PCI_VENDOR_ID_WD, 0x3296) },
967 {} 967 {}
968}; 968};
diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
index 823cbc92d1e7..7a37090dabbe 100644
--- a/drivers/spi/spi-img-spfi.c
+++ b/drivers/spi/spi-img-spfi.c
@@ -720,8 +720,6 @@ static int img_spfi_remove(struct platform_device *pdev)
720 clk_disable_unprepare(spfi->sys_clk); 720 clk_disable_unprepare(spfi->sys_clk);
721 } 721 }
722 722
723 spi_master_put(master);
724
725 return 0; 723 return 0;
726} 724}
727 725
diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
index 0be89e052428..899d7a8f0889 100644
--- a/drivers/spi/spi-mt65xx.c
+++ b/drivers/spi/spi-mt65xx.c
@@ -685,7 +685,6 @@ static int mtk_spi_remove(struct platform_device *pdev)
685 pm_runtime_disable(&pdev->dev); 685 pm_runtime_disable(&pdev->dev);
686 686
687 mtk_spi_reset(mdata); 687 mtk_spi_reset(mdata);
688 spi_master_put(master);
689 688
690 return 0; 689 return 0;
691} 690}
diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index f3df522db93b..58d2d48e16a5 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -214,6 +214,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
214 return PTR_ERR(ssp->clk); 214 return PTR_ERR(ssp->clk);
215 215
216 memset(&pi, 0, sizeof(pi)); 216 memset(&pi, 0, sizeof(pi));
217 pi.fwnode = dev->dev.fwnode;
217 pi.parent = &dev->dev; 218 pi.parent = &dev->dev;
218 pi.name = "pxa2xx-spi"; 219 pi.name = "pxa2xx-spi";
219 pi.id = ssp->port_id; 220 pi.id = ssp->port_id;
diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index c338ef1136f6..7f1555621f8e 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -1030,7 +1030,6 @@ static int spi_qup_remove(struct platform_device *pdev)
1030 1030
1031 pm_runtime_put_noidle(&pdev->dev); 1031 pm_runtime_put_noidle(&pdev->dev);
1032 pm_runtime_disable(&pdev->dev); 1032 pm_runtime_disable(&pdev->dev);
1033 spi_master_put(master);
1034 1033
1035 return 0; 1034 return 0;
1036} 1035}
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0f83ad1d5a58..1de3a772eb7d 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -262,6 +262,9 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
262 262
263 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) { 263 for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {
264 brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div); 264 brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);
265 /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */
266 if (sh_msiof_spi_div_table[k].div == 1 && brps > 2)
267 continue;
265 if (brps <= 32) /* max of brdv is 32 */ 268 if (brps <= 32) /* max of brdv is 32 */
266 break; 269 break;
267 } 270 }
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 51ad42fad567..200ca228d885 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -960,7 +960,7 @@ static int spi_transfer_one_message(struct spi_master *master,
960 struct spi_transfer *xfer; 960 struct spi_transfer *xfer;
961 bool keep_cs = false; 961 bool keep_cs = false;
962 int ret = 0; 962 int ret = 0;
963 unsigned long ms = 1; 963 unsigned long long ms = 1;
964 struct spi_statistics *statm = &master->statistics; 964 struct spi_statistics *statm = &master->statistics;
965 struct spi_statistics *stats = &msg->spi->statistics; 965 struct spi_statistics *stats = &msg->spi->statistics;
966 966
@@ -991,9 +991,13 @@ static int spi_transfer_one_message(struct spi_master *master,
991 991
992 if (ret > 0) { 992 if (ret > 0) {
993 ret = 0; 993 ret = 0;
994 ms = xfer->len * 8 * 1000 / xfer->speed_hz; 994 ms = 8LL * 1000LL * xfer->len;
995 do_div(ms, xfer->speed_hz);
995 ms += ms + 100; /* some tolerance */ 996 ms += ms + 100; /* some tolerance */
996 997
998 if (ms > UINT_MAX)
999 ms = UINT_MAX;
1000
997 ms = wait_for_completion_timeout(&master->xfer_completion, 1001 ms = wait_for_completion_timeout(&master->xfer_completion,
998 msecs_to_jiffies(ms)); 1002 msecs_to_jiffies(ms));
999 } 1003 }
@@ -1159,6 +1163,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
1159 if (ret < 0) { 1163 if (ret < 0) {
1160 dev_err(&master->dev, "Failed to power device: %d\n", 1164 dev_err(&master->dev, "Failed to power device: %d\n",
1161 ret); 1165 ret);
1166 mutex_unlock(&master->io_mutex);
1162 return; 1167 return;
1163 } 1168 }
1164 } 1169 }
@@ -1174,6 +1179,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread)
1174 1179
1175 if (master->auto_runtime_pm) 1180 if (master->auto_runtime_pm)
1176 pm_runtime_put(master->dev.parent); 1181 pm_runtime_put(master->dev.parent);
1182 mutex_unlock(&master->io_mutex);
1177 return; 1183 return;
1178 } 1184 }
1179 } 1185 }
diff --git a/drivers/staging/comedi/drivers/adv_pci1760.c b/drivers/staging/comedi/drivers/adv_pci1760.c
index d7dd1e55e347..9f525ff7290c 100644
--- a/drivers/staging/comedi/drivers/adv_pci1760.c
+++ b/drivers/staging/comedi/drivers/adv_pci1760.c
@@ -196,6 +196,7 @@ static int pci1760_pwm_ns_to_div(unsigned int flags, unsigned int ns)
196 break; 196 break;
197 case CMDF_ROUND_DOWN: 197 case CMDF_ROUND_DOWN:
198 divisor = ns / PCI1760_PWM_TIMEBASE; 198 divisor = ns / PCI1760_PWM_TIMEBASE;
199 break;
199 default: 200 default:
200 return -EINVAL; 201 return -EINVAL;
201 } 202 }
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 4ab186669f0c..ec5b9a23494d 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -56,11 +56,6 @@
56 56
57#define N_CHANS 8 57#define N_CHANS 8
58 58
59enum waveform_state_bits {
60 WAVEFORM_AI_RUNNING,
61 WAVEFORM_AO_RUNNING
62};
63
64/* Data unique to this driver */ 59/* Data unique to this driver */
65struct waveform_private { 60struct waveform_private {
66 struct timer_list ai_timer; /* timer for AI commands */ 61 struct timer_list ai_timer; /* timer for AI commands */
@@ -68,7 +63,6 @@ struct waveform_private {
68 unsigned int wf_amplitude; /* waveform amplitude in microvolts */ 63 unsigned int wf_amplitude; /* waveform amplitude in microvolts */
69 unsigned int wf_period; /* waveform period in microseconds */ 64 unsigned int wf_period; /* waveform period in microseconds */
70 unsigned int wf_current; /* current time in waveform period */ 65 unsigned int wf_current; /* current time in waveform period */
71 unsigned long state_bits;
72 unsigned int ai_scan_period; /* AI scan period in usec */ 66 unsigned int ai_scan_period; /* AI scan period in usec */
73 unsigned int ai_convert_period; /* AI conversion period in usec */ 67 unsigned int ai_convert_period; /* AI conversion period in usec */
74 struct timer_list ao_timer; /* timer for AO commands */ 68 struct timer_list ao_timer; /* timer for AO commands */
@@ -191,10 +185,6 @@ static void waveform_ai_timer(unsigned long arg)
191 unsigned int nsamples; 185 unsigned int nsamples;
192 unsigned int time_increment; 186 unsigned int time_increment;
193 187
194 /* check command is still active */
195 if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
196 return;
197
198 now = ktime_to_us(ktime_get()); 188 now = ktime_to_us(ktime_get());
199 nsamples = comedi_nsamples_left(s, UINT_MAX); 189 nsamples = comedi_nsamples_left(s, UINT_MAX);
200 190
@@ -386,11 +376,6 @@ static int waveform_ai_cmd(struct comedi_device *dev,
386 */ 376 */
387 devpriv->ai_timer.expires = 377 devpriv->ai_timer.expires =
388 jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1; 378 jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1;
389
390 /* mark command as active */
391 smp_mb__before_atomic();
392 set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
393 smp_mb__after_atomic();
394 add_timer(&devpriv->ai_timer); 379 add_timer(&devpriv->ai_timer);
395 return 0; 380 return 0;
396} 381}
@@ -400,11 +385,12 @@ static int waveform_ai_cancel(struct comedi_device *dev,
400{ 385{
401 struct waveform_private *devpriv = dev->private; 386 struct waveform_private *devpriv = dev->private;
402 387
403 /* mark command as no longer active */ 388 if (in_softirq()) {
404 clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits); 389 /* Assume we were called from the timer routine itself. */
405 smp_mb__after_atomic(); 390 del_timer(&devpriv->ai_timer);
406 /* cannot call del_timer_sync() as may be called from timer routine */ 391 } else {
407 del_timer(&devpriv->ai_timer); 392 del_timer_sync(&devpriv->ai_timer);
393 }
408 return 0; 394 return 0;
409} 395}
410 396
@@ -436,10 +422,6 @@ static void waveform_ao_timer(unsigned long arg)
436 u64 scans_since; 422 u64 scans_since;
437 unsigned int scans_avail = 0; 423 unsigned int scans_avail = 0;
438 424
439 /* check command is still active */
440 if (!test_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits))
441 return;
442
443 /* determine number of scan periods since last time */ 425 /* determine number of scan periods since last time */
444 now = ktime_to_us(ktime_get()); 426 now = ktime_to_us(ktime_get());
445 scans_since = now - devpriv->ao_last_scan_time; 427 scans_since = now - devpriv->ao_last_scan_time;
@@ -518,11 +500,6 @@ static int waveform_ao_inttrig_start(struct comedi_device *dev,
518 devpriv->ao_last_scan_time = ktime_to_us(ktime_get()); 500 devpriv->ao_last_scan_time = ktime_to_us(ktime_get());
519 devpriv->ao_timer.expires = 501 devpriv->ao_timer.expires =
520 jiffies + usecs_to_jiffies(devpriv->ao_scan_period); 502 jiffies + usecs_to_jiffies(devpriv->ao_scan_period);
521
522 /* mark command as active */
523 smp_mb__before_atomic();
524 set_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits);
525 smp_mb__after_atomic();
526 add_timer(&devpriv->ao_timer); 503 add_timer(&devpriv->ao_timer);
527 504
528 return 1; 505 return 1;
@@ -608,11 +585,12 @@ static int waveform_ao_cancel(struct comedi_device *dev,
608 struct waveform_private *devpriv = dev->private; 585 struct waveform_private *devpriv = dev->private;
609 586
610 s->async->inttrig = NULL; 587 s->async->inttrig = NULL;
611 /* mark command as no longer active */ 588 if (in_softirq()) {
612 clear_bit(WAVEFORM_AO_RUNNING, &devpriv->state_bits); 589 /* Assume we were called from the timer routine itself. */
613 smp_mb__after_atomic(); 590 del_timer(&devpriv->ao_timer);
614 /* cannot call del_timer_sync() as may be called from timer routine */ 591 } else {
615 del_timer(&devpriv->ao_timer); 592 del_timer_sync(&devpriv->ao_timer);
593 }
616 return 0; 594 return 0;
617} 595}
618 596
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index 65daef0c00d5..0f4eb954aa80 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -634,7 +634,7 @@ static const void *daqboard2000_find_boardinfo(struct comedi_device *dev,
634 const struct daq200_boardtype *board; 634 const struct daq200_boardtype *board;
635 int i; 635 int i;
636 636
637 if (pcidev->subsystem_device != PCI_VENDOR_ID_IOTECH) 637 if (pcidev->subsystem_vendor != PCI_VENDOR_ID_IOTECH)
638 return NULL; 638 return NULL;
639 639
640 for (i = 0; i < ARRAY_SIZE(boardtypes); i++) { 640 for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index 904f637797b6..8bbd93814340 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -588,8 +588,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
588 s = &dev->subdevices[0]; 588 s = &dev->subdevices[0];
589 s->type = COMEDI_SUBD_AI; 589 s->type = COMEDI_SUBD_AI;
590 s->subdev_flags = SDF_READABLE | 590 s->subdev_flags = SDF_READABLE |
591 (it->options[2] == 1) ? SDF_DIFF : 591 ((it->options[2] == 1) ? SDF_DIFF :
592 (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND; 592 (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND);
593 s->n_chan = (it->options[2] == 1) ? 8 : 16; 593 s->n_chan = (it->options[2] == 1) ? 8 : 16;
594 s->maxdata = 0x0fff; 594 s->maxdata = 0x0fff;
595 s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges 595 s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index 8dabb19519a5..0f97d7b611d7 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -2772,7 +2772,15 @@ static int ni_ao_inttrig(struct comedi_device *dev,
2772 int i; 2772 int i;
2773 static const int timeout = 1000; 2773 static const int timeout = 1000;
2774 2774
2775 if (trig_num != cmd->start_arg) 2775 /*
2776 * Require trig_num == cmd->start_arg when cmd->start_src == TRIG_INT.
2777 * For backwards compatibility, also allow trig_num == 0 when
2778 * cmd->start_src != TRIG_INT (i.e. when cmd->start_src == TRIG_EXT);
2779 * in that case, the internal trigger is being used as a pre-trigger
2780 * before the external trigger.
2781 */
2782 if (!(trig_num == cmd->start_arg ||
2783 (trig_num == 0 && cmd->start_src != TRIG_INT)))
2776 return -EINVAL; 2784 return -EINVAL;
2777 2785
2778 /* 2786 /*
@@ -5480,7 +5488,7 @@ static int ni_E_init(struct comedi_device *dev,
5480 s->maxdata = (devpriv->is_m_series) ? 0xffffffff 5488 s->maxdata = (devpriv->is_m_series) ? 0xffffffff
5481 : 0x00ffffff; 5489 : 0x00ffffff;
5482 s->insn_read = ni_tio_insn_read; 5490 s->insn_read = ni_tio_insn_read;
5483 s->insn_write = ni_tio_insn_read; 5491 s->insn_write = ni_tio_insn_write;
5484 s->insn_config = ni_tio_insn_config; 5492 s->insn_config = ni_tio_insn_config;
5485#ifdef PCIDMA 5493#ifdef PCIDMA
5486 if (dev->irq && devpriv->mite) { 5494 if (dev->irq && devpriv->mite) {
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 170ac980abcb..24c348d2f5bb 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -419,6 +419,7 @@ static ssize_t ad5933_store(struct device *dev,
419 mutex_lock(&indio_dev->mlock); 419 mutex_lock(&indio_dev->mlock);
420 switch ((u32)this_attr->address) { 420 switch ((u32)this_attr->address) {
421 case AD5933_OUT_RANGE: 421 case AD5933_OUT_RANGE:
422 ret = -EINVAL;
422 for (i = 0; i < 4; i++) 423 for (i = 0; i < 4; i++)
423 if (val == st->range_avail[i]) { 424 if (val == st->range_avail[i]) {
424 st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3); 425 st->ctrl_hb &= ~AD5933_CTRL_RANGE(0x3);
@@ -426,7 +427,6 @@ static ssize_t ad5933_store(struct device *dev,
426 ret = ad5933_cmd(st, 0); 427 ret = ad5933_cmd(st, 0);
427 break; 428 break;
428 } 429 }
429 ret = -EINVAL;
430 break; 430 break;
431 case AD5933_IN_PGA_GAIN: 431 case AD5933_IN_PGA_GAIN:
432 if (sysfs_streq(buf, "1")) { 432 if (sysfs_streq(buf, "1")) {
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 3664bfd0178b..2c4dc69731e8 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -388,6 +388,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
388 struct inode *inode = NULL; 388 struct inode *inode = NULL;
389 __u64 bits = 0; 389 __u64 bits = 0;
390 int rc = 0; 390 int rc = 0;
391 struct dentry *alias;
391 392
392 /* NB 1 request reference will be taken away by ll_intent_lock() 393 /* NB 1 request reference will be taken away by ll_intent_lock()
393 * when I return 394 * when I return
@@ -412,26 +413,12 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
412 */ 413 */
413 } 414 }
414 415
415 /* Only hash *de if it is unhashed (new dentry). 416 alias = ll_splice_alias(inode, *de);
416 * Atoimc_open may passing hashed dentries for open. 417 if (IS_ERR(alias)) {
417 */ 418 rc = PTR_ERR(alias);
418 if (d_unhashed(*de)) { 419 goto out;
419 struct dentry *alias;
420
421 alias = ll_splice_alias(inode, *de);
422 if (IS_ERR(alias)) {
423 rc = PTR_ERR(alias);
424 goto out;
425 }
426 *de = alias;
427 } else if (!it_disposition(it, DISP_LOOKUP_NEG) &&
428 !it_disposition(it, DISP_OPEN_CREATE)) {
429 /* With DISP_OPEN_CREATE dentry will be
430 * instantiated in ll_create_it.
431 */
432 LASSERT(!d_inode(*de));
433 d_instantiate(*de, inode);
434 } 420 }
421 *de = alias;
435 422
436 if (!it_disposition(it, DISP_LOOKUP_NEG)) { 423 if (!it_disposition(it, DISP_LOOKUP_NEG)) {
437 /* we have lookup look - unhide dentry */ 424 /* we have lookup look - unhide dentry */
@@ -587,6 +574,24 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
587 dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode, 574 dentry, PFID(ll_inode2fid(dir)), dir, file, open_flags, mode,
588 *opened); 575 *opened);
589 576
577 /* Only negative dentries enter here */
578 LASSERT(!d_inode(dentry));
579
580 if (!d_in_lookup(dentry)) {
581 /* A valid negative dentry that just passed revalidation,
582 * there's little point to try and open it server-side,
583 * even though there's a minuscle chance it might succeed.
584 * Either way it's a valid race to just return -ENOENT here.
585 */
586 if (!(open_flags & O_CREAT))
587 return -ENOENT;
588
589 /* Otherwise we just unhash it to be rehashed afresh via
590 * lookup if necessary
591 */
592 d_drop(dentry);
593 }
594
590 it = kzalloc(sizeof(*it), GFP_NOFS); 595 it = kzalloc(sizeof(*it), GFP_NOFS);
591 if (!it) 596 if (!it)
592 return -ENOMEM; 597 return -ENOMEM;
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 0b1760cba6e3..78f524fcd214 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3363,7 +3363,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3363 if (!hif_workqueue) { 3363 if (!hif_workqueue) {
3364 netdev_err(vif->ndev, "Failed to create workqueue\n"); 3364 netdev_err(vif->ndev, "Failed to create workqueue\n");
3365 result = -ENOMEM; 3365 result = -ENOMEM;
3366 goto _fail_mq_; 3366 goto _fail_;
3367 } 3367 }
3368 3368
3369 setup_timer(&periodic_rssi, GetPeriodicRSSI, 3369 setup_timer(&periodic_rssi, GetPeriodicRSSI,
@@ -3391,7 +3391,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
3391 3391
3392 clients_count++; 3392 clients_count++;
3393 3393
3394_fail_mq_:
3395 destroy_workqueue(hif_workqueue); 3394 destroy_workqueue(hif_workqueue);
3396_fail_: 3395_fail_:
3397 return result; 3396 return result;
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 3a66255f14fc..32215110d597 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -648,7 +648,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
648 mutex_unlock(&wl->hif_cs); 648 mutex_unlock(&wl->hif_cs);
649 } 649 }
650 if (&wl->txq_event) 650 if (&wl->txq_event)
651 wait_for_completion(&wl->txq_event); 651 complete(&wl->txq_event);
652 652
653 wlan_deinitialize_threads(dev); 653 wlan_deinitialize_threads(dev);
654 deinit_irq(dev); 654 deinit_irq(dev);
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 9092600a1794..2c2e8aca8305 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1191,7 +1191,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
1191 struct wilc_priv *priv; 1191 struct wilc_priv *priv;
1192 struct wilc_vif *vif; 1192 struct wilc_vif *vif;
1193 u32 i = 0; 1193 u32 i = 0;
1194 u32 associatedsta = 0; 1194 u32 associatedsta = ~0;
1195 u32 inactive_time = 0; 1195 u32 inactive_time = 0;
1196 priv = wiphy_priv(wiphy); 1196 priv = wiphy_priv(wiphy);
1197 vif = netdev_priv(dev); 1197 vif = netdev_priv(dev);
@@ -1204,7 +1204,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
1204 } 1204 }
1205 } 1205 }
1206 1206
1207 if (associatedsta == -1) { 1207 if (associatedsta == ~0) {
1208 netdev_err(dev, "sta required is not associated\n"); 1208 netdev_err(dev, "sta required is not associated\n");
1209 return -ENOENT; 1209 return -ENOENT;
1210 } 1210 }
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 9c15344b657a..a8c20413dbda 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -651,6 +651,12 @@ static struct pci_device_id nhi_ids[] = {
651 { 651 {
652 .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0, 652 .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0,
653 .vendor = PCI_VENDOR_ID_INTEL, 653 .vendor = PCI_VENDOR_ID_INTEL,
654 .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI,
655 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
656 },
657 {
658 .class = PCI_CLASS_SYSTEM_OTHER << 8, .class_mask = ~0,
659 .vendor = PCI_VENDOR_ID_INTEL,
654 .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI, 660 .device = PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI,
655 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 661 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID,
656 }, 662 },
diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index 1e116f53d6dd..9840fdecb73b 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -372,7 +372,9 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, u64 route)
372 372
373 if (sw->config.device_id != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE && 373 if (sw->config.device_id != PCI_DEVICE_ID_INTEL_LIGHT_RIDGE &&
374 sw->config.device_id != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C && 374 sw->config.device_id != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C &&
375 sw->config.device_id != PCI_DEVICE_ID_INTEL_PORT_RIDGE) 375 sw->config.device_id != PCI_DEVICE_ID_INTEL_PORT_RIDGE &&
376 sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE &&
377 sw->config.device_id != PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE)
376 tb_sw_warn(sw, "unsupported switch device id %#x\n", 378 tb_sw_warn(sw, "unsupported switch device id %#x\n",
377 sw->config.device_id); 379 sw->config.device_id);
378 380
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 122e0e4029fe..1a16feac9a36 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -15,8 +15,6 @@
15#include <linux/serial_reg.h> 15#include <linux/serial_reg.h>
16#include <linux/dmaengine.h> 16#include <linux/dmaengine.h>
17 17
18#include "../serial_mctrl_gpio.h"
19
20struct uart_8250_dma { 18struct uart_8250_dma {
21 int (*tx_dma)(struct uart_8250_port *p); 19 int (*tx_dma)(struct uart_8250_port *p);
22 int (*rx_dma)(struct uart_8250_port *p); 20 int (*rx_dma)(struct uart_8250_port *p);
@@ -133,43 +131,12 @@ void serial8250_em485_destroy(struct uart_8250_port *p);
133 131
134static inline void serial8250_out_MCR(struct uart_8250_port *up, int value) 132static inline void serial8250_out_MCR(struct uart_8250_port *up, int value)
135{ 133{
136 int mctrl_gpio = 0;
137
138 serial_out(up, UART_MCR, value); 134 serial_out(up, UART_MCR, value);
139
140 if (value & UART_MCR_RTS)
141 mctrl_gpio |= TIOCM_RTS;
142 if (value & UART_MCR_DTR)
143 mctrl_gpio |= TIOCM_DTR;
144
145 mctrl_gpio_set(up->gpios, mctrl_gpio);
146} 135}
147 136
148static inline int serial8250_in_MCR(struct uart_8250_port *up) 137static inline int serial8250_in_MCR(struct uart_8250_port *up)
149{ 138{
150 int mctrl, mctrl_gpio = 0; 139 return serial_in(up, UART_MCR);
151
152 mctrl = serial_in(up, UART_MCR);
153
154 /* save current MCR values */
155 if (mctrl & UART_MCR_RTS)
156 mctrl_gpio |= TIOCM_RTS;
157 if (mctrl & UART_MCR_DTR)
158 mctrl_gpio |= TIOCM_DTR;
159
160 mctrl_gpio = mctrl_gpio_get_outputs(up->gpios, &mctrl_gpio);
161
162 if (mctrl_gpio & TIOCM_RTS)
163 mctrl |= UART_MCR_RTS;
164 else
165 mctrl &= ~UART_MCR_RTS;
166
167 if (mctrl_gpio & TIOCM_DTR)
168 mctrl |= UART_MCR_DTR;
169 else
170 mctrl &= ~UART_MCR_DTR;
171
172 return mctrl;
173} 140}
174 141
175#if defined(__alpha__) && !defined(CONFIG_PCI) 142#if defined(__alpha__) && !defined(CONFIG_PCI)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 13ad5c3d2e68..dcf43f66404f 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -974,8 +974,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
974 974
975 uart = serial8250_find_match_or_unused(&up->port); 975 uart = serial8250_find_match_or_unused(&up->port);
976 if (uart && uart->port.type != PORT_8250_CIR) { 976 if (uart && uart->port.type != PORT_8250_CIR) {
977 struct mctrl_gpios *gpios;
978
979 if (uart->port.dev) 977 if (uart->port.dev)
980 uart_remove_one_port(&serial8250_reg, &uart->port); 978 uart_remove_one_port(&serial8250_reg, &uart->port);
981 979
@@ -1013,13 +1011,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up)
1013 if (up->port.flags & UPF_FIXED_TYPE) 1011 if (up->port.flags & UPF_FIXED_TYPE)
1014 uart->port.type = up->port.type; 1012 uart->port.type = up->port.type;
1015 1013
1016 gpios = mctrl_gpio_init(&uart->port, 0);
1017 if (IS_ERR(gpios)) {
1018 if (PTR_ERR(gpios) != -ENOSYS)
1019 return PTR_ERR(gpios);
1020 } else
1021 uart->gpios = gpios;
1022
1023 serial8250_set_defaults(uart); 1014 serial8250_set_defaults(uart);
1024 1015
1025 /* Possibly override default I/O functions. */ 1016 /* Possibly override default I/O functions. */
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 737b4b3957b0..0facc789fe7d 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -31,7 +31,7 @@
31#define IO_ADDR2 0x60 31#define IO_ADDR2 0x60
32#define LDN 0x7 32#define LDN 0x7
33 33
34#define IRQ_MODE 0x70 34#define FINTEK_IRQ_MODE 0x70
35#define IRQ_SHARE BIT(4) 35#define IRQ_SHARE BIT(4)
36#define IRQ_MODE_MASK (BIT(6) | BIT(5)) 36#define IRQ_MODE_MASK (BIT(6) | BIT(5))
37#define IRQ_LEVEL_LOW 0 37#define IRQ_LEVEL_LOW 0
@@ -195,7 +195,7 @@ static int fintek_8250_set_irq_mode(struct fintek_8250 *pdata, bool level_mode)
195 outb(LDN, pdata->base_port + ADDR_PORT); 195 outb(LDN, pdata->base_port + ADDR_PORT);
196 outb(pdata->index, pdata->base_port + DATA_PORT); 196 outb(pdata->index, pdata->base_port + DATA_PORT);
197 197
198 outb(IRQ_MODE, pdata->base_port + ADDR_PORT); 198 outb(FINTEK_IRQ_MODE, pdata->base_port + ADDR_PORT);
199 tmp = inb(pdata->base_port + DATA_PORT); 199 tmp = inb(pdata->base_port + DATA_PORT);
200 200
201 tmp &= ~IRQ_MODE_MASK; 201 tmp &= ~IRQ_MODE_MASK;
diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
index 339de9cd0866..20c5db2f4264 100644
--- a/drivers/tty/serial/8250/8250_mid.c
+++ b/drivers/tty/serial/8250/8250_mid.c
@@ -168,6 +168,9 @@ static void mid8250_set_termios(struct uart_port *p,
168 unsigned long w = BIT(24) - 1; 168 unsigned long w = BIT(24) - 1;
169 unsigned long mul, div; 169 unsigned long mul, div;
170 170
171 /* Gracefully handle the B0 case: fall back to B9600 */
172 fuart = fuart ? fuart : 9600 * 16;
173
171 if (mid->board->freq < fuart) { 174 if (mid->board->freq < fuart) {
172 /* Find prescaler value that satisfies Fuart < Fref */ 175 /* Find prescaler value that satisfies Fuart < Fref */
173 if (mid->board->freq > baud) 176 if (mid->board->freq > baud)
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index e14982f36a04..61ad6c3b20a0 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -134,21 +134,18 @@ static void omap8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
134 134
135 serial8250_do_set_mctrl(port, mctrl); 135 serial8250_do_set_mctrl(port, mctrl);
136 136
137 if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(up->gpios, 137 /*
138 UART_GPIO_RTS))) { 138 * Turn off autoRTS if RTS is lowered and restore autoRTS setting
139 /* 139 * if RTS is raised
140 * Turn off autoRTS if RTS is lowered and restore autoRTS 140 */
141 * setting if RTS is raised 141 lcr = serial_in(up, UART_LCR);
142 */ 142 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
143 lcr = serial_in(up, UART_LCR); 143 if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS))
144 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 144 priv->efr |= UART_EFR_RTS;
145 if ((mctrl & TIOCM_RTS) && (port->status & UPSTAT_AUTORTS)) 145 else
146 priv->efr |= UART_EFR_RTS; 146 priv->efr &= ~UART_EFR_RTS;
147 else 147 serial_out(up, UART_EFR, priv->efr);
148 priv->efr &= ~UART_EFR_RTS; 148 serial_out(up, UART_LCR, lcr);
149 serial_out(up, UART_EFR, priv->efr);
150 serial_out(up, UART_LCR, lcr);
151 }
152} 149}
153 150
154/* 151/*
@@ -449,9 +446,7 @@ static void omap_8250_set_termios(struct uart_port *port,
449 priv->efr = 0; 446 priv->efr = 0;
450 up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF); 447 up->port.status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF);
451 448
452 if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW 449 if (termios->c_cflag & CRTSCTS && up->port.flags & UPF_HARD_FLOW) {
453 && IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(up->gpios,
454 UART_GPIO_RTS))) {
455 /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */ 450 /* Enable AUTOCTS (autoRTS is enabled when RTS is raised) */
456 up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; 451 up->port.status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
457 priv->efr |= UART_EFR_CTS; 452 priv->efr |= UART_EFR_CTS;
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 20ebaea5c414..bc51b32b2774 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -1950,6 +1950,43 @@ pci_wch_ch38x_setup(struct serial_private *priv,
1950#define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954 1950#define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954
1951#define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958 1951#define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958
1952 1952
1953#define PCI_VENDOR_ID_ACCESIO 0x494f
1954#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB 0x1051
1955#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S 0x1053
1956#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB 0x105C
1957#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S 0x105E
1958#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB 0x1091
1959#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2 0x1093
1960#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB 0x1099
1961#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4 0x109B
1962#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB 0x10D1
1963#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM 0x10D3
1964#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB 0x10DA
1965#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM 0x10DC
1966#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1 0x1108
1967#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2 0x1110
1968#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2 0x1111
1969#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4 0x1118
1970#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4 0x1119
1971#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S 0x1152
1972#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S 0x115A
1973#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2 0x1190
1974#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2 0x1191
1975#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4 0x1198
1976#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4 0x1199
1977#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM 0x11D0
1978#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4 0x105A
1979#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4 0x105B
1980#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8 0x106A
1981#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8 0x106B
1982#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4 0x1098
1983#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8 0x10A9
1984#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM 0x10D9
1985#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM 0x10E9
1986#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM 0x11D8
1987
1988
1989
1953/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ 1990/* Unknown vendors/cards - this should not be in linux/pci_ids.h */
1954#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 1991#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
1955#define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588 1992#define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588
@@ -5113,6 +5150,108 @@ static struct pci_device_id serial_pci_tbl[] = {
5113 0, 5150 0,
5114 0, pbn_pericom_PI7C9X7958 }, 5151 0, pbn_pericom_PI7C9X7958 },
5115 /* 5152 /*
5153 * ACCES I/O Products quad
5154 */
5155 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB,
5156 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5157 pbn_pericom_PI7C9X7954 },
5158 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S,
5159 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5160 pbn_pericom_PI7C9X7954 },
5161 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB,
5162 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5163 pbn_pericom_PI7C9X7954 },
5164 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S,
5165 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5166 pbn_pericom_PI7C9X7954 },
5167 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB,
5168 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5169 pbn_pericom_PI7C9X7954 },
5170 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2,
5171 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5172 pbn_pericom_PI7C9X7954 },
5173 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB,
5174 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5175 pbn_pericom_PI7C9X7954 },
5176 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4,
5177 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5178 pbn_pericom_PI7C9X7954 },
5179 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB,
5180 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5181 pbn_pericom_PI7C9X7954 },
5182 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM,
5183 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5184 pbn_pericom_PI7C9X7954 },
5185 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB,
5186 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5187 pbn_pericom_PI7C9X7954 },
5188 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM,
5189 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5190 pbn_pericom_PI7C9X7954 },
5191 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1,
5192 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5193 pbn_pericom_PI7C9X7954 },
5194 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2,
5195 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5196 pbn_pericom_PI7C9X7954 },
5197 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2,
5198 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5199 pbn_pericom_PI7C9X7954 },
5200 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4,
5201 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5202 pbn_pericom_PI7C9X7954 },
5203 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4,
5204 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5205 pbn_pericom_PI7C9X7954 },
5206 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S,
5207 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5208 pbn_pericom_PI7C9X7954 },
5209 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
5210 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5211 pbn_pericom_PI7C9X7954 },
5212 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2,
5213 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5214 pbn_pericom_PI7C9X7954 },
5215 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2,
5216 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5217 pbn_pericom_PI7C9X7954 },
5218 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4,
5219 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5220 pbn_pericom_PI7C9X7954 },
5221 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4,
5222 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5223 pbn_pericom_PI7C9X7954 },
5224 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM,
5225 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5226 pbn_pericom_PI7C9X7954 },
5227 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4,
5228 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5229 pbn_pericom_PI7C9X7958 },
5230 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4,
5231 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5232 pbn_pericom_PI7C9X7958 },
5233 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8,
5234 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5235 pbn_pericom_PI7C9X7958 },
5236 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8,
5237 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5238 pbn_pericom_PI7C9X7958 },
5239 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4,
5240 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5241 pbn_pericom_PI7C9X7958 },
5242 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8,
5243 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5244 pbn_pericom_PI7C9X7958 },
5245 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM,
5246 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5247 pbn_pericom_PI7C9X7958 },
5248 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM,
5249 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5250 pbn_pericom_PI7C9X7958 },
5251 { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM,
5252 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
5253 pbn_pericom_PI7C9X7958 },
5254 /*
5116 * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) 5255 * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke)
5117 */ 5256 */
5118 { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560, 5257 { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560,
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 7481b95c6d84..bdfa659b9606 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1618,8 +1618,6 @@ static void serial8250_disable_ms(struct uart_port *port)
1618 if (up->bugs & UART_BUG_NOMSR) 1618 if (up->bugs & UART_BUG_NOMSR)
1619 return; 1619 return;
1620 1620
1621 mctrl_gpio_disable_ms(up->gpios);
1622
1623 up->ier &= ~UART_IER_MSI; 1621 up->ier &= ~UART_IER_MSI;
1624 serial_port_out(port, UART_IER, up->ier); 1622 serial_port_out(port, UART_IER, up->ier);
1625} 1623}
@@ -1632,8 +1630,6 @@ static void serial8250_enable_ms(struct uart_port *port)
1632 if (up->bugs & UART_BUG_NOMSR) 1630 if (up->bugs & UART_BUG_NOMSR)
1633 return; 1631 return;
1634 1632
1635 mctrl_gpio_enable_ms(up->gpios);
1636
1637 up->ier |= UART_IER_MSI; 1633 up->ier |= UART_IER_MSI;
1638 1634
1639 serial8250_rpm_get(up); 1635 serial8250_rpm_get(up);
@@ -1917,8 +1913,7 @@ unsigned int serial8250_do_get_mctrl(struct uart_port *port)
1917 ret |= TIOCM_DSR; 1913 ret |= TIOCM_DSR;
1918 if (status & UART_MSR_CTS) 1914 if (status & UART_MSR_CTS)
1919 ret |= TIOCM_CTS; 1915 ret |= TIOCM_CTS;
1920 1916 return ret;
1921 return mctrl_gpio_get(up->gpios, &ret);
1922} 1917}
1923EXPORT_SYMBOL_GPL(serial8250_do_get_mctrl); 1918EXPORT_SYMBOL_GPL(serial8250_do_get_mctrl);
1924 1919
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index c9ec839a5ddf..7c6f7afca5dd 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -6,7 +6,6 @@
6config SERIAL_8250 6config SERIAL_8250
7 tristate "8250/16550 and compatible serial support" 7 tristate "8250/16550 and compatible serial support"
8 select SERIAL_CORE 8 select SERIAL_CORE
9 select SERIAL_MCTRL_GPIO if GPIOLIB
10 ---help--- 9 ---help---
11 This selects whether you want to include the driver for the standard 10 This selects whether you want to include the driver for the standard
12 serial ports. The standard answer is Y. People who might say N 11 serial ports. The standard answer is Y. People who might say N
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 065f5d97aa67..dfec5a176315 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1596,8 +1596,11 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on)
1596{ 1596{
1597 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); 1597 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
1598 1598
1599 /* Data+ pullup controlled by OTG state machine in OTG fsm mode */ 1599 /*
1600 if (ci_otg_is_fsm_mode(ci)) 1600 * Data+ pullup controlled by OTG state machine in OTG fsm mode;
1601 * and don't touch Data+ in host mode for dual role config.
1602 */
1603 if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST)
1601 return 0; 1604 return 0;
1602 1605
1603 pm_runtime_get_sync(&ci->gadget.dev); 1606 pm_runtime_get_sync(&ci->gadget.dev);
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 051163189810..15ce4ab11688 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -187,7 +187,7 @@ static const unsigned short high_speed_maxpacket_maxes[4] = {
187 [USB_ENDPOINT_XFER_CONTROL] = 64, 187 [USB_ENDPOINT_XFER_CONTROL] = 64,
188 [USB_ENDPOINT_XFER_ISOC] = 1024, 188 [USB_ENDPOINT_XFER_ISOC] = 1024,
189 [USB_ENDPOINT_XFER_BULK] = 512, 189 [USB_ENDPOINT_XFER_BULK] = 512,
190 [USB_ENDPOINT_XFER_INT] = 1023, 190 [USB_ENDPOINT_XFER_INT] = 1024,
191}; 191};
192static const unsigned short super_speed_maxpacket_maxes[4] = { 192static const unsigned short super_speed_maxpacket_maxes[4] = {
193 [USB_ENDPOINT_XFER_CONTROL] = 512, 193 [USB_ENDPOINT_XFER_CONTROL] = 512,
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index e6a6d67c8705..09c8d9ca61ae 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1709,11 +1709,17 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
1709 as->urb->start_frame = uurb->start_frame; 1709 as->urb->start_frame = uurb->start_frame;
1710 as->urb->number_of_packets = number_of_packets; 1710 as->urb->number_of_packets = number_of_packets;
1711 as->urb->stream_id = stream_id; 1711 as->urb->stream_id = stream_id;
1712 if (uurb->type == USBDEVFS_URB_TYPE_ISO || 1712
1713 ps->dev->speed == USB_SPEED_HIGH) 1713 if (ep->desc.bInterval) {
1714 as->urb->interval = 1 << min(15, ep->desc.bInterval - 1); 1714 if (uurb->type == USBDEVFS_URB_TYPE_ISO ||
1715 else 1715 ps->dev->speed == USB_SPEED_HIGH ||
1716 as->urb->interval = ep->desc.bInterval; 1716 ps->dev->speed >= USB_SPEED_SUPER)
1717 as->urb->interval = 1 <<
1718 min(15, ep->desc.bInterval - 1);
1719 else
1720 as->urb->interval = ep->desc.bInterval;
1721 }
1722
1717 as->urb->context = as; 1723 as->urb->context = as;
1718 as->urb->complete = async_completed; 1724 as->urb->complete = async_completed;
1719 for (totlen = u = 0; u < number_of_packets; u++) { 1725 for (totlen = u = 0; u < number_of_packets; u++) {
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9fae0291cd69..d64551243789 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -868,6 +868,7 @@ struct dwc2_hsotg {
868 void *priv; 868 void *priv;
869 int irq; 869 int irq;
870 struct clk *clk; 870 struct clk *clk;
871 struct reset_control *reset;
871 872
872 unsigned int queuing_high_bandwidth:1; 873 unsigned int queuing_high_bandwidth:1;
873 unsigned int srp_success:1; 874 unsigned int srp_success:1;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index fc6f5251de5d..530959a8a6d1 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -45,6 +45,7 @@
45#include <linux/platform_device.h> 45#include <linux/platform_device.h>
46#include <linux/phy/phy.h> 46#include <linux/phy/phy.h>
47#include <linux/platform_data/s3c-hsotg.h> 47#include <linux/platform_data/s3c-hsotg.h>
48#include <linux/reset.h>
48 49
49#include <linux/usb/of.h> 50#include <linux/usb/of.h>
50 51
@@ -337,6 +338,24 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
337{ 338{
338 int i, ret; 339 int i, ret;
339 340
341 hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
342 if (IS_ERR(hsotg->reset)) {
343 ret = PTR_ERR(hsotg->reset);
344 switch (ret) {
345 case -ENOENT:
346 case -ENOTSUPP:
347 hsotg->reset = NULL;
348 break;
349 default:
350 dev_err(hsotg->dev, "error getting reset control %d\n",
351 ret);
352 return ret;
353 }
354 }
355
356 if (hsotg->reset)
357 reset_control_deassert(hsotg->reset);
358
340 /* Set default UTMI width */ 359 /* Set default UTMI width */
341 hsotg->phyif = GUSBCFG_PHYIF16; 360 hsotg->phyif = GUSBCFG_PHYIF16;
342 361
@@ -434,6 +453,9 @@ static int dwc2_driver_remove(struct platform_device *dev)
434 if (hsotg->ll_hw_enabled) 453 if (hsotg->ll_hw_enabled)
435 dwc2_lowlevel_hw_disable(hsotg); 454 dwc2_lowlevel_hw_disable(hsotg);
436 455
456 if (hsotg->reset)
457 reset_control_assert(hsotg->reset);
458
437 return 0; 459 return 0;
438} 460}
439 461
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 946643157b78..35d092456bec 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1192,6 +1192,7 @@ static int dwc3_runtime_resume(struct device *dev)
1192 } 1192 }
1193 1193
1194 pm_runtime_mark_last_busy(dev); 1194 pm_runtime_mark_last_busy(dev);
1195 pm_runtime_put(dev);
1195 1196
1196 return 0; 1197 return 0;
1197} 1198}
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
index 22dfc3dd6a13..33ab2a203c1b 100644
--- a/drivers/usb/dwc3/debug.h
+++ b/drivers/usb/dwc3/debug.h
@@ -192,7 +192,7 @@ dwc3_ep_event_string(const struct dwc3_event_depevt *event)
192 int ret; 192 int ret;
193 193
194 ret = sprintf(str, "ep%d%s: ", epnum >> 1, 194 ret = sprintf(str, "ep%d%s: ", epnum >> 1,
195 (epnum & 1) ? "in" : "in"); 195 (epnum & 1) ? "in" : "out");
196 if (ret < 0) 196 if (ret < 0)
197 return "UNKNOWN"; 197 return "UNKNOWN";
198 198
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 2eb84d6c24a6..0a32430f4c41 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -243,6 +243,13 @@ static int dwc3_pci_runtime_suspend(struct device *dev)
243 return -EBUSY; 243 return -EBUSY;
244} 244}
245 245
246static int dwc3_pci_runtime_resume(struct device *dev)
247{
248 struct platform_device *dwc3 = dev_get_drvdata(dev);
249
250 return pm_runtime_get(&dwc3->dev);
251}
252
246static int dwc3_pci_pm_dummy(struct device *dev) 253static int dwc3_pci_pm_dummy(struct device *dev)
247{ 254{
248 /* 255 /*
@@ -259,7 +266,7 @@ static int dwc3_pci_pm_dummy(struct device *dev)
259 266
260static struct dev_pm_ops dwc3_pci_dev_pm_ops = { 267static struct dev_pm_ops dwc3_pci_dev_pm_ops = {
261 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy) 268 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy)
262 SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_pm_dummy, 269 SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_runtime_resume,
263 NULL) 270 NULL)
264}; 271};
265 272
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 1f5597ef945d..7a8d3d822b54 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -884,12 +884,9 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
884 return DWC3_TRB_NUM - 1; 884 return DWC3_TRB_NUM - 1;
885 } 885 }
886 886
887 trbs_left = dep->trb_dequeue - dep->trb_enqueue; 887 trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1;
888 trbs_left &= (DWC3_TRB_NUM - 1); 888 trbs_left &= (DWC3_TRB_NUM - 1);
889 889
890 if (dep->trb_dequeue < dep->trb_enqueue)
891 trbs_left--;
892
893 return trbs_left; 890 return trbs_left;
894} 891}
895 892
@@ -1433,7 +1430,7 @@ static int dwc3_gadget_get_frame(struct usb_gadget *g)
1433 1430
1434static int __dwc3_gadget_wakeup(struct dwc3 *dwc) 1431static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
1435{ 1432{
1436 unsigned long timeout; 1433 int retries;
1437 1434
1438 int ret; 1435 int ret;
1439 u32 reg; 1436 u32 reg;
@@ -1484,9 +1481,9 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc)
1484 } 1481 }
1485 1482
1486 /* poll until Link State changes to ON */ 1483 /* poll until Link State changes to ON */
1487 timeout = jiffies + msecs_to_jiffies(100); 1484 retries = 20000;
1488 1485
1489 while (!time_after(jiffies, timeout)) { 1486 while (retries--) {
1490 reg = dwc3_readl(dwc->regs, DWC3_DSTS); 1487 reg = dwc3_readl(dwc->regs, DWC3_DSTS);
1491 1488
1492 /* in HS, means ON */ 1489 /* in HS, means ON */
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index d58bfc32be9e..8741fd740174 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -341,11 +341,15 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
341{ 341{
342 struct sk_buff *skb2 = NULL; 342 struct sk_buff *skb2 = NULL;
343 struct usb_ep *in = port->in_ep; 343 struct usb_ep *in = port->in_ep;
344 int padlen = 0; 344 int headroom, tailroom, padlen = 0;
345 u16 len = skb->len; 345 u16 len = skb->len;
346 346
347 int headroom = skb_headroom(skb); 347 if (!skb)
348 int tailroom = skb_tailroom(skb); 348 return NULL;
349
350 len = skb->len;
351 headroom = skb_headroom(skb);
352 tailroom = skb_tailroom(skb);
349 353
350 /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0, 354 /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
351 * stick two bytes of zero-length EEM packet on the end. 355 * stick two bytes of zero-length EEM packet on the end.
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index c8005823b190..16562e461121 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -374,6 +374,9 @@ static struct sk_buff *rndis_add_header(struct gether *port,
374{ 374{
375 struct sk_buff *skb2; 375 struct sk_buff *skb2;
376 376
377 if (!skb)
378 return NULL;
379
377 skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type)); 380 skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
378 rndis_add_hdr(skb2); 381 rndis_add_hdr(skb2);
379 382
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 6ded6345cd09..e0cd1e4c8892 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -375,10 +375,15 @@ __acquires(&port->port_lock)
375*/ 375*/
376{ 376{
377 struct list_head *pool = &port->write_pool; 377 struct list_head *pool = &port->write_pool;
378 struct usb_ep *in = port->port_usb->in; 378 struct usb_ep *in;
379 int status = 0; 379 int status = 0;
380 bool do_tty_wake = false; 380 bool do_tty_wake = false;
381 381
382 if (!port->port_usb)
383 return status;
384
385 in = port->port_usb->in;
386
382 while (!port->write_busy && !list_empty(pool)) { 387 while (!port->write_busy && !list_empty(pool)) {
383 struct usb_request *req; 388 struct usb_request *req;
384 int len; 389 int len;
diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index 934f83881c30..40c04bb25f2f 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -827,7 +827,7 @@ void usb_gadget_unmap_request_by_dev(struct device *dev,
827 return; 827 return;
828 828
829 if (req->num_mapped_sgs) { 829 if (req->num_mapped_sgs) {
830 dma_unmap_sg(dev, req->sg, req->num_mapped_sgs, 830 dma_unmap_sg(dev, req->sg, req->num_sgs,
831 is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); 831 is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
832 832
833 req->num_mapped_sgs = 0; 833 req->num_mapped_sgs = 0;
diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c
index cf8819a5c5b2..8bb011ea78f7 100644
--- a/drivers/usb/gadget/udc/fsl_qe_udc.c
+++ b/drivers/usb/gadget/udc/fsl_qe_udc.c
@@ -1878,11 +1878,8 @@ static int qe_get_frame(struct usb_gadget *gadget)
1878 1878
1879 tmp = in_be16(&udc->usb_param->frame_n); 1879 tmp = in_be16(&udc->usb_param->frame_n);
1880 if (tmp & 0x8000) 1880 if (tmp & 0x8000)
1881 tmp = tmp & 0x07ff; 1881 return tmp & 0x07ff;
1882 else 1882 return -EINVAL;
1883 tmp = -EINVAL;
1884
1885 return (int)tmp;
1886} 1883}
1887 1884
1888static int fsl_qe_start(struct usb_gadget *gadget, 1885static int fsl_qe_start(struct usb_gadget *gadget,
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index 192248f974ec..fe08e776fec3 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -290,6 +290,7 @@ int musb_hub_control(
290 u32 temp; 290 u32 temp;
291 int retval = 0; 291 int retval = 0;
292 unsigned long flags; 292 unsigned long flags;
293 bool start_musb = false;
293 294
294 spin_lock_irqsave(&musb->lock, flags); 295 spin_lock_irqsave(&musb->lock, flags);
295 296
@@ -390,7 +391,7 @@ int musb_hub_control(
390 * logic relating to VBUS power-up. 391 * logic relating to VBUS power-up.
391 */ 392 */
392 if (!hcd->self.is_b_host && musb_has_gadget(musb)) 393 if (!hcd->self.is_b_host && musb_has_gadget(musb))
393 musb_start(musb); 394 start_musb = true;
394 break; 395 break;
395 case USB_PORT_FEAT_RESET: 396 case USB_PORT_FEAT_RESET:
396 musb_port_reset(musb, true); 397 musb_port_reset(musb, true);
@@ -451,5 +452,9 @@ error:
451 retval = -EPIPE; 452 retval = -EPIPE;
452 } 453 }
453 spin_unlock_irqrestore(&musb->lock, flags); 454 spin_unlock_irqrestore(&musb->lock, flags);
455
456 if (start_musb)
457 musb_start(musb);
458
454 return retval; 459 return retval;
455} 460}
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c
index 92bc83b92d10..c4c64740a3e7 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -1076,7 +1076,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
1076 1076
1077 gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED); 1077 gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
1078 dev_info(dev, "%stransceiver found\n", 1078 dev_info(dev, "%stransceiver found\n",
1079 gpriv->transceiver ? "" : "no "); 1079 !IS_ERR(gpriv->transceiver) ? "" : "no ");
1080 1080
1081 /* 1081 /*
1082 * CAUTION 1082 * CAUTION
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 5608af4a369d..de9992b492b0 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1252,7 +1252,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
1252 1252
1253 if (urb->transfer_buffer == NULL) { 1253 if (urb->transfer_buffer == NULL) {
1254 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, 1254 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
1255 GFP_KERNEL); 1255 GFP_ATOMIC);
1256 if (!urb->transfer_buffer) 1256 if (!urb->transfer_buffer)
1257 goto exit; 1257 goto exit;
1258 } 1258 }
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index ed378fb232e7..57426d703a09 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1340,8 +1340,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1340 } 1340 }
1341 1341
1342 if (urb->transfer_buffer == NULL) { 1342 if (urb->transfer_buffer == NULL) {
1343 urb->transfer_buffer = 1343 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
1344 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); 1344 GFP_ATOMIC);
1345 if (!urb->transfer_buffer) 1345 if (!urb->transfer_buffer)
1346 goto exit; 1346 goto exit;
1347 } 1347 }
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index bc472584a229..9894e341c6ac 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -525,6 +525,12 @@ static void option_instat_callback(struct urb *urb);
525#define VIATELECOM_VENDOR_ID 0x15eb 525#define VIATELECOM_VENDOR_ID 0x15eb
526#define VIATELECOM_PRODUCT_CDS7 0x0001 526#define VIATELECOM_PRODUCT_CDS7 0x0001
527 527
528/* WeTelecom products */
529#define WETELECOM_VENDOR_ID 0x22de
530#define WETELECOM_PRODUCT_WMD200 0x6801
531#define WETELECOM_PRODUCT_6802 0x6802
532#define WETELECOM_PRODUCT_WMD300 0x6803
533
528struct option_blacklist_info { 534struct option_blacklist_info {
529 /* bitmask of interface numbers blacklisted for send_setup */ 535 /* bitmask of interface numbers blacklisted for send_setup */
530 const unsigned long sendsetup; 536 const unsigned long sendsetup;
@@ -1991,6 +1997,9 @@ static const struct usb_device_id option_ids[] = {
1991 { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */ 1997 { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
1992 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, 1998 { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) },
1993 { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, 1999 { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) },
2000 { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD200, 0xff, 0xff, 0xff) },
2001 { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_6802, 0xff, 0xff, 0xff) },
2002 { USB_DEVICE_AND_INTERFACE_INFO(WETELECOM_VENDOR_ID, WETELECOM_PRODUCT_WMD300, 0xff, 0xff, 0xff) },
1994 { } /* Terminating entry */ 2003 { } /* Terminating entry */
1995}; 2004};
1996MODULE_DEVICE_TABLE(usb, option_ids); 2005MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 7f6aff3f72eb..e5495f37c6ed 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -853,6 +853,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
853 current->flags |= PF_RANDOMIZE; 853 current->flags |= PF_RANDOMIZE;
854 854
855 setup_new_exec(bprm); 855 setup_new_exec(bprm);
856 install_exec_creds(bprm);
856 857
857 /* Do this so that we can load the interpreter, if need be. We will 858 /* Do this so that we can load the interpreter, if need be. We will
858 change some of these later */ 859 change some of these later */
@@ -1044,7 +1045,6 @@ static int load_elf_binary(struct linux_binprm *bprm)
1044 goto out; 1045 goto out;
1045#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ 1046#endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
1046 1047
1047 install_exec_creds(bprm);
1048 retval = create_elf_tables(bprm, &loc->elf_ex, 1048 retval = create_elf_tables(bprm, &loc->elf_ex,
1049 load_addr, interp_load_addr); 1049 load_addr, interp_load_addr);
1050 if (retval < 0) 1050 if (retval < 0)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0450dc410533..8c8a4d1e02b9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4901,11 +4901,6 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root,
4901 u64 expected; 4901 u64 expected;
4902 u64 to_reclaim = 0; 4902 u64 to_reclaim = 0;
4903 4903
4904 to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
4905 if (can_overcommit(root, space_info, to_reclaim,
4906 BTRFS_RESERVE_FLUSH_ALL))
4907 return 0;
4908
4909 list_for_each_entry(ticket, &space_info->tickets, list) 4904 list_for_each_entry(ticket, &space_info->tickets, list)
4910 to_reclaim += ticket->bytes; 4905 to_reclaim += ticket->bytes;
4911 list_for_each_entry(ticket, &space_info->priority_tickets, list) 4906 list_for_each_entry(ticket, &space_info->priority_tickets, list)
@@ -4913,6 +4908,11 @@ btrfs_calc_reclaim_metadata_size(struct btrfs_root *root,
4913 if (to_reclaim) 4908 if (to_reclaim)
4914 return to_reclaim; 4909 return to_reclaim;
4915 4910
4911 to_reclaim = min_t(u64, num_online_cpus() * SZ_1M, SZ_16M);
4912 if (can_overcommit(root, space_info, to_reclaim,
4913 BTRFS_RESERVE_FLUSH_ALL))
4914 return 0;
4915
4916 used = space_info->bytes_used + space_info->bytes_reserved + 4916 used = space_info->bytes_used + space_info->bytes_reserved +
4917 space_info->bytes_pinned + space_info->bytes_readonly + 4917 space_info->bytes_pinned + space_info->bytes_readonly +
4918 space_info->bytes_may_use; 4918 space_info->bytes_may_use;
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 8a2c2a07987b..c0c13dc6fe12 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4200,9 +4200,11 @@ restart:
4200 err = PTR_ERR(trans); 4200 err = PTR_ERR(trans);
4201 goto out_free; 4201 goto out_free;
4202 } 4202 }
4203 err = qgroup_fix_relocated_data_extents(trans, rc); 4203 ret = qgroup_fix_relocated_data_extents(trans, rc);
4204 if (err < 0) { 4204 if (ret < 0) {
4205 btrfs_abort_transaction(trans, err); 4205 btrfs_abort_transaction(trans, ret);
4206 if (!err)
4207 err = ret;
4206 goto out_free; 4208 goto out_free;
4207 } 4209 }
4208 btrfs_commit_transaction(trans, rc->extent_root); 4210 btrfs_commit_transaction(trans, rc->extent_root);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index efe129fe2678..a87675ffd02b 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4268,10 +4268,12 @@ static int process_all_refs(struct send_ctx *sctx,
4268 } 4268 }
4269 btrfs_release_path(path); 4269 btrfs_release_path(path);
4270 4270
4271 /*
4272 * We don't actually care about pending_move as we are simply
4273 * re-creating this inode and will be rename'ing it into place once we
4274 * rename the parent directory.
4275 */
4271 ret = process_recorded_refs(sctx, &pending_move); 4276 ret = process_recorded_refs(sctx, &pending_move);
4272 /* Only applicable to an incremental send. */
4273 ASSERT(pending_move == 0);
4274
4275out: 4277out:
4276 btrfs_free_path(path); 4278 btrfs_free_path(path);
4277 return ret; 4279 return ret;
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index d116453b0276..79a5941c2474 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -585,7 +585,8 @@ struct dentry *devpts_pty_new(struct pts_fs_info *fsi, int index, void *priv)
585 */ 585 */
586void *devpts_get_priv(struct dentry *dentry) 586void *devpts_get_priv(struct dentry *dentry)
587{ 587{
588 WARN_ON_ONCE(dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC); 588 if (dentry->d_sb->s_magic != DEVPTS_SUPER_MAGIC)
589 return NULL;
589 return dentry->d_fsdata; 590 return dentry->d_fsdata;
590} 591}
591 592
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3131747199e1..c6ea25a190f8 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5466,8 +5466,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
5466 sbi->s_want_extra_isize, 5466 sbi->s_want_extra_isize,
5467 iloc, handle); 5467 iloc, handle);
5468 if (ret) { 5468 if (ret) {
5469 ext4_set_inode_state(inode,
5470 EXT4_STATE_NO_EXPAND);
5471 if (mnt_count != 5469 if (mnt_count !=
5472 le16_to_cpu(sbi->s_es->s_mnt_count)) { 5470 le16_to_cpu(sbi->s_es->s_mnt_count)) {
5473 ext4_warning(inode->i_sb, 5471 ext4_warning(inode->i_sb,
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1c593aa0218e..3ec8708989ca 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2211,6 +2211,7 @@ void ext4_group_desc_csum_set(struct super_block *sb, __u32 block_group,
2211 2211
2212/* Called at mount-time, super-block is locked */ 2212/* Called at mount-time, super-block is locked */
2213static int ext4_check_descriptors(struct super_block *sb, 2213static int ext4_check_descriptors(struct super_block *sb,
2214 ext4_fsblk_t sb_block,
2214 ext4_group_t *first_not_zeroed) 2215 ext4_group_t *first_not_zeroed)
2215{ 2216{
2216 struct ext4_sb_info *sbi = EXT4_SB(sb); 2217 struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -2241,6 +2242,11 @@ static int ext4_check_descriptors(struct super_block *sb,
2241 grp = i; 2242 grp = i;
2242 2243
2243 block_bitmap = ext4_block_bitmap(sb, gdp); 2244 block_bitmap = ext4_block_bitmap(sb, gdp);
2245 if (block_bitmap == sb_block) {
2246 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2247 "Block bitmap for group %u overlaps "
2248 "superblock", i);
2249 }
2244 if (block_bitmap < first_block || block_bitmap > last_block) { 2250 if (block_bitmap < first_block || block_bitmap > last_block) {
2245 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2251 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2246 "Block bitmap for group %u not in group " 2252 "Block bitmap for group %u not in group "
@@ -2248,6 +2254,11 @@ static int ext4_check_descriptors(struct super_block *sb,
2248 return 0; 2254 return 0;
2249 } 2255 }
2250 inode_bitmap = ext4_inode_bitmap(sb, gdp); 2256 inode_bitmap = ext4_inode_bitmap(sb, gdp);
2257 if (inode_bitmap == sb_block) {
2258 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2259 "Inode bitmap for group %u overlaps "
2260 "superblock", i);
2261 }
2251 if (inode_bitmap < first_block || inode_bitmap > last_block) { 2262 if (inode_bitmap < first_block || inode_bitmap > last_block) {
2252 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2263 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2253 "Inode bitmap for group %u not in group " 2264 "Inode bitmap for group %u not in group "
@@ -2255,6 +2266,11 @@ static int ext4_check_descriptors(struct super_block *sb,
2255 return 0; 2266 return 0;
2256 } 2267 }
2257 inode_table = ext4_inode_table(sb, gdp); 2268 inode_table = ext4_inode_table(sb, gdp);
2269 if (inode_table == sb_block) {
2270 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
2271 "Inode table for group %u overlaps "
2272 "superblock", i);
2273 }
2258 if (inode_table < first_block || 2274 if (inode_table < first_block ||
2259 inode_table + sbi->s_itb_per_group - 1 > last_block) { 2275 inode_table + sbi->s_itb_per_group - 1 > last_block) {
2260 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " 2276 ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: "
@@ -3757,7 +3773,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3757 goto failed_mount2; 3773 goto failed_mount2;
3758 } 3774 }
3759 } 3775 }
3760 if (!ext4_check_descriptors(sb, &first_not_zeroed)) { 3776 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
3761 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); 3777 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
3762 ret = -EFSCORRUPTED; 3778 ret = -EFSCORRUPTED;
3763 goto failed_mount2; 3779 goto failed_mount2;
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 39e9cfb1b371..2eb935ca5d9e 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1353,15 +1353,19 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
1353 size_t min_offs, free; 1353 size_t min_offs, free;
1354 int total_ino; 1354 int total_ino;
1355 void *base, *start, *end; 1355 void *base, *start, *end;
1356 int extra_isize = 0, error = 0, tried_min_extra_isize = 0; 1356 int error = 0, tried_min_extra_isize = 0;
1357 int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize); 1357 int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize);
1358 int isize_diff; /* How much do we need to grow i_extra_isize */
1358 1359
1359 down_write(&EXT4_I(inode)->xattr_sem); 1360 down_write(&EXT4_I(inode)->xattr_sem);
1361 /*
1362 * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty
1363 */
1364 ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND);
1360retry: 1365retry:
1361 if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { 1366 isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize;
1362 up_write(&EXT4_I(inode)->xattr_sem); 1367 if (EXT4_I(inode)->i_extra_isize >= new_extra_isize)
1363 return 0; 1368 goto out;
1364 }
1365 1369
1366 header = IHDR(inode, raw_inode); 1370 header = IHDR(inode, raw_inode);
1367 entry = IFIRST(header); 1371 entry = IFIRST(header);
@@ -1382,7 +1386,7 @@ retry:
1382 goto cleanup; 1386 goto cleanup;
1383 1387
1384 free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); 1388 free = ext4_xattr_free_space(last, &min_offs, base, &total_ino);
1385 if (free >= new_extra_isize) { 1389 if (free >= isize_diff) {
1386 entry = IFIRST(header); 1390 entry = IFIRST(header);
1387 ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize 1391 ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize
1388 - new_extra_isize, (void *)raw_inode + 1392 - new_extra_isize, (void *)raw_inode +
@@ -1390,8 +1394,7 @@ retry:
1390 (void *)header, total_ino, 1394 (void *)header, total_ino,
1391 inode->i_sb->s_blocksize); 1395 inode->i_sb->s_blocksize);
1392 EXT4_I(inode)->i_extra_isize = new_extra_isize; 1396 EXT4_I(inode)->i_extra_isize = new_extra_isize;
1393 error = 0; 1397 goto out;
1394 goto cleanup;
1395 } 1398 }
1396 1399
1397 /* 1400 /*
@@ -1414,7 +1417,7 @@ retry:
1414 end = bh->b_data + bh->b_size; 1417 end = bh->b_data + bh->b_size;
1415 min_offs = end - base; 1418 min_offs = end - base;
1416 free = ext4_xattr_free_space(first, &min_offs, base, NULL); 1419 free = ext4_xattr_free_space(first, &min_offs, base, NULL);
1417 if (free < new_extra_isize) { 1420 if (free < isize_diff) {
1418 if (!tried_min_extra_isize && s_min_extra_isize) { 1421 if (!tried_min_extra_isize && s_min_extra_isize) {
1419 tried_min_extra_isize++; 1422 tried_min_extra_isize++;
1420 new_extra_isize = s_min_extra_isize; 1423 new_extra_isize = s_min_extra_isize;
@@ -1428,7 +1431,7 @@ retry:
1428 free = inode->i_sb->s_blocksize; 1431 free = inode->i_sb->s_blocksize;
1429 } 1432 }
1430 1433
1431 while (new_extra_isize > 0) { 1434 while (isize_diff > 0) {
1432 size_t offs, size, entry_size; 1435 size_t offs, size, entry_size;
1433 struct ext4_xattr_entry *small_entry = NULL; 1436 struct ext4_xattr_entry *small_entry = NULL;
1434 struct ext4_xattr_info i = { 1437 struct ext4_xattr_info i = {
@@ -1459,7 +1462,7 @@ retry:
1459 EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + 1462 EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
1460 EXT4_XATTR_LEN(last->e_name_len); 1463 EXT4_XATTR_LEN(last->e_name_len);
1461 if (total_size <= free && total_size < min_total_size) { 1464 if (total_size <= free && total_size < min_total_size) {
1462 if (total_size < new_extra_isize) { 1465 if (total_size < isize_diff) {
1463 small_entry = last; 1466 small_entry = last;
1464 } else { 1467 } else {
1465 entry = last; 1468 entry = last;
@@ -1514,22 +1517,22 @@ retry:
1514 error = ext4_xattr_ibody_set(handle, inode, &i, is); 1517 error = ext4_xattr_ibody_set(handle, inode, &i, is);
1515 if (error) 1518 if (error)
1516 goto cleanup; 1519 goto cleanup;
1520 total_ino -= entry_size;
1517 1521
1518 entry = IFIRST(header); 1522 entry = IFIRST(header);
1519 if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) 1523 if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff)
1520 shift_bytes = new_extra_isize; 1524 shift_bytes = isize_diff;
1521 else 1525 else
1522 shift_bytes = entry_size + size; 1526 shift_bytes = entry_size + EXT4_XATTR_SIZE(size);
1523 /* Adjust the offsets and shift the remaining entries ahead */ 1527 /* Adjust the offsets and shift the remaining entries ahead */
1524 ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - 1528 ext4_xattr_shift_entries(entry, -shift_bytes,
1525 shift_bytes, (void *)raw_inode + 1529 (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE +
1526 EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes, 1530 EXT4_I(inode)->i_extra_isize + shift_bytes,
1527 (void *)header, total_ino - entry_size, 1531 (void *)header, total_ino, inode->i_sb->s_blocksize);
1528 inode->i_sb->s_blocksize);
1529 1532
1530 extra_isize += shift_bytes; 1533 isize_diff -= shift_bytes;
1531 new_extra_isize -= shift_bytes; 1534 EXT4_I(inode)->i_extra_isize += shift_bytes;
1532 EXT4_I(inode)->i_extra_isize = extra_isize; 1535 header = IHDR(inode, raw_inode);
1533 1536
1534 i.name = b_entry_name; 1537 i.name = b_entry_name;
1535 i.value = buffer; 1538 i.value = buffer;
@@ -1551,6 +1554,8 @@ retry:
1551 kfree(bs); 1554 kfree(bs);
1552 } 1555 }
1553 brelse(bh); 1556 brelse(bh);
1557out:
1558 ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND);
1554 up_write(&EXT4_I(inode)->xattr_sem); 1559 up_write(&EXT4_I(inode)->xattr_sem);
1555 return 0; 1560 return 0;
1556 1561
@@ -1562,6 +1567,10 @@ cleanup:
1562 kfree(is); 1567 kfree(is);
1563 kfree(bs); 1568 kfree(bs);
1564 brelse(bh); 1569 brelse(bh);
1570 /*
1571 * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode
1572 * size expansion failed.
1573 */
1565 up_write(&EXT4_I(inode)->xattr_sem); 1574 up_write(&EXT4_I(inode)->xattr_sem);
1566 return error; 1575 return error;
1567} 1576}
diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
index 69dd3e6566e0..a92e783fa057 100644
--- a/fs/ext4/xattr.h
+++ b/fs/ext4/xattr.h
@@ -24,6 +24,7 @@
24#define EXT4_XATTR_INDEX_SYSTEM 7 24#define EXT4_XATTR_INDEX_SYSTEM 7
25#define EXT4_XATTR_INDEX_RICHACL 8 25#define EXT4_XATTR_INDEX_RICHACL 8
26#define EXT4_XATTR_INDEX_ENCRYPTION 9 26#define EXT4_XATTR_INDEX_ENCRYPTION 9
27#define EXT4_XATTR_INDEX_HURD 10 /* Reserved for Hurd */
27 28
28struct ext4_xattr_header { 29struct ext4_xattr_header {
29 __le32 h_magic; /* magic number for identification */ 30 __le32 h_magic; /* magic number for identification */
diff --git a/fs/iomap.c b/fs/iomap.c
index 0342254646e3..706270f21b35 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -428,9 +428,12 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
428 break; 428 break;
429 } 429 }
430 430
431 if (iomap->flags & IOMAP_F_MERGED)
432 flags |= FIEMAP_EXTENT_MERGED;
433
431 return fiemap_fill_next_extent(fi, iomap->offset, 434 return fiemap_fill_next_extent(fi, iomap->offset,
432 iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0, 435 iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0,
433 iomap->length, flags | FIEMAP_EXTENT_MERGED); 436 iomap->length, flags);
434 437
435} 438}
436 439
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index e1574008adc9..2bcb86e6e6ca 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -840,21 +840,35 @@ repeat:
840 mutex_lock(&kernfs_mutex); 840 mutex_lock(&kernfs_mutex);
841 841
842 list_for_each_entry(info, &kernfs_root(kn)->supers, node) { 842 list_for_each_entry(info, &kernfs_root(kn)->supers, node) {
843 struct kernfs_node *parent;
843 struct inode *inode; 844 struct inode *inode;
844 struct dentry *dentry;
845 845
846 /*
847 * We want fsnotify_modify() on @kn but as the
848 * modifications aren't originating from userland don't
849 * have the matching @file available. Look up the inodes
850 * and generate the events manually.
851 */
846 inode = ilookup(info->sb, kn->ino); 852 inode = ilookup(info->sb, kn->ino);
847 if (!inode) 853 if (!inode)
848 continue; 854 continue;
849 855
850 dentry = d_find_any_alias(inode); 856 parent = kernfs_get_parent(kn);
851 if (dentry) { 857 if (parent) {
852 fsnotify_parent(NULL, dentry, FS_MODIFY); 858 struct inode *p_inode;
853 fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE, 859
854 NULL, 0); 860 p_inode = ilookup(info->sb, parent->ino);
855 dput(dentry); 861 if (p_inode) {
862 fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
863 inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
864 iput(p_inode);
865 }
866
867 kernfs_put(parent);
856 } 868 }
857 869
870 fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
871 kn->name, 0);
858 iput(inode); 872 iput(inode);
859 } 873 }
860 874
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index f55a4e756047..217847679f0e 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -346,7 +346,7 @@ static void bl_write_cleanup(struct work_struct *work)
346 PAGE_SIZE - 1) & (loff_t)PAGE_MASK; 346 PAGE_SIZE - 1) & (loff_t)PAGE_MASK;
347 347
348 ext_tree_mark_written(bl, start >> SECTOR_SHIFT, 348 ext_tree_mark_written(bl, start >> SECTOR_SHIFT,
349 (end - start) >> SECTOR_SHIFT); 349 (end - start) >> SECTOR_SHIFT, end);
350 } 350 }
351 351
352 pnfs_ld_write_done(hdr); 352 pnfs_ld_write_done(hdr);
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
index 18e6fd0b9506..efc007f00742 100644
--- a/fs/nfs/blocklayout/blocklayout.h
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -141,6 +141,7 @@ struct pnfs_block_layout {
141 struct rb_root bl_ext_ro; 141 struct rb_root bl_ext_ro;
142 spinlock_t bl_ext_lock; /* Protects list manipulation */ 142 spinlock_t bl_ext_lock; /* Protects list manipulation */
143 bool bl_scsi_layout; 143 bool bl_scsi_layout;
144 u64 bl_lwb;
144}; 145};
145 146
146static inline struct pnfs_block_layout * 147static inline struct pnfs_block_layout *
@@ -182,7 +183,7 @@ int ext_tree_insert(struct pnfs_block_layout *bl,
182int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start, 183int ext_tree_remove(struct pnfs_block_layout *bl, bool rw, sector_t start,
183 sector_t end); 184 sector_t end);
184int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, 185int ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start,
185 sector_t len); 186 sector_t len, u64 lwb);
186bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect, 187bool ext_tree_lookup(struct pnfs_block_layout *bl, sector_t isect,
187 struct pnfs_block_extent *ret, bool rw); 188 struct pnfs_block_extent *ret, bool rw);
188int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg); 189int ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg);
diff --git a/fs/nfs/blocklayout/extent_tree.c b/fs/nfs/blocklayout/extent_tree.c
index 992bcb19c11e..c85fbfd2d0d9 100644
--- a/fs/nfs/blocklayout/extent_tree.c
+++ b/fs/nfs/blocklayout/extent_tree.c
@@ -402,7 +402,7 @@ ext_tree_split(struct rb_root *root, struct pnfs_block_extent *be,
402 402
403int 403int
404ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, 404ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start,
405 sector_t len) 405 sector_t len, u64 lwb)
406{ 406{
407 struct rb_root *root = &bl->bl_ext_rw; 407 struct rb_root *root = &bl->bl_ext_rw;
408 sector_t end = start + len; 408 sector_t end = start + len;
@@ -471,6 +471,8 @@ ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start,
471 } 471 }
472 } 472 }
473out: 473out:
474 if (bl->bl_lwb < lwb)
475 bl->bl_lwb = lwb;
474 spin_unlock(&bl->bl_ext_lock); 476 spin_unlock(&bl->bl_ext_lock);
475 477
476 __ext_put_deviceids(&tmp); 478 __ext_put_deviceids(&tmp);
@@ -518,7 +520,7 @@ static __be32 *encode_scsi_range(struct pnfs_block_extent *be, __be32 *p)
518} 520}
519 521
520static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p, 522static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p,
521 size_t buffer_size, size_t *count) 523 size_t buffer_size, size_t *count, __u64 *lastbyte)
522{ 524{
523 struct pnfs_block_extent *be; 525 struct pnfs_block_extent *be;
524 int ret = 0; 526 int ret = 0;
@@ -542,6 +544,8 @@ static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p,
542 p = encode_block_extent(be, p); 544 p = encode_block_extent(be, p);
543 be->be_tag = EXTENT_COMMITTING; 545 be->be_tag = EXTENT_COMMITTING;
544 } 546 }
547 *lastbyte = bl->bl_lwb - 1;
548 bl->bl_lwb = 0;
545 spin_unlock(&bl->bl_ext_lock); 549 spin_unlock(&bl->bl_ext_lock);
546 550
547 return ret; 551 return ret;
@@ -564,7 +568,7 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg)
564 arg->layoutupdate_pages = &arg->layoutupdate_page; 568 arg->layoutupdate_pages = &arg->layoutupdate_page;
565 569
566retry: 570retry:
567 ret = ext_tree_encode_commit(bl, start_p + 1, buffer_size, &count); 571 ret = ext_tree_encode_commit(bl, start_p + 1, buffer_size, &count, &arg->lastbytewritten);
568 if (unlikely(ret)) { 572 if (unlikely(ret)) {
569 ext_tree_free_commitdata(arg, buffer_size); 573 ext_tree_free_commitdata(arg, buffer_size);
570 574
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index a7f2e6e33305..52a28311e2a4 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -275,6 +275,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
275err_socks: 275err_socks:
276 svc_rpcb_cleanup(serv, net); 276 svc_rpcb_cleanup(serv, net);
277err_bind: 277err_bind:
278 nn->cb_users[minorversion]--;
278 dprintk("NFS: Couldn't create callback socket: err = %d; " 279 dprintk("NFS: Couldn't create callback socket: err = %d; "
279 "net = %p\n", ret, net); 280 "net = %p\n", ret, net);
280 return ret; 281 return ret;
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index c92a75e066a6..f953ef6b2f2e 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -454,11 +454,8 @@ static bool referring_call_exists(struct nfs_client *clp,
454 ((u32 *)&rclist->rcl_sessionid.data)[3], 454 ((u32 *)&rclist->rcl_sessionid.data)[3],
455 ref->rc_sequenceid, ref->rc_slotid); 455 ref->rc_sequenceid, ref->rc_slotid);
456 456
457 spin_lock(&tbl->slot_tbl_lock); 457 status = nfs4_slot_wait_on_seqid(tbl, ref->rc_slotid,
458 status = (test_bit(ref->rc_slotid, tbl->used_slots) && 458 ref->rc_sequenceid, HZ >> 1) < 0;
459 tbl->slots[ref->rc_slotid].seq_nr ==
460 ref->rc_sequenceid);
461 spin_unlock(&tbl->slot_tbl_lock);
462 if (status) 459 if (status)
463 goto out; 460 goto out;
464 } 461 }
@@ -487,7 +484,6 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
487 goto out; 484 goto out;
488 485
489 tbl = &clp->cl_session->bc_slot_table; 486 tbl = &clp->cl_session->bc_slot_table;
490 slot = tbl->slots + args->csa_slotid;
491 487
492 /* Set up res before grabbing the spinlock */ 488 /* Set up res before grabbing the spinlock */
493 memcpy(&res->csr_sessionid, &args->csa_sessionid, 489 memcpy(&res->csr_sessionid, &args->csa_sessionid,
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 003ebce4bbc4..1e106780a237 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -426,7 +426,7 @@ EXPORT_SYMBOL_GPL(nfs_mark_client_ready);
426 * Initialise the timeout values for a connection 426 * Initialise the timeout values for a connection
427 */ 427 */
428void nfs_init_timeout_values(struct rpc_timeout *to, int proto, 428void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
429 unsigned int timeo, unsigned int retrans) 429 int timeo, int retrans)
430{ 430{
431 to->to_initval = timeo * HZ / 10; 431 to->to_initval = timeo * HZ / 10;
432 to->to_retries = retrans; 432 to->to_retries = retrans;
@@ -434,9 +434,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
434 switch (proto) { 434 switch (proto) {
435 case XPRT_TRANSPORT_TCP: 435 case XPRT_TRANSPORT_TCP:
436 case XPRT_TRANSPORT_RDMA: 436 case XPRT_TRANSPORT_RDMA:
437 if (to->to_retries == 0) 437 if (retrans == NFS_UNSPEC_RETRANS)
438 to->to_retries = NFS_DEF_TCP_RETRANS; 438 to->to_retries = NFS_DEF_TCP_RETRANS;
439 if (to->to_initval == 0) 439 if (timeo == NFS_UNSPEC_TIMEO || to->to_retries == 0)
440 to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; 440 to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10;
441 if (to->to_initval > NFS_MAX_TCP_TIMEOUT) 441 if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
442 to->to_initval = NFS_MAX_TCP_TIMEOUT; 442 to->to_initval = NFS_MAX_TCP_TIMEOUT;
@@ -449,9 +449,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
449 to->to_exponential = 0; 449 to->to_exponential = 0;
450 break; 450 break;
451 case XPRT_TRANSPORT_UDP: 451 case XPRT_TRANSPORT_UDP:
452 if (to->to_retries == 0) 452 if (retrans == NFS_UNSPEC_RETRANS)
453 to->to_retries = NFS_DEF_UDP_RETRANS; 453 to->to_retries = NFS_DEF_UDP_RETRANS;
454 if (!to->to_initval) 454 if (timeo == NFS_UNSPEC_TIMEO || to->to_initval == 0)
455 to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; 455 to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10;
456 if (to->to_initval > NFS_MAX_UDP_TIMEOUT) 456 if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
457 to->to_initval = NFS_MAX_UDP_TIMEOUT; 457 to->to_initval = NFS_MAX_UDP_TIMEOUT;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index e6206eaf2bdf..51b51369704c 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -37,6 +37,7 @@ ff_layout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
37 if (ffl) { 37 if (ffl) {
38 INIT_LIST_HEAD(&ffl->error_list); 38 INIT_LIST_HEAD(&ffl->error_list);
39 INIT_LIST_HEAD(&ffl->mirrors); 39 INIT_LIST_HEAD(&ffl->mirrors);
40 ffl->last_report_time = ktime_get();
40 return &ffl->generic_hdr; 41 return &ffl->generic_hdr;
41 } else 42 } else
42 return NULL; 43 return NULL;
@@ -640,19 +641,18 @@ nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror,
640{ 641{
641 static const ktime_t notime = {0}; 642 static const ktime_t notime = {0};
642 s64 report_interval = FF_LAYOUTSTATS_REPORT_INTERVAL; 643 s64 report_interval = FF_LAYOUTSTATS_REPORT_INTERVAL;
644 struct nfs4_flexfile_layout *ffl = FF_LAYOUT_FROM_HDR(mirror->layout);
643 645
644 nfs4_ff_start_busy_timer(&layoutstat->busy_timer, now); 646 nfs4_ff_start_busy_timer(&layoutstat->busy_timer, now);
645 if (ktime_equal(mirror->start_time, notime)) 647 if (ktime_equal(mirror->start_time, notime))
646 mirror->start_time = now; 648 mirror->start_time = now;
647 if (ktime_equal(mirror->last_report_time, notime))
648 mirror->last_report_time = now;
649 if (mirror->report_interval != 0) 649 if (mirror->report_interval != 0)
650 report_interval = (s64)mirror->report_interval * 1000LL; 650 report_interval = (s64)mirror->report_interval * 1000LL;
651 else if (layoutstats_timer != 0) 651 else if (layoutstats_timer != 0)
652 report_interval = (s64)layoutstats_timer * 1000LL; 652 report_interval = (s64)layoutstats_timer * 1000LL;
653 if (ktime_to_ms(ktime_sub(now, mirror->last_report_time)) >= 653 if (ktime_to_ms(ktime_sub(now, ffl->last_report_time)) >=
654 report_interval) { 654 report_interval) {
655 mirror->last_report_time = now; 655 ffl->last_report_time = now;
656 return true; 656 return true;
657 } 657 }
658 658
@@ -806,11 +806,14 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
806{ 806{
807 struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); 807 struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg);
808 struct nfs4_pnfs_ds *ds; 808 struct nfs4_pnfs_ds *ds;
809 bool fail_return = false;
809 int idx; 810 int idx;
810 811
811 /* mirrors are sorted by efficiency */ 812 /* mirrors are sorted by efficiency */
812 for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) { 813 for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) {
813 ds = nfs4_ff_layout_prepare_ds(lseg, idx, false); 814 if (idx+1 == fls->mirror_array_cnt)
815 fail_return = true;
816 ds = nfs4_ff_layout_prepare_ds(lseg, idx, fail_return);
814 if (ds) { 817 if (ds) {
815 *best_idx = idx; 818 *best_idx = idx;
816 return ds; 819 return ds;
@@ -859,6 +862,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
859 struct nfs4_pnfs_ds *ds; 862 struct nfs4_pnfs_ds *ds;
860 int ds_idx; 863 int ds_idx;
861 864
865retry:
862 /* Use full layout for now */ 866 /* Use full layout for now */
863 if (!pgio->pg_lseg) 867 if (!pgio->pg_lseg)
864 ff_layout_pg_get_read(pgio, req, false); 868 ff_layout_pg_get_read(pgio, req, false);
@@ -871,10 +875,13 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
871 875
872 ds = ff_layout_choose_best_ds_for_read(pgio->pg_lseg, 0, &ds_idx); 876 ds = ff_layout_choose_best_ds_for_read(pgio->pg_lseg, 0, &ds_idx);
873 if (!ds) { 877 if (!ds) {
874 if (ff_layout_no_fallback_to_mds(pgio->pg_lseg)) 878 if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
875 goto out_pnfs;
876 else
877 goto out_mds; 879 goto out_mds;
880 pnfs_put_lseg(pgio->pg_lseg);
881 pgio->pg_lseg = NULL;
882 /* Sleep for 1 second before retrying */
883 ssleep(1);
884 goto retry;
878 } 885 }
879 886
880 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx); 887 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx);
@@ -890,12 +897,6 @@ out_mds:
890 pnfs_put_lseg(pgio->pg_lseg); 897 pnfs_put_lseg(pgio->pg_lseg);
891 pgio->pg_lseg = NULL; 898 pgio->pg_lseg = NULL;
892 nfs_pageio_reset_read_mds(pgio); 899 nfs_pageio_reset_read_mds(pgio);
893 return;
894
895out_pnfs:
896 pnfs_set_lo_fail(pgio->pg_lseg);
897 pnfs_put_lseg(pgio->pg_lseg);
898 pgio->pg_lseg = NULL;
899} 900}
900 901
901static void 902static void
@@ -909,6 +910,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
909 int i; 910 int i;
910 int status; 911 int status;
911 912
913retry:
912 if (!pgio->pg_lseg) { 914 if (!pgio->pg_lseg) {
913 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, 915 pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
914 req->wb_context, 916 req->wb_context,
@@ -940,10 +942,13 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
940 for (i = 0; i < pgio->pg_mirror_count; i++) { 942 for (i = 0; i < pgio->pg_mirror_count; i++) {
941 ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true); 943 ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true);
942 if (!ds) { 944 if (!ds) {
943 if (ff_layout_no_fallback_to_mds(pgio->pg_lseg)) 945 if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
944 goto out_pnfs;
945 else
946 goto out_mds; 946 goto out_mds;
947 pnfs_put_lseg(pgio->pg_lseg);
948 pgio->pg_lseg = NULL;
949 /* Sleep for 1 second before retrying */
950 ssleep(1);
951 goto retry;
947 } 952 }
948 pgm = &pgio->pg_mirrors[i]; 953 pgm = &pgio->pg_mirrors[i];
949 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i); 954 mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
@@ -956,12 +961,6 @@ out_mds:
956 pnfs_put_lseg(pgio->pg_lseg); 961 pnfs_put_lseg(pgio->pg_lseg);
957 pgio->pg_lseg = NULL; 962 pgio->pg_lseg = NULL;
958 nfs_pageio_reset_write_mds(pgio); 963 nfs_pageio_reset_write_mds(pgio);
959 return;
960
961out_pnfs:
962 pnfs_set_lo_fail(pgio->pg_lseg);
963 pnfs_put_lseg(pgio->pg_lseg);
964 pgio->pg_lseg = NULL;
965} 964}
966 965
967static unsigned int 966static unsigned int
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 1bcdb15d0c41..3ee0c9fcea76 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -84,7 +84,6 @@ struct nfs4_ff_layout_mirror {
84 struct nfs4_ff_layoutstat read_stat; 84 struct nfs4_ff_layoutstat read_stat;
85 struct nfs4_ff_layoutstat write_stat; 85 struct nfs4_ff_layoutstat write_stat;
86 ktime_t start_time; 86 ktime_t start_time;
87 ktime_t last_report_time;
88 u32 report_interval; 87 u32 report_interval;
89}; 88};
90 89
@@ -101,6 +100,7 @@ struct nfs4_flexfile_layout {
101 struct pnfs_ds_commit_info commit_info; 100 struct pnfs_ds_commit_info commit_info;
102 struct list_head mirrors; 101 struct list_head mirrors;
103 struct list_head error_list; /* nfs4_ff_layout_ds_err */ 102 struct list_head error_list; /* nfs4_ff_layout_ds_err */
103 ktime_t last_report_time; /* Layoutstat report times */
104}; 104};
105 105
106static inline struct nfs4_flexfile_layout * 106static inline struct nfs4_flexfile_layout *
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 0aa36be71fce..f7a3f6b05369 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -17,8 +17,8 @@
17 17
18#define NFSDBG_FACILITY NFSDBG_PNFS_LD 18#define NFSDBG_FACILITY NFSDBG_PNFS_LD
19 19
20static unsigned int dataserver_timeo = NFS4_DEF_DS_TIMEO; 20static unsigned int dataserver_timeo = NFS_DEF_TCP_RETRANS;
21static unsigned int dataserver_retrans = NFS4_DEF_DS_RETRANS; 21static unsigned int dataserver_retrans;
22 22
23void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds) 23void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
24{ 24{
@@ -379,7 +379,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
379 379
380 devid = &mirror->mirror_ds->id_node; 380 devid = &mirror->mirror_ds->id_node;
381 if (ff_layout_test_devid_unavailable(devid)) 381 if (ff_layout_test_devid_unavailable(devid))
382 goto out; 382 goto out_fail;
383 383
384 ds = mirror->mirror_ds->ds; 384 ds = mirror->mirror_ds->ds;
385 /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */ 385 /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */
@@ -405,15 +405,16 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
405 mirror->mirror_ds->ds_versions[0].rsize = max_payload; 405 mirror->mirror_ds->ds_versions[0].rsize = max_payload;
406 if (mirror->mirror_ds->ds_versions[0].wsize > max_payload) 406 if (mirror->mirror_ds->ds_versions[0].wsize > max_payload)
407 mirror->mirror_ds->ds_versions[0].wsize = max_payload; 407 mirror->mirror_ds->ds_versions[0].wsize = max_payload;
408 } else { 408 goto out;
409 ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout),
410 mirror, lseg->pls_range.offset,
411 lseg->pls_range.length, NFS4ERR_NXIO,
412 OP_ILLEGAL, GFP_NOIO);
413 if (fail_return || !ff_layout_has_available_ds(lseg))
414 pnfs_error_mark_layout_for_return(ino, lseg);
415 ds = NULL;
416 } 409 }
410 ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout),
411 mirror, lseg->pls_range.offset,
412 lseg->pls_range.length, NFS4ERR_NXIO,
413 OP_ILLEGAL, GFP_NOIO);
414out_fail:
415 if (fail_return || !ff_layout_has_available_ds(lseg))
416 pnfs_error_mark_layout_for_return(ino, lseg);
417 ds = NULL;
417out: 418out:
418 return ds; 419 return ds;
419} 420}
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7ce5e023c3c3..74935a19e4bf 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -58,6 +58,9 @@ struct nfs_clone_mount {
58 */ 58 */
59#define NFS_UNSPEC_PORT (-1) 59#define NFS_UNSPEC_PORT (-1)
60 60
61#define NFS_UNSPEC_RETRANS (UINT_MAX)
62#define NFS_UNSPEC_TIMEO (UINT_MAX)
63
61/* 64/*
62 * Maximum number of pages that readdir can use for creating 65 * Maximum number of pages that readdir can use for creating
63 * a vmapped array of pages. 66 * a vmapped array of pages.
@@ -156,7 +159,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
156int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *); 159int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
157void nfs_server_insert_lists(struct nfs_server *); 160void nfs_server_insert_lists(struct nfs_server *);
158void nfs_server_remove_lists(struct nfs_server *); 161void nfs_server_remove_lists(struct nfs_server *);
159void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int); 162void nfs_init_timeout_values(struct rpc_timeout *to, int proto, int timeo, int retrans);
160int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t, 163int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t,
161 rpc_authflavor_t); 164 rpc_authflavor_t);
162struct nfs_server *nfs_alloc_server(void); 165struct nfs_server *nfs_alloc_server(void);
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 6f4752734804..64b43b4ad9dd 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -318,10 +318,22 @@ static void
318nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata) 318nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata)
319{ 319{
320 struct nfs42_layoutstat_data *data = calldata; 320 struct nfs42_layoutstat_data *data = calldata;
321 struct nfs_server *server = NFS_SERVER(data->args.inode); 321 struct inode *inode = data->inode;
322 struct nfs_server *server = NFS_SERVER(inode);
323 struct pnfs_layout_hdr *lo;
322 324
325 spin_lock(&inode->i_lock);
326 lo = NFS_I(inode)->layout;
327 if (!pnfs_layout_is_valid(lo)) {
328 spin_unlock(&inode->i_lock);
329 rpc_exit(task, 0);
330 return;
331 }
332 nfs4_stateid_copy(&data->args.stateid, &lo->plh_stateid);
333 spin_unlock(&inode->i_lock);
323 nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args, 334 nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args,
324 &data->res.seq_res, task); 335 &data->res.seq_res, task);
336
325} 337}
326 338
327static void 339static void
@@ -341,11 +353,11 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
341 case -NFS4ERR_ADMIN_REVOKED: 353 case -NFS4ERR_ADMIN_REVOKED:
342 case -NFS4ERR_DELEG_REVOKED: 354 case -NFS4ERR_DELEG_REVOKED:
343 case -NFS4ERR_STALE_STATEID: 355 case -NFS4ERR_STALE_STATEID:
344 case -NFS4ERR_OLD_STATEID:
345 case -NFS4ERR_BAD_STATEID: 356 case -NFS4ERR_BAD_STATEID:
346 spin_lock(&inode->i_lock); 357 spin_lock(&inode->i_lock);
347 lo = NFS_I(inode)->layout; 358 lo = NFS_I(inode)->layout;
348 if (lo && nfs4_stateid_match(&data->args.stateid, 359 if (pnfs_layout_is_valid(lo) &&
360 nfs4_stateid_match(&data->args.stateid,
349 &lo->plh_stateid)) { 361 &lo->plh_stateid)) {
350 LIST_HEAD(head); 362 LIST_HEAD(head);
351 363
@@ -359,11 +371,23 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
359 } else 371 } else
360 spin_unlock(&inode->i_lock); 372 spin_unlock(&inode->i_lock);
361 break; 373 break;
374 case -NFS4ERR_OLD_STATEID:
375 spin_lock(&inode->i_lock);
376 lo = NFS_I(inode)->layout;
377 if (pnfs_layout_is_valid(lo) &&
378 nfs4_stateid_match_other(&data->args.stateid,
379 &lo->plh_stateid)) {
380 /* Do we need to delay before resending? */
381 if (!nfs4_stateid_is_newer(&lo->plh_stateid,
382 &data->args.stateid))
383 rpc_delay(task, HZ);
384 rpc_restart_call_prepare(task);
385 }
386 spin_unlock(&inode->i_lock);
387 break;
362 case -ENOTSUPP: 388 case -ENOTSUPP:
363 case -EOPNOTSUPP: 389 case -EOPNOTSUPP:
364 NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS; 390 NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS;
365 default:
366 break;
367 } 391 }
368 392
369 dprintk("%s server returns %d\n", __func__, task->tk_status); 393 dprintk("%s server returns %d\n", __func__, task->tk_status);
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 8d7d08d4f95f..cd3b7cfdde16 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -817,6 +817,11 @@ static int nfs4_set_client(struct nfs_server *server,
817 goto error; 817 goto error;
818 } 818 }
819 819
820 if (server->nfs_client == clp) {
821 error = -ELOOP;
822 goto error;
823 }
824
820 /* 825 /*
821 * Query for the lease time on clientid setup or renewal 826 * Query for the lease time on clientid setup or renewal
822 * 827 *
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1949bbd806eb..f5aecaabcb7c 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -634,15 +634,11 @@ out_sleep:
634} 634}
635EXPORT_SYMBOL_GPL(nfs40_setup_sequence); 635EXPORT_SYMBOL_GPL(nfs40_setup_sequence);
636 636
637static int nfs40_sequence_done(struct rpc_task *task, 637static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
638 struct nfs4_sequence_res *res)
639{ 638{
640 struct nfs4_slot *slot = res->sr_slot; 639 struct nfs4_slot *slot = res->sr_slot;
641 struct nfs4_slot_table *tbl; 640 struct nfs4_slot_table *tbl;
642 641
643 if (slot == NULL)
644 goto out;
645
646 tbl = slot->table; 642 tbl = slot->table;
647 spin_lock(&tbl->slot_tbl_lock); 643 spin_lock(&tbl->slot_tbl_lock);
648 if (!nfs41_wake_and_assign_slot(tbl, slot)) 644 if (!nfs41_wake_and_assign_slot(tbl, slot))
@@ -650,7 +646,13 @@ static int nfs40_sequence_done(struct rpc_task *task,
650 spin_unlock(&tbl->slot_tbl_lock); 646 spin_unlock(&tbl->slot_tbl_lock);
651 647
652 res->sr_slot = NULL; 648 res->sr_slot = NULL;
653out: 649}
650
651static int nfs40_sequence_done(struct rpc_task *task,
652 struct nfs4_sequence_res *res)
653{
654 if (res->sr_slot != NULL)
655 nfs40_sequence_free_slot(res);
654 return 1; 656 return 1;
655} 657}
656 658
@@ -666,6 +668,11 @@ static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res)
666 tbl = slot->table; 668 tbl = slot->table;
667 session = tbl->session; 669 session = tbl->session;
668 670
671 /* Bump the slot sequence number */
672 if (slot->seq_done)
673 slot->seq_nr++;
674 slot->seq_done = 0;
675
669 spin_lock(&tbl->slot_tbl_lock); 676 spin_lock(&tbl->slot_tbl_lock);
670 /* Be nice to the server: try to ensure that the last transmitted 677 /* Be nice to the server: try to ensure that the last transmitted
671 * value for highest_user_slotid <= target_highest_slotid 678 * value for highest_user_slotid <= target_highest_slotid
@@ -686,9 +693,12 @@ out_unlock:
686 res->sr_slot = NULL; 693 res->sr_slot = NULL;
687 if (send_new_highest_used_slotid) 694 if (send_new_highest_used_slotid)
688 nfs41_notify_server(session->clp); 695 nfs41_notify_server(session->clp);
696 if (waitqueue_active(&tbl->slot_waitq))
697 wake_up_all(&tbl->slot_waitq);
689} 698}
690 699
691int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) 700static int nfs41_sequence_process(struct rpc_task *task,
701 struct nfs4_sequence_res *res)
692{ 702{
693 struct nfs4_session *session; 703 struct nfs4_session *session;
694 struct nfs4_slot *slot = res->sr_slot; 704 struct nfs4_slot *slot = res->sr_slot;
@@ -714,7 +724,7 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
714 switch (res->sr_status) { 724 switch (res->sr_status) {
715 case 0: 725 case 0:
716 /* Update the slot's sequence and clientid lease timer */ 726 /* Update the slot's sequence and clientid lease timer */
717 ++slot->seq_nr; 727 slot->seq_done = 1;
718 clp = session->clp; 728 clp = session->clp;
719 do_renew_lease(clp, res->sr_timestamp); 729 do_renew_lease(clp, res->sr_timestamp);
720 /* Check sequence flags */ 730 /* Check sequence flags */
@@ -769,16 +779,16 @@ int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
769 goto retry_nowait; 779 goto retry_nowait;
770 default: 780 default:
771 /* Just update the slot sequence no. */ 781 /* Just update the slot sequence no. */
772 ++slot->seq_nr; 782 slot->seq_done = 1;
773 } 783 }
774out: 784out:
775 /* The session may be reset by one of the error handlers. */ 785 /* The session may be reset by one of the error handlers. */
776 dprintk("%s: Error %d free the slot \n", __func__, res->sr_status); 786 dprintk("%s: Error %d free the slot \n", __func__, res->sr_status);
777 nfs41_sequence_free_slot(res);
778out_noaction: 787out_noaction:
779 return ret; 788 return ret;
780retry_nowait: 789retry_nowait:
781 if (rpc_restart_call_prepare(task)) { 790 if (rpc_restart_call_prepare(task)) {
791 nfs41_sequence_free_slot(res);
782 task->tk_status = 0; 792 task->tk_status = 0;
783 ret = 0; 793 ret = 0;
784 } 794 }
@@ -789,8 +799,37 @@ out_retry:
789 rpc_delay(task, NFS4_POLL_RETRY_MAX); 799 rpc_delay(task, NFS4_POLL_RETRY_MAX);
790 return 0; 800 return 0;
791} 801}
802
803int nfs41_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
804{
805 if (!nfs41_sequence_process(task, res))
806 return 0;
807 if (res->sr_slot != NULL)
808 nfs41_sequence_free_slot(res);
809 return 1;
810
811}
792EXPORT_SYMBOL_GPL(nfs41_sequence_done); 812EXPORT_SYMBOL_GPL(nfs41_sequence_done);
793 813
814static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
815{
816 if (res->sr_slot == NULL)
817 return 1;
818 if (res->sr_slot->table->session != NULL)
819 return nfs41_sequence_process(task, res);
820 return nfs40_sequence_done(task, res);
821}
822
823static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
824{
825 if (res->sr_slot != NULL) {
826 if (res->sr_slot->table->session != NULL)
827 nfs41_sequence_free_slot(res);
828 else
829 nfs40_sequence_free_slot(res);
830 }
831}
832
794int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res) 833int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
795{ 834{
796 if (res->sr_slot == NULL) 835 if (res->sr_slot == NULL)
@@ -920,6 +959,17 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
920 args, res, task); 959 args, res, task);
921} 960}
922 961
962static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
963{
964 return nfs40_sequence_done(task, res);
965}
966
967static void nfs4_sequence_free_slot(struct nfs4_sequence_res *res)
968{
969 if (res->sr_slot != NULL)
970 nfs40_sequence_free_slot(res);
971}
972
923int nfs4_sequence_done(struct rpc_task *task, 973int nfs4_sequence_done(struct rpc_task *task,
924 struct nfs4_sequence_res *res) 974 struct nfs4_sequence_res *res)
925{ 975{
@@ -1197,6 +1247,7 @@ static void nfs4_opendata_free(struct kref *kref)
1197 struct super_block *sb = p->dentry->d_sb; 1247 struct super_block *sb = p->dentry->d_sb;
1198 1248
1199 nfs_free_seqid(p->o_arg.seqid); 1249 nfs_free_seqid(p->o_arg.seqid);
1250 nfs4_sequence_free_slot(&p->o_res.seq_res);
1200 if (p->state != NULL) 1251 if (p->state != NULL)
1201 nfs4_put_open_state(p->state); 1252 nfs4_put_open_state(p->state);
1202 nfs4_put_state_owner(p->owner); 1253 nfs4_put_state_owner(p->owner);
@@ -1656,9 +1707,14 @@ err:
1656static struct nfs4_state * 1707static struct nfs4_state *
1657nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) 1708nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data)
1658{ 1709{
1710 struct nfs4_state *ret;
1711
1659 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) 1712 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS)
1660 return _nfs4_opendata_reclaim_to_nfs4_state(data); 1713 ret =_nfs4_opendata_reclaim_to_nfs4_state(data);
1661 return _nfs4_opendata_to_nfs4_state(data); 1714 else
1715 ret = _nfs4_opendata_to_nfs4_state(data);
1716 nfs4_sequence_free_slot(&data->o_res.seq_res);
1717 return ret;
1662} 1718}
1663 1719
1664static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) 1720static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state)
@@ -2056,7 +2112,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
2056 2112
2057 data->rpc_status = task->tk_status; 2113 data->rpc_status = task->tk_status;
2058 2114
2059 if (!nfs4_sequence_done(task, &data->o_res.seq_res)) 2115 if (!nfs4_sequence_process(task, &data->o_res.seq_res))
2060 return; 2116 return;
2061 2117
2062 if (task->tk_status == 0) { 2118 if (task->tk_status == 0) {
@@ -7864,7 +7920,7 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)
7864 struct nfs4_layoutget *lgp = calldata; 7920 struct nfs4_layoutget *lgp = calldata;
7865 7921
7866 dprintk("--> %s\n", __func__); 7922 dprintk("--> %s\n", __func__);
7867 nfs41_sequence_done(task, &lgp->res.seq_res); 7923 nfs41_sequence_process(task, &lgp->res.seq_res);
7868 dprintk("<-- %s\n", __func__); 7924 dprintk("<-- %s\n", __func__);
7869} 7925}
7870 7926
@@ -8080,6 +8136,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
8080 /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */ 8136 /* if layoutp->len is 0, nfs4_layoutget_prepare called rpc_exit */
8081 if (status == 0 && lgp->res.layoutp->len) 8137 if (status == 0 && lgp->res.layoutp->len)
8082 lseg = pnfs_layout_process(lgp); 8138 lseg = pnfs_layout_process(lgp);
8139 nfs4_sequence_free_slot(&lgp->res.seq_res);
8083 rpc_put_task(task); 8140 rpc_put_task(task);
8084 dprintk("<-- %s status=%d\n", __func__, status); 8141 dprintk("<-- %s status=%d\n", __func__, status);
8085 if (status) 8142 if (status)
@@ -8106,7 +8163,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
8106 8163
8107 dprintk("--> %s\n", __func__); 8164 dprintk("--> %s\n", __func__);
8108 8165
8109 if (!nfs41_sequence_done(task, &lrp->res.seq_res)) 8166 if (!nfs41_sequence_process(task, &lrp->res.seq_res))
8110 return; 8167 return;
8111 8168
8112 server = NFS_SERVER(lrp->args.inode); 8169 server = NFS_SERVER(lrp->args.inode);
@@ -8118,6 +8175,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
8118 case -NFS4ERR_DELAY: 8175 case -NFS4ERR_DELAY:
8119 if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN) 8176 if (nfs4_async_handle_error(task, server, NULL, NULL) != -EAGAIN)
8120 break; 8177 break;
8178 nfs4_sequence_free_slot(&lrp->res.seq_res);
8121 rpc_restart_call_prepare(task); 8179 rpc_restart_call_prepare(task);
8122 return; 8180 return;
8123 } 8181 }
@@ -8138,6 +8196,7 @@ static void nfs4_layoutreturn_release(void *calldata)
8138 pnfs_set_layout_stateid(lo, &lrp->res.stateid, true); 8196 pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
8139 pnfs_clear_layoutreturn_waitbit(lo); 8197 pnfs_clear_layoutreturn_waitbit(lo);
8140 spin_unlock(&lo->plh_inode->i_lock); 8198 spin_unlock(&lo->plh_inode->i_lock);
8199 nfs4_sequence_free_slot(&lrp->res.seq_res);
8141 pnfs_free_lseg_list(&freeme); 8200 pnfs_free_lseg_list(&freeme);
8142 pnfs_put_layout_hdr(lrp->args.layout); 8201 pnfs_put_layout_hdr(lrp->args.layout);
8143 nfs_iput_and_deactive(lrp->inode); 8202 nfs_iput_and_deactive(lrp->inode);
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c
index 332d06e64fa9..b62973045a3e 100644
--- a/fs/nfs/nfs4session.c
+++ b/fs/nfs/nfs4session.c
@@ -28,6 +28,7 @@ static void nfs4_init_slot_table(struct nfs4_slot_table *tbl, const char *queue)
28 tbl->highest_used_slotid = NFS4_NO_SLOT; 28 tbl->highest_used_slotid = NFS4_NO_SLOT;
29 spin_lock_init(&tbl->slot_tbl_lock); 29 spin_lock_init(&tbl->slot_tbl_lock);
30 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue); 30 rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, queue);
31 init_waitqueue_head(&tbl->slot_waitq);
31 init_completion(&tbl->complete); 32 init_completion(&tbl->complete);
32} 33}
33 34
@@ -172,6 +173,58 @@ struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid)
172 return ERR_PTR(-E2BIG); 173 return ERR_PTR(-E2BIG);
173} 174}
174 175
176static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
177 u32 *seq_nr)
178 __must_hold(&tbl->slot_tbl_lock)
179{
180 struct nfs4_slot *slot;
181
182 slot = nfs4_lookup_slot(tbl, slotid);
183 if (IS_ERR(slot))
184 return PTR_ERR(slot);
185 *seq_nr = slot->seq_nr;
186 return 0;
187}
188
189/*
190 * nfs4_slot_seqid_in_use - test if a slot sequence id is still in use
191 *
192 * Given a slot table, slot id and sequence number, determine if the
193 * RPC call in question is still in flight. This function is mainly
194 * intended for use by the callback channel.
195 */
196static bool nfs4_slot_seqid_in_use(struct nfs4_slot_table *tbl,
197 u32 slotid, u32 seq_nr)
198{
199 u32 cur_seq;
200 bool ret = false;
201
202 spin_lock(&tbl->slot_tbl_lock);
203 if (nfs4_slot_get_seqid(tbl, slotid, &cur_seq) == 0 &&
204 cur_seq == seq_nr && test_bit(slotid, tbl->used_slots))
205 ret = true;
206 spin_unlock(&tbl->slot_tbl_lock);
207 return ret;
208}
209
210/*
211 * nfs4_slot_wait_on_seqid - wait until a slot sequence id is complete
212 *
213 * Given a slot table, slot id and sequence number, wait until the
214 * corresponding RPC call completes. This function is mainly
215 * intended for use by the callback channel.
216 */
217int nfs4_slot_wait_on_seqid(struct nfs4_slot_table *tbl,
218 u32 slotid, u32 seq_nr,
219 unsigned long timeout)
220{
221 if (wait_event_timeout(tbl->slot_waitq,
222 !nfs4_slot_seqid_in_use(tbl, slotid, seq_nr),
223 timeout) == 0)
224 return -ETIMEDOUT;
225 return 0;
226}
227
175/* 228/*
176 * nfs4_alloc_slot - efficiently look for a free slot 229 * nfs4_alloc_slot - efficiently look for a free slot
177 * 230 *
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h
index 5b51298d1d03..f703b755351b 100644
--- a/fs/nfs/nfs4session.h
+++ b/fs/nfs/nfs4session.h
@@ -21,7 +21,8 @@ struct nfs4_slot {
21 unsigned long generation; 21 unsigned long generation;
22 u32 slot_nr; 22 u32 slot_nr;
23 u32 seq_nr; 23 u32 seq_nr;
24 unsigned int interrupted : 1; 24 unsigned int interrupted : 1,
25 seq_done : 1;
25}; 26};
26 27
27/* Sessions */ 28/* Sessions */
@@ -36,6 +37,7 @@ struct nfs4_slot_table {
36 unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */ 37 unsigned long used_slots[SLOT_TABLE_SZ]; /* used/unused bitmap */
37 spinlock_t slot_tbl_lock; 38 spinlock_t slot_tbl_lock;
38 struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */ 39 struct rpc_wait_queue slot_tbl_waitq; /* allocators may wait here */
40 wait_queue_head_t slot_waitq; /* Completion wait on slot */
39 u32 max_slots; /* # slots in table */ 41 u32 max_slots; /* # slots in table */
40 u32 max_slotid; /* Max allowed slotid value */ 42 u32 max_slotid; /* Max allowed slotid value */
41 u32 highest_used_slotid; /* sent to server on each SEQ. 43 u32 highest_used_slotid; /* sent to server on each SEQ.
@@ -78,6 +80,9 @@ extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl,
78extern void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl); 80extern void nfs4_shutdown_slot_table(struct nfs4_slot_table *tbl);
79extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); 81extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl);
80extern struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid); 82extern struct nfs4_slot *nfs4_lookup_slot(struct nfs4_slot_table *tbl, u32 slotid);
83extern int nfs4_slot_wait_on_seqid(struct nfs4_slot_table *tbl,
84 u32 slotid, u32 seq_nr,
85 unsigned long timeout);
81extern bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); 86extern bool nfs4_try_to_lock_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot);
82extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); 87extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot);
83extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); 88extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 70806cae0d36..6daf034645c8 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1555,6 +1555,7 @@ pnfs_update_layout(struct inode *ino,
1555 } 1555 }
1556 1556
1557lookup_again: 1557lookup_again:
1558 nfs4_client_recover_expired_lease(clp);
1558 first = false; 1559 first = false;
1559 spin_lock(&ino->i_lock); 1560 spin_lock(&ino->i_lock);
1560 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags); 1561 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
@@ -2510,7 +2511,6 @@ pnfs_report_layoutstat(struct inode *inode, gfp_t gfp_flags)
2510 2511
2511 data->args.fh = NFS_FH(inode); 2512 data->args.fh = NFS_FH(inode);
2512 data->args.inode = inode; 2513 data->args.inode = inode;
2513 nfs4_stateid_copy(&data->args.stateid, &hdr->plh_stateid);
2514 status = ld->prepare_layoutstats(&data->args); 2514 status = ld->prepare_layoutstats(&data->args);
2515 if (status) 2515 if (status)
2516 goto out_free; 2516 goto out_free;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 18d446e1a82b..d39601381adf 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -923,6 +923,8 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void)
923 923
924 data = kzalloc(sizeof(*data), GFP_KERNEL); 924 data = kzalloc(sizeof(*data), GFP_KERNEL);
925 if (data) { 925 if (data) {
926 data->timeo = NFS_UNSPEC_TIMEO;
927 data->retrans = NFS_UNSPEC_RETRANS;
926 data->acregmin = NFS_DEF_ACREGMIN; 928 data->acregmin = NFS_DEF_ACREGMIN;
927 data->acregmax = NFS_DEF_ACREGMAX; 929 data->acregmax = NFS_DEF_ACREGMAX;
928 data->acdirmin = NFS_DEF_ACDIRMIN; 930 data->acdirmin = NFS_DEF_ACDIRMIN;
@@ -1189,6 +1191,19 @@ static int nfs_get_option_ul(substring_t args[], unsigned long *option)
1189 return rc; 1191 return rc;
1190} 1192}
1191 1193
1194static int nfs_get_option_ul_bound(substring_t args[], unsigned long *option,
1195 unsigned long l_bound, unsigned long u_bound)
1196{
1197 int ret;
1198
1199 ret = nfs_get_option_ul(args, option);
1200 if (ret != 0)
1201 return ret;
1202 if (*option < l_bound || *option > u_bound)
1203 return -ERANGE;
1204 return 0;
1205}
1206
1192/* 1207/*
1193 * Error-check and convert a string of mount options from user space into 1208 * Error-check and convert a string of mount options from user space into
1194 * a data structure. The whole mount string is processed; bad options are 1209 * a data structure. The whole mount string is processed; bad options are
@@ -1352,12 +1367,12 @@ static int nfs_parse_mount_options(char *raw,
1352 mnt->bsize = option; 1367 mnt->bsize = option;
1353 break; 1368 break;
1354 case Opt_timeo: 1369 case Opt_timeo:
1355 if (nfs_get_option_ul(args, &option) || option == 0) 1370 if (nfs_get_option_ul_bound(args, &option, 1, INT_MAX))
1356 goto out_invalid_value; 1371 goto out_invalid_value;
1357 mnt->timeo = option; 1372 mnt->timeo = option;
1358 break; 1373 break;
1359 case Opt_retrans: 1374 case Opt_retrans:
1360 if (nfs_get_option_ul(args, &option) || option == 0) 1375 if (nfs_get_option_ul_bound(args, &option, 0, INT_MAX))
1361 goto out_invalid_value; 1376 goto out_invalid_value;
1362 mnt->retrans = option; 1377 mnt->retrans = option;
1363 break; 1378 break;
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 54e5d6681786..43fdc2765aea 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -80,6 +80,8 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)
80 } 80 }
81 81
82 for (name = buf; name < (buf + list_size); name += strlen(name) + 1) { 82 for (name = buf; name < (buf + list_size); name += strlen(name) + 1) {
83 if (ovl_is_private_xattr(name))
84 continue;
83retry: 85retry:
84 size = vfs_getxattr(old, name, value, value_size); 86 size = vfs_getxattr(old, name, value, value_size);
85 if (size == -ERANGE) 87 if (size == -ERANGE)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 12bcd07b9e32..1560fdc09a5f 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -12,6 +12,8 @@
12#include <linux/xattr.h> 12#include <linux/xattr.h>
13#include <linux/security.h> 13#include <linux/security.h>
14#include <linux/cred.h> 14#include <linux/cred.h>
15#include <linux/posix_acl.h>
16#include <linux/posix_acl_xattr.h>
15#include "overlayfs.h" 17#include "overlayfs.h"
16 18
17void ovl_cleanup(struct inode *wdir, struct dentry *wdentry) 19void ovl_cleanup(struct inode *wdir, struct dentry *wdentry)
@@ -186,6 +188,9 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
186 struct dentry *newdentry; 188 struct dentry *newdentry;
187 int err; 189 int err;
188 190
191 if (!hardlink && !IS_POSIXACL(udir))
192 stat->mode &= ~current_umask();
193
189 inode_lock_nested(udir, I_MUTEX_PARENT); 194 inode_lock_nested(udir, I_MUTEX_PARENT);
190 newdentry = lookup_one_len(dentry->d_name.name, upperdir, 195 newdentry = lookup_one_len(dentry->d_name.name, upperdir,
191 dentry->d_name.len); 196 dentry->d_name.len);
@@ -335,6 +340,32 @@ out_free:
335 return ret; 340 return ret;
336} 341}
337 342
343static int ovl_set_upper_acl(struct dentry *upperdentry, const char *name,
344 const struct posix_acl *acl)
345{
346 void *buffer;
347 size_t size;
348 int err;
349
350 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !acl)
351 return 0;
352
353 size = posix_acl_to_xattr(NULL, acl, NULL, 0);
354 buffer = kmalloc(size, GFP_KERNEL);
355 if (!buffer)
356 return -ENOMEM;
357
358 size = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
359 err = size;
360 if (err < 0)
361 goto out_free;
362
363 err = vfs_setxattr(upperdentry, name, buffer, size, XATTR_CREATE);
364out_free:
365 kfree(buffer);
366 return err;
367}
368
338static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, 369static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
339 struct kstat *stat, const char *link, 370 struct kstat *stat, const char *link,
340 struct dentry *hardlink) 371 struct dentry *hardlink)
@@ -346,10 +377,18 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
346 struct dentry *upper; 377 struct dentry *upper;
347 struct dentry *newdentry; 378 struct dentry *newdentry;
348 int err; 379 int err;
380 struct posix_acl *acl, *default_acl;
349 381
350 if (WARN_ON(!workdir)) 382 if (WARN_ON(!workdir))
351 return -EROFS; 383 return -EROFS;
352 384
385 if (!hardlink) {
386 err = posix_acl_create(dentry->d_parent->d_inode,
387 &stat->mode, &default_acl, &acl);
388 if (err)
389 return err;
390 }
391
353 err = ovl_lock_rename_workdir(workdir, upperdir); 392 err = ovl_lock_rename_workdir(workdir, upperdir);
354 if (err) 393 if (err)
355 goto out; 394 goto out;
@@ -384,6 +423,17 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
384 if (err) 423 if (err)
385 goto out_cleanup; 424 goto out_cleanup;
386 } 425 }
426 if (!hardlink) {
427 err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_ACCESS,
428 acl);
429 if (err)
430 goto out_cleanup;
431
432 err = ovl_set_upper_acl(newdentry, XATTR_NAME_POSIX_ACL_DEFAULT,
433 default_acl);
434 if (err)
435 goto out_cleanup;
436 }
387 437
388 if (!hardlink && S_ISDIR(stat->mode)) { 438 if (!hardlink && S_ISDIR(stat->mode)) {
389 err = ovl_set_opaque(newdentry); 439 err = ovl_set_opaque(newdentry);
@@ -410,6 +460,10 @@ out_dput:
410out_unlock: 460out_unlock:
411 unlock_rename(workdir, upperdir); 461 unlock_rename(workdir, upperdir);
412out: 462out:
463 if (!hardlink) {
464 posix_acl_release(acl);
465 posix_acl_release(default_acl);
466 }
413 return err; 467 return err;
414 468
415out_cleanup: 469out_cleanup:
@@ -950,9 +1004,9 @@ const struct inode_operations ovl_dir_inode_operations = {
950 .permission = ovl_permission, 1004 .permission = ovl_permission,
951 .getattr = ovl_dir_getattr, 1005 .getattr = ovl_dir_getattr,
952 .setxattr = generic_setxattr, 1006 .setxattr = generic_setxattr,
953 .getxattr = ovl_getxattr, 1007 .getxattr = generic_getxattr,
954 .listxattr = ovl_listxattr, 1008 .listxattr = ovl_listxattr,
955 .removexattr = ovl_removexattr, 1009 .removexattr = generic_removexattr,
956 .get_acl = ovl_get_acl, 1010 .get_acl = ovl_get_acl,
957 .update_time = ovl_update_time, 1011 .update_time = ovl_update_time,
958}; 1012};
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 1b885c156028..c75625c1efa3 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -10,6 +10,7 @@
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/slab.h> 11#include <linux/slab.h>
12#include <linux/xattr.h> 12#include <linux/xattr.h>
13#include <linux/posix_acl.h>
13#include "overlayfs.h" 14#include "overlayfs.h"
14 15
15static int ovl_copy_up_truncate(struct dentry *dentry) 16static int ovl_copy_up_truncate(struct dentry *dentry)
@@ -191,32 +192,44 @@ static int ovl_readlink(struct dentry *dentry, char __user *buf, int bufsiz)
191 return err; 192 return err;
192} 193}
193 194
194static bool ovl_is_private_xattr(const char *name) 195bool ovl_is_private_xattr(const char *name)
195{ 196{
196#define OVL_XATTR_PRE_NAME OVL_XATTR_PREFIX "." 197 return strncmp(name, OVL_XATTR_PREFIX,
197 return strncmp(name, OVL_XATTR_PRE_NAME, 198 sizeof(OVL_XATTR_PREFIX) - 1) == 0;
198 sizeof(OVL_XATTR_PRE_NAME) - 1) == 0;
199} 199}
200 200
201int ovl_setxattr(struct dentry *dentry, struct inode *inode, 201int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
202 const char *name, const void *value, 202 size_t size, int flags)
203 size_t size, int flags)
204{ 203{
205 int err; 204 int err;
206 struct dentry *upperdentry; 205 struct path realpath;
206 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
207 const struct cred *old_cred; 207 const struct cred *old_cred;
208 208
209 err = ovl_want_write(dentry); 209 err = ovl_want_write(dentry);
210 if (err) 210 if (err)
211 goto out; 211 goto out;
212 212
213 if (!value && !OVL_TYPE_UPPER(type)) {
214 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
215 if (err < 0)
216 goto out_drop_write;
217 }
218
213 err = ovl_copy_up(dentry); 219 err = ovl_copy_up(dentry);
214 if (err) 220 if (err)
215 goto out_drop_write; 221 goto out_drop_write;
216 222
217 upperdentry = ovl_dentry_upper(dentry); 223 if (!OVL_TYPE_UPPER(type))
224 ovl_path_upper(dentry, &realpath);
225
218 old_cred = ovl_override_creds(dentry->d_sb); 226 old_cred = ovl_override_creds(dentry->d_sb);
219 err = vfs_setxattr(upperdentry, name, value, size, flags); 227 if (value)
228 err = vfs_setxattr(realpath.dentry, name, value, size, flags);
229 else {
230 WARN_ON(flags != XATTR_REPLACE);
231 err = vfs_removexattr(realpath.dentry, name);
232 }
220 revert_creds(old_cred); 233 revert_creds(old_cred);
221 234
222out_drop_write: 235out_drop_write:
@@ -225,16 +238,13 @@ out:
225 return err; 238 return err;
226} 239}
227 240
228ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, 241int ovl_xattr_get(struct dentry *dentry, const char *name,
229 const char *name, void *value, size_t size) 242 void *value, size_t size)
230{ 243{
231 struct dentry *realdentry = ovl_dentry_real(dentry); 244 struct dentry *realdentry = ovl_dentry_real(dentry);
232 ssize_t res; 245 ssize_t res;
233 const struct cred *old_cred; 246 const struct cred *old_cred;
234 247
235 if (ovl_is_private_xattr(name))
236 return -ENODATA;
237
238 old_cred = ovl_override_creds(dentry->d_sb); 248 old_cred = ovl_override_creds(dentry->d_sb);
239 res = vfs_getxattr(realdentry, name, value, size); 249 res = vfs_getxattr(realdentry, name, value, size);
240 revert_creds(old_cred); 250 revert_creds(old_cred);
@@ -245,7 +255,8 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
245{ 255{
246 struct dentry *realdentry = ovl_dentry_real(dentry); 256 struct dentry *realdentry = ovl_dentry_real(dentry);
247 ssize_t res; 257 ssize_t res;
248 int off; 258 size_t len;
259 char *s;
249 const struct cred *old_cred; 260 const struct cred *old_cred;
250 261
251 old_cred = ovl_override_creds(dentry->d_sb); 262 old_cred = ovl_override_creds(dentry->d_sb);
@@ -255,73 +266,39 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
255 return res; 266 return res;
256 267
257 /* filter out private xattrs */ 268 /* filter out private xattrs */
258 for (off = 0; off < res;) { 269 for (s = list, len = res; len;) {
259 char *s = list + off; 270 size_t slen = strnlen(s, len) + 1;
260 size_t slen = strlen(s) + 1;
261 271
262 BUG_ON(off + slen > res); 272 /* underlying fs providing us with an broken xattr list? */
273 if (WARN_ON(slen > len))
274 return -EIO;
263 275
276 len -= slen;
264 if (ovl_is_private_xattr(s)) { 277 if (ovl_is_private_xattr(s)) {
265 res -= slen; 278 res -= slen;
266 memmove(s, s + slen, res - off); 279 memmove(s, s + slen, len);
267 } else { 280 } else {
268 off += slen; 281 s += slen;
269 } 282 }
270 } 283 }
271 284
272 return res; 285 return res;
273} 286}
274 287
275int ovl_removexattr(struct dentry *dentry, const char *name)
276{
277 int err;
278 struct path realpath;
279 enum ovl_path_type type = ovl_path_real(dentry, &realpath);
280 const struct cred *old_cred;
281
282 err = ovl_want_write(dentry);
283 if (err)
284 goto out;
285
286 err = -ENODATA;
287 if (ovl_is_private_xattr(name))
288 goto out_drop_write;
289
290 if (!OVL_TYPE_UPPER(type)) {
291 err = vfs_getxattr(realpath.dentry, name, NULL, 0);
292 if (err < 0)
293 goto out_drop_write;
294
295 err = ovl_copy_up(dentry);
296 if (err)
297 goto out_drop_write;
298
299 ovl_path_upper(dentry, &realpath);
300 }
301
302 old_cred = ovl_override_creds(dentry->d_sb);
303 err = vfs_removexattr(realpath.dentry, name);
304 revert_creds(old_cred);
305out_drop_write:
306 ovl_drop_write(dentry);
307out:
308 return err;
309}
310
311struct posix_acl *ovl_get_acl(struct inode *inode, int type) 288struct posix_acl *ovl_get_acl(struct inode *inode, int type)
312{ 289{
313 struct inode *realinode = ovl_inode_real(inode, NULL); 290 struct inode *realinode = ovl_inode_real(inode, NULL);
314 const struct cred *old_cred; 291 const struct cred *old_cred;
315 struct posix_acl *acl; 292 struct posix_acl *acl;
316 293
317 if (!IS_POSIXACL(realinode)) 294 if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
318 return NULL; 295 return NULL;
319 296
320 if (!realinode->i_op->get_acl) 297 if (!realinode->i_op->get_acl)
321 return NULL; 298 return NULL;
322 299
323 old_cred = ovl_override_creds(inode->i_sb); 300 old_cred = ovl_override_creds(inode->i_sb);
324 acl = realinode->i_op->get_acl(realinode, type); 301 acl = get_acl(realinode, type);
325 revert_creds(old_cred); 302 revert_creds(old_cred);
326 303
327 return acl; 304 return acl;
@@ -391,9 +368,9 @@ static const struct inode_operations ovl_file_inode_operations = {
391 .permission = ovl_permission, 368 .permission = ovl_permission,
392 .getattr = ovl_getattr, 369 .getattr = ovl_getattr,
393 .setxattr = generic_setxattr, 370 .setxattr = generic_setxattr,
394 .getxattr = ovl_getxattr, 371 .getxattr = generic_getxattr,
395 .listxattr = ovl_listxattr, 372 .listxattr = ovl_listxattr,
396 .removexattr = ovl_removexattr, 373 .removexattr = generic_removexattr,
397 .get_acl = ovl_get_acl, 374 .get_acl = ovl_get_acl,
398 .update_time = ovl_update_time, 375 .update_time = ovl_update_time,
399}; 376};
@@ -404,9 +381,9 @@ static const struct inode_operations ovl_symlink_inode_operations = {
404 .readlink = ovl_readlink, 381 .readlink = ovl_readlink,
405 .getattr = ovl_getattr, 382 .getattr = ovl_getattr,
406 .setxattr = generic_setxattr, 383 .setxattr = generic_setxattr,
407 .getxattr = ovl_getxattr, 384 .getxattr = generic_getxattr,
408 .listxattr = ovl_listxattr, 385 .listxattr = ovl_listxattr,
409 .removexattr = ovl_removexattr, 386 .removexattr = generic_removexattr,
410 .update_time = ovl_update_time, 387 .update_time = ovl_update_time,
411}; 388};
412 389
@@ -415,6 +392,9 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode)
415 inode->i_ino = get_next_ino(); 392 inode->i_ino = get_next_ino();
416 inode->i_mode = mode; 393 inode->i_mode = mode;
417 inode->i_flags |= S_NOCMTIME; 394 inode->i_flags |= S_NOCMTIME;
395#ifdef CONFIG_FS_POSIX_ACL
396 inode->i_acl = inode->i_default_acl = ACL_DONT_CACHE;
397#endif
418 398
419 mode &= S_IFMT; 399 mode &= S_IFMT;
420 switch (mode) { 400 switch (mode) {
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index e4f5c9536bfe..5813ccff8cd9 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -24,8 +24,8 @@ enum ovl_path_type {
24 (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type)) 24 (OVL_TYPE_MERGE(type) || !OVL_TYPE_UPPER(type))
25 25
26 26
27#define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay" 27#define OVL_XATTR_PREFIX XATTR_TRUSTED_PREFIX "overlay."
28#define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX ".opaque" 28#define OVL_XATTR_OPAQUE OVL_XATTR_PREFIX "opaque"
29 29
30#define OVL_ISUPPER_MASK 1UL 30#define OVL_ISUPPER_MASK 1UL
31 31
@@ -179,20 +179,21 @@ int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list);
179void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list); 179void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list);
180void ovl_cache_free(struct list_head *list); 180void ovl_cache_free(struct list_head *list);
181int ovl_check_d_type_supported(struct path *realpath); 181int ovl_check_d_type_supported(struct path *realpath);
182void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
183 struct dentry *dentry, int level);
182 184
183/* inode.c */ 185/* inode.c */
184int ovl_setattr(struct dentry *dentry, struct iattr *attr); 186int ovl_setattr(struct dentry *dentry, struct iattr *attr);
185int ovl_permission(struct inode *inode, int mask); 187int ovl_permission(struct inode *inode, int mask);
186int ovl_setxattr(struct dentry *dentry, struct inode *inode, 188int ovl_xattr_set(struct dentry *dentry, const char *name, const void *value,
187 const char *name, const void *value, 189 size_t size, int flags);
188 size_t size, int flags); 190int ovl_xattr_get(struct dentry *dentry, const char *name,
189ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode, 191 void *value, size_t size);
190 const char *name, void *value, size_t size);
191ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size); 192ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
192int ovl_removexattr(struct dentry *dentry, const char *name);
193struct posix_acl *ovl_get_acl(struct inode *inode, int type); 193struct posix_acl *ovl_get_acl(struct inode *inode, int type);
194int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); 194int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags);
195int ovl_update_time(struct inode *inode, struct timespec *ts, int flags); 195int ovl_update_time(struct inode *inode, struct timespec *ts, int flags);
196bool ovl_is_private_xattr(const char *name);
196 197
197struct inode *ovl_new_inode(struct super_block *sb, umode_t mode); 198struct inode *ovl_new_inode(struct super_block *sb, umode_t mode);
198struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode); 199struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode);
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index cf37fc76fc9f..f241b4ee3d8a 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -248,7 +248,7 @@ static inline int ovl_dir_read(struct path *realpath,
248 err = rdd->err; 248 err = rdd->err;
249 } while (!err && rdd->count); 249 } while (!err && rdd->count);
250 250
251 if (!err && rdd->first_maybe_whiteout) 251 if (!err && rdd->first_maybe_whiteout && rdd->dentry)
252 err = ovl_check_whiteouts(realpath->dentry, rdd); 252 err = ovl_check_whiteouts(realpath->dentry, rdd);
253 253
254 fput(realfile); 254 fput(realfile);
@@ -606,3 +606,64 @@ int ovl_check_d_type_supported(struct path *realpath)
606 606
607 return rdd.d_type_supported; 607 return rdd.d_type_supported;
608} 608}
609
610static void ovl_workdir_cleanup_recurse(struct path *path, int level)
611{
612 int err;
613 struct inode *dir = path->dentry->d_inode;
614 LIST_HEAD(list);
615 struct ovl_cache_entry *p;
616 struct ovl_readdir_data rdd = {
617 .ctx.actor = ovl_fill_merge,
618 .dentry = NULL,
619 .list = &list,
620 .root = RB_ROOT,
621 .is_lowest = false,
622 };
623
624 err = ovl_dir_read(path, &rdd);
625 if (err)
626 goto out;
627
628 inode_lock_nested(dir, I_MUTEX_PARENT);
629 list_for_each_entry(p, &list, l_node) {
630 struct dentry *dentry;
631
632 if (p->name[0] == '.') {
633 if (p->len == 1)
634 continue;
635 if (p->len == 2 && p->name[1] == '.')
636 continue;
637 }
638 dentry = lookup_one_len(p->name, path->dentry, p->len);
639 if (IS_ERR(dentry))
640 continue;
641 if (dentry->d_inode)
642 ovl_workdir_cleanup(dir, path->mnt, dentry, level);
643 dput(dentry);
644 }
645 inode_unlock(dir);
646out:
647 ovl_cache_free(&list);
648}
649
650void ovl_workdir_cleanup(struct inode *dir, struct vfsmount *mnt,
651 struct dentry *dentry, int level)
652{
653 int err;
654
655 if (!d_is_dir(dentry) || level > 1) {
656 ovl_cleanup(dir, dentry);
657 return;
658 }
659
660 err = ovl_do_rmdir(dir, dentry);
661 if (err) {
662 struct path path = { .mnt = mnt, .dentry = dentry };
663
664 inode_unlock(dir);
665 ovl_workdir_cleanup_recurse(&path, level + 1);
666 inode_lock_nested(dir, I_MUTEX_PARENT);
667 ovl_cleanup(dir, dentry);
668 }
669}
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 4036132842b5..a4585f961bf9 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -814,6 +814,10 @@ retry:
814 struct kstat stat = { 814 struct kstat stat = {
815 .mode = S_IFDIR | 0, 815 .mode = S_IFDIR | 0,
816 }; 816 };
817 struct iattr attr = {
818 .ia_valid = ATTR_MODE,
819 .ia_mode = stat.mode,
820 };
817 821
818 if (work->d_inode) { 822 if (work->d_inode) {
819 err = -EEXIST; 823 err = -EEXIST;
@@ -821,7 +825,7 @@ retry:
821 goto out_dput; 825 goto out_dput;
822 826
823 retried = true; 827 retried = true;
824 ovl_cleanup(dir, work); 828 ovl_workdir_cleanup(dir, mnt, work, 0);
825 dput(work); 829 dput(work);
826 goto retry; 830 goto retry;
827 } 831 }
@@ -829,6 +833,21 @@ retry:
829 err = ovl_create_real(dir, work, &stat, NULL, NULL, true); 833 err = ovl_create_real(dir, work, &stat, NULL, NULL, true);
830 if (err) 834 if (err)
831 goto out_dput; 835 goto out_dput;
836
837 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_DEFAULT);
838 if (err && err != -ENODATA)
839 goto out_dput;
840
841 err = vfs_removexattr(work, XATTR_NAME_POSIX_ACL_ACCESS);
842 if (err && err != -ENODATA)
843 goto out_dput;
844
845 /* Clear any inherited mode bits */
846 inode_lock(work->d_inode);
847 err = notify_change(work, &attr, NULL);
848 inode_unlock(work->d_inode);
849 if (err)
850 goto out_dput;
832 } 851 }
833out_unlock: 852out_unlock:
834 inode_unlock(dir); 853 inode_unlock(dir);
@@ -967,10 +986,19 @@ static unsigned int ovl_split_lowerdirs(char *str)
967 return ctr; 986 return ctr;
968} 987}
969 988
970static int ovl_posix_acl_xattr_set(const struct xattr_handler *handler, 989static int __maybe_unused
971 struct dentry *dentry, struct inode *inode, 990ovl_posix_acl_xattr_get(const struct xattr_handler *handler,
972 const char *name, const void *value, 991 struct dentry *dentry, struct inode *inode,
973 size_t size, int flags) 992 const char *name, void *buffer, size_t size)
993{
994 return ovl_xattr_get(dentry, handler->name, buffer, size);
995}
996
997static int __maybe_unused
998ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
999 struct dentry *dentry, struct inode *inode,
1000 const char *name, const void *value,
1001 size_t size, int flags)
974{ 1002{
975 struct dentry *workdir = ovl_workdir(dentry); 1003 struct dentry *workdir = ovl_workdir(dentry);
976 struct inode *realinode = ovl_inode_real(inode, NULL); 1004 struct inode *realinode = ovl_inode_real(inode, NULL);
@@ -998,19 +1026,22 @@ static int ovl_posix_acl_xattr_set(const struct xattr_handler *handler,
998 1026
999 posix_acl_release(acl); 1027 posix_acl_release(acl);
1000 1028
1001 return ovl_setxattr(dentry, inode, handler->name, value, size, flags); 1029 err = ovl_xattr_set(dentry, handler->name, value, size, flags);
1030 if (!err)
1031 ovl_copyattr(ovl_inode_real(inode, NULL), inode);
1032
1033 return err;
1002 1034
1003out_acl_release: 1035out_acl_release:
1004 posix_acl_release(acl); 1036 posix_acl_release(acl);
1005 return err; 1037 return err;
1006} 1038}
1007 1039
1008static int ovl_other_xattr_set(const struct xattr_handler *handler, 1040static int ovl_own_xattr_get(const struct xattr_handler *handler,
1009 struct dentry *dentry, struct inode *inode, 1041 struct dentry *dentry, struct inode *inode,
1010 const char *name, const void *value, 1042 const char *name, void *buffer, size_t size)
1011 size_t size, int flags)
1012{ 1043{
1013 return ovl_setxattr(dentry, inode, name, value, size, flags); 1044 return -EPERM;
1014} 1045}
1015 1046
1016static int ovl_own_xattr_set(const struct xattr_handler *handler, 1047static int ovl_own_xattr_set(const struct xattr_handler *handler,
@@ -1021,42 +1052,59 @@ static int ovl_own_xattr_set(const struct xattr_handler *handler,
1021 return -EPERM; 1052 return -EPERM;
1022} 1053}
1023 1054
1024static const struct xattr_handler ovl_posix_acl_access_xattr_handler = { 1055static int ovl_other_xattr_get(const struct xattr_handler *handler,
1056 struct dentry *dentry, struct inode *inode,
1057 const char *name, void *buffer, size_t size)
1058{
1059 return ovl_xattr_get(dentry, name, buffer, size);
1060}
1061
1062static int ovl_other_xattr_set(const struct xattr_handler *handler,
1063 struct dentry *dentry, struct inode *inode,
1064 const char *name, const void *value,
1065 size_t size, int flags)
1066{
1067 return ovl_xattr_set(dentry, name, value, size, flags);
1068}
1069
1070static const struct xattr_handler __maybe_unused
1071ovl_posix_acl_access_xattr_handler = {
1025 .name = XATTR_NAME_POSIX_ACL_ACCESS, 1072 .name = XATTR_NAME_POSIX_ACL_ACCESS,
1026 .flags = ACL_TYPE_ACCESS, 1073 .flags = ACL_TYPE_ACCESS,
1074 .get = ovl_posix_acl_xattr_get,
1027 .set = ovl_posix_acl_xattr_set, 1075 .set = ovl_posix_acl_xattr_set,
1028}; 1076};
1029 1077
1030static const struct xattr_handler ovl_posix_acl_default_xattr_handler = { 1078static const struct xattr_handler __maybe_unused
1079ovl_posix_acl_default_xattr_handler = {
1031 .name = XATTR_NAME_POSIX_ACL_DEFAULT, 1080 .name = XATTR_NAME_POSIX_ACL_DEFAULT,
1032 .flags = ACL_TYPE_DEFAULT, 1081 .flags = ACL_TYPE_DEFAULT,
1082 .get = ovl_posix_acl_xattr_get,
1033 .set = ovl_posix_acl_xattr_set, 1083 .set = ovl_posix_acl_xattr_set,
1034}; 1084};
1035 1085
1036static const struct xattr_handler ovl_own_xattr_handler = { 1086static const struct xattr_handler ovl_own_xattr_handler = {
1037 .prefix = OVL_XATTR_PREFIX, 1087 .prefix = OVL_XATTR_PREFIX,
1088 .get = ovl_own_xattr_get,
1038 .set = ovl_own_xattr_set, 1089 .set = ovl_own_xattr_set,
1039}; 1090};
1040 1091
1041static const struct xattr_handler ovl_other_xattr_handler = { 1092static const struct xattr_handler ovl_other_xattr_handler = {
1042 .prefix = "", /* catch all */ 1093 .prefix = "", /* catch all */
1094 .get = ovl_other_xattr_get,
1043 .set = ovl_other_xattr_set, 1095 .set = ovl_other_xattr_set,
1044}; 1096};
1045 1097
1046static const struct xattr_handler *ovl_xattr_handlers[] = { 1098static const struct xattr_handler *ovl_xattr_handlers[] = {
1099#ifdef CONFIG_FS_POSIX_ACL
1047 &ovl_posix_acl_access_xattr_handler, 1100 &ovl_posix_acl_access_xattr_handler,
1048 &ovl_posix_acl_default_xattr_handler, 1101 &ovl_posix_acl_default_xattr_handler,
1102#endif
1049 &ovl_own_xattr_handler, 1103 &ovl_own_xattr_handler,
1050 &ovl_other_xattr_handler, 1104 &ovl_other_xattr_handler,
1051 NULL 1105 NULL
1052}; 1106};
1053 1107
1054static const struct xattr_handler *ovl_xattr_noacl_handlers[] = {
1055 &ovl_own_xattr_handler,
1056 &ovl_other_xattr_handler,
1057 NULL,
1058};
1059
1060static int ovl_fill_super(struct super_block *sb, void *data, int silent) 1108static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1061{ 1109{
1062 struct path upperpath = { NULL, NULL }; 1110 struct path upperpath = { NULL, NULL };
@@ -1132,7 +1180,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1132 err = -EINVAL; 1180 err = -EINVAL;
1133 stacklen = ovl_split_lowerdirs(lowertmp); 1181 stacklen = ovl_split_lowerdirs(lowertmp);
1134 if (stacklen > OVL_MAX_STACK) { 1182 if (stacklen > OVL_MAX_STACK) {
1135 pr_err("overlayfs: too many lower directries, limit is %d\n", 1183 pr_err("overlayfs: too many lower directories, limit is %d\n",
1136 OVL_MAX_STACK); 1184 OVL_MAX_STACK);
1137 goto out_free_lowertmp; 1185 goto out_free_lowertmp;
1138 } else if (!ufs->config.upperdir && stacklen == 1) { 1186 } else if (!ufs->config.upperdir && stacklen == 1) {
@@ -1269,10 +1317,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
1269 1317
1270 sb->s_magic = OVERLAYFS_SUPER_MAGIC; 1318 sb->s_magic = OVERLAYFS_SUPER_MAGIC;
1271 sb->s_op = &ovl_super_operations; 1319 sb->s_op = &ovl_super_operations;
1272 if (IS_ENABLED(CONFIG_FS_POSIX_ACL)) 1320 sb->s_xattr = ovl_xattr_handlers;
1273 sb->s_xattr = ovl_xattr_handlers;
1274 else
1275 sb->s_xattr = ovl_xattr_noacl_handlers;
1276 sb->s_root = root_dentry; 1321 sb->s_root = root_dentry;
1277 sb->s_fs_info = ufs; 1322 sb->s_fs_info = ufs;
1278 sb->s_flags |= MS_POSIXACL; 1323 sb->s_flags |= MS_POSIXACL;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 54e270262979..ac0df4dde823 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1556,18 +1556,13 @@ static const struct file_operations proc_pid_set_comm_operations = {
1556static int proc_exe_link(struct dentry *dentry, struct path *exe_path) 1556static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
1557{ 1557{
1558 struct task_struct *task; 1558 struct task_struct *task;
1559 struct mm_struct *mm;
1560 struct file *exe_file; 1559 struct file *exe_file;
1561 1560
1562 task = get_proc_task(d_inode(dentry)); 1561 task = get_proc_task(d_inode(dentry));
1563 if (!task) 1562 if (!task)
1564 return -ENOENT; 1563 return -ENOENT;
1565 mm = get_task_mm(task); 1564 exe_file = get_task_exe_file(task);
1566 put_task_struct(task); 1565 put_task_struct(task);
1567 if (!mm)
1568 return -ENOENT;
1569 exe_file = get_mm_exe_file(mm);
1570 mmput(mm);
1571 if (exe_file) { 1566 if (exe_file) {
1572 *exe_path = exe_file->f_path; 1567 *exe_path = exe_file->f_path;
1573 path_get(&exe_file->f_path); 1568 path_get(&exe_file->f_path);
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index f35523d4fa3a..b803213d1307 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -114,9 +114,15 @@ static ssize_t sysfs_kf_read(struct kernfs_open_file *of, char *buf,
114 * If buf != of->prealloc_buf, we don't know how 114 * If buf != of->prealloc_buf, we don't know how
115 * large it is, so cannot safely pass it to ->show 115 * large it is, so cannot safely pass it to ->show
116 */ 116 */
117 if (pos || WARN_ON_ONCE(buf != of->prealloc_buf)) 117 if (WARN_ON_ONCE(buf != of->prealloc_buf))
118 return 0; 118 return 0;
119 len = ops->show(kobj, of->kn->priv, buf); 119 len = ops->show(kobj, of->kn->priv, buf);
120 if (pos) {
121 if (len <= pos)
122 return 0;
123 len -= pos;
124 memmove(buf, buf + pos, len);
125 }
120 return min(count, len); 126 return min(count, len);
121} 127}
122 128
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 3dd8f1d54498..05b5243d89f6 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -2278,6 +2278,8 @@ xfs_alloc_log_agf(
2278 offsetof(xfs_agf_t, agf_btreeblks), 2278 offsetof(xfs_agf_t, agf_btreeblks),
2279 offsetof(xfs_agf_t, agf_uuid), 2279 offsetof(xfs_agf_t, agf_uuid),
2280 offsetof(xfs_agf_t, agf_rmap_blocks), 2280 offsetof(xfs_agf_t, agf_rmap_blocks),
2281 /* needed so that we don't log the whole rest of the structure: */
2282 offsetof(xfs_agf_t, agf_spare64),
2281 sizeof(xfs_agf_t) 2283 sizeof(xfs_agf_t)
2282 }; 2284 };
2283 2285
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index b5c213a051cd..08569792fe20 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -1814,6 +1814,10 @@ xfs_btree_lookup(
1814 1814
1815 XFS_BTREE_STATS_INC(cur, lookup); 1815 XFS_BTREE_STATS_INC(cur, lookup);
1816 1816
1817 /* No such thing as a zero-level tree. */
1818 if (cur->bc_nlevels == 0)
1819 return -EFSCORRUPTED;
1820
1817 block = NULL; 1821 block = NULL;
1818 keyno = 0; 1822 keyno = 0;
1819 1823
@@ -4554,15 +4558,22 @@ xfs_btree_simple_query_range(
4554 if (error) 4558 if (error)
4555 goto out; 4559 goto out;
4556 4560
4561 /* Nothing? See if there's anything to the right. */
4562 if (!stat) {
4563 error = xfs_btree_increment(cur, 0, &stat);
4564 if (error)
4565 goto out;
4566 }
4567
4557 while (stat) { 4568 while (stat) {
4558 /* Find the record. */ 4569 /* Find the record. */
4559 error = xfs_btree_get_rec(cur, &recp, &stat); 4570 error = xfs_btree_get_rec(cur, &recp, &stat);
4560 if (error || !stat) 4571 if (error || !stat)
4561 break; 4572 break;
4562 cur->bc_ops->init_high_key_from_rec(&rec_key, recp);
4563 4573
4564 /* Skip if high_key(rec) < low_key. */ 4574 /* Skip if high_key(rec) < low_key. */
4565 if (firstrec) { 4575 if (firstrec) {
4576 cur->bc_ops->init_high_key_from_rec(&rec_key, recp);
4566 firstrec = false; 4577 firstrec = false;
4567 diff = cur->bc_ops->diff_two_keys(cur, low_key, 4578 diff = cur->bc_ops->diff_two_keys(cur, low_key,
4568 &rec_key); 4579 &rec_key);
@@ -4571,6 +4582,7 @@ xfs_btree_simple_query_range(
4571 } 4582 }
4572 4583
4573 /* Stop if high_key < low_key(rec). */ 4584 /* Stop if high_key < low_key(rec). */
4585 cur->bc_ops->init_key_from_rec(&rec_key, recp);
4574 diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key); 4586 diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key);
4575 if (diff > 0) 4587 if (diff > 0)
4576 break; 4588 break;
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 054a2032fdb3..c221d0ecd52e 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -194,7 +194,7 @@ xfs_defer_trans_abort(
194 /* Abort intent items. */ 194 /* Abort intent items. */
195 list_for_each_entry(dfp, &dop->dop_pending, dfp_list) { 195 list_for_each_entry(dfp, &dop->dop_pending, dfp_list) {
196 trace_xfs_defer_pending_abort(tp->t_mountp, dfp); 196 trace_xfs_defer_pending_abort(tp->t_mountp, dfp);
197 if (dfp->dfp_committed) 197 if (!dfp->dfp_done)
198 dfp->dfp_type->abort_intent(dfp->dfp_intent); 198 dfp->dfp_type->abort_intent(dfp->dfp_intent);
199 } 199 }
200 200
@@ -290,7 +290,6 @@ xfs_defer_finish(
290 struct xfs_defer_pending *dfp; 290 struct xfs_defer_pending *dfp;
291 struct list_head *li; 291 struct list_head *li;
292 struct list_head *n; 292 struct list_head *n;
293 void *done_item = NULL;
294 void *state; 293 void *state;
295 int error = 0; 294 int error = 0;
296 void (*cleanup_fn)(struct xfs_trans *, void *, int); 295 void (*cleanup_fn)(struct xfs_trans *, void *, int);
@@ -309,19 +308,11 @@ xfs_defer_finish(
309 if (error) 308 if (error)
310 goto out; 309 goto out;
311 310
312 /* Mark all pending intents as committed. */
313 list_for_each_entry_reverse(dfp, &dop->dop_pending, dfp_list) {
314 if (dfp->dfp_committed)
315 break;
316 trace_xfs_defer_pending_commit((*tp)->t_mountp, dfp);
317 dfp->dfp_committed = true;
318 }
319
320 /* Log an intent-done item for the first pending item. */ 311 /* Log an intent-done item for the first pending item. */
321 dfp = list_first_entry(&dop->dop_pending, 312 dfp = list_first_entry(&dop->dop_pending,
322 struct xfs_defer_pending, dfp_list); 313 struct xfs_defer_pending, dfp_list);
323 trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp); 314 trace_xfs_defer_pending_finish((*tp)->t_mountp, dfp);
324 done_item = dfp->dfp_type->create_done(*tp, dfp->dfp_intent, 315 dfp->dfp_done = dfp->dfp_type->create_done(*tp, dfp->dfp_intent,
325 dfp->dfp_count); 316 dfp->dfp_count);
326 cleanup_fn = dfp->dfp_type->finish_cleanup; 317 cleanup_fn = dfp->dfp_type->finish_cleanup;
327 318
@@ -331,7 +322,7 @@ xfs_defer_finish(
331 list_del(li); 322 list_del(li);
332 dfp->dfp_count--; 323 dfp->dfp_count--;
333 error = dfp->dfp_type->finish_item(*tp, dop, li, 324 error = dfp->dfp_type->finish_item(*tp, dop, li,
334 done_item, &state); 325 dfp->dfp_done, &state);
335 if (error) { 326 if (error) {
336 /* 327 /*
337 * Clean up after ourselves and jump out. 328 * Clean up after ourselves and jump out.
@@ -428,8 +419,8 @@ xfs_defer_add(
428 dfp = kmem_alloc(sizeof(struct xfs_defer_pending), 419 dfp = kmem_alloc(sizeof(struct xfs_defer_pending),
429 KM_SLEEP | KM_NOFS); 420 KM_SLEEP | KM_NOFS);
430 dfp->dfp_type = defer_op_types[type]; 421 dfp->dfp_type = defer_op_types[type];
431 dfp->dfp_committed = false;
432 dfp->dfp_intent = NULL; 422 dfp->dfp_intent = NULL;
423 dfp->dfp_done = NULL;
433 dfp->dfp_count = 0; 424 dfp->dfp_count = 0;
434 INIT_LIST_HEAD(&dfp->dfp_work); 425 INIT_LIST_HEAD(&dfp->dfp_work);
435 list_add_tail(&dfp->dfp_list, &dop->dop_intake); 426 list_add_tail(&dfp->dfp_list, &dop->dop_intake);
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index cc3981c48296..e96533d178cf 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -30,8 +30,8 @@ struct xfs_defer_op_type;
30struct xfs_defer_pending { 30struct xfs_defer_pending {
31 const struct xfs_defer_op_type *dfp_type; /* function pointers */ 31 const struct xfs_defer_op_type *dfp_type; /* function pointers */
32 struct list_head dfp_list; /* pending items */ 32 struct list_head dfp_list; /* pending items */
33 bool dfp_committed; /* committed trans? */
34 void *dfp_intent; /* log intent item */ 33 void *dfp_intent; /* log intent item */
34 void *dfp_done; /* log done item */
35 struct list_head dfp_work; /* work items */ 35 struct list_head dfp_work; /* work items */
36 unsigned int dfp_count; /* # extent items */ 36 unsigned int dfp_count; /* # extent items */
37}; 37};
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index e6a8bea0f7ba..270fb5cf4fa1 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -674,7 +674,8 @@ typedef struct xfs_agf {
674#define XFS_AGF_BTREEBLKS 0x00000800 674#define XFS_AGF_BTREEBLKS 0x00000800
675#define XFS_AGF_UUID 0x00001000 675#define XFS_AGF_UUID 0x00001000
676#define XFS_AGF_RMAP_BLOCKS 0x00002000 676#define XFS_AGF_RMAP_BLOCKS 0x00002000
677#define XFS_AGF_NUM_BITS 14 677#define XFS_AGF_SPARE64 0x00004000
678#define XFS_AGF_NUM_BITS 15
678#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) 679#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
679 680
680#define XFS_AGF_FLAGS \ 681#define XFS_AGF_FLAGS \
@@ -691,7 +692,8 @@ typedef struct xfs_agf {
691 { XFS_AGF_LONGEST, "LONGEST" }, \ 692 { XFS_AGF_LONGEST, "LONGEST" }, \
692 { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ 693 { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \
693 { XFS_AGF_UUID, "UUID" }, \ 694 { XFS_AGF_UUID, "UUID" }, \
694 { XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" } 695 { XFS_AGF_RMAP_BLOCKS, "RMAP_BLOCKS" }, \
696 { XFS_AGF_SPARE64, "SPARE64" }
695 697
696/* disk block (xfs_daddr_t) in the AG */ 698/* disk block (xfs_daddr_t) in the AG */
697#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 699#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 0e3d4f5ec33c..4aecc5fefe96 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -583,7 +583,8 @@ xfs_sb_verify(
583 * Only check the in progress field for the primary superblock as 583 * Only check the in progress field for the primary superblock as
584 * mkfs.xfs doesn't clear it from secondary superblocks. 584 * mkfs.xfs doesn't clear it from secondary superblocks.
585 */ 585 */
586 return xfs_mount_validate_sb(mp, &sb, bp->b_bn == XFS_SB_DADDR, 586 return xfs_mount_validate_sb(mp, &sb,
587 bp->b_maps[0].bm_bn == XFS_SB_DADDR,
587 check_version); 588 check_version);
588} 589}
589 590
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 607cc29bba21..b5b9bffe3520 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1611,7 +1611,7 @@ xfs_wait_buftarg(
1611 */ 1611 */
1612 while (percpu_counter_sum(&btp->bt_io_count)) 1612 while (percpu_counter_sum(&btp->bt_io_count))
1613 delay(100); 1613 delay(100);
1614 drain_workqueue(btp->bt_mount->m_buf_workqueue); 1614 flush_workqueue(btp->bt_mount->m_buf_workqueue);
1615 1615
1616 /* loop until there is nothing left on the lru list. */ 1616 /* loop until there is nothing left on the lru list. */
1617 while (list_lru_count(&btp->bt_lru)) { 1617 while (list_lru_count(&btp->bt_lru)) {
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 24ef83ef04de..fd6be45b3a1e 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1574,9 +1574,16 @@ xfs_fs_fill_super(
1574 } 1574 }
1575 } 1575 }
1576 1576
1577 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) 1577 if (xfs_sb_version_hasrmapbt(&mp->m_sb)) {
1578 if (mp->m_sb.sb_rblocks) {
1579 xfs_alert(mp,
1580 "EXPERIMENTAL reverse mapping btree not compatible with realtime device!");
1581 error = -EINVAL;
1582 goto out_filestream_unmount;
1583 }
1578 xfs_alert(mp, 1584 xfs_alert(mp,
1579 "EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!"); 1585 "EXPERIMENTAL reverse mapping btree feature enabled. Use at your own risk!");
1586 }
1580 1587
1581 error = xfs_mountfs(mp); 1588 error = xfs_mountfs(mp);
1582 if (error) 1589 if (error)
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 7e88bec3f359..d303a665dba9 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -2295,7 +2295,7 @@ DECLARE_EVENT_CLASS(xfs_defer_pending_class,
2295 __entry->dev = mp ? mp->m_super->s_dev : 0; 2295 __entry->dev = mp ? mp->m_super->s_dev : 0;
2296 __entry->type = dfp->dfp_type->type; 2296 __entry->type = dfp->dfp_type->type;
2297 __entry->intent = dfp->dfp_intent; 2297 __entry->intent = dfp->dfp_intent;
2298 __entry->committed = dfp->dfp_committed; 2298 __entry->committed = dfp->dfp_done != NULL;
2299 __entry->nr = dfp->dfp_count; 2299 __entry->nr = dfp->dfp_count;
2300 ), 2300 ),
2301 TP_printk("dev %d:%d optype %d intent %p committed %d nr %d\n", 2301 TP_printk("dev %d:%d optype %d intent %p committed %d nr %d\n",
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 1bfa602958f2..5dea1fb6979c 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -72,6 +72,7 @@ struct exception_table_entry
72/* Returns 0 if exception not found and fixup otherwise. */ 72/* Returns 0 if exception not found and fixup otherwise. */
73extern unsigned long search_exception_table(unsigned long); 73extern unsigned long search_exception_table(unsigned long);
74 74
75
75/* 76/*
76 * architectures with an MMU should override these two 77 * architectures with an MMU should override these two
77 */ 78 */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4d8452c2384b..c5eaf2f80a4c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1056,7 +1056,7 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
1056 return NULL; 1056 return NULL;
1057} 1057}
1058 1058
1059#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, validate, data, fn) \ 1059#define ACPI_DECLARE_PROBE_ENTRY(table, name, table_id, subtable, valid, data, fn) \
1060 static const void * __acpi_table_##name[] \ 1060 static const void * __acpi_table_##name[] \
1061 __attribute__((unused)) \ 1061 __attribute__((unused)) \
1062 = { (void *) table_id, \ 1062 = { (void *) table_id, \
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 8dbc8929a6a0..573c5a18908f 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -158,7 +158,7 @@
158#define __compiler_offsetof(a, b) \ 158#define __compiler_offsetof(a, b) \
159 __builtin_offsetof(a, b) 159 __builtin_offsetof(a, b)
160 160
161#if GCC_VERSION >= 40100 && GCC_VERSION < 40600 161#if GCC_VERSION >= 40100
162# define __compiletime_object_size(obj) __builtin_object_size(obj, 0) 162# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
163#endif 163#endif
164 164
diff --git a/include/linux/fence.h b/include/linux/fence.h
index 8cc719a63728..2ac6fa5f4712 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -49,8 +49,6 @@ struct fence_cb;
49 * @timestamp: Timestamp when the fence was signaled. 49 * @timestamp: Timestamp when the fence was signaled.
50 * @status: Optional, only valid if < 0, must be set before calling 50 * @status: Optional, only valid if < 0, must be set before calling
51 * fence_signal, indicates that the fence has completed with an error. 51 * fence_signal, indicates that the fence has completed with an error.
52 * @child_list: list of children fences
53 * @active_list: list of active fences
54 * 52 *
55 * the flags member must be manipulated and read using the appropriate 53 * the flags member must be manipulated and read using the appropriate
56 * atomic ops (bit_*), so taking the spinlock will not be needed most 54 * atomic ops (bit_*), so taking the spinlock will not be needed most
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 3523bf62f328..901e25d495cc 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -574,6 +574,7 @@ static inline void mapping_allow_writable(struct address_space *mapping)
574 574
575struct posix_acl; 575struct posix_acl;
576#define ACL_NOT_CACHED ((void *)(-1)) 576#define ACL_NOT_CACHED ((void *)(-1))
577#define ACL_DONT_CACHE ((void *)(-3))
577 578
578static inline struct posix_acl * 579static inline struct posix_acl *
579uncached_acl_sentinel(struct task_struct *task) 580uncached_acl_sentinel(struct task_struct *task)
diff --git a/include/linux/iio/sw_trigger.h b/include/linux/iio/sw_trigger.h
index 5198f8ed08a4..c97eab67558f 100644
--- a/include/linux/iio/sw_trigger.h
+++ b/include/linux/iio/sw_trigger.h
@@ -62,7 +62,7 @@ void iio_swt_group_init_type_name(struct iio_sw_trigger *t,
62 const char *name, 62 const char *name,
63 struct config_item_type *type) 63 struct config_item_type *type)
64{ 64{
65#ifdef CONFIG_CONFIGFS_FS 65#if IS_ENABLED(CONFIG_CONFIGFS_FS)
66 config_group_init_type_name(&t->group, name, type); 66 config_group_init_type_name(&t->group, name, type);
67#endif 67#endif
68} 68}
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 3267df461012..3d70ece10313 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -19,6 +19,11 @@ struct vm_fault;
19#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */ 19#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */
20 20
21/* 21/*
22 * Flags for iomap mappings:
23 */
24#define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */
25
26/*
22 * Magic value for blkno: 27 * Magic value for blkno:
23 */ 28 */
24#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */ 29#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */
@@ -27,7 +32,8 @@ struct iomap {
27 sector_t blkno; /* 1st sector of mapping, 512b units */ 32 sector_t blkno; /* 1st sector of mapping, 512b units */
28 loff_t offset; /* file offset of mapping, bytes */ 33 loff_t offset; /* file offset of mapping, bytes */
29 u64 length; /* length of mapping, bytes */ 34 u64 length; /* length of mapping, bytes */
30 int type; /* type of mapping */ 35 u16 type; /* type of mapping */
36 u16 flags; /* flags for mapping */
31 struct block_device *bdev; /* block device for I/O */ 37 struct block_device *bdev; /* block device for I/O */
32}; 38};
33 39
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index 4429d255c8ab..5e5b2969d931 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -195,6 +195,7 @@ static inline bool vma_migratable(struct vm_area_struct *vma)
195} 195}
196 196
197extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long); 197extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long);
198extern void mpol_put_task_policy(struct task_struct *);
198 199
199#else 200#else
200 201
@@ -297,5 +298,8 @@ static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma,
297 return -1; /* no node preference */ 298 return -1; /* no node preference */
298} 299}
299 300
301static inline void mpol_put_task_policy(struct task_struct *task)
302{
303}
300#endif /* CONFIG_NUMA */ 304#endif /* CONFIG_NUMA */
301#endif 305#endif
diff --git a/include/linux/mfd/da8xx-cfgchip.h b/include/linux/mfd/da8xx-cfgchip.h
new file mode 100644
index 000000000000..304985e288d2
--- /dev/null
+++ b/include/linux/mfd/da8xx-cfgchip.h
@@ -0,0 +1,153 @@
1/*
2 * TI DaVinci DA8xx CHIPCFGx registers for syscon consumers.
3 *
4 * Copyright (C) 2016 David Lechner <david@lechnology.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef __LINUX_MFD_DA8XX_CFGCHIP_H
18#define __LINUX_MFD_DA8XX_CFGCHIP_H
19
20#include <linux/bitops.h>
21
22/* register offset (32-bit registers) */
23#define CFGCHIP(n) ((n) * 4)
24
25/* CFGCHIP0 (PLL0/EDMA3_0) register bits */
26#define CFGCHIP0_PLL_MASTER_LOCK BIT(4)
27#define CFGCHIP0_EDMA30TC1DBS(n) ((n) << 2)
28#define CFGCHIP0_EDMA30TC1DBS_MASK CFGCHIP0_EDMA30TC1DBS(0x3)
29#define CFGCHIP0_EDMA30TC1DBS_16 CFGCHIP0_EDMA30TC1DBS(0x0)
30#define CFGCHIP0_EDMA30TC1DBS_32 CFGCHIP0_EDMA30TC1DBS(0x1)
31#define CFGCHIP0_EDMA30TC1DBS_64 CFGCHIP0_EDMA30TC1DBS(0x2)
32#define CFGCHIP0_EDMA30TC0DBS(n) ((n) << 0)
33#define CFGCHIP0_EDMA30TC0DBS_MASK CFGCHIP0_EDMA30TC0DBS(0x3)
34#define CFGCHIP0_EDMA30TC0DBS_16 CFGCHIP0_EDMA30TC0DBS(0x0)
35#define CFGCHIP0_EDMA30TC0DBS_32 CFGCHIP0_EDMA30TC0DBS(0x1)
36#define CFGCHIP0_EDMA30TC0DBS_64 CFGCHIP0_EDMA30TC0DBS(0x2)
37
38/* CFGCHIP1 (eCAP/HPI/EDMA3_1/eHRPWM TBCLK/McASP0 AMUTEIN) register bits */
39#define CFGCHIP1_CAP2SRC(n) ((n) << 27)
40#define CFGCHIP1_CAP2SRC_MASK CFGCHIP1_CAP2SRC(0x1f)
41#define CFGCHIP1_CAP2SRC_ECAP_PIN CFGCHIP1_CAP2SRC(0x0)
42#define CFGCHIP1_CAP2SRC_MCASP0_TX CFGCHIP1_CAP2SRC(0x1)
43#define CFGCHIP1_CAP2SRC_MCASP0_RX CFGCHIP1_CAP2SRC(0x2)
44#define CFGCHIP1_CAP2SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP2SRC(0x7)
45#define CFGCHIP1_CAP2SRC_EMAC_C0_RX CFGCHIP1_CAP2SRC(0x8)
46#define CFGCHIP1_CAP2SRC_EMAC_C0_TX CFGCHIP1_CAP2SRC(0x9)
47#define CFGCHIP1_CAP2SRC_EMAC_C0_MISC CFGCHIP1_CAP2SRC(0xa)
48#define CFGCHIP1_CAP2SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP2SRC(0xb)
49#define CFGCHIP1_CAP2SRC_EMAC_C1_RX CFGCHIP1_CAP2SRC(0xc)
50#define CFGCHIP1_CAP2SRC_EMAC_C1_TX CFGCHIP1_CAP2SRC(0xd)
51#define CFGCHIP1_CAP2SRC_EMAC_C1_MISC CFGCHIP1_CAP2SRC(0xe)
52#define CFGCHIP1_CAP2SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP2SRC(0xf)
53#define CFGCHIP1_CAP2SRC_EMAC_C2_RX CFGCHIP1_CAP2SRC(0x10)
54#define CFGCHIP1_CAP2SRC_EMAC_C2_TX CFGCHIP1_CAP2SRC(0x11)
55#define CFGCHIP1_CAP2SRC_EMAC_C2_MISC CFGCHIP1_CAP2SRC(0x12)
56#define CFGCHIP1_CAP1SRC(n) ((n) << 22)
57#define CFGCHIP1_CAP1SRC_MASK CFGCHIP1_CAP1SRC(0x1f)
58#define CFGCHIP1_CAP1SRC_ECAP_PIN CFGCHIP1_CAP1SRC(0x0)
59#define CFGCHIP1_CAP1SRC_MCASP0_TX CFGCHIP1_CAP1SRC(0x1)
60#define CFGCHIP1_CAP1SRC_MCASP0_RX CFGCHIP1_CAP1SRC(0x2)
61#define CFGCHIP1_CAP1SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP1SRC(0x7)
62#define CFGCHIP1_CAP1SRC_EMAC_C0_RX CFGCHIP1_CAP1SRC(0x8)
63#define CFGCHIP1_CAP1SRC_EMAC_C0_TX CFGCHIP1_CAP1SRC(0x9)
64#define CFGCHIP1_CAP1SRC_EMAC_C0_MISC CFGCHIP1_CAP1SRC(0xa)
65#define CFGCHIP1_CAP1SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP1SRC(0xb)
66#define CFGCHIP1_CAP1SRC_EMAC_C1_RX CFGCHIP1_CAP1SRC(0xc)
67#define CFGCHIP1_CAP1SRC_EMAC_C1_TX CFGCHIP1_CAP1SRC(0xd)
68#define CFGCHIP1_CAP1SRC_EMAC_C1_MISC CFGCHIP1_CAP1SRC(0xe)
69#define CFGCHIP1_CAP1SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP1SRC(0xf)
70#define CFGCHIP1_CAP1SRC_EMAC_C2_RX CFGCHIP1_CAP1SRC(0x10)
71#define CFGCHIP1_CAP1SRC_EMAC_C2_TX CFGCHIP1_CAP1SRC(0x11)
72#define CFGCHIP1_CAP1SRC_EMAC_C2_MISC CFGCHIP1_CAP1SRC(0x12)
73#define CFGCHIP1_CAP0SRC(n) ((n) << 17)
74#define CFGCHIP1_CAP0SRC_MASK CFGCHIP1_CAP0SRC(0x1f)
75#define CFGCHIP1_CAP0SRC_ECAP_PIN CFGCHIP1_CAP0SRC(0x0)
76#define CFGCHIP1_CAP0SRC_MCASP0_TX CFGCHIP1_CAP0SRC(0x1)
77#define CFGCHIP1_CAP0SRC_MCASP0_RX CFGCHIP1_CAP0SRC(0x2)
78#define CFGCHIP1_CAP0SRC_EMAC_C0_RX_THRESHOLD CFGCHIP1_CAP0SRC(0x7)
79#define CFGCHIP1_CAP0SRC_EMAC_C0_RX CFGCHIP1_CAP0SRC(0x8)
80#define CFGCHIP1_CAP0SRC_EMAC_C0_TX CFGCHIP1_CAP0SRC(0x9)
81#define CFGCHIP1_CAP0SRC_EMAC_C0_MISC CFGCHIP1_CAP0SRC(0xa)
82#define CFGCHIP1_CAP0SRC_EMAC_C1_RX_THRESHOLD CFGCHIP1_CAP0SRC(0xb)
83#define CFGCHIP1_CAP0SRC_EMAC_C1_RX CFGCHIP1_CAP0SRC(0xc)
84#define CFGCHIP1_CAP0SRC_EMAC_C1_TX CFGCHIP1_CAP0SRC(0xd)
85#define CFGCHIP1_CAP0SRC_EMAC_C1_MISC CFGCHIP1_CAP0SRC(0xe)
86#define CFGCHIP1_CAP0SRC_EMAC_C2_RX_THRESHOLD CFGCHIP1_CAP0SRC(0xf)
87#define CFGCHIP1_CAP0SRC_EMAC_C2_RX CFGCHIP1_CAP0SRC(0x10)
88#define CFGCHIP1_CAP0SRC_EMAC_C2_TX CFGCHIP1_CAP0SRC(0x11)
89#define CFGCHIP1_CAP0SRC_EMAC_C2_MISC CFGCHIP1_CAP0SRC(0x12)
90#define CFGCHIP1_HPIBYTEAD BIT(16)
91#define CFGCHIP1_HPIENA BIT(15)
92#define CFGCHIP0_EDMA31TC0DBS(n) ((n) << 13)
93#define CFGCHIP0_EDMA31TC0DBS_MASK CFGCHIP0_EDMA31TC0DBS(0x3)
94#define CFGCHIP0_EDMA31TC0DBS_16 CFGCHIP0_EDMA31TC0DBS(0x0)
95#define CFGCHIP0_EDMA31TC0DBS_32 CFGCHIP0_EDMA31TC0DBS(0x1)
96#define CFGCHIP0_EDMA31TC0DBS_64 CFGCHIP0_EDMA31TC0DBS(0x2)
97#define CFGCHIP1_TBCLKSYNC BIT(12)
98#define CFGCHIP1_AMUTESEL0(n) ((n) << 0)
99#define CFGCHIP1_AMUTESEL0_MASK CFGCHIP1_AMUTESEL0(0xf)
100#define CFGCHIP1_AMUTESEL0_LOW CFGCHIP1_AMUTESEL0(0x0)
101#define CFGCHIP1_AMUTESEL0_BANK_0 CFGCHIP1_AMUTESEL0(0x1)
102#define CFGCHIP1_AMUTESEL0_BANK_1 CFGCHIP1_AMUTESEL0(0x2)
103#define CFGCHIP1_AMUTESEL0_BANK_2 CFGCHIP1_AMUTESEL0(0x3)
104#define CFGCHIP1_AMUTESEL0_BANK_3 CFGCHIP1_AMUTESEL0(0x4)
105#define CFGCHIP1_AMUTESEL0_BANK_4 CFGCHIP1_AMUTESEL0(0x5)
106#define CFGCHIP1_AMUTESEL0_BANK_5 CFGCHIP1_AMUTESEL0(0x6)
107#define CFGCHIP1_AMUTESEL0_BANK_6 CFGCHIP1_AMUTESEL0(0x7)
108#define CFGCHIP1_AMUTESEL0_BANK_7 CFGCHIP1_AMUTESEL0(0x8)
109
110/* CFGCHIP2 (USB PHY) register bits */
111#define CFGCHIP2_PHYCLKGD BIT(17)
112#define CFGCHIP2_VBUSSENSE BIT(16)
113#define CFGCHIP2_RESET BIT(15)
114#define CFGCHIP2_OTGMODE(n) ((n) << 13)
115#define CFGCHIP2_OTGMODE_MASK CFGCHIP2_OTGMODE(0x3)
116#define CFGCHIP2_OTGMODE_NO_OVERRIDE CFGCHIP2_OTGMODE(0x0)
117#define CFGCHIP2_OTGMODE_FORCE_HOST CFGCHIP2_OTGMODE(0x1)
118#define CFGCHIP2_OTGMODE_FORCE_DEVICE CFGCHIP2_OTGMODE(0x2)
119#define CFGCHIP2_OTGMODE_FORCE_HOST_VBUS_LOW CFGCHIP2_OTGMODE(0x3)
120#define CFGCHIP2_USB1PHYCLKMUX BIT(12)
121#define CFGCHIP2_USB2PHYCLKMUX BIT(11)
122#define CFGCHIP2_PHYPWRDN BIT(10)
123#define CFGCHIP2_OTGPWRDN BIT(9)
124#define CFGCHIP2_DATPOL BIT(8)
125#define CFGCHIP2_USB1SUSPENDM BIT(7)
126#define CFGCHIP2_PHY_PLLON BIT(6)
127#define CFGCHIP2_SESENDEN BIT(5)
128#define CFGCHIP2_VBDTCTEN BIT(4)
129#define CFGCHIP2_REFFREQ(n) ((n) << 0)
130#define CFGCHIP2_REFFREQ_MASK CFGCHIP2_REFFREQ(0xf)
131#define CFGCHIP2_REFFREQ_12MHZ CFGCHIP2_REFFREQ(0x1)
132#define CFGCHIP2_REFFREQ_24MHZ CFGCHIP2_REFFREQ(0x2)
133#define CFGCHIP2_REFFREQ_48MHZ CFGCHIP2_REFFREQ(0x3)
134#define CFGCHIP2_REFFREQ_19_2MHZ CFGCHIP2_REFFREQ(0x4)
135#define CFGCHIP2_REFFREQ_38_4MHZ CFGCHIP2_REFFREQ(0x5)
136#define CFGCHIP2_REFFREQ_13MHZ CFGCHIP2_REFFREQ(0x6)
137#define CFGCHIP2_REFFREQ_26MHZ CFGCHIP2_REFFREQ(0x7)
138#define CFGCHIP2_REFFREQ_20MHZ CFGCHIP2_REFFREQ(0x8)
139#define CFGCHIP2_REFFREQ_40MHZ CFGCHIP2_REFFREQ(0x9)
140
141/* CFGCHIP3 (EMAC/uPP/PLL1/ASYNC3/PRU/DIV4.5/EMIFA) register bits */
142#define CFGCHIP3_RMII_SEL BIT(8)
143#define CFGCHIP3_UPP_TX_CLKSRC BIT(6)
144#define CFGCHIP3_PLL1_MASTER_LOCK BIT(5)
145#define CFGCHIP3_ASYNC3_CLKSRC BIT(4)
146#define CFGCHIP3_PRUEVTSEL BIT(3)
147#define CFGCHIP3_DIV45PENA BIT(2)
148#define CFGCHIP3_EMA_CLKSRC BIT(1)
149
150/* CFGCHIP4 (McASP0 AMUNTEIN) register bits */
151#define CFGCHIP4_AMUTECLR0 BIT(0)
152
153#endif /* __LINUX_MFD_DA8XX_CFGCHIP_H */
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 2567a87872b0..7f55b8b41032 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -138,16 +138,16 @@
138/* 138/*
139 * time in us for processing a single channel, calculated as follows: 139 * time in us for processing a single channel, calculated as follows:
140 * 140 *
141 * num cycles = open delay + (sample delay + conv time) * averaging 141 * max num cycles = open delay + (sample delay + conv time) * averaging
142 * 142 *
143 * num cycles: 152 + (1 + 13) * 16 = 376 143 * max num cycles: 262143 + (255 + 13) * 16 = 266431
144 * 144 *
145 * clock frequency: 26MHz / 8 = 3.25MHz 145 * clock frequency: 26MHz / 8 = 3.25MHz
146 * clock period: 1 / 3.25MHz = 308ns 146 * clock period: 1 / 3.25MHz = 308ns
147 * 147 *
148 * processing time: 376 * 308ns = 116us 148 * max processing time: 266431 * 308ns = 83ms(approx)
149 */ 149 */
150#define IDLE_TIMEOUT 116 /* microsec */ 150#define IDLE_TIMEOUT 83 /* milliseconds */
151 151
152#define TSCADC_CELLS 2 152#define TSCADC_CELLS 2
153 153
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 08ed53eeedd5..ef815b9cd426 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2014,6 +2014,7 @@ extern void mm_drop_all_locks(struct mm_struct *mm);
2014 2014
2015extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); 2015extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
2016extern struct file *get_mm_exe_file(struct mm_struct *mm); 2016extern struct file *get_mm_exe_file(struct mm_struct *mm);
2017extern struct file *get_task_exe_file(struct task_struct *task);
2017 2018
2018extern bool may_expand_vm(struct mm_struct *, vm_flags_t, unsigned long npages); 2019extern bool may_expand_vm(struct mm_struct *, vm_flags_t, unsigned long npages);
2019extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages); 2020extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index d572b78b65e1..7f2ae99e5daf 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -828,9 +828,21 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
828 */ 828 */
829#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) 829#define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)
830 830
831static inline int populated_zone(struct zone *zone) 831/*
832 * Returns true if a zone has pages managed by the buddy allocator.
833 * All the reclaim decisions have to use this function rather than
834 * populated_zone(). If the whole zone is reserved then we can easily
835 * end up with populated_zone() && !managed_zone().
836 */
837static inline bool managed_zone(struct zone *zone)
838{
839 return zone->managed_pages;
840}
841
842/* Returns true if a zone has memory */
843static inline bool populated_zone(struct zone *zone)
832{ 844{
833 return (!!zone->present_pages); 845 return zone->present_pages;
834} 846}
835 847
836extern int movable_zone; 848extern int movable_zone;
diff --git a/include/linux/netfilter/nfnetlink_acct.h b/include/linux/netfilter/nfnetlink_acct.h
index 80ca889b164e..664da0048625 100644
--- a/include/linux/netfilter/nfnetlink_acct.h
+++ b/include/linux/netfilter/nfnetlink_acct.h
@@ -15,6 +15,6 @@ struct nf_acct;
15struct nf_acct *nfnl_acct_find_get(struct net *net, const char *filter_name); 15struct nf_acct *nfnl_acct_find_get(struct net *net, const char *filter_name);
16void nfnl_acct_put(struct nf_acct *acct); 16void nfnl_acct_put(struct nf_acct *acct);
17void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct); 17void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct);
18extern int nfnl_acct_overquota(const struct sk_buff *skb, 18int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb,
19 struct nf_acct *nfacct); 19 struct nf_acct *nfacct);
20#endif /* _NFNL_ACCT_H */ 20#endif /* _NFNL_ACCT_H */
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index d8b37bab2887..7676557ce357 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -794,7 +794,7 @@ struct nvmf_connect_command {
794}; 794};
795 795
796struct nvmf_connect_data { 796struct nvmf_connect_data {
797 uuid_le hostid; 797 uuid_be hostid;
798 __le16 cntlid; 798 __le16 cntlid;
799 char resv4[238]; 799 char resv4[238];
800 char subsysnqn[NVMF_NQN_FIELD_LEN]; 800 char subsysnqn[NVMF_NQN_FIELD_LEN];
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fbc1fa625c3e..0ab835965669 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -683,15 +683,6 @@ struct pci_driver {
683#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver) 683#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
684 684
685/** 685/**
686 * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table
687 * @_table: device table name
688 *
689 * This macro is deprecated and should not be used in new code.
690 */
691#define DEFINE_PCI_DEVICE_TABLE(_table) \
692 const struct pci_device_id _table[]
693
694/**
695 * PCI_DEVICE - macro used to describe a specific pci device 686 * PCI_DEVICE - macro used to describe a specific pci device
696 * @vend: the 16 bit PCI Vendor ID 687 * @vend: the 16 bit PCI Vendor ID
697 * @dev: the 16 bit PCI Device ID 688 * @dev: the 16 bit PCI Device ID
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 923266cd294a..48ec7651989b 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -111,7 +111,6 @@ struct uart_8250_port {
111 * if no_console_suspend 111 * if no_console_suspend
112 */ 112 */
113 unsigned char probe; 113 unsigned char probe;
114 struct mctrl_gpios *gpios;
115#define UART_PROBE_RSA (1 << 0) 114#define UART_PROBE_RSA (1 << 0)
116 115
117 /* 116 /*
diff --git a/include/linux/smc91x.h b/include/linux/smc91x.h
index 76199b75d584..e302c447e057 100644
--- a/include/linux/smc91x.h
+++ b/include/linux/smc91x.h
@@ -1,6 +1,16 @@
1#ifndef __SMC91X_H__ 1#ifndef __SMC91X_H__
2#define __SMC91X_H__ 2#define __SMC91X_H__
3 3
4/*
5 * These bits define which access sizes a platform can support, rather
6 * than the maximal access size. So, if your platform can do 16-bit
7 * and 32-bit accesses to the SMC91x device, but not 8-bit, set both
8 * SMC91X_USE_16BIT and SMC91X_USE_32BIT.
9 *
10 * The SMC91x driver requires at least one of SMC91X_USE_8BIT or
11 * SMC91X_USE_16BIT to be supported - just setting SMC91X_USE_32BIT is
12 * an invalid configuration.
13 */
4#define SMC91X_USE_8BIT (1 << 0) 14#define SMC91X_USE_8BIT (1 << 0)
5#define SMC91X_USE_16BIT (1 << 1) 15#define SMC91X_USE_16BIT (1 << 1)
6#define SMC91X_USE_32BIT (1 << 2) 16#define SMC91X_USE_32BIT (1 << 2)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index c00e7d51bb18..7717302cab91 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1523,6 +1523,8 @@ static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unli
1523{ 1523{
1524 if (sk->sk_send_head == skb_unlinked) 1524 if (sk->sk_send_head == skb_unlinked)
1525 sk->sk_send_head = NULL; 1525 sk->sk_send_head = NULL;
1526 if (tcp_sk(sk)->highest_sack == skb_unlinked)
1527 tcp_sk(sk)->highest_sack = NULL;
1526} 1528}
1527 1529
1528static inline void tcp_init_send_head(struct sock *sk) 1530static inline void tcp_init_send_head(struct sock *sk)
diff --git a/include/uapi/linux/atm_zatm.h b/include/uapi/linux/atm_zatm.h
index 9c9c6ad55f14..5cd4d4d2dd1d 100644
--- a/include/uapi/linux/atm_zatm.h
+++ b/include/uapi/linux/atm_zatm.h
@@ -14,6 +14,7 @@
14 14
15#include <linux/atmapi.h> 15#include <linux/atmapi.h>
16#include <linux/atmioc.h> 16#include <linux/atmioc.h>
17#include <linux/time.h>
17 18
18#define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc) 19#define ZATM_GETPOOL _IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)
19 /* get pool statistics */ 20 /* get pool statistics */
diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h
index 163e8adac2d6..4bd1f55d6377 100644
--- a/include/uapi/linux/if_pppol2tp.h
+++ b/include/uapi/linux/if_pppol2tp.h
@@ -16,7 +16,8 @@
16#define _UAPI__LINUX_IF_PPPOL2TP_H 16#define _UAPI__LINUX_IF_PPPOL2TP_H
17 17
18#include <linux/types.h> 18#include <linux/types.h>
19 19#include <linux/in.h>
20#include <linux/in6.h>
20 21
21/* Structure used to connect() the socket to a particular tunnel UDP 22/* Structure used to connect() the socket to a particular tunnel UDP
22 * socket over IPv4. 23 * socket over IPv4.
diff --git a/include/uapi/linux/if_pppox.h b/include/uapi/linux/if_pppox.h
index e128769331b5..d37bbb17a007 100644
--- a/include/uapi/linux/if_pppox.h
+++ b/include/uapi/linux/if_pppox.h
@@ -21,8 +21,11 @@
21#include <asm/byteorder.h> 21#include <asm/byteorder.h>
22 22
23#include <linux/socket.h> 23#include <linux/socket.h>
24#include <linux/if.h>
24#include <linux/if_ether.h> 25#include <linux/if_ether.h>
25#include <linux/if_pppol2tp.h> 26#include <linux/if_pppol2tp.h>
27#include <linux/in.h>
28#include <linux/in6.h>
26 29
27/* For user-space programs to pick up these definitions 30/* For user-space programs to pick up these definitions
28 * which they wouldn't get otherwise without defining __KERNEL__ 31 * which they wouldn't get otherwise without defining __KERNEL__
diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h
index 1046f5515174..777b6cdb1b7b 100644
--- a/include/uapi/linux/if_tunnel.h
+++ b/include/uapi/linux/if_tunnel.h
@@ -2,6 +2,9 @@
2#define _UAPI_IF_TUNNEL_H_ 2#define _UAPI_IF_TUNNEL_H_
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/if.h>
6#include <linux/ip.h>
7#include <linux/in6.h>
5#include <asm/byteorder.h> 8#include <asm/byteorder.h>
6 9
7 10
diff --git a/include/uapi/linux/ipx.h b/include/uapi/linux/ipx.h
index 3d48014cdd71..30f031db12f6 100644
--- a/include/uapi/linux/ipx.h
+++ b/include/uapi/linux/ipx.h
@@ -1,11 +1,13 @@
1#ifndef _IPX_H_ 1#ifndef _IPX_H_
2#define _IPX_H_ 2#define _IPX_H_
3#include <linux/libc-compat.h> /* for compatibility with glibc netipx/ipx.h */
3#include <linux/types.h> 4#include <linux/types.h>
4#include <linux/sockios.h> 5#include <linux/sockios.h>
5#include <linux/socket.h> 6#include <linux/socket.h>
6#define IPX_NODE_LEN 6 7#define IPX_NODE_LEN 6
7#define IPX_MTU 576 8#define IPX_MTU 576
8 9
10#if __UAPI_DEF_SOCKADDR_IPX
9struct sockaddr_ipx { 11struct sockaddr_ipx {
10 __kernel_sa_family_t sipx_family; 12 __kernel_sa_family_t sipx_family;
11 __be16 sipx_port; 13 __be16 sipx_port;
@@ -14,6 +16,7 @@ struct sockaddr_ipx {
14 __u8 sipx_type; 16 __u8 sipx_type;
15 unsigned char sipx_zero; /* 16 byte fill */ 17 unsigned char sipx_zero; /* 16 byte fill */
16}; 18};
19#endif /* __UAPI_DEF_SOCKADDR_IPX */
17 20
18/* 21/*
19 * So we can fit the extra info for SIOCSIFADDR into the address nicely 22 * So we can fit the extra info for SIOCSIFADDR into the address nicely
@@ -23,12 +26,15 @@ struct sockaddr_ipx {
23#define IPX_DLTITF 0 26#define IPX_DLTITF 0
24#define IPX_CRTITF 1 27#define IPX_CRTITF 1
25 28
29#if __UAPI_DEF_IPX_ROUTE_DEFINITION
26struct ipx_route_definition { 30struct ipx_route_definition {
27 __be32 ipx_network; 31 __be32 ipx_network;
28 __be32 ipx_router_network; 32 __be32 ipx_router_network;
29 unsigned char ipx_router_node[IPX_NODE_LEN]; 33 unsigned char ipx_router_node[IPX_NODE_LEN];
30}; 34};
35#endif /* __UAPI_DEF_IPX_ROUTE_DEFINITION */
31 36
37#if __UAPI_DEF_IPX_INTERFACE_DEFINITION
32struct ipx_interface_definition { 38struct ipx_interface_definition {
33 __be32 ipx_network; 39 __be32 ipx_network;
34 unsigned char ipx_device[16]; 40 unsigned char ipx_device[16];
@@ -45,16 +51,20 @@ struct ipx_interface_definition {
45#define IPX_INTERNAL 2 51#define IPX_INTERNAL 2
46 unsigned char ipx_node[IPX_NODE_LEN]; 52 unsigned char ipx_node[IPX_NODE_LEN];
47}; 53};
48 54#endif /* __UAPI_DEF_IPX_INTERFACE_DEFINITION */
55
56#if __UAPI_DEF_IPX_CONFIG_DATA
49struct ipx_config_data { 57struct ipx_config_data {
50 unsigned char ipxcfg_auto_select_primary; 58 unsigned char ipxcfg_auto_select_primary;
51 unsigned char ipxcfg_auto_create_interfaces; 59 unsigned char ipxcfg_auto_create_interfaces;
52}; 60};
61#endif /* __UAPI_DEF_IPX_CONFIG_DATA */
53 62
54/* 63/*
55 * OLD Route Definition for backward compatibility. 64 * OLD Route Definition for backward compatibility.
56 */ 65 */
57 66
67#if __UAPI_DEF_IPX_ROUTE_DEF
58struct ipx_route_def { 68struct ipx_route_def {
59 __be32 ipx_network; 69 __be32 ipx_network;
60 __be32 ipx_router_network; 70 __be32 ipx_router_network;
@@ -67,6 +77,7 @@ struct ipx_route_def {
67#define IPX_RT_BLUEBOOK 2 77#define IPX_RT_BLUEBOOK 2
68#define IPX_RT_ROUTED 1 78#define IPX_RT_ROUTED 1
69}; 79};
80#endif /* __UAPI_DEF_IPX_ROUTE_DEF */
70 81
71#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) 82#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE)
72#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1) 83#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1)
diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
index e4f048ee7043..44b8a6bd5fe1 100644
--- a/include/uapi/linux/libc-compat.h
+++ b/include/uapi/linux/libc-compat.h
@@ -139,6 +139,25 @@
139 139
140#endif /* _NETINET_IN_H */ 140#endif /* _NETINET_IN_H */
141 141
142/* Coordinate with glibc netipx/ipx.h header. */
143#if defined(__NETIPX_IPX_H)
144
145#define __UAPI_DEF_SOCKADDR_IPX 0
146#define __UAPI_DEF_IPX_ROUTE_DEFINITION 0
147#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 0
148#define __UAPI_DEF_IPX_CONFIG_DATA 0
149#define __UAPI_DEF_IPX_ROUTE_DEF 0
150
151#else /* defined(__NETIPX_IPX_H) */
152
153#define __UAPI_DEF_SOCKADDR_IPX 1
154#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
155#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
156#define __UAPI_DEF_IPX_CONFIG_DATA 1
157#define __UAPI_DEF_IPX_ROUTE_DEF 1
158
159#endif /* defined(__NETIPX_IPX_H) */
160
142/* Definitions for xattr.h */ 161/* Definitions for xattr.h */
143#if defined(_SYS_XATTR_H) 162#if defined(_SYS_XATTR_H)
144#define __UAPI_DEF_XATTR 0 163#define __UAPI_DEF_XATTR 0
@@ -179,6 +198,13 @@
179#define __UAPI_DEF_IN6_PKTINFO 1 198#define __UAPI_DEF_IN6_PKTINFO 1
180#define __UAPI_DEF_IP6_MTUINFO 1 199#define __UAPI_DEF_IP6_MTUINFO 1
181 200
201/* Definitions for ipx.h */
202#define __UAPI_DEF_SOCKADDR_IPX 1
203#define __UAPI_DEF_IPX_ROUTE_DEFINITION 1
204#define __UAPI_DEF_IPX_INTERFACE_DEFINITION 1
205#define __UAPI_DEF_IPX_CONFIG_DATA 1
206#define __UAPI_DEF_IPX_ROUTE_DEF 1
207
182/* Definitions for xattr.h */ 208/* Definitions for xattr.h */
183#define __UAPI_DEF_XATTR 1 209#define __UAPI_DEF_XATTR 1
184 210
diff --git a/include/uapi/linux/openvswitch.h b/include/uapi/linux/openvswitch.h
index d95a3018f6a1..54c3b4f4aceb 100644
--- a/include/uapi/linux/openvswitch.h
+++ b/include/uapi/linux/openvswitch.h
@@ -583,7 +583,7 @@ enum ovs_userspace_attr {
583#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1) 583#define OVS_USERSPACE_ATTR_MAX (__OVS_USERSPACE_ATTR_MAX - 1)
584 584
585struct ovs_action_trunc { 585struct ovs_action_trunc {
586 uint32_t max_len; /* Max packet size in bytes. */ 586 __u32 max_len; /* Max packet size in bytes. */
587}; 587};
588 588
589/** 589/**
@@ -632,8 +632,8 @@ enum ovs_hash_alg {
632 * @hash_basis: basis used for computing hash. 632 * @hash_basis: basis used for computing hash.
633 */ 633 */
634struct ovs_action_hash { 634struct ovs_action_hash {
635 uint32_t hash_alg; /* One of ovs_hash_alg. */ 635 __u32 hash_alg; /* One of ovs_hash_alg. */
636 uint32_t hash_basis; 636 __u32 hash_basis;
637}; 637};
638 638
639/** 639/**
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index d6709eb70970..0d302a87f21b 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21 21
22#include <linux/file.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/audit.h> 24#include <linux/audit.h>
24#include <linux/kthread.h> 25#include <linux/kthread.h>
@@ -544,10 +545,11 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark)
544 unsigned long ino; 545 unsigned long ino;
545 dev_t dev; 546 dev_t dev;
546 547
547 rcu_read_lock(); 548 exe_file = get_task_exe_file(tsk);
548 exe_file = rcu_dereference(tsk->mm->exe_file); 549 if (!exe_file)
550 return 0;
549 ino = exe_file->f_inode->i_ino; 551 ino = exe_file->f_inode->i_ino;
550 dev = exe_file->f_inode->i_sb->s_dev; 552 dev = exe_file->f_inode->i_sb->s_dev;
551 rcu_read_unlock(); 553 fput(exe_file);
552 return audit_mark_compare(mark, ino, dev); 554 return audit_mark_compare(mark, ino, dev);
553} 555}
diff --git a/kernel/configs/tiny.config b/kernel/configs/tiny.config
index c2de56ab0fce..7fa0c4ae6394 100644
--- a/kernel/configs/tiny.config
+++ b/kernel/configs/tiny.config
@@ -1,4 +1,12 @@
1# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
1CONFIG_CC_OPTIMIZE_FOR_SIZE=y 2CONFIG_CC_OPTIMIZE_FOR_SIZE=y
3# CONFIG_KERNEL_GZIP is not set
4# CONFIG_KERNEL_BZIP2 is not set
5# CONFIG_KERNEL_LZMA is not set
2CONFIG_KERNEL_XZ=y 6CONFIG_KERNEL_XZ=y
7# CONFIG_KERNEL_LZO is not set
8# CONFIG_KERNEL_LZ4 is not set
3CONFIG_OPTIMIZE_INLINING=y 9CONFIG_OPTIMIZE_INLINING=y
10# CONFIG_SLAB is not set
11# CONFIG_SLUB is not set
4CONFIG_SLOB=y 12CONFIG_SLOB=y
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index c7fd2778ed50..c27e53326bef 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2069,6 +2069,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
2069 mutex_unlock(&cpuset_mutex); 2069 mutex_unlock(&cpuset_mutex);
2070} 2070}
2071 2071
2072/*
2073 * Make sure the new task conform to the current state of its parent,
2074 * which could have been changed by cpuset just after it inherits the
2075 * state from the parent and before it sits on the cgroup's task list.
2076 */
2077void cpuset_fork(struct task_struct *task)
2078{
2079 if (task_css_is_root(task, cpuset_cgrp_id))
2080 return;
2081
2082 set_cpus_allowed_ptr(task, &current->cpus_allowed);
2083 task->mems_allowed = current->mems_allowed;
2084}
2085
2072struct cgroup_subsys cpuset_cgrp_subsys = { 2086struct cgroup_subsys cpuset_cgrp_subsys = {
2073 .css_alloc = cpuset_css_alloc, 2087 .css_alloc = cpuset_css_alloc,
2074 .css_online = cpuset_css_online, 2088 .css_online = cpuset_css_online,
@@ -2079,6 +2093,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
2079 .attach = cpuset_attach, 2093 .attach = cpuset_attach,
2080 .post_attach = cpuset_post_attach, 2094 .post_attach = cpuset_post_attach,
2081 .bind = cpuset_bind, 2095 .bind = cpuset_bind,
2096 .fork = cpuset_fork,
2082 .legacy_cftypes = files, 2097 .legacy_cftypes = files,
2083 .early_init = true, 2098 .early_init = true,
2084}; 2099};
diff --git a/kernel/exit.c b/kernel/exit.c
index 2f974ae042a6..091a78be3b09 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -848,12 +848,7 @@ void do_exit(long code)
848 TASKS_RCU(preempt_enable()); 848 TASKS_RCU(preempt_enable());
849 exit_notify(tsk, group_dead); 849 exit_notify(tsk, group_dead);
850 proc_exit_connector(tsk); 850 proc_exit_connector(tsk);
851#ifdef CONFIG_NUMA 851 mpol_put_task_policy(tsk);
852 task_lock(tsk);
853 mpol_put(tsk->mempolicy);
854 tsk->mempolicy = NULL;
855 task_unlock(tsk);
856#endif
857#ifdef CONFIG_FUTEX 852#ifdef CONFIG_FUTEX
858 if (unlikely(current->pi_state_cache)) 853 if (unlikely(current->pi_state_cache))
859 kfree(current->pi_state_cache); 854 kfree(current->pi_state_cache);
diff --git a/kernel/fork.c b/kernel/fork.c
index 52e725d4a866..beb31725f7e2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -799,6 +799,29 @@ struct file *get_mm_exe_file(struct mm_struct *mm)
799EXPORT_SYMBOL(get_mm_exe_file); 799EXPORT_SYMBOL(get_mm_exe_file);
800 800
801/** 801/**
802 * get_task_exe_file - acquire a reference to the task's executable file
803 *
804 * Returns %NULL if task's mm (if any) has no associated executable file or
805 * this is a kernel thread with borrowed mm (see the comment above get_task_mm).
806 * User must release file via fput().
807 */
808struct file *get_task_exe_file(struct task_struct *task)
809{
810 struct file *exe_file = NULL;
811 struct mm_struct *mm;
812
813 task_lock(task);
814 mm = task->mm;
815 if (mm) {
816 if (!(task->flags & PF_KTHREAD))
817 exe_file = get_mm_exe_file(mm);
818 }
819 task_unlock(task);
820 return exe_file;
821}
822EXPORT_SYMBOL(get_task_exe_file);
823
824/**
802 * get_task_mm - acquire a reference to the task's mm 825 * get_task_mm - acquire a reference to the task's mm
803 * 826 *
804 * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning 827 * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning
@@ -913,14 +936,12 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
913 deactivate_mm(tsk, mm); 936 deactivate_mm(tsk, mm);
914 937
915 /* 938 /*
916 * If we're exiting normally, clear a user-space tid field if 939 * Signal userspace if we're not exiting with a core dump
917 * requested. We leave this alone when dying by signal, to leave 940 * because we want to leave the value intact for debugging
918 * the value intact in a core dump, and to save the unnecessary 941 * purposes.
919 * trouble, say, a killed vfork parent shouldn't touch this mm.
920 * Userland only wants this done for a sys_exit.
921 */ 942 */
922 if (tsk->clear_child_tid) { 943 if (tsk->clear_child_tid) {
923 if (!(tsk->flags & PF_SIGNALED) && 944 if (!(tsk->signal->flags & SIGNAL_GROUP_COREDUMP) &&
924 atomic_read(&mm->mm_users) > 1) { 945 atomic_read(&mm->mm_users) > 1) {
925 /* 946 /*
926 * We don't check the error code - if userspace has 947 * We don't check the error code - if userspace has
@@ -1404,7 +1425,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1404 p->real_start_time = ktime_get_boot_ns(); 1425 p->real_start_time = ktime_get_boot_ns();
1405 p->io_context = NULL; 1426 p->io_context = NULL;
1406 p->audit_context = NULL; 1427 p->audit_context = NULL;
1407 threadgroup_change_begin(current);
1408 cgroup_fork(p); 1428 cgroup_fork(p);
1409#ifdef CONFIG_NUMA 1429#ifdef CONFIG_NUMA
1410 p->mempolicy = mpol_dup(p->mempolicy); 1430 p->mempolicy = mpol_dup(p->mempolicy);
@@ -1556,6 +1576,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1556 INIT_LIST_HEAD(&p->thread_group); 1576 INIT_LIST_HEAD(&p->thread_group);
1557 p->task_works = NULL; 1577 p->task_works = NULL;
1558 1578
1579 threadgroup_change_begin(current);
1559 /* 1580 /*
1560 * Ensure that the cgroup subsystem policies allow the new process to be 1581 * Ensure that the cgroup subsystem policies allow the new process to be
1561 * forked. It should be noted the the new process's css_set can be changed 1582 * forked. It should be noted the the new process's css_set can be changed
@@ -1656,6 +1677,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1656bad_fork_cancel_cgroup: 1677bad_fork_cancel_cgroup:
1657 cgroup_cancel_fork(p); 1678 cgroup_cancel_fork(p);
1658bad_fork_free_pid: 1679bad_fork_free_pid:
1680 threadgroup_change_end(current);
1659 if (pid != &init_struct_pid) 1681 if (pid != &init_struct_pid)
1660 free_pid(pid); 1682 free_pid(pid);
1661bad_fork_cleanup_thread: 1683bad_fork_cleanup_thread:
@@ -1688,7 +1710,6 @@ bad_fork_cleanup_policy:
1688 mpol_put(p->mempolicy); 1710 mpol_put(p->mempolicy);
1689bad_fork_cleanup_threadgroup_lock: 1711bad_fork_cleanup_threadgroup_lock:
1690#endif 1712#endif
1691 threadgroup_change_end(current);
1692 delayacct_tsk_free(p); 1713 delayacct_tsk_free(p);
1693bad_fork_cleanup_count: 1714bad_fork_cleanup_count:
1694 atomic_dec(&p->cred->user->processes); 1715 atomic_dec(&p->cred->user->processes);
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index 503bc2d348e5..037c321c5618 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -887,7 +887,10 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
887 return 0; 887 return 0;
888out: 888out:
889 vfree(pi->sechdrs); 889 vfree(pi->sechdrs);
890 pi->sechdrs = NULL;
891
890 vfree(pi->purgatory_buf); 892 vfree(pi->purgatory_buf);
893 pi->purgatory_buf = NULL;
891 return ret; 894 return ret;
892} 895}
893 896
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c
index b69eb8a2876f..16bab471c7e2 100644
--- a/kernel/printk/nmi.c
+++ b/kernel/printk/nmi.c
@@ -99,27 +99,33 @@ again:
99 return add; 99 return add;
100} 100}
101 101
102/* 102static void printk_nmi_flush_line(const char *text, int len)
103 * printk one line from the temporary buffer from @start index until
104 * and including the @end index.
105 */
106static void print_nmi_seq_line(struct nmi_seq_buf *s, int start, int end)
107{ 103{
108 const char *buf = s->buffer + start;
109
110 /* 104 /*
111 * The buffers are flushed in NMI only on panic. The messages must 105 * The buffers are flushed in NMI only on panic. The messages must
112 * go only into the ring buffer at this stage. Consoles will get 106 * go only into the ring buffer at this stage. Consoles will get
113 * explicitly called later when a crashdump is not generated. 107 * explicitly called later when a crashdump is not generated.
114 */ 108 */
115 if (in_nmi()) 109 if (in_nmi())
116 printk_deferred("%.*s", (end - start) + 1, buf); 110 printk_deferred("%.*s", len, text);
117 else 111 else
118 printk("%.*s", (end - start) + 1, buf); 112 printk("%.*s", len, text);
119 113
120} 114}
121 115
122/* 116/*
117 * printk one line from the temporary buffer from @start index until
118 * and including the @end index.
119 */
120static void printk_nmi_flush_seq_line(struct nmi_seq_buf *s,
121 int start, int end)
122{
123 const char *buf = s->buffer + start;
124
125 printk_nmi_flush_line(buf, (end - start) + 1);
126}
127
128/*
123 * Flush data from the associated per_CPU buffer. The function 129 * Flush data from the associated per_CPU buffer. The function
124 * can be called either via IRQ work or independently. 130 * can be called either via IRQ work or independently.
125 */ 131 */
@@ -150,9 +156,11 @@ more:
150 * the buffer an unexpected way. If we printed something then 156 * the buffer an unexpected way. If we printed something then
151 * @len must only increase. 157 * @len must only increase.
152 */ 158 */
153 if (i && i >= len) 159 if (i && i >= len) {
154 pr_err("printk_nmi_flush: internal error: i=%d >= len=%zu\n", 160 const char *msg = "printk_nmi_flush: internal error\n";
155 i, len); 161
162 printk_nmi_flush_line(msg, strlen(msg));
163 }
156 164
157 if (!len) 165 if (!len)
158 goto out; /* Someone else has already flushed the buffer. */ 166 goto out; /* Someone else has already flushed the buffer. */
@@ -166,14 +174,14 @@ more:
166 /* Print line by line. */ 174 /* Print line by line. */
167 for (; i < size; i++) { 175 for (; i < size; i++) {
168 if (s->buffer[i] == '\n') { 176 if (s->buffer[i] == '\n') {
169 print_nmi_seq_line(s, last_i, i); 177 printk_nmi_flush_seq_line(s, last_i, i);
170 last_i = i + 1; 178 last_i = i + 1;
171 } 179 }
172 } 180 }
173 /* Check if there was a partial line. */ 181 /* Check if there was a partial line. */
174 if (last_i < size) { 182 if (last_i < size) {
175 print_nmi_seq_line(s, last_i, size - 1); 183 printk_nmi_flush_seq_line(s, last_i, size - 1);
176 pr_cont("\n"); 184 printk_nmi_flush_line("\n", strlen("\n"));
177 } 185 }
178 186
179 /* 187 /*
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index ef6c6c3f9d8a..0db7c8a2afe2 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -605,12 +605,16 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd,
605 ptrace_event(PTRACE_EVENT_SECCOMP, data); 605 ptrace_event(PTRACE_EVENT_SECCOMP, data);
606 /* 606 /*
607 * The delivery of a fatal signal during event 607 * The delivery of a fatal signal during event
608 * notification may silently skip tracer notification. 608 * notification may silently skip tracer notification,
609 * Terminating the task now avoids executing a system 609 * which could leave us with a potentially unmodified
610 * call that may not be intended. 610 * syscall that the tracer would have liked to have
611 * changed. Since the process is about to die, we just
612 * force the syscall to be skipped and let the signal
613 * kill the process and correctly handle any tracer exit
614 * notifications.
611 */ 615 */
612 if (fatal_signal_pending(current)) 616 if (fatal_signal_pending(current))
613 do_exit(SIGSYS); 617 goto skip;
614 /* Check if the tracer forced the syscall to be skipped. */ 618 /* Check if the tracer forced the syscall to be skipped. */
615 this_syscall = syscall_get_nr(current, task_pt_regs(current)); 619 this_syscall = syscall_get_nr(current, task_pt_regs(current));
616 if (this_syscall < 0) 620 if (this_syscall < 0)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 204fdc86863d..2ec7c00228f3 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -908,10 +908,11 @@ static void __tick_nohz_idle_enter(struct tick_sched *ts)
908 ktime_t now, expires; 908 ktime_t now, expires;
909 int cpu = smp_processor_id(); 909 int cpu = smp_processor_id();
910 910
911 now = tick_nohz_start_idle(ts);
912
911 if (can_stop_idle_tick(cpu, ts)) { 913 if (can_stop_idle_tick(cpu, ts)) {
912 int was_stopped = ts->tick_stopped; 914 int was_stopped = ts->tick_stopped;
913 915
914 now = tick_nohz_start_idle(ts);
915 ts->idle_calls++; 916 ts->idle_calls++;
916 917
917 expires = tick_nohz_stop_sched_tick(ts, now, cpu); 918 expires = tick_nohz_stop_sched_tick(ts, now, cpu);
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 2307d7c89dac..2e2cca509231 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1686,24 +1686,6 @@ config LATENCYTOP
1686 Enable this option if you want to use the LatencyTOP tool 1686 Enable this option if you want to use the LatencyTOP tool
1687 to find out which userspace is blocking on what kernel operations. 1687 to find out which userspace is blocking on what kernel operations.
1688 1688
1689config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
1690 bool
1691
1692config DEBUG_STRICT_USER_COPY_CHECKS
1693 bool "Strict user copy size checks"
1694 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
1695 depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
1696 help
1697 Enabling this option turns a certain set of sanity checks for user
1698 copy operations into compile time failures.
1699
1700 The copy_from_user() etc checks are there to help test if there
1701 are sufficient security checks on the length argument of
1702 the copy operation, by having gcc prove that the argument is
1703 within bounds.
1704
1705 If unsure, say N.
1706
1707source kernel/trace/Kconfig 1689source kernel/trace/Kconfig
1708 1690
1709menu "Runtime Testing" 1691menu "Runtime Testing"
diff --git a/lib/Makefile b/lib/Makefile
index cfa68eb269e4..5dc77a8ec297 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -24,7 +24,6 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
24 is_single_threaded.o plist.o decompress.o kobject_uevent.o \ 24 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
25 earlycpio.o seq_buf.o nmi_backtrace.o nodemask.o 25 earlycpio.o seq_buf.o nmi_backtrace.o nodemask.o
26 26
27obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o
28lib-$(CONFIG_MMU) += ioremap.o 27lib-$(CONFIG_MMU) += ioremap.o
29lib-$(CONFIG_SMP) += cpumask.o 28lib-$(CONFIG_SMP) += cpumask.o
30lib-$(CONFIG_HAS_DMA) += dma-noop.o 29lib-$(CONFIG_HAS_DMA) += dma-noop.o
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 5ba520b544d7..56054e541a0f 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -77,17 +77,18 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl,
77 size = min_t(unsigned int, size, tbl->size >> 1); 77 size = min_t(unsigned int, size, tbl->size >> 1);
78 78
79 if (sizeof(spinlock_t) != 0) { 79 if (sizeof(spinlock_t) != 0) {
80 tbl->locks = NULL;
80#ifdef CONFIG_NUMA 81#ifdef CONFIG_NUMA
81 if (size * sizeof(spinlock_t) > PAGE_SIZE && 82 if (size * sizeof(spinlock_t) > PAGE_SIZE &&
82 gfp == GFP_KERNEL) 83 gfp == GFP_KERNEL)
83 tbl->locks = vmalloc(size * sizeof(spinlock_t)); 84 tbl->locks = vmalloc(size * sizeof(spinlock_t));
84 else
85#endif 85#endif
86 if (gfp != GFP_KERNEL) 86 if (gfp != GFP_KERNEL)
87 gfp |= __GFP_NOWARN | __GFP_NORETRY; 87 gfp |= __GFP_NOWARN | __GFP_NORETRY;
88 88
89 tbl->locks = kmalloc_array(size, sizeof(spinlock_t), 89 if (!tbl->locks)
90 gfp); 90 tbl->locks = kmalloc_array(size, sizeof(spinlock_t),
91 gfp);
91 if (!tbl->locks) 92 if (!tbl->locks)
92 return -ENOMEM; 93 return -ENOMEM;
93 for (i = 0; i < size; i++) 94 for (i = 0; i < size; i++)
diff --git a/lib/test_hash.c b/lib/test_hash.c
index 66c5fc8351e8..cac20c5fb304 100644
--- a/lib/test_hash.c
+++ b/lib/test_hash.c
@@ -143,7 +143,7 @@ static int __init
143test_hash_init(void) 143test_hash_init(void)
144{ 144{
145 char buf[SIZE+1]; 145 char buf[SIZE+1];
146 u32 string_or = 0, hash_or[2][33] = { 0 }; 146 u32 string_or = 0, hash_or[2][33] = { { 0, } };
147 unsigned tests = 0; 147 unsigned tests = 0;
148 unsigned long long h64 = 0; 148 unsigned long long h64 = 0;
149 int i, j; 149 int i, j;
@@ -219,21 +219,27 @@ test_hash_init(void)
219 } 219 }
220 220
221 /* Issue notices about skipped tests. */ 221 /* Issue notices about skipped tests. */
222#ifndef HAVE_ARCH__HASH_32 222#ifdef HAVE_ARCH__HASH_32
223 pr_info("__hash_32() has no arch implementation to test."); 223#if HAVE_ARCH__HASH_32 != 1
224#elif HAVE_ARCH__HASH_32 != 1
225 pr_info("__hash_32() is arch-specific; not compared to generic."); 224 pr_info("__hash_32() is arch-specific; not compared to generic.");
226#endif 225#endif
227#ifndef HAVE_ARCH_HASH_32 226#else
228 pr_info("hash_32() has no arch implementation to test."); 227 pr_info("__hash_32() has no arch implementation to test.");
229#elif HAVE_ARCH_HASH_32 != 1 228#endif
229#ifdef HAVE_ARCH_HASH_32
230#if HAVE_ARCH_HASH_32 != 1
230 pr_info("hash_32() is arch-specific; not compared to generic."); 231 pr_info("hash_32() is arch-specific; not compared to generic.");
231#endif 232#endif
232#ifndef HAVE_ARCH_HASH_64 233#else
233 pr_info("hash_64() has no arch implementation to test."); 234 pr_info("hash_32() has no arch implementation to test.");
234#elif HAVE_ARCH_HASH_64 != 1 235#endif
236#ifdef HAVE_ARCH_HASH_64
237#if HAVE_ARCH_HASH_64 != 1
235 pr_info("hash_64() is arch-specific; not compared to generic."); 238 pr_info("hash_64() is arch-specific; not compared to generic.");
236#endif 239#endif
240#else
241 pr_info("hash_64() has no arch implementation to test.");
242#endif
237 243
238 pr_notice("%u tests passed.", tests); 244 pr_notice("%u tests passed.", tests);
239 245
diff --git a/lib/usercopy.c b/lib/usercopy.c
deleted file mode 100644
index 4f5b1ddbcd25..000000000000
--- a/lib/usercopy.c
+++ /dev/null
@@ -1,9 +0,0 @@
1#include <linux/export.h>
2#include <linux/bug.h>
3#include <linux/uaccess.h>
4
5void copy_from_user_overflow(void)
6{
7 WARN(1, "Buffer overflow detected!\n");
8}
9EXPORT_SYMBOL(copy_from_user_overflow);
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index d8c4e38fb5f4..2da72a5b6ecc 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2336,6 +2336,23 @@ out:
2336 return ret; 2336 return ret;
2337} 2337}
2338 2338
2339/*
2340 * Drop the (possibly final) reference to task->mempolicy. It needs to be
2341 * dropped after task->mempolicy is set to NULL so that any allocation done as
2342 * part of its kmem_cache_free(), such as by KASAN, doesn't reference a freed
2343 * policy.
2344 */
2345void mpol_put_task_policy(struct task_struct *task)
2346{
2347 struct mempolicy *pol;
2348
2349 task_lock(task);
2350 pol = task->mempolicy;
2351 task->mempolicy = NULL;
2352 task_unlock(task);
2353 mpol_put(pol);
2354}
2355
2339static void sp_delete(struct shared_policy *sp, struct sp_node *n) 2356static void sp_delete(struct shared_policy *sp, struct sp_node *n)
2340{ 2357{
2341 pr_debug("deleting %lx-l%lx\n", n->start, n->end); 2358 pr_debug("deleting %lx-l%lx\n", n->start, n->end);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3fbe73a6fe4b..a2214c64ed3c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3137,54 +3137,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
3137 return NULL; 3137 return NULL;
3138} 3138}
3139 3139
3140static inline bool
3141should_compact_retry(struct alloc_context *ac, int order, int alloc_flags,
3142 enum compact_result compact_result,
3143 enum compact_priority *compact_priority,
3144 int compaction_retries)
3145{
3146 int max_retries = MAX_COMPACT_RETRIES;
3147
3148 if (!order)
3149 return false;
3150
3151 /*
3152 * compaction considers all the zone as desperately out of memory
3153 * so it doesn't really make much sense to retry except when the
3154 * failure could be caused by insufficient priority
3155 */
3156 if (compaction_failed(compact_result)) {
3157 if (*compact_priority > MIN_COMPACT_PRIORITY) {
3158 (*compact_priority)--;
3159 return true;
3160 }
3161 return false;
3162 }
3163
3164 /*
3165 * make sure the compaction wasn't deferred or didn't bail out early
3166 * due to locks contention before we declare that we should give up.
3167 * But do not retry if the given zonelist is not suitable for
3168 * compaction.
3169 */
3170 if (compaction_withdrawn(compact_result))
3171 return compaction_zonelist_suitable(ac, order, alloc_flags);
3172
3173 /*
3174 * !costly requests are much more important than __GFP_REPEAT
3175 * costly ones because they are de facto nofail and invoke OOM
3176 * killer to move on while costly can fail and users are ready
3177 * to cope with that. 1/4 retries is rather arbitrary but we
3178 * would need much more detailed feedback from compaction to
3179 * make a better decision.
3180 */
3181 if (order > PAGE_ALLOC_COSTLY_ORDER)
3182 max_retries /= 4;
3183 if (compaction_retries <= max_retries)
3184 return true;
3185
3186 return false;
3187}
3188#else 3140#else
3189static inline struct page * 3141static inline struct page *
3190__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, 3142__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
@@ -3195,6 +3147,8 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
3195 return NULL; 3147 return NULL;
3196} 3148}
3197 3149
3150#endif /* CONFIG_COMPACTION */
3151
3198static inline bool 3152static inline bool
3199should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags, 3153should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags,
3200 enum compact_result compact_result, 3154 enum compact_result compact_result,
@@ -3221,7 +3175,6 @@ should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_fla
3221 } 3175 }
3222 return false; 3176 return false;
3223} 3177}
3224#endif /* CONFIG_COMPACTION */
3225 3178
3226/* Perform direct synchronous page reclaim */ 3179/* Perform direct synchronous page reclaim */
3227static int 3180static int
@@ -4407,7 +4360,7 @@ static int build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist,
4407 do { 4360 do {
4408 zone_type--; 4361 zone_type--;
4409 zone = pgdat->node_zones + zone_type; 4362 zone = pgdat->node_zones + zone_type;
4410 if (populated_zone(zone)) { 4363 if (managed_zone(zone)) {
4411 zoneref_set_zone(zone, 4364 zoneref_set_zone(zone,
4412 &zonelist->_zonerefs[nr_zones++]); 4365 &zonelist->_zonerefs[nr_zones++]);
4413 check_highest_zone(zone_type); 4366 check_highest_zone(zone_type);
@@ -4645,7 +4598,7 @@ static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes)
4645 for (j = 0; j < nr_nodes; j++) { 4598 for (j = 0; j < nr_nodes; j++) {
4646 node = node_order[j]; 4599 node = node_order[j];
4647 z = &NODE_DATA(node)->node_zones[zone_type]; 4600 z = &NODE_DATA(node)->node_zones[zone_type];
4648 if (populated_zone(z)) { 4601 if (managed_zone(z)) {
4649 zoneref_set_zone(z, 4602 zoneref_set_zone(z,
4650 &zonelist->_zonerefs[pos++]); 4603 &zonelist->_zonerefs[pos++]);
4651 check_highest_zone(zone_type); 4604 check_highest_zone(zone_type);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 374d95d04178..b1e12a1ea9cf 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1665,7 +1665,7 @@ static bool inactive_reclaimable_pages(struct lruvec *lruvec,
1665 1665
1666 for (zid = sc->reclaim_idx; zid >= 0; zid--) { 1666 for (zid = sc->reclaim_idx; zid >= 0; zid--) {
1667 zone = &pgdat->node_zones[zid]; 1667 zone = &pgdat->node_zones[zid];
1668 if (!populated_zone(zone)) 1668 if (!managed_zone(zone))
1669 continue; 1669 continue;
1670 1670
1671 if (zone_page_state_snapshot(zone, NR_ZONE_LRU_BASE + 1671 if (zone_page_state_snapshot(zone, NR_ZONE_LRU_BASE +
@@ -2036,7 +2036,7 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,
2036 struct zone *zone = &pgdat->node_zones[zid]; 2036 struct zone *zone = &pgdat->node_zones[zid];
2037 unsigned long inactive_zone, active_zone; 2037 unsigned long inactive_zone, active_zone;
2038 2038
2039 if (!populated_zone(zone)) 2039 if (!managed_zone(zone))
2040 continue; 2040 continue;
2041 2041
2042 inactive_zone = zone_page_state(zone, 2042 inactive_zone = zone_page_state(zone,
@@ -2171,7 +2171,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,
2171 2171
2172 for (z = 0; z < MAX_NR_ZONES; z++) { 2172 for (z = 0; z < MAX_NR_ZONES; z++) {
2173 struct zone *zone = &pgdat->node_zones[z]; 2173 struct zone *zone = &pgdat->node_zones[z];
2174 if (!populated_zone(zone)) 2174 if (!managed_zone(zone))
2175 continue; 2175 continue;
2176 2176
2177 total_high_wmark += high_wmark_pages(zone); 2177 total_high_wmark += high_wmark_pages(zone);
@@ -2510,7 +2510,7 @@ static inline bool should_continue_reclaim(struct pglist_data *pgdat,
2510 /* If compaction would go ahead or the allocation would succeed, stop */ 2510 /* If compaction would go ahead or the allocation would succeed, stop */
2511 for (z = 0; z <= sc->reclaim_idx; z++) { 2511 for (z = 0; z <= sc->reclaim_idx; z++) {
2512 struct zone *zone = &pgdat->node_zones[z]; 2512 struct zone *zone = &pgdat->node_zones[z];
2513 if (!populated_zone(zone)) 2513 if (!managed_zone(zone))
2514 continue; 2514 continue;
2515 2515
2516 switch (compaction_suitable(zone, sc->order, 0, sc->reclaim_idx)) { 2516 switch (compaction_suitable(zone, sc->order, 0, sc->reclaim_idx)) {
@@ -2840,7 +2840,7 @@ static bool pfmemalloc_watermark_ok(pg_data_t *pgdat)
2840 2840
2841 for (i = 0; i <= ZONE_NORMAL; i++) { 2841 for (i = 0; i <= ZONE_NORMAL; i++) {
2842 zone = &pgdat->node_zones[i]; 2842 zone = &pgdat->node_zones[i];
2843 if (!populated_zone(zone) || 2843 if (!managed_zone(zone) ||
2844 pgdat_reclaimable_pages(pgdat) == 0) 2844 pgdat_reclaimable_pages(pgdat) == 0)
2845 continue; 2845 continue;
2846 2846
@@ -3141,7 +3141,7 @@ static bool prepare_kswapd_sleep(pg_data_t *pgdat, int order, int classzone_idx)
3141 for (i = 0; i <= classzone_idx; i++) { 3141 for (i = 0; i <= classzone_idx; i++) {
3142 struct zone *zone = pgdat->node_zones + i; 3142 struct zone *zone = pgdat->node_zones + i;
3143 3143
3144 if (!populated_zone(zone)) 3144 if (!managed_zone(zone))
3145 continue; 3145 continue;
3146 3146
3147 if (!zone_balanced(zone, order, classzone_idx)) 3147 if (!zone_balanced(zone, order, classzone_idx))
@@ -3169,7 +3169,7 @@ static bool kswapd_shrink_node(pg_data_t *pgdat,
3169 sc->nr_to_reclaim = 0; 3169 sc->nr_to_reclaim = 0;
3170 for (z = 0; z <= sc->reclaim_idx; z++) { 3170 for (z = 0; z <= sc->reclaim_idx; z++) {
3171 zone = pgdat->node_zones + z; 3171 zone = pgdat->node_zones + z;
3172 if (!populated_zone(zone)) 3172 if (!managed_zone(zone))
3173 continue; 3173 continue;
3174 3174
3175 sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX); 3175 sc->nr_to_reclaim += max(high_wmark_pages(zone), SWAP_CLUSTER_MAX);
@@ -3242,7 +3242,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
3242 if (buffer_heads_over_limit) { 3242 if (buffer_heads_over_limit) {
3243 for (i = MAX_NR_ZONES - 1; i >= 0; i--) { 3243 for (i = MAX_NR_ZONES - 1; i >= 0; i--) {
3244 zone = pgdat->node_zones + i; 3244 zone = pgdat->node_zones + i;
3245 if (!populated_zone(zone)) 3245 if (!managed_zone(zone))
3246 continue; 3246 continue;
3247 3247
3248 sc.reclaim_idx = i; 3248 sc.reclaim_idx = i;
@@ -3262,7 +3262,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int classzone_idx)
3262 */ 3262 */
3263 for (i = classzone_idx; i >= 0; i--) { 3263 for (i = classzone_idx; i >= 0; i--) {
3264 zone = pgdat->node_zones + i; 3264 zone = pgdat->node_zones + i;
3265 if (!populated_zone(zone)) 3265 if (!managed_zone(zone))
3266 continue; 3266 continue;
3267 3267
3268 if (zone_balanced(zone, sc.order, classzone_idx)) 3268 if (zone_balanced(zone, sc.order, classzone_idx))
@@ -3508,7 +3508,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx)
3508 pg_data_t *pgdat; 3508 pg_data_t *pgdat;
3509 int z; 3509 int z;
3510 3510
3511 if (!populated_zone(zone)) 3511 if (!managed_zone(zone))
3512 return; 3512 return;
3513 3513
3514 if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL)) 3514 if (!cpuset_zone_allowed(zone, GFP_KERNEL | __GFP_HARDWALL))
@@ -3522,7 +3522,7 @@ void wakeup_kswapd(struct zone *zone, int order, enum zone_type classzone_idx)
3522 /* Only wake kswapd if all zones are unbalanced */ 3522 /* Only wake kswapd if all zones are unbalanced */
3523 for (z = 0; z <= classzone_idx; z++) { 3523 for (z = 0; z <= classzone_idx; z++) {
3524 zone = pgdat->node_zones + z; 3524 zone = pgdat->node_zones + z;
3525 if (!populated_zone(zone)) 3525 if (!managed_zone(zone))
3526 continue; 3526 continue;
3527 3527
3528 if (zone_balanced(zone, order, classzone_idx)) 3528 if (zone_balanced(zone, order, classzone_idx))
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index ece45e0683fd..0b5f729d08d2 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -250,7 +250,7 @@ int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
250 250
251 skb_free_datagram(sk, skb); 251 skb_free_datagram(sk, skb);
252 252
253 if (msg->msg_flags & MSG_TRUNC) 253 if (flags & MSG_TRUNC)
254 copied = skblen; 254 copied = skblen;
255 255
256 return err ? : copied; 256 return err ? : copied;
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index c045b3c54768..b0e23dfc5c34 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -262,6 +262,8 @@ int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req,
262 break; 262 break;
263 } 263 }
264 264
265 kfree_skb(hdev->req_skb);
266 hdev->req_skb = NULL;
265 hdev->req_status = hdev->req_result = 0; 267 hdev->req_status = hdev->req_result = 0;
266 268
267 BT_DBG("%s end: err %d", hdev->name, err); 269 BT_DBG("%s end: err %d", hdev->name, err);
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 6ef8a01a9ad4..96f04b7b9556 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1091,7 +1091,7 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg,
1091 1091
1092 skb_free_datagram(sk, skb); 1092 skb_free_datagram(sk, skb);
1093 1093
1094 if (msg->msg_flags & MSG_TRUNC) 1094 if (flags & MSG_TRUNC)
1095 copied = skblen; 1095 copied = skblen;
1096 1096
1097 return err ? : copied; 1097 return err ? : copied;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 54ceb1f2cc9a..d4cad29b033f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/debugfs.h> 33#include <linux/debugfs.h>
34#include <linux/crc16.h> 34#include <linux/crc16.h>
35#include <linux/filter.h>
35 36
36#include <net/bluetooth/bluetooth.h> 37#include <net/bluetooth/bluetooth.h>
37#include <net/bluetooth/hci_core.h> 38#include <net/bluetooth/hci_core.h>
@@ -5835,6 +5836,9 @@ static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb,
5835 if (chan->sdu) 5836 if (chan->sdu)
5836 break; 5837 break;
5837 5838
5839 if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE))
5840 break;
5841
5838 chan->sdu_len = get_unaligned_le16(skb->data); 5842 chan->sdu_len = get_unaligned_le16(skb->data);
5839 skb_pull(skb, L2CAP_SDULEN_SIZE); 5843 skb_pull(skb, L2CAP_SDULEN_SIZE);
5840 5844
@@ -6610,6 +6614,10 @@ static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
6610 goto drop; 6614 goto drop;
6611 } 6615 }
6612 6616
6617 if ((chan->mode == L2CAP_MODE_ERTM ||
6618 chan->mode == L2CAP_MODE_STREAMING) && sk_filter(chan->data, skb))
6619 goto drop;
6620
6613 if (!control->sframe) { 6621 if (!control->sframe) {
6614 int err; 6622 int err;
6615 6623
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 1842141baedb..a8ba752732c9 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1019,7 +1019,7 @@ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
1019 goto done; 1019 goto done;
1020 1020
1021 if (pi->rx_busy_skb) { 1021 if (pi->rx_busy_skb) {
1022 if (!sock_queue_rcv_skb(sk, pi->rx_busy_skb)) 1022 if (!__sock_queue_rcv_skb(sk, pi->rx_busy_skb))
1023 pi->rx_busy_skb = NULL; 1023 pi->rx_busy_skb = NULL;
1024 else 1024 else
1025 goto done; 1025 goto done;
@@ -1270,7 +1270,17 @@ static int l2cap_sock_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
1270 goto done; 1270 goto done;
1271 } 1271 }
1272 1272
1273 err = sock_queue_rcv_skb(sk, skb); 1273 if (chan->mode != L2CAP_MODE_ERTM &&
1274 chan->mode != L2CAP_MODE_STREAMING) {
1275 /* Even if no filter is attached, we could potentially
1276 * get errors from security modules, etc.
1277 */
1278 err = sk_filter(sk, skb);
1279 if (err)
1280 goto done;
1281 }
1282
1283 err = __sock_queue_rcv_skb(sk, skb);
1274 1284
1275 /* For ERTM, handle one skb that doesn't fit into the recv 1285 /* For ERTM, handle one skb that doesn't fit into the recv
1276 * buffer. This is important to do because the data frames 1286 * buffer. This is important to do because the data frames
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index febca0f1008c..e2ffc2a5c7db 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -249,7 +249,7 @@ static inline unsigned long get_index(t_key key, struct key_vector *kv)
249 * index into the parent's child array. That is, they will be used to find 249 * index into the parent's child array. That is, they will be used to find
250 * 'n' among tp's children. 250 * 'n' among tp's children.
251 * 251 *
252 * The bits from (n->pos + n->bits) to (tn->pos - 1) - "S" - are skipped bits 252 * The bits from (n->pos + n->bits) to (tp->pos - 1) - "S" - are skipped bits
253 * for the node n. 253 * for the node n.
254 * 254 *
255 * All the bits we have seen so far are significant to the node n. The rest 255 * All the bits we have seen so far are significant to the node n. The rest
@@ -258,7 +258,7 @@ static inline unsigned long get_index(t_key key, struct key_vector *kv)
258 * The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into 258 * The bits from (n->pos) to (n->pos + n->bits - 1) - "C" - are the index into
259 * n's child array, and will of course be different for each child. 259 * n's child array, and will of course be different for each child.
260 * 260 *
261 * The rest of the bits, from 0 to (n->pos + n->bits), are completely unknown 261 * The rest of the bits, from 0 to (n->pos -1) - "u" - are completely unknown
262 * at this point. 262 * at this point.
263 */ 263 */
264 264
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 9d847c302551..0f227db0e9ac 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -73,9 +73,11 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
73 skb_dst_set(skb, &rt->dst); 73 skb_dst_set(skb, &rt->dst);
74 memset(IPCB(skb), 0, sizeof(*IPCB(skb))); 74 memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
75 75
76 if (skb_iif && proto == IPPROTO_UDP) { 76 if (skb_iif && !(df & htons(IP_DF))) {
77 /* Arrived from an ingress interface and got udp encapuslated. 77 /* Arrived from an ingress interface, got encapsulated, with
78 * The encapsulated network segment length may exceed dst mtu. 78 * fragmentation of encapulating frames allowed.
79 * If skb is gso, the resulting encapsulated network segments
80 * may exceed dst mtu.
79 * Allow IP Fragmentation of segments. 81 * Allow IP Fragmentation of segments.
80 */ 82 */
81 IPCB(skb)->flags |= IPSKB_FRAG_SEGS; 83 IPCB(skb)->flags |= IPSKB_FRAG_SEGS;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 032a96d78c99..ffbb218de520 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3193,7 +3193,6 @@ int tcp_abort(struct sock *sk, int err)
3193 local_bh_enable(); 3193 local_bh_enable();
3194 return 0; 3194 return 0;
3195 } 3195 }
3196 sock_gen_put(sk);
3197 return -EOPNOTSUPP; 3196 return -EOPNOTSUPP;
3198 } 3197 }
3199 3198
@@ -3222,7 +3221,6 @@ int tcp_abort(struct sock *sk, int err)
3222 bh_unlock_sock(sk); 3221 bh_unlock_sock(sk);
3223 local_bh_enable(); 3222 local_bh_enable();
3224 release_sock(sk); 3223 release_sock(sk);
3225 sock_put(sk);
3226 return 0; 3224 return 0;
3227} 3225}
3228EXPORT_SYMBOL_GPL(tcp_abort); 3226EXPORT_SYMBOL_GPL(tcp_abort);
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 4d610934fb39..a748c74aa8b7 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -54,11 +54,16 @@ static int tcp_diag_destroy(struct sk_buff *in_skb,
54{ 54{
55 struct net *net = sock_net(in_skb->sk); 55 struct net *net = sock_net(in_skb->sk);
56 struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req); 56 struct sock *sk = inet_diag_find_one_icsk(net, &tcp_hashinfo, req);
57 int err;
57 58
58 if (IS_ERR(sk)) 59 if (IS_ERR(sk))
59 return PTR_ERR(sk); 60 return PTR_ERR(sk);
60 61
61 return sock_diag_destroy(sk, ECONNABORTED); 62 err = sock_diag_destroy(sk, ECONNABORTED);
63
64 sock_gen_put(sk);
65
66 return err;
62} 67}
63#endif 68#endif
64 69
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 32b048e524d6..7158d4f8dae4 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -814,8 +814,14 @@ static void tcp_v4_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
814 u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 : 814 u32 seq = (sk->sk_state == TCP_LISTEN) ? tcp_rsk(req)->snt_isn + 1 :
815 tcp_sk(sk)->snd_nxt; 815 tcp_sk(sk)->snd_nxt;
816 816
817 /* RFC 7323 2.3
818 * The window field (SEG.WND) of every outgoing segment, with the
819 * exception of <SYN> segments, MUST be right-shifted by
820 * Rcv.Wind.Shift bits:
821 */
817 tcp_v4_send_ack(sock_net(sk), skb, seq, 822 tcp_v4_send_ack(sock_net(sk), skb, seq,
818 tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, 823 tcp_rsk(req)->rcv_nxt,
824 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
819 tcp_time_stamp, 825 tcp_time_stamp,
820 req->ts_recent, 826 req->ts_recent,
821 0, 827 0,
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e61f7cd65d08..5fdcb8d108d4 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1182,13 +1182,13 @@ out:
1182 * @sk: socket 1182 * @sk: socket
1183 * 1183 *
1184 * Drops all bad checksum frames, until a valid one is found. 1184 * Drops all bad checksum frames, until a valid one is found.
1185 * Returns the length of found skb, or 0 if none is found. 1185 * Returns the length of found skb, or -1 if none is found.
1186 */ 1186 */
1187static unsigned int first_packet_length(struct sock *sk) 1187static int first_packet_length(struct sock *sk)
1188{ 1188{
1189 struct sk_buff_head list_kill, *rcvq = &sk->sk_receive_queue; 1189 struct sk_buff_head list_kill, *rcvq = &sk->sk_receive_queue;
1190 struct sk_buff *skb; 1190 struct sk_buff *skb;
1191 unsigned int res; 1191 int res;
1192 1192
1193 __skb_queue_head_init(&list_kill); 1193 __skb_queue_head_init(&list_kill);
1194 1194
@@ -1203,7 +1203,7 @@ static unsigned int first_packet_length(struct sock *sk)
1203 __skb_unlink(skb, rcvq); 1203 __skb_unlink(skb, rcvq);
1204 __skb_queue_tail(&list_kill, skb); 1204 __skb_queue_tail(&list_kill, skb);
1205 } 1205 }
1206 res = skb ? skb->len : 0; 1206 res = skb ? skb->len : -1;
1207 spin_unlock_bh(&rcvq->lock); 1207 spin_unlock_bh(&rcvq->lock);
1208 1208
1209 if (!skb_queue_empty(&list_kill)) { 1209 if (!skb_queue_empty(&list_kill)) {
@@ -1232,7 +1232,7 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
1232 1232
1233 case SIOCINQ: 1233 case SIOCINQ:
1234 { 1234 {
1235 unsigned int amount = first_packet_length(sk); 1235 int amount = max_t(int, 0, first_packet_length(sk));
1236 1236
1237 return put_user(amount, (int __user *)arg); 1237 return put_user(amount, (int __user *)arg);
1238 } 1238 }
@@ -2184,7 +2184,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
2184 2184
2185 /* Check for false positives due to checksum errors */ 2185 /* Check for false positives due to checksum errors */
2186 if ((mask & POLLRDNORM) && !(file->f_flags & O_NONBLOCK) && 2186 if ((mask & POLLRDNORM) && !(file->f_flags & O_NONBLOCK) &&
2187 !(sk->sk_shutdown & RCV_SHUTDOWN) && !first_packet_length(sk)) 2187 !(sk->sk_shutdown & RCV_SHUTDOWN) && first_packet_length(sk) == -1)
2188 mask &= ~(POLLIN | POLLRDNORM); 2188 mask &= ~(POLLIN | POLLRDNORM);
2189 2189
2190 return mask; 2190 return mask;
@@ -2216,7 +2216,6 @@ struct proto udp_prot = {
2216 .sysctl_wmem = &sysctl_udp_wmem_min, 2216 .sysctl_wmem = &sysctl_udp_wmem_min,
2217 .sysctl_rmem = &sysctl_udp_rmem_min, 2217 .sysctl_rmem = &sysctl_udp_rmem_min,
2218 .obj_size = sizeof(struct udp_sock), 2218 .obj_size = sizeof(struct udp_sock),
2219 .slab_flags = SLAB_DESTROY_BY_RCU,
2220 .h.udp_table = &udp_table, 2219 .h.udp_table = &udp_table,
2221#ifdef CONFIG_COMPAT 2220#ifdef CONFIG_COMPAT
2222 .compat_setsockopt = compat_udp_setsockopt, 2221 .compat_setsockopt = compat_udp_setsockopt,
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 3b3efbda48e1..2eea073e27ef 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -55,7 +55,6 @@ struct proto udplite_prot = {
55 .unhash = udp_lib_unhash, 55 .unhash = udp_lib_unhash,
56 .get_port = udp_v4_get_port, 56 .get_port = udp_v4_get_port,
57 .obj_size = sizeof(struct udp_sock), 57 .obj_size = sizeof(struct udp_sock),
58 .slab_flags = SLAB_DESTROY_BY_RCU,
59 .h.udp_table = &udplite_table, 58 .h.udp_table = &udplite_table,
60#ifdef CONFIG_COMPAT 59#ifdef CONFIG_COMPAT
61 .compat_setsockopt = compat_udp_setsockopt, 60 .compat_setsockopt = compat_udp_setsockopt,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index df8425fcbc2c..f418d2eaeddd 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1872,7 +1872,6 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp)
1872 1872
1873void addrconf_dad_failure(struct inet6_ifaddr *ifp) 1873void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1874{ 1874{
1875 struct in6_addr addr;
1876 struct inet6_dev *idev = ifp->idev; 1875 struct inet6_dev *idev = ifp->idev;
1877 struct net *net = dev_net(ifp->idev->dev); 1876 struct net *net = dev_net(ifp->idev->dev);
1878 1877
@@ -1934,18 +1933,6 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1934 in6_ifa_put(ifp2); 1933 in6_ifa_put(ifp2);
1935lock_errdad: 1934lock_errdad:
1936 spin_lock_bh(&ifp->lock); 1935 spin_lock_bh(&ifp->lock);
1937 } else if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1938 addr.s6_addr32[0] = htonl(0xfe800000);
1939 addr.s6_addr32[1] = 0;
1940
1941 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
1942 ipv6_addr_equal(&ifp->addr, &addr)) {
1943 /* DAD failed for link-local based on MAC address */
1944 idev->cnf.disable_ipv6 = 1;
1945
1946 pr_info("%s: IPv6 being disabled!\n",
1947 ifp->idev->dev->name);
1948 }
1949 } 1936 }
1950 1937
1951errdad: 1938errdad:
@@ -3821,6 +3808,7 @@ static void addrconf_dad_work(struct work_struct *w)
3821 dad_work); 3808 dad_work);
3822 struct inet6_dev *idev = ifp->idev; 3809 struct inet6_dev *idev = ifp->idev;
3823 struct in6_addr mcaddr; 3810 struct in6_addr mcaddr;
3811 bool disable_ipv6 = false;
3824 3812
3825 enum { 3813 enum {
3826 DAD_PROCESS, 3814 DAD_PROCESS,
@@ -3837,6 +3825,24 @@ static void addrconf_dad_work(struct work_struct *w)
3837 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { 3825 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) {
3838 action = DAD_ABORT; 3826 action = DAD_ABORT;
3839 ifp->state = INET6_IFADDR_STATE_POSTDAD; 3827 ifp->state = INET6_IFADDR_STATE_POSTDAD;
3828
3829 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6 &&
3830 !(ifp->flags & IFA_F_STABLE_PRIVACY)) {
3831 struct in6_addr addr;
3832
3833 addr.s6_addr32[0] = htonl(0xfe800000);
3834 addr.s6_addr32[1] = 0;
3835
3836 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
3837 ipv6_addr_equal(&ifp->addr, &addr)) {
3838 /* DAD failed for link-local based on MAC */
3839 idev->cnf.disable_ipv6 = 1;
3840
3841 pr_info("%s: IPv6 being disabled!\n",
3842 ifp->idev->dev->name);
3843 disable_ipv6 = true;
3844 }
3845 }
3840 } 3846 }
3841 spin_unlock_bh(&ifp->lock); 3847 spin_unlock_bh(&ifp->lock);
3842 3848
@@ -3845,6 +3851,8 @@ static void addrconf_dad_work(struct work_struct *w)
3845 goto out; 3851 goto out;
3846 } else if (action == DAD_ABORT) { 3852 } else if (action == DAD_ABORT) {
3847 addrconf_dad_stop(ifp, 1); 3853 addrconf_dad_stop(ifp, 1);
3854 if (disable_ipv6)
3855 addrconf_ifdown(idev->dev, 0);
3848 goto out; 3856 goto out;
3849 } 3857 }
3850 3858
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 33df8b8575cc..94f4f89d73e7 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -944,9 +944,15 @@ static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
944 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV 944 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV
945 * sk->sk_state == TCP_SYN_RECV -> for Fast Open. 945 * sk->sk_state == TCP_SYN_RECV -> for Fast Open.
946 */ 946 */
947 /* RFC 7323 2.3
948 * The window field (SEG.WND) of every outgoing segment, with the
949 * exception of <SYN> segments, MUST be right-shifted by
950 * Rcv.Wind.Shift bits:
951 */
947 tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ? 952 tcp_v6_send_ack(sk, skb, (sk->sk_state == TCP_LISTEN) ?
948 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt, 953 tcp_rsk(req)->snt_isn + 1 : tcp_sk(sk)->snd_nxt,
949 tcp_rsk(req)->rcv_nxt, req->rsk_rcv_wnd, 954 tcp_rsk(req)->rcv_nxt,
955 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
950 tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if, 956 tcp_time_stamp, req->ts_recent, sk->sk_bound_dev_if,
951 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr), 957 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr),
952 0, 0); 958 0, 0);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 81e2f98b958d..19ac3a1c308d 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1460,7 +1460,6 @@ struct proto udpv6_prot = {
1460 .sysctl_wmem = &sysctl_udp_wmem_min, 1460 .sysctl_wmem = &sysctl_udp_wmem_min,
1461 .sysctl_rmem = &sysctl_udp_rmem_min, 1461 .sysctl_rmem = &sysctl_udp_rmem_min,
1462 .obj_size = sizeof(struct udp6_sock), 1462 .obj_size = sizeof(struct udp6_sock),
1463 .slab_flags = SLAB_DESTROY_BY_RCU,
1464 .h.udp_table = &udp_table, 1463 .h.udp_table = &udp_table,
1465#ifdef CONFIG_COMPAT 1464#ifdef CONFIG_COMPAT
1466 .compat_setsockopt = compat_udpv6_setsockopt, 1465 .compat_setsockopt = compat_udpv6_setsockopt,
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 9cf097e206e9..fd6ef414899b 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -50,7 +50,6 @@ struct proto udplitev6_prot = {
50 .unhash = udp_lib_unhash, 50 .unhash = udp_lib_unhash,
51 .get_port = udp_v6_get_port, 51 .get_port = udp_v6_get_port,
52 .obj_size = sizeof(struct udp6_sock), 52 .obj_size = sizeof(struct udp6_sock),
53 .slab_flags = SLAB_DESTROY_BY_RCU,
54 .h.udp_table = &udplite_table, 53 .h.udp_table = &udplite_table,
55#ifdef CONFIG_COMPAT 54#ifdef CONFIG_COMPAT
56 .compat_setsockopt = compat_udpv6_setsockopt, 55 .compat_setsockopt = compat_udpv6_setsockopt,
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index d9560aa2dba3..232cb92033e8 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -856,7 +856,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
856 error = -ENOTCONN; 856 error = -ENOTCONN;
857 if (sk == NULL) 857 if (sk == NULL)
858 goto end; 858 goto end;
859 if (sk->sk_state != PPPOX_CONNECTED) 859 if (!(sk->sk_state & PPPOX_CONNECTED))
860 goto end; 860 goto end;
861 861
862 error = -EBADF; 862 error = -EBADF;
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 958a1455ca7f..9f267c3ffb39 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -205,6 +205,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
205 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash); 205 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash);
206 const struct nf_conntrack_l3proto *l3proto; 206 const struct nf_conntrack_l3proto *l3proto;
207 const struct nf_conntrack_l4proto *l4proto; 207 const struct nf_conntrack_l4proto *l4proto;
208 struct net *net = seq_file_net(s);
208 int ret = 0; 209 int ret = 0;
209 210
210 NF_CT_ASSERT(ct); 211 NF_CT_ASSERT(ct);
@@ -215,6 +216,9 @@ static int ct_seq_show(struct seq_file *s, void *v)
215 if (NF_CT_DIRECTION(hash)) 216 if (NF_CT_DIRECTION(hash))
216 goto release; 217 goto release;
217 218
219 if (!net_eq(nf_ct_net(ct), net))
220 goto release;
221
218 l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct)); 222 l3proto = __nf_ct_l3proto_find(nf_ct_l3num(ct));
219 NF_CT_ASSERT(l3proto); 223 NF_CT_ASSERT(l3proto);
220 l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct)); 224 l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index 1b4de4bd6958..70eb2f6a3b01 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -326,14 +326,14 @@ static int nfnl_acct_try_del(struct nf_acct *cur)
326{ 326{
327 int ret = 0; 327 int ret = 0;
328 328
329 /* we want to avoid races with nfnl_acct_find_get. */ 329 /* We want to avoid races with nfnl_acct_put. So only when the current
330 if (atomic_dec_and_test(&cur->refcnt)) { 330 * refcnt is 1, we decrease it to 0.
331 */
332 if (atomic_cmpxchg(&cur->refcnt, 1, 0) == 1) {
331 /* We are protected by nfnl mutex. */ 333 /* We are protected by nfnl mutex. */
332 list_del_rcu(&cur->head); 334 list_del_rcu(&cur->head);
333 kfree_rcu(cur, rcu_head); 335 kfree_rcu(cur, rcu_head);
334 } else { 336 } else {
335 /* still in use, restore reference counter. */
336 atomic_inc(&cur->refcnt);
337 ret = -EBUSY; 337 ret = -EBUSY;
338 } 338 }
339 return ret; 339 return ret;
@@ -443,7 +443,7 @@ void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct)
443} 443}
444EXPORT_SYMBOL_GPL(nfnl_acct_update); 444EXPORT_SYMBOL_GPL(nfnl_acct_update);
445 445
446static void nfnl_overquota_report(struct nf_acct *nfacct) 446static void nfnl_overquota_report(struct net *net, struct nf_acct *nfacct)
447{ 447{
448 int ret; 448 int ret;
449 struct sk_buff *skb; 449 struct sk_buff *skb;
@@ -458,11 +458,12 @@ static void nfnl_overquota_report(struct nf_acct *nfacct)
458 kfree_skb(skb); 458 kfree_skb(skb);
459 return; 459 return;
460 } 460 }
461 netlink_broadcast(init_net.nfnl, skb, 0, NFNLGRP_ACCT_QUOTA, 461 netlink_broadcast(net->nfnl, skb, 0, NFNLGRP_ACCT_QUOTA,
462 GFP_ATOMIC); 462 GFP_ATOMIC);
463} 463}
464 464
465int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct) 465int nfnl_acct_overquota(struct net *net, const struct sk_buff *skb,
466 struct nf_acct *nfacct)
466{ 467{
467 u64 now; 468 u64 now;
468 u64 *quota; 469 u64 *quota;
@@ -480,7 +481,7 @@ int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
480 481
481 if (now >= *quota && 482 if (now >= *quota &&
482 !test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) { 483 !test_and_set_bit(NFACCT_OVERQUOTA_BIT, &nfacct->flags)) {
483 nfnl_overquota_report(nfacct); 484 nfnl_overquota_report(net, nfacct);
484 } 485 }
485 486
486 return ret; 487 return ret;
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 4cdcd969b64c..68216cdc7083 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -330,16 +330,16 @@ static int ctnl_timeout_try_del(struct net *net, struct ctnl_timeout *timeout)
330{ 330{
331 int ret = 0; 331 int ret = 0;
332 332
333 /* we want to avoid races with nf_ct_timeout_find_get. */ 333 /* We want to avoid races with ctnl_timeout_put. So only when the
334 if (atomic_dec_and_test(&timeout->refcnt)) { 334 * current refcnt is 1, we decrease it to 0.
335 */
336 if (atomic_cmpxchg(&timeout->refcnt, 1, 0) == 1) {
335 /* We are protected by nfnl mutex. */ 337 /* We are protected by nfnl mutex. */
336 list_del_rcu(&timeout->head); 338 list_del_rcu(&timeout->head);
337 nf_ct_l4proto_put(timeout->l4proto); 339 nf_ct_l4proto_put(timeout->l4proto);
338 ctnl_untimeout(net, timeout); 340 ctnl_untimeout(net, timeout);
339 kfree_rcu(timeout, rcu_head); 341 kfree_rcu(timeout, rcu_head);
340 } else { 342 } else {
341 /* still in use, restore reference counter. */
342 atomic_inc(&timeout->refcnt);
343 ret = -EBUSY; 343 ret = -EBUSY;
344 } 344 }
345 return ret; 345 return ret;
@@ -543,7 +543,9 @@ err:
543 543
544static void ctnl_timeout_put(struct ctnl_timeout *timeout) 544static void ctnl_timeout_put(struct ctnl_timeout *timeout)
545{ 545{
546 atomic_dec(&timeout->refcnt); 546 if (atomic_dec_and_test(&timeout->refcnt))
547 kfree_rcu(timeout, rcu_head);
548
547 module_put(THIS_MODULE); 549 module_put(THIS_MODULE);
548} 550}
549#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ 551#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
@@ -591,7 +593,9 @@ static void __net_exit cttimeout_net_exit(struct net *net)
591 list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) { 593 list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list, head) {
592 list_del_rcu(&cur->head); 594 list_del_rcu(&cur->head);
593 nf_ct_l4proto_put(cur->l4proto); 595 nf_ct_l4proto_put(cur->l4proto);
594 kfree_rcu(cur, rcu_head); 596
597 if (atomic_dec_and_test(&cur->refcnt))
598 kfree_rcu(cur, rcu_head);
595 } 599 }
596} 600}
597 601
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index cbcfdfb586a6..6577db524ef6 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -1147,6 +1147,7 @@ MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_ULOG);
1147MODULE_ALIAS_NF_LOGGER(AF_INET, 1); 1147MODULE_ALIAS_NF_LOGGER(AF_INET, 1);
1148MODULE_ALIAS_NF_LOGGER(AF_INET6, 1); 1148MODULE_ALIAS_NF_LOGGER(AF_INET6, 1);
1149MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 1); 1149MODULE_ALIAS_NF_LOGGER(AF_BRIDGE, 1);
1150MODULE_ALIAS_NF_LOGGER(3, 1); /* NFPROTO_ARP */
1150 1151
1151module_init(nfnetlink_log_init); 1152module_init(nfnetlink_log_init);
1152module_exit(nfnetlink_log_fini); 1153module_exit(nfnetlink_log_fini);
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
index 7f4414d26a66..663c4c3c9072 100644
--- a/net/netfilter/xt_TPROXY.c
+++ b/net/netfilter/xt_TPROXY.c
@@ -127,6 +127,8 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
127 daddr, dport, 127 daddr, dport,
128 in->ifindex); 128 in->ifindex);
129 129
130 if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
131 sk = NULL;
130 /* NOTE: we return listeners even if bound to 132 /* NOTE: we return listeners even if bound to
131 * 0.0.0.0, those are filtered out in 133 * 0.0.0.0, those are filtered out in
132 * xt_socket, since xt_TPROXY needs 0 bound 134 * xt_socket, since xt_TPROXY needs 0 bound
@@ -195,6 +197,8 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
195 daddr, ntohs(dport), 197 daddr, ntohs(dport),
196 in->ifindex); 198 in->ifindex);
197 199
200 if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
201 sk = NULL;
198 /* NOTE: we return listeners even if bound to 202 /* NOTE: we return listeners even if bound to
199 * 0.0.0.0, those are filtered out in 203 * 0.0.0.0, those are filtered out in
200 * xt_socket, since xt_TPROXY needs 0 bound 204 * xt_socket, since xt_TPROXY needs 0 bound
diff --git a/net/netfilter/xt_nfacct.c b/net/netfilter/xt_nfacct.c
index 3048a7e3a90a..cf327593852a 100644
--- a/net/netfilter/xt_nfacct.c
+++ b/net/netfilter/xt_nfacct.c
@@ -26,7 +26,7 @@ static bool nfacct_mt(const struct sk_buff *skb, struct xt_action_param *par)
26 26
27 nfnl_acct_update(skb, info->nfacct); 27 nfnl_acct_update(skb, info->nfacct);
28 28
29 overquota = nfnl_acct_overquota(skb, info->nfacct); 29 overquota = nfnl_acct_overquota(par->net, skb, info->nfacct);
30 30
31 return overquota == NFACCT_UNDERQUOTA ? false : true; 31 return overquota == NFACCT_UNDERQUOTA ? false : true;
32} 32}
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 141a06eeb1e5..e87cd81315e1 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -53,7 +53,7 @@ int ife_tlv_meta_encode(void *skbdata, u16 attrtype, u16 dlen, const void *dval)
53 u32 *tlv = (u32 *)(skbdata); 53 u32 *tlv = (u32 *)(skbdata);
54 u16 totlen = nla_total_size(dlen); /*alignment + hdr */ 54 u16 totlen = nla_total_size(dlen); /*alignment + hdr */
55 char *dptr = (char *)tlv + NLA_HDRLEN; 55 char *dptr = (char *)tlv + NLA_HDRLEN;
56 u32 htlv = attrtype << 16 | totlen; 56 u32 htlv = attrtype << 16 | dlen;
57 57
58 *tlv = htonl(htlv); 58 *tlv = htonl(htlv);
59 memset(dptr, 0, totlen - NLA_HDRLEN); 59 memset(dptr, 0, totlen - NLA_HDRLEN);
@@ -135,7 +135,7 @@ EXPORT_SYMBOL_GPL(ife_release_meta_gen);
135 135
136int ife_validate_meta_u32(void *val, int len) 136int ife_validate_meta_u32(void *val, int len)
137{ 137{
138 if (len == 4) 138 if (len == sizeof(u32))
139 return 0; 139 return 0;
140 140
141 return -EINVAL; 141 return -EINVAL;
@@ -144,8 +144,8 @@ EXPORT_SYMBOL_GPL(ife_validate_meta_u32);
144 144
145int ife_validate_meta_u16(void *val, int len) 145int ife_validate_meta_u16(void *val, int len)
146{ 146{
147 /* length will include padding */ 147 /* length will not include padding */
148 if (len == NLA_ALIGN(2)) 148 if (len == sizeof(u16))
149 return 0; 149 return 0;
150 150
151 return -EINVAL; 151 return -EINVAL;
@@ -652,12 +652,14 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
652 u8 *tlvdata = (u8 *)tlv; 652 u8 *tlvdata = (u8 *)tlv;
653 u16 mtype = tlv->type; 653 u16 mtype = tlv->type;
654 u16 mlen = tlv->len; 654 u16 mlen = tlv->len;
655 u16 alen;
655 656
656 mtype = ntohs(mtype); 657 mtype = ntohs(mtype);
657 mlen = ntohs(mlen); 658 mlen = ntohs(mlen);
659 alen = NLA_ALIGN(mlen);
658 660
659 if (find_decode_metaid(skb, ife, mtype, (mlen - 4), 661 if (find_decode_metaid(skb, ife, mtype, (mlen - NLA_HDRLEN),
660 (void *)(tlvdata + 4))) { 662 (void *)(tlvdata + NLA_HDRLEN))) {
661 /* abuse overlimits to count when we receive metadata 663 /* abuse overlimits to count when we receive metadata
662 * but dont have an ops for it 664 * but dont have an ops for it
663 */ 665 */
@@ -666,8 +668,8 @@ static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a,
666 ife->tcf_qstats.overlimits++; 668 ife->tcf_qstats.overlimits++;
667 } 669 }
668 670
669 tlvdata += mlen; 671 tlvdata += alen;
670 ifehdrln -= mlen; 672 ifehdrln -= alen;
671 tlv = (struct meta_tlvhdr *)tlvdata; 673 tlv = (struct meta_tlvhdr *)tlvdata;
672 } 674 }
673 675
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index e95b67cd5718..657c13362b19 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -643,18 +643,19 @@ struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
643 struct Qdisc *sch; 643 struct Qdisc *sch;
644 644
645 if (!try_module_get(ops->owner)) 645 if (!try_module_get(ops->owner))
646 goto errout; 646 return NULL;
647 647
648 sch = qdisc_alloc(dev_queue, ops); 648 sch = qdisc_alloc(dev_queue, ops);
649 if (IS_ERR(sch)) 649 if (IS_ERR(sch)) {
650 goto errout; 650 module_put(ops->owner);
651 return NULL;
652 }
651 sch->parent = parentid; 653 sch->parent = parentid;
652 654
653 if (!ops->init || ops->init(sch, NULL) == 0) 655 if (!ops->init || ops->init(sch, NULL) == 0)
654 return sch; 656 return sch;
655 657
656 qdisc_destroy(sch); 658 qdisc_destroy(sch);
657errout:
658 return NULL; 659 return NULL;
659} 660}
660EXPORT_SYMBOL(qdisc_create_dflt); 661EXPORT_SYMBOL(qdisc_create_dflt);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index c182db7d691f..69444d32ecda 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -119,7 +119,13 @@ int sctp_rcv(struct sk_buff *skb)
119 skb_transport_offset(skb)) 119 skb_transport_offset(skb))
120 goto discard_it; 120 goto discard_it;
121 121
122 if (!pskb_may_pull(skb, sizeof(struct sctphdr))) 122 /* If the packet is fragmented and we need to do crc checking,
123 * it's better to just linearize it otherwise crc computing
124 * takes longer.
125 */
126 if ((!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) &&
127 skb_linearize(skb)) ||
128 !pskb_may_pull(skb, sizeof(struct sctphdr)))
123 goto discard_it; 129 goto discard_it;
124 130
125 /* Pull up the IP header. */ 131 /* Pull up the IP header. */
@@ -1177,9 +1183,6 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net,
1177 if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) 1183 if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP)
1178 return NULL; 1184 return NULL;
1179 1185
1180 if (skb_linearize(skb))
1181 return NULL;
1182
1183 ch = (sctp_chunkhdr_t *) skb->data; 1186 ch = (sctp_chunkhdr_t *) skb->data;
1184 1187
1185 /* The code below will attempt to walk the chunk and extract 1188 /* The code below will attempt to walk the chunk and extract
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c
index c30ddb0f3190..6437aa97cfd7 100644
--- a/net/sctp/inqueue.c
+++ b/net/sctp/inqueue.c
@@ -170,19 +170,6 @@ next_chunk:
170 170
171 chunk = list_entry(entry, struct sctp_chunk, list); 171 chunk = list_entry(entry, struct sctp_chunk, list);
172 172
173 /* Linearize if it's not GSO */
174 if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) != SKB_GSO_SCTP &&
175 skb_is_nonlinear(chunk->skb)) {
176 if (skb_linearize(chunk->skb)) {
177 __SCTP_INC_STATS(dev_net(chunk->skb->dev), SCTP_MIB_IN_PKT_DISCARDS);
178 sctp_chunk_free(chunk);
179 goto next_chunk;
180 }
181
182 /* Update sctp_hdr as it probably changed */
183 chunk->sctp_hdr = sctp_hdr(chunk->skb);
184 }
185
186 if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { 173 if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) {
187 /* GSO-marked skbs but without frags, handle 174 /* GSO-marked skbs but without frags, handle
188 * them normally 175 * them normally
diff --git a/net/sctp/sctp_diag.c b/net/sctp/sctp_diag.c
index bb691538adc8..f3508aa75815 100644
--- a/net/sctp/sctp_diag.c
+++ b/net/sctp/sctp_diag.c
@@ -424,11 +424,13 @@ static int sctp_diag_dump_one(struct sk_buff *in_skb,
424 paddr.v4.sin_family = AF_INET; 424 paddr.v4.sin_family = AF_INET;
425 } else { 425 } else {
426 laddr.v6.sin6_port = req->id.idiag_sport; 426 laddr.v6.sin6_port = req->id.idiag_sport;
427 memcpy(&laddr.v6.sin6_addr, req->id.idiag_src, 64); 427 memcpy(&laddr.v6.sin6_addr, req->id.idiag_src,
428 sizeof(laddr.v6.sin6_addr));
428 laddr.v6.sin6_family = AF_INET6; 429 laddr.v6.sin6_family = AF_INET6;
429 430
430 paddr.v6.sin6_port = req->id.idiag_dport; 431 paddr.v6.sin6_port = req->id.idiag_dport;
431 memcpy(&paddr.v6.sin6_addr, req->id.idiag_dst, 64); 432 memcpy(&paddr.v6.sin6_addr, req->id.idiag_dst,
433 sizeof(paddr.v6.sin6_addr));
432 paddr.v6.sin6_family = AF_INET6; 434 paddr.v6.sin6_family = AF_INET6;
433 } 435 }
434 436
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 7f79fb7dc6a0..66f23b376fa0 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -453,7 +453,7 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
453 struct rpc_xprt_switch *xps; 453 struct rpc_xprt_switch *xps;
454 454
455 if (args->bc_xprt && args->bc_xprt->xpt_bc_xps) { 455 if (args->bc_xprt && args->bc_xprt->xpt_bc_xps) {
456 WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP); 456 WARN_ON_ONCE(!(args->protocol & XPRT_TRANSPORT_BC));
457 xps = args->bc_xprt->xpt_bc_xps; 457 xps = args->bc_xprt->xpt_bc_xps;
458 xprt_switch_get(xps); 458 xprt_switch_get(xps);
459 } else { 459 } else {
@@ -520,7 +520,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
520 char servername[48]; 520 char servername[48];
521 521
522 if (args->bc_xprt) { 522 if (args->bc_xprt) {
523 WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP); 523 WARN_ON_ONCE(!(args->protocol & XPRT_TRANSPORT_BC));
524 xprt = args->bc_xprt->xpt_bc_xprt; 524 xprt = args->bc_xprt->xpt_bc_xprt;
525 if (xprt) { 525 if (xprt) {
526 xprt_get(xprt); 526 xprt_get(xprt);
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index b016c011970b..ae7e14cae085 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -396,10 +396,13 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
396 tuncfg.encap_destroy = NULL; 396 tuncfg.encap_destroy = NULL;
397 setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg); 397 setup_udp_tunnel_sock(net, ub->ubsock, &tuncfg);
398 398
399 if (enable_mcast(ub, remote)) 399 err = enable_mcast(ub, remote);
400 if (err)
400 goto err; 401 goto err;
401 return 0; 402 return 0;
402err: 403err:
404 if (ub->ubsock)
405 udp_tunnel_sock_release(ub->ubsock);
403 kfree(ub); 406 kfree(ub);
404 return err; 407 return err;
405} 408}
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4de3cc42fc50..206a6b346a8d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3570,15 +3570,6 @@ sub process {
3570 } 3570 }
3571 } 3571 }
3572 3572
3573# check for uses of DEFINE_PCI_DEVICE_TABLE
3574 if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) {
3575 if (WARN("DEFINE_PCI_DEVICE_TABLE",
3576 "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) &&
3577 $fix) {
3578 $fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /;
3579 }
3580 }
3581
3582# check for new typedefs, only function parameters and sparse annotations 3573# check for new typedefs, only function parameters and sparse annotations
3583# make sense. 3574# make sense.
3584 if ($line =~ /\btypedef\s/ && 3575 if ($line =~ /\btypedef\s/ &&
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index e1c09e2f9be7..8ea9fd2b6573 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -332,7 +332,9 @@ if grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then
332 (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" 332 (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles"
333fi 333fi
334(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" 334(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles"
335(cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" 335if grep -q '^CONFIG_GCC_PLUGINS=y' $KCONFIG_CONFIG ; then
336 (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles"
337fi
336destdir=$kernel_headers_dir/usr/src/linux-headers-$version 338destdir=$kernel_headers_dir/usr/src/linux-headers-$version
337mkdir -p "$destdir" 339mkdir -p "$destdir"
338(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) 340(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -)
diff --git a/scripts/tags.sh b/scripts/tags.sh
index ed7eef24ef89..b3775a9604ea 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -206,7 +206,6 @@ regex_c=(
206 '/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/' 206 '/\<DEFINE_PER_CPU_SHARED_ALIGNED([^,]*, *\([[:alnum:]_]*\)/\1/v/'
207 '/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/' 207 '/\<DECLARE_WAIT_QUEUE_HEAD(\([[:alnum:]_]*\)/\1/v/'
208 '/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/' 208 '/\<DECLARE_\(TASKLET\|WORK\|DELAYED_WORK\)(\([[:alnum:]_]*\)/\2/v/'
209 '/\<DEFINE_PCI_DEVICE_TABLE(\([[:alnum:]_]*\)/\1/v/'
210 '/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/' 209 '/\(^\s\)OFFSET(\([[:alnum:]_]*\)/\2/v/'
211 '/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/' 210 '/\(^\s\)DEFINE(\([[:alnum:]_]*\)/\2/v/'
212 '/\<DEFINE_HASHTABLE(\([[:alnum:]_]*\)/\1/v/' 211 '/\<DEFINE_HASHTABLE(\([[:alnum:]_]*\)/\1/v/'
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0e8a1f7a292d..ae68bf0e2d51 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
348 int notrigger = 0; 348 int notrigger = 0;
349 char *dummy; 349 char *dummy;
350 350
351 struct iio_channel_info *channels; 351 struct iio_channel_info *channels = NULL;
352 352
353 register_cleanup(); 353 register_cleanup();
354 354